From e11fe9853a1920efe386923f4feeb91eb3a39b82 Mon Sep 17 00:00:00 2001 From: dgis Date: Wed, 21 Nov 2018 21:16:39 +0000 Subject: [PATCH] --- app/CMakeLists.txt | 12 ++-- app/src/main/cpp/win32-layer.c | 103 ++++++++++++++++++++++++++++++++- app/src/main/cpp/win32-layer.h | 95 +++++++++++++++++++++++++----- 3 files changed, 187 insertions(+), 23 deletions(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index cd2990a..2ad7e25 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -34,11 +34,11 @@ add_library( # Sets the name of the library. src/main/cpp/engine.c src/main/cpp/external.c src/main/cpp/fetch.c - src/main/cpp/files.c + src/main/cpp/files.c #TODO src/main/cpp/i28f160.c src/main/cpp/keyboard.c # src/main/cpp/keymacro.c - src/main/cpp/kml.c + src/main/cpp/kml.c #TODO src/main/cpp/lodepng.c src/main/cpp/lowbat.c src/main/cpp/mops.c @@ -48,13 +48,13 @@ add_library( # Sets the name of the library. # src/main/cpp/redeye.c src/main/cpp/rpl.c # src/main/cpp/serial.c - src/main/cpp/settings.c + src/main/cpp/settings.c #TODO # src/main/cpp/sndenum.c # src/main/cpp/sound.c src/main/cpp/stack.c - src/main/cpp/symbfile.c - src/main/cpp/timer.c - src/main/cpp/udp.c + src/main/cpp/symbfile.c #TODO + src/main/cpp/timer.c #TODO + src/main/cpp/udp.c #TODO src/main/cpp/emu48-jni.c diff --git a/app/src/main/cpp/win32-layer.c b/app/src/main/cpp/win32-layer.c index f5ef127..c62bc9f 100644 --- a/app/src/main/cpp/win32-layer.c +++ b/app/src/main/cpp/win32-layer.c @@ -416,17 +416,114 @@ BOOL GetSystemPowerStatus(LPSYSTEM_POWER_STATUS status) } -// file.c - BOOL GetWindowPlacement(HWND hWnd, WINDOWPLACEMENT *lpwndpl) { return 0; } + + +HANDLE WINAPI CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId) { + //TODO + return NULL; +} + +BOOL WINAPI CloseHandle(HANDLE hObject) { + //TODO + // Can be a thread/event/file hande! + return 0; +} + +BOOL WINAPI MessageBeep(UINT uType) { + //TODO System beep + return 1; +} + +HGLOBAL WINAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes) { + //TODO + return NULL; +} +LPVOID WINAPI GlobalLock (HGLOBAL hMem) { + //TODO + return NULL; +} + +BOOL WINAPI GlobalUnlock(HGLOBAL hMem) { + //TODO + return 0; +} + +BOOL WINAPI OpenClipboard(HWND hWndNewOwner) { + //TODO + return 0; +} +BOOL WINAPI CloseClipboard(VOID) { + //TODO + return 0; +} + +BOOL WINAPI EmptyClipboard(VOID) { + //TODO + return 0; +} + +HANDLE WINAPI SetClipboardData(UINT uFormat,HANDLE hMem) { + //TODO + return NULL; +} + +BOOL WINAPI IsClipboardFormatAvailable(UINT format) { + //TODO + return 0; +} + +HANDLE WINAPI GetClipboardData(UINT uFormat) { + //TODO + return NULL; +} + +HGLOBAL WINAPI GlobalFree(HGLOBAL hMem) { + //TODO + return NULL; +} + + + +#ifdef UNICODE + + +int WINAPI wvsprintf(LPWSTR, LPCWSTR, va_list arglist) { + return vswprintf(arg1, MAX_PATH, arg2, arglist); +} DWORD GetFullPathName(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR* lpFilePart) { return 0; } -void __cdecl _wsplitpath(wchar_t const* _FullPath, wchar_t* _Drive, wchar_t* _Dir, wchar_t* _Filename, wchar_t* _Ext) {} LPWSTR lstrcpyn(LPWSTR lpString1, LPCWSTR lpString2,int iMaxLength) { return strcpy(lpString1, lpString2); } LPWSTR lstrcat(LPWSTR lpString1, LPCWSTR lpString2) { return NULL; } +void __cdecl _wsplitpath(wchar_t const* _FullPath, wchar_t* _Drive, wchar_t* _Dir, wchar_t* _Filename, wchar_t* _Ext) {} +int WINAPI lstrcmp(LPCWSTR lpString1, LPCWSTR lpString2) { + return wcscmp(lpString1, lpString2); +} + +#else + +int WINAPI wvsprintf(LPSTR arg1, LPCSTR arg2, va_list arglist) { + return vsprintf(arg1, arg2, arglist); +} +DWORD GetFullPathName(LPCSTR lpFileName, DWORD nBufferLength, LPSTR lpBuffer, LPSTR* lpFilePart) { return 0; } +LPSTR lstrcpyn(LPSTR lpString1, LPCSTR lpString2,int iMaxLength) { + return strcpy(lpString1, lpString2); +} +LPSTR lstrcat(LPSTR lpString1, LPCSTR lpString2) { + return NULL; +} +void __cdecl _splitpath(char const* _FullPath, char* _Drive, char* _Dir, char* _Filename, char* _Ext) {} +int WINAPI lstrcmp(LPCSTR lpString1, LPCSTR lpString2) { + return strcmp(lpString1, lpString2); +} + + + +#endif // !UNICODE + void _wmakepath(wchar_t _Buffer, wchar_t const* _Drive, wchar_t const* _Dir, wchar_t const* _Filename, wchar_t const* _Ext) { } diff --git a/app/src/main/cpp/win32-layer.h b/app/src/main/cpp/win32-layer.h index 2345ed5..6e15ce8 100644 --- a/app/src/main/cpp/win32-layer.h +++ b/app/src/main/cpp/win32-layer.h @@ -20,6 +20,7 @@ typedef int64_t __int64; typedef unsigned char BYTE; typedef BYTE byte; typedef uint32_t DWORD; +typedef DWORD *LPDWORD; typedef BYTE *LPBYTE; typedef unsigned short WORD; typedef uint32_t UINT; @@ -72,11 +73,17 @@ typedef union _LARGE_INTEGER { }d; } LARGE_INTEGER, *PLARGE_INTEGER; -typedef char *LPTSTR ; -typedef char *LPSTR ; -typedef char LPCSTR[255] ; -typedef const char *LPCTSTR ; +typedef char *LPTSTR; +typedef char *LPSTR; +//typedef char LPCSTR[255]; +typedef const char *LPCSTR; +typedef const char *LPCTSTR; +#ifdef UNICODE +typedef wchar_t TCHAR; +#else typedef char TCHAR; +#endif // !UNICODE + typedef pthread_mutex_t CRITICAL_SECTION; typedef HANDLE HINSTANCE; @@ -340,7 +347,25 @@ extern void Sleep(int); extern BOOL GetSystemPowerStatus(LPSYSTEM_POWER_STATUS l); -//RC +typedef struct _SECURITY_ATTRIBUTES { + DWORD nLength; + LPVOID lpSecurityDescriptor; + BOOL bInheritHandle; +} SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES; +typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)( + LPVOID lpThreadParameter +); +typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE; +extern HANDLE WINAPI CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId); +extern BOOL WINAPI CloseHandle(HANDLE hObject); + + + + + + + + struct HRGN__ { int unused; }; typedef struct HRGN__ *HRGN; @@ -397,15 +422,57 @@ extern BOOL WINAPI SetWindowPlacement(HWND hWnd, CONST WINDOWPLACEMENT *lpwndpl) typedef wchar_t WCHAR; // wc, 16-bit UNICODE character typedef CONST WCHAR *LPCWSTR, *PCWSTR; typedef WCHAR *NWPSTR, *LPWSTR, *PWSTR; -extern DWORD WINAPI GetFullPathName(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR* lpFilePart); -extern void __cdecl _wsplitpath(wchar_t const* _FullPath, wchar_t* _Drive, wchar_t* _Dir, wchar_t* _Filename, wchar_t* _Ext); -#define _tsplitpath _wsplitpath -#define _tcschr wcschr -extern LPWSTR WINAPI lstrcpyn(LPWSTR lpString1, LPCWSTR lpString2,int iMaxLength); -extern LPWSTR WINAPI lstrcat(LPWSTR lpString1, LPCWSTR lpString2); -#define _tmakepath _wmakepath -extern void _wmakepath(wchar_t _Buffer, wchar_t const* _Drive, wchar_t const* _Dir, wchar_t const* _Filename, wchar_t const* _Ext); extern BOOL WINAPI GetClientRect(HWND hWnd, LPRECT lpRect); typedef char *PSZ; -typedef DWORD COLORREF; \ No newline at end of file +typedef DWORD COLORREF; + +extern BOOL WINAPI MessageBeep(UINT uType); + +typedef HANDLE HGLOBAL; +#define GMEM_MOVEABLE 0x0002 +extern HGLOBAL WINAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes); +extern LPVOID WINAPI GlobalLock (HGLOBAL hMem); +extern BOOL WINAPI GlobalUnlock(HGLOBAL hMem); + +#define CF_TEXT 1 +extern BOOL WINAPI OpenClipboard(HWND hWndNewOwner); +extern BOOL WINAPI CloseClipboard(VOID); +extern BOOL WINAPI EmptyClipboard(VOID); +extern HANDLE WINAPI SetClipboardData(UINT uFormat,HANDLE hMem); +extern HGLOBAL WINAPI GlobalFree(HGLOBAL hMem); +extern BOOL WINAPI IsClipboardFormatAvailable(UINT format); +extern HANDLE WINAPI GetClipboardData(UINT uFormat); + +#ifdef UNICODE + +extern int WINAPI wvsprintf(LPWSTR, LPCWSTR, va_list arglist); +extern DWORD WINAPI GetFullPathName(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR* lpFilePart); +extern LPWSTR WINAPI lstrcpyn(LPWSTR lpString1, LPCWSTR lpString2,int iMaxLength); +extern LPWSTR WINAPI lstrcat(LPWSTR lpString1, LPCWSTR lpString2); + +extern void __cdecl _wsplitpath(wchar_t const* _FullPath, wchar_t* _Drive, wchar_t* _Dir, wchar_t* _Filename, wchar_t* _Ext); +#define _tsplitpath _wsplitpath +#define _tcschr wcschr +extern void _wmakepath(wchar_t _Buffer, wchar_t const* _Drive, wchar_t const* _Dir, wchar_t const* _Filename, wchar_t const* _Ext); +#define _tmakepath _wmakepath +extern int WINAPI lstrcmp(LPCWSTR lpString1, LPCWSTR lpString2); +#define _tcsncmp wcsncmp + +#else + +extern int WINAPI wvsprintf(LPSTR, LPCSTR, va_list arglist); +extern DWORD WINAPI GetFullPathName(LPCSTR lpFileName, DWORD nBufferLength, LPSTR lpBuffer, LPSTR* lpFilePart); +extern LPSTR WINAPI lstrcpyn(LPSTR lpString1, LPCSTR lpString2,int iMaxLength); +extern LPSTR WINAPI lstrcat(LPSTR lpString1, LPCSTR lpString2); + +extern void __cdecl _splitpath(char const* _FullPath, char* _Drive, char* _Dir, char* _Filename, char* _Ext); +#define _tsplitpath _splitpath +#define _tcschr strchr +extern void _makepath(char _Buffer, char const* _Drive, char const* _Dir, char const* _Filename, char const* _Ext); +#define _tmakepath _makepath +extern int WINAPI lstrcmp(LPCSTR lpString1, LPCSTR lpString2); +#define _tcsncmp strncmp + + +#endif // !UNICODE