Mercurial > foo_out_sdl
comparison foosdk/sdk/pfc/pp-winapi.h @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e9bb126753e7 | 1:20d02a178406 |
|---|---|
| 1 #if !defined(PP_WINAPI_H_INCLUDED) && defined(_WIN32) | |
| 2 #define PP_WINAPI_H_INCLUDED | |
| 3 | |
| 4 #ifdef WINAPI_FAMILY_PARTITION | |
| 5 | |
| 6 #if ! WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) | |
| 7 | |
| 8 #ifndef CreateEvent // SPECIAL HACK: disable this stuff if somehow these functions are already defined | |
| 9 | |
| 10 inline HANDLE CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCTSTR lpName) { | |
| 11 DWORD flags = 0; | |
| 12 if (bManualReset) flags |= CREATE_EVENT_MANUAL_RESET; | |
| 13 if (bInitialState) flags |= CREATE_EVENT_INITIAL_SET; | |
| 14 DWORD rights = SYNCHRONIZE | EVENT_MODIFY_STATE; | |
| 15 return CreateEventEx(lpEventAttributes, lpName, flags, rights); | |
| 16 } | |
| 17 | |
| 18 #define CreateEvent CreateEventW | |
| 19 | |
| 20 inline DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) { | |
| 21 return WaitForSingleObjectEx(hHandle, dwMilliseconds, FALSE); | |
| 22 } | |
| 23 | |
| 24 inline DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE *lpHandles, BOOL bWaitAll, DWORD dwMilliseconds) { | |
| 25 return WaitForMultipleObjectsEx(nCount, lpHandles, bWaitAll, dwMilliseconds, FALSE); | |
| 26 } | |
| 27 | |
| 28 inline void InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { | |
| 29 InitializeCriticalSectionEx(lpCriticalSection, 0, 0); | |
| 30 } | |
| 31 | |
| 32 #endif // #ifndef CreateEvent | |
| 33 | |
| 34 | |
| 35 #ifndef CreateMutex | |
| 36 | |
| 37 inline HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, LPCTSTR lpName) { | |
| 38 DWORD rights = MUTEX_MODIFY_STATE | SYNCHRONIZE; | |
| 39 DWORD flags = 0; | |
| 40 if (bInitialOwner) flags |= CREATE_MUTEX_INITIAL_OWNER; | |
| 41 return CreateMutexExW(lpMutexAttributes, lpName, flags, rights); | |
| 42 } | |
| 43 | |
| 44 #define CreateMutex CreateMutexW | |
| 45 | |
| 46 #endif // CreateMutex | |
| 47 | |
| 48 | |
| 49 #ifndef FindFirstFile | |
| 50 | |
| 51 inline HANDLE FindFirstFileW(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData) { | |
| 52 return FindFirstFileEx(lpFileName, FindExInfoStandard, lpFindFileData, FindExSearchNameMatch, NULL, 0); | |
| 53 } | |
| 54 | |
| 55 #define FindFirstFile FindFirstFileW | |
| 56 | |
| 57 #endif // #ifndef FindFirstFile | |
| 58 | |
| 59 // No reliable way to detect if GetFileSizeEx is present?? Give ours another name | |
| 60 inline BOOL GetFileSizeEx_Fallback(HANDLE hFile, PLARGE_INTEGER lpFileSize) { | |
| 61 FILE_STANDARD_INFO info; | |
| 62 if (!GetFileInformationByHandleEx(hFile, FileStandardInfo, &info, sizeof(info))) return FALSE; | |
| 63 *lpFileSize = info.EndOfFile; | |
| 64 return TRUE; | |
| 65 } | |
| 66 | |
| 67 #define PP_GetFileSizeEx_Fallback_Present | |
| 68 | |
| 69 #ifndef CreateFile | |
| 70 | |
| 71 inline HANDLE CreateFileW(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) { | |
| 72 CREATEFILE2_EXTENDED_PARAMETERS arg = {}; | |
| 73 arg.dwSize = sizeof(arg); | |
| 74 arg.hTemplateFile = hTemplateFile; | |
| 75 arg.lpSecurityAttributes = lpSecurityAttributes; | |
| 76 arg.dwFileAttributes = dwFlagsAndAttributes & 0x0000FFFF; | |
| 77 arg.dwFileFlags = dwFlagsAndAttributes & 0xFFFF0000; | |
| 78 return CreateFile2(lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, &arg); | |
| 79 } | |
| 80 | |
| 81 #define CreateFile CreateFileW | |
| 82 | |
| 83 #endif // #ifndef CreateFile | |
| 84 | |
| 85 #ifndef GetFileAttributes | |
| 86 | |
| 87 inline DWORD GetFileAttributesW(const wchar_t * path) { | |
| 88 WIN32_FILE_ATTRIBUTE_DATA data = {}; | |
| 89 if (!GetFileAttributesEx(path, GetFileExInfoStandard, &data)) return 0xFFFFFFFF; | |
| 90 return data.dwFileAttributes; | |
| 91 } | |
| 92 | |
| 93 #define GetFileAttributes GetFileAttributesW | |
| 94 | |
| 95 #endif // #ifndef GetFileAttributes | |
| 96 | |
| 97 #endif // #if ! WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) | |
| 98 | |
| 99 #endif // #ifdef WINAPI_FAMILY_PARTITION | |
| 100 | |
| 101 #ifndef PP_GetFileSizeEx_Fallback_Present | |
| 102 #define GetFileSizeEx_Fallback GetFileSizeEx | |
| 103 #endif | |
| 104 | |
| 105 #endif // !defined(PP_WINAPI_H_INCLUDED) && defined(_WIN32) |
