VirtualBox

Changeset 70341 in vbox


Ignore:
Timestamp:
Dec 26, 2017 2:42:28 PM (7 years ago)
Author:
vboxsync
Message:

IPRT: More NT 3.1 compatibility tweaking.

Location:
trunk/src/VBox/Runtime
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp

    r70336 r70341  
    9393/** KeSetTargetProcessorDpc - Introducted in NT 3.51. */
    9494decltype(KeSetTargetProcessorDpc)      *g_pfnrtKeSetTargetProcessorDpc;
     95/** KeInitializeTimerEx - Introduced in NT 4. */
     96decltype(KeInitializeTimerEx)          *g_pfnrtKeInitializeTimerEx;
    9597/** Pointer to the MmProtectMdlSystemAddress kernel function if it's available.
    9698 * This API was introduced in XP. */
     
    303305    GET_SYSTEM_ROUTINE(KeSetImportanceDpc);
    304306    GET_SYSTEM_ROUTINE(KeSetTargetProcessorDpc);
     307    GET_SYSTEM_ROUTINE(KeInitializeTimerEx);
    305308    GET_SYSTEM_ROUTINE(MmProtectMdlSystemAddress);
    306309    GET_SYSTEM_ROUTINE(MmAllocatePagesForMdl);
  • trunk/src/VBox/Runtime/r0drv/nt/internal-r0drv-nt.h

    r70336 r70341  
    8484extern decltype(KeSetImportanceDpc)           *g_pfnrtKeSetImportanceDpc;
    8585extern decltype(KeSetTargetProcessorDpc)      *g_pfnrtKeSetTargetProcessorDpc;
     86extern decltype(KeInitializeTimerEx)          *g_pfnrtKeInitializeTimerEx;
    8687extern decltype(MmProtectMdlSystemAddress)    *g_pfnrtMmProtectMdlSystemAddress;
    8788extern decltype(MmAllocatePagesForMdl)        *g_pfnrtMmAllocatePagesForMdl;
  • trunk/src/VBox/Runtime/r0drv/nt/nt3fakes-r0drv-nt.cpp

    r70336 r70341  
    9696decltype(KfAcquireSpinLock)                *g_pfnrtKfAcquireSpinLock;
    9797decltype(KfReleaseSpinLock)                *g_pfnrtKfReleaseSpinLock;
     98decltype(KefAcquireSpinLockAtDpcLevel)     *g_pfnrtKefAcquireSpinLockAtDpcLevel;
     99decltype(KefReleaseSpinLockFromDpcLevel)   *g_pfnrtKefReleaseSpinLockFromDpcLevel;
    98100decltype(KfLowerIrql)                      *g_pfnrtKfLowerIrql;
    99101decltype(KfRaiseIrql)                      *g_pfnrtKfRaiseIrql;
     
    104106KIRQL                           (__stdcall *g_pfnrtKeAcquireSpinLock)(PKSPIN_LOCK);
    105107VOID                            (__stdcall *g_pfnrtKeReleaseSpinLock)(PKSPIN_LOCK, KIRQL);
     108KIRQL                           (__stdcall *g_pfnrtKeAcquireSpinLockAtDpcLevel)(PKSPIN_LOCK);
     109VOID                            (__stdcall *g_pfnrtKeReleaseSpinLockFromDpcLevel)(PKSPIN_LOCK);
    106110VOID                            (__stdcall *g_pfnrtKeLowerIrql)(KIRQL);
    107111KIRQL                           (__stdcall *g_pfnrtKeRaiseIrql)(KIRQL);
     
    468472    uint32_t cbRm = 1;
    469473
    470     if (   (bRm & X86_MODRM_MOD_MASK) == 3
     474    if (   (bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT)
    471475        || (bRm & (X86_MODRM_MOD_MASK | X86_MODRM_RM_MASK)) == 5)
    472476        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))
    474478        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))
    476480        cbRm += 2; /* disp16 */
    477481
    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))
    479483        cbRm += 1; /* SIB */
    480484
     
    515519            AssertLogRelReturn(RT_CONCAT(g_pfnrt,a_fnFastcall) || RT_CONCAT(g_pfnrt,a_fnStdcall), VERR_INTERNAL_ERROR_3); \
    516520        } 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);
    524530
    525531    /*
     
    541547    if (!_imp__KeTickCount)
    542548    {
     549        if (!g_fNt3VersionInitialized)
     550            rtR0Nt3InitVersion();
    543551        Assert(g_uNt3MajorVer == 3 && g_uNt3MinorVer < 50);
     552
    544553        uint8_t const *pbCode = (uint8_t const *)RTR0DbgKrnlInfoGetSymbol(hKrnlInfo, NULL, "KeQueryTickCount");
    545554        AssertLogRelReturn(pbCode, VERR_INTERNAL_ERROR_2);
     
    550559            switch (b1)
    551560            {
    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. */
    554562                    if ((pbCode[off] & (X86_MODRM_MOD_MASK | X86_MODRM_RM_MASK)) == 5 /*disp32*/)
    555563                        _imp__KeTickCount = *(KSYSTEM_TIME **)&pbCode[off + 1];
    556564                    RT_FALL_THRU();
    557                 case 0x8b:
     565                case 0x89: /* mov r/m, reg */
    558566                    off += rtR0Nt3CalcModRmLength(pbCode[off]);
    559567                    break;
  • trunk/src/VBox/Runtime/r0drv/nt/nt3fakesA-r0drv-nt.asm

    r70336 r70341  
    7777; @param 2  The stdcall name.
    7878; @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
    8083BEGINCODE
    8184extern _g_pfnrt %+ %1
     
    9194        push    ebp
    9295        mov     ebp, esp
     96%if %4 == 1
     97        push    dword 0
     98        push    esp
     99%else
    93100        push    edx
     101%endif
    94102        push    ecx
    95103        call    [_g_pfnrt %+ %2]
     104%if %4 == 1
     105        movzx   eax, byte [ebp - 4]
     106%endif
    96107        leave
    97108        ret
     
    107118%endmacro
    108119
    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
     120FastOrStdCallWrapper IofCompleteRequest,            IoCompleteRequest,              8, 0
     121FastOrStdCallWrapper IofCallDriver,                 IoCallDriver,                   8, 0
     122FastOrStdCallWrapper ObfDereferenceObject,          ObDereferenceObject,            4, 0
     123FastOrStdCallWrapper KfAcquireSpinLock,             KeAcquireSpinLock,              4, 1
     124FastOrStdCallWrapper KfReleaseSpinLock,             KeReleaseSpinLock,              8, 0
     125FastOrStdCallWrapper KfRaiseIrql,                   KeRaiseIrql,                    4, 1
     126FastOrStdCallWrapper KfLowerIrql,                   KeLowerIrql,                    4, 0
     127FastOrStdCallWrapper KefAcquireSpinLockAtDpcLevel,  KeAcquireSpinLockAtDpcLevel,    4, 0
     128FastOrStdCallWrapper KefReleaseSpinLockFromDpcLevel,KeReleaseSpinLockFromDpcLevel,  4, 0
    116129
    117130
  • trunk/src/VBox/Runtime/r0drv/nt/timer-r0drv-nt.cpp

    r70212 r70341  
    510510    pTimer->pvUser = pvUser;
    511511    pTimer->u64NanoInterval = u64NanoInterval;
    512     KeInitializeTimerEx(&pTimer->NtTimer, SynchronizationTimer);
     512    if (g_pfnrtKeInitializeTimerEx)
     513        g_pfnrtKeInitializeTimerEx(&pTimer->NtTimer, SynchronizationTimer);
     514    else
     515        KeInitializeTimer(&pTimer->NtTimer);
    513516    int rc = VINF_SUCCESS;
    514517    if (pTimer->fOmniTimer)
  • trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakes.cpp

    r70213 r70341  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
    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. */
    3232#include <iprt/cdefs.h>
    3333#include <iprt/types.h>
     
    5555#define VerifyVersionInfoA                      Ignore_VerifyVersionInfoA
    5656#define VerSetConditionMask                     Ignore_VerSetConditionMask
    57 #define IsProcessorFeaturePresent               Ignore_IsProcessorFeaturePresent /* NT 3.51 start */
     57#define IsProcessorFeaturePresent               Ignore_IsProcessorFeaturePresent    /* NT 3.51 start */
    5858#define CancelIo                                Ignore_CancelIo
    59 #define IsDebuggerPresent                       Ignore_IsDebuggerPresent /* NT 3.50 start */
     59#define IsDebuggerPresent                       Ignore_IsDebuggerPresent            /* NT 3.50 start */
    6060#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
    6171
    6272#include <iprt/nt/nt-and-windows.h>
     
    8191#undef IsDebuggerPresent
    8292#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*********************************************************************************************************************************/
    85108#ifndef HEAP_STANDARD
    86109# define HEAP_STANDARD 0
     
    118141
    119142
    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*********************************************************************************************************************************/
     152DECL_KERNEL32(BOOL) WINAPI GetVersionExA(LPOSVERSIONINFOA pInfo);
     153
     154
     155DECL_KERNEL32(PVOID) DecodePointer(PVOID pvEncoded)
    123156{
    124157    RESOLVE_ME(DecodePointer);
     
    133166
    134167
    135 extern "C"
    136 __declspec(dllexport) PVOID WINAPI
    137 EncodePointer(PVOID pvNative)
     168DECL_KERNEL32(PVOID) EncodePointer(PVOID pvNative)
    138169{
    139170    RESOLVE_ME(EncodePointer);
     
    148179
    149180
    150 extern "C"
    151 __declspec(dllexport) BOOL WINAPI
    152 InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION pCritSect, DWORD cSpin)
     181DECL_KERNEL32(BOOL) InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION pCritSect, DWORD cSpin)
    153182{
    154183    RESOLVE_ME(InitializeCriticalSectionAndSpinCount);
     
    164193
    165194
    166 extern "C"
    167 __declspec(dllexport) BOOL WINAPI
    168 HeapSetInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, PVOID pvBuf, SIZE_T cbBuf)
     195DECL_KERNEL32(BOOL) HeapSetInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, PVOID pvBuf, SIZE_T cbBuf)
    169196{
    170197    RESOLVE_ME(HeapSetInformation);
     
    193220
    194221
    195 extern "C"
    196 __declspec(dllexport) BOOL WINAPI
    197 HeapQueryInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, PVOID pvBuf, SIZE_T cbBuf, PSIZE_T pcbRet)
     222DECL_KERNEL32(BOOL) HeapQueryInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass,
     223                                         PVOID pvBuf, SIZE_T cbBuf, PSIZE_T pcbRet)
    198224{
    199225    RESOLVE_ME(HeapQueryInformation);
     
    223249/* These are used by INTEL\mt_obj\Timer.obj: */
    224250
    225 extern "C"
    226 __declspec(dllexport)
    227 HANDLE WINAPI CreateTimerQueue(void)
     251DECL_KERNEL32(HANDLE) CreateTimerQueue(void)
    228252{
    229253    RESOLVE_ME(CreateTimerQueue);
     
    234258}
    235259
    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)
     260DECL_KERNEL32(BOOL) CreateTimerQueueTimer(PHANDLE phTimer, HANDLE hTimerQueue, WAITORTIMERCALLBACK pfnCallback, PVOID pvUser,
     261                                          DWORD msDueTime, DWORD msPeriod, ULONG fFlags)
    240262{
    241263    RESOLVE_ME(CreateTimerQueueTimer);
     
    246268}
    247269
    248 extern "C"
    249 __declspec(dllexport)
    250 BOOL WINAPI DeleteTimerQueueTimer(HANDLE hTimerQueue, HANDLE hTimer, HANDLE hEvtCompletion)
     270DECL_KERNEL32(BOOL) DeleteTimerQueueTimer(HANDLE hTimerQueue, HANDLE hTimer, HANDLE hEvtCompletion)
    251271{
    252272    RESOLVE_ME(DeleteTimerQueueTimer);
     
    259279/* This is used by several APIs. */
    260280
    261 extern "C"
    262 __declspec(dllexport)
    263 VOID WINAPI InitializeSListHead(PSLIST_HEADER pHead)
     281DECL_KERNEL32(VOID) InitializeSListHead(PSLIST_HEADER pHead)
    264282{
    265283    RESOLVE_ME(InitializeSListHead);
     
    271289
    272290
    273 extern "C"
    274 __declspec(dllexport)
    275 PSLIST_ENTRY WINAPI InterlockedFlushSList(PSLIST_HEADER pHead)
     291DECL_KERNEL32(PSLIST_ENTRY) InterlockedFlushSList(PSLIST_HEADER pHead)
    276292{
    277293    RESOLVE_ME(InterlockedFlushSList);
     
    299315}
    300316
    301 extern "C"
    302 __declspec(dllexport)
    303 PSLIST_ENTRY WINAPI InterlockedPopEntrySList(PSLIST_HEADER pHead)
     317DECL_KERNEL32(PSLIST_ENTRY) InterlockedPopEntrySList(PSLIST_HEADER pHead)
    304318{
    305319    RESOLVE_ME(InterlockedPopEntrySList);
     
    335349}
    336350
    337 extern "C"
    338 __declspec(dllexport)
    339 PSLIST_ENTRY WINAPI InterlockedPushEntrySList(PSLIST_HEADER pHead, PSLIST_ENTRY pEntry)
     351DECL_KERNEL32(PSLIST_ENTRY) InterlockedPushEntrySList(PSLIST_HEADER pHead, PSLIST_ENTRY pEntry)
    340352{
    341353    RESOLVE_ME(InterlockedPushEntrySList);
     
    360372}
    361373
    362 extern "C"
    363 __declspec(dllexport)
    364 WORD WINAPI QueryDepthSList(PSLIST_HEADER pHead)
     374DECL_KERNEL32(WORD) QueryDepthSList(PSLIST_HEADER pHead)
    365375{
    366376    RESOLVE_ME(QueryDepthSList);
     
    372382
    373383/* curl drags these in: */
    374 extern "C"
    375 __declspec(dllexport)
    376 BOOL WINAPI VerifyVersionInfoA(LPOSVERSIONINFOEXA pInfo, DWORD fTypeMask, DWORDLONG fConditionMask)
     384DECL_KERNEL32(BOOL) VerifyVersionInfoA(LPOSVERSIONINFOEXA pInfo, DWORD fTypeMask, DWORDLONG fConditionMask)
    377385{
    378386    RESOLVE_ME(VerifyVersionInfoA);
     
    384392    RT_ZERO(VerInfo);
    385393    VerInfo.dwOSVersionInfoSize = sizeof(VerInfo);
    386     if (!GetVersionEx((OSVERSIONINFO *)&VerInfo))
     394    if (!GetVersionExA((OSVERSIONINFO *)&VerInfo))
    387395    {
    388396        RT_ZERO(VerInfo);
    389397        VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    390         AssertReturn(GetVersionEx((OSVERSIONINFO *)&VerInfo), FALSE);
     398        AssertReturn(GetVersionExA((OSVERSIONINFO *)&VerInfo), FALSE);
    391399    }
    392400
     
    427435
    428436
    429 extern "C"
    430 __declspec(dllexport)
    431 ULONGLONG WINAPI VerSetConditionMask(ULONGLONG fConditionMask, DWORD fTypeMask, BYTE bOperator)
     437DECL_KERNEL32(ULONGLONG) VerSetConditionMask(ULONGLONG fConditionMask, DWORD fTypeMask, BYTE bOperator)
    432438{
    433439    RESOLVE_ME(VerSetConditionMask);
     
    452458 */
    453459
    454 extern "C" DECLEXPORT(BOOL) WINAPI IsProcessorFeaturePresent(DWORD enmProcessorFeature)
     460DECL_KERNEL32(BOOL) IsProcessorFeaturePresent(DWORD enmProcessorFeature)
    455461{
    456462    RESOLVE_ME(IsProcessorFeaturePresent);
     
    463469
    464470
    465 extern "C" DECLEXPORT(BOOL) WINAPI CancelIo(HANDLE hHandle)
     471DECL_KERNEL32(BOOL) CancelIo(HANDLE hHandle)
    466472{
    467473    RESOLVE_ME(CancelIo);
     
    492498 */
    493499
    494 extern "C" DECLEXPORT(BOOL) WINAPI IsDebuggerPresent(VOID)
     500DECL_KERNEL32(BOOL) IsDebuggerPresent(VOID)
    495501{
    496502    RESOLVE_ME(IsDebuggerPresent);
     
    501507
    502508
    503 extern "C" DECLEXPORT(VOID) WINAPI GetSystemTimeAsFileTime(LPFILETIME pTime)
     509DECL_KERNEL32(VOID) GetSystemTimeAsFileTime(LPFILETIME pTime)
    504510{
    505511    RESOLVE_ME(GetSystemTimeAsFileTime);
     
    528534        else
    529535        {
    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
     550DECL_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
     590DECL_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
     630DECL_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
     664DECL_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
     675DECL_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
     687DECL_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
     699DECL_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
     711DECL_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
     730DECL_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. */
     748DECL_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;
    534756}
    535757
  • trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakesA.asm

    r70213 r70341  
    4545GLOBALNAME vcc100_kernel32_fakes_asm
    4646
     47; NT 4
    4748MAKE_IMPORT_ENTRY DecodePointer, 4
    4849MAKE_IMPORT_ENTRY EncodePointer, 4
     
    6061MAKE_IMPORT_ENTRY VerifyVersionInfoA, 16
    6162MAKE_IMPORT_ENTRY VerSetConditionMask, 16
     63; NT 3.51
    6264MAKE_IMPORT_ENTRY IsProcessorFeaturePresent, 4
    6365MAKE_IMPORT_ENTRY CancelIo, 4
     66; NT 3.50
    6467MAKE_IMPORT_ENTRY IsDebuggerPresent, 0
    6568MAKE_IMPORT_ENTRY GetSystemTimeAsFileTime, 4
     69; NT 3.1
     70MAKE_IMPORT_ENTRY GetVersionExA, 4
     71MAKE_IMPORT_ENTRY GetVersionExW, 4
     72MAKE_IMPORT_ENTRY GetEnvironmentStringsW, 0
     73MAKE_IMPORT_ENTRY FreeEnvironmentStringsW, 4
     74MAKE_IMPORT_ENTRY GetLocaleInfoA, 16
     75MAKE_IMPORT_ENTRY EnumSystemLocalesA, 8
     76MAKE_IMPORT_ENTRY IsValidLocale, 8
     77MAKE_IMPORT_ENTRY SetThreadAffinityMask, 8
     78MAKE_IMPORT_ENTRY GetProcessAffinityMask, 12
     79MAKE_IMPORT_ENTRY CommandLineToArgvW, 8 ; Lazy bird: this lives in shell32.
    6680
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette