VirtualBox

Ignore:
Timestamp:
Jun 9, 2020 10:47:05 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
138525
Message:

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

File:
1 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/**
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