Changeset 70341 in vbox
- Timestamp:
- Dec 26, 2017 2:42:28 PM (7 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp
r70336 r70341 93 93 /** KeSetTargetProcessorDpc - Introducted in NT 3.51. */ 94 94 decltype(KeSetTargetProcessorDpc) *g_pfnrtKeSetTargetProcessorDpc; 95 /** KeInitializeTimerEx - Introduced in NT 4. */ 96 decltype(KeInitializeTimerEx) *g_pfnrtKeInitializeTimerEx; 95 97 /** Pointer to the MmProtectMdlSystemAddress kernel function if it's available. 96 98 * This API was introduced in XP. */ … … 303 305 GET_SYSTEM_ROUTINE(KeSetImportanceDpc); 304 306 GET_SYSTEM_ROUTINE(KeSetTargetProcessorDpc); 307 GET_SYSTEM_ROUTINE(KeInitializeTimerEx); 305 308 GET_SYSTEM_ROUTINE(MmProtectMdlSystemAddress); 306 309 GET_SYSTEM_ROUTINE(MmAllocatePagesForMdl); -
trunk/src/VBox/Runtime/r0drv/nt/internal-r0drv-nt.h
r70336 r70341 84 84 extern decltype(KeSetImportanceDpc) *g_pfnrtKeSetImportanceDpc; 85 85 extern decltype(KeSetTargetProcessorDpc) *g_pfnrtKeSetTargetProcessorDpc; 86 extern decltype(KeInitializeTimerEx) *g_pfnrtKeInitializeTimerEx; 86 87 extern decltype(MmProtectMdlSystemAddress) *g_pfnrtMmProtectMdlSystemAddress; 87 88 extern decltype(MmAllocatePagesForMdl) *g_pfnrtMmAllocatePagesForMdl; -
trunk/src/VBox/Runtime/r0drv/nt/nt3fakes-r0drv-nt.cpp
r70336 r70341 96 96 decltype(KfAcquireSpinLock) *g_pfnrtKfAcquireSpinLock; 97 97 decltype(KfReleaseSpinLock) *g_pfnrtKfReleaseSpinLock; 98 decltype(KefAcquireSpinLockAtDpcLevel) *g_pfnrtKefAcquireSpinLockAtDpcLevel; 99 decltype(KefReleaseSpinLockFromDpcLevel) *g_pfnrtKefReleaseSpinLockFromDpcLevel; 98 100 decltype(KfLowerIrql) *g_pfnrtKfLowerIrql; 99 101 decltype(KfRaiseIrql) *g_pfnrtKfRaiseIrql; … … 104 106 KIRQL (__stdcall *g_pfnrtKeAcquireSpinLock)(PKSPIN_LOCK); 105 107 VOID (__stdcall *g_pfnrtKeReleaseSpinLock)(PKSPIN_LOCK, KIRQL); 108 KIRQL (__stdcall *g_pfnrtKeAcquireSpinLockAtDpcLevel)(PKSPIN_LOCK); 109 VOID (__stdcall *g_pfnrtKeReleaseSpinLockFromDpcLevel)(PKSPIN_LOCK); 106 110 VOID (__stdcall *g_pfnrtKeLowerIrql)(KIRQL); 107 111 KIRQL (__stdcall *g_pfnrtKeRaiseIrql)(KIRQL); … … 468 472 uint32_t cbRm = 1; 469 473 470 if ( (bRm & X86_MODRM_MOD_MASK) == 3474 if ( (bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT) 471 475 || (bRm & (X86_MODRM_MOD_MASK | X86_MODRM_RM_MASK)) == 5) 472 476 cbRm += 4; /* disp32 */ 473 else if ((bRm & X86_MODRM_MOD_MASK) == 1)477 else if ((bRm & X86_MODRM_MOD_MASK) == (1 << X86_MODRM_MOD_SHIFT)) 474 478 cbRm += 1; /* disp8 */ 475 else if ((bRm & X86_MODRM_MOD_MASK) == 2)479 else if ((bRm & X86_MODRM_MOD_MASK) == (2 << X86_MODRM_MOD_SHIFT)) 476 480 cbRm += 2; /* disp16 */ 477 481 478 if ((bRm & X86_MODRM_RM_MASK) == 4 && (bRm & X86_MODRM_MOD_MASK) != 3)482 if ((bRm & X86_MODRM_RM_MASK) == 4 && (bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT)) 479 483 cbRm += 1; /* SIB */ 480 484 … … 515 519 AssertLogRelReturn(RT_CONCAT(g_pfnrt,a_fnFastcall) || RT_CONCAT(g_pfnrt,a_fnStdcall), VERR_INTERNAL_ERROR_3); \ 516 520 } while (0) 517 GET_FAST_CALL_SYSTEM_ROUTINE(IofCompleteRequest, IoCompleteRequest); 518 GET_FAST_CALL_SYSTEM_ROUTINE(ObfDereferenceObject, ObDereferenceObject); 519 GET_FAST_CALL_SYSTEM_ROUTINE(IofCallDriver, IofCallDriver); 520 GET_FAST_CALL_SYSTEM_ROUTINE(KfAcquireSpinLock, KeAcquireSpinLock); 521 GET_FAST_CALL_SYSTEM_ROUTINE(KfReleaseSpinLock, KeReleaseSpinLock); 522 GET_FAST_CALL_SYSTEM_ROUTINE(KfLowerIrql, KeLowerIrql); 523 GET_FAST_CALL_SYSTEM_ROUTINE(KfRaiseIrql, KeRaiseIrql); 521 GET_FAST_CALL_SYSTEM_ROUTINE(IofCompleteRequest, IoCompleteRequest); 522 GET_FAST_CALL_SYSTEM_ROUTINE(ObfDereferenceObject, ObDereferenceObject); 523 GET_FAST_CALL_SYSTEM_ROUTINE(IofCallDriver, IoCallDriver); 524 GET_FAST_CALL_SYSTEM_ROUTINE(KfAcquireSpinLock, KeAcquireSpinLock); 525 GET_FAST_CALL_SYSTEM_ROUTINE(KfReleaseSpinLock, KeReleaseSpinLock); 526 GET_FAST_CALL_SYSTEM_ROUTINE(KfLowerIrql, KeLowerIrql); 527 GET_FAST_CALL_SYSTEM_ROUTINE(KfRaiseIrql, KeRaiseIrql); 528 GET_FAST_CALL_SYSTEM_ROUTINE(KefAcquireSpinLockAtDpcLevel, KeAcquireSpinLockAtDpcLevel); 529 GET_FAST_CALL_SYSTEM_ROUTINE(KefReleaseSpinLockFromDpcLevel, KeReleaseSpinLockFromDpcLevel); 524 530 525 531 /* … … 541 547 if (!_imp__KeTickCount) 542 548 { 549 if (!g_fNt3VersionInitialized) 550 rtR0Nt3InitVersion(); 543 551 Assert(g_uNt3MajorVer == 3 && g_uNt3MinorVer < 50); 552 544 553 uint8_t const *pbCode = (uint8_t const *)RTR0DbgKrnlInfoGetSymbol(hKrnlInfo, NULL, "KeQueryTickCount"); 545 554 AssertLogRelReturn(pbCode, VERR_INTERNAL_ERROR_2); … … 550 559 switch (b1) 551 560 { 552 case 0x89: 553 /* mov reg, r/m ; We're looking for absolute address in r/m. */ 561 case 0x8b: /* mov reg, r/m ; We're looking for absolute address in r/m. */ 554 562 if ((pbCode[off] & (X86_MODRM_MOD_MASK | X86_MODRM_RM_MASK)) == 5 /*disp32*/) 555 563 _imp__KeTickCount = *(KSYSTEM_TIME **)&pbCode[off + 1]; 556 564 RT_FALL_THRU(); 557 case 0x8 b:565 case 0x89: /* mov r/m, reg */ 558 566 off += rtR0Nt3CalcModRmLength(pbCode[off]); 559 567 break; -
trunk/src/VBox/Runtime/r0drv/nt/nt3fakesA-r0drv-nt.asm
r70336 r70341 77 77 ; @param 2 The stdcall name. 78 78 ; @param 3 Byte size of arguments. 79 %macro FastOrStdCallWrapper 3 79 ; @param 4 Zero if 1:1 mapping; 80 ; One if 2nd parameter is a byte pointer that the farcall version 81 ; instead returns in al. 82 %macro FastOrStdCallWrapper 4 80 83 BEGINCODE 81 84 extern _g_pfnrt %+ %1 … … 91 94 push ebp 92 95 mov ebp, esp 96 %if %4 == 1 97 push dword 0 98 push esp 99 %else 93 100 push edx 101 %endif 94 102 push ecx 95 103 call [_g_pfnrt %+ %2] 104 %if %4 == 1 105 movzx eax, byte [ebp - 4] 106 %endif 96 107 leave 97 108 ret … … 107 118 %endmacro 108 119 109 FastOrStdCallWrapper IofCompleteRequest, IoCompleteRequest, 8 110 FastOrStdCallWrapper IofCallDriver, IoCallDriver, 8 111 FastOrStdCallWrapper ObfDereferenceObject, ObDereferenceObject, 4 112 FastOrStdCallWrapper KfAcquireSpinLock, KeAcquireSpinLock, 4 113 FastOrStdCallWrapper KfReleaseSpinLock, KeReleaseSpinLock, 8 114 FastOrStdCallWrapper KfLowerIrql, KeLowerIrql, 4 115 FastOrStdCallWrapper KfRaiseIrql, KeRaiseIrql, 4 120 FastOrStdCallWrapper IofCompleteRequest, IoCompleteRequest, 8, 0 121 FastOrStdCallWrapper IofCallDriver, IoCallDriver, 8, 0 122 FastOrStdCallWrapper ObfDereferenceObject, ObDereferenceObject, 4, 0 123 FastOrStdCallWrapper KfAcquireSpinLock, KeAcquireSpinLock, 4, 1 124 FastOrStdCallWrapper KfReleaseSpinLock, KeReleaseSpinLock, 8, 0 125 FastOrStdCallWrapper KfRaiseIrql, KeRaiseIrql, 4, 1 126 FastOrStdCallWrapper KfLowerIrql, KeLowerIrql, 4, 0 127 FastOrStdCallWrapper KefAcquireSpinLockAtDpcLevel, KeAcquireSpinLockAtDpcLevel, 4, 0 128 FastOrStdCallWrapper KefReleaseSpinLockFromDpcLevel,KeReleaseSpinLockFromDpcLevel, 4, 0 116 129 117 130 -
trunk/src/VBox/Runtime/r0drv/nt/timer-r0drv-nt.cpp
r70212 r70341 510 510 pTimer->pvUser = pvUser; 511 511 pTimer->u64NanoInterval = u64NanoInterval; 512 KeInitializeTimerEx(&pTimer->NtTimer, SynchronizationTimer); 512 if (g_pfnrtKeInitializeTimerEx) 513 g_pfnrtKeInitializeTimerEx(&pTimer->NtTimer, SynchronizationTimer); 514 else 515 KeInitializeTimer(&pTimer->NtTimer); 513 516 int rc = VINF_SUCCESS; 514 517 if (pTimer->fOmniTimer) -
trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakes.cpp
r70213 r70341 29 29 * Header Files * 30 30 *********************************************************************************************************************************/ 31 #define RT_NO_STRICT /* Minimal deps so that it works on NT 3.51 too. */31 //#define RT_NO_STRICT /* Minimal deps so that it works on NT 3.51 too. */ 32 32 #include <iprt/cdefs.h> 33 33 #include <iprt/types.h> … … 55 55 #define VerifyVersionInfoA Ignore_VerifyVersionInfoA 56 56 #define VerSetConditionMask Ignore_VerSetConditionMask 57 #define IsProcessorFeaturePresent Ignore_IsProcessorFeaturePresent /* NT 3.51 start */57 #define IsProcessorFeaturePresent Ignore_IsProcessorFeaturePresent /* NT 3.51 start */ 58 58 #define CancelIo Ignore_CancelIo 59 #define IsDebuggerPresent Ignore_IsDebuggerPresent /* NT 3.50 start */59 #define IsDebuggerPresent Ignore_IsDebuggerPresent /* NT 3.50 start */ 60 60 #define GetSystemTimeAsFileTime Ignore_GetSystemTimeAsFileTime 61 #define GetVersionExA Ignore_GetVersionExA /* NT 3.1 start */ 62 #define GetVersionExW Ignore_GetVersionExW 63 #define GetEnvironmentStringsW Ignore_GetEnvironmentStringsW 64 #define FreeEnvironmentStringsW Ignore_FreeEnvironmentStringsW 65 #define GetLocaleInfoA Ignore_GetLocaleInfoA 66 #define EnumSystemLocalesA Ignore_EnumSystemLocalesA 67 #define IsValidLocale Ignore_IsValidLocale 68 #define SetThreadAffinityMask Ignore_SetThreadAffinityMask 69 #define GetProcessAffinityMask Ignore_GetProcessAffinityMask 70 #define CommandLineToArgvW Ignore_CommandLineToArgvW 61 71 62 72 #include <iprt/nt/nt-and-windows.h> … … 81 91 #undef IsDebuggerPresent 82 92 #undef GetSystemTimeAsFileTime 83 84 93 #undef GetVersionExA 94 #undef GetVersionExW 95 #undef GetEnvironmentStringsW 96 #undef FreeEnvironmentStringsW 97 #undef GetLocaleInfoA 98 #undef EnumSystemLocalesA 99 #undef IsValidLocale 100 #undef SetThreadAffinityMask 101 #undef GetProcessAffinityMask 102 #undef CommandLineToArgvW 103 104 105 /********************************************************************************************************************************* 106 * Defined Constants And Macros * 107 *********************************************************************************************************************************/ 85 108 #ifndef HEAP_STANDARD 86 109 # define HEAP_STANDARD 0 … … 118 141 119 142 120 extern "C" 121 __declspec(dllexport) PVOID WINAPI 122 DecodePointer(PVOID pvEncoded) 143 /** Declare a kernel32 API. 144 * @note We are not exporting them as that causes duplicate symbol troubles in 145 * the OpenGL bits. */ 146 #define DECL_KERNEL32(a_Type) extern "C" a_Type WINAPI 147 148 149 /********************************************************************************************************************************* 150 * Internal Functions * 151 *********************************************************************************************************************************/ 152 DECL_KERNEL32(BOOL) WINAPI GetVersionExA(LPOSVERSIONINFOA pInfo); 153 154 155 DECL_KERNEL32(PVOID) DecodePointer(PVOID pvEncoded) 123 156 { 124 157 RESOLVE_ME(DecodePointer); … … 133 166 134 167 135 extern "C" 136 __declspec(dllexport) PVOID WINAPI 137 EncodePointer(PVOID pvNative) 168 DECL_KERNEL32(PVOID) EncodePointer(PVOID pvNative) 138 169 { 139 170 RESOLVE_ME(EncodePointer); … … 148 179 149 180 150 extern "C" 151 __declspec(dllexport) BOOL WINAPI 152 InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION pCritSect, DWORD cSpin) 181 DECL_KERNEL32(BOOL) InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION pCritSect, DWORD cSpin) 153 182 { 154 183 RESOLVE_ME(InitializeCriticalSectionAndSpinCount); … … 164 193 165 194 166 extern "C" 167 __declspec(dllexport) BOOL WINAPI 168 HeapSetInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, PVOID pvBuf, SIZE_T cbBuf) 195 DECL_KERNEL32(BOOL) HeapSetInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, PVOID pvBuf, SIZE_T cbBuf) 169 196 { 170 197 RESOLVE_ME(HeapSetInformation); … … 193 220 194 221 195 extern "C" 196 __declspec(dllexport) BOOL WINAPI 197 HeapQueryInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, PVOID pvBuf, SIZE_T cbBuf, PSIZE_T pcbRet) 222 DECL_KERNEL32(BOOL) HeapQueryInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, 223 PVOID pvBuf, SIZE_T cbBuf, PSIZE_T pcbRet) 198 224 { 199 225 RESOLVE_ME(HeapQueryInformation); … … 223 249 /* These are used by INTEL\mt_obj\Timer.obj: */ 224 250 225 extern "C" 226 __declspec(dllexport) 227 HANDLE WINAPI CreateTimerQueue(void) 251 DECL_KERNEL32(HANDLE) CreateTimerQueue(void) 228 252 { 229 253 RESOLVE_ME(CreateTimerQueue); … … 234 258 } 235 259 236 extern "C" 237 __declspec(dllexport) 238 BOOL WINAPI CreateTimerQueueTimer(PHANDLE phTimer, HANDLE hTimerQueue, WAITORTIMERCALLBACK pfnCallback, PVOID pvUser, 239 DWORD msDueTime, DWORD msPeriod, ULONG fFlags) 260 DECL_KERNEL32(BOOL) CreateTimerQueueTimer(PHANDLE phTimer, HANDLE hTimerQueue, WAITORTIMERCALLBACK pfnCallback, PVOID pvUser, 261 DWORD msDueTime, DWORD msPeriod, ULONG fFlags) 240 262 { 241 263 RESOLVE_ME(CreateTimerQueueTimer); … … 246 268 } 247 269 248 extern "C" 249 __declspec(dllexport) 250 BOOL WINAPI DeleteTimerQueueTimer(HANDLE hTimerQueue, HANDLE hTimer, HANDLE hEvtCompletion) 270 DECL_KERNEL32(BOOL) DeleteTimerQueueTimer(HANDLE hTimerQueue, HANDLE hTimer, HANDLE hEvtCompletion) 251 271 { 252 272 RESOLVE_ME(DeleteTimerQueueTimer); … … 259 279 /* This is used by several APIs. */ 260 280 261 extern "C" 262 __declspec(dllexport) 263 VOID WINAPI InitializeSListHead(PSLIST_HEADER pHead) 281 DECL_KERNEL32(VOID) InitializeSListHead(PSLIST_HEADER pHead) 264 282 { 265 283 RESOLVE_ME(InitializeSListHead); … … 271 289 272 290 273 extern "C" 274 __declspec(dllexport) 275 PSLIST_ENTRY WINAPI InterlockedFlushSList(PSLIST_HEADER pHead) 291 DECL_KERNEL32(PSLIST_ENTRY) InterlockedFlushSList(PSLIST_HEADER pHead) 276 292 { 277 293 RESOLVE_ME(InterlockedFlushSList); … … 299 315 } 300 316 301 extern "C" 302 __declspec(dllexport) 303 PSLIST_ENTRY WINAPI InterlockedPopEntrySList(PSLIST_HEADER pHead) 317 DECL_KERNEL32(PSLIST_ENTRY) InterlockedPopEntrySList(PSLIST_HEADER pHead) 304 318 { 305 319 RESOLVE_ME(InterlockedPopEntrySList); … … 335 349 } 336 350 337 extern "C" 338 __declspec(dllexport) 339 PSLIST_ENTRY WINAPI InterlockedPushEntrySList(PSLIST_HEADER pHead, PSLIST_ENTRY pEntry) 351 DECL_KERNEL32(PSLIST_ENTRY) InterlockedPushEntrySList(PSLIST_HEADER pHead, PSLIST_ENTRY pEntry) 340 352 { 341 353 RESOLVE_ME(InterlockedPushEntrySList); … … 360 372 } 361 373 362 extern "C" 363 __declspec(dllexport) 364 WORD WINAPI QueryDepthSList(PSLIST_HEADER pHead) 374 DECL_KERNEL32(WORD) QueryDepthSList(PSLIST_HEADER pHead) 365 375 { 366 376 RESOLVE_ME(QueryDepthSList); … … 372 382 373 383 /* curl drags these in: */ 374 extern "C" 375 __declspec(dllexport) 376 BOOL WINAPI VerifyVersionInfoA(LPOSVERSIONINFOEXA pInfo, DWORD fTypeMask, DWORDLONG fConditionMask) 384 DECL_KERNEL32(BOOL) VerifyVersionInfoA(LPOSVERSIONINFOEXA pInfo, DWORD fTypeMask, DWORDLONG fConditionMask) 377 385 { 378 386 RESOLVE_ME(VerifyVersionInfoA); … … 384 392 RT_ZERO(VerInfo); 385 393 VerInfo.dwOSVersionInfoSize = sizeof(VerInfo); 386 if (!GetVersionEx ((OSVERSIONINFO *)&VerInfo))394 if (!GetVersionExA((OSVERSIONINFO *)&VerInfo)) 387 395 { 388 396 RT_ZERO(VerInfo); 389 397 VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 390 AssertReturn(GetVersionEx ((OSVERSIONINFO *)&VerInfo), FALSE);398 AssertReturn(GetVersionExA((OSVERSIONINFO *)&VerInfo), FALSE); 391 399 } 392 400 … … 427 435 428 436 429 extern "C" 430 __declspec(dllexport) 431 ULONGLONG WINAPI VerSetConditionMask(ULONGLONG fConditionMask, DWORD fTypeMask, BYTE bOperator) 437 DECL_KERNEL32(ULONGLONG) VerSetConditionMask(ULONGLONG fConditionMask, DWORD fTypeMask, BYTE bOperator) 432 438 { 433 439 RESOLVE_ME(VerSetConditionMask); … … 452 458 */ 453 459 454 extern "C" DECLEXPORT(BOOL) WINAPIIsProcessorFeaturePresent(DWORD enmProcessorFeature)460 DECL_KERNEL32(BOOL) IsProcessorFeaturePresent(DWORD enmProcessorFeature) 455 461 { 456 462 RESOLVE_ME(IsProcessorFeaturePresent); … … 463 469 464 470 465 extern "C" DECLEXPORT(BOOL) WINAPICancelIo(HANDLE hHandle)471 DECL_KERNEL32(BOOL) CancelIo(HANDLE hHandle) 466 472 { 467 473 RESOLVE_ME(CancelIo); … … 492 498 */ 493 499 494 extern "C" DECLEXPORT(BOOL) WINAPIIsDebuggerPresent(VOID)500 DECL_KERNEL32(BOOL) IsDebuggerPresent(VOID) 495 501 { 496 502 RESOLVE_ME(IsDebuggerPresent); … … 501 507 502 508 503 extern "C" DECLEXPORT(VOID) WINAPIGetSystemTimeAsFileTime(LPFILETIME pTime)509 DECL_KERNEL32(VOID) GetSystemTimeAsFileTime(LPFILETIME pTime) 504 510 { 505 511 RESOLVE_ME(GetSystemTimeAsFileTime); … … 528 534 else 529 535 { 530 /** @todo */ 531 __debugbreak(); 532 } 533 } 536 /* NT 3.1 didn't have a KUSER_SHARED_DATA nor a GetSystemTimeAsFileTime export. */ 537 SYSTEMTIME SystemTime; 538 GetSystemTime(&SystemTime); 539 BOOL fRet = SystemTimeToFileTime(&SystemTime, pTime); 540 AssertStmt(fRet, pTime->dwHighDateTime = pTime->dwLowDateTime = 0); 541 } 542 } 543 } 544 545 546 /* 547 * NT 3.1 stuff. 548 */ 549 550 DECL_KERNEL32(BOOL) GetVersionExA(LPOSVERSIONINFOA pInfo) 551 { 552 RESOLVE_ME(GetVersionExA); 553 if (pfnApi) 554 return pfnApi(pInfo); 555 556 DWORD dwVersion = GetVersion(); 557 558 /* Common fields: */ 559 pInfo->dwMajorVersion = dwVersion & 0xff; 560 pInfo->dwMinorVersion = (dwVersion >> 8) & 0xff; 561 if (!(dwVersion & RT_BIT_32(31))) 562 pInfo->dwBuildNumber = dwVersion >> 16; 563 else 564 pInfo->dwBuildNumber = 511; 565 pInfo->dwPlatformId = VER_PLATFORM_WIN32_NT; 566 /** @todo get CSD from registry. */ 567 pInfo->szCSDVersion[0] = '\0'; 568 569 /* OSVERSIONINFOEX fields: */ 570 if (pInfo->dwOSVersionInfoSize > sizeof((*pInfo))) 571 { 572 LPOSVERSIONINFOEXA pInfoEx = (LPOSVERSIONINFOEXA)pInfo; 573 if (pInfoEx->dwOSVersionInfoSize > RT_UOFFSETOF(OSVERSIONINFOEXA, wServicePackMinor)) 574 { 575 pInfoEx->wServicePackMajor = 0; 576 pInfoEx->wServicePackMinor = 0; 577 } 578 if (pInfoEx->dwOSVersionInfoSize > RT_UOFFSETOF(OSVERSIONINFOEXA, wSuiteMask)) 579 pInfoEx->wSuiteMask = 0; 580 if (pInfoEx->dwOSVersionInfoSize > RT_UOFFSETOF(OSVERSIONINFOEXA, wProductType)) 581 pInfoEx->wProductType = VER_NT_WORKSTATION; 582 if (pInfoEx->wReserved > RT_UOFFSETOF(OSVERSIONINFOEXA, wProductType)) 583 pInfoEx->wReserved = 0; 584 } 585 586 return TRUE; 587 } 588 589 590 DECL_KERNEL32(BOOL) GetVersionExW(LPOSVERSIONINFOW pInfo) 591 { 592 RESOLVE_ME(GetVersionExW); 593 if (pfnApi) 594 return pfnApi(pInfo); 595 596 DWORD dwVersion = GetVersion(); 597 598 /* Common fields: */ 599 pInfo->dwMajorVersion = dwVersion & 0xff; 600 pInfo->dwMinorVersion = (dwVersion >> 8) & 0xff; 601 if (!(dwVersion & RT_BIT_32(31))) 602 pInfo->dwBuildNumber = dwVersion >> 16; 603 else 604 pInfo->dwBuildNumber = 511; 605 pInfo->dwPlatformId = VER_PLATFORM_WIN32_NT; 606 /** @todo get CSD from registry. */ 607 pInfo->szCSDVersion[0] = '\0'; 608 609 /* OSVERSIONINFOEX fields: */ 610 if (pInfo->dwOSVersionInfoSize > sizeof((*pInfo))) 611 { 612 LPOSVERSIONINFOEXW pInfoEx = (LPOSVERSIONINFOEXW)pInfo; 613 if (pInfoEx->dwOSVersionInfoSize > RT_UOFFSETOF(OSVERSIONINFOEXW, wServicePackMinor)) 614 { 615 pInfoEx->wServicePackMajor = 0; 616 pInfoEx->wServicePackMinor = 0; 617 } 618 if (pInfoEx->dwOSVersionInfoSize > RT_UOFFSETOF(OSVERSIONINFOEXW, wSuiteMask)) 619 pInfoEx->wSuiteMask = 0; 620 if (pInfoEx->dwOSVersionInfoSize > RT_UOFFSETOF(OSVERSIONINFOEXW, wProductType)) 621 pInfoEx->wProductType = VER_NT_WORKSTATION; 622 if (pInfoEx->wReserved > RT_UOFFSETOF(OSVERSIONINFOEXW, wProductType)) 623 pInfoEx->wReserved = 0; 624 } 625 626 return TRUE; 627 } 628 629 630 DECL_KERNEL32(LPWCH) GetEnvironmentStringsW(void) 631 { 632 RESOLVE_ME(GetEnvironmentStringsW); 633 if (pfnApi) 634 return pfnApi(); 635 636 /* 637 * Environment is ANSI in NT 3.1. We should only be here for NT 3.1. 638 * For now, don't try do a perfect job converting it, just do it. 639 */ 640 char *pszzEnv = (char *)RTNtCurrentPeb()->ProcessParameters->Environment; 641 size_t offEnv = 0; 642 while (pszzEnv[offEnv] != '\0') 643 { 644 size_t cchLen = strlen(&pszzEnv[offEnv]); 645 offEnv += cchLen + 1; 646 } 647 size_t const cchEnv = offEnv + 1; 648 649 PRTUTF16 pwszzEnv = (PRTUTF16)HeapAlloc(GetProcessHeap(), 0, cchEnv * sizeof(RTUTF16)); 650 if (!pwszzEnv) 651 return NULL; 652 for (offEnv = 0; offEnv < cchEnv; offEnv++) 653 { 654 unsigned char ch = pwszzEnv[offEnv]; 655 if (!(ch & 0x80)) 656 pwszzEnv[offEnv] = ch; 657 else 658 pwszzEnv[offEnv] = '_'; 659 } 660 return pwszzEnv; 661 } 662 663 664 DECL_KERNEL32(BOOL) FreeEnvironmentStringsW(LPWCH pwszzEnv) 665 { 666 RESOLVE_ME(FreeEnvironmentStringsW); 667 if (pfnApi) 668 return pfnApi(pwszzEnv); 669 if (pwszzEnv) 670 HeapFree(GetProcessHeap(), 0, pwszzEnv); 671 return TRUE; 672 } 673 674 675 DECL_KERNEL32(int) GetLocaleInfoA(LCID idLocale, LCTYPE enmType, LPSTR pData, int cchData) 676 { 677 RESOLVE_ME(GetLocaleInfoA); 678 if (pfnApi) 679 return pfnApi(idLocale, enmType, pData, cchData); 680 681 AssertMsgFailed(("GetLocaleInfoA: idLocale=%#x enmType=%#x cchData=%#x\n", idLocale, enmType, cchData)); 682 SetLastError(ERROR_NOT_SUPPORTED); 683 return 0; 684 } 685 686 687 DECL_KERNEL32(BOOL) EnumSystemLocalesA(LOCALE_ENUMPROCA pfnCallback, DWORD fFlags) 688 { 689 RESOLVE_ME(EnumSystemLocalesA); 690 if (pfnApi) 691 return pfnApi(pfnCallback, fFlags); 692 693 AssertMsgFailed(("EnumSystemLocalesA: pfnCallback=%p fFlags=%#x\n", pfnCallback, fFlags)); 694 SetLastError(ERROR_NOT_SUPPORTED); 695 return FALSE; 696 } 697 698 699 DECL_KERNEL32(BOOL) IsValidLocale(LCID idLocale, DWORD fFlags) 700 { 701 RESOLVE_ME(IsValidLocale); 702 if (pfnApi) 703 return pfnApi(idLocale, fFlags); 704 705 AssertMsgFailed(("IsValidLocale: idLocale fFlags=%#x\n", idLocale, fFlags)); 706 SetLastError(ERROR_NOT_SUPPORTED); 707 return FALSE; 708 } 709 710 711 DECL_KERNEL32(DWORD_PTR) SetThreadAffinityMask(HANDLE hThread, DWORD_PTR fAffinityMask) 712 { 713 RESOLVE_ME(SetThreadAffinityMask); 714 if (pfnApi) 715 return pfnApi(hThread, fAffinityMask); 716 717 SYSTEM_INFO SysInfo; 718 GetSystemInfo(&SysInfo); 719 AssertMsgFailed(("SetThreadAffinityMask: hThread=%p fAffinityMask=%p SysInfo.dwActiveProcessorMask=%p\n", 720 hThread, fAffinityMask, SysInfo.dwActiveProcessorMask)); 721 if ( SysInfo.dwActiveProcessorMask == fAffinityMask 722 || fAffinityMask == ~(DWORD_PTR)0) 723 return fAffinityMask; 724 725 SetLastError(ERROR_NOT_SUPPORTED); 726 return 0; 727 } 728 729 730 DECL_KERNEL32(BOOL) GetProcessAffinityMask(HANDLE hProcess, PDWORD_PTR pfProcessAffinityMask, PDWORD_PTR pfSystemAffinityMask) 731 { 732 RESOLVE_ME(GetProcessAffinityMask); 733 if (pfnApi) 734 return pfnApi(hProcess, pfProcessAffinityMask, pfSystemAffinityMask); 735 736 SYSTEM_INFO SysInfo; 737 GetSystemInfo(&SysInfo); 738 AssertMsgFailed(("GetProcessAffinityMask: SysInfo.dwActiveProcessorMask=%p\n", SysInfo.dwActiveProcessorMask)); 739 if (pfProcessAffinityMask) 740 *pfProcessAffinityMask = SysInfo.dwActiveProcessorMask; 741 if (pfSystemAffinityMask) 742 *pfSystemAffinityMask = SysInfo.dwActiveProcessorMask; 743 return TRUE; 744 } 745 746 747 /** @todo This is actually in SHELL32. */ 748 DECL_KERNEL32(LPWSTR *) CommandLineToArgvW(LPCWSTR pwszCmdLine, int *pcArgs) 749 { 750 RESOLVE_ME(CommandLineToArgvW); 751 if (pfnApi) 752 return pfnApi(pwszCmdLine, pcArgs); 753 754 *pcArgs = 0; 755 return NULL; 534 756 } 535 757 -
trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakesA.asm
r70213 r70341 45 45 GLOBALNAME vcc100_kernel32_fakes_asm 46 46 47 ; NT 4 47 48 MAKE_IMPORT_ENTRY DecodePointer, 4 48 49 MAKE_IMPORT_ENTRY EncodePointer, 4 … … 60 61 MAKE_IMPORT_ENTRY VerifyVersionInfoA, 16 61 62 MAKE_IMPORT_ENTRY VerSetConditionMask, 16 63 ; NT 3.51 62 64 MAKE_IMPORT_ENTRY IsProcessorFeaturePresent, 4 63 65 MAKE_IMPORT_ENTRY CancelIo, 4 66 ; NT 3.50 64 67 MAKE_IMPORT_ENTRY IsDebuggerPresent, 0 65 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 CommandLineToArgvW, 8 ; Lazy bird: this lives in shell32. 66 80
Note:
See TracChangeset
for help on using the changeset viewer.