Changeset 84735 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Jun 9, 2020 10:47:05 AM (5 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Installer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/VBoxGuestInstallHelper.cpp
r84057 r84735 188 188 } 189 189 190 #ifndef UNICODE191 static void vboxChar2WCharFree(PWCHAR pwString)192 {193 if (pwString)194 HeapFree(GetProcessHeap(), 0, pwString);195 }196 197 static int vboxChar2WCharAlloc(const TCHAR *pszString, PWCHAR *ppwString)198 {199 int rc = VINF_SUCCESS;200 201 int iLen = (int)_tcslen(pszString) + 2;202 WCHAR *pwString = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, iLen * sizeof(WCHAR));203 if (!pwString)204 {205 rc = VERR_NO_MEMORY;206 }207 else208 {209 if (MultiByteToWideChar(CP_ACP, 0, pszString, -1, pwString, iLen) == 0)210 {211 rc = VERR_INVALID_PARAMETER;212 HeapFree(GetProcessHeap(), 0, pwString);213 }214 else215 {216 *ppwString = pwString;217 }218 }219 return rc;220 }221 #endif /* !UNICODE */222 223 /**224 * Disables the Windows File Protection for a specified file225 * using an undocumented SFC API call. Don't try this at home!226 *227 * @param hwndParent Window handle of parent.228 * @param string_size Size of variable string.229 * @param variables The actual variable string.230 * @param stacktop Pointer to a pointer to the current stack.231 * @param extra Extra parameters. Currently unused.232 */233 VBOXINSTALLHELPER_EXPORT DisableWFP(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop,234 extra_parameters *extra)235 {236 RT_NOREF(hwndParent, extra);237 238 EXDLL_INIT();239 240 TCHAR szFile[MAX_PATH + 1];241 int rc = vboxPopString(szFile, sizeof(szFile) / sizeof(TCHAR));242 if (RT_SUCCESS(rc))243 {244 RTLDRMOD hSFC;245 rc = RTLdrLoadSystem("sfc_os.dll", false /* fNoUnload */, &hSFC);246 if (RT_SUCCESS(rc))247 {248 PFNSFCFILEEXCEPTION pfnSfcFileException = NULL;249 rc = RTLdrGetSymbol(hSFC, "SfcFileException", (void **)&pfnSfcFileException);250 if (RT_FAILURE(rc))251 {252 /* Native fallback. */253 HMODULE hSFCNative = (HMODULE)RTLdrGetNativeHandle(hSFC);254 255 /* If we didn't get the proc address with the call above, try it harder with256 * the (zero based) index of the function list (ordinal). */257 pfnSfcFileException = (PFNSFCFILEEXCEPTION)GetProcAddress(hSFCNative, (LPCSTR)5);258 if (pfnSfcFileException)259 rc = VINF_SUCCESS;260 }261 262 if (RT_SUCCESS(rc))263 {264 #ifndef UNICODE265 WCHAR *pwszFile;266 rc = vboxChar2WCharAlloc(szFile, &pwszFile);267 if (RT_SUCCESS(rc))268 {269 #else270 TCHAR *pwszFile = szFile;271 #endif272 if (pfnSfcFileException(0, pwszFile, UINT32_MAX) != 0)273 rc = VERR_ACCESS_DENIED; /** @todo Find a better rc. */274 #ifndef UNICODE275 vboxChar2WCharFree(pwszFile);276 }277 #endif278 }279 280 RTLdrClose(hSFC);281 }282 }283 284 vboxPushRcAsString(rc);285 }286 190 287 191 /** -
trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsCommon.nsh
r84433 r84735 789 789 !define InstallFileVerify "!insertmacro InstallFileVerify" 790 790 791 ; Prepares the access rights for replacing792 ; a WRP (Windows Resource Protection) protected file793 !macro PrepareWRPFile un794 Function ${un}PrepareWRPFile795 796 Pop $0797 Push $1798 799 ${IfNot} ${FileExists} "$0"800 ${LogVerbose} "WRP: File $\"$0$\" does not exist, skipping"801 Return802 ${EndIf}803 804 ${Switch} $g_strWinVersion805 ${Case} "NT4"806 ${Case} "2000"807 ${Case} "XP"808 ${LogVerbose} "WRP: changing ownership or permissions is not required on NT4, 2000, XP."809 ${Break}810 ${Default}811 ${CmdExecute} "$\"$g_strSystemDir\takeown.exe$\" /A /F $\"$0$\"" "true"812 Pop $1813 ${LogVerbose} "WRP: Changing ownership for $\"$0$\" returned: $1"814 815 ${CmdExecute} "icacls.exe $\"$0$\" /grant *S-1-5-32-544:F" "true"816 Pop $1817 ${LogVerbose} "WRP: Changing DACL for $\"$0$\" returned: $1"818 819 Sleep 1000 ; TrustedInstaller needs some time to forget about the file820 ${EndSwitch}821 822 !if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1"823 !ifdef WFP_FILE_EXCEPTION824 VBoxGuestInstallHelper::DisableWFP "$0"825 Pop $1 ; Get return value (ignored for now)826 ${LogVerbose} "WRP: Setting WFP exception for $\"$0$\" returned: $1"827 !endif828 !endif829 830 Pop $1831 832 FunctionEnd833 !macroend834 !insertmacro PrepareWRPFile ""835 !insertmacro PrepareWRPFile "un."836 837 ;838 ; Macro for preparing the access rights for replacing839 ; a WRP (Windows Resource Protection) protected file.840 ; @return None.841 ; @param Path of file to prepare.842 ;843 !macro PrepareWRPFileEx un FileSrc844 Push $0845 Push "${FileSrc}"846 Call ${un}PrepareWRPFile847 Pop $0848 !macroend849 !define PrepareWRPFileEx "!insertmacro PrepareWRPFileEx"850 791 851 792 ; Note: We don't ship modified Direct3D files anymore, but we need to (try to) … … 879 820 ${LogVerbose} "Restoring original D3D files ..." 880 821 !if $%BUILD_TARGET_ARCH% == "x86" 881 ${PrepareWRPFileEx} "${un}" "$SYSDIR\d3d8.dll"882 822 ${CopyFileEx} "${un}" "$SYSDIR\msd3d8.dll" "$SYSDIR\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%" 883 823 !endif 884 ${PrepareWRPFileEx} "${un}" "$SYSDIR\d3d9.dll"885 824 ${CopyFileEx} "${un}" "$SYSDIR\msd3d9.dll" "$SYSDIR\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%" 886 825 887 826 ${If} $g_bCapDllCache == "true" 888 827 !if $%BUILD_TARGET_ARCH% == "x86" 889 ${PrepareWRPFileEx} "${un}" "$SYSDIR\dllcache\d3d8.dll"890 828 ${CopyFileEx} "${un}" "$SYSDIR\dllcache\msd3d8.dll" "$SYSDIR\dllcache\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%" 891 829 !endif 892 ${PrepareWRPFileEx} "${un}" "$SYSDIR\dllcache\d3d9.dll"893 830 ${CopyFileEx} "${un}" "$SYSDIR\dllcache\msd3d9.dll" "$SYSDIR\dllcache\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%" 894 831 ${EndIf} 895 832 896 833 !if $%BUILD_TARGET_ARCH% == "amd64" 897 ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\d3d8.dll"898 834 ${CopyFileEx} "${un}" "$g_strSysWow64\msd3d8.dll" "$g_strSysWow64\d3d8.dll" "Microsoft Corporation" "x86" 899 ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\d3d9.dll"900 835 ${CopyFileEx} "${un}" "$g_strSysWow64\msd3d9.dll" "$g_strSysWow64\d3d9.dll" "Microsoft Corporation" "x86" 901 836 902 837 ${If} $g_bCapDllCache == "true" 903 ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\dllcache\d3d8.dll"904 838 ${CopyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d8.dll" "$g_strSysWow64\dllcache\d3d8.dll" "Microsoft Corporation" "x86" 905 ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\dllcache\d3d9.dll"906 839 ${CopyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d9.dll" "$g_strSysWow64\dllcache\d3d9.dll" "Microsoft Corporation" "x86" 907 840 ${EndIf}
Note:
See TracChangeset
for help on using the changeset viewer.