- Timestamp:
- Dec 20, 2019 9:22:17 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 135514
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/VBoxGuestInstallHelper.cpp
r82626 r82627 221 221 222 222 /** 223 * Loads a system DLL.224 *225 * @returns Module handle or NULL226 * @param pszName The DLL name.227 */228 static HMODULE loadSystemDll(const char *pszName)229 {230 char szPath[MAX_PATH];231 UINT cchPath = GetSystemDirectoryA(szPath, sizeof(szPath));232 size_t cbName = strlen(pszName) + 1;233 if (cchPath + 1 + cbName > sizeof(szPath))234 return NULL;235 szPath[cchPath] = '\\';236 memcpy(&szPath[cchPath + 1], pszName, cbName);237 return LoadLibraryA(szPath);238 }239 240 /**241 223 * Disables the Windows File Protection for a specified file 242 224 * using an undocumented SFC API call. Don't try this at home! … … 259 241 if (RT_SUCCESS(rc)) 260 242 { 261 HMODULE hSFC = loadSystemDll("sfc_os.dll"); /** @todo Replace this by RTLdr APIs. */ 262 if (NULL != hSFC) 263 { 264 g_pfnSfcFileException = (PFNSFCFILEEXCEPTION)GetProcAddress(hSFC, "SfcFileException"); 265 if (g_pfnSfcFileException == NULL) 243 HMODULE hSFCNative = NULL; /* Native fallback. */ 244 245 RTLDRMOD hSFC; 246 rc = RTLdrLoadSystem("sfc_os.dll", true /* fNoUnload */, &hSFC); 247 if (RT_SUCCESS(rc)) 248 { 249 rc = RTLdrGetSymbol(hSFC, "SfcFileException", (void **)&g_pfnSfcFileException); 250 if (RT_FAILURE(rc)) 266 251 { 252 hSFCNative = (HMODULE)RTLdrGetNativeHandle(hSFC); 253 267 254 /* If we didn't get the proc address with the call above, try it harder with 268 * the (zero based) index of the function list . */269 g_pfnSfcFileException = (PFNSFCFILEEXCEPTION)GetProcAddress(hSFC , (LPCSTR)5);270 if (g_pfnSfcFileException == NULL)271 rc = V ERR_SYMBOL_NOT_FOUND;255 * the (zero based) index of the function list (ordinal). */ 256 g_pfnSfcFileException = (PFNSFCFILEEXCEPTION)GetProcAddress(hSFCNative, (LPCSTR)5); 257 if (g_pfnSfcFileException) 258 rc = VINF_SUCCESS; 272 259 } 273 } 274 else275 rc = VERR_FILE_NOT_FOUND;260 261 RTLdrClose(hSFC); 262 } 276 263 277 264 if (RT_SUCCESS(rc)) … … 283 270 { 284 271 #else 285 TCHAR *pwszFile = szFile;272 TCHAR *pwszFile = szFile; 286 273 #endif 287 274 if (g_pfnSfcFileException(0, pwszFile, UINT32_MAX) != 0) … … 293 280 } 294 281 295 if (hSFC )296 FreeLibrary(hSFC );282 if (hSFCNative) 283 FreeLibrary(hSFCNative); 297 284 } 298 285
Note:
See TracChangeset
for help on using the changeset viewer.