VirtualBox

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


Ignore:
Timestamp:
Mar 29, 2011 11:37:01 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
70837
Message:

Windows Guest Additions installer: Try to replace WFP protected files on the fly.

Location:
trunk/src/VBox/Additions/WINNT/Installer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/VBoxGuestInstallHelper.cpp

    r35351 r36455  
    55
    66/*
    7  * Copyright (C) 2010 Oracle Corporation
     7 * Copyright (C) 2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2626HINSTANCE g_hInstance;
    2727HWND g_hwndParent;
     28
     29typedef DWORD (__stdcall *fnSfcFileException) (DWORD param1, PWCHAR param2, DWORD param3);
     30fnSfcFileException g_pfnSfcFileException = NULL;
    2831
    2932#define VBOXINSTALLHELPER_EXPORT extern "C" void __declspec(dllexport)
     
    181184}
    182185
     186/**
     187 * Disables the Windows File Protection for a specified file
     188 * using an undocumented SFC API call. Don't try this at home!
     189 *
     190 * @param   hwndParent          Window handle of parent.
     191 * @param   string_size         Size of variable string.
     192 * @param   variables           The actual variable string.
     193 * @param   stacktop            Pointer to a pointer to the current stack.
     194 */
     195VBOXINSTALLHELPER_EXPORT DisableWFP(HWND hwndParent, int string_size,
     196                                    TCHAR *variables, stack_t **stacktop)
     197{
     198    TCHAR szFile[MAX_PATH + 1];
     199    HRESULT hr = VBoxPopString(szFile, sizeof(szFile) / sizeof(TCHAR));
     200    if (SUCCEEDED(hr))
     201    {
     202        HMODULE hSFC = LoadLibrary("sfc_os.dll");
     203        if (NULL != hSFC)
     204        {
     205            g_pfnSfcFileException = (fnSfcFileException)GetProcAddress(hSFC, "SfcFileException");
     206            if (g_pfnSfcFileException == NULL)
     207            {
     208                /* If we didn't get the proc address with the call above, try it harder with
     209                 * the (zero based) index of the function list. */
     210                g_pfnSfcFileException = (fnSfcFileException)GetProcAddress(hSFC, (LPCSTR)5);
     211                if (g_pfnSfcFileException == NULL)
     212                    hr = HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND);
     213            }
     214        }
     215        else
     216            hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
     217
     218        if (SUCCEEDED(hr))
     219        {
     220            WCHAR wszFile[MAX_PATH + 1];
     221            hr = StringCchPrintfW(wszFile, sizeof(wszFile), L"%s", szFile);
     222            if (SUCCEEDED(hr))
     223                hr = HRESULT_FROM_WIN32(g_pfnSfcFileException(0, wszFile, -1));
     224        }
     225
     226        if (hSFC)
     227            FreeLibrary(hSFC);
     228    }
     229
     230    /* Push simple return value on stack. */
     231    SUCCEEDED(hr) ? pushstring("0") : pushstring("1");
     232}
     233
  • trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditions.nsi

    r36404 r36455  
    2727
    2828; Defines for special functions
    29 !define WHQL_FAKE    ; Turns on the faking of non WHQL signed / approved drivers
    30                      ; Needs the VBoxWHQLFake.exe in the additions output directory!
     29!define WHQL_FAKE                   ; Enables faking of non WHQL signed / approved drivers
     30                                    ; Needs the VBoxWHQLFake.exe in the additions output directory!
     31!define WFP_FILE_EXCEPTION          ; Enables setting a temporary file exception for WFP proctected files
    3132
    3233!define VENDOR_ROOT_KEY             "SOFTWARE\$%VBOX_VENDOR_SHORT%"
    3334
     35; Product defines
    3436!define PRODUCT_NAME                "$%VBOX_PRODUCT% Guest Additions"
    3537!define PRODUCT_DESC                "$%VBOX_PRODUCT% Guest Additions"
     
    730732
    731733  Pop $0
     734
     735!if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1"
     736  !ifdef WFP_FILE_EXCEPTION
     737    VBoxGuestInstallHelper::DisableWFP "$0"
     738    Pop $1 ; Get return value (ignored for now)
     739    DetailPrint "Setting WFP exception for '$0': $1"
     740  !endif
     741!endif
     742
    732743  IfFileExists "$g_strSystemDir\takeown.exe" 0 +2
    733744    nsExec::ExecToLog '"$g_strSystemDir\takeown.exe" /F "$0"'
     
    871882
    872883done:
     884
     885!ifndef WFP_FILE_EXCEPTION
    873886  MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_WFP_WARN_REPLACE) /SD IDOK
     887!endif
    874888  Goto exit
    875889
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