Changeset 46593 in vbox for trunk/src/VBox/Additions/WINNT
- Timestamp:
- Jun 17, 2013 2:32:51 PM (12 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.