Changeset 70375 in vbox
- Timestamp:
- Dec 28, 2017 8:46:21 PM (7 years ago)
- Location:
- trunk/src/VBox/Runtime/r3/win
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakes.cpp
r70360 r70375 29 29 * Header Files * 30 30 *********************************************************************************************************************************/ 31 #define RT_NO_STRICT /* Minimal deps so that it works on NT 3.51 too. */32 31 #include <iprt/cdefs.h> 33 32 #include <iprt/types.h> … … 35 34 #include <iprt/assert.h> 36 35 #include <iprt/string.h> 36 #ifdef DEBUG 37 # include <stdio.h> /* _snprintf */ 38 #endif 37 39 38 40 #ifndef RT_ARCH_X86 … … 40 42 #endif 41 43 42 #define DecodePointer Ignore_DecodePointer43 #define EncodePointer Ignore_EncodePointer44 #define InitializeCriticalSectionAndSpinCount Ignore_InitializeCriticalSectionAndSpinCount45 #define HeapSetInformation Ignore_HeapSetInformation46 #define HeapQueryInformation Ignore_HeapQueryInformation47 #define CreateTimerQueue Ignore_CreateTimerQueue48 #define CreateTimerQueueTimer Ignore_CreateTimerQueueTimer49 #define DeleteTimerQueueTimer Ignore_DeleteTimerQueueTimer50 #define InitializeSListHead Ignore_InitializeSListHead51 #define InterlockedFlushSList Ignore_InterlockedFlushSList52 #define InterlockedPopEntrySList Ignore_InterlockedPopEntrySList53 #define InterlockedPushEntrySList Ignore_InterlockedPushEntrySList54 #define QueryDepthSList Ignore_QueryDepthSList55 #define VerifyVersionInfoA Ignore_VerifyVersionInfoA56 #define VerSetConditionMask Ignore_VerSetConditionMask57 #define IsProcessorFeaturePresent Ignore_IsProcessorFeaturePresent /* NT 3.51 start */58 #define CancelIo Ignore_CancelIo59 #define IsDebuggerPresent Ignore_IsDebuggerPresent /* NT 3.50 start */60 #define GetSystemTimeAsFileTime Ignore_GetSystemTimeAsFileTime61 #define GetVersionExA Ignore_GetVersionExA /* NT 3.1 start */62 #define GetVersionExW Ignore_GetVersionExW63 #define GetEnvironmentStringsW Ignore_GetEnvironmentStringsW64 #define FreeEnvironmentStringsW Ignore_FreeEnvironmentStringsW65 #define GetLocaleInfoA Ignore_GetLocaleInfoA66 #define EnumSystemLocalesA Ignore_EnumSystemLocalesA67 #define IsValidLocale Ignore_IsValidLocale68 #define SetThreadAffinityMask Ignore_SetThreadAffinityMask69 #define GetProcessAffinityMask Ignore_GetProcessAffinityMask70 #define GetHandleInformation Ignore_GetHandleInformation71 #define SetHandleInformation Ignore_SetHandleInformation72 73 44 #include <iprt/nt/nt-and-windows.h> 74 45 75 #undef DecodePointer 76 #undef EncodePointer 77 #undef InitializeCriticalSectionAndSpinCount 78 #undef HeapSetInformation 79 #undef HeapQueryInformation 80 #undef CreateTimerQueue 81 #undef CreateTimerQueueTimer 82 #undef DeleteTimerQueueTimer 83 #undef InitializeSListHead 84 #undef InterlockedFlushSList 85 #undef InterlockedPopEntrySList 86 #undef InterlockedPushEntrySList 87 #undef QueryDepthSList 88 #undef VerifyVersionInfoA 89 #undef VerSetConditionMask 90 #undef IsProcessorFeaturePresent 91 #undef CancelIo 92 #undef IsDebuggerPresent 93 #undef GetSystemTimeAsFileTime 94 #undef GetVersionExA 95 #undef GetVersionExW 96 #undef GetEnvironmentStringsW 97 #undef FreeEnvironmentStringsW 98 #undef GetLocaleInfoA 99 #undef EnumSystemLocalesA 100 #undef IsValidLocale 101 #undef SetThreadAffinityMask 102 #undef GetProcessAffinityMask 103 #undef GetHandleInformation 104 #undef SetHandleInformation 46 #include "vcc100-fakes.h" 105 47 106 48 … … 113 55 114 56 115 /** Dynamically resolves an kernel32 API. */116 #define RESOLVE_ME(ApiNm) \117 static bool volatile s_fInitialized = false; \118 static decltype(ApiNm) *s_pfnApi = NULL; \119 decltype(ApiNm) *pfnApi; \120 if (s_fInitialized) \121 pfnApi = s_pfnApi; \122 else \123 { \124 pfnApi = (decltype(pfnApi))GetProcAddress(GetModuleHandleW(L"kernel32"), #ApiNm); \125 s_pfnApi = pfnApi; \126 s_fInitialized = true; \127 } do {} while (0)128 129 130 /** Dynamically resolves an NTDLL API we need. */131 #define RESOLVE_NTDLL_API(ApiNm) \132 static bool volatile s_fInitialized##ApiNm = false; \133 static decltype(ApiNm) *s_pfn##ApiNm = NULL; \134 decltype(ApiNm) *pfn##ApiNm; \135 if (s_fInitialized##ApiNm) \136 pfn##ApiNm = s_pfn##ApiNm; \137 else \138 { \139 pfn##ApiNm = (decltype(pfn##ApiNm))GetProcAddress(GetModuleHandleW(L"ntdll"), #ApiNm); \140 s_pfn##ApiNm = pfn##ApiNm; \141 s_fInitialized##ApiNm = true; \142 } do {} while (0)143 144 145 57 /** Declare a kernel32 API. 146 58 * @note We are not exporting them as that causes duplicate symbol troubles in … … 149 61 150 62 63 151 64 /********************************************************************************************************************************* 152 * Internal Functions*65 * Global Variables * 153 66 *********************************************************************************************************************************/ 154 DECL_KERNEL32(BOOL) WINAPI GetVersionExA(LPOSVERSIONINFOA pInfo); 155 156 157 DECL_KERNEL32(PVOID) DecodePointer(PVOID pvEncoded) 158 { 159 RESOLVE_ME(DecodePointer); 160 if (pfnApi) 161 return pfnApi(pvEncoded); 67 static volatile bool g_fInitialized = false; 68 #define MAKE_IMPORT_ENTRY(a_uMajorVer, a_uMinorVer, a_Name, a_cb) DECLARE_FUNCTION_POINTER(a_Name, a_cb) 69 #include "vcc100-kernel32-fakes.h" 70 71 72 /** 73 * Resolves all the APIs ones and for all, updating the fake IAT entries. 74 */ 75 static void InitFakes(void) 76 { 77 CURRENT_VERSION_VARIABLE(); 78 79 HMODULE hmod = GetModuleHandleW(L"kernel32"); 80 MY_ASSERT(hmod != NULL, "kernel32"); 81 82 #undef MAKE_IMPORT_ENTRY 83 #define MAKE_IMPORT_ENTRY(a_uMajorVer, a_uMinorVer, a_Name, a_cb) RESOLVE_IMPORT(a_uMajorVer, a_uMinorVer, a_Name, a_cb) 84 #include "vcc100-kernel32-fakes.h" 85 86 g_fInitialized = true; 87 } 88 89 90 DECL_KERNEL32(PVOID) Fake_DecodePointer(PVOID pvEncoded) 91 { 92 INIT_FAKES(DecodePointer,(pvEncoded)); 162 93 163 94 /* … … 168 99 169 100 170 DECL_KERNEL32(PVOID) EncodePointer(PVOID pvNative) 171 { 172 RESOLVE_ME(EncodePointer); 173 if (pfnApi) 174 return pfnApi(pvNative); 101 DECL_KERNEL32(PVOID) Fake_EncodePointer(PVOID pvNative) 102 { 103 INIT_FAKES(EncodePointer, (pvNative)); 175 104 176 105 /* … … 181 110 182 111 183 DECL_KERNEL32(BOOL) InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION pCritSect, DWORD cSpin) 184 { 185 RESOLVE_ME(InitializeCriticalSectionAndSpinCount); 186 if (pfnApi) 187 return pfnApi(pCritSect, cSpin); 112 DECL_KERNEL32(BOOL) Fake_InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION pCritSect, DWORD cSpin) 113 { 114 INIT_FAKES(InitializeCriticalSectionAndSpinCount, (pCritSect, cSpin)); 188 115 189 116 /* … … 195 122 196 123 197 DECL_KERNEL32(BOOL) HeapSetInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, PVOID pvBuf, SIZE_T cbBuf) 198 { 199 RESOLVE_ME(HeapSetInformation); 200 if (pfnApi) 201 return pfnApi(hHeap, enmInfoClass, pvBuf, cbBuf); 124 DECL_KERNEL32(BOOL) Fake_HeapSetInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, PVOID pvBuf, SIZE_T cbBuf) 125 { 126 INIT_FAKES(HeapSetInformation, (hHeap, enmInfoClass, pvBuf, cbBuf)); 202 127 203 128 /* … … 222 147 223 148 224 DECL_KERNEL32(BOOL) HeapQueryInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, 225 PVOID pvBuf, SIZE_T cbBuf, PSIZE_T pcbRet) 226 { 227 RESOLVE_ME(HeapQueryInformation); 228 if (pfnApi) 229 return pfnApi(hHeap, enmInfoClass, pvBuf, cbBuf, pcbRet); 149 DECL_KERNEL32(BOOL) Fake_HeapQueryInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, 150 PVOID pvBuf, SIZE_T cbBuf, PSIZE_T pcbRet) 151 { 152 INIT_FAKES(HeapQueryInformation, (hHeap, enmInfoClass, pvBuf, cbBuf, pcbRet)); 230 153 231 154 /* … … 251 174 /* These are used by INTEL\mt_obj\Timer.obj: */ 252 175 253 DECL_KERNEL32(HANDLE) CreateTimerQueue(void) 254 { 255 RESOLVE_ME(CreateTimerQueue); 256 if (pfnApi) 257 return pfnApi(); 176 DECL_KERNEL32(HANDLE) Fake_CreateTimerQueue(void) 177 { 178 INIT_FAKES(CreateTimerQueue, ()); 179 258 180 SetLastError(ERROR_NOT_SUPPORTED); 259 181 return NULL; 260 182 } 261 183 262 DECL_KERNEL32(BOOL) CreateTimerQueueTimer(PHANDLE phTimer, HANDLE hTimerQueue, WAITORTIMERCALLBACK pfnCallback, PVOID pvUser, 263 DWORD msDueTime, DWORD msPeriod, ULONG fFlags) 264 { 265 RESOLVE_ME(CreateTimerQueueTimer); 266 if (pfnApi) 267 return pfnApi(phTimer, hTimerQueue, pfnCallback, pvUser, msDueTime, msPeriod, fFlags); 184 DECL_KERNEL32(BOOL) Fake_CreateTimerQueueTimer(PHANDLE phTimer, HANDLE hTimerQueue, WAITORTIMERCALLBACK pfnCallback, PVOID pvUser, 185 DWORD msDueTime, DWORD msPeriod, ULONG fFlags) 186 { 187 INIT_FAKES(CreateTimerQueueTimer, (phTimer, hTimerQueue, pfnCallback, pvUser, msDueTime, msPeriod, fFlags)); 188 268 189 SetLastError(ERROR_NOT_SUPPORTED); 269 190 return FALSE; 270 191 } 271 192 272 DECL_KERNEL32(BOOL) DeleteTimerQueueTimer(HANDLE hTimerQueue, HANDLE hTimer, HANDLE hEvtCompletion) 273 { 274 RESOLVE_ME(DeleteTimerQueueTimer); 275 if (pfnApi) 276 return pfnApi(hTimerQueue, hTimer, hEvtCompletion); 193 DECL_KERNEL32(BOOL) Fake_DeleteTimerQueueTimer(HANDLE hTimerQueue, HANDLE hTimer, HANDLE hEvtCompletion) 194 { 195 INIT_FAKES(DeleteTimerQueueTimer, (hTimerQueue, hTimer, hEvtCompletion)); 196 277 197 SetLastError(ERROR_NOT_SUPPORTED); 278 198 return FALSE; … … 281 201 /* This is used by several APIs. */ 282 202 283 DECL_KERNEL32(VOID) InitializeSListHead(PSLIST_HEADER pHead) 284 { 285 RESOLVE_ME(InitializeSListHead); 286 if (pfnApi) 287 pfnApi(pHead); 288 else /* fallback: */ 289 pHead->Alignment = 0; 290 } 291 292 293 DECL_KERNEL32(PSLIST_ENTRY) InterlockedFlushSList(PSLIST_HEADER pHead) 294 { 295 RESOLVE_ME(InterlockedFlushSList); 296 if (pfnApi) 297 return pfnApi(pHead); 203 DECL_KERNEL32(VOID) Fake_InitializeSListHead(PSLIST_HEADER pHead) 204 { 205 INIT_FAKES_VOID(InitializeSListHead, (pHead)); 206 207 /* fallback: */ 208 pHead->Alignment = 0; 209 } 210 211 212 DECL_KERNEL32(PSLIST_ENTRY) Fake_InterlockedFlushSList(PSLIST_HEADER pHead) 213 { 214 INIT_FAKES(InterlockedFlushSList, (pHead)); 298 215 299 216 /* fallback: */ … … 317 234 } 318 235 319 DECL_KERNEL32(PSLIST_ENTRY) InterlockedPopEntrySList(PSLIST_HEADER pHead) 320 { 321 RESOLVE_ME(InterlockedPopEntrySList); 322 if (pfnApi) 323 return pfnApi(pHead); 236 DECL_KERNEL32(PSLIST_ENTRY) Fake_InterlockedPopEntrySList(PSLIST_HEADER pHead) 237 { 238 INIT_FAKES(InterlockedPopEntrySList, (pHead)); 324 239 325 240 /* fallback: */ … … 351 266 } 352 267 353 DECL_KERNEL32(PSLIST_ENTRY) InterlockedPushEntrySList(PSLIST_HEADER pHead, PSLIST_ENTRY pEntry) 354 { 355 RESOLVE_ME(InterlockedPushEntrySList); 356 if (pfnApi) 357 return pfnApi(pHead, pEntry); 268 DECL_KERNEL32(PSLIST_ENTRY) Fake_InterlockedPushEntrySList(PSLIST_HEADER pHead, PSLIST_ENTRY pEntry) 269 { 270 INIT_FAKES(InterlockedPushEntrySList, (pHead, pEntry)); 358 271 359 272 /* fallback: */ … … 374 287 } 375 288 376 DECL_KERNEL32(WORD) QueryDepthSList(PSLIST_HEADER pHead)377 { 378 RESOLVE_ME(QueryDepthSList);379 if (pfnApi) 380 return pfnApi(pHead);289 DECL_KERNEL32(WORD) Fake_QueryDepthSList(PSLIST_HEADER pHead) 290 { 291 INIT_FAKES(QueryDepthSList, (pHead)); 292 293 /* fallback: */ 381 294 return pHead->Depth; 382 295 } … … 384 297 385 298 /* curl drags these in: */ 386 DECL_KERNEL32(BOOL) VerifyVersionInfoA(LPOSVERSIONINFOEXA pInfo, DWORD fTypeMask, DWORDLONG fConditionMask) 387 { 388 RESOLVE_ME(VerifyVersionInfoA); 389 if (pfnApi) 390 return pfnApi(pInfo, fTypeMask, fConditionMask); 299 DECL_KERNEL32(BOOL) Fake_VerifyVersionInfoA(LPOSVERSIONINFOEXA pInfo, DWORD fTypeMask, DWORDLONG fConditionMask) 300 { 301 INIT_FAKES(VerifyVersionInfoA, (pInfo, fTypeMask, fConditionMask)); 391 302 392 303 /* fallback to make curl happy: */ … … 398 309 RT_ZERO(VerInfo); 399 310 VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 400 AssertReturn(GetVersionExA((OSVERSIONINFO *)&VerInfo), FALSE); 311 BOOL fRet = GetVersionExA((OSVERSIONINFO *)&VerInfo); 312 if (fRet) 313 { /* likely */ } 314 else 315 { 316 MY_ASSERT(false, "VerifyVersionInfoA: #1"); 317 return FALSE; 318 } 401 319 } 402 320 … … 418 336 MY_CASE(VER_PRODUCT_TYPE, wProductType); 419 337 #undef MY_CASE 420 default: uLeft = uRight = 0; AssertFailed();338 default: uLeft = uRight = 0; MY_ASSERT(false, "VerifyVersionInfoA: #2"); 421 339 } 422 340 switch ((uint8_t)(fConditionMask >> (i*8))) … … 429 347 case VER_AND: fRet = (uLeft & uRight) == uRight; break; 430 348 case VER_OR: fRet = (uLeft & uRight) != 0; break; 431 default: fRet = FALSE; AssertFailed(); break;349 default: fRet = FALSE; MY_ASSERT(false, "VerifyVersionInfoA: #3"); break; 432 350 } 433 351 } … … 437 355 438 356 439 DECL_KERNEL32(ULONGLONG) VerSetConditionMask(ULONGLONG fConditionMask, DWORD fTypeMask, BYTE bOperator) 440 { 441 RESOLVE_ME(VerSetConditionMask); 442 if (pfnApi) 443 return pfnApi(fConditionMask, fTypeMask, bOperator); 357 DECL_KERNEL32(ULONGLONG) Fake_VerSetConditionMask(ULONGLONG fConditionMask, DWORD fTypeMask, BYTE bOperator) 358 { 359 INIT_FAKES(VerSetConditionMask, (fConditionMask, fTypeMask, bOperator)); 444 360 445 361 /* fallback: */ … … 460 376 */ 461 377 462 DECL_KERNEL32(BOOL) IsProcessorFeaturePresent(DWORD enmProcessorFeature) 463 { 464 RESOLVE_ME(IsProcessorFeaturePresent); 465 if (pfnApi) 466 return pfnApi(enmProcessorFeature); 378 DECL_KERNEL32(BOOL) Fake_IsProcessorFeaturePresent(DWORD enmProcessorFeature) 379 { 380 INIT_FAKES(IsProcessorFeaturePresent, (enmProcessorFeature)); 467 381 468 382 /* Could make more of an effort here... */ … … 471 385 472 386 473 DECL_KERNEL32(BOOL) CancelIo(HANDLE hHandle) 474 { 475 RESOLVE_ME(CancelIo); 476 if (pfnApi) 477 return pfnApi(hHandle); 387 DECL_KERNEL32(BOOL) Fake_CancelIo(HANDLE hHandle) 388 { 389 INIT_FAKES(CancelIo, (hHandle)); 478 390 479 391 /* NT 3.51 have the NTDLL API this corresponds to. */ … … 500 412 */ 501 413 502 DECL_KERNEL32(BOOL) IsDebuggerPresent(VOID) 503 { 504 RESOLVE_ME(IsDebuggerPresent); 505 if (pfnApi) 506 return pfnApi(); 507 return FALSE; 508 } 509 510 511 DECL_KERNEL32(VOID) GetSystemTimeAsFileTime(LPFILETIME pTime) 512 { 513 RESOLVE_ME(GetSystemTimeAsFileTime); 514 if (pfnApi) 515 pfnApi(pTime); 414 DECL_KERNEL32(BOOL) Fake_IsDebuggerPresent(VOID) 415 { 416 INIT_FAKES(IsDebuggerPresent, ()); 417 418 /* Fallback: */ 419 return FALSE; 420 } 421 422 423 DECL_KERNEL32(VOID) Fake_GetSystemTimeAsFileTime(LPFILETIME pTime) 424 { 425 INIT_FAKES_VOID(GetSystemTimeAsFileTime, (pTime)); 426 427 DWORD dwVersion = GetVersion(); 428 if ( (dwVersion & 0xff) > 3 429 || ( (dwVersion & 0xff) == 3 430 && ((dwVersion >> 8) & 0xff) >= 50) ) 431 { 432 PKUSER_SHARED_DATA pUsd = (PKUSER_SHARED_DATA)MM_SHARED_USER_DATA_VA; 433 434 /* use interrupt time */ 435 LARGE_INTEGER Time; 436 do 437 { 438 Time.HighPart = pUsd->SystemTime.High1Time; 439 Time.LowPart = pUsd->SystemTime.LowPart; 440 } while (pUsd->SystemTime.High2Time != Time.HighPart); 441 442 pTime->dwHighDateTime = Time.HighPart; 443 pTime->dwLowDateTime = Time.LowPart; 444 } 516 445 else 517 446 { 518 DWORD dwVersion = GetVersion(); 519 if ( (dwVersion & 0xff) > 3 520 || ( (dwVersion & 0xff) == 3 521 && ((dwVersion >> 8) & 0xff) >= 50) ) 522 { 523 PKUSER_SHARED_DATA pUsd = (PKUSER_SHARED_DATA)MM_SHARED_USER_DATA_VA; 524 525 /* use interrupt time */ 526 LARGE_INTEGER Time; 527 do 528 { 529 Time.HighPart = pUsd->SystemTime.High1Time; 530 Time.LowPart = pUsd->SystemTime.LowPart; 531 } while (pUsd->SystemTime.High2Time != Time.HighPart); 532 533 pTime->dwHighDateTime = Time.HighPart; 534 pTime->dwLowDateTime = Time.LowPart; 535 } 447 /* NT 3.1 didn't have a KUSER_SHARED_DATA nor a GetSystemTimeAsFileTime export. */ 448 SYSTEMTIME SystemTime; 449 GetSystemTime(&SystemTime); 450 BOOL fRet = SystemTimeToFileTime(&SystemTime, pTime); 451 if (fRet) 452 { /* likely */ } 536 453 else 537 454 { 538 /* NT 3.1 didn't have a KUSER_SHARED_DATA nor a GetSystemTimeAsFileTime export. */ 539 SYSTEMTIME SystemTime; 540 GetSystemTime(&SystemTime); 541 BOOL fRet = SystemTimeToFileTime(&SystemTime, pTime); 542 AssertStmt(fRet, pTime->dwHighDateTime = pTime->dwLowDateTime = 0); 455 MY_ASSERT(false, "GetSystemTimeAsFileTime: #2"); 456 pTime->dwHighDateTime = 0; 457 pTime->dwLowDateTime = 0; 543 458 } 544 459 } … … 550 465 */ 551 466 552 DECL_KERNEL32(BOOL) GetVersionExA(LPOSVERSIONINFOA pInfo) 553 { 554 RESOLVE_ME(GetVersionExA); 555 if (pfnApi) 556 return pfnApi(pInfo); 557 467 DECL_KERNEL32(BOOL) Fake_GetVersionExA(LPOSVERSIONINFOA pInfo) 468 { 469 INIT_FAKES(GetVersionExA, (pInfo)); 470 471 /* 472 * Fallback. 473 */ 558 474 DWORD dwVersion = GetVersion(); 559 475 … … 590 506 591 507 592 DECL_KERNEL32(BOOL) GetVersionExW(LPOSVERSIONINFOW pInfo) 593 { 594 RESOLVE_ME(GetVersionExW); 595 if (pfnApi) 596 return pfnApi(pInfo); 597 508 DECL_KERNEL32(BOOL) Fake_GetVersionExW(LPOSVERSIONINFOW pInfo) 509 { 510 INIT_FAKES(GetVersionExW, (pInfo)); 511 512 /* 513 * Fallback. 514 */ 598 515 DWORD dwVersion = GetVersion(); 599 516 … … 630 547 631 548 632 DECL_KERNEL32(LPWCH) GetEnvironmentStringsW(void)633 { 634 RESOLVE_ME(GetEnvironmentStringsW);635 if (pfnApi) 636 return pfnApi();637 638 /*549 DECL_KERNEL32(LPWCH) Fake_GetEnvironmentStringsW(void) 550 { 551 INIT_FAKES(GetEnvironmentStringsW, ()); 552 553 /* 554 * Fallback: 555 * 639 556 * Environment is ANSI in NT 3.1. We should only be here for NT 3.1. 640 557 * For now, don't try do a perfect job converting it, just do it. … … 664 581 665 582 666 DECL_KERNEL32(BOOL) F reeEnvironmentStringsW(LPWCH pwszzEnv)667 { 668 RESOLVE_ME(FreeEnvironmentStringsW);669 if (pfnApi) 670 return pfnApi(pwszzEnv);583 DECL_KERNEL32(BOOL) Fake_FreeEnvironmentStringsW(LPWCH pwszzEnv) 584 { 585 INIT_FAKES(FreeEnvironmentStringsW, (pwszzEnv)); 586 587 /* Fallback: */ 671 588 if (pwszzEnv) 672 589 HeapFree(GetProcessHeap(), 0, pwszzEnv); … … 675 592 676 593 677 DECL_KERNEL32(int) GetLocaleInfoA(LCID idLocale, LCTYPE enmType, LPSTR pData, int cchData) 678 { 679 RESOLVE_ME(GetLocaleInfoA); 680 if (pfnApi) 681 return pfnApi(idLocale, enmType, pData, cchData); 682 683 AssertMsgFailed(("GetLocaleInfoA: idLocale=%#x enmType=%#x cchData=%#x\n", idLocale, enmType, cchData)); 594 DECL_KERNEL32(int) Fake_GetLocaleInfoA(LCID idLocale, LCTYPE enmType, LPSTR pData, int cchData) 595 { 596 INIT_FAKES(GetLocaleInfoA, (idLocale, enmType, pData, cchData)); 597 598 /* Fallback: */ 599 MY_ASSERT(false, "GetLocaleInfoA: idLocale=%#x enmType=%#x cchData=%#x", idLocale, enmType, cchData); 684 600 SetLastError(ERROR_NOT_SUPPORTED); 685 601 return 0; … … 687 603 688 604 689 DECL_KERNEL32(BOOL) EnumSystemLocalesA(LOCALE_ENUMPROCA pfnCallback, DWORD fFlags) 690 { 691 RESOLVE_ME(EnumSystemLocalesA); 692 if (pfnApi) 693 return pfnApi(pfnCallback, fFlags); 694 695 AssertMsgFailed(("EnumSystemLocalesA: pfnCallback=%p fFlags=%#x\n", pfnCallback, fFlags)); 605 DECL_KERNEL32(BOOL) Fake_EnumSystemLocalesA(LOCALE_ENUMPROCA pfnCallback, DWORD fFlags) 606 { 607 INIT_FAKES(EnumSystemLocalesA, (pfnCallback, fFlags)); 608 609 /* Fallback: */ 610 MY_ASSERT(false, "EnumSystemLocalesA: pfnCallback=%p fFlags=%#x", pfnCallback, fFlags); 696 611 SetLastError(ERROR_NOT_SUPPORTED); 697 612 return FALSE; … … 699 614 700 615 701 DECL_KERNEL32(BOOL) IsValidLocale(LCID idLocale, DWORD fFlags) 702 { 703 RESOLVE_ME(IsValidLocale); 704 if (pfnApi) 705 return pfnApi(idLocale, fFlags); 706 707 AssertMsgFailed(("IsValidLocale: idLocale fFlags=%#x\n", idLocale, fFlags)); 616 DECL_KERNEL32(BOOL) Fake_IsValidLocale(LCID idLocale, DWORD fFlags) 617 { 618 INIT_FAKES(IsValidLocale, (idLocale, fFlags)); 619 620 /* Fallback: */ 621 MY_ASSERT(false, "IsValidLocale: idLocale fFlags=%#x", idLocale, fFlags); 708 622 SetLastError(ERROR_NOT_SUPPORTED); 709 623 return FALSE; … … 711 625 712 626 713 DECL_KERNEL32(DWORD_PTR) SetThreadAffinityMask(HANDLE hThread, DWORD_PTR fAffinityMask) 714 { 715 RESOLVE_ME(SetThreadAffinityMask); 716 if (pfnApi) 717 return pfnApi(hThread, fAffinityMask); 718 627 DECL_KERNEL32(DWORD_PTR) Fake_SetThreadAffinityMask(HANDLE hThread, DWORD_PTR fAffinityMask) 628 { 629 INIT_FAKES(SetThreadAffinityMask, (hThread, fAffinityMask)); 630 631 /* Fallback: */ 719 632 SYSTEM_INFO SysInfo; 720 633 GetSystemInfo(&SysInfo); 721 AssertMsgFailed(("SetThreadAffinityMask: hThread=%p fAffinityMask=%p SysInfo.dwActiveProcessorMask=%p\n",722 hThread, fAffinityMask, SysInfo.dwActiveProcessorMask));634 MY_ASSERT(false, "SetThreadAffinityMask: hThread=%p fAffinityMask=%p SysInfo.dwActiveProcessorMask=%p", 635 hThread, fAffinityMask, SysInfo.dwActiveProcessorMask); 723 636 if ( SysInfo.dwActiveProcessorMask == fAffinityMask 724 637 || fAffinityMask == ~(DWORD_PTR)0) … … 730 643 731 644 732 DECL_KERNEL32(BOOL) GetProcessAffinityMask(HANDLE hProcess, PDWORD_PTR pfProcessAffinityMask, PDWORD_PTR pfSystemAffinityMask) 733 { 734 RESOLVE_ME(GetProcessAffinityMask); 735 if (pfnApi) 736 return pfnApi(hProcess, pfProcessAffinityMask, pfSystemAffinityMask); 737 645 DECL_KERNEL32(BOOL) Fake_GetProcessAffinityMask(HANDLE hProcess, PDWORD_PTR pfProcessAffinityMask, PDWORD_PTR pfSystemAffinityMask) 646 { 647 INIT_FAKES(GetProcessAffinityMask, (hProcess, pfProcessAffinityMask, pfSystemAffinityMask)); 648 649 /* Fallback: */ 738 650 SYSTEM_INFO SysInfo; 739 651 GetSystemInfo(&SysInfo); 740 AssertMsgFailed(("GetProcessAffinityMask: SysInfo.dwActiveProcessorMask=%p\n", SysInfo.dwActiveProcessorMask));652 MY_ASSERT(false, "GetProcessAffinityMask: SysInfo.dwActiveProcessorMask=%p", SysInfo.dwActiveProcessorMask); 741 653 if (pfProcessAffinityMask) 742 654 *pfProcessAffinityMask = SysInfo.dwActiveProcessorMask; … … 747 659 748 660 749 DECL_KERNEL32(BOOL) GetHandleInformation(HANDLE hObject, DWORD *pfFlags) 750 { 751 RESOLVE_ME(GetHandleInformation); 752 if (pfnApi) 753 return pfnApi(hObject, pfFlags); 754 755 661 DECL_KERNEL32(BOOL) Fake_GetHandleInformation(HANDLE hObject, DWORD *pfFlags) 662 { 663 INIT_FAKES(GetHandleInformation, (hObject, pfFlags)); 664 665 /* Fallback: */ 756 666 OBJECT_HANDLE_FLAG_INFORMATION Info = { 0, 0 }; 757 667 DWORD cbRet = sizeof(Info); … … 764 674 } 765 675 *pfFlags = 0; 766 AssertMsg(rcNt == STATUS_INVALID_HANDLE, ("rcNt=%#x\n", rcNt)); 767 SetLastError(rcNt == STATUS_INVALID_HANDLE ? ERROR_INVALID_HANDLE : ERROR_INVALID_FUNCTION); 768 return FALSE; 769 } 770 771 772 DECL_KERNEL32(BOOL) SetHandleInformation(HANDLE hObject, DWORD fMask, DWORD fFlags) 773 { 774 RESOLVE_ME(SetHandleInformation); 775 if (pfnApi) 776 return pfnApi(hObject, fMask, fFlags); 777 676 MY_ASSERT(rcNt == STATUS_INVALID_HANDLE, "rcNt=%#x", rcNt); 677 SetLastError(rcNt == STATUS_INVALID_HANDLE ? ERROR_INVALID_HANDLE : ERROR_INVALID_FUNCTION); /* see also process-win.cpp */ 678 return FALSE; 679 } 680 681 682 DECL_KERNEL32(BOOL) Fake_SetHandleInformation(HANDLE hObject, DWORD fMask, DWORD fFlags) 683 { 684 INIT_FAKES(SetHandleInformation, (hObject, fMask, fFlags)); 685 686 /* Fallback: */ 778 687 SetLastError(ERROR_INVALID_FUNCTION); 779 688 return FALSE; -
trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakesA.asm
r70345 r70375 26 26 27 27 28 %include "iprt/asmdefs.mac" 29 30 %ifndef RT_ARCH_X86 31 %error "This is x86 only code. 32 %endif 33 34 35 %macro MAKE_IMPORT_ENTRY 2 36 extern _ %+ %1 %+ @ %+ %2 37 global __imp__ %+ %1 %+ @ %+ %2 38 __imp__ %+ %1 %+ @ %+ %2: 39 dd _ %+ %1 %+ @ %+ %2 40 41 %endmacro 42 28 %include "vcc100-fakes.mac" 43 29 44 30 BEGINDATA 45 31 GLOBALNAME vcc100_kernel32_fakes_asm 46 32 47 ; NT 4 48 MAKE_IMPORT_ENTRY DecodePointer, 4 49 MAKE_IMPORT_ENTRY EncodePointer, 4 50 MAKE_IMPORT_ENTRY InitializeCriticalSectionAndSpinCount, 8 51 MAKE_IMPORT_ENTRY HeapSetInformation, 16 52 MAKE_IMPORT_ENTRY HeapQueryInformation, 20 53 MAKE_IMPORT_ENTRY CreateTimerQueue, 0 54 MAKE_IMPORT_ENTRY CreateTimerQueueTimer, 28 55 MAKE_IMPORT_ENTRY DeleteTimerQueueTimer, 12 56 MAKE_IMPORT_ENTRY InitializeSListHead, 4 57 MAKE_IMPORT_ENTRY InterlockedFlushSList, 4 58 MAKE_IMPORT_ENTRY InterlockedPopEntrySList, 4 59 MAKE_IMPORT_ENTRY InterlockedPushEntrySList, 8 60 MAKE_IMPORT_ENTRY QueryDepthSList, 4 61 MAKE_IMPORT_ENTRY VerifyVersionInfoA, 16 62 MAKE_IMPORT_ENTRY VerSetConditionMask, 16 63 ; NT 3.51 64 MAKE_IMPORT_ENTRY IsProcessorFeaturePresent, 4 65 MAKE_IMPORT_ENTRY CancelIo, 4 66 ; NT 3.50 67 MAKE_IMPORT_ENTRY IsDebuggerPresent, 0 68 MAKE_IMPORT_ENTRY GetSystemTimeAsFileTime, 4 69 ; NT 3.1 70 MAKE_IMPORT_ENTRY GetVersionExA, 4 71 MAKE_IMPORT_ENTRY GetVersionExW, 4 72 MAKE_IMPORT_ENTRY GetEnvironmentStringsW, 0 73 MAKE_IMPORT_ENTRY FreeEnvironmentStringsW, 4 74 MAKE_IMPORT_ENTRY GetLocaleInfoA, 16 75 MAKE_IMPORT_ENTRY EnumSystemLocalesA, 8 76 MAKE_IMPORT_ENTRY IsValidLocale, 8 77 MAKE_IMPORT_ENTRY SetThreadAffinityMask, 8 78 MAKE_IMPORT_ENTRY GetProcessAffinityMask, 12 79 MAKE_IMPORT_ENTRY GetHandleInformation, 8 80 MAKE_IMPORT_ENTRY SetHandleInformation, 12 33 %include "vcc100-kernel32-fakes.h" 81 34
Note:
See TracChangeset
for help on using the changeset viewer.