VirtualBox

Changeset 82629 in vbox for trunk/src


Ignore:
Timestamp:
Dec 20, 2019 3:46:48 PM (5 years ago)
Author:
vboxsync
Message:

Windows Additions/Installer: initialize IPRT, do mot mix FreeLibrary with RTLdrClose.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/VBoxGuestInstallHelper.cpp

    r82627 r82629  
    6262HINSTANCE               g_hInstance;
    6363HWND                    g_hwndParent;
    64 PFNSFCFILEEXCEPTION     g_pfnSfcFileException = NULL;
    6564
    6665/**
     
    241240    if (RT_SUCCESS(rc))
    242241    {
    243         HMODULE hSFCNative = NULL; /* Native fallback. */
    244 
    245242        RTLDRMOD hSFC;
    246         rc = RTLdrLoadSystem("sfc_os.dll", true /* fNoUnload */, &hSFC);
     243        rc = RTLdrLoadSystem("sfc_os.dll", false /* fNoUnload */, &hSFC);
    247244        if (RT_SUCCESS(rc))
    248245        {
    249             rc = RTLdrGetSymbol(hSFC, "SfcFileException", (void **)&g_pfnSfcFileException);
     246            PFNSFCFILEEXCEPTION pfnSfcFileException = NULL;
     247            rc = RTLdrGetSymbol(hSFC, "SfcFileException", (void **)&pfnSfcFileException);
    250248            if (RT_FAILURE(rc))
    251249            {
    252                 hSFCNative = (HMODULE)RTLdrGetNativeHandle(hSFC);
     250                /* Native fallback. */
     251                HMODULE hSFCNative = (HMODULE)RTLdrGetNativeHandle(hSFC);
    253252
    254253                /* If we didn't get the proc address with the call above, try it harder with
    255254                 * the (zero based) index of the function list (ordinal). */
    256                 g_pfnSfcFileException = (PFNSFCFILEEXCEPTION)GetProcAddress(hSFCNative, (LPCSTR)5);
    257                 if (g_pfnSfcFileException)
     255                pfnSfcFileException = (PFNSFCFILEEXCEPTION)GetProcAddress(hSFCNative, (LPCSTR)5);
     256                if (pfnSfcFileException)
    258257                    rc = VINF_SUCCESS;
    259258            }
    260259
    261             RTLdrClose(hSFC);
    262         }
    263 
    264         if (RT_SUCCESS(rc))
    265         {
    266 #ifndef UNICODE
    267             WCHAR *pwszFile;
    268             rc = vboxChar2WCharAlloc(szFile, &pwszFile);
    269260            if (RT_SUCCESS(rc))
    270261            {
     262#ifndef UNICODE
     263                WCHAR *pwszFile;
     264                rc = vboxChar2WCharAlloc(szFile, &pwszFile);
     265                if (RT_SUCCESS(rc))
     266                {
    271267#else
    272                 TCHAR *pwszFile = szFile;
    273 #endif
    274                 if (g_pfnSfcFileException(0, pwszFile, UINT32_MAX) != 0)
    275                     rc = VERR_ACCESS_DENIED; /** @todo Find a better rc. */
     268                    TCHAR *pwszFile = szFile;
     269#endif
     270                    if (pfnSfcFileException(0, pwszFile, UINT32_MAX) != 0)
     271                        rc = VERR_ACCESS_DENIED; /** @todo Find a better rc. */
    276272#ifndef UNICODE
    277                 vboxChar2WCharFree(pwszFile);
     273                    vboxChar2WCharFree(pwszFile);
     274                }
     275#endif
    278276            }
    279 #endif
    280         }
    281 
    282         if (hSFCNative)
    283             FreeLibrary(hSFCNative);
     277
     278            RTLdrClose(hSFC);
     279        }
    284280    }
    285281
     
    512508BOOL WINAPI DllMain(HANDLE hInst, ULONG uReason, LPVOID pReserved)
    513509{
    514     RT_NOREF(uReason, pReserved);
     510    RT_NOREF(pReserved);
     511
    515512    g_hInstance = (HINSTANCE)hInst;
     513
     514    switch (uReason)
     515    {
     516        case DLL_PROCESS_ATTACH:
     517            RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
     518            break;
     519
     520        case DLL_PROCESS_DETACH:
     521            break;
     522
     523        case DLL_THREAD_ATTACH:
     524            break;
     525
     526        case DLL_THREAD_DETACH:
     527            break;
     528
     529        default:
     530            break;
     531    }
     532
    516533    return TRUE;
    517534}
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