VirtualBox

Ignore:
Timestamp:
Dec 30, 2017 7:27:35 PM (7 years ago)
Author:
vboxsync
Message:

vcc100-*: fixes and optimizations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakes.cpp

    r70375 r70394  
    7070
    7171
    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 
    8972
    9073DECL_KERNEL32(PVOID) Fake_DecodePointer(PVOID pvEncoded)
    9174{
    92     INIT_FAKES(DecodePointer,(pvEncoded));
    93 
    94     /*
    95      * Fallback code.
    96      */
    9775    return pvEncoded;
    9876}
     
    10179DECL_KERNEL32(PVOID) Fake_EncodePointer(PVOID pvNative)
    10280{
    103     INIT_FAKES(EncodePointer, (pvNative));
    104 
    105     /*
    106      * Fallback code.
    107      */
    10881    return pvNative;
    10982}
     
    11285DECL_KERNEL32(BOOL) Fake_InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION pCritSect, DWORD cSpin)
    11386{
    114     INIT_FAKES(InitializeCriticalSectionAndSpinCount, (pCritSect, cSpin));
    115 
    116     /*
    117      * Fallback code.
    118      */
     87    RT_NOREF(cSpin);
    11988    InitializeCriticalSection(pCritSect);
    12089    return TRUE;
     
    12493DECL_KERNEL32(BOOL) Fake_HeapSetInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, PVOID pvBuf, SIZE_T cbBuf)
    12594{
    126     INIT_FAKES(HeapSetInformation, (hHeap, enmInfoClass, pvBuf, cbBuf));
    127 
    128     /*
    129      * Fallback code.
    130      */
     95    RT_NOREF(hHeap);
    13196    if (enmInfoClass == HeapCompatibilityInformation)
    13297    {
     
    150115                                              PVOID pvBuf, SIZE_T cbBuf, PSIZE_T pcbRet)
    151116{
    152     INIT_FAKES(HeapQueryInformation, (hHeap, enmInfoClass, pvBuf, cbBuf, pcbRet));
    153 
    154     /*
    155      * Fallback code.
    156      */
     117    RT_NOREF(hHeap);
    157118    if (enmInfoClass == HeapCompatibilityInformation)
    158119    {
     
    176137DECL_KERNEL32(HANDLE) Fake_CreateTimerQueue(void)
    177138{
    178     INIT_FAKES(CreateTimerQueue, ());
    179 
    180139    SetLastError(ERROR_NOT_SUPPORTED);
    181140    return NULL;
     
    185144                                               DWORD msDueTime, DWORD msPeriod, ULONG fFlags)
    186145{
    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);
    189147    SetLastError(ERROR_NOT_SUPPORTED);
    190148    return FALSE;
     
    193151DECL_KERNEL32(BOOL) Fake_DeleteTimerQueueTimer(HANDLE hTimerQueue, HANDLE hTimer, HANDLE hEvtCompletion)
    194152{
    195     INIT_FAKES(DeleteTimerQueueTimer, (hTimerQueue, hTimer, hEvtCompletion));
    196 
     153    NOREF(hTimerQueue); NOREF(hTimer); NOREF(hEvtCompletion);
    197154    SetLastError(ERROR_NOT_SUPPORTED);
    198155    return FALSE;
     
    203160DECL_KERNEL32(VOID) Fake_InitializeSListHead(PSLIST_HEADER pHead)
    204161{
    205     INIT_FAKES_VOID(InitializeSListHead, (pHead));
    206 
    207     /* fallback: */
    208162    pHead->Alignment = 0;
    209163}
     
    212166DECL_KERNEL32(PSLIST_ENTRY) Fake_InterlockedFlushSList(PSLIST_HEADER pHead)
    213167{
    214     INIT_FAKES(InterlockedFlushSList, (pHead));
    215 
    216     /* fallback: */
    217168    PSLIST_ENTRY pRet = NULL;
    218169    if (pHead->Next.Next)
     
    236187DECL_KERNEL32(PSLIST_ENTRY) Fake_InterlockedPopEntrySList(PSLIST_HEADER pHead)
    237188{
    238     INIT_FAKES(InterlockedPopEntrySList, (pHead));
    239 
    240     /* fallback: */
    241189    PSLIST_ENTRY pRet = NULL;
    242190    for (;;)
     
    268216DECL_KERNEL32(PSLIST_ENTRY) Fake_InterlockedPushEntrySList(PSLIST_HEADER pHead, PSLIST_ENTRY pEntry)
    269217{
    270     INIT_FAKES(InterlockedPushEntrySList, (pHead, pEntry));
    271 
    272     /* fallback: */
    273218    PSLIST_ENTRY pRet = NULL;
    274219    for (;;)
     
    289234DECL_KERNEL32(WORD) Fake_QueryDepthSList(PSLIST_HEADER pHead)
    290235{
    291     INIT_FAKES(QueryDepthSList, (pHead));
    292 
    293     /* fallback: */
    294236    return pHead->Depth;
    295237}
     
    299241DECL_KERNEL32(BOOL) Fake_VerifyVersionInfoA(LPOSVERSIONINFOEXA pInfo, DWORD fTypeMask, DWORDLONG fConditionMask)
    300242{
    301     INIT_FAKES(VerifyVersionInfoA, (pInfo, fTypeMask, fConditionMask));
    302 
    303     /* fallback to make curl happy: */
    304243    OSVERSIONINFOEXA VerInfo;
    305244    RT_ZERO(VerInfo);
     
    357296DECL_KERNEL32(ULONGLONG) Fake_VerSetConditionMask(ULONGLONG fConditionMask, DWORD fTypeMask, BYTE bOperator)
    358297{
    359     INIT_FAKES(VerSetConditionMask, (fConditionMask, fTypeMask, bOperator));
    360 
    361     /* fallback: */
    362298    for (unsigned i = 0; i < 8; i++)
    363299        if (fTypeMask & RT_BIT_32(i))
     
    378314DECL_KERNEL32(BOOL) Fake_IsProcessorFeaturePresent(DWORD enmProcessorFeature)
    379315{
    380     INIT_FAKES(IsProcessorFeaturePresent, (enmProcessorFeature));
    381 
    382316    /* Could make more of an effort here... */
     317    RT_NOREF(enmProcessorFeature);
    383318    return FALSE;
    384319}
     
    387322DECL_KERNEL32(BOOL) Fake_CancelIo(HANDLE hHandle)
    388323{
    389     INIT_FAKES(CancelIo, (hHandle));
    390 
    391324    /* NT 3.51 have the NTDLL API this corresponds to. */
    392325    RESOLVE_NTDLL_API(NtCancelIoFile);
     
    414347DECL_KERNEL32(BOOL) Fake_IsDebuggerPresent(VOID)
    415348{
    416     INIT_FAKES(IsDebuggerPresent, ());
    417 
    418349    /* Fallback: */
    419350    return FALSE;
     
    423354DECL_KERNEL32(VOID) Fake_GetSystemTimeAsFileTime(LPFILETIME pTime)
    424355{
    425     INIT_FAKES_VOID(GetSystemTimeAsFileTime, (pTime));
    426 
    427356    DWORD dwVersion = GetVersion();
    428357    if (   (dwVersion & 0xff) > 3
     
    467396DECL_KERNEL32(BOOL) Fake_GetVersionExA(LPOSVERSIONINFOA pInfo)
    468397{
    469     INIT_FAKES(GetVersionExA, (pInfo));
    470 
    471     /*
    472      * Fallback.
    473      */
    474398    DWORD dwVersion = GetVersion();
    475399
     
    508432DECL_KERNEL32(BOOL) Fake_GetVersionExW(LPOSVERSIONINFOW pInfo)
    509433{
    510     INIT_FAKES(GetVersionExW, (pInfo));
    511 
    512     /*
    513      * Fallback.
    514      */
    515434    DWORD dwVersion = GetVersion();
    516435
     
    549468DECL_KERNEL32(LPWCH) Fake_GetEnvironmentStringsW(void)
    550469{
    551     INIT_FAKES(GetEnvironmentStringsW, ());
    552 
    553470    /*
    554      * Fallback:
    555      *
    556471     * Environment is ANSI in NT 3.1. We should only be here for NT 3.1.
    557472     * For now, don't try do a perfect job converting it, just do it.
     
    583498DECL_KERNEL32(BOOL) Fake_FreeEnvironmentStringsW(LPWCH pwszzEnv)
    584499{
    585     INIT_FAKES(FreeEnvironmentStringsW, (pwszzEnv));
    586 
    587     /* Fallback: */
    588500    if (pwszzEnv)
    589501        HeapFree(GetProcessHeap(), 0, pwszzEnv);
     
    594506DECL_KERNEL32(int) Fake_GetLocaleInfoA(LCID idLocale, LCTYPE enmType, LPSTR pData, int cchData)
    595507{
    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");
    600511    SetLastError(ERROR_NOT_SUPPORTED);
    601512    return 0;
     
    605516DECL_KERNEL32(BOOL) Fake_EnumSystemLocalesA(LOCALE_ENUMPROCA pfnCallback, DWORD fFlags)
    606517{
    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");
    611521    SetLastError(ERROR_NOT_SUPPORTED);
    612522    return FALSE;
     
    616526DECL_KERNEL32(BOOL) Fake_IsValidLocale(LCID idLocale, DWORD fFlags)
    617527{
    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");
    622531    SetLastError(ERROR_NOT_SUPPORTED);
    623532    return FALSE;
     
    627536DECL_KERNEL32(DWORD_PTR) Fake_SetThreadAffinityMask(HANDLE hThread, DWORD_PTR fAffinityMask)
    628537{
    629     INIT_FAKES(SetThreadAffinityMask, (hThread, fAffinityMask));
    630 
    631     /* Fallback: */
    632538    SYSTEM_INFO SysInfo;
    633539    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");
    636543    if (   SysInfo.dwActiveProcessorMask == fAffinityMask
    637544        || fAffinityMask                 == ~(DWORD_PTR)0)
     
    639546
    640547    SetLastError(ERROR_NOT_SUPPORTED);
     548    RT_NOREF(hThread);
    641549    return 0;
    642550}
     
    645553DECL_KERNEL32(BOOL) Fake_GetProcessAffinityMask(HANDLE hProcess, PDWORD_PTR pfProcessAffinityMask, PDWORD_PTR pfSystemAffinityMask)
    646554{
    647     INIT_FAKES(GetProcessAffinityMask, (hProcess, pfProcessAffinityMask, pfSystemAffinityMask));
    648 
    649     /* Fallback: */
    650555    SYSTEM_INFO SysInfo;
    651556    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");
    653559    if (pfProcessAffinityMask)
    654560        *pfProcessAffinityMask = SysInfo.dwActiveProcessorMask;
    655561    if (pfSystemAffinityMask)
    656562        *pfSystemAffinityMask  = SysInfo.dwActiveProcessorMask;
     563    RT_NOREF(hProcess);
    657564    return TRUE;
    658565}
     
    661568DECL_KERNEL32(BOOL) Fake_GetHandleInformation(HANDLE hObject, DWORD *pfFlags)
    662569{
    663     INIT_FAKES(GetHandleInformation, (hObject, pfFlags));
    664 
    665     /* Fallback: */
    666570    OBJECT_HANDLE_FLAG_INFORMATION  Info  = { 0, 0 };
    667571    DWORD                           cbRet = sizeof(Info);
     
    674578    }
    675579    *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");
    677582    SetLastError(rcNt == STATUS_INVALID_HANDLE ? ERROR_INVALID_HANDLE : ERROR_INVALID_FUNCTION); /* see also process-win.cpp */
    678583    return FALSE;
     
    682587DECL_KERNEL32(BOOL) Fake_SetHandleInformation(HANDLE hObject, DWORD fMask, DWORD fFlags)
    683588{
    684     INIT_FAKES(SetHandleInformation, (hObject, fMask, fFlags));
    685 
    686     /* Fallback: */
     589    NOREF(hObject); NOREF(fMask); NOREF(fFlags);
    687590    SetLastError(ERROR_INVALID_FUNCTION);
    688591    return FALSE;
     592}
     593
     594
     595
     596/**
     597 * Resolves all the APIs ones and for all, updating the fake IAT entries.
     598 */
     599DECLASM(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;
    689611}
    690612
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