VirtualBox

Changeset 46593 in vbox


Ignore:
Timestamp:
Jun 17, 2013 2:32:51 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86471
Message:

updates

Location:
trunk
Files:
2 added
55 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/ldr.h

    r46273 r46593  
    195195 * resolution of subsequently loaded libraries. */
    196196#define RTLDRLOAD_FLAGS_GLOBAL      RT_BIT_32(0)
     197/** Do not unload the library upon RTLdrClose. (For system libs.) */
     198#define RTLDRLOAD_FLAGS_NO_UNLOAD   RT_BIT_32(1)
    197199/** The mask of valid flag bits. */
    198 #define RTLDRLOAD_FLAGS_VALID_MASK  UINT32_C(0x00000001)
     200#define RTLDRLOAD_FLAGS_VALID_MASK  UINT32_C(0x00000003)
    199201/** @} */
     202
     203/**
     204 * Loads a dynamic load library (/shared object) image file residing in one of
     205 * the default system library locations.
     206 *
     207 * Only the system library locations are searched. No suffix is required.
     208 *
     209 * @returns iprt status code.
     210 * @param   pszFilename Image filename. No path.
     211 * @param   fNoUnload   Do not unload the library when RTLdrClose is called.
     212 * @param   phLdrMod    Where to store the handle to the loaded module.
     213 */
     214RTDECL(int) RTLdrLoadSystem(const char *pszFilename, bool fNoUnload, PRTLDRMOD phLdrMod);
     215
     216/**
     217 * Combines RTLdrLoadSystem and RTLdrGetSymbol, with fNoUnload set to true.
     218 *
     219 * @returns The symbol value, NULL on failure.  (If you care for a less boolean
     220 *          status, go thru the necessary API calls yourself.)
     221 * @param   pszFilename Image filename. No path.
     222 * @param   pszSymbol       Symbol name.
     223 */
     224RTDECL(void *) RTLdrGetSystemSymbol(const char *pszFilename, const char *pszSymbol);
    200225
    201226/**
     
    210235 */
    211236RTDECL(int) RTLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod);
     237
     238/**
     239 * Gets the native module handle for a module loaded by RTLdrLoad, RTLdrLoadEx,
     240 * RTLdrLoadSystem,  or RTLdrLoadAppPriv.
     241 *
     242 * @returns Native handle on success, ~(uintptr_t)0 on failure.
     243 * @param   hLdrMod     The loader module handle.
     244 */
     245RTDECL(uintptr_t) RTLdrGetNativeHandle(RTLDRMOD hLdrMod);
     246
    212247
    213248/**
     
    359394RTDECL(int) RTLdrGetSymbolEx(RTLDRMOD hLdrMod, const void *pvBits, RTLDRADDR BaseAddress, const char *pszSymbol,
    360395                             PRTLDRADDR pValue);
     396
     397
     398/**
     399 * Gets the address of a named exported function.
     400 *
     401 * Same as RTLdrGetSymbol, but skips the status code and pointer to return
     402 * variable stuff.
     403 *
     404 * @returns Pointer to the function if found, NULL if not.
     405 * @param   hLdrMod         The loader module handle.
     406 * @param   pszSymbol       Function name.
     407 */
     408RTDECL(PFNRT) RTLdrGetFunction(RTLDRMOD hLdrMod, const char *pszSymbol);
    361409
    362410/**
  • trunk/include/iprt/mangling.h

    r46567 r46593  
    632632# define RTLdrGetEndian                                 RT_MANGLER(RTLdrGetEndian)
    633633# define RTLdrGetFormat                                 RT_MANGLER(RTLdrGetFormat)
     634# define RTLdrGetFunction                               RT_MANGLER(RTLdrGetFunction)
     635# define RTLdrGetNativeHandle                           RT_MANGLER(RTLdrGetNativeHandle)
    634636# define RTLdrGetSuff                                   RT_MANGLER(RTLdrGetSuff)
    635637# define RTLdrGetSymbol                                 RT_MANGLER(RTLdrGetSymbol)
    636638# define RTLdrGetSymbolEx                               RT_MANGLER(RTLdrGetSymbolEx)
     639# define RTLdrGetSystemSymbol                           RT_MANGLER(RTLdrGetSystemSymbol)
    637640# define RTLdrGetType                                   RT_MANGLER(RTLdrGetType)
    638641# define RTLdrIsLoadable                                RT_MANGLER(RTLdrIsLoadable)
     
    642645# define RTLdrLoadAppPriv                               RT_MANGLER(RTLdrLoadAppPriv)
    643646# define RTLdrLoadEx                                    RT_MANGLER(RTLdrLoadEx)
     647# define RTLdrLoadSystem                                RT_MANGLER(RTLdrLoadSystem)
    644648# define RTLdrOpen                                      RT_MANGLER(RTLdrOpen)
    645649# define RTLdrOpenInMemory                              RT_MANGLER(RTLdrOpenInMemory)
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.cpp

    r44529 r46593  
    18001800            vboxVDbgVEHandlerRegister();
    18011801#endif
    1802             int rc = RTR3InitDll(0);
     1802            int rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    18031803            AssertRC(rc);
    18041804            if (RT_SUCCESS(rc))
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3DIf.cpp

    r44529 r46593  
    2828}
    2929
     30/**
     31 * Loads a system DLL.
     32 *
     33 * @returns Module handle or NULL
     34 * @param   pszName             The DLL name.
     35 */
     36static HMODULE loadSystemDll(const char *pszName)
     37{
     38    char   szPath[MAX_PATH];
     39    UINT   cchPath = GetSystemDirectoryA(szPath, sizeof(szPath));
     40    size_t cbName  = strlen(pszName) + 1;
     41    if (cchPath + 1 + cbName > sizeof(szPath))
     42    {
     43        SetLastError(ERROR_FILENAME_EXCED_RANGE);
     44        return NULL;
     45    }
     46    szPath[cchPath] = '\\';
     47    memcpy(&szPath[cchPath + 1], pszName, cbName);
     48    return LoadLibraryA(szPath);
     49}
    3050
    3151HRESULT VBoxDispD3DOpen(VBOXDISPD3D *pD3D)
    3252{
    3353#ifdef VBOX_WDDM_WOW64
    34     pD3D->hD3DLib = LoadLibraryW(L"VBoxD3D9wddm-x86.dll");
     54    pD3D->hD3DLib = loadSystemDll("VBoxD3D9wddm-x86.dll");
    3555#else
    36     pD3D->hD3DLib = LoadLibraryW(L"VBoxD3D9wddm.dll");
     56    pD3D->hD3DLib = loadSystemDll("VBoxD3D9wddm.dll");
    3757#endif
    3858    if (!pD3D->hD3DLib)
    3959    {
    4060        DWORD winErr = GetLastError();
    41         WARN((__FUNCTION__": LoadLibraryW failed, winErr = (%d)", winErr));
     61        WARN((__FUNCTION__": LoadLibrary failed, winErr = (%d)", winErr));
    4262        return E_FAIL;
    4363    }
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispKmt.cpp

    r46172 r46593  
    2323#endif
    2424
     25/**
     26 * Loads a system DLL.
     27 *
     28 * @returns Module handle or NULL
     29 * @param   pszName             The DLL name.
     30 */
     31static HMODULE loadSystemDll(const char *pszName)
     32{
     33    char   szPath[MAX_PATH];
     34    UINT   cchPath = GetSystemDirectoryA(szPath, sizeof(szPath));
     35    size_t cbName  = strlen(pszName) + 1;
     36    if (cchPath + 1 + cbName > sizeof(szPath))
     37        return NULL;
     38    szPath[cchPath] = '\\';
     39    memcpy(&szPath[cchPath + 1], pszName, cbName);
     40    return LoadLibraryA(szPath);
     41}
     42
    2543HRESULT vboxDispKmtCallbacksInit(PVBOXDISPKMT_CALLBACKS pCallbacks)
    2644{
     
    2947    memset(pCallbacks, 0, sizeof (*pCallbacks));
    3048
    31     pCallbacks->hGdi32 = LoadLibraryW(L"gdi32.dll");
     49    pCallbacks->hGdi32 = loadSystemDll("gdi32.dll");
    3250    if (pCallbacks->hGdi32 != NULL)
    3351    {
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxScreen.cpp

    r44529 r46593  
    11/* $Id$ */
    2 
    32/** @file
    43 * VBoxVideo Display D3D User mode dll
     
    65
    76/*
    8  * Copyright (C) 2011-2012 Oracle Corporation
     7 * Copyright (C) 2011-2013 Oracle Corporation
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    341340}
    342341
     342/**
     343 * Loads a system DLL.
     344 *
     345 * @returns Module handle or NULL
     346 * @param   pszName             The DLL name.
     347 */
     348static HMODULE loadSystemDll(const char *pszName)
     349{
     350    char   szPath[MAX_PATH];
     351    UINT   cchPath = GetSystemDirectoryA(szPath, sizeof(szPath));
     352    size_t cbName  = strlen(pszName) + 1;
     353    if (cchPath + 1 + cbName > sizeof(szPath))
     354        return NULL;
     355    szPath[cchPath] = '\\';
     356    memcpy(&szPath[cchPath + 1], pszName, cbName);
     357    return LoadLibraryA(szPath);
     358}
     359
    343360//HRESULT vboxScreenMonInit(PVBOXSCREENMON pMon)
    344361HRESULT vboxScreenMonInit()
     
    351368    pMon->LoData.ScreenLayout.EscapeHdr.escapeCode = VBOXESC_SCREENLAYOUT;
    352369
    353     pMon->hGdi32 = LoadLibraryW(L"gdi32.dll");
     370    pMon->hGdi32 = loadSystemDll("gdi32.dll");
    354371    if (pMon->hGdi32 != NULL)
    355372    {
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/switcher/sw_common.c

    r44529 r46593  
    11/* $Id$ */
    2 
    32/** @file
    43 * VBox D3D8/9 dll switcher
     
    65
    76/*
    8  * Copyright (C) 2009-2012 Oracle Corporation
     7 * Copyright (C) 2009-2013 Oracle Corporation
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2322static char* gsBlackListDll[] = {"awt.dll", "wpfgfx_v0400.dll", "wpfgfx_v0300.dll", NULL};
    2423
     24/**
     25 * Loads a system DLL.
     26 *
     27 * @returns Module handle or NULL
     28 * @param   pszName             The DLL name.
     29 */
     30static HMODULE loadSystemDll(const char *pszName)
     31{
     32    char   szPath[MAX_PATH];
     33    UINT   cchPath = GetSystemDirectoryA(szPath, sizeof(szPath));
     34    size_t cbName  = strlen(pszName) + 1;
     35    if (cchPath + 1 + cbName > sizeof(szPath))
     36        return NULL;
     37    szPath[cchPath] = '\\';
     38    memcpy(&szPath[cchPath + 1], pszName, cbName);
     39    return LoadLibraryA(szPath);
     40}
     41
    2542/* Checks if 3D is enabled for VM and it works on host machine */
    2643BOOL isVBox3DEnabled(void)
     
    3148
    3249#ifdef VBOX_WDDM_WOW64
    33     hDLL = LoadLibrary("VBoxOGL-x86.dll");
     50    hDLL = loadSystemDll("VBoxOGL-x86.dll");
    3451#else
    35     hDLL = LoadLibrary("VBoxOGL.dll");
     52    hDLL = loadSystemDll("VBoxOGL.dll");
    3653#endif
    3754
     
    6683    int i;
    6784
    68         if (!GetModuleFileName(NULL, name, 1000))
    69                 return TRUE;
     85    if (!GetModuleFileName(NULL, name, 1000))
     86        return TRUE;
    7087
    7188    /*Extract filename*/
     
    108125
    109126    if (isVBox3DEnabled() && checkOptions())
    110     {
    111127        dllName = vboxName;
    112     } else
    113     {
     128    else
    114129        dllName = msName;
    115     }
    116130
    117     hDLL = LoadLibrary(dllName);
     131    hDLL = loadSystemDll(dllName);
    118132    FillD3DExports(hDLL);
    119133}
     134
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/directx.c

    r42499 r46593  
    53085308}
    53095309
     5310/**
     5311 * Loads a system DLL.
     5312 *
     5313 * @returns Module handle or NULL
     5314 * @param   pszName             The DLL name.
     5315 */
     5316static HMODULE loadSystemDll(const char *pszName)
     5317{
     5318    char   szPath[MAX_PATH];
     5319    UINT   cchPath = GetSystemDirectoryA(szPath, sizeof(szPath));
     5320    size_t cbName  = strlen(pszName) + 1;
     5321    if (cchPath + 1 + cbName > sizeof(szPath))
     5322        return NULL;
     5323    szPath[cchPath] = '\\';
     5324    memcpy(&szPath[cchPath + 1], pszName, cbName);
     5325    return LoadLibraryA(szPath);
     5326}
     5327
    53105328static BOOL InitAdapters(IWineD3DImpl *This)
    53115329{
     
    53235341    if(!mod_gl) {
    53245342#ifdef USE_WIN32_OPENGL
    5325 #define USE_GL_FUNC(pfn) pfn = (void*)GetProcAddress(mod_gl, #pfn);
    5326 #if defined(VBOX_WITH_WDDM) || defined(VBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT)
     5343# define USE_GL_FUNC(pfn) pfn = (void*)GetProcAddress(mod_gl, #pfn);
     5344# if defined(VBOX_WITH_WDDM) || defined(VBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT)
    53275345        BOOL (APIENTRY *pDrvValidateVersion)(DWORD) DECLSPEC_HIDDEN;
    5328 #ifdef VBOX_WDDM_WOW64
    5329         mod_gl = LoadLibraryA("VBoxOGL-x86.dll");
    5330 #else
    5331         mod_gl = LoadLibraryA("VBoxOGL.dll");
    5332 #endif
    5333 #else
    5334         mod_gl = LoadLibraryA("opengl32.dll");
    5335 #endif
     5346#  ifdef VBOX_WDDM_WOW64
     5347        mod_gl = loadSystemDll("VBoxOGL-x86.dll");
     5348#  else
     5349        mod_gl = loadSystemDll("VBoxOGL.dll");
     5350#  endif
     5351# else
     5352        mod_gl = loadSystemDll("opengl32.dll");
     5353# endif
    53365354        if(!mod_gl) {
    53375355            ERR("Can't load opengl32.dll!\n");
    53385356            goto nogl_adapter;
    53395357        }
    5340 #if defined(VBOX_WITH_WDDM) || defined(VBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT)
     5358# if defined(VBOX_WITH_WDDM) || defined(VBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT)
    53415359        /* init properly */
    53425360        pDrvValidateVersion = (void*)GetProcAddress(mod_gl, "DrvValidateVersion");
     
    53495367            goto nogl_adapter;
    53505368        }
    5351 #endif
     5369# endif
    53525370#else
    5353 #define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn);
     5371# define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn);
    53545372        /* To bypass the opengl32 thunks load wglGetProcAddress from gdi32 (glXGetProcAddress wrapper) instead of opengl32's */
    53555373        mod_gl = GetModuleHandleA("gdi32.dll");
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/switcher/sw_common.c

    r46521 r46593  
    11/* $Id$ */
    2 
    32/** @file
    43 * VBox D3D8/9 dll switcher
     
    65
    76/*
    8  * Copyright (C) 2009 Oracle Corporation
     7 * Copyright (C) 2009-2013 Oracle Corporation
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2322static char* gsBlackListDll[] = {"awt.dll", "wpfgfx_v0400.dll", "wpfgfx_v0300.dll", NULL};
    2423
     24/**
     25 * Loads a system DLL.
     26 *
     27 * @returns Module handle or NULL
     28 * @param   pszName             The DLL name.
     29 */
     30static HMODULE loadSystemDll(const char *pszName)
     31{
     32    char   szPath[MAX_PATH];
     33    UINT   cchPath = GetSystemDirectoryA(szPath, sizeof(szPath));
     34    size_t cbName  = strlen(pszName) + 1;
     35    if (cchPath + 1 + cbName > sizeof(szPath))
     36        return NULL;
     37    szPath[cchPath] = '\\';
     38    memcpy(&szPath[cchPath + 1], pszName, cbName);
     39    return LoadLibraryA(szPath);
     40}
     41
    2542/* Checks if 3D is enabled for VM and it works on host machine */
    2643BOOL isVBox3DEnabled(void)
     
    3148
    3249#ifdef VBOX_WDDM_WOW64
    33     hDLL = LoadLibrary("VBoxOGL-x86.dll");
     50    hDLL = loadSystemDll("VBoxOGL-x86.dll");
    3451#else
    35     hDLL = LoadLibrary("VBoxOGL.dll");
     52    hDLL = loadSystemDll("VBoxOGL.dll");
    3653#endif
    3754
     
    108125
    109126    if (isVBox3DEnabled() && checkOptions())
    110     {
    111127        dllName = vboxName;
    112     } else
    113     {
     128    else
    114129        dllName = msName;
    115     }
    116130
    117     hDLL = LoadLibrary(dllName);
     131    hDLL = loadSystemDll(dllName);
    118132    FillD3DExports(hDLL);
    119133}
     134
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/wined3d/directx.c

    r46521 r46593  
    51215121}
    51225122
     5123/**
     5124 * Loads a system DLL.
     5125 *
     5126 * @returns Module handle or NULL
     5127 * @param   pszName             The DLL name.
     5128 */
     5129static HMODULE loadSystemDll(const char *pszName)
     5130{
     5131    char   szPath[MAX_PATH];
     5132    UINT   cchPath = GetSystemDirectoryA(szPath, sizeof(szPath));
     5133    size_t cbName  = strlen(pszName) + 1;
     5134    if (cchPath + 1 + cbName > sizeof(szPath))
     5135        return NULL;
     5136    szPath[cchPath] = '\\';
     5137    memcpy(&szPath[cchPath + 1], pszName, cbName);
     5138    return LoadLibraryA(szPath);
     5139}
     5140
    51235141/* Do not call while under the GL lock. */
    51245142static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal)
     
    51425160#ifdef USE_WIN32_OPENGL
    51435161    {
    5144 #ifndef VBOX
     5162# ifndef VBOX
    51455163        HMODULE mod_gl = GetModuleHandleA("opengl32.dll");
    5146 #else
     5164# else
    51475165        BOOL (APIENTRY *pDrvValidateVersion)(DWORD) DECLSPEC_HIDDEN;
    5148 # ifdef VBOX_WDDM_WOW64
    5149         HMODULE mod_gl = LoadLibraryA("VBoxOGL-x86.dll");
    5150 # else
    5151         HMODULE mod_gl = LoadLibraryA("VBoxOGL.dll");
    5152 # endif
     5166#  ifdef VBOX_WDDM_WOW64
     5167        HMODULE mod_gl = loadSystemDll("VBoxOGL-x86.dll");
     5168#  else
     5169        HMODULE mod_gl = loadSystemDll("VBoxOGL.dll");
     5170#  endif
    51535171        if (!mod_gl)
    51545172        {
     
    51695187        }
    51705188
    5171 # define VBOX_USE_FUNC(f) p##f = (void *)GetProcAddress(mod_gl, #f);
     5189#  define VBOX_USE_FUNC(f) p##f = (void *)GetProcAddress(mod_gl, #f);
    51725190        VBOX_GL_FUNCS_GEN
    5173 # undef VBOX_USE_FUNC
    5174 #endif
    5175 #define USE_GL_FUNC(f) gl_info->gl_ops.gl.p_##f = (void *)GetProcAddress(mod_gl, #f);
     5191#  undef VBOX_USE_FUNC
     5192# endif
     5193# define USE_GL_FUNC(f) gl_info->gl_ops.gl.p_##f = (void *)GetProcAddress(mod_gl, #f);
    51765194        ALL_WGL_FUNCS
    5177 #undef USE_GL_FUNC
     5195# undef USE_GL_FUNC
    51785196        gl_info->gl_ops.wgl.p_wglSwapBuffers = (void *)GetProcAddress(mod_gl, "wglSwapBuffers");
    51795197    }
  • trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/VBoxGuestInstallHelper.cpp

    r44529 r46593  
    197197
    198198/**
     199 * Loads a system DLL.
     200 *
     201 * @returns Module handle or NULL
     202 * @param   pszName             The DLL name.
     203 */
     204static HMODULE loadSystemDll(const char *pszName)
     205{
     206    char   szPath[MAX_PATH];
     207    UINT   cchPath = GetSystemDirectoryA(szPath, sizeof(szPath));
     208    size_t cbName  = strlen(pszName) + 1;
     209    if (cchPath + 1 + cbName > sizeof(szPath))
     210        return NULL;
     211    szPath[cchPath] = '\\';
     212    memcpy(&szPath[cchPath + 1], pszName, cbName);
     213    return LoadLibraryA(szPath);
     214}
     215
     216/**
    199217 * Disables the Windows File Protection for a specified file
    200218 * using an undocumented SFC API call. Don't try this at home!
     
    214232    if (SUCCEEDED(hr))
    215233    {
    216         HMODULE hSFC = LoadLibrary("sfc_os.dll");
     234        HMODULE hSFC = loadSystemDll("sfc_os.dll");
    217235        if (NULL != hSFC)
    218236        {
  • trunk/src/VBox/Additions/WINNT/Installer/VBoxDrvInst.cpp

    r45938 r46593  
    130130     if (pCallbackContext)
    131131         fwprintf((FILE*)pCallbackContext, _T("(%u) %u - %s\n"), Event, dwError, pEventDescription);
     132}
     133
     134/**
     135 * Loads a system DLL.
     136 *
     137 * @returns Module handle or NULL
     138 * @param   pszName             The DLL name.
     139 */
     140static HMODULE loadSystemDll(const char *pszName)
     141{
     142    char   szPath[MAX_PATH];
     143    UINT   cchPath = GetSystemDirectoryA(szPath, sizeof(szPath));
     144    size_t cbName  = strlen(pszName) + 1;
     145    if (cchPath + 1 + cbName > sizeof(szPath))
     146        return NULL;
     147    szPath[cchPath] = '\\';
     148    memcpy(&szPath[cchPath + 1], pszName, cbName);
     149    return LoadLibraryA(szPath);
    132150}
    133151
     
    146164{
    147165    HRESULT hr = S_OK;
    148     HMODULE hDIFxAPI = LoadLibrary(_T("DIFxAPI.dll"));
     166    HMODULE hDIFxAPI = loadSystemDll("DIFxAPI.dll");
    149167    if (NULL == hDIFxAPI)
    150168    {
  • trunk/src/VBox/Additions/WINNT/SharedFolders/np/vboxmrxnp.cpp

    r40295 r46593  
    15981598    {
    15991599        case DLL_PROCESS_ATTACH:
    1600             RTR3InitDll(0);
     1600            RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    16011601            VbglR3Init();
    16021602            LogRel(("VBOXNP: DLL loaded.\n"));
  • trunk/src/VBox/Additions/WINNT/VBoxCredProv/VBoxCredentialProvider.cpp

    r46382 r46593  
    363363        case DLL_PROCESS_ATTACH:
    364364        {
    365             int rc = RTR3InitDll(0 /* Flags */);
     365            int rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    366366            if (RT_SUCCESS(rc))
    367367                rc = VbglR3Init();
  • trunk/src/VBox/Additions/WINNT/VBoxGINA/VBoxGINA.cpp

    r40768 r46593  
    2020#include <iprt/buildconfig.h>
    2121#include <iprt/initterm.h>
     22#include <iprt/ldr.h>
    2223
    2324#include <VBox/VBoxGuestLib.h>
     
    8384        case DLL_PROCESS_ATTACH:
    8485        {
    85             RTR3InitDll(0 /* Flags */);
     86            RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    8687            VbglR3Init();
    8788
     
    115116                         DWORD *pdwDllVersion)
    116117{
    117     HINSTANCE hDll;
    118 
    119118    VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: dwWinlogonVersion: %ld\n", dwWinlogonVersion);
    120119
    121120    /* Load the standard Microsoft GINA DLL. */
    122     if (!(hDll = LoadLibrary(TEXT("MSGINA.DLL"))))
    123     {
    124         VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed loading MSGINA! Last error=%ld\n", GetLastError());
     121    RTLDRMOD hLdrMod;
     122    int rc = RTLdrLoadSystem("MSGINA.DLL", true /*fNoUnload*/, &hLdrMod);
     123    if (RT_FAILURE(rc))
     124    {
     125        VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: failed loading MSGINA! rc=%Rrc\n", rc);
    125126        return FALSE;
    126127    }
     
    129130     * Now get the entry points of the MSGINA
    130131     */
    131     GWlxNegotiate = (PGWLXNEGOTIATE)GetProcAddress(hDll, "WlxNegotiate");
     132    GWlxNegotiate = (PGWLXNEGOTIATE)RTLdrGetFunction(hLdrMod, "WlxNegotiate");
    132133    if (!GWlxNegotiate)
    133134    {
     
    135136        return FALSE;
    136137    }
    137     GWlxInitialize = (PGWLXINITIALIZE)GetProcAddress(hDll, "WlxInitialize");
     138    GWlxInitialize = (PGWLXINITIALIZE)RTLdrGetFunction(hLdrMod, "WlxInitialize");
    138139    if (!GWlxInitialize)
    139140    {
     
    142143    }
    143144    GWlxDisplaySASNotice =
    144         (PGWLXDISPLAYSASNOTICE)GetProcAddress(hDll, "WlxDisplaySASNotice");
     145        (PGWLXDISPLAYSASNOTICE)RTLdrGetFunction(hLdrMod, "WlxDisplaySASNotice");
    145146    if (!GWlxDisplaySASNotice)
    146147    {
     
    149150    }
    150151    GWlxLoggedOutSAS =
    151         (PGWLXLOGGEDOUTSAS)GetProcAddress(hDll, "WlxLoggedOutSAS");
     152        (PGWLXLOGGEDOUTSAS)RTLdrGetFunction(hLdrMod, "WlxLoggedOutSAS");
    152153    if (!GWlxLoggedOutSAS)
    153154    {
     
    156157    }
    157158    GWlxActivateUserShell =
    158         (PGWLXACTIVATEUSERSHELL)GetProcAddress(hDll, "WlxActivateUserShell");
     159        (PGWLXACTIVATEUSERSHELL)RTLdrGetFunction(hLdrMod, "WlxActivateUserShell");
    159160    if (!GWlxActivateUserShell)
    160161    {
     
    163164    }
    164165    GWlxLoggedOnSAS =
    165         (PGWLXLOGGEDONSAS)GetProcAddress(hDll, "WlxLoggedOnSAS");
     166        (PGWLXLOGGEDONSAS)RTLdrGetFunction(hLdrMod, "WlxLoggedOnSAS");
    166167    if (!GWlxLoggedOnSAS)
    167168    {
     
    170171    }
    171172    GWlxDisplayLockedNotice =
    172         (PGWLXDISPLAYLOCKEDNOTICE)GetProcAddress(hDll, "WlxDisplayLockedNotice");
     173        (PGWLXDISPLAYLOCKEDNOTICE)RTLdrGetFunction(hLdrMod, "WlxDisplayLockedNotice");
    173174    if (!GWlxDisplayLockedNotice)
    174175    {
     
    176177        return FALSE;
    177178    }
    178     GWlxIsLockOk = (PGWLXISLOCKOK)GetProcAddress(hDll, "WlxIsLockOk");
     179    GWlxIsLockOk = (PGWLXISLOCKOK)RTLdrGetFunction(hLdrMod, "WlxIsLockOk");
    179180    if (!GWlxIsLockOk)
    180181    {
     
    183184    }
    184185    GWlxWkstaLockedSAS =
    185         (PGWLXWKSTALOCKEDSAS)GetProcAddress(hDll, "WlxWkstaLockedSAS");
     186        (PGWLXWKSTALOCKEDSAS)RTLdrGetFunction(hLdrMod, "WlxWkstaLockedSAS");
    186187    if (!GWlxWkstaLockedSAS)
    187188    {
     
    189190        return FALSE;
    190191    }
    191     GWlxIsLogoffOk = (PGWLXISLOGOFFOK)GetProcAddress(hDll, "WlxIsLogoffOk");
     192    GWlxIsLogoffOk = (PGWLXISLOGOFFOK)RTLdrGetFunction(hLdrMod, "WlxIsLogoffOk");
    192193    if (!GWlxIsLogoffOk)
    193194    {
     
    195196        return FALSE;
    196197    }
    197     GWlxLogoff = (PGWLXLOGOFF)GetProcAddress(hDll, "WlxLogoff");
     198    GWlxLogoff = (PGWLXLOGOFF)RTLdrGetFunction(hLdrMod, "WlxLogoff");
    198199    if (!GWlxLogoff)
    199200    {
     
    201202        return FALSE;
    202203    }
    203     GWlxShutdown = (PGWLXSHUTDOWN)GetProcAddress(hDll, "WlxShutdown");
     204    GWlxShutdown = (PGWLXSHUTDOWN)RTLdrGetFunction(hLdrMod, "WlxShutdown");
    204205    if (!GWlxShutdown)
    205206    {
     
    208209    }
    209210    /* GINA 1.1, optional */
    210     GWlxStartApplication = (PGWLXSTARTAPPLICATION)GetProcAddress(hDll, "WlxStartApplication");
    211     GWlxScreenSaverNotify = (PGWLXSCREENSAVERNOTIFY)GetProcAddress(hDll, "WlxScreenSaverNotify");
     211    GWlxStartApplication = (PGWLXSTARTAPPLICATION)RTLdrGetFunction(hLdrMod, "WlxStartApplication");
     212    GWlxScreenSaverNotify = (PGWLXSCREENSAVERNOTIFY)RTLdrGetFunction(hLdrMod, "WlxScreenSaverNotify");
    212213    /* GINA 1.3, optional */
    213     GWlxNetworkProviderLoad = (PGWLXNETWORKPROVIDERLOAD)GetProcAddress( hDll, "WlxNetworkProviderLoad");
    214     GWlxDisplayStatusMessage = (PGWLXDISPLAYSTATUSMESSAGE)GetProcAddress( hDll, "WlxDisplayStatusMessage");
    215     GWlxGetStatusMessage = (PGWLXGETSTATUSMESSAGE)GetProcAddress( hDll, "WlxGetStatusMessage");
    216     GWlxRemoveStatusMessage = (PGWLXREMOVESTATUSMESSAGE)GetProcAddress( hDll, "WlxRemoveStatusMessage");
     214    GWlxNetworkProviderLoad = (PGWLXNETWORKPROVIDERLOAD)RTLdrGetFunction(hLdrMod, "WlxNetworkProviderLoad");
     215    GWlxDisplayStatusMessage = (PGWLXDISPLAYSTATUSMESSAGE)RTLdrGetFunction(hLdrMod, "WlxDisplayStatusMessage");
     216    GWlxGetStatusMessage = (PGWLXGETSTATUSMESSAGE)RTLdrGetFunction(hLdrMod, "WlxGetStatusMessage");
     217    GWlxRemoveStatusMessage = (PGWLXREMOVESTATUSMESSAGE)RTLdrGetFunction(hLdrMod, "WlxRemoveStatusMessage");
    217218    /* GINA 1.4, optional */
    218219    GWlxGetConsoleSwitchCredentials =
    219         (PGWLXGETCONSOLESWITCHCREDENTIALS)GetProcAddress(hDll, "WlxGetConsoleSwitchCredentials");
    220     GWlxReconnectNotify = (PGWLXRECONNECTNOTIFY)GetProcAddress(hDll, "WlxReconnectNotify");
    221     GWlxDisconnectNotify = (PGWLXDISCONNECTNOTIFY)GetProcAddress(hDll, "WlxDisconnectNotify");
     220        (PGWLXGETCONSOLESWITCHCREDENTIALS)RTLdrGetFunction(hLdrMod, "WlxGetConsoleSwitchCredentials");
     221    GWlxReconnectNotify = (PGWLXRECONNECTNOTIFY)RTLdrGetFunction(hLdrMod, "WlxReconnectNotify");
     222    GWlxDisconnectNotify = (PGWLXDISCONNECTNOTIFY)RTLdrGetFunction(hLdrMod, "WlxDisconnectNotify");
    222223    VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: optional function pointers:\n"
    223224                    "  WlxStartApplication: %p\n"
  • trunk/src/VBox/Additions/WINNT/VBoxMMR/dllmain.cpp

    r44864 r46593  
    4545            if (isWMP)
    4646            {
    47                 RTR3InitDll(0);
     47                RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    4848                VbglR3Init();
    4949                VBoxMMRHookLog("VBoxMMR: Hooking wmplayer process\n");
  • trunk/src/VBox/Additions/WINNT/VBoxMMR/tsmfhook.cpp

    r44864 r46593  
    13431343}
    13441344
    1345 void InstallHooksForModule(const char *pszName, HookEntry hooks[])
    1346 {
    1347     HMODULE hMod = LoadLibraryA(pszName);
    1348     if (hMod != NULL)
    1349     {
    1350         VBoxMMRHookLog("VBoxMMR: Hooking %s -> %x \n", pszName, hMod);
    1351         const IMAGE_IMPORT_DESCRIPTOR *pDescriptor = GetImportDescriptor(hMod);
    1352         InstallHooks(pDescriptor, (PBYTE) hMod, hooks);
     1345void InstallHooksForSystemModule(const char *pszName, HookEntry hooks[])
     1346{
     1347    /* Construct the full path to the given module and load it. */
     1348    char   szPath[MAX_PATH];
     1349    UINT   cchPath = GetSystemDirectoryA(szPath, MAX_PATH);
     1350    size_t cbName  = strlen(pszName) + 1;
     1351    if (cchPath + 1 + cbName <= sizeof(szPath))
     1352    {
     1353        szPath[cchPath] = '\\';
     1354        memcpy(&szPath[cchPath + 1], pszName, cbName);
     1355
     1356        HMODULE hMod = LoadLibraryA(szPath);
     1357        if (hMod != NULL)
     1358        {
     1359            VBoxMMRHookLog("VBoxMMR: Hooking %s -> %x \n", pszName, hMod);
     1360            const IMAGE_IMPORT_DESCRIPTOR *pDescriptor = GetImportDescriptor(hMod);
     1361            InstallHooks(pDescriptor, (PBYTE) hMod, hooks);
     1362        }
     1363        else
     1364            VBoxMMRHookLog("VBoxMMR: Error hooking %s -> not found (last error %u)\n", pszName, GetLastError());
    13531365    }
    13541366    else
    1355     {
    13561367        VBoxMMRHookLog("VBoxMMR: Error hooking %s -> not found\n", pszName);
    1357     }
    13581368}
    13591369
     
    13821392        }
    13831393
    1384         InstallHooksForModule("winmm.dll", g_WinMMHooks);
    1385         InstallHooksForModule("tsmf.dll", g_TSMFHooks);
    1386         InstallHooksForModule("DSHOWRDPFILTER.dll", g_TSMFHooks);
    1387         InstallHooksForModule("MSMPEG2VDEC.dll", g_DShowHooks);
    1388         InstallHooksForModule("MFDS.dll", g_DShowHooks);
    1389         InstallHooksForModule("mf.dll", g_MFHooks);
     1394        InstallHooksForSystemModule("winmm.dll", g_WinMMHooks);
     1395        InstallHooksForSystemModule("tsmf.dll", g_TSMFHooks);
     1396        InstallHooksForSystemModule("DSHOWRDPFILTER.dll", g_TSMFHooks);
     1397        InstallHooksForSystemModule("MSMPEG2VDEC.dll", g_DShowHooks);
     1398        InstallHooksForSystemModule("MFDS.dll", g_DShowHooks);
     1399        InstallHooksForSystemModule("mf.dll", g_MFHooks);
    13901400
    13911401        ULONG ret = RegisterTraceGuids(
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxLA.cpp

    r43584 r46593  
    2727#include <iprt/alloc.h>
    2828#include <iprt/list.h>
     29#include <iprt/ldr.h>
    2930
    3031#define LALOG(a) do { if (gCtx.fLogEnabled) LogRel(a); } while(0)
     
    8788        char *pszPropWaitPattern; /* Which properties are monitored. */
    8889    } activeClient;
    89 
    90     HMODULE hModuleKernel32;
    9190
    9291    BOOL (WINAPI * pfnProcessIdToSessionId)(DWORD dwProcessId, DWORD *pSessionId);
     
    12501249    RT_ZERO(gCtx.activeClient);
    12511250
    1252     gCtx.hModuleKernel32 = LoadLibrary("KERNEL32");
    1253 
    1254     if (gCtx.hModuleKernel32)
    1255     {
    1256         *(uintptr_t *)&gCtx.pfnProcessIdToSessionId = (uintptr_t)GetProcAddress(gCtx.hModuleKernel32, "ProcessIdToSessionId");
    1257     }
    1258     else
    1259     {
    1260         gCtx.pfnProcessIdToSessionId = NULL;
    1261     }
     1251    *(void **)&gCtx.pfnProcessIdToSessionId = RTLdrGetSystemSymbol("KERNEL32", "ProcessIdToSessionId");
    12621252    *pfStartThread = true;
    12631253    *ppInstance = &gCtx;
     
    12801270    ActionExecutorDeleteActions(&pCtx->listDetachActions);
    12811271
    1282     if (pCtx->hModuleKernel32)
    1283     {
    1284         FreeLibrary(pCtx->hModuleKernel32);
    1285         pCtx->pfnProcessIdToSessionId = NULL;
    1286     }
    1287     pCtx->hModuleKernel32 = NULL;
     1272    pCtx->pfnProcessIdToSessionId = NULL;
    12881273}
    12891274
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxMMR.cpp

    r42295 r46593  
    1818#include "VBoxTray.h"
    1919#include "VBoxMMR.h"
     20#include <iprt/ldr.h>
    2021
    2122struct VBOXMMRCONTEXT
    2223{
    23     HINSTANCE hMod;
     24    RTLDRMOD  hModHook;
    2425    HHOOK     hHook;
    2526};
     
    3233void VBoxMMRCleanup(VBOXMMRCONTEXT *pCtx)
    3334{
    34     if (NULL != pCtx->hHook)
     35    if (pCtx->hHook)
    3536    {
    3637        UnhookWindowsHookEx(pCtx->hHook);
     38        pCtx->hHook = NULL;
    3739    }
    3840
    39     if (pCtx->hMod)
     41    if (pCtx->hModHook != NIL_RTLDRMOD)
    4042    {
    41         FreeLibrary(pCtx->hMod);
     43        RTLdrClose(pCtx->hModHook);
     44        pCtx->hModHook = NIL_RTLDRMOD;
    4245    }
    43 
    44     return;
    4546}
    4647
     
    5051    bool *pfStartThread)
    5152{
    52     HOOKPROC pHook = NULL;
    53 
    5453    LogRel2(("VBoxMMR: Initializing\n"));
    5554
    56     gCtx.hMod = LoadLibraryA(g_pszMMRDLL);
    57     if (NULL == gCtx.hMod)
     55    int rc = RTLdrLoadAppPriv(g_pszMMRDLL, &gCtx.hModHook);
     56    if (RT_SUCCESS(rc))
    5857    {
    59         LogRel2(("VBoxMMR: Hooking library not found\n"));
    60         VBoxMMRCleanup(&gCtx);
    61         return VERR_NOT_FOUND;
     58        HOOKPROC pHook = (HOOKPROC)RTLdrGetFunction(gCtx.hModHook, g_pszMMRPROC);
     59        if (pHook)
     60        {
     61            HMODULE hMod = (HMODULE)RTLdrGetNativeHandle(gCtx.hModHook);
     62            Assert(hMod != (HMODULE)~(uintptr_t)0);
     63            gCtx.hHook = SetWindowsHookEx(WH_CBT, pHook, hMod, 0);
     64            if (gCtx.hHook)
     65            {
     66                *ppInstance = &gCtx;
     67                return VINF_SUCCESS;
     68            }
     69
     70            rc = RTErrConvertFromWin32(GetLastError());
     71            LogRel2(("VBoxMMR: Error installing hooking proc: %Rrc\n", rc));
     72        }
     73        else
     74        {
     75            LogRel2(("VBoxMMR: Hooking proc not found\n"));
     76            rc = VERR_NOT_FOUND;
     77        }
    6278    }
     79    else
     80        LogRel2(("VBoxMMR: Hooking library not found (%Rrc)\n", rc));
    6381
    64     pHook = (HOOKPROC) GetProcAddress(gCtx.hMod, g_pszMMRPROC);
    65     if (NULL == pHook)
    66     {
    67         LogRel2(("VBoxMMR: Hooking proc not found\n"));
    68         VBoxMMRCleanup(&gCtx);
    69         return VERR_NOT_FOUND;
    70     }
    71 
    72     gCtx.hHook = SetWindowsHookEx(WH_CBT, pHook, gCtx.hMod, 0);
    73     if (NULL == gCtx.hHook)
    74     {
    75         int rc = RTErrConvertFromWin32(GetLastError());
    76         LogRel2(("VBoxMMR: Error installing hooking proc: %d\n", rc));
    77         VBoxMMRCleanup(&gCtx);
    78         return rc;
    79     }
    80 
    81     *ppInstance = &gCtx;
    82 
    83     return VINF_SUCCESS;
     82    RTLdrClose(gCtx.hModHook);
     83    gCtx.hModHook = NIL_RTLDRMOD;
     84    return rc;
    8485}
    8586
     
    9596    return 0;
    9697}
     98
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxSeamless.cpp

    r45760 r46593  
    2525#include <VBox/VMMDev.h>
    2626#include <iprt/assert.h>
     27#include <iprt/ldr.h>
    2728#include <VBoxGuestInternal.h>
    2829
     
    3132    const VBOXSERVICEENV *pEnv;
    3233
    33     HMODULE    hModule;
     34    RTLDRMOD hModHook;
    3435
    3536    BOOL    (* pfnVBoxHookInstallWindowTracker)(HMODULE hDll);
     
    5556    *pfStartThread = false;
    5657    gCtx.pEnv = pEnv;
     58    gCtx.hModHook = NIL_RTLDRMOD;
    5759
    5860    OSVERSIONINFO OSinfo;
     
    7274    {
    7375        /* Will fail if SetWinEventHook is not present (version < NT4 SP6 apparently) */
    74         gCtx.hModule = LoadLibrary(VBOXHOOK_DLL_NAME);
    75         if (gCtx.hModule)
    76         {
    77             *(uintptr_t *)&gCtx.pfnVBoxHookInstallWindowTracker = (uintptr_t)GetProcAddress(gCtx.hModule, "VBoxHookInstallWindowTracker");
    78             *(uintptr_t *)&gCtx.pfnVBoxHookRemoveWindowTracker  = (uintptr_t)GetProcAddress(gCtx.hModule, "VBoxHookRemoveWindowTracker");
     76        rc = RTLdrLoadAppPriv(VBOXHOOK_DLL_NAME, &gCtx.hModHook);
     77        if (RT_SUCCESS(rc))
     78        {
     79            *(PFNRT *)&gCtx.pfnVBoxHookInstallWindowTracker = RTLdrGetFunction(gCtx.hModHook, "VBoxHookInstallWindowTracker");
     80            *(PFNRT *)&gCtx.pfnVBoxHookRemoveWindowTracker  = RTLdrGetFunction(gCtx.hModHook, "VBoxHookRemoveWindowTracker");
    7981
    8082            /* rc should contain success status */
     
    9092        }
    9193        else
    92         {
    93             rc = RTErrConvertFromWin32(GetLastError());
    9494            Log(("VBoxTray: VBoxSeamlessInit: LoadLibrary of \"%s\" failed with rc=%Rrc\n", VBOXHOOK_DLL_NAME, rc));
    95         }
    9695    }
    9796
     
    109108    if (gCtx.pfnVBoxHookRemoveWindowTracker)
    110109        gCtx.pfnVBoxHookRemoveWindowTracker();
    111     if (gCtx.hModule)
    112         FreeLibrary(gCtx.hModule);
    113     gCtx.hModule = 0;
     110    if (gCtx.hModHook != NIL_RTLDRMOD)
     111    {
     112        RTLdrClose(gCtx.hModHook);
     113        gCtx.hModHook = NIL_RTLDRMOD;
     114    }
    114115    return;
    115116}
     
    122123        VBoxSeamlessCheckWindows();
    123124
    124         gCtx.pfnVBoxHookInstallWindowTracker(gCtx.hModule);
     125        HMODULE hMod = (HMODULE)RTLdrGetNativeHandle(gCtx.hModHook);
     126        Assert(hMod != (HMODULE)~(uintptr_t)0);
     127        gCtx.pfnVBoxHookInstallWindowTracker(hMod);
    125128    }
    126129}
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp

    r46428 r46593  
    4141
    4242#include <iprt/buildconfig.h>
     43#include <iprt/ldr.h>
    4344
    4445/* Default desktop state tracking */
     
    6364 * of the window passed to vboxStInit */
    6465static int vboxStInit(HWND hWnd);
    65 static void vboxStTerm();
     66static void vboxStTerm(void);
    6667/* @returns true on "IsActiveConsole" state change */
    6768static BOOL vboxStHandleEvent(WPARAM EventID, LPARAM SessionID);
     
    549550        {
    550551            BOOL (WINAPI * pfnConvertStringSecurityDescriptorToSecurityDescriptorA)(LPCSTR StringSecurityDescriptor, DWORD StringSDRevision, PSECURITY_DESCRIPTOR  *SecurityDescriptor, PULONG  SecurityDescriptorSize);
    551 
    552             HMODULE hModule = LoadLibrary("ADVAPI32.DLL");
    553             if (!hModule)
    554             {
    555                 dwErr = GetLastError();
    556                 Log(("VBoxTray: Loading module ADVAPI32.DLL failed with last error = %08X\n", dwErr));
    557             }
    558             else
     552            *(void **)&pfnConvertStringSecurityDescriptorToSecurityDescriptorA =
     553                RTLdrGetSystemSymbol("ADVAPI32.DLL", "ConvertStringSecurityDescriptorToSecurityDescriptorA");
     554            Log(("VBoxTray: pfnConvertStringSecurityDescriptorToSecurityDescriptorA = %x\n", pfnConvertStringSecurityDescriptorToSecurityDescriptorA));
     555            if (pfnConvertStringSecurityDescriptorToSecurityDescriptorA)
    559556            {
    560557                PSECURITY_DESCRIPTOR    pSD;
     
    563560                BOOL                    fSaclDefaulted = FALSE;
    564561
    565                 *(uintptr_t *)&pfnConvertStringSecurityDescriptorToSecurityDescriptorA = (uintptr_t)GetProcAddress(hModule, "ConvertStringSecurityDescriptorToSecurityDescriptorA");
    566 
    567                 Log(("VBoxTray: pfnConvertStringSecurityDescriptorToSecurityDescriptorA = %x\n", pfnConvertStringSecurityDescriptorToSecurityDescriptorA));
    568                 if (pfnConvertStringSecurityDescriptorToSecurityDescriptorA)
     562                fRC = pfnConvertStringSecurityDescriptorToSecurityDescriptorA("S:(ML;;NW;;;LW)", /* this means "low integrity" */
     563                                                                              SDDL_REVISION_1, &pSD, NULL);
     564                if (!fRC)
    569565                {
    570                     fRC = pfnConvertStringSecurityDescriptorToSecurityDescriptorA("S:(ML;;NW;;;LW)", /* this means "low integrity" */
    571                                                                                   SDDL_REVISION_1, &pSD, NULL);
     566                    dwErr = GetLastError();
     567                    Log(("VBoxTray: ConvertStringSecurityDescriptorToSecurityDescriptorA failed with last error = %08X\n", dwErr));
     568                }
     569                else
     570                {
     571                    fRC = GetSecurityDescriptorSacl(pSD, &fSaclPresent, &pSacl, &fSaclDefaulted);
    572572                    if (!fRC)
    573573                    {
    574574                        dwErr = GetLastError();
    575                         Log(("VBoxTray: ConvertStringSecurityDescriptorToSecurityDescriptorA failed with last error = %08X\n", dwErr));
     575                        Log(("VBoxTray: GetSecurityDescriptorSacl failed with last error = %08X\n", dwErr));
    576576                    }
    577577                    else
    578578                    {
    579                         fRC = GetSecurityDescriptorSacl(pSD, &fSaclPresent, &pSacl, &fSaclDefaulted);
     579                        fRC = SetSecurityDescriptorSacl(SecAttr.lpSecurityDescriptor, TRUE, pSacl, FALSE);
    580580                        if (!fRC)
    581581                        {
    582582                            dwErr = GetLastError();
    583                             Log(("VBoxTray: GetSecurityDescriptorSacl failed with last error = %08X\n", dwErr));
    584                         }
    585                         else
    586                         {
    587                             fRC = SetSecurityDescriptorSacl(SecAttr.lpSecurityDescriptor, TRUE, pSacl, FALSE);
    588                             if (!fRC)
    589                             {
    590                                 dwErr = GetLastError();
    591                                 Log(("VBoxTray: SetSecurityDescriptorSacl failed with last error = %08X\n", dwErr));
    592                             }
     583                            Log(("VBoxTray: SetSecurityDescriptorSacl failed with last error = %08X\n", dwErr));
    593584                        }
    594585                    }
     
    10151006{
    10161007    HWND hWTSAPIWnd;
    1017     HMODULE hWTSAPI32;
     1008    RTLDRMOD hLdrModWTSAPI32;
    10181009    BOOL fIsConsole;
    10191010    WTS_CONNECTSTATE_CLASS enmConnectState;
     
    10321023    USHORT *pProtocolType = NULL;
    10331024    DWORD cbBuf = 0;
    1034     if (gVBoxSt.pfnWTSQuerySessionInformationA(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSConnectState, (LPTSTR *)&penmConnectState, &cbBuf))
    1035     {
    1036         if (gVBoxSt.pfnWTSQuerySessionInformationA(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSClientProtocolType, (LPTSTR *)&pProtocolType, &cbBuf))
     1025    if (gVBoxSt.pfnWTSQuerySessionInformationA(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSConnectState,
     1026                                               (LPTSTR *)&penmConnectState, &cbBuf))
     1027    {
     1028        if (gVBoxSt.pfnWTSQuerySessionInformationA(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSClientProtocolType,
     1029                                                   (LPTSTR *)&pProtocolType, &cbBuf))
    10371030        {
    10381031            gVBoxSt.fIsConsole = (*pProtocolType == 0);
     
    10401033            return VINF_SUCCESS;
    10411034        }
    1042         else
    1043         {
    1044             DWORD dwErr = GetLastError();
    1045             WARN(("VBoxTray: WTSQuerySessionInformationA WTSClientProtocolType failed, error = %08X\n", dwErr));
    1046             rc = RTErrConvertFromWin32(dwErr);
    1047         }
     1035
     1036        DWORD dwErr = GetLastError();
     1037        WARN(("VBoxTray: WTSQuerySessionInformationA WTSClientProtocolType failed, error = %08X\n", dwErr));
     1038        rc = RTErrConvertFromWin32(dwErr);
    10481039    }
    10491040    else
     
    10631054static int vboxStInit(HWND hWnd)
    10641055{
    1065     int rc = VINF_SUCCESS;
    1066     memset(&gVBoxSt, 0, sizeof (gVBoxSt));
    1067     gVBoxSt.hWTSAPI32 = LoadLibrary("WTSAPI32.DLL");
    1068     if (gVBoxSt.hWTSAPI32)
    1069     {
    1070         *(uintptr_t *)&gVBoxSt.pfnWTSRegisterSessionNotification = (uintptr_t)GetProcAddress(gVBoxSt.hWTSAPI32, "WTSRegisterSessionNotification");
    1071         if (!gVBoxSt.pfnWTSRegisterSessionNotification)
    1072         {
     1056    RT_ZERO(gVBoxSt);
     1057    int rc = RTLdrLoadSystem("WTSAPI32.DLL", false /*fNoUnload*/, &gVBoxSt.hLdrModWTSAPI32);
     1058    if (RT_SUCCESS(rc))
     1059    {
     1060        rc = RTLdrGetSymbol(gVBoxSt.hLdrModWTSAPI32, "WTSRegisterSessionNotification",
     1061                            (void **)&gVBoxSt.pfnWTSRegisterSessionNotification);
     1062        if (RT_SUCCESS(rc))
     1063        {
     1064            rc = RTLdrGetSymbol(gVBoxSt.hLdrModWTSAPI32, "WTSUnRegisterSessionNotification",
     1065                                (void **)&gVBoxSt.pfnWTSUnRegisterSessionNotification);
     1066            if (RT_SUCCESS(rc))
     1067            {
     1068                rc = RTLdrGetSymbol(gVBoxSt.hLdrModWTSAPI32, "WTSQuerySessionInformationA",
     1069                                    (void **)&gVBoxSt.pfnWTSQuerySessionInformationA);
     1070                if (RT_FAILURE(rc))
     1071                    WARN(("VBoxTray: WTSQuerySessionInformationA not found\n"));
     1072            }
     1073            else
     1074                WARN(("VBoxTray: WTSUnRegisterSessionNotification not found\n"));
     1075        }
     1076        else
    10731077            WARN(("VBoxTray: WTSRegisterSessionNotification not found\n"));
    1074             rc = VERR_NOT_SUPPORTED;
    1075         }
    1076 
    1077         *(uintptr_t *)&gVBoxSt.pfnWTSUnRegisterSessionNotification = (uintptr_t)GetProcAddress(gVBoxSt.hWTSAPI32, "WTSUnRegisterSessionNotification");
    1078         if (!gVBoxSt.pfnWTSUnRegisterSessionNotification)
    1079         {
    1080             WARN(("VBoxTray: WTSUnRegisterSessionNotification not found\n"));
    1081             rc = VERR_NOT_SUPPORTED;
    1082         }
    1083 
    1084         *(uintptr_t *)&gVBoxSt.pfnWTSQuerySessionInformationA = (uintptr_t)GetProcAddress(gVBoxSt.hWTSAPI32, "WTSQuerySessionInformationA");
    1085         if (!gVBoxSt.pfnWTSQuerySessionInformationA)
    1086         {
    1087             WARN(("VBoxTray: WTSQuerySessionInformationA not found\n"));
    1088             rc = VERR_NOT_SUPPORTED;
    1089         }
    1090 
    1091         if (rc == VINF_SUCCESS)
     1078        if (RT_SUCCESS(rc))
    10921079        {
    10931080            gVBoxSt.hWTSAPIWnd = hWnd;
    10941081            if (gVBoxSt.pfnWTSRegisterSessionNotification(gVBoxSt.hWTSAPIWnd, NOTIFY_FOR_THIS_SESSION))
    1095             {
    10961082                vboxStCheckState();
    1097             }
    10981083            else
    10991084            {
     
    11021087                if (dwErr == RPC_S_INVALID_BINDING)
    11031088                {
    1104                     gVBoxSt.idDelayedInitTimer = SetTimer(gVBoxSt.hWTSAPIWnd, TIMERID_VBOXTRAY_ST_DELAYED_INIT_TIMER, 2000, (TIMERPROC)NULL);
    1105                     rc = VINF_SUCCESS;
    1106 
     1089                    gVBoxSt.idDelayedInitTimer = SetTimer(gVBoxSt.hWTSAPIWnd, TIMERID_VBOXTRAY_ST_DELAYED_INIT_TIMER,
     1090                                                          2000, (TIMERPROC)NULL);
    11071091                    gVBoxSt.fIsConsole = TRUE;
    11081092                    gVBoxSt.enmConnectState = WTSActive;
     1093                    rc = VINF_SUCCESS;
    11091094                }
    11101095                else
     
    11161101        }
    11171102
    1118         FreeLibrary(gVBoxSt.hWTSAPI32);
     1103        RTLdrClose(gVBoxSt.hLdrModWTSAPI32);
    11191104    }
    11201105    else
    1121     {
    1122         DWORD dwErr = GetLastError();
    1123         WARN(("VBoxTray: WTSAPI32 load failed, error = %08X\n", dwErr));
    1124         rc = RTErrConvertFromWin32(dwErr);
    1125     }
    1126 
    1127     memset(&gVBoxSt, 0, sizeof (gVBoxSt));
     1106        WARN(("VBoxTray: WTSAPI32 load failed, rc = %Rrc\n", rc));
     1107
     1108    RT_ZERO(gVBoxSt);
    11281109    gVBoxSt.fIsConsole = TRUE;
    11291110    gVBoxSt.enmConnectState = WTSActive;
     
    11311112}
    11321113
    1133 static void vboxStTerm()
    1134 {
    1135     if (gVBoxSt.hWTSAPIWnd)
     1114static void vboxStTerm(void)
     1115{
     1116    if (!gVBoxSt.hWTSAPIWnd)
    11361117    {
    11371118        WARN(("VBoxTray: vboxStTerm called for non-initialized St\n"));
     
    11541135    }
    11551136
    1156     FreeLibrary(gVBoxSt.hWTSAPI32);
    1157     memset(&gVBoxSt, 0, sizeof (gVBoxSt));
     1137    RTLdrClose(gVBoxSt.hLdrModWTSAPI32);
     1138    RT_ZERO(gVBoxSt);
    11581139}
    11591140
     
    12281209    BOOL fIsInputDesktop;
    12291210    UINT_PTR idTimer;
    1230     HMODULE hHookModule;
     1211    RTLDRMOD hLdrModHook;
    12311212    BOOL (* pfnVBoxHookInstallActiveDesktopTracker)(HMODULE hDll);
    12321213    BOOL (* pfnVBoxHookRemoveActiveDesktopTracker)();
    1233     HMODULE hUSER32;
    12341214    HDESK (WINAPI * pfnGetThreadDesktop)(DWORD dwThreadId);
    12351215    HDESK (WINAPI * pfnOpenInputDesktop)(DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess);
     
    12891269    }
    12901270
    1291     memset(&gVBoxDt, 0, sizeof (gVBoxDt));
     1271    RT_ZERO(gVBoxDt);
    12921272
    12931273    gVBoxDt.hNotifyEvent = CreateEvent(NULL, FALSE, FALSE, VBOXHOOK_GLOBAL_DT_EVENT_NAME);
    12941274    if (gVBoxDt.hNotifyEvent != NULL)
    12951275    {
    1296         gVBoxDt.hHookModule = LoadLibrary(VBOXHOOK_DLL_NAME);
    1297         if (gVBoxDt.hHookModule)
    1298         {
    1299             *(uintptr_t *)&gVBoxDt.pfnVBoxHookInstallActiveDesktopTracker = (uintptr_t)GetProcAddress(gVBoxDt.hHookModule, "VBoxHookInstallActiveDesktopTracker");
    1300             if (!gVBoxDt.pfnVBoxHookInstallActiveDesktopTracker)
    1301             {
     1276        /* Load the hook dll and resolve the necessary entry points. */
     1277        rc = RTLdrLoadAppPriv(VBOXHOOK_DLL_NAME, &gVBoxDt.hLdrModHook);
     1278        if (RT_SUCCESS(rc))
     1279        {
     1280            rc = RTLdrGetSymbol(gVBoxDt.hLdrModHook, "VBoxHookInstallActiveDesktopTracker",
     1281                                (void **)&gVBoxDt.pfnVBoxHookInstallActiveDesktopTracker);
     1282            if (RT_SUCCESS(rc))
     1283            {
     1284                rc = RTLdrGetSymbol(gVBoxDt.hLdrModHook, "VBoxHookRemoveActiveDesktopTracker",
     1285                                    (void **)&gVBoxDt.pfnVBoxHookRemoveActiveDesktopTracker);
     1286                if (RT_FAILURE(rc))
     1287                    WARN(("VBoxTray: VBoxHookRemoveActiveDesktopTracker not found\n"));
     1288            }
     1289            else
    13021290                WARN(("VBoxTray: VBoxHookInstallActiveDesktopTracker not found\n"));
    1303                 rc = VERR_NOT_SUPPORTED;
    1304             }
    1305 
    1306             *(uintptr_t *)&gVBoxDt.pfnVBoxHookRemoveActiveDesktopTracker  = (uintptr_t)GetProcAddress(gVBoxDt.hHookModule, "VBoxHookInstallActiveDesktopTracker");
    1307             if (!gVBoxDt.pfnVBoxHookRemoveActiveDesktopTracker)
    1308             {
    1309                 WARN(("VBoxTray: VBoxHookRemoveActiveDesktopTracker not found\n"));
    1310                 rc = VERR_NOT_SUPPORTED;
    1311             }
    1312 
    1313             if (VINF_SUCCESS == rc)
    1314             {
    1315                 gVBoxDt.hUSER32 = LoadLibrary("User32.dll");
    1316                 if (gVBoxDt.hUSER32)
     1291            if (RT_SUCCESS(rc))
     1292            {
     1293                /* Try get the system APIs we need. */
     1294                *(void **)&gVBoxDt.pfnGetThreadDesktop = RTLdrGetSystemSymbol("User32.dll", "GetThreadDesktop");
     1295                if (!gVBoxDt.pfnGetThreadDesktop)
    13171296                {
    1318                     *(uintptr_t *)&gVBoxDt.pfnGetThreadDesktop = (uintptr_t)GetProcAddress(gVBoxDt.hUSER32, "GetThreadDesktop");
    1319                     if (!gVBoxDt.pfnGetThreadDesktop)
     1297                    WARN(("VBoxTray: GetThreadDesktop not found\n"));
     1298                    rc = VERR_NOT_SUPPORTED;
     1299                }
     1300
     1301                *(void **)&gVBoxDt.pfnOpenInputDesktop = RTLdrGetSystemSymbol("User32.dll", "OpenInputDesktop");
     1302                if (!gVBoxDt.pfnOpenInputDesktop)
     1303                {
     1304                    WARN(("VBoxTray: OpenInputDesktop not found\n"));
     1305                    rc = VERR_NOT_SUPPORTED;
     1306                }
     1307
     1308                *(void **)&gVBoxDt.pfnCloseDesktop = RTLdrGetSystemSymbol("User32.dll", "CloseDesktop");
     1309                if (!gVBoxDt.pfnCloseDesktop)
     1310                {
     1311                    WARN(("VBoxTray: CloseDesktop not found\n"));
     1312                    rc = VERR_NOT_SUPPORTED;
     1313                }
     1314
     1315                if (RT_SUCCESS(rc))
     1316                {
     1317                    BOOL fRc = FALSE;
     1318                    /* For Vista and up we need to change the integrity of the security descriptor, too. */
     1319                    if (gMajorVersion >= 6)
    13201320                    {
    1321                         WARN(("VBoxTray: GetThreadDesktop not found\n"));
    1322                         rc = VERR_NOT_SUPPORTED;
    1323                     }
    1324 
    1325                     *(uintptr_t *)&gVBoxDt.pfnOpenInputDesktop = (uintptr_t)GetProcAddress(gVBoxDt.hUSER32, "OpenInputDesktop");
    1326                     if (!gVBoxDt.pfnOpenInputDesktop)
    1327                     {
    1328                         WARN(("VBoxTray: OpenInputDesktop not found\n"));
    1329                         rc = VERR_NOT_SUPPORTED;
    1330                     }
    1331 
    1332                     *(uintptr_t *)&gVBoxDt.pfnCloseDesktop = (uintptr_t)GetProcAddress(gVBoxDt.hUSER32, "CloseDesktop");
    1333                     if (!gVBoxDt.pfnCloseDesktop)
    1334                     {
    1335                         WARN(("VBoxTray: CloseDesktop not found\n"));
    1336                         rc = VERR_NOT_SUPPORTED;
    1337                     }
    1338 
    1339                     if (VINF_SUCCESS == rc)
    1340                     {
    1341                         BOOL bRc = FALSE;
    1342                         /* For Vista and up we need to change the integrity of the security descriptor, too. */
    1343                         if (gMajorVersion >= 6)
     1321                        HMODULE hModHook = (HMODULE)RTLdrGetNativeHandle(gVBoxDt.hLdrModHook);
     1322                        Assert((uintptr_t)hModHook != ~(uintptr_t)0);
     1323                        fRc = gVBoxDt.pfnVBoxHookInstallActiveDesktopTracker(hModHook);
     1324                        if (!fRc)
    13441325                        {
    1345                             bRc = gVBoxDt.pfnVBoxHookInstallActiveDesktopTracker(gVBoxDt.hHookModule);
    1346                             if (!bRc)
    1347                             {
    1348                                 DWORD dwErr = GetLastError();
    1349                                 WARN(("VBoxTray: pfnVBoxHookInstallActiveDesktopTracker failed, last error = %08X\n", dwErr));
    1350                             }
    1351                         }
    1352 
    1353                         if (!bRc)
    1354                         {
    1355                             gVBoxDt.idTimer = SetTimer(ghwndToolWindow, TIMERID_VBOXTRAY_DT_TIMER, 500, (TIMERPROC)NULL);
    1356                             if (!gVBoxDt.idTimer)
    1357                             {
    1358                                 DWORD dwErr = GetLastError();
    1359                                 WARN(("VBoxTray: SetTimer error %08X\n", dwErr));
    1360                                 rc = RTErrConvertFromWin32(dwErr);
    1361                             }
    1362                         }
    1363 
    1364                         if (RT_SUCCESS(rc))
    1365                         {
    1366                             gVBoxDt.fIsInputDesktop = vboxDtCalculateIsInputDesktop();
    1367                             return VINF_SUCCESS;
     1326                            DWORD dwErr = GetLastError();
     1327                            WARN(("VBoxTray: pfnVBoxHookInstallActiveDesktopTracker failed, last error = %08X\n", dwErr));
    13681328                        }
    13691329                    }
    1370                     FreeLibrary(gVBoxDt.hUSER32);
     1330
     1331                    if (!fRc)
     1332                    {
     1333                        gVBoxDt.idTimer = SetTimer(ghwndToolWindow, TIMERID_VBOXTRAY_DT_TIMER, 500, (TIMERPROC)NULL);
     1334                        if (!gVBoxDt.idTimer)
     1335                        {
     1336                            DWORD dwErr = GetLastError();
     1337                            WARN(("VBoxTray: SetTimer error %08X\n", dwErr));
     1338                            rc = RTErrConvertFromWin32(dwErr);
     1339                        }
     1340                    }
     1341
     1342                    if (RT_SUCCESS(rc))
     1343                    {
     1344                        gVBoxDt.fIsInputDesktop = vboxDtCalculateIsInputDesktop();
     1345                        return VINF_SUCCESS;
     1346                    }
    13711347                }
    13721348            }
    13731349
    1374             FreeLibrary(gVBoxDt.hHookModule);
     1350            RTLdrClose(gVBoxDt.hLdrModHook);
    13751351        }
    13761352        else
     
    13911367
    13921368
    1393     memset(&gVBoxDt, 0, sizeof (gVBoxDt));
     1369    RT_ZERO(gVBoxDt);
    13941370    gVBoxDt.fIsInputDesktop = TRUE;
    13951371
     
    13991375static void vboxDtTerm()
    14001376{
    1401     if (!gVBoxDt.hHookModule)
     1377    if (!gVBoxDt.hLdrModHook)
    14021378        return;
    14031379
    14041380    gVBoxDt.pfnVBoxHookRemoveActiveDesktopTracker();
    14051381
    1406     FreeLibrary(gVBoxDt.hUSER32);
    1407     FreeLibrary(gVBoxDt.hHookModule);
     1382    RTLdrClose(gVBoxDt.hLdrModHook);
    14081383    CloseHandle(gVBoxDt.hNotifyEvent);
    14091384
    1410     memset(&gVBoxDt, 0, sizeof (gVBoxDt));
     1385    RT_ZERO(gVBoxDt);
    14111386}
    14121387/* @returns true on "IsInputDesktop" state change */
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxVRDP.cpp

    r33966 r46593  
    2525#include <VBoxGuestInternal.h>
    2626#include <iprt/assert.h>
     27#include <iprt/ldr.h>
    2728
    2829
     
    256257    BOOL fSavedThemeEnabled;
    257258
    258     HMODULE hModule;
     259    RTLDRMOD hModUxTheme;
    259260
    260261    HRESULT (* pfnEnableTheming)(BOOL fEnable);
     
    274275    gCtx.fSavedThemeEnabled = FALSE;
    275276
    276     gCtx.hModule = LoadLibrary("UxTheme");
    277 
    278     if (gCtx.hModule)
    279     {
    280         *(uintptr_t *)&gCtx.pfnEnableTheming = (uintptr_t)GetProcAddress(gCtx.hModule, "EnableTheming");
    281         *(uintptr_t *)&gCtx.pfnIsThemeActive = (uintptr_t)GetProcAddress(gCtx.hModule, "IsThemeActive");
     277    int rc = RTLdrLoadSystem("UxTheme.dll", false /*fNoUnload*/, &gCtx.hModUxTheme);
     278    if (RT_SUCCESS(rc))
     279    {
     280        *(PFNRT *)&gCtx.pfnEnableTheming = RTLdrGetFunction(gCtx.hModUxTheme, "EnableTheming");
     281        *(PFNRT *)&gCtx.pfnIsThemeActive = RTLdrGetFunction(gCtx.hModUxTheme, "IsThemeActive");
    282282    }
    283283    else
    284284    {
    285         gCtx.pfnEnableTheming = 0;
     285        gCtx.hModUxTheme = NIL_RTLDRMOD;
     286        gCtx.pfnEnableTheming = NULL;
     287        gCtx.pfnIsThemeActive = NULL;
    286288    }
    287289
     
    297299    VBOXVRDPCONTEXT *pCtx = (VBOXVRDPCONTEXT *)pInstance;
    298300    vboxExperienceRestore (pCtx->level);
    299     if (gCtx.hModule)
    300         FreeLibrary(gCtx.hModule);
    301     gCtx.hModule = 0;
     301    if (gCtx.hModUxTheme != NIL_RTLDRMOD)
     302    {
     303        RTLdrClose(gCtx.hModUxTheme);
     304        gCtx.hModUxTheme = NIL_RTLDRMOD;
     305    }
    302306    return;
    303307}
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServicePageSharing.cpp

    r44863 r46593  
    2424#include <iprt/asm.h>
    2525#include <iprt/mem.h>
     26#include <iprt/ldr.h>
    2627#include <iprt/process.h>
    2728#include <iprt/env.h>
     
    8182
    8283typedef NTSTATUS (WINAPI *PFNZWQUERYSYSTEMINFORMATION)(ULONG, PVOID, ULONG, PULONG);
    83 static PFNZWQUERYSYSTEMINFORMATION ZwQuerySystemInformation = NULL;
    84 static HMODULE hNtdll = 0;
     84static PFNZWQUERYSYSTEMINFORMATION g_pfnZwQuerySystemInformation = NULL;
    8585
    8686
     
    366366
    367367    /* Check all loaded kernel modules. */
    368     if (ZwQuerySystemInformation)
     368    if (g_pfnZwQuerySystemInformation)
    369369    {
    370370        ULONG                cbBuffer = 0;
     
    372372        PRTL_PROCESS_MODULES pSystemModules;
    373373
    374         NTSTATUS ret = ZwQuerySystemInformation(SystemModuleInformation, (PVOID)&cbBuffer, 0, &cbBuffer);
     374        NTSTATUS ret = g_pfnZwQuerySystemInformation(SystemModuleInformation, (PVOID)&cbBuffer, 0, &cbBuffer);
    375375        if (!cbBuffer)
    376376        {
     
    383383            goto skipkernelmodules;
    384384
    385         ret = ZwQuerySystemInformation(SystemModuleInformation, pBuffer, cbBuffer, &cbBuffer);
     385        ret = g_pfnZwQuerySystemInformation(SystemModuleInformation, pBuffer, cbBuffer, &cbBuffer);
    386386        if (ret != STATUS_SUCCESS)
    387387        {
     
    553553
    554554#if defined(RT_OS_WINDOWS) && !defined(TARGET_NT4)
    555     hNtdll = LoadLibrary("ntdll.dll");
    556 
    557     if (hNtdll)
    558         ZwQuerySystemInformation = (PFNZWQUERYSYSTEMINFORMATION)GetProcAddress(hNtdll, "ZwQuerySystemInformation");
    559 
    560     rc =  VbglR3GetSessionId(&g_idSession);
     555    g_pfnZwQuerySystemInformation = (PFNZWQUERYSYSTEMINFORMATION)RTLdrGetSystemSymbol("ntdll.dll", "ZwQuerySystemInformation");
     556
     557    rc = VbglR3GetSessionId(&g_idSession);
    561558    if (RT_FAILURE(rc))
    562559    {
     
    738735{
    739736    VBoxServiceVerbose(3, "VBoxServicePageSharingTerm\n");
    740 
    741 #if defined(RT_OS_WINDOWS) && !defined(TARGET_NT4)
    742     if (hNtdll)
    743         FreeLibrary(hNtdll);
    744 #endif
    745     return;
    746737}
    747738
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceStats.cpp

    r44528 r46593  
    4444#include <iprt/assert.h>
    4545#include <iprt/mem.h>
     46#include <iprt/ldr.h>
    4647#include <VBox/param.h>
    4748#include <iprt/semaphore.h>
     
    124125
    125126#ifdef RT_OS_WINDOWS
    126     /** @todo Use RTLdr instead of LoadLibrary/GetProcAddress here! */
    127 
    128     /* NtQuerySystemInformation might be dropped in future releases, so load it dynamically as per Microsoft's recommendation */
    129     HMODULE hMod = LoadLibrary("NTDLL.DLL");
    130     if (hMod)
    131     {
    132         *(uintptr_t *)&gCtx.pfnNtQuerySystemInformation = (uintptr_t)GetProcAddress(hMod, "NtQuerySystemInformation");
    133         if (gCtx.pfnNtQuerySystemInformation)
    134             VBoxServiceVerbose(3, "VBoxStatsInit: gCtx.pfnNtQuerySystemInformation = %x\n", gCtx.pfnNtQuerySystemInformation);
    135         else
    136         {
    137             VBoxServiceVerbose(3, "VBoxStatsInit: NTDLL.NtQuerySystemInformation not found!\n");
    138             return VERR_SERVICE_DISABLED;
    139         }
     127    /* NtQuerySystemInformation might be dropped in future releases, so load
     128       it dynamically as per Microsoft's recommendation. */
     129    *(void **)&gCtx.pfnNtQuerySystemInformation = RTLdrGetSystemSymbol("NTDLL.DLL", "NtQuerySystemInformation");
     130    if (gCtx.pfnNtQuerySystemInformation)
     131        VBoxServiceVerbose(3, "VBoxStatsInit: gCtx.pfnNtQuerySystemInformation = %x\n", gCtx.pfnNtQuerySystemInformation);
     132    else
     133    {
     134        VBoxServiceVerbose(3, "VBoxStatsInit: NTDLL.NtQuerySystemInformation not found!\n");
     135        return VERR_SERVICE_DISABLED;
    140136    }
    141137
    142138    /* GlobalMemoryStatus is win2k and up, so load it dynamically */
    143     hMod = LoadLibrary("KERNEL32.DLL");
    144     if (hMod)
    145     {
    146         *(uintptr_t *)&gCtx.pfnGlobalMemoryStatusEx = (uintptr_t)GetProcAddress(hMod, "GlobalMemoryStatusEx");
    147         if (gCtx.pfnGlobalMemoryStatusEx)
    148             VBoxServiceVerbose(3, "VBoxStatsInit: gCtx.GlobalMemoryStatusEx = %x\n", gCtx.pfnGlobalMemoryStatusEx);
    149         else
    150         {
    151             /** @todo Now fails in NT4; do we care? */
    152             VBoxServiceVerbose(3, "VBoxStatsInit: KERNEL32.GlobalMemoryStatusEx not found!\n");
    153             return VERR_SERVICE_DISABLED;
    154         }
    155     }
     139    *(void **)&gCtx.pfnGlobalMemoryStatusEx = RTLdrGetSystemSymbol("KERNEL32.DLL", "GlobalMemoryStatusEx");
     140    if (gCtx.pfnGlobalMemoryStatusEx)
     141        VBoxServiceVerbose(3, "VBoxStatsInit: gCtx.GlobalMemoryStatusEx = %x\n", gCtx.pfnGlobalMemoryStatusEx);
     142    else
     143    {
     144        /** @todo Now fails in NT4; do we care? */
     145        VBoxServiceVerbose(3, "VBoxStatsInit: KERNEL32.GlobalMemoryStatusEx not found!\n");
     146        return VERR_SERVICE_DISABLED;
     147    }
     148
    156149    /* GetPerformanceInfo is xp and up, so load it dynamically */
    157     hMod = LoadLibrary("PSAPI.DLL");
    158     if (hMod)
    159     {
    160         *(uintptr_t *)&gCtx.pfnGetPerformanceInfo = (uintptr_t)GetProcAddress(hMod, "GetPerformanceInfo");
    161         if (gCtx.pfnGetPerformanceInfo)
    162             VBoxServiceVerbose(3, "VBoxStatsInit: gCtx.pfnGetPerformanceInfo= %x\n", gCtx.pfnGetPerformanceInfo);
    163         /* failure is not fatal */
    164     }
     150    *(void **)&gCtx.pfnGetPerformanceInfo = RTLdrGetSystemSymbol("PSAPI.DLL", "GetPerformanceInfo");
     151    if (gCtx.pfnGetPerformanceInfo)
     152        VBoxServiceVerbose(3, "VBoxStatsInit: gCtx.pfnGetPerformanceInfo= %x\n", gCtx.pfnGetPerformanceInfo);
    165153#endif /* RT_OS_WINDOWS */
    166154
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp

    r44884 r46593  
    169169            /* Loading the module and getting the symbol for each and every process is expensive
    170170             * -- since this function (at the moment) only is used for debugging purposes it's okay. */
    171             RTLDRMOD hMod;
    172             rc = RTLdrLoad("kernel32.dll", &hMod);
    173             if (RT_SUCCESS(rc))
     171            PFNQUERYFULLPROCESSIMAGENAME pfnQueryFullProcessImageName;
     172            pfnQueryFullProcessImageName = (PFNQUERYFULLPROCESSIMAGENAME)
     173                RTLdrGetSystemSymbol("kernel32.dll", "QueryFullProcessImageNameA");
     174            /** @todo r=bird: WTF don't we query the UNICODE name? */
     175            if (pfnQueryFullProcessImageName)
    174176            {
    175                 PFNQUERYFULLPROCESSIMAGENAME pfnQueryFullProcessImageName;
    176                 rc = RTLdrGetSymbol(hMod, "QueryFullProcessImageNameA", (void **)&pfnQueryFullProcessImageName);
    177                 if (RT_SUCCESS(rc))
    178                 {
    179                     DWORD dwLen = cbName / sizeof(TCHAR);
    180                     if (!pfnQueryFullProcessImageName(h, 0 /*PROCESS_NAME_NATIVE*/, pszName, &dwLen))
    181                         rc = VERR_ACCESS_DENIED;
    182                 }
    183 
    184                 RTLdrClose(hMod);
     177                /** @todo r=bird: Completely bogus use of TCHAR.
     178                 *  !!ALL USE OF TCHAR IS HEREWITH BANNED IN ALL VBOX SOURCES!!
     179                 *  We use WCHAR when talking to windows, everything else is WRONG. (We don't
     180                 *  want Chinese MBCS being treated as UTF-8.) */
     181                DWORD dwLen = cbName / sizeof(TCHAR);
     182                if (!pfnQueryFullProcessImageName(h, 0 /*PROCESS_NAME_NATIVE*/, pszName, &dwLen))
     183                    rc = VERR_ACCESS_DENIED;
    185184            }
    186185        }
  • trunk/src/VBox/Additions/haiku/VBoxTray/VBoxGuestDeskbarView.cpp

    r43407 r46593  
    261261    }
    262262
    263     int rc = RTR3InitDll(0);
     263    int rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    264264    if (RT_SUCCESS(rc))
    265265    {
  • trunk/src/VBox/Debugger/VBoxDbgStatsQt4.cpp

    r44528 r46593  
    353353     */
    354354    static ssize_t getNodePath(PCDBGGUISTATSNODE pNode, char *psz, ssize_t cch);
     355
     356    /**
     357     * Calculates the full path of a node, returning the string pointer.
     358     *
     359     * @returns @a psz. On failure, NULL.
     360     *
     361     * @param   pNode       The node.
     362     * @param   psz         The output buffer.
     363     * @param   cch         The size of the buffer.
     364     */
     365    static char *getNodePath2(PCDBGGUISTATSNODE pNode, char *psz, ssize_t cch);
    355366
    356367    /**
     
    13121323
    13131324
     1325/*static*/ char *
     1326VBoxDbgStatsModel::getNodePath2(PCDBGGUISTATSNODE pNode, char *psz, ssize_t cch)
     1327{
     1328    if (VBoxDbgStatsModel::getNodePath(pNode, psz, cch) < 0)
     1329        return NULL;
     1330    return psz;
     1331}
     1332
     1333
     1334
    13141335/*static*/ bool
    13151336VBoxDbgStatsModel::isNodeAncestorOf(PCDBGGUISTATSNODE pAncestor, PCDBGGUISTATSNODE pDescendant)
     
    14341455VBoxDbgStatsModel::updateCallbackHandleOutOfOrder(const char *pszName)
    14351456{
     1457#if defined(VBOX_STRICT) || defined(LOG_ENABLED)
     1458    char szStrict[1024];
     1459#endif
     1460
    14361461    /*
    14371462     * We might be inserting a new node between pPrev and pNode
     
    14511476    PDBGGUISTATSNODE pNode = m_pUpdateParent->papChildren[m_iUpdateChild];
    14521477    PDBGGUISTATSNODE const pPrev = prevDataNode(pNode);
     1478    AssertMsg(strcmp(pszName, getNodePath2(pNode, szStrict, sizeof(szStrict))), ("%s\n", szStrict));
     1479    AssertMsg(strcmp(pszName, getNodePath2(pPrev, szStrict, sizeof(szStrict))), ("%s\n", szStrict));
     1480    Log(("updateCallbackHandleOutOfOrder: pszName='%s' m_szUpdateParent='%s' m_cchUpdateParent=%u pNode='%s'\n",
     1481         pszName, m_szUpdateParent, m_cchUpdateParent, getNodePath2(pNode, szStrict, sizeof(szStrict))));
     1482
    14531483    pNode = pNode->pParent;
    14541484    while (pNode != m_pRoot)
     
    14591489        m_cchUpdateParent -= pNode->cchName + 1;
    14601490        m_szUpdateParent[m_cchUpdateParent] = '\0';
     1491        Log2(("updateCallbackHandleOutOfOrder: m_szUpdateParent='%s' m_cchUpdateParent=%u, removed '/%s' (%u)\n", m_szUpdateParent, m_cchUpdateParent, pNode->pszName, __LINE__));
    14611492        pNode = pNode->pParent;
    14621493    }
     
    14701501    {
    14711502        /* Find the end of this component. */
    1472         const char *const pszSubName = &pszName[m_cchUpdateParent];
     1503        const char * const pszSubName = &pszName[m_cchUpdateParent];
    14731504        const char *pszEnd = strchr(pszSubName, '/');
    14741505        if (!pszEnd)
     
    14821513        m_szUpdateParent[m_cchUpdateParent] = '\0';
    14831514        Assert(m_cchUpdateParent < sizeof(m_szUpdateParent));
     1515        Log2(("updateCallbackHandleOutOfOrder: m_szUpdateParent='%s' m_cchUpdateParent=%u (%u)\n", m_szUpdateParent, m_cchUpdateParent, __LINE__));
    14841516
    14851517        if (!pNode->cChildren)
     
    15711603    m_pUpdateParent = pNode->pParent;
    15721604    m_iUpdateChild = pNode->iSelf;
     1605    Log2(("updateCallbackHandleOutOfOrder: m_szUpdateParent='%s' m_cchUpdateParent=%u (%u)\n", m_szUpdateParent, m_cchUpdateParent, __LINE__));
    15731606
    15741607    return pNode;
  • trunk/src/VBox/Devices/Network/slirp/ip_icmp.c

    r44528 r46593  
    5757#include "ip_icmp.h"
    5858#ifdef RT_OS_WINDOWS
    59 #include <Icmpapi.h>
    60 #include <Iphlpapi.h>
     59# include <Icmpapi.h>
     60# include <Iphlpapi.h>
     61# include <iprt/ldr.h>
    6162#endif
    6263
     
    116117    fd_nonblock(pData->icmp_socket.s);
    117118    NSOCK_INC();
     119
    118120#else /* RT_OS_WINDOWS */
    119     pData->hmIcmpLibrary = LoadLibrary("Iphlpapi.dll");
    120     if (pData->hmIcmpLibrary != NULL)
    121     {
    122         pData->pfIcmpParseReplies = (long (WINAPI *)(void *, long))
    123                                     GetProcAddress(pData->hmIcmpLibrary, "IcmpParseReplies");
    124         pData->pfIcmpCloseHandle = (BOOL (WINAPI *)(HANDLE))
    125                                     GetProcAddress(pData->hmIcmpLibrary, "IcmpCloseHandle");
    126         pData->pfGetAdaptersAddresses = (ULONG (WINAPI *)(ULONG, ULONG, PVOID, PIP_ADAPTER_ADDRESSES, PULONG))
    127                                     GetProcAddress(pData->hmIcmpLibrary, "GetAdaptersAddresses");
    128         if (pData->pfGetAdaptersAddresses == NULL)
     121    /* Resolve symbols we need. */
     122    {
     123        RTLDRMOD hLdrMod;
     124        int rc = RTLdrLoadSystem("Iphlpapi.dll", true /*fNoUnload*/, &hLdrMod);
     125        if (RT_SUCCESS(rc))
    129126        {
    130             LogRel(("NAT: Can't find GetAdapterAddresses in Iphlpapi.dll\n"));
     127            pData->pfIcmpParseReplies = (long (WINAPI *)(void *, long))RTLdrGetFunction(hLdrMod, "IcmpParseReplies");
     128            pData->pfIcmpCloseHandle = (BOOL (WINAPI *)(HANDLE))RTLdrGetFunction(hLdrMod, "IcmpCloseHandle");
     129            rc = RTLdrGetSymbol(hLdrMod, "GetAdaptersAddresses", (void **)&pData->pfGetAdaptersAddresses);
     130            if (RT_FAILURE(rc))
     131                LogRel(("NAT: Can't find GetAdapterAddresses in Iphlpapi.dll\n"));
     132            RTLdrClose(hLdrMod);
    131133        }
    132     }
    133 
     134
     135        if (pData->pfIcmpParseReplies == NULL)
     136        {
     137            int rc = RTLdrLoadSystem("Icmp.dll", true /*fNoUnload*/, &hLdrMod);
     138            if (RT_FAILURE(rc))
     139            {
     140                LogRel(("NAT: Icmp.dll could not be loaded: %Rrc\n", rc));
     141                return 1;
     142            }
     143            pData->pfIcmpParseReplies = (long (WINAPI *)(void *, long))RTLdrGetFunction(hLdrMod, "IcmpParseReplies");
     144            pData->pfIcmpCloseHandle = (BOOL (WINAPI *)(HANDLE))RTLdrGetFunction(hLdrMod, "IcmpCloseHandle");
     145            RTLdrClose(hLdrMod);
     146        }
     147    }
    134148    if (pData->pfIcmpParseReplies == NULL)
    135149    {
    136         if(pData->pfGetAdaptersAddresses == NULL)
    137             FreeLibrary(pData->hmIcmpLibrary);
    138         pData->hmIcmpLibrary = LoadLibrary("Icmp.dll");
    139         if (pData->hmIcmpLibrary == NULL)
    140         {
    141             LogRel(("NAT: Icmp.dll could not be loaded\n"));
    142             return 1;
    143         }
    144         pData->pfIcmpParseReplies = (long (WINAPI *)(void *, long))
    145                                     GetProcAddress(pData->hmIcmpLibrary, "IcmpParseReplies");
    146         pData->pfIcmpCloseHandle = (BOOL (WINAPI *)(HANDLE))
    147                                     GetProcAddress(pData->hmIcmpLibrary, "IcmpCloseHandle");
    148     }
    149     if (pData->pfIcmpParseReplies == NULL)
    150     {
    151150        LogRel(("NAT: Can't find IcmpParseReplies symbol\n"));
    152         FreeLibrary(pData->hmIcmpLibrary);
    153151        return 1;
    154152    }
     
    156154    {
    157155        LogRel(("NAT: Can't find IcmpCloseHandle symbol\n"));
    158         FreeLibrary(pData->hmIcmpLibrary);
    159156        return 1;
    160157    }
     158
    161159    pData->icmp_socket.sh = IcmpCreateFile();
    162160    pData->phEvents[VBOX_ICMP_EVENT_INDEX] = CreateEvent(NULL, FALSE, FALSE, NULL);
    163     pData->szIcmpBuffer = sizeof(ICMP_ECHO_REPLY) * 10;
    164     pData->pvIcmpBuffer = RTMemAlloc(pData->szIcmpBuffer);
     161    pData->cbIcmpBuffer = sizeof(ICMP_ECHO_REPLY) * 10;
     162    pData->pvIcmpBuffer = RTMemAlloc(pData->cbIcmpBuffer);
    165163#endif /* RT_OS_WINDOWS */
     164
    166165    LIST_INIT(&pData->icmp_msg_head);
    167166    return 0;
     
    177176#ifdef RT_OS_WINDOWS
    178177    pData->pfIcmpCloseHandle(pData->icmp_socket.sh);
    179     FreeLibrary(pData->hmIcmpLibrary);
    180178    RTMemFree(pData->pvIcmpBuffer);
    181179#else
     
    529527                                       &ipopt /*=RequestOptions*/,
    530528                                       pData->pvIcmpBuffer /*=ReplyBuffer*/,
    531                                        pData->szIcmpBuffer /*=ReplySize*/,
     529                                       pData->cbIcmpBuffer /*=ReplySize*/,
    532530                                       1 /*=Timeout in ms*/);
    533531                error = GetLastError();
     
    710708    {
    711709        /* DEBUG : append message to ICMP packet */
    712         int message_len;
     710        size_t message_len;
    713711        message_len = strlen(message);
    714712        if (message_len > ICMP_MAXDATALEN)
    715713            message_len = ICMP_MAXDATALEN;
    716         m_append(pData, m, message_len, message);
     714        m_append(pData, m, (int)message_len, message);
    717715    }
    718716#else
  • trunk/src/VBox/Devices/Network/slirp/slirp_state.h

    r41987 r46593  
    202202# ifdef RT_OS_WINDOWS
    203203    void *pvIcmpBuffer;
    204     size_t szIcmpBuffer;
    205     /* Accordin MSDN specification IcmpParseReplies
    206      * function should be detected in runtime
     204    uint32_t cbIcmpBuffer;
     205    /* According MSDN specification IcmpParseReplies
     206     * function should be detected at runtime.
    207207     */
    208208    long (WINAPI * pfIcmpParseReplies)(void *, long);
    209209    BOOL (WINAPI * pfIcmpCloseHandle)(HANDLE);
    210     HMODULE hmIcmpLibrary;
    211210# endif
    212211#if defined(RT_OS_WINDOWS)
  • trunk/src/VBox/Devices/Network/slirp/socket.c

    r45261 r46593  
    14791479    int size;
    14801480
    1481     len = pData->pfIcmpParseReplies(pData->pvIcmpBuffer, pData->szIcmpBuffer);
     1481    len = pData->pfIcmpParseReplies(pData->pvIcmpBuffer, pData->cbIcmpBuffer);
    14821482    if (len < 0)
    14831483    {
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.cpp

    r44529 r46593  
    11/* $Id$ */
    22/** @file
    3  *
    4  * VBox frontends: Qt GUI ("VirtualBox"):
    5  * QILineEdit class implementation
     3 * VirtualBox Qt GUI - QILineEdit class implementation.
    64 */
    75
    86/*
    9  * Copyright (C) 2008-2010 Oracle Corporation
     7 * Copyright (C) 2008-2013 Oracle Corporation
    108 *
    119 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2422
    2523#if defined (Q_WS_WIN32)
    26 #include <QWindowsVistaStyle>
    27 #include <QLibrary>
     24# include <QWindowsVistaStyle>
     25# include <QLibrary>
     26#endif
     27#if defined (Q_WS_WIN32)
     28# include <Windows.h>
     29# include "iprt/ldr.h"
    2830#endif
    2931
     
    6264        /* Check if l&f style theme is really active else painting performed by
    6365         * Windows Classic theme and there is no such shifting error. */
    64         typedef bool (*IsAppThemedFunction)();
    65         IsAppThemedFunction isAppThemed =
    66             (IsAppThemedFunction) QLibrary::resolve ("uxtheme", "IsAppThemed");
    67         if (isAppThemed && isAppThemed()) sa -= QSize (23, 0);
     66        typedef BOOL (WINAPI *PFNISAPPTHEMED)(VOID);
     67        static PFNISAPPTHEMED s_pfnIsAppThemed = (PFNISAPPTHEMED)~(uintptr_t)0;
     68        if (s_pfnIsAppThemed == (PFNISAPPTHEMED)~(uintptr_t)0 )
     69            s_pfnIsAppThemed = (PFNISAPPTHEMED)RTLdrGetSystemSymbol("uxtheme.dll", "IsAppThemed");
     70
     71        if (s_pfnIsAppThemed && s_pfnIsAppThemed())
     72            sa -= QSize(23, 0);
    6873    }
    6974#endif
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/cfg/VBoxNetCfg.cpp

    r46386 r46593  
    21402140
    21412141
    2142 #define NETSHELL_LIBRARY _T("netshell.dll")
    2143 
    21442142/**
    21452143 *  Use the IShellFolder API to rename the connection.
     
    21872185
    21882186    return hr;
     2187}
     2188
     2189/**
     2190 * Loads a system DLL.
     2191 *
     2192 * @returns Module handle or NULL
     2193 * @param   pszName             The DLL name.
     2194 */
     2195static HMODULE loadSystemDll(const char *pszName)
     2196{
     2197    char   szPath[MAX_PATH];
     2198    UINT   cchPath = GetSystemDirectoryA(szPath, sizeof(szPath));
     2199    size_t cbName  = strlen(pszName) + 1;
     2200    if (cchPath + 1 + cbName > sizeof(szPath))
     2201        return NULL;
     2202    szPath[cchPath] = '\\';
     2203    memcpy(&szPath[cchPath + 1], pszName, cbName);
     2204    return LoadLibraryA(szPath);
    21892205}
    21902206
     
    22092225        if (FAILED(status))
    22102226            return E_FAIL;
    2211         hNetShell = LoadLibrary (NETSHELL_LIBRARY);
     2227        hNetShell = loadSystemDll("netshell.dll");
    22122228        if (hNetShell == NULL)
    22132229            return E_FAIL;
  • trunk/src/VBox/Main/src-client/win/dllmain.cpp

    r44528 r46593  
    4646
    4747        // idempotent, so doesn't harm, and needed for COM embedding scenario
    48         RTR3InitDll(0);
     48        RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    4949    }
    5050    else if (dwReason == DLL_PROCESS_DETACH)
  • trunk/src/VBox/Main/src-server/win/PerformanceWin.cpp

    r46460 r46593  
    3434
    3535#include <iprt/err.h>
     36#include <iprt/ldr.h>
    3637#include <iprt/mp.h>
    3738#include <iprt/mem.h>
     
    8788    PFNGST  mpfnGetSystemTimes;
    8889    PFNNQSI mpfnNtQuerySystemInformation;
    89     HMODULE mhNtDll;
    9090
    9191    ULONG   totalRAM;
     
    9797}
    9898
    99 CollectorWin::CollectorWin() : CollectorHAL(), mhNtDll(0)
    100 {
    101     mpfnGetSystemTimes = (PFNGST)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")),
    102                                                 "GetSystemTimes");
     99CollectorWin::CollectorWin() : CollectorHAL(), mpfnNtQuerySystemInformation(NULL)
     100{
     101    /* Note! Both kernel32.dll and ntdll.dll can be assumed to always be present. */
     102    mpfnGetSystemTimes = (PFNGST)RTLdrGetSystemSymbol("kernel32.dll", "GetSystemTimes");
    103103    if (!mpfnGetSystemTimes)
    104104    {
    105105        /* Fall back to deprecated NtQuerySystemInformation */
    106         if (!(mhNtDll = LoadLibrary(TEXT("ntdll.dll"))))
    107         {
    108             LogRel(("Failed to load NTDLL.DLL with error 0x%x. GetSystemTimes() is"
    109                     " not available either. CPU and VM metrics will not be collected.\n",
    110                     GetLastError()));
    111             mpfnNtQuerySystemInformation = 0;
    112         }
    113         else if (!(mpfnNtQuerySystemInformation = (PFNNQSI)GetProcAddress(mhNtDll,
    114                                                                           "NtQuerySystemInformation")))
    115         {
    116             LogRel(("Neither GetSystemTimes() nor NtQuerySystemInformation() is"
    117                     " not available. CPU and VM metrics will not be collected.\n"));
    118             mpfnNtQuerySystemInformation = 0;
    119         }
     106        mpfnNtQuerySystemInformation = (PFNNQSI)RTLdrGetSystemSymbol("ntdll.dll", "NtQuerySystemInformation");
     107        if (!mpfnNtQuerySystemInformation)
     108            LogRel(("Warning! Neither GetSystemTimes() nor NtQuerySystemInformation() is not available.\n"
     109                    "         CPU and VM metrics will not be collected! (lasterr %u)\n", GetLastError()));
    120110    }
    121111
     
    130120CollectorWin::~CollectorWin()
    131121{
    132     if (mhNtDll)
    133         FreeLibrary(mhNtDll);
    134122}
    135123
  • trunk/src/VBox/Runtime/Makefile.kmk

    r46570 r46593  
    595595        r3/win/fileio-win.cpp \
    596596        r3/win/fs-win.cpp \
     597        r3/win/init-win.cpp \
    597598        r3/win/ldrNative-win.cpp \
    598599        r3/win/localipc-win.cpp \
  • trunk/src/VBox/Runtime/VBox/VBoxRTDeps.cpp

    r41117 r46593  
    3636#include <iprt/system.h>
    3737
    38 #include <libxml/xmlmodule.h>
     38#include <libxml/catalog.h>
    3939#include <libxml/globals.h>
    4040#include <openssl/md5.h>
     
    5858    (PFNRT)SUPTracerFireProbe,
    5959#endif
    60     (PFNRT)xmlModuleOpen,
     60    (PFNRT)xmlLoadCatalogs,
    6161    (PFNRT)MD5_Init,
    6262    (PFNRT)RC4,
  • trunk/src/VBox/Runtime/common/ldr/ldr.cpp

    r46164 r46593  
    9494
    9595
     96RTDECL(PFNRT) RTLdrGetFunction(RTLDRMOD hLdrMod, const char *pszSymbol)
     97{
     98    PFNRT pfn;
     99    int rc = RTLdrGetSymbol(hLdrMod, pszSymbol, (void **)&pfn);
     100    if (RT_SUCCESS(rc))
     101        return pfn;
     102    return NULL;
     103}
     104RT_EXPORT_SYMBOL(RTLdrGetFunction);
     105
     106
    96107RTDECL(RTLDRFMT) RTLdrGetFormat(RTLDRMOD hLdrMod)
    97108{
  • trunk/src/VBox/Runtime/common/ldr/ldrNative.cpp

    r46164 r46593  
    55
    66/*
    7  * Copyright (C) 2006-2011 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6363 * Operations for a native module.
    6464 */
    65 static const RTLDROPS s_rtldrNativeOps =
     65static const RTLDROPS g_rtldrNativeOps =
    6666{
    6767    "native",
     
    131131        pMod->Core.u32Magic     = RTLDRMOD_MAGIC;
    132132        pMod->Core.eState       = LDR_STATE_LOADED;
    133         pMod->Core.pOps         = &s_rtldrNativeOps;
     133        pMod->Core.pOps         = &g_rtldrNativeOps;
    134134        pMod->Core.pReader      = NULL;
    135135        pMod->Core.enmFormat    = RTLDRFMT_NATIVE;
     
    148148#endif
    149149        pMod->hNative           = ~(uintptr_t)0;
     150        pMod->fFlags            = fFlags;
    150151
    151152        /*
     
    171172
    172173
     174RTDECL(int) RTLdrLoadSystem(const char *pszFilename, bool fNoUnload, PRTLDRMOD phLdrMod)
     175{
     176    LogFlow(("RTLdrLoadSystem: pszFilename=%p:{%s} fNoUnload=%RTbool phLdrMod=%p\n",
     177             pszFilename, pszFilename, fNoUnload, phLdrMod));
     178
     179    /*
     180     * Validate input.
     181     */
     182    AssertPtrReturn(phLdrMod, VERR_INVALID_PARAMETER);
     183    *phLdrMod = NIL_RTLDRMOD;
     184    AssertPtrReturn(pszFilename, VERR_INVALID_PARAMETER);
     185    AssertMsgReturn(!RTPathHavePath(pszFilename), ("%s\n", pszFilename), VERR_INVALID_PARAMETER);
     186
     187    /*
     188     * Check the filename.
     189     */
     190    size_t cchFilename = strlen(pszFilename);
     191    AssertMsgReturn(cchFilename < (RTPATH_MAX / 4) * 3, ("%zu\n", cchFilename), VERR_INVALID_PARAMETER);
     192
     193    const char *pszExt = "";
     194    if (!RTPathHaveExt(pszFilename))
     195        pszExt = RTLdrGetSuff();
     196
     197    /*
     198     * Let the platform specific code do the rest.
     199     */
     200    int rc = rtldrNativeLoadSystem(pszFilename, pszExt, fNoUnload ? RTLDRLOAD_FLAGS_NO_UNLOAD : 0, phLdrMod);
     201    LogFlow(("RTLdrLoadSystem: returns %Rrc\n", rc));
     202    return rc;
     203}
     204
     205
     206RTDECL(void *) RTLdrGetSystemSymbol(const char *pszFilename, const char *pszSymbol)
     207{
     208    void    *pvRet = NULL;
     209    RTLDRMOD hLdrMod;
     210    int rc = RTLdrLoadSystem(pszFilename, true /*fNoUnload*/, &hLdrMod);
     211    if (RT_SUCCESS(rc))
     212    {
     213        rc = RTLdrGetSymbol(hLdrMod, pszSymbol, &pvRet);
     214        if (RT_FAILURE(rc))
     215            pvRet = NULL; /* paranoia */
     216        RTLdrClose(hLdrMod);
     217    }
     218    return pvRet;
     219}
     220
     221
    173222/**
    174223 * Loads a dynamic load library (/shared object) image file residing in the
     
    258307RT_EXPORT_SYMBOL(RTLdrGetSuff);
    259308
     309
     310RTDECL(uintptr_t) RTLdrGetNativeHandle(RTLDRMOD hLdrMod)
     311{
     312    PRTLDRMODNATIVE pThis = (PRTLDRMODNATIVE)hLdrMod;
     313    AssertPtrReturn(pThis, ~(uintptr_t)0);
     314    AssertReturn(pThis->Core.u32Magic == RTLDRMOD_MAGIC, ~(uintptr_t)0);
     315    AssertReturn(pThis->Core.pOps == &g_rtldrNativeOps, ~(uintptr_t)0);
     316    return pThis->hNative;
     317}
     318RT_EXPORT_SYMBOL(RTLdrGetNativeHandle);
     319
  • trunk/src/VBox/Runtime/common/misc/thread.cpp

    r44528 r46593  
    184184    return rc;
    185185}
     186
     187
     188#ifdef IN_RING3
     189/**
     190 * Called when IPRT was first initialized in unobtrusive mode and later changed
     191 * to obtrustive.
     192 *
     193 * This is only applicable in ring-3.
     194 */
     195DECLHIDDEN(void) rtThreadReInitObtrusive(void)
     196{
     197    rtThreadNativeReInitObtrusive();
     198}
     199#endif
    186200
    187201
  • trunk/src/VBox/Runtime/include/internal/ldr.h

    r46164 r46593  
    459459    /** The native handle. */
    460460    uintptr_t           hNative;
    461 } RTLDRMODNATIVE, *PRTLDRMODNATIVE;
     461    /** The load flags (RTLDRLOAD_FLAGS_XXX). */
     462    uint32_t            fFlags;
     463} RTLDRMODNATIVE;
     464/** Pointer to a native module. */
     465typedef RTLDRMODNATIVE *PRTLDRMODNATIVE;
    462466
    463467/** @copydoc RTLDROPS::pfnGetSymbol */
     
    472476 * @param   pszFilename     The image filename.
    473477 * @param   phHandle        Where to store the module handle on success.
    474  * @param   fFlags          See RTLDRFLAGS_.
     478 * @param   fFlags          RTLDRLOAD_FLAGS_XXX.
    475479 * @param   pErrInfo        Where to return extended error information. Optional.
    476480 */
    477481int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo);
     482
     483/**
     484 * Load a system library.
     485 *
     486 * @returns iprt status code.
     487 * @param   pszFilename     The image filename.
     488 * @param   pszExt          Extension to add. NULL if none.
     489 * @param   fFlags          RTLDRLOAD_FLAGS_XXX.
     490 * @param   phLdrMod        Where to return the module handle on success.
     491 */
     492int rtldrNativeLoadSystem(const char *pszFilename, const char *pszExt, uint32_t fFlags, PRTLDRMOD phLdrMod);
    478493
    479494int rtldrPEOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offNtHdrs, PRTLDRMOD phLdrMod);
  • trunk/src/VBox/Runtime/include/internal/thread.h

    r44528 r46593  
    140140DECLHIDDEN(int) rtThreadNativeInit(void);
    141141
     142#ifdef IN_RING3
     143/**
     144 * Called when IPRT was first initialized in unobtrusive mode and later changed
     145 * to obtrustive.
     146 *
     147 * This is only applicable in ring-3.
     148 */
     149DECLHIDDEN(void) rtThreadNativeReInitObtrusive(void);
     150#endif
     151
    142152/**
    143153 * Create a native thread.
     
    200210DECLHIDDEN(PRTTHREADINT) rtThreadGet(RTTHREAD Thread);
    201211DECLHIDDEN(int)          rtThreadInit(void);
     212#ifdef IN_RING3
     213DECLHIDDEN(void)         rtThreadReInitObtrusive(void);
     214#endif
    202215DECLHIDDEN(void)         rtThreadTerm(void);
    203216DECLHIDDEN(void)         rtThreadInsert(PRTTHREADINT pThread, RTNATIVETHREAD NativeThread);
  • trunk/src/VBox/Runtime/r3/init.cpp

    r45375 r46593  
    6767#include <stdlib.h>
    6868
     69#include "init.h"
    6970#include "internal/alignmentchecks.h"
    7071#include "internal/path.h"
    7172#include "internal/process.h"
    72 #include "internal/thread.h"
    7373#include "internal/thread.h"
    7474#include "internal/time.h"
     
    140140 */
    141141RTDATADECL(bool) g_fRTAlignmentChecks = false;
     142#endif
     143
     144
     145#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_HAIKU) \
     146 || defined(RT_OS_LINUX)  || defined(RT_OS_OS2)     || defined(RT_OS_SOLARIS) /** @todo add host init hooks everywhere. */
     147/* Stubs */
     148DECLHIDDEN(int)  rtR3InitNativeFirst(uint32_t fFlags) { return VINF_SUCCESS; }
     149DECLHIDDEN(int)  rtR3InitNativeFinal(uint32_t fFlags) { return VINF_SUCCESS; }
     150DECLHIDDEN(void) rtR3InitNativeObtrusive(void) { }
    142151#endif
    143152
     
    351360{
    352361    /*
     362     * Early native initialization.
     363     */
     364    int rc = rtR3InitNativeFirst(fFlags);
     365    AssertMsgRCReturn(rc, ("rtR3InitNativeFirst failed with %Rrc\n", rc), rc);
     366
     367    /*
     368     * Disable error popups.
     369     */
     370#if defined(RT_OS_OS2) /** @todo move to private code. */
     371    DosError(FERR_DISABLEHARDERR);
     372#endif
     373
     374    /*
    353375     * Init C runtime locale before we do anything that may end up converting
    354376     * paths or we'll end up using the "C" locale for path conversion.
     
    366388
    367389    /*
    368      * Disable error popups.
    369      */
    370 #ifdef RT_OS_WINDOWS
    371     UINT fOldErrMode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
    372     SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX | fOldErrMode);
    373 #elif defined(RT_OS_OS2)
    374     DosError(FERR_DISABLEHARDERR);
    375 #endif
    376 
    377     /*
    378390     * Save the init flags.
    379391     */
     
    403415     * without having initialized TLS entries and suchlike.
    404416     */
    405     int rc = rtThreadInit();
     417    rc = rtThreadInit();
    406418    AssertMsgRCReturn(rc, ("Failed to initialize threads, rc=%Rrc!\n", rc), rc);
    407419
     
    505517#endif
    506518
     519    /*
     520     * Final native initialization.
     521     */
     522    rc = rtR3InitNativeFinal(fFlags);
     523    AssertMsgRCReturn(rc, ("rtR3InitNativeFinal failed with %Rrc\n", rc), rc);
     524
    507525    return VINF_SUCCESS;
    508526}
     
    546564        }
    547565#endif
    548         if (!pszProgramPath)
    549             return VINF_SUCCESS;
    550 
    551         int rc = rtR3InitProgramPath(pszProgramPath);
     566
     567        if (   !(fFlags      & RTR3INIT_FLAGS_UNOBTRUSIVE)
     568            && (g_fInitFlags & RTR3INIT_FLAGS_UNOBTRUSIVE))
     569        {
     570            g_fInitFlags &= ~RTR3INIT_FLAGS_UNOBTRUSIVE;
     571            rtR3InitNativeObtrusive();
     572            rtThreadReInitObtrusive();
     573        }
     574
     575        int rc = VINF_SUCCESS;
     576        if (pszProgramPath)
     577            rc = rtR3InitProgramPath(pszProgramPath);
    552578        if (RT_SUCCESS(rc))
    553579            rc = rtR3InitArgv(fFlags, cArgs, papszArgs);
  • trunk/src/VBox/Runtime/r3/os2/thread-os2.cpp

    r44528 r46593  
    7979
    8080
    81 DECLHIDDEN(int) rtThreadNativeAdopt(PRTTHREADINT pThread)
     81static void rtThreadOs2BlockSigAlarm(void)
    8282{
    8383    /*
     
    9090    sigaddset(&SigSet, SIGALRM);
    9191    sigprocmask(SIG_BLOCK, &SigSet, NULL);
     92}
     93
     94
     95DECLHIDDEN(void) rtThreadNativeReInitObtrusive(void)
     96{
     97    rtThreadOs2BlockSigAlarm();
     98}
     99
     100
     101DECLHIDDEN(int) rtThreadNativeAdopt(PRTTHREADINT pThread)
     102{
    92103
    93104    *g_ppCurThread = pThread;
     
    108119static void rtThreadNativeMain(void *pvArgs)
    109120{
    110     /*
    111      * Block SIGALRM - required for timer-posix.cpp.
    112      * This is done to limit harm done by OSes which doesn't do special SIGALRM scheduling.
    113      * It will not help much if someone creates threads directly using pthread_create. :/
    114      */
    115     sigset_t SigSet;
    116     sigemptyset(&SigSet);
    117     sigaddset(&SigSet, SIGALRM);
    118     sigprocmask(SIG_BLOCK, &SigSet, NULL);
     121    rtThreadOs2BlockSigAlarm();
    119122
    120123    /*
  • trunk/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp

    r44528 r46593  
    109109{
    110110    PRTLDRMODNATIVE pModNative = (PRTLDRMODNATIVE)pMod;
    111     if (!dlclose((void *)pModNative->hNative))
     111    if (   (pModNative->fFlags & RTLDRLOAD_FLAGS_NO_UNLOAD)
     112        || !dlclose((void *)pModNative->hNative))
    112113    {
    113114        pModNative->hNative = (uintptr_t)0;
     
    118119}
    119120
     121
     122int rtldrNativeLoadSystem(const char *pszFilename, const char *pszExt, uint32_t fFlags, PRTLDRMOD phLdrMod)
     123{
     124    /** @todo implement this in some sensible fashion. */
     125    return VERR_NOT_SUPPORTED;
     126}
     127
  • trunk/src/VBox/Runtime/r3/posix/thread-posix.cpp

    r44528 r46593  
    121121
    122122
    123 DECLHIDDEN(int) rtThreadNativeInit(void)
    124 {
    125     /*
    126      * Allocate the TLS (key in posix terms) where we store the pointer to
    127      * a threads RTTHREADINT structure.
    128      */
    129     int rc = pthread_key_create(&g_SelfKey, rtThreadKeyDestruct);
    130     if (rc)
    131         return VERR_NO_TLS_FOR_SELF;
    132 
    133 #ifdef RTTHREAD_POSIX_WITH_POKE
    134     /*
    135      * Try register the dummy signal handler for RTThreadPoke.
    136      * Avoid SIGRTMIN thru SIGRTMIN+2 because of LinuxThreads.
     123#ifdef RTTHREAD_POSIX_WITH_POKE
     124/**
     125 * Try register the dummy signal handler for RTThreadPoke.
     126 */
     127static void rtThreadPosixSelectPokeSignal(void)
     128{
     129    /*
     130     * Note! Avoid SIGRTMIN thru SIGRTMIN+2 because of LinuxThreads.
    137131     */
    138132    static const int s_aiSigCandidates[] =
     
    179173        }
    180174    }
     175}
    181176#endif /* RTTHREAD_POSIX_WITH_POKE */
     177
     178
     179DECLHIDDEN(int) rtThreadNativeInit(void)
     180{
     181    /*
     182     * Allocate the TLS (key in posix terms) where we store the pointer to
     183     * a threads RTTHREADINT structure.
     184     */
     185    int rc = pthread_key_create(&g_SelfKey, rtThreadKeyDestruct);
     186    if (rc)
     187        return VERR_NO_TLS_FOR_SELF;
     188
     189#ifdef RTTHREAD_POSIX_WITH_POKE
     190    rtThreadPosixSelectPokeSignal();
     191#endif
    182192
    183193#ifdef IPRT_MAY_HAVE_PTHREAD_SET_NAME_NP
     
    188198}
    189199
    190 
    191 /**
    192  * Destructor called when a thread terminates.
    193  * @param   pvValue     The key value. PRTTHREAD in our case.
    194  */
    195 static void rtThreadKeyDestruct(void *pvValue)
    196 {
    197     /*
    198      * Deal with alien threads.
    199      */
    200     PRTTHREADINT pThread = (PRTTHREADINT)pvValue;
    201     if (pThread->fIntFlags & RTTHREADINT_FLAGS_ALIEN)
    202     {
    203         pthread_setspecific(g_SelfKey, pThread);
    204         rtThreadTerminate(pThread, 0);
    205         pthread_setspecific(g_SelfKey, NULL);
    206     }
    207 }
    208 
    209 
    210 #ifdef RTTHREAD_POSIX_WITH_POKE
    211 /**
    212  * Dummy signal handler for the poke signal.
    213  *
    214  * @param   iSignal     The signal number.
    215  */
    216 static void rtThreadPosixPokeSignal(int iSignal)
    217 {
    218     Assert(iSignal == g_iSigPokeThread);
    219     NOREF(iSignal);
    220 }
    221 #endif
    222 
    223 
    224 /**
    225  * Adopts a thread, this is called immediately after allocating the
    226  * thread structure.
    227  *
    228  * @param   pThread     Pointer to the thread structure.
    229  */
    230 DECLHIDDEN(int) rtThreadNativeAdopt(PRTTHREADINT pThread)
     200static void rtThreadPosixBlockSignals(void)
    231201{
    232202    /*
     
    246216        siginterrupt(g_iSigPokeThread, 1);
    247217#endif
     218}
     219
     220DECLHIDDEN(void) rtThreadNativeReInitObtrusive(void)
     221{
     222#ifdef RTTHREAD_POSIX_WITH_POKE
     223    Assert(!RTR3InitIsUnobtrusive());
     224    rtThreadPosixSelectPokeSignal();
     225#endif
     226    rtThreadPosixBlockSignals();
     227}
     228
     229
     230/**
     231 * Destructor called when a thread terminates.
     232 * @param   pvValue     The key value. PRTTHREAD in our case.
     233 */
     234static void rtThreadKeyDestruct(void *pvValue)
     235{
     236    /*
     237     * Deal with alien threads.
     238     */
     239    PRTTHREADINT pThread = (PRTTHREADINT)pvValue;
     240    if (pThread->fIntFlags & RTTHREADINT_FLAGS_ALIEN)
     241    {
     242        pthread_setspecific(g_SelfKey, pThread);
     243        rtThreadTerminate(pThread, 0);
     244        pthread_setspecific(g_SelfKey, NULL);
     245    }
     246}
     247
     248
     249#ifdef RTTHREAD_POSIX_WITH_POKE
     250/**
     251 * Dummy signal handler for the poke signal.
     252 *
     253 * @param   iSignal     The signal number.
     254 */
     255static void rtThreadPosixPokeSignal(int iSignal)
     256{
     257    Assert(iSignal == g_iSigPokeThread);
     258    NOREF(iSignal);
     259}
     260#endif
     261
     262
     263/**
     264 * Adopts a thread, this is called immediately after allocating the
     265 * thread structure.
     266 *
     267 * @param   pThread     Pointer to the thread structure.
     268 */
     269DECLHIDDEN(int) rtThreadNativeAdopt(PRTTHREADINT pThread)
     270{
     271    rtThreadPosixBlockSignals();
    248272
    249273    int rc = pthread_setspecific(g_SelfKey, pThread);
     
    278302#endif
    279303
    280     /*
    281      * Block SIGALRM - required for timer-posix.cpp.
    282      * This is done to limit harm done by OSes which doesn't do special SIGALRM scheduling.
    283      * It will not help much if someone creates threads directly using pthread_create. :/
    284      */
    285     sigset_t SigSet;
    286     sigemptyset(&SigSet);
    287     sigaddset(&SigSet, SIGALRM);
    288     sigprocmask(SIG_BLOCK, &SigSet, NULL);
    289 #ifdef RTTHREAD_POSIX_WITH_POKE
    290     if (g_iSigPokeThread != -1)
    291         siginterrupt(g_iSigPokeThread, 1);
    292 #endif
     304    rtThreadPosixBlockSignals();
    293305
    294306    /*
  • trunk/src/VBox/Runtime/r3/win/ldrNative-win.cpp

    r46561 r46593  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3232
    3333#include <iprt/ldr.h>
     34#include "internal/iprt.h"
     35
     36#include <iprt/alloca.h>
    3437#include <iprt/assert.h>
     38#include <iprt/err.h>
     39#include <iprt/file.h>
    3540#include <iprt/path.h>
    36 #include <iprt/err.h>
    37 #include <iprt/alloca.h>
     41#include <iprt/string.h>
     42
    3843#include <iprt/once.h>
    3944#include <iprt/string.h>
    4045#include "internal/ldr.h"
    4146
    42 static RTONCE g_Once = RTONCE_INITIALIZER;
    43 
    44 static DECLCALLBACK(int) rtldrOnceSetDllDirectory(void *pvUser)
    45 {
    46     HMODULE hmod = GetModuleHandle(TEXT("kernel32.dll"));
    47     if (hmod)
    48     {
    49         typedef BOOLEAN (WINAPI *PFNSETDLLDIRECTORY)(LPCWSTR);
    50         PFNSETDLLDIRECTORY pfn = (PFNSETDLLDIRECTORY)GetProcAddress(hmod, "SetDllDirectoryW");
    51         if (pfn)
    52         {
    53             BOOL fOk = pfn(L"");
    54             if (!fOk)
    55                 return RTErrConvertFromWin32(GetLastError());
    56         }
    57     }
    58     return VINF_SUCCESS;
    59 }
    6047
    6148int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo)
    6249{
    6350    Assert(sizeof(*phHandle) >= sizeof(HMODULE));
    64     AssertReturn(fFlags == 0, VERR_INVALID_PARAMETER);
     51    AssertReturn(fFlags == 0 || fFlags == RTLDRLOAD_FLAGS_NO_UNLOAD, VERR_INVALID_PARAMETER);
    6552
    6653    /*
     
    7966
    8067    /*
    81      * Don't allow loading DLLs from the current directory.
    82      */
    83 #if 0
    84     int rc = RTOnce(&g_Once, rtldrOnceSetDllDirectory, NULL);
    85     if (RT_FAILURE(rc))
    86         return rc;
    87 #else
    88     int rc = VINF_SUCCESS;
    89 #endif
    90 
    91     /*
    9268     * Attempt load.
    9369     */
     
    10379     */
    10480    DWORD dwErr = GetLastError();
    105     rc = RTErrConvertFromWin32(dwErr);
     81    int rc = RTErrConvertFromWin32(dwErr);
    10682    return RTErrInfoSetF(pErrInfo, rc, "GetLastError=%u", dwErr);
    10783}
     
    125101{
    126102    PRTLDRMODNATIVE pModNative = (PRTLDRMODNATIVE)pMod;
    127     if (FreeLibrary((HMODULE)pModNative->hNative))
     103    if (   (pModNative->fFlags & RTLDRLOAD_FLAGS_NO_UNLOAD)
     104        || FreeLibrary((HMODULE)pModNative->hNative))
    128105    {
    129106        pModNative->hNative = (uintptr_t)INVALID_HANDLE_VALUE;
     
    133110}
    134111
     112
     113int rtldrNativeLoadSystem(const char *pszFilename, const char *pszExt, uint32_t fFlags, PRTLDRMOD phLdrMod)
     114{
     115    /*
     116     * We only try the System32 directory.
     117     */
     118    WCHAR wszSysDir[MAX_PATH];
     119    UINT cwcSysDir = GetSystemDirectoryW(wszSysDir, MAX_PATH);
     120    if (cwcSysDir >= MAX_PATH)
     121        return VERR_FILENAME_TOO_LONG;
     122
     123    char szPath[RTPATH_MAX];
     124    char *pszPath = szPath;
     125    int rc = RTUtf16ToUtf8Ex(wszSysDir, RTSTR_MAX, &pszPath, sizeof(szPath), NULL);
     126    if (RT_SUCCESS(rc))
     127    {
     128        rc = RTPathAppend(szPath, sizeof(szPath), pszFilename);
     129        if (pszExt && RT_SUCCESS(rc))
     130            rc = RTStrCat(szPath, sizeof(szPath), pszExt);
     131        if (RT_SUCCESS(rc))
     132        {
     133            if (RTFileExists(szPath))
     134                rc = RTLdrLoadEx(szPath, phLdrMod, fFlags, NULL);
     135            else
     136                rc = VERR_MODULE_NOT_FOUND;
     137        }
     138    }
     139
     140    return rc;
     141}
     142
  • trunk/src/VBox/Runtime/r3/win/process-win.cpp

    r46404 r46593  
    5858#include <iprt/string.h>
    5959#include <iprt/socket.h>
     60
     61#include "../init.h"
    6062
    6163
     
    422424     * Load PSAPI.DLL and resolve the two symbols we need.
    423425     */
    424     RTLDRMOD hPsApi;
    425     int rc = RTLdrLoad("PSAPI.dll", &hPsApi);
    426     if (RT_FAILURE_NP(rc))
     426    PFNGETMODULEBASENAME pfnGetModuleBaseName = (PFNGETMODULEBASENAME)RTLdrGetSystemSymbol("psapi.dll", "GetModuleBaseName");
     427    if (!pfnGetModuleBaseName)
    427428        return false;
    428     PFNGETMODULEBASENAME    pfnGetModuleBaseName;
    429     PFNENUMPROCESSES        pfnEnumProcesses;
    430     rc = RTLdrGetSymbol(hPsApi, "EnumProcesses", (void**)&pfnEnumProcesses);
     429    PFNENUMPROCESSES pfnEnumProcesses = (PFNENUMPROCESSES)RTLdrGetSystemSymbol("psapi.dll", "EnumProcesses");
     430    if (!pfnEnumProcesses)
     431        return false;
     432
     433    /*
     434     * Get a list of PID.  We retry if it looks like there are more PIDs
     435     * to be returned than what we supplied buffer space for.
     436     */
     437    int    rc = VINF_SUCCESS;
     438    DWORD  cbPidsAllocated = 4096;
     439    DWORD  cbPidsReturned  = 0;
     440    DWORD *paPids;
     441    for (;;)
     442    {
     443        paPids = (DWORD *)RTMemTmpAlloc(cbPidsAllocated);
     444        AssertBreakStmt(paPids, rc = VERR_NO_TMP_MEMORY);
     445        if (!pfnEnumProcesses(paPids, cbPidsAllocated, &cbPidsReturned))
     446        {
     447            rc = RTErrConvertFromWin32(GetLastError());
     448            AssertMsgFailedBreak(("%Rrc\n", rc));
     449        }
     450        if (   cbPidsReturned < cbPidsAllocated
     451            || cbPidsAllocated >= _512K)
     452            break;
     453        RTMemTmpFree(paPids);
     454        cbPidsAllocated *= 2;
     455    }
    431456    if (RT_SUCCESS(rc))
    432         rc = RTLdrGetSymbol(hPsApi, "GetModuleBaseName", (void**)&pfnGetModuleBaseName);
    433     if (RT_SUCCESS(rc))
    434457    {
    435458        /*
    436          * Get a list of PID.  We retry if it looks like there are more PIDs
    437          * to be returned than what we supplied buffer space for.
     459         * Search for the process.
     460         *
     461         * We ASSUME that the caller won't be specifying any names longer
     462         * than RTPATH_MAX.
    438463         */
    439         DWORD  cbPidsAllocated = 4096;
    440         DWORD  cbPidsReturned  = 0;
    441         DWORD *paPids;
    442         for (;;)
    443         {
    444             paPids = (DWORD *)RTMemTmpAlloc(cbPidsAllocated);
    445             AssertBreakStmt(paPids, rc = VERR_NO_TMP_MEMORY);
    446             if (!pfnEnumProcesses(paPids, cbPidsAllocated, &cbPidsReturned))
     464        DWORD cbProcName  = RTPATH_MAX;
     465        char *pszProcName = (char *)RTMemTmpAlloc(RTPATH_MAX);
     466        if (pszProcName)
     467        {
     468            for (size_t i = 0; papszNames[i] && !fFound; i++)
    447469            {
    448                 rc = RTErrConvertFromWin32(GetLastError());
    449                 AssertMsgFailedBreak(("%Rrc\n", rc));
    450             }
    451             if (   cbPidsReturned < cbPidsAllocated
    452                 || cbPidsAllocated >= _512K)
    453                 break;
    454             RTMemTmpFree(paPids);
    455             cbPidsAllocated *= 2;
    456         }
    457         if (RT_SUCCESS(rc))
    458         {
    459             /*
    460              * Search for the process.
    461              *
    462              * We ASSUME that the caller won't be specifying any names longer
    463              * than RTPATH_MAX.
    464              */
    465             DWORD cbProcName  = RTPATH_MAX;
    466             char *pszProcName = (char *)RTMemTmpAlloc(RTPATH_MAX);
    467             if (pszProcName)
    468             {
    469                 for (size_t i = 0; papszNames[i] && !fFound; i++)
     470                const DWORD cPids = cbPidsReturned / sizeof(DWORD);
     471                for (DWORD iPid = 0; iPid < cPids && !fFound; iPid++)
    470472                {
    471                     const DWORD cPids = cbPidsReturned / sizeof(DWORD);
    472                     for (DWORD iPid = 0; iPid < cPids && !fFound; iPid++)
     473                    HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, paPids[iPid]);
     474                    if (hProc)
    473475                    {
    474                         HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, paPids[iPid]);
    475                         if (hProc)
    476                         {
    477                             *pszProcName = '\0';
    478                             DWORD cbRet = pfnGetModuleBaseName(hProc, 0 /*hModule = exe */, pszProcName, cbProcName);
    479                             if (   cbRet > 0
    480                                 && _stricmp(pszProcName, papszNames[i]) == 0
    481                                 && RT_SUCCESS(rtProcWinGetProcessTokenHandle(paPids[iPid], pSid, phToken)))
    482                                 fFound = true;
    483                             CloseHandle(hProc);
    484                         }
     476                        *pszProcName = '\0';
     477                        DWORD cbRet = pfnGetModuleBaseName(hProc, 0 /*hModule = exe */, pszProcName, cbProcName);
     478                        if (   cbRet > 0
     479                            && _stricmp(pszProcName, papszNames[i]) == 0
     480                            && RT_SUCCESS(rtProcWinGetProcessTokenHandle(paPids[iPid], pSid, phToken)))
     481                            fFound = true;
     482                        CloseHandle(hProc);
    485483                    }
    486484                }
    487                 RTMemTmpFree(pszProcName);
    488485            }
    489             else
    490                 rc = VERR_NO_TMP_MEMORY;
    491         }
    492         RTMemTmpFree(paPids);
    493     }
    494     RTLdrClose(hPsApi);
     486            RTMemTmpFree(pszProcName);
     487        }
     488        else
     489            rc = VERR_NO_TMP_MEMORY;
     490    }
     491    RTMemTmpFree(paPids);
     492
    495493    return fFound;
    496494}
     
    519517     * and reliable.  Fallback to EnumProcess on NT4.
    520518     */
    521     RTLDRMOD hKernel32;
    522     int rc = RTLdrLoad("Kernel32.dll", &hKernel32);
    523     if (RT_SUCCESS(rc))
    524     {
    525         PFNCREATETOOLHELP32SNAPSHOT pfnCreateToolhelp32Snapshot;
    526         PFNPROCESS32FIRST           pfnProcess32First;
    527         PFNPROCESS32NEXT            pfnProcess32Next;
    528         rc = RTLdrGetSymbol(hKernel32, "CreateToolhelp32Snapshot", (void **)&pfnCreateToolhelp32Snapshot);
    529         if (RT_SUCCESS(rc))
    530             rc = RTLdrGetSymbol(hKernel32, "Process32First", (void**)&pfnProcess32First);
    531         if (RT_SUCCESS(rc))
    532             rc = RTLdrGetSymbol(hKernel32, "Process32Next", (void**)&pfnProcess32Next);
    533 
    534         if (RT_SUCCESS(rc))
    535         {
    536             HANDLE hSnap = pfnCreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    537             if (hSnap != INVALID_HANDLE_VALUE)
     519    PFNCREATETOOLHELP32SNAPSHOT pfnCreateToolhelp32Snapshot;
     520    pfnCreateToolhelp32Snapshot = (PFNCREATETOOLHELP32SNAPSHOT)GetProcAddress(g_hModKernel32, "CreateToolhelp32Snapshot");
     521    PFNPROCESS32FIRST pfnProcess32First = (PFNPROCESS32FIRST)GetProcAddress(g_hModKernel32, "Process32First");
     522    PFNPROCESS32NEXT  pfnProcess32Next  = (PFNPROCESS32NEXT )GetProcAddress(g_hModKernel32, "Process32Next");
     523    bool fFallback = true;
     524    if (pfnProcess32Next && pfnProcess32First && pfnCreateToolhelp32Snapshot)
     525    {
     526        HANDLE hSnap = pfnCreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
     527        if (hSnap != INVALID_HANDLE_VALUE)
     528        {
     529            fFallback = false;
     530            for (size_t i = 0; papszNames[i] && !fFound; i++)
    538531            {
    539                 for (size_t i = 0; papszNames[i] && !fFound; i++)
     532                PROCESSENTRY32 procEntry;
     533                procEntry.dwSize = sizeof(PROCESSENTRY32);
     534                if (pfnProcess32First(hSnap, &procEntry))
    540535                {
    541                     PROCESSENTRY32 procEntry;
    542                     procEntry.dwSize = sizeof(PROCESSENTRY32);
    543                     if (pfnProcess32First(hSnap, &procEntry))
     536                    do
    544537                    {
    545                         do
     538                        if (   _stricmp(procEntry.szExeFile, papszNames[i]) == 0
     539                            && RT_SUCCESS(rtProcWinGetProcessTokenHandle(procEntry.th32ProcessID, pSid, phToken)))
    546540                        {
    547                             if (   _stricmp(procEntry.szExeFile, papszNames[i]) == 0
    548                                 && RT_SUCCESS(rtProcWinGetProcessTokenHandle(procEntry.th32ProcessID, pSid, phToken)))
    549                             {
    550                                 fFound = true;
    551                                 break;
    552                             }
    553                         } while (pfnProcess32Next(hSnap, &procEntry));
    554                     }
     541                            fFound = true;
     542                            break;
     543                        }
     544                    } while (pfnProcess32Next(hSnap, &procEntry));
     545                }
    555546#ifdef RT_STRICT
    556                     else
    557                     {
    558                         DWORD dwErr = GetLastError();
    559                         AssertMsgFailed(("dwErr=%u (%x)\n", dwErr, dwErr));
    560                     }
     547                else
     548                {
     549                    DWORD dwErr = GetLastError();
     550                    AssertMsgFailed(("dwErr=%u (%x)\n", dwErr, dwErr));
     551                }
    561552#endif
    562                 }
    563                 CloseHandle(hSnap);
    564553            }
    565             else /* hSnap == INVALID_HANDLE_VALUE */
    566                 rc = RTErrConvertFromWin32(GetLastError());
    567         }
    568         RTLdrClose(hKernel32);
     554            CloseHandle(hSnap);
     555        }
    569556    }
    570557
    571558    /* If we couldn't take a process snapshot for some reason or another, fall
    572559       back on the NT4 compatible API. */
    573     if (RT_FAILURE(rc))
     560    if (fFallback)
    574561        return rtProcWinFindTokenByProcessAndPsApi(papszNames, pSid, phToken);
    575562    return fFound;
     
    689676{
    690677    RTLDRMOD hUserenv;
    691     int rc = RTLdrLoad("Userenv.dll", &hUserenv);
     678    int rc = RTLdrLoadSystem("Userenv.dll", true /*fNoUnload*/, &hUserenv);
    692679    if (RT_SUCCESS(rc))
    693680    {
     
    881868            phToken = fFound ? &hTokenUserDesktop : &hTokenLogon;
    882869            RTLDRMOD hUserenv;
    883             int rc = RTLdrLoad("Userenv.dll", &hUserenv);
     870            int rc = RTLdrLoadSystem("Userenv.dll", true /*fNoUnload*/, &hUserenv);
    884871            if (RT_SUCCESS(rc))
    885872            {
     
    979966                                  STARTUPINFOW *pStartupInfo, PROCESS_INFORMATION *pProcInfo, uint32_t fFlags)
    980967{
    981     RTLDRMOD hAdvAPI32;
    982     int rc = RTLdrLoad("Advapi32.dll", &hAdvAPI32);
     968    PFNCREATEPROCESSWITHLOGON pfnCreateProcessWithLogonW;
     969    pfnCreateProcessWithLogonW = (PFNCREATEPROCESSWITHLOGON)RTLdrGetSystemSymbol("Advapi32.dll", "CreateProcessWithLogonW");
     970    if (pfnCreateProcessWithLogonW)
     971        return VERR_SYMBOL_NOT_FOUND;
     972
     973    PRTUTF16 pwszzBlock;
     974    int rc = rtProcWinCreateEnvFromAccount(pwszUser, pwszPassword, NULL /* Domain */,
     975                                           hEnv, &pwszzBlock);
    983976    if (RT_SUCCESS(rc))
    984977    {
    985         PFNCREATEPROCESSWITHLOGON pfnCreateProcessWithLogonW;
    986         rc = RTLdrGetSymbol(hAdvAPI32, "CreateProcessWithLogonW", (void **)&pfnCreateProcessWithLogonW);
    987         if (RT_SUCCESS(rc))
    988         {
    989             PRTUTF16 pwszzBlock;
    990             rc = rtProcWinCreateEnvFromAccount(pwszUser, pwszPassword, NULL /* Domain */,
    991                                                hEnv, &pwszzBlock);
    992             if (RT_SUCCESS(rc))
    993             {
    994                 BOOL fRc = pfnCreateProcessWithLogonW(pwszUser,
    995                                                       NULL,                       /* lpDomain*/
    996                                                       pwszPassword,
    997                                                       1 /*LOGON_WITH_PROFILE*/,   /* dwLogonFlags */
    998                                                       pwszExec,
    999                                                       pwszCmdLine,
    1000                                                       dwCreationFlags,
    1001                                                       pwszzBlock,
    1002                                                       NULL,                       /* pCurrentDirectory */
    1003                                                       pStartupInfo,
    1004                                                       pProcInfo);
    1005                 if (!fRc)
    1006                 {
    1007                     DWORD dwErr = GetLastError();
    1008                     rc = rtProcWinMapErrorCodes(dwErr);
    1009                     if (rc == VERR_UNRESOLVED_ERROR)
    1010                         LogRelFunc(("pfnCreateProcessWithLogonW (%p) failed: dwErr=%u (%#x), rc=%Rrc\n",
    1011                                     pfnCreateProcessWithLogonW, dwErr, dwErr, rc));
    1012                 }
    1013                 rtProcWinDestroyEnv(pwszzBlock);
    1014             }
    1015         }
    1016         RTLdrClose(hAdvAPI32);
     978        BOOL fRc = pfnCreateProcessWithLogonW(pwszUser,
     979                                              NULL,                       /* lpDomain*/
     980                                              pwszPassword,
     981                                              1 /*LOGON_WITH_PROFILE*/,   /* dwLogonFlags */
     982                                              pwszExec,
     983                                              pwszCmdLine,
     984                                              dwCreationFlags,
     985                                              pwszzBlock,
     986                                              NULL,                       /* pCurrentDirectory */
     987                                              pStartupInfo,
     988                                              pProcInfo);
     989        if (!fRc)
     990        {
     991            DWORD dwErr = GetLastError();
     992            rc = rtProcWinMapErrorCodes(dwErr);
     993            if (rc == VERR_UNRESOLVED_ERROR)
     994                LogRelFunc(("pfnCreateProcessWithLogonW (%p) failed: dwErr=%u (%#x), rc=%Rrc\n",
     995                            pfnCreateProcessWithLogonW, dwErr, dwErr, rc));
     996        }
     997        rtProcWinDestroyEnv(pwszzBlock);
    1017998    }
    1018999    return rc;
  • trunk/src/VBox/Runtime/r3/win/symlink-win.cpp

    r44529 r46593  
    4242
    4343#include <Windows.h>
     44#include "../init.h"
    4445
    4546
     
    134135    if (!s_fTried)
    135136    {
    136         HMODULE hmod = LoadLibrary("KERNEL32.DLL");
    137         if (hmod)
    138         {
    139             PFNCREATESYMBOLICLINKW pfn = (PFNCREATESYMBOLICLINKW)GetProcAddress(hmod, "CreateSymbolicLinkW");
    140             if (pfn)
    141                 s_pfnCreateSymbolicLinkW = pfn;
    142         }
     137        PFNCREATESYMBOLICLINKW pfn = (PFNCREATESYMBOLICLINKW)GetProcAddress(g_hModKernel32, "CreateSymbolicLinkW");
     138        if (pfn)
     139            s_pfnCreateSymbolicLinkW = pfn;
    143140        s_fTried = true;
    144141    }
  • trunk/src/VBox/Runtime/r3/win/thread-win.cpp

    r37733 r46593  
    6969
    7070
     71DECLHIDDEN(void) rtThreadNativeReInitObtrusive(void)
     72{
     73    /* nothing to do here. */
     74}
     75
     76
    7177DECLHIDDEN(void) rtThreadNativeDetach(void)
    7278{
  • trunk/src/libs/libxml2-2.6.31/Makefile.kmk

    r41477 r46593  
    6565        xmlreader.c \
    6666        xmlregexp.c \
    67         xmlmodule.c \
    6867        xmlsave.c \
    6968        xmlschemas.c \
     
    7574        xmlstring.c
    7675
     76# xmlmodule.c - not compiling this.
     77
    7778# For linking:
    7879# VBox-libxml2_LDFLAGS.win    = /VERSION:$(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION)
  • trunk/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcLog.cpp

    r46431 r46593  
    106106#ifdef VBOX
    107107    // initialize VBox Runtime
    108     RTR3InitDll(0);
     108    RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    109109
    110110    PL_strncpyz(ipcLogPrefix, prefix, sizeof(ipcLogPrefix));
  • trunk/src/libs/xpcom18a4/java/src/nsJavaInterfaces.cpp

    r46478 r46593  
    147147{
    148148#if defined(VBOX_PATH_APP_PRIVATE_ARCH) && defined(VBOX_PATH_SHARED_LIBS)
    149     rv = RTR3InitDll(0);
     149    rv = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    150150#else
    151151    const char *pszHome  = nsnull;
     
    175175      memcpy(pszExePath, pszHome, cchHome);
    176176      memcpy(pszExePath + cchHome, "/javafake", sizeof("/javafake"));
    177       rv = RTR3InitEx(RTR3INIT_VER_CUR, RTR3INIT_FLAGS_DLL, 0, NULL, pszExePath);
     177      rv = RTR3InitEx(RTR3INIT_VER_CUR, RTR3INIT_FLAGS_DLL | RTR3INIT_FLAGS_UNOBTRUSIVE, 0, NULL, pszExePath);
    178178    } else {
    179       rv = RTR3InitDll(0);
     179      rv = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    180180    }
    181181
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/io/prlog.c

    r38636 r46593  
    424424    if (strcmp(file, "IPRT") == 0) {
    425425        /* initialize VBox Runtime */
    426         RTR3InitDll(0);
     426        RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    427427        newLogFile = IPRT_DEBUG_FILE;
    428428    }
     
    465465    if (strcmp(file, "IPRT") == 0) {
    466466        /* initialize VBox Runtime */
    467         RTR3InitDll(0);
     467        RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    468468        logFile = IPRT_DEBUG_FILE;
    469469        return PR_TRUE;
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prinit.c

    r39817 r46593  
    177177    _pr_initialized = PR_TRUE;
    178178#ifdef VBOX_USE_IPRT_IN_NSPR
    179     RTR3InitDll(0);
     179    RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    180180#endif
    181181#ifdef _PR_ZONE_ALLOCATOR
  • trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp

    r39719 r46593  
    801801
    802802#if defined(VBOX_PATH_APP_PRIVATE_ARCH) && defined(VBOX_PATH_SHARED_LIBS)
    803     rc = RTR3InitDll(0);
     803    rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    804804#else
    805805    const char *home = getenv("VBOX_PROGRAM_PATH");
     
    809809      memcpy(exepath, home, len);
    810810      memcpy(exepath + len, "/pythonfake", sizeof("/pythonfake"));
    811       rc = RTR3InitEx(RTR3INIT_VER_CUR, RTR3INIT_FLAGS_DLL, 0, NULL, exepath);
     811      rc = RTR3InitEx(RTR3INIT_VER_CUR, RTR3INIT_FLAGS_DLL | RTR3INIT_FLAGS_UNOBTRUSIVE, 0, NULL, exepath);
    812812    } else {
    813       rc = RTR3InitDll(0);
     813      rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    814814    }
    815815#endif
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette