VirtualBox

Changeset 84735 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Jun 9, 2020 10:47:05 AM (5 years ago)
Author:
vboxsync
Message:

Add/NT/Installer: WRP workaround is not needed any more, bugref:9725

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  
    188188}
    189189
    190 #ifndef UNICODE
    191 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     else
    208     {
    209         if (MultiByteToWideChar(CP_ACP, 0, pszString, -1, pwString, iLen) == 0)
    210         {
    211             rc = VERR_INVALID_PARAMETER;
    212             HeapFree(GetProcessHeap(), 0, pwString);
    213         }
    214         else
    215         {
    216             *ppwString = pwString;
    217         }
    218     }
    219     return rc;
    220 }
    221 #endif /* !UNICODE */
    222 
    223 /**
    224  * Disables the Windows File Protection for a specified file
    225  * 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 with
    256                  * 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 UNICODE
    265                 WCHAR *pwszFile;
    266                 rc = vboxChar2WCharAlloc(szFile, &pwszFile);
    267                 if (RT_SUCCESS(rc))
    268                 {
    269 #else
    270                     TCHAR *pwszFile = szFile;
    271 #endif
    272                     if (pfnSfcFileException(0, pwszFile, UINT32_MAX) != 0)
    273                         rc = VERR_ACCESS_DENIED; /** @todo Find a better rc. */
    274 #ifndef UNICODE
    275                     vboxChar2WCharFree(pwszFile);
    276                 }
    277 #endif
    278             }
    279 
    280             RTLdrClose(hSFC);
    281         }
    282     }
    283 
    284     vboxPushRcAsString(rc);
    285 }
    286190
    287191/**
  • trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsCommon.nsh

    r84433 r84735  
    789789!define InstallFileVerify "!insertmacro InstallFileVerify"
    790790
    791 ; Prepares the access rights for replacing
    792 ; a WRP (Windows Resource Protection) protected file
    793 !macro PrepareWRPFile un
    794 Function ${un}PrepareWRPFile
    795 
    796   Pop $0
    797   Push $1
    798 
    799   ${IfNot} ${FileExists} "$0"
    800     ${LogVerbose} "WRP: File $\"$0$\" does not exist, skipping"
    801     Return
    802   ${EndIf}
    803 
    804   ${Switch} $g_strWinVersion
    805     ${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 $1
    813       ${LogVerbose} "WRP: Changing ownership for $\"$0$\" returned: $1"
    814 
    815       ${CmdExecute} "icacls.exe $\"$0$\" /grant *S-1-5-32-544:F" "true"
    816       Pop $1
    817       ${LogVerbose} "WRP: Changing DACL for $\"$0$\" returned: $1"
    818 
    819       Sleep 1000 ; TrustedInstaller needs some time to forget about the file
    820   ${EndSwitch}
    821 
    822 !if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1"
    823   !ifdef WFP_FILE_EXCEPTION
    824     VBoxGuestInstallHelper::DisableWFP "$0"
    825     Pop $1 ; Get return value (ignored for now)
    826     ${LogVerbose} "WRP: Setting WFP exception for $\"$0$\" returned: $1"
    827   !endif
    828 !endif
    829 
    830   Pop $1
    831 
    832 FunctionEnd
    833 !macroend
    834 !insertmacro PrepareWRPFile ""
    835 !insertmacro PrepareWRPFile "un."
    836 
    837 ;
    838 ; Macro for preparing the access rights for replacing
    839 ; a WRP (Windows Resource Protection) protected file.
    840 ; @return  None.
    841 ; @param   Path of file to prepare.
    842 ;
    843 !macro PrepareWRPFileEx un FileSrc
    844   Push $0
    845   Push "${FileSrc}"
    846   Call ${un}PrepareWRPFile
    847   Pop $0
    848 !macroend
    849 !define PrepareWRPFileEx "!insertmacro PrepareWRPFileEx"
    850791
    851792; Note: We don't ship modified Direct3D files anymore, but we need to (try to)
     
    879820  ${LogVerbose} "Restoring original D3D files ..."
    880821!if $%BUILD_TARGET_ARCH% == "x86"
    881   ${PrepareWRPFileEx} "${un}" "$SYSDIR\d3d8.dll"
    882822  ${CopyFileEx} "${un}" "$SYSDIR\msd3d8.dll" "$SYSDIR\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
    883823!endif
    884   ${PrepareWRPFileEx} "${un}" "$SYSDIR\d3d9.dll"
    885824  ${CopyFileEx} "${un}" "$SYSDIR\msd3d9.dll" "$SYSDIR\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
    886825
    887826  ${If} $g_bCapDllCache == "true"
    888827!if $%BUILD_TARGET_ARCH% == "x86"
    889     ${PrepareWRPFileEx} "${un}" "$SYSDIR\dllcache\d3d8.dll"
    890828    ${CopyFileEx} "${un}" "$SYSDIR\dllcache\msd3d8.dll" "$SYSDIR\dllcache\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
    891829!endif
    892     ${PrepareWRPFileEx} "${un}" "$SYSDIR\dllcache\d3d9.dll"
    893830    ${CopyFileEx} "${un}" "$SYSDIR\dllcache\msd3d9.dll" "$SYSDIR\dllcache\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
    894831  ${EndIf}
    895832
    896833!if $%BUILD_TARGET_ARCH% == "amd64"
    897   ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\d3d8.dll"
    898834  ${CopyFileEx} "${un}" "$g_strSysWow64\msd3d8.dll" "$g_strSysWow64\d3d8.dll" "Microsoft Corporation" "x86"
    899   ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\d3d9.dll"
    900835  ${CopyFileEx} "${un}" "$g_strSysWow64\msd3d9.dll" "$g_strSysWow64\d3d9.dll" "Microsoft Corporation" "x86"
    901836
    902837  ${If} $g_bCapDllCache == "true"
    903     ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\dllcache\d3d8.dll"
    904838    ${CopyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d8.dll" "$g_strSysWow64\dllcache\d3d8.dll" "Microsoft Corporation" "x86"
    905     ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\dllcache\d3d9.dll"
    906839    ${CopyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d9.dll" "$g_strSysWow64\dllcache\d3d9.dll" "Microsoft Corporation" "x86"
    907840  ${EndIf}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette