Changeset 46593 in vbox
- Timestamp:
- Jun 17, 2013 2:32:51 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 86471
- Location:
- trunk
- Files:
-
- 2 added
- 55 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/ldr.h
r46273 r46593 195 195 * resolution of subsequently loaded libraries. */ 196 196 #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) 197 199 /** The mask of valid flag bits. */ 198 #define RTLDRLOAD_FLAGS_VALID_MASK UINT32_C(0x0000000 1)200 #define RTLDRLOAD_FLAGS_VALID_MASK UINT32_C(0x00000003) 199 201 /** @} */ 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 */ 214 RTDECL(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 */ 224 RTDECL(void *) RTLdrGetSystemSymbol(const char *pszFilename, const char *pszSymbol); 200 225 201 226 /** … … 210 235 */ 211 236 RTDECL(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 */ 245 RTDECL(uintptr_t) RTLdrGetNativeHandle(RTLDRMOD hLdrMod); 246 212 247 213 248 /** … … 359 394 RTDECL(int) RTLdrGetSymbolEx(RTLDRMOD hLdrMod, const void *pvBits, RTLDRADDR BaseAddress, const char *pszSymbol, 360 395 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 */ 408 RTDECL(PFNRT) RTLdrGetFunction(RTLDRMOD hLdrMod, const char *pszSymbol); 361 409 362 410 /** -
trunk/include/iprt/mangling.h
r46567 r46593 632 632 # define RTLdrGetEndian RT_MANGLER(RTLdrGetEndian) 633 633 # define RTLdrGetFormat RT_MANGLER(RTLdrGetFormat) 634 # define RTLdrGetFunction RT_MANGLER(RTLdrGetFunction) 635 # define RTLdrGetNativeHandle RT_MANGLER(RTLdrGetNativeHandle) 634 636 # define RTLdrGetSuff RT_MANGLER(RTLdrGetSuff) 635 637 # define RTLdrGetSymbol RT_MANGLER(RTLdrGetSymbol) 636 638 # define RTLdrGetSymbolEx RT_MANGLER(RTLdrGetSymbolEx) 639 # define RTLdrGetSystemSymbol RT_MANGLER(RTLdrGetSystemSymbol) 637 640 # define RTLdrGetType RT_MANGLER(RTLdrGetType) 638 641 # define RTLdrIsLoadable RT_MANGLER(RTLdrIsLoadable) … … 642 645 # define RTLdrLoadAppPriv RT_MANGLER(RTLdrLoadAppPriv) 643 646 # define RTLdrLoadEx RT_MANGLER(RTLdrLoadEx) 647 # define RTLdrLoadSystem RT_MANGLER(RTLdrLoadSystem) 644 648 # define RTLdrOpen RT_MANGLER(RTLdrOpen) 645 649 # define RTLdrOpenInMemory RT_MANGLER(RTLdrOpenInMemory) -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.cpp
r44529 r46593 1800 1800 vboxVDbgVEHandlerRegister(); 1801 1801 #endif 1802 int rc = RTR3InitDll( 0);1802 int rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 1803 1803 AssertRC(rc); 1804 1804 if (RT_SUCCESS(rc)) -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3DIf.cpp
r44529 r46593 28 28 } 29 29 30 /** 31 * Loads a system DLL. 32 * 33 * @returns Module handle or NULL 34 * @param pszName The DLL name. 35 */ 36 static 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 } 30 50 31 51 HRESULT VBoxDispD3DOpen(VBOXDISPD3D *pD3D) 32 52 { 33 53 #ifdef VBOX_WDDM_WOW64 34 pD3D->hD3DLib = LoadLibraryW(L"VBoxD3D9wddm-x86.dll");54 pD3D->hD3DLib = loadSystemDll("VBoxD3D9wddm-x86.dll"); 35 55 #else 36 pD3D->hD3DLib = LoadLibraryW(L"VBoxD3D9wddm.dll");56 pD3D->hD3DLib = loadSystemDll("VBoxD3D9wddm.dll"); 37 57 #endif 38 58 if (!pD3D->hD3DLib) 39 59 { 40 60 DWORD winErr = GetLastError(); 41 WARN((__FUNCTION__": LoadLibrary Wfailed, winErr = (%d)", winErr));61 WARN((__FUNCTION__": LoadLibrary failed, winErr = (%d)", winErr)); 42 62 return E_FAIL; 43 63 } -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispKmt.cpp
r46172 r46593 23 23 #endif 24 24 25 /** 26 * Loads a system DLL. 27 * 28 * @returns Module handle or NULL 29 * @param pszName The DLL name. 30 */ 31 static 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 25 43 HRESULT vboxDispKmtCallbacksInit(PVBOXDISPKMT_CALLBACKS pCallbacks) 26 44 { … … 29 47 memset(pCallbacks, 0, sizeof (*pCallbacks)); 30 48 31 pCallbacks->hGdi32 = LoadLibraryW(L"gdi32.dll");49 pCallbacks->hGdi32 = loadSystemDll("gdi32.dll"); 32 50 if (pCallbacks->hGdi32 != NULL) 33 51 { -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxScreen.cpp
r44529 r46593 1 1 /* $Id$ */ 2 3 2 /** @file 4 3 * VBoxVideo Display D3D User mode dll … … 6 5 7 6 /* 8 * Copyright (C) 2011-201 2Oracle Corporation7 * Copyright (C) 2011-2013 Oracle Corporation 9 8 * 10 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 341 340 } 342 341 342 /** 343 * Loads a system DLL. 344 * 345 * @returns Module handle or NULL 346 * @param pszName The DLL name. 347 */ 348 static 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 343 360 //HRESULT vboxScreenMonInit(PVBOXSCREENMON pMon) 344 361 HRESULT vboxScreenMonInit() … … 351 368 pMon->LoData.ScreenLayout.EscapeHdr.escapeCode = VBOXESC_SCREENLAYOUT; 352 369 353 pMon->hGdi32 = LoadLibraryW(L"gdi32.dll");370 pMon->hGdi32 = loadSystemDll("gdi32.dll"); 354 371 if (pMon->hGdi32 != NULL) 355 372 { -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/switcher/sw_common.c
r44529 r46593 1 1 /* $Id$ */ 2 3 2 /** @file 4 3 * VBox D3D8/9 dll switcher … … 6 5 7 6 /* 8 * Copyright (C) 2009-201 2Oracle Corporation7 * Copyright (C) 2009-2013 Oracle Corporation 9 8 * 10 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 23 22 static char* gsBlackListDll[] = {"awt.dll", "wpfgfx_v0400.dll", "wpfgfx_v0300.dll", NULL}; 24 23 24 /** 25 * Loads a system DLL. 26 * 27 * @returns Module handle or NULL 28 * @param pszName The DLL name. 29 */ 30 static 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 25 42 /* Checks if 3D is enabled for VM and it works on host machine */ 26 43 BOOL isVBox3DEnabled(void) … … 31 48 32 49 #ifdef VBOX_WDDM_WOW64 33 hDLL = LoadLibrary("VBoxOGL-x86.dll");50 hDLL = loadSystemDll("VBoxOGL-x86.dll"); 34 51 #else 35 hDLL = LoadLibrary("VBoxOGL.dll");52 hDLL = loadSystemDll("VBoxOGL.dll"); 36 53 #endif 37 54 … … 66 83 int i; 67 84 68 69 85 if (!GetModuleFileName(NULL, name, 1000)) 86 return TRUE; 70 87 71 88 /*Extract filename*/ … … 108 125 109 126 if (isVBox3DEnabled() && checkOptions()) 110 {111 127 dllName = vboxName; 112 } else 113 { 128 else 114 129 dllName = msName; 115 }116 130 117 hDLL = LoadLibrary(dllName);131 hDLL = loadSystemDll(dllName); 118 132 FillD3DExports(hDLL); 119 133 } 134 -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/directx.c
r42499 r46593 5308 5308 } 5309 5309 5310 /** 5311 * Loads a system DLL. 5312 * 5313 * @returns Module handle or NULL 5314 * @param pszName The DLL name. 5315 */ 5316 static 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 5310 5328 static BOOL InitAdapters(IWineD3DImpl *This) 5311 5329 { … … 5323 5341 if(!mod_gl) { 5324 5342 #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) 5327 5345 BOOL (APIENTRY *pDrvValidateVersion)(DWORD) DECLSPEC_HIDDEN; 5328 # ifdef VBOX_WDDM_WOW645329 mod_gl = LoadLibraryA("VBoxOGL-x86.dll");5330 # else5331 mod_gl = LoadLibraryA("VBoxOGL.dll");5332 # endif5333 # else5334 mod_gl = LoadLibraryA("opengl32.dll");5335 # endif5346 # 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 5336 5354 if(!mod_gl) { 5337 5355 ERR("Can't load opengl32.dll!\n"); 5338 5356 goto nogl_adapter; 5339 5357 } 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) 5341 5359 /* init properly */ 5342 5360 pDrvValidateVersion = (void*)GetProcAddress(mod_gl, "DrvValidateVersion"); … … 5349 5367 goto nogl_adapter; 5350 5368 } 5351 # endif5369 # endif 5352 5370 #else 5353 # define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn);5371 # define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn); 5354 5372 /* To bypass the opengl32 thunks load wglGetProcAddress from gdi32 (glXGetProcAddress wrapper) instead of opengl32's */ 5355 5373 mod_gl = GetModuleHandleA("gdi32.dll"); -
trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/switcher/sw_common.c
r46521 r46593 1 1 /* $Id$ */ 2 3 2 /** @file 4 3 * VBox D3D8/9 dll switcher … … 6 5 7 6 /* 8 * Copyright (C) 2009 Oracle Corporation7 * Copyright (C) 2009-2013 Oracle Corporation 9 8 * 10 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 23 22 static char* gsBlackListDll[] = {"awt.dll", "wpfgfx_v0400.dll", "wpfgfx_v0300.dll", NULL}; 24 23 24 /** 25 * Loads a system DLL. 26 * 27 * @returns Module handle or NULL 28 * @param pszName The DLL name. 29 */ 30 static 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 25 42 /* Checks if 3D is enabled for VM and it works on host machine */ 26 43 BOOL isVBox3DEnabled(void) … … 31 48 32 49 #ifdef VBOX_WDDM_WOW64 33 hDLL = LoadLibrary("VBoxOGL-x86.dll");50 hDLL = loadSystemDll("VBoxOGL-x86.dll"); 34 51 #else 35 hDLL = LoadLibrary("VBoxOGL.dll");52 hDLL = loadSystemDll("VBoxOGL.dll"); 36 53 #endif 37 54 … … 108 125 109 126 if (isVBox3DEnabled() && checkOptions()) 110 {111 127 dllName = vboxName; 112 } else 113 { 128 else 114 129 dllName = msName; 115 }116 130 117 hDLL = LoadLibrary(dllName);131 hDLL = loadSystemDll(dllName); 118 132 FillD3DExports(hDLL); 119 133 } 134 -
trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/wined3d/directx.c
r46521 r46593 5121 5121 } 5122 5122 5123 /** 5124 * Loads a system DLL. 5125 * 5126 * @returns Module handle or NULL 5127 * @param pszName The DLL name. 5128 */ 5129 static 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 5123 5141 /* Do not call while under the GL lock. */ 5124 5142 static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal) … … 5142 5160 #ifdef USE_WIN32_OPENGL 5143 5161 { 5144 # ifndef VBOX5162 # ifndef VBOX 5145 5163 HMODULE mod_gl = GetModuleHandleA("opengl32.dll"); 5146 # else5164 # else 5147 5165 BOOL (APIENTRY *pDrvValidateVersion)(DWORD) DECLSPEC_HIDDEN; 5148 # ifdef VBOX_WDDM_WOW645149 HMODULE mod_gl = LoadLibraryA("VBoxOGL-x86.dll");5150 # else5151 HMODULE mod_gl = LoadLibraryA("VBoxOGL.dll");5152 # endif5166 # ifdef VBOX_WDDM_WOW64 5167 HMODULE mod_gl = loadSystemDll("VBoxOGL-x86.dll"); 5168 # else 5169 HMODULE mod_gl = loadSystemDll("VBoxOGL.dll"); 5170 # endif 5153 5171 if (!mod_gl) 5154 5172 { … … 5169 5187 } 5170 5188 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); 5172 5190 VBOX_GL_FUNCS_GEN 5173 # undef VBOX_USE_FUNC5174 # endif5175 # 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); 5176 5194 ALL_WGL_FUNCS 5177 # undef USE_GL_FUNC5195 # undef USE_GL_FUNC 5178 5196 gl_info->gl_ops.wgl.p_wglSwapBuffers = (void *)GetProcAddress(mod_gl, "wglSwapBuffers"); 5179 5197 } -
trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/VBoxGuestInstallHelper.cpp
r44529 r46593 197 197 198 198 /** 199 * Loads a system DLL. 200 * 201 * @returns Module handle or NULL 202 * @param pszName The DLL name. 203 */ 204 static 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 /** 199 217 * Disables the Windows File Protection for a specified file 200 218 * using an undocumented SFC API call. Don't try this at home! … … 214 232 if (SUCCEEDED(hr)) 215 233 { 216 HMODULE hSFC = LoadLibrary("sfc_os.dll");234 HMODULE hSFC = loadSystemDll("sfc_os.dll"); 217 235 if (NULL != hSFC) 218 236 { -
trunk/src/VBox/Additions/WINNT/Installer/VBoxDrvInst.cpp
r45938 r46593 130 130 if (pCallbackContext) 131 131 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 */ 140 static 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); 132 150 } 133 151 … … 146 164 { 147 165 HRESULT hr = S_OK; 148 HMODULE hDIFxAPI = LoadLibrary(_T("DIFxAPI.dll"));166 HMODULE hDIFxAPI = loadSystemDll("DIFxAPI.dll"); 149 167 if (NULL == hDIFxAPI) 150 168 { -
trunk/src/VBox/Additions/WINNT/SharedFolders/np/vboxmrxnp.cpp
r40295 r46593 1598 1598 { 1599 1599 case DLL_PROCESS_ATTACH: 1600 RTR3InitDll( 0);1600 RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 1601 1601 VbglR3Init(); 1602 1602 LogRel(("VBOXNP: DLL loaded.\n")); -
trunk/src/VBox/Additions/WINNT/VBoxCredProv/VBoxCredentialProvider.cpp
r46382 r46593 363 363 case DLL_PROCESS_ATTACH: 364 364 { 365 int rc = RTR3InitDll( 0 /* Flags */);365 int rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 366 366 if (RT_SUCCESS(rc)) 367 367 rc = VbglR3Init(); -
trunk/src/VBox/Additions/WINNT/VBoxGINA/VBoxGINA.cpp
r40768 r46593 20 20 #include <iprt/buildconfig.h> 21 21 #include <iprt/initterm.h> 22 #include <iprt/ldr.h> 22 23 23 24 #include <VBox/VBoxGuestLib.h> … … 83 84 case DLL_PROCESS_ATTACH: 84 85 { 85 RTR3InitDll( 0 /* Flags */);86 RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 86 87 VbglR3Init(); 87 88 … … 115 116 DWORD *pdwDllVersion) 116 117 { 117 HINSTANCE hDll;118 119 118 VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: dwWinlogonVersion: %ld\n", dwWinlogonVersion); 120 119 121 120 /* 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); 125 126 return FALSE; 126 127 } … … 129 130 * Now get the entry points of the MSGINA 130 131 */ 131 GWlxNegotiate = (PGWLXNEGOTIATE) GetProcAddress(hDll, "WlxNegotiate");132 GWlxNegotiate = (PGWLXNEGOTIATE)RTLdrGetFunction(hLdrMod, "WlxNegotiate"); 132 133 if (!GWlxNegotiate) 133 134 { … … 135 136 return FALSE; 136 137 } 137 GWlxInitialize = (PGWLXINITIALIZE) GetProcAddress(hDll, "WlxInitialize");138 GWlxInitialize = (PGWLXINITIALIZE)RTLdrGetFunction(hLdrMod, "WlxInitialize"); 138 139 if (!GWlxInitialize) 139 140 { … … 142 143 } 143 144 GWlxDisplaySASNotice = 144 (PGWLXDISPLAYSASNOTICE) GetProcAddress(hDll, "WlxDisplaySASNotice");145 (PGWLXDISPLAYSASNOTICE)RTLdrGetFunction(hLdrMod, "WlxDisplaySASNotice"); 145 146 if (!GWlxDisplaySASNotice) 146 147 { … … 149 150 } 150 151 GWlxLoggedOutSAS = 151 (PGWLXLOGGEDOUTSAS) GetProcAddress(hDll, "WlxLoggedOutSAS");152 (PGWLXLOGGEDOUTSAS)RTLdrGetFunction(hLdrMod, "WlxLoggedOutSAS"); 152 153 if (!GWlxLoggedOutSAS) 153 154 { … … 156 157 } 157 158 GWlxActivateUserShell = 158 (PGWLXACTIVATEUSERSHELL) GetProcAddress(hDll, "WlxActivateUserShell");159 (PGWLXACTIVATEUSERSHELL)RTLdrGetFunction(hLdrMod, "WlxActivateUserShell"); 159 160 if (!GWlxActivateUserShell) 160 161 { … … 163 164 } 164 165 GWlxLoggedOnSAS = 165 (PGWLXLOGGEDONSAS) GetProcAddress(hDll, "WlxLoggedOnSAS");166 (PGWLXLOGGEDONSAS)RTLdrGetFunction(hLdrMod, "WlxLoggedOnSAS"); 166 167 if (!GWlxLoggedOnSAS) 167 168 { … … 170 171 } 171 172 GWlxDisplayLockedNotice = 172 (PGWLXDISPLAYLOCKEDNOTICE) GetProcAddress(hDll, "WlxDisplayLockedNotice");173 (PGWLXDISPLAYLOCKEDNOTICE)RTLdrGetFunction(hLdrMod, "WlxDisplayLockedNotice"); 173 174 if (!GWlxDisplayLockedNotice) 174 175 { … … 176 177 return FALSE; 177 178 } 178 GWlxIsLockOk = (PGWLXISLOCKOK) GetProcAddress(hDll, "WlxIsLockOk");179 GWlxIsLockOk = (PGWLXISLOCKOK)RTLdrGetFunction(hLdrMod, "WlxIsLockOk"); 179 180 if (!GWlxIsLockOk) 180 181 { … … 183 184 } 184 185 GWlxWkstaLockedSAS = 185 (PGWLXWKSTALOCKEDSAS) GetProcAddress(hDll, "WlxWkstaLockedSAS");186 (PGWLXWKSTALOCKEDSAS)RTLdrGetFunction(hLdrMod, "WlxWkstaLockedSAS"); 186 187 if (!GWlxWkstaLockedSAS) 187 188 { … … 189 190 return FALSE; 190 191 } 191 GWlxIsLogoffOk = (PGWLXISLOGOFFOK) GetProcAddress(hDll, "WlxIsLogoffOk");192 GWlxIsLogoffOk = (PGWLXISLOGOFFOK)RTLdrGetFunction(hLdrMod, "WlxIsLogoffOk"); 192 193 if (!GWlxIsLogoffOk) 193 194 { … … 195 196 return FALSE; 196 197 } 197 GWlxLogoff = (PGWLXLOGOFF) GetProcAddress(hDll, "WlxLogoff");198 GWlxLogoff = (PGWLXLOGOFF)RTLdrGetFunction(hLdrMod, "WlxLogoff"); 198 199 if (!GWlxLogoff) 199 200 { … … 201 202 return FALSE; 202 203 } 203 GWlxShutdown = (PGWLXSHUTDOWN) GetProcAddress(hDll, "WlxShutdown");204 GWlxShutdown = (PGWLXSHUTDOWN)RTLdrGetFunction(hLdrMod, "WlxShutdown"); 204 205 if (!GWlxShutdown) 205 206 { … … 208 209 } 209 210 /* 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"); 212 213 /* 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"); 217 218 /* GINA 1.4, optional */ 218 219 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"); 222 223 VBoxGINAVerbose(0, "VBoxGINA::WlxNegotiate: optional function pointers:\n" 223 224 " WlxStartApplication: %p\n" -
trunk/src/VBox/Additions/WINNT/VBoxMMR/dllmain.cpp
r44864 r46593 45 45 if (isWMP) 46 46 { 47 RTR3InitDll( 0);47 RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 48 48 VbglR3Init(); 49 49 VBoxMMRHookLog("VBoxMMR: Hooking wmplayer process\n"); -
trunk/src/VBox/Additions/WINNT/VBoxMMR/tsmfhook.cpp
r44864 r46593 1343 1343 } 1344 1344 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); 1345 void 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()); 1353 1365 } 1354 1366 else 1355 {1356 1367 VBoxMMRHookLog("VBoxMMR: Error hooking %s -> not found\n", pszName); 1357 }1358 1368 } 1359 1369 … … 1382 1392 } 1383 1393 1384 InstallHooksFor Module("winmm.dll", g_WinMMHooks);1385 InstallHooksFor Module("tsmf.dll", g_TSMFHooks);1386 InstallHooksFor Module("DSHOWRDPFILTER.dll", g_TSMFHooks);1387 InstallHooksFor Module("MSMPEG2VDEC.dll", g_DShowHooks);1388 InstallHooksFor Module("MFDS.dll", g_DShowHooks);1389 InstallHooksFor Module("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); 1390 1400 1391 1401 ULONG ret = RegisterTraceGuids( -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxLA.cpp
r43584 r46593 27 27 #include <iprt/alloc.h> 28 28 #include <iprt/list.h> 29 #include <iprt/ldr.h> 29 30 30 31 #define LALOG(a) do { if (gCtx.fLogEnabled) LogRel(a); } while(0) … … 87 88 char *pszPropWaitPattern; /* Which properties are monitored. */ 88 89 } activeClient; 89 90 HMODULE hModuleKernel32;91 90 92 91 BOOL (WINAPI * pfnProcessIdToSessionId)(DWORD dwProcessId, DWORD *pSessionId); … … 1250 1249 RT_ZERO(gCtx.activeClient); 1251 1250 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"); 1262 1252 *pfStartThread = true; 1263 1253 *ppInstance = &gCtx; … … 1280 1270 ActionExecutorDeleteActions(&pCtx->listDetachActions); 1281 1271 1282 if (pCtx->hModuleKernel32) 1283 { 1284 FreeLibrary(pCtx->hModuleKernel32); 1285 pCtx->pfnProcessIdToSessionId = NULL; 1286 } 1287 pCtx->hModuleKernel32 = NULL; 1272 pCtx->pfnProcessIdToSessionId = NULL; 1288 1273 } 1289 1274 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxMMR.cpp
r42295 r46593 18 18 #include "VBoxTray.h" 19 19 #include "VBoxMMR.h" 20 #include <iprt/ldr.h> 20 21 21 22 struct VBOXMMRCONTEXT 22 23 { 23 HINSTANCE hMod;24 RTLDRMOD hModHook; 24 25 HHOOK hHook; 25 26 }; … … 32 33 void VBoxMMRCleanup(VBOXMMRCONTEXT *pCtx) 33 34 { 34 if ( NULL !=pCtx->hHook)35 if (pCtx->hHook) 35 36 { 36 37 UnhookWindowsHookEx(pCtx->hHook); 38 pCtx->hHook = NULL; 37 39 } 38 40 39 if (pCtx->hMod )41 if (pCtx->hModHook != NIL_RTLDRMOD) 40 42 { 41 FreeLibrary(pCtx->hMod); 43 RTLdrClose(pCtx->hModHook); 44 pCtx->hModHook = NIL_RTLDRMOD; 42 45 } 43 44 return;45 46 } 46 47 … … 50 51 bool *pfStartThread) 51 52 { 52 HOOKPROC pHook = NULL;53 54 53 LogRel2(("VBoxMMR: Initializing\n")); 55 54 56 gCtx.hMod = LoadLibraryA(g_pszMMRDLL);57 if ( NULL == gCtx.hMod)55 int rc = RTLdrLoadAppPriv(g_pszMMRDLL, &gCtx.hModHook); 56 if (RT_SUCCESS(rc)) 58 57 { 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 } 62 78 } 79 else 80 LogRel2(("VBoxMMR: Hooking library not found (%Rrc)\n", rc)); 63 81 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; 84 85 } 85 86 … … 95 96 return 0; 96 97 } 98 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxSeamless.cpp
r45760 r46593 25 25 #include <VBox/VMMDev.h> 26 26 #include <iprt/assert.h> 27 #include <iprt/ldr.h> 27 28 #include <VBoxGuestInternal.h> 28 29 … … 31 32 const VBOXSERVICEENV *pEnv; 32 33 33 HMODULE hModule;34 RTLDRMOD hModHook; 34 35 35 36 BOOL (* pfnVBoxHookInstallWindowTracker)(HMODULE hDll); … … 55 56 *pfStartThread = false; 56 57 gCtx.pEnv = pEnv; 58 gCtx.hModHook = NIL_RTLDRMOD; 57 59 58 60 OSVERSIONINFO OSinfo; … … 72 74 { 73 75 /* 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"); 79 81 80 82 /* rc should contain success status */ … … 90 92 } 91 93 else 92 {93 rc = RTErrConvertFromWin32(GetLastError());94 94 Log(("VBoxTray: VBoxSeamlessInit: LoadLibrary of \"%s\" failed with rc=%Rrc\n", VBOXHOOK_DLL_NAME, rc)); 95 }96 95 } 97 96 … … 109 108 if (gCtx.pfnVBoxHookRemoveWindowTracker) 110 109 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 } 114 115 return; 115 116 } … … 122 123 VBoxSeamlessCheckWindows(); 123 124 124 gCtx.pfnVBoxHookInstallWindowTracker(gCtx.hModule); 125 HMODULE hMod = (HMODULE)RTLdrGetNativeHandle(gCtx.hModHook); 126 Assert(hMod != (HMODULE)~(uintptr_t)0); 127 gCtx.pfnVBoxHookInstallWindowTracker(hMod); 125 128 } 126 129 } -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp
r46428 r46593 41 41 42 42 #include <iprt/buildconfig.h> 43 #include <iprt/ldr.h> 43 44 44 45 /* Default desktop state tracking */ … … 63 64 * of the window passed to vboxStInit */ 64 65 static int vboxStInit(HWND hWnd); 65 static void vboxStTerm( );66 static void vboxStTerm(void); 66 67 /* @returns true on "IsActiveConsole" state change */ 67 68 static BOOL vboxStHandleEvent(WPARAM EventID, LPARAM SessionID); … … 549 550 { 550 551 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) 559 556 { 560 557 PSECURITY_DESCRIPTOR pSD; … … 563 560 BOOL fSaclDefaulted = FALSE; 564 561 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) 569 565 { 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); 572 572 if (!fRC) 573 573 { 574 574 dwErr = GetLastError(); 575 Log(("VBoxTray: ConvertStringSecurityDescriptorToSecurityDescriptorAfailed with last error = %08X\n", dwErr));575 Log(("VBoxTray: GetSecurityDescriptorSacl failed with last error = %08X\n", dwErr)); 576 576 } 577 577 else 578 578 { 579 fRC = GetSecurityDescriptorSacl(pSD, &fSaclPresent, &pSacl, &fSaclDefaulted);579 fRC = SetSecurityDescriptorSacl(SecAttr.lpSecurityDescriptor, TRUE, pSacl, FALSE); 580 580 if (!fRC) 581 581 { 582 582 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)); 593 584 } 594 585 } … … 1015 1006 { 1016 1007 HWND hWTSAPIWnd; 1017 HMODULE hWTSAPI32;1008 RTLDRMOD hLdrModWTSAPI32; 1018 1009 BOOL fIsConsole; 1019 1010 WTS_CONNECTSTATE_CLASS enmConnectState; … … 1032 1023 USHORT *pProtocolType = NULL; 1033 1024 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)) 1037 1030 { 1038 1031 gVBoxSt.fIsConsole = (*pProtocolType == 0); … … 1040 1033 return VINF_SUCCESS; 1041 1034 } 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); 1048 1039 } 1049 1040 else … … 1063 1054 static int vboxStInit(HWND hWnd) 1064 1055 { 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 1073 1077 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)) 1092 1079 { 1093 1080 gVBoxSt.hWTSAPIWnd = hWnd; 1094 1081 if (gVBoxSt.pfnWTSRegisterSessionNotification(gVBoxSt.hWTSAPIWnd, NOTIFY_FOR_THIS_SESSION)) 1095 {1096 1082 vboxStCheckState(); 1097 }1098 1083 else 1099 1084 { … … 1102 1087 if (dwErr == RPC_S_INVALID_BINDING) 1103 1088 { 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); 1107 1091 gVBoxSt.fIsConsole = TRUE; 1108 1092 gVBoxSt.enmConnectState = WTSActive; 1093 rc = VINF_SUCCESS; 1109 1094 } 1110 1095 else … … 1116 1101 } 1117 1102 1118 FreeLibrary(gVBoxSt.hWTSAPI32);1103 RTLdrClose(gVBoxSt.hLdrModWTSAPI32); 1119 1104 } 1120 1105 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); 1128 1109 gVBoxSt.fIsConsole = TRUE; 1129 1110 gVBoxSt.enmConnectState = WTSActive; … … 1131 1112 } 1132 1113 1133 static void vboxStTerm( )1134 { 1135 if ( gVBoxSt.hWTSAPIWnd)1114 static void vboxStTerm(void) 1115 { 1116 if (!gVBoxSt.hWTSAPIWnd) 1136 1117 { 1137 1118 WARN(("VBoxTray: vboxStTerm called for non-initialized St\n")); … … 1154 1135 } 1155 1136 1156 FreeLibrary(gVBoxSt.hWTSAPI32);1157 memset(&gVBoxSt, 0, sizeof (gVBoxSt));1137 RTLdrClose(gVBoxSt.hLdrModWTSAPI32); 1138 RT_ZERO(gVBoxSt); 1158 1139 } 1159 1140 … … 1228 1209 BOOL fIsInputDesktop; 1229 1210 UINT_PTR idTimer; 1230 HMODULE hHookModule;1211 RTLDRMOD hLdrModHook; 1231 1212 BOOL (* pfnVBoxHookInstallActiveDesktopTracker)(HMODULE hDll); 1232 1213 BOOL (* pfnVBoxHookRemoveActiveDesktopTracker)(); 1233 HMODULE hUSER32;1234 1214 HDESK (WINAPI * pfnGetThreadDesktop)(DWORD dwThreadId); 1235 1215 HDESK (WINAPI * pfnOpenInputDesktop)(DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess); … … 1289 1269 } 1290 1270 1291 memset(&gVBoxDt, 0, sizeof (gVBoxDt));1271 RT_ZERO(gVBoxDt); 1292 1272 1293 1273 gVBoxDt.hNotifyEvent = CreateEvent(NULL, FALSE, FALSE, VBOXHOOK_GLOBAL_DT_EVENT_NAME); 1294 1274 if (gVBoxDt.hNotifyEvent != NULL) 1295 1275 { 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 1302 1290 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) 1317 1296 { 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) 1320 1320 { 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) 1344 1325 { 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)); 1368 1328 } 1369 1329 } 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 } 1371 1347 } 1372 1348 } 1373 1349 1374 FreeLibrary(gVBoxDt.hHookModule);1350 RTLdrClose(gVBoxDt.hLdrModHook); 1375 1351 } 1376 1352 else … … 1391 1367 1392 1368 1393 memset(&gVBoxDt, 0, sizeof (gVBoxDt));1369 RT_ZERO(gVBoxDt); 1394 1370 gVBoxDt.fIsInputDesktop = TRUE; 1395 1371 … … 1399 1375 static void vboxDtTerm() 1400 1376 { 1401 if (!gVBoxDt.h HookModule)1377 if (!gVBoxDt.hLdrModHook) 1402 1378 return; 1403 1379 1404 1380 gVBoxDt.pfnVBoxHookRemoveActiveDesktopTracker(); 1405 1381 1406 FreeLibrary(gVBoxDt.hUSER32); 1407 FreeLibrary(gVBoxDt.hHookModule); 1382 RTLdrClose(gVBoxDt.hLdrModHook); 1408 1383 CloseHandle(gVBoxDt.hNotifyEvent); 1409 1384 1410 memset(&gVBoxDt, 0, sizeof (gVBoxDt));1385 RT_ZERO(gVBoxDt); 1411 1386 } 1412 1387 /* @returns true on "IsInputDesktop" state change */ -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxVRDP.cpp
r33966 r46593 25 25 #include <VBoxGuestInternal.h> 26 26 #include <iprt/assert.h> 27 #include <iprt/ldr.h> 27 28 28 29 … … 256 257 BOOL fSavedThemeEnabled; 257 258 258 HMODULE hModule;259 RTLDRMOD hModUxTheme; 259 260 260 261 HRESULT (* pfnEnableTheming)(BOOL fEnable); … … 274 275 gCtx.fSavedThemeEnabled = FALSE; 275 276 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"); 282 282 } 283 283 else 284 284 { 285 gCtx.pfnEnableTheming = 0; 285 gCtx.hModUxTheme = NIL_RTLDRMOD; 286 gCtx.pfnEnableTheming = NULL; 287 gCtx.pfnIsThemeActive = NULL; 286 288 } 287 289 … … 297 299 VBOXVRDPCONTEXT *pCtx = (VBOXVRDPCONTEXT *)pInstance; 298 300 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 } 302 306 return; 303 307 } -
trunk/src/VBox/Additions/common/VBoxService/VBoxServicePageSharing.cpp
r44863 r46593 24 24 #include <iprt/asm.h> 25 25 #include <iprt/mem.h> 26 #include <iprt/ldr.h> 26 27 #include <iprt/process.h> 27 28 #include <iprt/env.h> … … 81 82 82 83 typedef NTSTATUS (WINAPI *PFNZWQUERYSYSTEMINFORMATION)(ULONG, PVOID, ULONG, PULONG); 83 static PFNZWQUERYSYSTEMINFORMATION ZwQuerySystemInformation = NULL; 84 static HMODULE hNtdll = 0; 84 static PFNZWQUERYSYSTEMINFORMATION g_pfnZwQuerySystemInformation = NULL; 85 85 86 86 … … 366 366 367 367 /* Check all loaded kernel modules. */ 368 if ( ZwQuerySystemInformation)368 if (g_pfnZwQuerySystemInformation) 369 369 { 370 370 ULONG cbBuffer = 0; … … 372 372 PRTL_PROCESS_MODULES pSystemModules; 373 373 374 NTSTATUS ret = ZwQuerySystemInformation(SystemModuleInformation, (PVOID)&cbBuffer, 0, &cbBuffer);374 NTSTATUS ret = g_pfnZwQuerySystemInformation(SystemModuleInformation, (PVOID)&cbBuffer, 0, &cbBuffer); 375 375 if (!cbBuffer) 376 376 { … … 383 383 goto skipkernelmodules; 384 384 385 ret = ZwQuerySystemInformation(SystemModuleInformation, pBuffer, cbBuffer, &cbBuffer);385 ret = g_pfnZwQuerySystemInformation(SystemModuleInformation, pBuffer, cbBuffer, &cbBuffer); 386 386 if (ret != STATUS_SUCCESS) 387 387 { … … 553 553 554 554 #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); 561 558 if (RT_FAILURE(rc)) 562 559 { … … 738 735 { 739 736 VBoxServiceVerbose(3, "VBoxServicePageSharingTerm\n"); 740 741 #if defined(RT_OS_WINDOWS) && !defined(TARGET_NT4)742 if (hNtdll)743 FreeLibrary(hNtdll);744 #endif745 return;746 737 } 747 738 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceStats.cpp
r44528 r46593 44 44 #include <iprt/assert.h> 45 45 #include <iprt/mem.h> 46 #include <iprt/ldr.h> 46 47 #include <VBox/param.h> 47 48 #include <iprt/semaphore.h> … … 124 125 125 126 #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; 140 136 } 141 137 142 138 /* 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 156 149 /* 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); 165 153 #endif /* RT_OS_WINDOWS */ 166 154 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp
r44884 r46593 169 169 /* Loading the module and getting the symbol for each and every process is expensive 170 170 * -- 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) 174 176 { 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; 185 184 } 186 185 } -
trunk/src/VBox/Additions/haiku/VBoxTray/VBoxGuestDeskbarView.cpp
r43407 r46593 261 261 } 262 262 263 int rc = RTR3InitDll( 0);263 int rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 264 264 if (RT_SUCCESS(rc)) 265 265 { -
trunk/src/VBox/Debugger/VBoxDbgStatsQt4.cpp
r44528 r46593 353 353 */ 354 354 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); 355 366 356 367 /** … … 1312 1323 1313 1324 1325 /*static*/ char * 1326 VBoxDbgStatsModel::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 1314 1335 /*static*/ bool 1315 1336 VBoxDbgStatsModel::isNodeAncestorOf(PCDBGGUISTATSNODE pAncestor, PCDBGGUISTATSNODE pDescendant) … … 1434 1455 VBoxDbgStatsModel::updateCallbackHandleOutOfOrder(const char *pszName) 1435 1456 { 1457 #if defined(VBOX_STRICT) || defined(LOG_ENABLED) 1458 char szStrict[1024]; 1459 #endif 1460 1436 1461 /* 1437 1462 * We might be inserting a new node between pPrev and pNode … … 1451 1476 PDBGGUISTATSNODE pNode = m_pUpdateParent->papChildren[m_iUpdateChild]; 1452 1477 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 1453 1483 pNode = pNode->pParent; 1454 1484 while (pNode != m_pRoot) … … 1459 1489 m_cchUpdateParent -= pNode->cchName + 1; 1460 1490 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__)); 1461 1492 pNode = pNode->pParent; 1462 1493 } … … 1470 1501 { 1471 1502 /* Find the end of this component. */ 1472 const char * const pszSubName = &pszName[m_cchUpdateParent];1503 const char * const pszSubName = &pszName[m_cchUpdateParent]; 1473 1504 const char *pszEnd = strchr(pszSubName, '/'); 1474 1505 if (!pszEnd) … … 1482 1513 m_szUpdateParent[m_cchUpdateParent] = '\0'; 1483 1514 Assert(m_cchUpdateParent < sizeof(m_szUpdateParent)); 1515 Log2(("updateCallbackHandleOutOfOrder: m_szUpdateParent='%s' m_cchUpdateParent=%u (%u)\n", m_szUpdateParent, m_cchUpdateParent, __LINE__)); 1484 1516 1485 1517 if (!pNode->cChildren) … … 1571 1603 m_pUpdateParent = pNode->pParent; 1572 1604 m_iUpdateChild = pNode->iSelf; 1605 Log2(("updateCallbackHandleOutOfOrder: m_szUpdateParent='%s' m_cchUpdateParent=%u (%u)\n", m_szUpdateParent, m_cchUpdateParent, __LINE__)); 1573 1606 1574 1607 return pNode; -
trunk/src/VBox/Devices/Network/slirp/ip_icmp.c
r44528 r46593 57 57 #include "ip_icmp.h" 58 58 #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> 61 62 #endif 62 63 … … 116 117 fd_nonblock(pData->icmp_socket.s); 117 118 NSOCK_INC(); 119 118 120 #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)) 129 126 { 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); 131 133 } 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 } 134 148 if (pData->pfIcmpParseReplies == NULL) 135 149 { 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 {151 150 LogRel(("NAT: Can't find IcmpParseReplies symbol\n")); 152 FreeLibrary(pData->hmIcmpLibrary);153 151 return 1; 154 152 } … … 156 154 { 157 155 LogRel(("NAT: Can't find IcmpCloseHandle symbol\n")); 158 FreeLibrary(pData->hmIcmpLibrary);159 156 return 1; 160 157 } 158 161 159 pData->icmp_socket.sh = IcmpCreateFile(); 162 160 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); 165 163 #endif /* RT_OS_WINDOWS */ 164 166 165 LIST_INIT(&pData->icmp_msg_head); 167 166 return 0; … … 177 176 #ifdef RT_OS_WINDOWS 178 177 pData->pfIcmpCloseHandle(pData->icmp_socket.sh); 179 FreeLibrary(pData->hmIcmpLibrary);180 178 RTMemFree(pData->pvIcmpBuffer); 181 179 #else … … 529 527 &ipopt /*=RequestOptions*/, 530 528 pData->pvIcmpBuffer /*=ReplyBuffer*/, 531 pData-> szIcmpBuffer /*=ReplySize*/,529 pData->cbIcmpBuffer /*=ReplySize*/, 532 530 1 /*=Timeout in ms*/); 533 531 error = GetLastError(); … … 710 708 { 711 709 /* DEBUG : append message to ICMP packet */ 712 int message_len;710 size_t message_len; 713 711 message_len = strlen(message); 714 712 if (message_len > ICMP_MAXDATALEN) 715 713 message_len = ICMP_MAXDATALEN; 716 m_append(pData, m, message_len, message);714 m_append(pData, m, (int)message_len, message); 717 715 } 718 716 #else -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r41987 r46593 202 202 # ifdef RT_OS_WINDOWS 203 203 void *pvIcmpBuffer; 204 size_t szIcmpBuffer;205 /* Accordin MSDN specification IcmpParseReplies206 * function should be detected in runtime204 uint32_t cbIcmpBuffer; 205 /* According MSDN specification IcmpParseReplies 206 * function should be detected at runtime. 207 207 */ 208 208 long (WINAPI * pfIcmpParseReplies)(void *, long); 209 209 BOOL (WINAPI * pfIcmpCloseHandle)(HANDLE); 210 HMODULE hmIcmpLibrary;211 210 # endif 212 211 #if defined(RT_OS_WINDOWS) -
trunk/src/VBox/Devices/Network/slirp/socket.c
r45261 r46593 1479 1479 int size; 1480 1480 1481 len = pData->pfIcmpParseReplies(pData->pvIcmpBuffer, pData-> szIcmpBuffer);1481 len = pData->pfIcmpParseReplies(pData->pvIcmpBuffer, pData->cbIcmpBuffer); 1482 1482 if (len < 0) 1483 1483 { -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.cpp
r44529 r46593 1 1 /* $Id$ */ 2 2 /** @file 3 * 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * QILineEdit class implementation 3 * VirtualBox Qt GUI - QILineEdit class implementation. 6 4 */ 7 5 8 6 /* 9 * Copyright (C) 2008-201 0Oracle Corporation7 * Copyright (C) 2008-2013 Oracle Corporation 10 8 * 11 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 24 22 25 23 #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" 28 30 #endif 29 31 … … 62 64 /* Check if l&f style theme is really active else painting performed by 63 65 * 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); 68 73 } 69 74 #endif -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/cfg/VBoxNetCfg.cpp
r46386 r46593 2140 2140 2141 2141 2142 #define NETSHELL_LIBRARY _T("netshell.dll")2143 2144 2142 /** 2145 2143 * Use the IShellFolder API to rename the connection. … … 2187 2185 2188 2186 return hr; 2187 } 2188 2189 /** 2190 * Loads a system DLL. 2191 * 2192 * @returns Module handle or NULL 2193 * @param pszName The DLL name. 2194 */ 2195 static 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); 2189 2205 } 2190 2206 … … 2209 2225 if (FAILED(status)) 2210 2226 return E_FAIL; 2211 hNetShell = LoadLibrary (NETSHELL_LIBRARY);2227 hNetShell = loadSystemDll("netshell.dll"); 2212 2228 if (hNetShell == NULL) 2213 2229 return E_FAIL; -
trunk/src/VBox/Main/src-client/win/dllmain.cpp
r44528 r46593 46 46 47 47 // idempotent, so doesn't harm, and needed for COM embedding scenario 48 RTR3InitDll( 0);48 RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 49 49 } 50 50 else if (dwReason == DLL_PROCESS_DETACH) -
trunk/src/VBox/Main/src-server/win/PerformanceWin.cpp
r46460 r46593 34 34 35 35 #include <iprt/err.h> 36 #include <iprt/ldr.h> 36 37 #include <iprt/mp.h> 37 38 #include <iprt/mem.h> … … 87 88 PFNGST mpfnGetSystemTimes; 88 89 PFNNQSI mpfnNtQuerySystemInformation; 89 HMODULE mhNtDll;90 90 91 91 ULONG totalRAM; … … 97 97 } 98 98 99 CollectorWin::CollectorWin() : CollectorHAL(), m hNtDll(0)100 { 101 mpfnGetSystemTimes = (PFNGST)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")),102 99 CollectorWin::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"); 103 103 if (!mpfnGetSystemTimes) 104 104 { 105 105 /* 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())); 120 110 } 121 111 … … 130 120 CollectorWin::~CollectorWin() 131 121 { 132 if (mhNtDll)133 FreeLibrary(mhNtDll);134 122 } 135 123 -
trunk/src/VBox/Runtime/Makefile.kmk
r46570 r46593 595 595 r3/win/fileio-win.cpp \ 596 596 r3/win/fs-win.cpp \ 597 r3/win/init-win.cpp \ 597 598 r3/win/ldrNative-win.cpp \ 598 599 r3/win/localipc-win.cpp \ -
trunk/src/VBox/Runtime/VBox/VBoxRTDeps.cpp
r41117 r46593 36 36 #include <iprt/system.h> 37 37 38 #include <libxml/ xmlmodule.h>38 #include <libxml/catalog.h> 39 39 #include <libxml/globals.h> 40 40 #include <openssl/md5.h> … … 58 58 (PFNRT)SUPTracerFireProbe, 59 59 #endif 60 (PFNRT)xml ModuleOpen,60 (PFNRT)xmlLoadCatalogs, 61 61 (PFNRT)MD5_Init, 62 62 (PFNRT)RC4, -
trunk/src/VBox/Runtime/common/ldr/ldr.cpp
r46164 r46593 94 94 95 95 96 RTDECL(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 } 104 RT_EXPORT_SYMBOL(RTLdrGetFunction); 105 106 96 107 RTDECL(RTLDRFMT) RTLdrGetFormat(RTLDRMOD hLdrMod) 97 108 { -
trunk/src/VBox/Runtime/common/ldr/ldrNative.cpp
r46164 r46593 5 5 6 6 /* 7 * Copyright (C) 2006-201 1Oracle Corporation7 * Copyright (C) 2006-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 63 63 * Operations for a native module. 64 64 */ 65 static const RTLDROPS s_rtldrNativeOps =65 static const RTLDROPS g_rtldrNativeOps = 66 66 { 67 67 "native", … … 131 131 pMod->Core.u32Magic = RTLDRMOD_MAGIC; 132 132 pMod->Core.eState = LDR_STATE_LOADED; 133 pMod->Core.pOps = & s_rtldrNativeOps;133 pMod->Core.pOps = &g_rtldrNativeOps; 134 134 pMod->Core.pReader = NULL; 135 135 pMod->Core.enmFormat = RTLDRFMT_NATIVE; … … 148 148 #endif 149 149 pMod->hNative = ~(uintptr_t)0; 150 pMod->fFlags = fFlags; 150 151 151 152 /* … … 171 172 172 173 174 RTDECL(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 206 RTDECL(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 173 222 /** 174 223 * Loads a dynamic load library (/shared object) image file residing in the … … 258 307 RT_EXPORT_SYMBOL(RTLdrGetSuff); 259 308 309 310 RTDECL(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 } 318 RT_EXPORT_SYMBOL(RTLdrGetNativeHandle); 319 -
trunk/src/VBox/Runtime/common/misc/thread.cpp
r44528 r46593 184 184 return rc; 185 185 } 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 */ 195 DECLHIDDEN(void) rtThreadReInitObtrusive(void) 196 { 197 rtThreadNativeReInitObtrusive(); 198 } 199 #endif 186 200 187 201 -
trunk/src/VBox/Runtime/include/internal/ldr.h
r46164 r46593 459 459 /** The native handle. */ 460 460 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. */ 465 typedef RTLDRMODNATIVE *PRTLDRMODNATIVE; 462 466 463 467 /** @copydoc RTLDROPS::pfnGetSymbol */ … … 472 476 * @param pszFilename The image filename. 473 477 * @param phHandle Where to store the module handle on success. 474 * @param fFlags See RTLDRFLAGS_.478 * @param fFlags RTLDRLOAD_FLAGS_XXX. 475 479 * @param pErrInfo Where to return extended error information. Optional. 476 480 */ 477 481 int 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 */ 492 int rtldrNativeLoadSystem(const char *pszFilename, const char *pszExt, uint32_t fFlags, PRTLDRMOD phLdrMod); 478 493 479 494 int rtldrPEOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offNtHdrs, PRTLDRMOD phLdrMod); -
trunk/src/VBox/Runtime/include/internal/thread.h
r44528 r46593 140 140 DECLHIDDEN(int) rtThreadNativeInit(void); 141 141 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 */ 149 DECLHIDDEN(void) rtThreadNativeReInitObtrusive(void); 150 #endif 151 142 152 /** 143 153 * Create a native thread. … … 200 210 DECLHIDDEN(PRTTHREADINT) rtThreadGet(RTTHREAD Thread); 201 211 DECLHIDDEN(int) rtThreadInit(void); 212 #ifdef IN_RING3 213 DECLHIDDEN(void) rtThreadReInitObtrusive(void); 214 #endif 202 215 DECLHIDDEN(void) rtThreadTerm(void); 203 216 DECLHIDDEN(void) rtThreadInsert(PRTTHREADINT pThread, RTNATIVETHREAD NativeThread); -
trunk/src/VBox/Runtime/r3/init.cpp
r45375 r46593 67 67 #include <stdlib.h> 68 68 69 #include "init.h" 69 70 #include "internal/alignmentchecks.h" 70 71 #include "internal/path.h" 71 72 #include "internal/process.h" 72 #include "internal/thread.h"73 73 #include "internal/thread.h" 74 74 #include "internal/time.h" … … 140 140 */ 141 141 RTDATADECL(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 */ 148 DECLHIDDEN(int) rtR3InitNativeFirst(uint32_t fFlags) { return VINF_SUCCESS; } 149 DECLHIDDEN(int) rtR3InitNativeFinal(uint32_t fFlags) { return VINF_SUCCESS; } 150 DECLHIDDEN(void) rtR3InitNativeObtrusive(void) { } 142 151 #endif 143 152 … … 351 360 { 352 361 /* 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 /* 353 375 * Init C runtime locale before we do anything that may end up converting 354 376 * paths or we'll end up using the "C" locale for path conversion. … … 366 388 367 389 /* 368 * Disable error popups.369 */370 #ifdef RT_OS_WINDOWS371 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 #endif376 377 /*378 390 * Save the init flags. 379 391 */ … … 403 415 * without having initialized TLS entries and suchlike. 404 416 */ 405 intrc = rtThreadInit();417 rc = rtThreadInit(); 406 418 AssertMsgRCReturn(rc, ("Failed to initialize threads, rc=%Rrc!\n", rc), rc); 407 419 … … 505 517 #endif 506 518 519 /* 520 * Final native initialization. 521 */ 522 rc = rtR3InitNativeFinal(fFlags); 523 AssertMsgRCReturn(rc, ("rtR3InitNativeFinal failed with %Rrc\n", rc), rc); 524 507 525 return VINF_SUCCESS; 508 526 } … … 546 564 } 547 565 #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); 552 578 if (RT_SUCCESS(rc)) 553 579 rc = rtR3InitArgv(fFlags, cArgs, papszArgs); -
trunk/src/VBox/Runtime/r3/os2/thread-os2.cpp
r44528 r46593 79 79 80 80 81 DECLHIDDEN(int) rtThreadNativeAdopt(PRTTHREADINT pThread)81 static void rtThreadOs2BlockSigAlarm(void) 82 82 { 83 83 /* … … 90 90 sigaddset(&SigSet, SIGALRM); 91 91 sigprocmask(SIG_BLOCK, &SigSet, NULL); 92 } 93 94 95 DECLHIDDEN(void) rtThreadNativeReInitObtrusive(void) 96 { 97 rtThreadOs2BlockSigAlarm(); 98 } 99 100 101 DECLHIDDEN(int) rtThreadNativeAdopt(PRTTHREADINT pThread) 102 { 92 103 93 104 *g_ppCurThread = pThread; … … 108 119 static void rtThreadNativeMain(void *pvArgs) 109 120 { 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(); 119 122 120 123 /* -
trunk/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp
r44528 r46593 109 109 { 110 110 PRTLDRMODNATIVE pModNative = (PRTLDRMODNATIVE)pMod; 111 if (!dlclose((void *)pModNative->hNative)) 111 if ( (pModNative->fFlags & RTLDRLOAD_FLAGS_NO_UNLOAD) 112 || !dlclose((void *)pModNative->hNative)) 112 113 { 113 114 pModNative->hNative = (uintptr_t)0; … … 118 119 } 119 120 121 122 int 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 121 121 122 122 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 */ 127 static void rtThreadPosixSelectPokeSignal(void) 128 { 129 /* 130 * Note! Avoid SIGRTMIN thru SIGRTMIN+2 because of LinuxThreads. 137 131 */ 138 132 static const int s_aiSigCandidates[] = … … 179 173 } 180 174 } 175 } 181 176 #endif /* RTTHREAD_POSIX_WITH_POKE */ 177 178 179 DECLHIDDEN(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 182 192 183 193 #ifdef IPRT_MAY_HAVE_PTHREAD_SET_NAME_NP … … 188 198 } 189 199 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) 200 static void rtThreadPosixBlockSignals(void) 231 201 { 232 202 /* … … 246 216 siginterrupt(g_iSigPokeThread, 1); 247 217 #endif 218 } 219 220 DECLHIDDEN(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 */ 234 static 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 */ 255 static 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 */ 269 DECLHIDDEN(int) rtThreadNativeAdopt(PRTTHREADINT pThread) 270 { 271 rtThreadPosixBlockSignals(); 248 272 249 273 int rc = pthread_setspecific(g_SelfKey, pThread); … … 278 302 #endif 279 303 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(); 293 305 294 306 /* -
trunk/src/VBox/Runtime/r3/win/ldrNative-win.cpp
r46561 r46593 5 5 6 6 /* 7 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 32 32 33 33 #include <iprt/ldr.h> 34 #include "internal/iprt.h" 35 36 #include <iprt/alloca.h> 34 37 #include <iprt/assert.h> 38 #include <iprt/err.h> 39 #include <iprt/file.h> 35 40 #include <iprt/path.h> 36 #include <iprt/ err.h>37 #include <iprt/alloca.h> 41 #include <iprt/string.h> 42 38 43 #include <iprt/once.h> 39 44 #include <iprt/string.h> 40 45 #include "internal/ldr.h" 41 46 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 }60 47 61 48 int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo) 62 49 { 63 50 Assert(sizeof(*phHandle) >= sizeof(HMODULE)); 64 AssertReturn(fFlags == 0 , VERR_INVALID_PARAMETER);51 AssertReturn(fFlags == 0 || fFlags == RTLDRLOAD_FLAGS_NO_UNLOAD, VERR_INVALID_PARAMETER); 65 52 66 53 /* … … 79 66 80 67 /* 81 * Don't allow loading DLLs from the current directory.82 */83 #if 084 int rc = RTOnce(&g_Once, rtldrOnceSetDllDirectory, NULL);85 if (RT_FAILURE(rc))86 return rc;87 #else88 int rc = VINF_SUCCESS;89 #endif90 91 /*92 68 * Attempt load. 93 69 */ … … 103 79 */ 104 80 DWORD dwErr = GetLastError(); 105 rc = RTErrConvertFromWin32(dwErr);81 int rc = RTErrConvertFromWin32(dwErr); 106 82 return RTErrInfoSetF(pErrInfo, rc, "GetLastError=%u", dwErr); 107 83 } … … 125 101 { 126 102 PRTLDRMODNATIVE pModNative = (PRTLDRMODNATIVE)pMod; 127 if (FreeLibrary((HMODULE)pModNative->hNative)) 103 if ( (pModNative->fFlags & RTLDRLOAD_FLAGS_NO_UNLOAD) 104 || FreeLibrary((HMODULE)pModNative->hNative)) 128 105 { 129 106 pModNative->hNative = (uintptr_t)INVALID_HANDLE_VALUE; … … 133 110 } 134 111 112 113 int 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 58 58 #include <iprt/string.h> 59 59 #include <iprt/socket.h> 60 61 #include "../init.h" 60 62 61 63 … … 422 424 * Load PSAPI.DLL and resolve the two symbols we need. 423 425 */ 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) 427 428 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 } 431 456 if (RT_SUCCESS(rc)) 432 rc = RTLdrGetSymbol(hPsApi, "GetModuleBaseName", (void**)&pfnGetModuleBaseName);433 if (RT_SUCCESS(rc))434 457 { 435 458 /* 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. 438 463 */ 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++) 447 469 { 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++) 470 472 { 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) 473 475 { 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); 485 483 } 486 484 } 487 RTMemTmpFree(pszProcName);488 485 } 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 495 493 return fFound; 496 494 } … … 519 517 * and reliable. Fallback to EnumProcess on NT4. 520 518 */ 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++) 538 531 { 539 for (size_t i = 0; papszNames[i] && !fFound; i++) 532 PROCESSENTRY32 procEntry; 533 procEntry.dwSize = sizeof(PROCESSENTRY32); 534 if (pfnProcess32First(hSnap, &procEntry)) 540 535 { 541 PROCESSENTRY32 procEntry; 542 procEntry.dwSize = sizeof(PROCESSENTRY32); 543 if (pfnProcess32First(hSnap, &procEntry)) 536 do 544 537 { 545 do 538 if ( _stricmp(procEntry.szExeFile, papszNames[i]) == 0 539 && RT_SUCCESS(rtProcWinGetProcessTokenHandle(procEntry.th32ProcessID, pSid, phToken))) 546 540 { 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 } 555 546 #ifdef RT_STRICT 556 557 558 559 560 547 else 548 { 549 DWORD dwErr = GetLastError(); 550 AssertMsgFailed(("dwErr=%u (%x)\n", dwErr, dwErr)); 551 } 561 552 #endif 562 }563 CloseHandle(hSnap);564 553 } 565 else /* hSnap == INVALID_HANDLE_VALUE */ 566 rc = RTErrConvertFromWin32(GetLastError()); 567 } 568 RTLdrClose(hKernel32); 554 CloseHandle(hSnap); 555 } 569 556 } 570 557 571 558 /* If we couldn't take a process snapshot for some reason or another, fall 572 559 back on the NT4 compatible API. */ 573 if ( RT_FAILURE(rc))560 if (fFallback) 574 561 return rtProcWinFindTokenByProcessAndPsApi(papszNames, pSid, phToken); 575 562 return fFound; … … 689 676 { 690 677 RTLDRMOD hUserenv; 691 int rc = RTLdrLoad ("Userenv.dll", &hUserenv);678 int rc = RTLdrLoadSystem("Userenv.dll", true /*fNoUnload*/, &hUserenv); 692 679 if (RT_SUCCESS(rc)) 693 680 { … … 881 868 phToken = fFound ? &hTokenUserDesktop : &hTokenLogon; 882 869 RTLDRMOD hUserenv; 883 int rc = RTLdrLoad ("Userenv.dll", &hUserenv);870 int rc = RTLdrLoadSystem("Userenv.dll", true /*fNoUnload*/, &hUserenv); 884 871 if (RT_SUCCESS(rc)) 885 872 { … … 979 966 STARTUPINFOW *pStartupInfo, PROCESS_INFORMATION *pProcInfo, uint32_t fFlags) 980 967 { 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); 983 976 if (RT_SUCCESS(rc)) 984 977 { 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); 1017 998 } 1018 999 return rc; -
trunk/src/VBox/Runtime/r3/win/symlink-win.cpp
r44529 r46593 42 42 43 43 #include <Windows.h> 44 #include "../init.h" 44 45 45 46 … … 134 135 if (!s_fTried) 135 136 { 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; 143 140 s_fTried = true; 144 141 } -
trunk/src/VBox/Runtime/r3/win/thread-win.cpp
r37733 r46593 69 69 70 70 71 DECLHIDDEN(void) rtThreadNativeReInitObtrusive(void) 72 { 73 /* nothing to do here. */ 74 } 75 76 71 77 DECLHIDDEN(void) rtThreadNativeDetach(void) 72 78 { -
trunk/src/libs/libxml2-2.6.31/Makefile.kmk
r41477 r46593 65 65 xmlreader.c \ 66 66 xmlregexp.c \ 67 xmlmodule.c \68 67 xmlsave.c \ 69 68 xmlschemas.c \ … … 75 74 xmlstring.c 76 75 76 # xmlmodule.c - not compiling this. 77 77 78 # For linking: 78 79 # VBox-libxml2_LDFLAGS.win = /VERSION:$(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION) -
trunk/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcLog.cpp
r46431 r46593 106 106 #ifdef VBOX 107 107 // initialize VBox Runtime 108 RTR3InitDll( 0);108 RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 109 109 110 110 PL_strncpyz(ipcLogPrefix, prefix, sizeof(ipcLogPrefix)); -
trunk/src/libs/xpcom18a4/java/src/nsJavaInterfaces.cpp
r46478 r46593 147 147 { 148 148 #if defined(VBOX_PATH_APP_PRIVATE_ARCH) && defined(VBOX_PATH_SHARED_LIBS) 149 rv = RTR3InitDll( 0);149 rv = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 150 150 #else 151 151 const char *pszHome = nsnull; … … 175 175 memcpy(pszExePath, pszHome, cchHome); 176 176 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); 178 178 } else { 179 rv = RTR3InitDll( 0);179 rv = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 180 180 } 181 181 -
trunk/src/libs/xpcom18a4/nsprpub/pr/src/io/prlog.c
r38636 r46593 424 424 if (strcmp(file, "IPRT") == 0) { 425 425 /* initialize VBox Runtime */ 426 RTR3InitDll( 0);426 RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 427 427 newLogFile = IPRT_DEBUG_FILE; 428 428 } … … 465 465 if (strcmp(file, "IPRT") == 0) { 466 466 /* initialize VBox Runtime */ 467 RTR3InitDll( 0);467 RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 468 468 logFile = IPRT_DEBUG_FILE; 469 469 return PR_TRUE; -
trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prinit.c
r39817 r46593 177 177 _pr_initialized = PR_TRUE; 178 178 #ifdef VBOX_USE_IPRT_IN_NSPR 179 RTR3InitDll( 0);179 RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 180 180 #endif 181 181 #ifdef _PR_ZONE_ALLOCATOR -
trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp
r39719 r46593 801 801 802 802 #if defined(VBOX_PATH_APP_PRIVATE_ARCH) && defined(VBOX_PATH_SHARED_LIBS) 803 rc = RTR3InitDll( 0);803 rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 804 804 #else 805 805 const char *home = getenv("VBOX_PROGRAM_PATH"); … … 809 809 memcpy(exepath, home, len); 810 810 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); 812 812 } else { 813 rc = RTR3InitDll( 0);813 rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 814 814 } 815 815 #endif
Note:
See TracChangeset
for help on using the changeset viewer.