Mercurial > games > semicongine
comparison fuhtark_test/include/winapi/newapis.h @ 1500:91c8c3b7cbf0
add: futhark tests for generating vulkan api
| author | sam <sam@basx.dev> |
|---|---|
| date | Wed, 26 Nov 2025 21:36:48 +0700 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1499:1f58458b7ef7 | 1500:91c8c3b7cbf0 |
|---|---|
| 1 /** | |
| 2 * This file has no copyright assigned and is placed in the Public Domain. | |
| 3 * This file is part of the w64 mingw-runtime package. | |
| 4 * No warranty is given; refer to the file DISCLAIMER within this package. | |
| 5 */ | |
| 6 #ifdef __cplusplus | |
| 7 extern "C" { | |
| 8 #endif | |
| 9 | |
| 10 #ifdef WANT_GETDISKFREESPACEEX_WRAPPER | |
| 11 | |
| 12 #undef GetDiskFreeSpaceEx | |
| 13 #define GetDiskFreeSpaceEx _GetDiskFreeSpaceEx | |
| 14 | |
| 15 extern WINBOOL (CALLBACK *GetDiskFreeSpaceEx)(LPCTSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER); | |
| 16 | |
| 17 #ifdef COMPILE_NEWAPIS_STUBS | |
| 18 static WINBOOL WINAPI Emulate_GetDiskFreeSpaceEx(LPCTSTR ptszRoot,PULARGE_INTEGER pliQuota,PULARGE_INTEGER pliTotal,PULARGE_INTEGER pliFree) { | |
| 19 DWORD dwSecPerClus,dwBytesPerSec,dwFreeClus,dwTotalClus; | |
| 20 WINBOOL fRc; | |
| 21 fRc = GetDiskFreeSpace(ptszRoot,&dwSecPerClus,&dwBytesPerSec,&dwFreeClus,&dwTotalClus); | |
| 22 if(fRc) { | |
| 23 DWORD dwBytesPerClus = dwSecPerClus *dwBytesPerSec; | |
| 24 *(__int64 *)pliQuota = Int32x32To64(dwBytesPerClus,dwFreeClus); | |
| 25 if(pliFree) { | |
| 26 *pliFree = *pliQuota; | |
| 27 } | |
| 28 *(__int64 *)pliTotal = Int32x32To64(dwBytesPerClus,dwTotalClus); | |
| 29 } | |
| 30 return fRc; | |
| 31 } | |
| 32 | |
| 33 static WINBOOL WINAPI Probe_GetDiskFreeSpaceEx(LPCTSTR ptszRoot,PULARGE_INTEGER pliQuota,PULARGE_INTEGER pliTotal,PULARGE_INTEGER pliFree) { | |
| 34 HINSTANCE hinst; | |
| 35 FARPROC fp; | |
| 36 WINBOOL fRc; | |
| 37 WINBOOL (CALLBACK *RealGetDiskFreeSpaceEx) (LPCTSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER); | |
| 38 hinst = GetModuleHandle(TEXT("KERNEL32")); | |
| 39 #ifdef UNICODE | |
| 40 fp = GetProcAddress(hinst,"GetDiskFreeSpaceExW"); | |
| 41 #else | |
| 42 fp = GetProcAddress(hinst,"GetDiskFreeSpaceExA"); | |
| 43 #endif | |
| 44 if(fp) { | |
| 45 *(FARPROC *)&RealGetDiskFreeSpaceEx = fp; | |
| 46 fRc = RealGetDiskFreeSpaceEx(ptszRoot,pliQuota,pliTotal,pliFree); | |
| 47 if(fRc || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED) { | |
| 48 GetDiskFreeSpaceEx = RealGetDiskFreeSpaceEx; | |
| 49 } else { | |
| 50 GetDiskFreeSpaceEx = Emulate_GetDiskFreeSpaceEx; | |
| 51 fRc = GetDiskFreeSpaceEx(ptszRoot,pliQuota,pliTotal,pliFree); | |
| 52 } | |
| 53 } else { | |
| 54 GetDiskFreeSpaceEx = Emulate_GetDiskFreeSpaceEx; | |
| 55 fRc = GetDiskFreeSpaceEx(ptszRoot,pliQuota,pliTotal,pliFree); | |
| 56 } | |
| 57 return fRc; | |
| 58 } | |
| 59 | |
| 60 WINBOOL (CALLBACK *GetDiskFreeSpaceEx) (LPCTSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER) = Probe_GetDiskFreeSpaceEx; | |
| 61 #endif | |
| 62 #endif | |
| 63 | |
| 64 #ifdef WANT_GETLONGPATHNAME_WRAPPER | |
| 65 #include <shlobj.h> | |
| 66 | |
| 67 #undef GetLongPathName | |
| 68 #define GetLongPathName _GetLongPathName | |
| 69 | |
| 70 extern DWORD (CALLBACK *GetLongPathName)(LPCTSTR,LPTSTR,DWORD); | |
| 71 | |
| 72 #ifdef COMPILE_NEWAPIS_STUBS | |
| 73 static DWORD WINAPI Emulate_GetLongPathName(LPCTSTR ptszShort,LPTSTR ptszLong,DWORD ctchBuf) { | |
| 74 LPSHELLFOLDER psfDesk; | |
| 75 HRESULT hr; | |
| 76 LPITEMIDLIST pidl; | |
| 77 TCHAR tsz[MAX_PATH]; | |
| 78 DWORD dwRc; | |
| 79 LPMALLOC pMalloc; | |
| 80 if(GetFileAttributes(ptszShort)==0xFFFFFFFF) return 0; | |
| 81 dwRc = GetFullPathName(ptszShort,MAX_PATH,tsz,NULL); | |
| 82 if(dwRc==0) { | |
| 83 } else if(dwRc >= MAX_PATH) { | |
| 84 SetLastError(ERROR_BUFFER_OVERFLOW); | |
| 85 dwRc = 0; | |
| 86 } else { | |
| 87 hr = SHGetDesktopFolder(&psfDesk); | |
| 88 if(SUCCEEDED(hr)) { | |
| 89 ULONG cwchEaten; | |
| 90 #ifdef UNICODE | |
| 91 #ifdef __cplusplus | |
| 92 hr = psfDesk->ParseDisplayName(NULL,NULL,tsz,&cwchEaten,&pidl,NULL); | |
| 93 #else | |
| 94 hr = psfDesk->lpVtbl->ParseDisplayName(psfDesk,NULL,NULL,tsz,&cwchEaten,&pidl,NULL); | |
| 95 #endif | |
| 96 #else | |
| 97 WCHAR wsz[MAX_PATH]; | |
| 98 | |
| 99 dwRc = MultiByteToWideChar(AreFileApisANSI() ? CP_ACP : CP_OEMCP,0,tsz,-1,wsz,MAX_PATH); | |
| 100 if(dwRc==0) { | |
| 101 if(GetLastError()==ERROR_INSUFFICIENT_BUFFER) { | |
| 102 SetLastError(ERROR_BUFFER_OVERFLOW); | |
| 103 } | |
| 104 dwRc = 0; | |
| 105 } else { | |
| 106 #ifdef __cplusplus | |
| 107 hr = psfDesk->ParseDisplayName(NULL,NULL,wsz,&cwchEaten,&pidl,NULL); | |
| 108 #else | |
| 109 hr = psfDesk->lpVtbl->ParseDisplayName(psfDesk,NULL,NULL,wsz,&cwchEaten,&pidl,NULL); | |
| 110 #endif | |
| 111 #endif | |
| 112 if(FAILED(hr)) { | |
| 113 if(HRESULT_FACILITY(hr)==FACILITY_WIN32) { | |
| 114 SetLastError(HRESULT_CODE(hr)); | |
| 115 } else { | |
| 116 SetLastError(ERROR_INVALID_DATA); | |
| 117 } | |
| 118 dwRc = 0; | |
| 119 } else { | |
| 120 dwRc = SHGetPathFromIDList(pidl,tsz); | |
| 121 if(dwRc==0 && tsz[0]) { | |
| 122 SetLastError(ERROR_INVALID_DATA); | |
| 123 } else { | |
| 124 dwRc = lstrlen(tsz); | |
| 125 if(dwRc + 1 > ctchBuf) { | |
| 126 SetLastError(ERROR_INSUFFICIENT_BUFFER); | |
| 127 dwRc = dwRc + 1; | |
| 128 } else { | |
| 129 lstrcpyn(ptszLong,tsz,ctchBuf); | |
| 130 } | |
| 131 } | |
| 132 if(SUCCEEDED(SHGetMalloc(&pMalloc))) { | |
| 133 #ifdef __cplusplus | |
| 134 pMalloc->Free(pidl); | |
| 135 pMalloc->Release(); | |
| 136 #else | |
| 137 pMalloc->lpVtbl->Free(pMalloc,pidl); | |
| 138 pMalloc->lpVtbl->Release(pMalloc); | |
| 139 #endif | |
| 140 } | |
| 141 } | |
| 142 #ifndef UNICODE | |
| 143 } | |
| 144 #endif | |
| 145 #ifdef __cplusplus | |
| 146 psfDesk->Release(); | |
| 147 #else | |
| 148 psfDesk->lpVtbl->Release(psfDesk); | |
| 149 #endif | |
| 150 } | |
| 151 } | |
| 152 return dwRc; | |
| 153 } | |
| 154 | |
| 155 static DWORD WINAPI Probe_GetLongPathName(LPCTSTR ptszShort,LPTSTR ptszLong,DWORD ctchBuf) { | |
| 156 HINSTANCE hinst; | |
| 157 FARPROC fp; | |
| 158 DWORD dwRc; | |
| 159 DWORD (CALLBACK *RealGetLongPathName)(LPCTSTR,LPTSTR,DWORD); | |
| 160 hinst = GetModuleHandle(TEXT("KERNEL32")); | |
| 161 #ifdef UNICODE | |
| 162 fp = GetProcAddress(hinst,"GetLongPathNameW"); | |
| 163 #else | |
| 164 fp = GetProcAddress(hinst,"GetLongPathNameA"); | |
| 165 #endif | |
| 166 if(fp) { | |
| 167 *(FARPROC *)&RealGetLongPathName = fp; | |
| 168 dwRc = RealGetLongPathName(ptszShort,ptszLong,ctchBuf); | |
| 169 if(dwRc || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED) { | |
| 170 GetLongPathName = RealGetLongPathName; | |
| 171 } else { | |
| 172 GetLongPathName = Emulate_GetLongPathName; | |
| 173 dwRc = GetLongPathName(ptszShort,ptszLong,ctchBuf); | |
| 174 } | |
| 175 } else { | |
| 176 GetLongPathName = Emulate_GetLongPathName; | |
| 177 dwRc = GetLongPathName(ptszShort,ptszLong,ctchBuf); | |
| 178 } | |
| 179 return dwRc; | |
| 180 | |
| 181 } | |
| 182 | |
| 183 DWORD (CALLBACK *GetLongPathName)(LPCTSTR,LPTSTR,DWORD) = Probe_GetLongPathName; | |
| 184 #endif | |
| 185 #endif | |
| 186 | |
| 187 #ifdef WANT_GETFILEATTRIBUTESEX_WRAPPER | |
| 188 | |
| 189 #undef GetFileAttributesEx | |
| 190 #define GetFileAttributesEx _GetFileAttributesEx | |
| 191 | |
| 192 extern WINBOOL (CALLBACK *GetFileAttributesEx) | |
| 193 (LPCTSTR,GET_FILEEX_INFO_LEVELS,LPVOID); | |
| 194 | |
| 195 #ifdef COMPILE_NEWAPIS_STUBS | |
| 196 | |
| 197 static WINBOOL WINAPI Emulate_GetFileAttributesEx(LPCTSTR ptszFile,GET_FILEEX_INFO_LEVELS level,LPVOID pv) { | |
| 198 WINBOOL fRc; | |
| 199 if(level==GetFileExInfoStandard) { | |
| 200 if(GetFileAttributes(ptszFile)!=0xFFFFFFFF) { | |
| 201 HANDLE hfind; | |
| 202 WIN32_FIND_DATA wfd; | |
| 203 hfind = FindFirstFile(ptszFile,&wfd); | |
| 204 if(hfind!=INVALID_HANDLE_VALUE) { | |
| 205 LPWIN32_FILE_ATTRIBUTE_DATA pfad = pv; | |
| 206 FindClose(hfind); | |
| 207 pfad->dwFileAttributes = wfd.dwFileAttributes; | |
| 208 pfad->ftCreationTime = wfd.ftCreationTime; | |
| 209 pfad->ftLastAccessTime = wfd.ftLastAccessTime; | |
| 210 pfad->ftLastWriteTime = wfd.ftLastWriteTime; | |
| 211 pfad->nFileSizeHigh = wfd.nFileSizeHigh; | |
| 212 pfad->nFileSizeLow = wfd.nFileSizeLow; | |
| 213 | |
| 214 fRc = TRUE; | |
| 215 } else { | |
| 216 fRc = FALSE; | |
| 217 } | |
| 218 } else { | |
| 219 fRc = FALSE; | |
| 220 } | |
| 221 } else { | |
| 222 SetLastError(ERROR_INVALID_PARAMETER); | |
| 223 fRc = FALSE; | |
| 224 } | |
| 225 return fRc; | |
| 226 } | |
| 227 | |
| 228 static WINBOOL WINAPI Probe_GetFileAttributesEx(LPCTSTR ptszFile,GET_FILEEX_INFO_LEVELS level,LPVOID pv) { | |
| 229 HINSTANCE hinst; | |
| 230 FARPROC fp; | |
| 231 WINBOOL fRc; | |
| 232 WINBOOL (CALLBACK *RealGetFileAttributesEx)(LPCTSTR,GET_FILEEX_INFO_LEVELS,LPVOID); | |
| 233 hinst = GetModuleHandle(TEXT("KERNEL32")); | |
| 234 #ifdef UNICODE | |
| 235 fp = GetProcAddress(hinst,"GetFileAttributesExW"); | |
| 236 #else | |
| 237 fp = GetProcAddress(hinst,"GetFileAttributesExA"); | |
| 238 #endif | |
| 239 if(fp) { | |
| 240 *(FARPROC *)&RealGetFileAttributesEx = fp; | |
| 241 fRc = RealGetFileAttributesEx(ptszFile,level,pv); | |
| 242 if(fRc || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED) { | |
| 243 GetFileAttributesEx = RealGetFileAttributesEx; | |
| 244 } else { | |
| 245 GetFileAttributesEx = Emulate_GetFileAttributesEx; | |
| 246 fRc = GetFileAttributesEx(ptszFile,level,pv); | |
| 247 } | |
| 248 } else { | |
| 249 GetFileAttributesEx = Emulate_GetFileAttributesEx; | |
| 250 fRc = GetFileAttributesEx(ptszFile,level,pv); | |
| 251 } | |
| 252 return fRc; | |
| 253 } | |
| 254 | |
| 255 WINBOOL (CALLBACK *GetFileAttributesEx)(LPCTSTR,GET_FILEEX_INFO_LEVELS,LPVOID) = Probe_GetFileAttributesEx; | |
| 256 #endif | |
| 257 #endif | |
| 258 | |
| 259 #ifdef WANT_ISDEBUGGERPRESENT_WRAPPER | |
| 260 #define IsDebuggerPresent _IsDebuggerPresent | |
| 261 | |
| 262 extern WINBOOL (CALLBACK *IsDebuggerPresent)(VOID); | |
| 263 | |
| 264 #ifdef COMPILE_NEWAPIS_STUBS | |
| 265 static WINBOOL WINAPI Emulate_IsDebuggerPresent(VOID) { return FALSE; } | |
| 266 static WINBOOL WINAPI Probe_IsDebuggerPresent(VOID) { | |
| 267 HINSTANCE hinst; | |
| 268 FARPROC fp; | |
| 269 WINBOOL (CALLBACK *RealIsDebuggerPresent)(VOID); | |
| 270 hinst = GetModuleHandle(TEXT("KERNEL32")); | |
| 271 fp = GetProcAddress(hinst,"IsDebuggerPresent"); | |
| 272 if(fp) { | |
| 273 *(FARPROC *)&IsDebuggerPresent = fp; | |
| 274 } else { | |
| 275 IsDebuggerPresent = Emulate_IsDebuggerPresent; | |
| 276 } | |
| 277 return IsDebuggerPresent(); | |
| 278 } | |
| 279 | |
| 280 WINBOOL (CALLBACK *IsDebuggerPresent)(VOID) = Probe_IsDebuggerPresent; | |
| 281 #endif | |
| 282 #endif | |
| 283 | |
| 284 #ifdef __cplusplus | |
| 285 } | |
| 286 #endif |
