VirtualBox

Ignore:
Timestamp:
Jul 3, 2019 12:54:38 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/DllMain: Don't put a 8KB buffer on the stack that we only need for processing the one time DLL_PROCESS_ATTACH event. This function is called for each thread being created or destroyed too.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/dllmain-win.cpp

    r76553 r79496  
    3737
    3838/**
     39 * Increases the load count on the IPRT DLL so it won't unload.
     40 *
     41 * This is a separate function so as to not overflow the stack of threads with
     42 * very little of it.
     43 *
     44 * @param   hModule     The IPRT DLL module handle.
     45 */
     46DECL_NO_INLINE(static, void) EnsureNoUnload(HMODULE hModule)
     47{
     48    WCHAR wszName[RTPATH_MAX];
     49    SetLastError(NO_ERROR);
     50    if (   GetModuleFileNameW(hModule, wszName, RT_ELEMENTS(wszName)) > 0
     51        && GetLastError() == NO_ERROR)
     52    {
     53        int cExtraLoads = 32;
     54        while (cExtraLoads-- > 0)
     55            LoadLibraryW(wszName);
     56    }
     57}
     58
     59
     60/**
    3961 * The Dll main entry point.
    4062 */
     
    5072         */
    5173        case DLL_PROCESS_ATTACH:
    52         {
    53             WCHAR wszName[RTPATH_MAX];
    54             SetLastError(NO_ERROR);
    55             if (   GetModuleFileNameW((HMODULE)hModule, wszName, RT_ELEMENTS(wszName)) > 0
    56                 && GetLastError() == NO_ERROR)
    57             {
    58                 int cExtraLoads = 32;
    59                 while (cExtraLoads-- > 0)
    60                     LoadLibraryW(wszName);
    61             }
     74            EnsureNoUnload((HMODULE)hModule);
    6275            break;
    63         }
    6476
    6577        case DLL_PROCESS_DETACH:
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