Changeset 70394 in vbox for trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakes.cpp
- Timestamp:
- Dec 30, 2017 7:27:35 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakes.cpp
r70375 r70394 70 70 71 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_ENTRY83 #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 72 90 73 DECL_KERNEL32(PVOID) Fake_DecodePointer(PVOID pvEncoded) 91 74 { 92 INIT_FAKES(DecodePointer,(pvEncoded));93 94 /*95 * Fallback code.96 */97 75 return pvEncoded; 98 76 } … … 101 79 DECL_KERNEL32(PVOID) Fake_EncodePointer(PVOID pvNative) 102 80 { 103 INIT_FAKES(EncodePointer, (pvNative));104 105 /*106 * Fallback code.107 */108 81 return pvNative; 109 82 } … … 112 85 DECL_KERNEL32(BOOL) Fake_InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION pCritSect, DWORD cSpin) 113 86 { 114 INIT_FAKES(InitializeCriticalSectionAndSpinCount, (pCritSect, cSpin)); 115 116 /* 117 * Fallback code. 118 */ 87 RT_NOREF(cSpin); 119 88 InitializeCriticalSection(pCritSect); 120 89 return TRUE; … … 124 93 DECL_KERNEL32(BOOL) Fake_HeapSetInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, PVOID pvBuf, SIZE_T cbBuf) 125 94 { 126 INIT_FAKES(HeapSetInformation, (hHeap, enmInfoClass, pvBuf, cbBuf)); 127 128 /* 129 * Fallback code. 130 */ 95 RT_NOREF(hHeap); 131 96 if (enmInfoClass == HeapCompatibilityInformation) 132 97 { … … 150 115 PVOID pvBuf, SIZE_T cbBuf, PSIZE_T pcbRet) 151 116 { 152 INIT_FAKES(HeapQueryInformation, (hHeap, enmInfoClass, pvBuf, cbBuf, pcbRet)); 153 154 /* 155 * Fallback code. 156 */ 117 RT_NOREF(hHeap); 157 118 if (enmInfoClass == HeapCompatibilityInformation) 158 119 { … … 176 137 DECL_KERNEL32(HANDLE) Fake_CreateTimerQueue(void) 177 138 { 178 INIT_FAKES(CreateTimerQueue, ());179 180 139 SetLastError(ERROR_NOT_SUPPORTED); 181 140 return NULL; … … 185 144 DWORD msDueTime, DWORD msPeriod, ULONG fFlags) 186 145 { 187 INIT_FAKES(CreateTimerQueueTimer, (phTimer, hTimerQueue, pfnCallback, pvUser, msDueTime, msPeriod, fFlags)); 188 146 NOREF(phTimer); NOREF(hTimerQueue); NOREF(pfnCallback); NOREF(pvUser); NOREF(msDueTime); NOREF(msPeriod); NOREF(fFlags); 189 147 SetLastError(ERROR_NOT_SUPPORTED); 190 148 return FALSE; … … 193 151 DECL_KERNEL32(BOOL) Fake_DeleteTimerQueueTimer(HANDLE hTimerQueue, HANDLE hTimer, HANDLE hEvtCompletion) 194 152 { 195 INIT_FAKES(DeleteTimerQueueTimer, (hTimerQueue, hTimer, hEvtCompletion)); 196 153 NOREF(hTimerQueue); NOREF(hTimer); NOREF(hEvtCompletion); 197 154 SetLastError(ERROR_NOT_SUPPORTED); 198 155 return FALSE; … … 203 160 DECL_KERNEL32(VOID) Fake_InitializeSListHead(PSLIST_HEADER pHead) 204 161 { 205 INIT_FAKES_VOID(InitializeSListHead, (pHead));206 207 /* fallback: */208 162 pHead->Alignment = 0; 209 163 } … … 212 166 DECL_KERNEL32(PSLIST_ENTRY) Fake_InterlockedFlushSList(PSLIST_HEADER pHead) 213 167 { 214 INIT_FAKES(InterlockedFlushSList, (pHead));215 216 /* fallback: */217 168 PSLIST_ENTRY pRet = NULL; 218 169 if (pHead->Next.Next) … … 236 187 DECL_KERNEL32(PSLIST_ENTRY) Fake_InterlockedPopEntrySList(PSLIST_HEADER pHead) 237 188 { 238 INIT_FAKES(InterlockedPopEntrySList, (pHead));239 240 /* fallback: */241 189 PSLIST_ENTRY pRet = NULL; 242 190 for (;;) … … 268 216 DECL_KERNEL32(PSLIST_ENTRY) Fake_InterlockedPushEntrySList(PSLIST_HEADER pHead, PSLIST_ENTRY pEntry) 269 217 { 270 INIT_FAKES(InterlockedPushEntrySList, (pHead, pEntry));271 272 /* fallback: */273 218 PSLIST_ENTRY pRet = NULL; 274 219 for (;;) … … 289 234 DECL_KERNEL32(WORD) Fake_QueryDepthSList(PSLIST_HEADER pHead) 290 235 { 291 INIT_FAKES(QueryDepthSList, (pHead));292 293 /* fallback: */294 236 return pHead->Depth; 295 237 } … … 299 241 DECL_KERNEL32(BOOL) Fake_VerifyVersionInfoA(LPOSVERSIONINFOEXA pInfo, DWORD fTypeMask, DWORDLONG fConditionMask) 300 242 { 301 INIT_FAKES(VerifyVersionInfoA, (pInfo, fTypeMask, fConditionMask));302 303 /* fallback to make curl happy: */304 243 OSVERSIONINFOEXA VerInfo; 305 244 RT_ZERO(VerInfo); … … 357 296 DECL_KERNEL32(ULONGLONG) Fake_VerSetConditionMask(ULONGLONG fConditionMask, DWORD fTypeMask, BYTE bOperator) 358 297 { 359 INIT_FAKES(VerSetConditionMask, (fConditionMask, fTypeMask, bOperator));360 361 /* fallback: */362 298 for (unsigned i = 0; i < 8; i++) 363 299 if (fTypeMask & RT_BIT_32(i)) … … 378 314 DECL_KERNEL32(BOOL) Fake_IsProcessorFeaturePresent(DWORD enmProcessorFeature) 379 315 { 380 INIT_FAKES(IsProcessorFeaturePresent, (enmProcessorFeature));381 382 316 /* Could make more of an effort here... */ 317 RT_NOREF(enmProcessorFeature); 383 318 return FALSE; 384 319 } … … 387 322 DECL_KERNEL32(BOOL) Fake_CancelIo(HANDLE hHandle) 388 323 { 389 INIT_FAKES(CancelIo, (hHandle));390 391 324 /* NT 3.51 have the NTDLL API this corresponds to. */ 392 325 RESOLVE_NTDLL_API(NtCancelIoFile); … … 414 347 DECL_KERNEL32(BOOL) Fake_IsDebuggerPresent(VOID) 415 348 { 416 INIT_FAKES(IsDebuggerPresent, ());417 418 349 /* Fallback: */ 419 350 return FALSE; … … 423 354 DECL_KERNEL32(VOID) Fake_GetSystemTimeAsFileTime(LPFILETIME pTime) 424 355 { 425 INIT_FAKES_VOID(GetSystemTimeAsFileTime, (pTime));426 427 356 DWORD dwVersion = GetVersion(); 428 357 if ( (dwVersion & 0xff) > 3 … … 467 396 DECL_KERNEL32(BOOL) Fake_GetVersionExA(LPOSVERSIONINFOA pInfo) 468 397 { 469 INIT_FAKES(GetVersionExA, (pInfo));470 471 /*472 * Fallback.473 */474 398 DWORD dwVersion = GetVersion(); 475 399 … … 508 432 DECL_KERNEL32(BOOL) Fake_GetVersionExW(LPOSVERSIONINFOW pInfo) 509 433 { 510 INIT_FAKES(GetVersionExW, (pInfo));511 512 /*513 * Fallback.514 */515 434 DWORD dwVersion = GetVersion(); 516 435 … … 549 468 DECL_KERNEL32(LPWCH) Fake_GetEnvironmentStringsW(void) 550 469 { 551 INIT_FAKES(GetEnvironmentStringsW, ());552 553 470 /* 554 * Fallback:555 *556 471 * Environment is ANSI in NT 3.1. We should only be here for NT 3.1. 557 472 * For now, don't try do a perfect job converting it, just do it. … … 583 498 DECL_KERNEL32(BOOL) Fake_FreeEnvironmentStringsW(LPWCH pwszzEnv) 584 499 { 585 INIT_FAKES(FreeEnvironmentStringsW, (pwszzEnv));586 587 /* Fallback: */588 500 if (pwszzEnv) 589 501 HeapFree(GetProcessHeap(), 0, pwszzEnv); … … 594 506 DECL_KERNEL32(int) Fake_GetLocaleInfoA(LCID idLocale, LCTYPE enmType, LPSTR pData, int cchData) 595 507 { 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); 508 NOREF(idLocale); NOREF(enmType); NOREF(pData); NOREF(cchData); 509 //MY_ASSERT(false, "GetLocaleInfoA: idLocale=%#x enmType=%#x cchData=%#x", idLocale, enmType, cchData); 510 MY_ASSERT(false, "GetLocaleInfoA"); 600 511 SetLastError(ERROR_NOT_SUPPORTED); 601 512 return 0; … … 605 516 DECL_KERNEL32(BOOL) Fake_EnumSystemLocalesA(LOCALE_ENUMPROCA pfnCallback, DWORD fFlags) 606 517 { 607 INIT_FAKES(EnumSystemLocalesA, (pfnCallback, fFlags)); 608 609 /* Fallback: */ 610 MY_ASSERT(false, "EnumSystemLocalesA: pfnCallback=%p fFlags=%#x", pfnCallback, fFlags); 518 NOREF(pfnCallback); NOREF(fFlags); 519 //MY_ASSERT(false, "EnumSystemLocalesA: pfnCallback=%p fFlags=%#x", pfnCallback, fFlags); 520 MY_ASSERT(false, "EnumSystemLocalesA"); 611 521 SetLastError(ERROR_NOT_SUPPORTED); 612 522 return FALSE; … … 616 526 DECL_KERNEL32(BOOL) Fake_IsValidLocale(LCID idLocale, DWORD fFlags) 617 527 { 618 INIT_FAKES(IsValidLocale, (idLocale, fFlags)); 619 620 /* Fallback: */ 621 MY_ASSERT(false, "IsValidLocale: idLocale fFlags=%#x", idLocale, fFlags); 528 NOREF(idLocale); NOREF(fFlags); 529 //MY_ASSERT(false, "IsValidLocale: idLocale fFlags=%#x", idLocale, fFlags); 530 MY_ASSERT(false, "IsValidLocale"); 622 531 SetLastError(ERROR_NOT_SUPPORTED); 623 532 return FALSE; … … 627 536 DECL_KERNEL32(DWORD_PTR) Fake_SetThreadAffinityMask(HANDLE hThread, DWORD_PTR fAffinityMask) 628 537 { 629 INIT_FAKES(SetThreadAffinityMask, (hThread, fAffinityMask));630 631 /* Fallback: */632 538 SYSTEM_INFO SysInfo; 633 539 GetSystemInfo(&SysInfo); 634 MY_ASSERT(false, "SetThreadAffinityMask: hThread=%p fAffinityMask=%p SysInfo.dwActiveProcessorMask=%p", 635 hThread, fAffinityMask, SysInfo.dwActiveProcessorMask); 540 //MY_ASSERT(false, "SetThreadAffinityMask: hThread=%p fAffinityMask=%p SysInfo.dwActiveProcessorMask=%p", 541 // hThread, fAffinityMask, SysInfo.dwActiveProcessorMask); 542 MY_ASSERT(false, "SetThreadAffinityMask"); 636 543 if ( SysInfo.dwActiveProcessorMask == fAffinityMask 637 544 || fAffinityMask == ~(DWORD_PTR)0) … … 639 546 640 547 SetLastError(ERROR_NOT_SUPPORTED); 548 RT_NOREF(hThread); 641 549 return 0; 642 550 } … … 645 553 DECL_KERNEL32(BOOL) Fake_GetProcessAffinityMask(HANDLE hProcess, PDWORD_PTR pfProcessAffinityMask, PDWORD_PTR pfSystemAffinityMask) 646 554 { 647 INIT_FAKES(GetProcessAffinityMask, (hProcess, pfProcessAffinityMask, pfSystemAffinityMask));648 649 /* Fallback: */650 555 SYSTEM_INFO SysInfo; 651 556 GetSystemInfo(&SysInfo); 652 MY_ASSERT(false, "GetProcessAffinityMask: SysInfo.dwActiveProcessorMask=%p", SysInfo.dwActiveProcessorMask); 557 //MY_ASSERT(false, "GetProcessAffinityMask: SysInfo.dwActiveProcessorMask=%p", SysInfo.dwActiveProcessorMask); 558 MY_ASSERT(false, "GetProcessAffinityMask"); 653 559 if (pfProcessAffinityMask) 654 560 *pfProcessAffinityMask = SysInfo.dwActiveProcessorMask; 655 561 if (pfSystemAffinityMask) 656 562 *pfSystemAffinityMask = SysInfo.dwActiveProcessorMask; 563 RT_NOREF(hProcess); 657 564 return TRUE; 658 565 } … … 661 568 DECL_KERNEL32(BOOL) Fake_GetHandleInformation(HANDLE hObject, DWORD *pfFlags) 662 569 { 663 INIT_FAKES(GetHandleInformation, (hObject, pfFlags));664 665 /* Fallback: */666 570 OBJECT_HANDLE_FLAG_INFORMATION Info = { 0, 0 }; 667 571 DWORD cbRet = sizeof(Info); … … 674 578 } 675 579 *pfFlags = 0; 676 MY_ASSERT(rcNt == STATUS_INVALID_HANDLE, "rcNt=%#x", rcNt); 580 //MY_ASSERT(rcNt == STATUS_INVALID_HANDLE, "rcNt=%#x", rcNt); 581 MY_ASSERT(rcNt == STATUS_INVALID_HANDLE, "GetHandleInformation"); 677 582 SetLastError(rcNt == STATUS_INVALID_HANDLE ? ERROR_INVALID_HANDLE : ERROR_INVALID_FUNCTION); /* see also process-win.cpp */ 678 583 return FALSE; … … 682 587 DECL_KERNEL32(BOOL) Fake_SetHandleInformation(HANDLE hObject, DWORD fMask, DWORD fFlags) 683 588 { 684 INIT_FAKES(SetHandleInformation, (hObject, fMask, fFlags)); 685 686 /* Fallback: */ 589 NOREF(hObject); NOREF(fMask); NOREF(fFlags); 687 590 SetLastError(ERROR_INVALID_FUNCTION); 688 591 return FALSE; 592 } 593 594 595 596 /** 597 * Resolves all the APIs ones and for all, updating the fake IAT entries. 598 */ 599 DECLASM(void) FakeResolve_kernel32(void) 600 { 601 CURRENT_VERSION_VARIABLE(); 602 603 HMODULE hmod = GetModuleHandleW(L"kernel32"); 604 MY_ASSERT(hmod != NULL, "kernel32"); 605 606 #undef MAKE_IMPORT_ENTRY 607 #define MAKE_IMPORT_ENTRY(a_uMajorVer, a_uMinorVer, a_Name, a_cb) RESOLVE_IMPORT(a_uMajorVer, a_uMinorVer, a_Name, a_cb) 608 #include "vcc100-kernel32-fakes.h" 609 610 g_fInitialized = true; 689 611 } 690 612
Note:
See TracChangeset
for help on using the changeset viewer.