VirtualBox

Ignore:
Timestamp:
May 6, 2016 2:43:04 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
107075
Message:

Never use static instances of CComModule as it messes up the log filename by using VBoxRT.dll before it's initialized.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/win/dllmain.cpp

    r60765 r60865  
    3131*   Global Variables                                                                                                             *
    3232*********************************************************************************************************************************/
    33 static ATL::CComModule _Module;
     33static ATL::CComModule *g_pAtlComModule;
    3434
    3535BEGIN_OBJECT_MAP(ObjectMap)
     
    5050        RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    5151
    52         _Module.Init(ObjectMap, hInstance, &LIBID_VirtualBox);
     52        g_pAtlComModule = new(ATL::CComModule);
     53        if (!g_pAtlComModule)
     54            return FALSE;
     55
     56        g_pAtlComModule->Init(ObjectMap, hInstance, &LIBID_VirtualBox);
    5357        DisableThreadLibraryCalls(hInstance);
    5458    }
    5559    else if (dwReason == DLL_PROCESS_DETACH)
    5660    {
    57         _Module.Term();
     61        if (g_pAtlComModule)
     62        {
     63            g_pAtlComModule->Term();
     64            delete g_pAtlComModule;
     65            g_pAtlComModule = NULL;
     66        }
    5867    }
    5968    return TRUE;
     
    6574STDAPI DllCanUnloadNow(void)
    6675{
    67     return (_Module.GetLockCount() == 0) ? S_OK : S_FALSE;
     76    AssertReturn(g_pAtlComModule, S_OK);
     77    return g_pAtlComModule->GetLockCount() == 0 ? S_OK : S_FALSE;
    6878}
    6979
     
    7383STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
    7484{
    75     return _Module.GetClassObject(rclsid, riid, ppv);
     85    AssertReturn(g_pAtlComModule, E_UNEXPECTED);
     86    return g_pAtlComModule->GetClassObject(rclsid, riid, ppv);
    7687}
    7788
     
    8394#ifndef VBOX_WITH_MIDL_PROXY_STUB
    8495    // registers object, typelib and all interfaces in typelib
    85     return _Module.RegisterServer(TRUE);
     96    AssertReturn(g_pAtlComModule, E_UNEXPECTED);
     97    return g_pAtlComModule->RegisterServer(TRUE);
    8698#else
    8799    return S_OK; /* VBoxProxyStub does all the work, no need to duplicate it here. */
     
    95107{
    96108#ifndef VBOX_WITH_MIDL_PROXY_STUB
    97     HRESULT hrc = _Module.UnregisterServer(TRUE);
     109    AssertReturn(g_pAtlComModule, E_UNEXPECTED);
     110    HRESULT hrc = g_pAtlComModule->UnregisterServer(TRUE);
    98111    return hrc;
    99112#else
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