VirtualBox

Changeset 36362 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Mar 23, 2011 10:53:35 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
70704
Message:

iprt/dllmain-win.cpp: Make sure IPRT doesn't ever get unloaded.

File:
1 edited

Legend:

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

    r28800 r36362  
    3131#include <Windows.h>
    3232#include <iprt/thread.h>
     33#include <iprt/param.h>
    3334#include "internal/thread.h"
    3435
     
    4243    switch (dwReason)
    4344    {
     45        /*
     46         * When attaching to a process, we'd like to make sure IPRT stays put
     47         * and doesn't get unloaded.
     48         */
    4449        case DLL_PROCESS_ATTACH:
     50        {
     51            WCHAR wszName[RTPATH_MAX];
     52            SetLastError(NO_ERROR);
     53            if (   GetModuleFileNameW((HMODULE)hModule, wszName, RT_ELEMENTS(wszName)) > 0
     54                && GetLastError() == NO_ERROR)
     55            {
     56                int cExtraLoads = 32;
     57                while (cExtraLoads-- > 0)
     58                    LoadLibraryW(wszName);
     59            }
     60            break;
     61        }
     62
    4563        case DLL_PROCESS_DETACH:
    4664        case DLL_THREAD_ATTACH:
     
    5573    return TRUE;
    5674}
     75
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