Changeset 46745 in vbox for trunk/src/VBox/Additions/WINNT
- Timestamp:
- Jun 23, 2013 6:22:49 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Installer/VBoxDrvInst.cpp
r46710 r46745 136 136 * 137 137 * @returns Module handle or NULL 138 * @param p szNameThe DLL name.138 * @param pwszName The DLL name. 139 139 */ 140 static HMODULE loadInstalledDll(const char *pszName) 141 { 142 char szPath[MAX_PATH]; 143 UINT cchPath = GetModuleFileNameA(NULL, szPath, sizeof(szPath)); 144 size_t cbName = strlen(pszName) + 1; 145 if (cchPath && cchPath <= sizeof(szPath)) 146 { 147 char *pszSlashFile = strrchr(szPath, '\\'); 148 if (pszSlashFile) 149 cchPath = pszSlashFile - szPath; 150 } 151 if (cchPath + 1 + cbName > sizeof(szPath)) 140 static HMODULE loadInstalledDll(const wchar_t *pwszName) 141 { 142 /* Get the process image path. */ 143 WCHAR wszPath[MAX_PATH]; 144 UINT cwcPath = GetModuleFileNameW(NULL, wszPath, MAX_PATH); 145 if (!cwcPath || cwcPath >= MAX_PATH) 152 146 return NULL; 153 szPath[cchPath] = '\\'; 154 memcpy(&szPath[cchPath + 1], pszName, cbName); 155 return LoadLibraryA(szPath); 147 148 /* Drop the image filename. */ 149 UINT off = cwcPath - 1; 150 for (;;) 151 { 152 if ( wszPath[off] == '\\' 153 || wszPath[off] == '/' 154 || wszPath[off] == ':') 155 { 156 wszPath[off] = '\0'; 157 cwcPath = off; 158 break; 159 } 160 if (!off--) 161 return NULL; /* No path? Shouldn't ever happen! */ 162 } 163 164 /* Check if there is room in the buffer to construct the desired name. */ 165 size_t cwcName = 0; 166 while (pwszName[cwcName]) 167 cwcName++; 168 if (cwcPath + 1 + cwcName + 1 > MAX_PATH) 169 return NULL; 170 171 wszPath[cwcPath] = '\\'; 172 memcpy(&wszPath[cwcPath + 1], pwszName, (cwcName + 1) * sizeof(wszPath[0])); 173 return LoadLibraryW(wszPath); 156 174 } 157 175 … … 170 188 { 171 189 HRESULT hr = S_OK; 172 HMODULE hDIFxAPI = loadInstalledDll( "DIFxAPI.dll");190 HMODULE hDIFxAPI = loadInstalledDll(L"DIFxAPI.dll"); 173 191 if (NULL == hDIFxAPI) 174 192 {
Note:
See TracChangeset
for help on using the changeset viewer.