VirtualBox

Changeset 86775 in vbox for trunk/src/VBox/Installer/win


Ignore:
Timestamp:
Oct 30, 2020 6:24:36 PM (4 years ago)
Author:
vboxsync
Message:

Windows host installer: Rewritten Python installation support to now utilize IPRT for most tasks, also now supporting

  • Python 3 support.
  • Python Core installer support for user-based installs (as fallback only).
  • Automatic (simple) validation of the VBox API after installation.

Work in progress.

Location:
trunk/src/VBox/Installer/win/InstallHelper
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/win/InstallHelper/Makefile.kmk

    r82968 r86775  
    2020
    2121DLLS += VBoxInstallHelper
    22 VBoxInstallHelper_TEMPLATE = VBOXR3STATIC
     22VBoxInstallHelper_TEMPLATE = VBoxR3Static
    2323VBoxInstallHelper_DEFS     = _WIN32_WINNT=0x0501 _UNICODE UNICODE
    2424VBoxInstallHelper_DEFS    += VBOX_SVN_REV=$(VBOX_SVN_REV)
     
    3636endif
    3737VBoxInstallHelper_SDKS     = ReorderCompilerIncs $(VBOX_WINPSDK) $(VBOX_WINDDK)
    38 VBoxInstallHelper_LIBS     = $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/Msi.lib
     38VBoxInstallHelper_LIBS    += $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/Msi.lib
    3939ifdef VBOX_WITH_NETFLT
    4040 VBoxInstallHelper_LIBS   += \
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp

    r82968 r86775  
    2121*********************************************************************************************************************************/
    2222#include <iprt/win/windows.h>
     23
    2324#include <tchar.h>
    2425#include <stdio.h>
     
    2627#include <msi.h>
    2728#include <msiquery.h>
     29
     30#include <iprt/utf16.h>
    2831
    2932
     
    4043#endif
    4144
    42 UINT VBoxGetProperty(MSIHANDLE a_hModule, WCHAR *a_pwszName, WCHAR *a_pwszValue, DWORD a_dwSize)
     45UINT VBoxGetMsiProp(MSIHANDLE hMsi, WCHAR *pwszName, WCHAR *pwszValue, DWORD dwSize)
    4346{
    4447    DWORD dwBuffer = 0;
    45     UINT uiRet = MsiGetPropertyW(a_hModule, a_pwszName, L"", &dwBuffer);
     48    UINT uiRet = MsiGetPropertyW(hMsi, pwszName, L"", &dwBuffer);
    4649    if (uiRet == ERROR_MORE_DATA)
    4750    {
    4851        ++dwBuffer;     /* On output does not include terminating null, so add 1. */
    4952
    50         if (dwBuffer > a_dwSize)
     53        if (dwBuffer > dwSize)
    5154            return ERROR_MORE_DATA;
    5255
    53         ZeroMemory(a_pwszValue, a_dwSize);
    54         uiRet = MsiGetPropertyW(a_hModule, a_pwszName, a_pwszValue, &dwBuffer);
     56        ZeroMemory(pwszValue, dwSize);
     57        uiRet = MsiGetPropertyW(hMsi, pwszName, pwszValue, &dwBuffer);
    5558    }
    5659    return uiRet;
    5760}
    5861
    59 UINT VBoxSetProperty(MSIHANDLE a_hModule, WCHAR *a_pwszName, WCHAR *a_pwszValue)
     62/**
     63 * Retrieves a MSI property (in UTF-8).
     64 *
     65 * Convenience function for VBoxGetMsiProp().
     66 *
     67 * @returns VBox status code.
     68 * @param   hMsi                MSI handle to use.
     69 * @param   pcszName            Name of property to retrieve.
     70 * @param   ppszValue           Where to store the allocated value on success.
     71 *                              Must be free'd using RTStrFree() by the caller.
     72 */
     73int VBoxGetMsiPropUtf8(MSIHANDLE hMsi, const char *pcszName, char **ppszValue)
    6074{
    61     return MsiSetPropertyW(a_hModule, a_pwszName, a_pwszValue);
     75    PRTUTF16 pwszName;
     76    int rc = RTStrToUtf16(pcszName, &pwszName);
     77    if (RT_SUCCESS(rc))
     78    {
     79        WCHAR wszValue[1024]; /* 1024 should be enough for everybody (tm). */
     80        if (VBoxGetMsiProp(hMsi, pwszName, wszValue, sizeof(wszValue)) == ERROR_SUCCESS)
     81        {
     82            rc = RTUtf16ToUtf8(wszValue, ppszValue);
     83        }
     84        else
     85            rc = VERR_NOT_FOUND;
     86
     87        RTUtf16Free(pwszName);
     88    }
     89
     90    return rc;
    6291}
    6392
     93UINT VBoxSetMsiProp(MSIHANDLE hMsi, WCHAR *pwszName, WCHAR *pwszValue)
     94{
     95    return MsiSetPropertyW(hMsi, pwszName, pwszValue);
     96}
     97
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxCommon.h

    r82968 r86775  
    2626#endif
    2727
    28 UINT VBoxGetProperty(MSIHANDLE a_hModule, WCHAR *a_pwszName, WCHAR *a_pwszValue, DWORD a_dwSize);
    29 UINT VBoxSetProperty(MSIHANDLE a_hModule, WCHAR *a_pwszName, WCHAR *a_pwszValue);
     28UINT VBoxGetMsiProp(MSIHANDLE hMsi, WCHAR *pwszName, WCHAR *pwszValue, DWORD dwSize);
     29int  VBoxGetMsiPropUtf8(MSIHANDLE hMsi, const char *pcszName, char **ppszValue);
     30UINT VBoxSetMsiProp(MSIHANDLE hMsi, WCHAR *pwszName, WCHAR *pwszValue);
    3031
    3132#endif /* !VBOX_INCLUDED_SRC_InstallHelper_VBoxCommon_h */
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxInstallHelper.cpp

    r85121 r86775  
    2727#include <VBox/version.h>
    2828
    29 #include <iprt/win/windows.h>
    3029#include <wchar.h>
    3130#include <stdio.h>
     
    3635#define _WIN32_DCOM
    3736#include <iprt/win/windows.h>
     37
    3838#include <assert.h>
    3939#include <shellapi.h>
    4040#define INITGUID
    4141#include <guiddef.h>
     42#include <cfgmgr32.h>
    4243#include <devguid.h>
     44
     45#include <iprt/env.h>
     46#include <iprt/err.h>
     47#include <iprt/initterm.h>
     48#include <iprt/path.h>
     49#include <iprt/process.h>
     50#include <iprt/utf16.h>
     51
    4352#include <iprt/win/objbase.h>
    4453#include <iprt/win/setupapi.h>
    4554#include <iprt/win/shlobj.h>
    46 #include <cfgmgr32.h>
    4755
    4856#include "VBoxCommon.h"
     
    6674
    6775
    68 BOOL APIENTRY DllMain(HANDLE hModule, DWORD  uReason, LPVOID lpReserved)
    69 {
    70     RT_NOREF3(hModule, uReason, lpReserved);
     76BOOL WINAPI DllMain(HANDLE hInst, ULONG uReason, LPVOID pReserved)
     77{
     78    RT_NOREF(hInst, pReserved);
     79
     80    switch (uReason)
     81    {
     82        case DLL_PROCESS_ATTACH:
     83            RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
     84            break;
     85
     86        case DLL_PROCESS_DETACH:
     87            break;
     88
     89        case DLL_THREAD_ATTACH:
     90            break;
     91
     92        case DLL_THREAD_DETACH:
     93            break;
     94
     95        default:
     96            break;
     97    }
     98
    7199    return TRUE;
    72100}
    73101
    74 
    75 static void logString(MSIHANDLE hInstall, LPCSTR szString, ...)
    76 {
    77     PMSIHANDLE newHandle = MsiCreateRecord(2);
    78 
    79     char szBuffer[1024];
     102static int logStringF(MSIHANDLE hInstall, const char *pcszFmt, ...)
     103{
     104    PMSIHANDLE hMSI = MsiCreateRecord(2 /* cParms */);
     105    if (!hMSI)
     106        return VERR_ACCESS_DENIED;
     107
     108    RTUTF16 wszBuf[_1K] = { 0 };
     109
    80110    va_list va;
    81     va_start(va, szString);
    82     _vsnprintf(szBuffer, sizeof(szBuffer), szString, va);
     111    va_start(va, pcszFmt);
     112    ssize_t cwch = RTUtf16PrintfV(wszBuf, RT_ELEMENTS(wszBuf), pcszFmt, va);
    83113    va_end(va);
    84114
    85     MsiRecordSetStringA(newHandle, 0, szBuffer);
    86     MsiProcessMessage(hInstall, INSTALLMESSAGE(INSTALLMESSAGE_INFO), newHandle);
    87     MsiCloseHandle(newHandle);
    88 
    89 #if 0/*def DEBUG - wrong? What does '%s' expect, wchar or char? */
    90     _tprintf(_T("Debug: %s\n"), szBuffer);
    91 #endif
    92 }
    93 
    94 static void logStringW(MSIHANDLE hInstall, LPCWSTR pwszString, ...)
    95 {
    96     PMSIHANDLE newHandle = MsiCreateRecord(2);
    97 
    98     WCHAR szBuffer[1024];
    99     va_list va;
    100     va_start(va, pwszString);
    101     _vsnwprintf(szBuffer, RT_ELEMENTS(szBuffer), pwszString, va);
    102     va_end(va);
    103 
    104     MsiRecordSetStringW(newHandle, 0, szBuffer);
    105     MsiProcessMessage(hInstall, INSTALLMESSAGE(INSTALLMESSAGE_INFO), newHandle);
    106     MsiCloseHandle(newHandle);
     115    if (cwch <= 0)
     116        return VERR_BUFFER_OVERFLOW;
     117
     118    MsiRecordSetStringW(hMSI, 0, wszBuf);
     119    MsiProcessMessage(hInstall, INSTALLMESSAGE(INSTALLMESSAGE_INFO), hMSI);
     120    MsiCloseHandle(hMSI);
     121
     122    return VINF_SUCCESS;
    107123}
    108124
     
    110126{
    111127#ifndef VBOX_OSE
    112     /*BOOL bRet =*/ serialCheckNeeded(hModule);
     128    /*BOOL fRet =*/ serialCheckNeeded(hModule);
    113129#else
    114     RT_NOREF1(hModule);
     130    RT_NOREF(hModule);
    115131#endif
    116132    return ERROR_SUCCESS;
     
    122138    /*BOOL bRet =*/ serialIsValid(hModule);
    123139#else
    124     RT_NOREF1(hModule);
     140    RT_NOREF(hModule);
    125141#endif
    126142    return ERROR_SUCCESS;
    127143}
    128144
    129 DWORD Exec(MSIHANDLE hModule,
    130            const WCHAR *pwszAppName, WCHAR *pwszCmdLine, const WCHAR *pwszWorkDir,
    131            DWORD *pdwExitCode)
    132 {
    133     STARTUPINFOW si;
    134     PROCESS_INFORMATION pi;
    135     DWORD rc = ERROR_SUCCESS;
    136 
    137     ZeroMemory(&si, sizeof(si));
    138     si.dwFlags = STARTF_USESHOWWINDOW;
    139 #ifdef UNICODE
    140     si.dwFlags |= CREATE_UNICODE_ENVIRONMENT;
     145/**
     146 * Tries to retrieve the Python installation path on the system.
     147 *
     148 * @returns VBox status code.
     149 * @param   hModule             Windows installer module handle.
     150 * @param   hKeyRoot            Registry root key to use, e.g. HKEY_LOCAL_MACHINE.
     151 * @param   ppszPath            Where to store the allocated Python path on success.
     152 *                              Must be free'd by the caller using RTStrFree().
     153 */
     154static int getPythonPath(MSIHANDLE hModule, HKEY hKeyRoot, char **ppszPath)
     155{
     156    HKEY hkPythonCore = NULL;
     157    LSTATUS dwErr = RegOpenKeyExW(hKeyRoot, L"SOFTWARE\\Python\\PythonCore", 0, KEY_READ, &hkPythonCore);
     158    if (dwErr != ERROR_SUCCESS)
     159        return RTErrConvertFromWin32(dwErr);
     160
     161    char *pszPythonPath = NULL;
     162
     163    RTUTF16 wszKey [RTPATH_MAX] = { 0 };
     164    RTUTF16 wszKey2[RTPATH_MAX] = { 0 };
     165    RTUTF16 wszVal [RTPATH_MAX] = { 0 };
     166
     167    int rc = VINF_SUCCESS;
     168
     169    /* Note: The loop ASSUMES that later found versions are higher, e.g. newer Python versions.
     170     *       For now we always go by the newest version. */
     171    for (int i = 0;; ++i)
     172    {
     173        DWORD dwKey     = sizeof(wszKey);
     174        DWORD dwKeyType = REG_SZ;
     175
     176        dwErr = RegEnumKeyExW(hkPythonCore, i, wszKey, &dwKey, NULL, NULL, NULL, NULL);
     177        if (dwErr != ERROR_SUCCESS || dwKey <= 0)
     178            break;
     179        AssertBreakStmt(dwKey <= sizeof(wszKey), VERR_BUFFER_OVERFLOW);
     180
     181        if (RTUtf16Printf(wszKey2, sizeof(wszKey2), "%ls\\InstallPath", wszKey) <= 0)
     182        {
     183            rc = VERR_BUFFER_OVERFLOW;
     184            break;
     185        }
     186
     187        dwKey = sizeof(wszKey2); /* Re-initialize length. */
     188
     189        HKEY hkPythonInstPath = NULL;
     190        dwErr = RegOpenKeyExW(hkPythonCore, wszKey2, 0, KEY_READ,  &hkPythonInstPath);
     191        if (dwErr != ERROR_SUCCESS)
     192            continue;
     193
     194        dwErr = RegQueryValueExW(hkPythonInstPath, L"", NULL, &dwKeyType, (LPBYTE)wszVal, &dwKey);
     195        if (dwErr == ERROR_SUCCESS)
     196            logStringF(hModule, "InstallPythonAPI: Path \"%ls\" found.", wszVal);
     197
     198        if (pszPythonPath) /* Free former path, if any. */
     199        {
     200            RTStrFree(pszPythonPath);
     201            pszPythonPath = NULL;
     202        }
     203
     204        rc = RTUtf16ToUtf8(wszVal, &pszPythonPath);
     205        AssertRCBreak(rc);
     206
     207        if (!RTPathExists(pszPythonPath))
     208        {
     209            logStringF(hModule, "InstallPythonAPI: Warning: Path \"%s\" does not exist, skipping.", wszVal);
     210            rc = VERR_PATH_NOT_FOUND;
     211        }
     212
     213        RegCloseKey(hkPythonInstPath);
     214    }
     215
     216    RegCloseKey(hkPythonCore);
     217
     218    if (RT_FAILURE(rc))
     219    {
     220        RTStrFree(pszPythonPath);
     221    }
     222    else
     223        *ppszPath = pszPythonPath;
     224
     225    return rc;
     226}
     227
     228/**
     229 * Waits for a started process to terminate.
     230 *
     231 * @returns VBox status code.
     232 * @param   Process             Handle of process to wait for.
     233 * @param   msTimeout           Timeout (in ms) to wait for process to terminate.
     234 * @param   pProcSts            Pointer to process status on return.
     235 */
     236int procWait(RTPROCESS Process, RTMSINTERVAL msTimeout, PRTPROCSTATUS pProcSts)
     237{
     238    uint64_t tsStartMs = RTTimeMilliTS();
     239
     240    while (RTTimeMilliTS() - tsStartMs <= msTimeout)
     241    {
     242        int rc = RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, pProcSts);
     243        if (rc == VERR_PROCESS_RUNNING)
     244            continue;
     245        else if (RT_FAILURE(rc))
     246            return rc;
     247
     248        if (   pProcSts->iStatus   != 0
     249            || pProcSts->enmReason != RTPROCEXITREASON_NORMAL)
     250        {
     251            rc = VERR_GENERAL_FAILURE; /** @todo Fudge! */
     252        }
     253
     254        return VINF_SUCCESS;
     255    }
     256
     257    return VERR_TIMEOUT;
     258}
     259
     260/**
     261 * Checks for a valid Python installation on the system.
     262 *
     263 * Called from the MSI installer as custom action.
     264 *
     265 * @returns Always ERROR_SUCCESS.
     266 *          Sets public property VBOX_PYTHON_INSTALLED to "0" (false) or "1" (success).
     267 *          Sets public property VBOX_PYTHON_PATH to the Python installation path (if found).
     268 *
     269 * @param   hModule             Windows installer module handle.
     270 */
     271UINT __stdcall IsPythonInstalled(MSIHANDLE hModule)
     272{
     273    char *pszPythonPath;
     274    int rc = getPythonPath(hModule, HKEY_LOCAL_MACHINE, &pszPythonPath);
     275    if (RT_FAILURE(rc))
     276        rc = getPythonPath(hModule, HKEY_CURRENT_USER, &pszPythonPath);
     277
     278    if (RT_SUCCESS(rc))
     279    {
     280        logStringF(hModule, "IsPythonInstalled: Python installation found at \"%s\"", pszPythonPath);
     281
     282        PRTUTF16 pwszPythonPath;
     283        rc = RTStrToUtf16(pszPythonPath, &pwszPythonPath);
     284        if (RT_SUCCESS(rc))
     285        {
     286            VBoxSetMsiProp(hModule, L"VBOX_PYTHON_PATH", pwszPythonPath);
     287
     288            RTUtf16Free(pwszPythonPath);
     289        }
     290        else
     291            logStringF(hModule, "IsPythonInstalled: Error: Unable to convert path, rc=%Rrc", rc);
     292
     293        RTStrFree(pszPythonPath);
     294    }
     295    else
     296        logStringF(hModule, "IsPythonInstalled: Error: No suitable Python installation found (%Rrc), skipping installation.", rc);
     297
     298    VBoxSetMsiProp(hModule, L"VBOX_PYTHON_INSTALLED", RT_SUCCESS(rc) ? L"1" : L"0");
     299
     300    return ERROR_SUCCESS; /* Never return failure. */
     301}
     302
     303/**
     304 * Installs and compiles the VBox Python bindings.
     305 *
     306 * Called from the MSI installer as custom action.
     307 *
     308 * @returns Always ERROR_SUCCESS.
     309 *          Sets public property VBOX_API_INSTALLED to "0" (false) or "1" (success).
     310 *
     311 * @param   hModule             Windows installer module handle.
     312 */
     313UINT __stdcall InstallPythonAPI(MSIHANDLE hModule)
     314{
     315    logStringF(hModule, "InstallPythonAPI: Checking for installed Python environment(s) ...");
     316
     317    char *pszPythonPath;
     318    int rc = getPythonPath(hModule, HKEY_LOCAL_MACHINE, &pszPythonPath);
     319    if (RT_FAILURE(rc))
     320        rc = getPythonPath(hModule, HKEY_CURRENT_USER, &pszPythonPath);
     321
     322    if (RT_FAILURE(rc))
     323    {
     324        VBoxSetMsiProp(hModule, L"VBOX_API_INSTALLED", L"0");
     325
     326        logStringF(hModule, "InstallPythonAPI: Python seems not to be installed (%Rrc); please download + install the Python Core package.", rc);
     327        return ERROR_SUCCESS;
     328    }
     329
     330    logStringF(hModule, "InstallPythonAPI: Python installation found at \"%s\".", pszPythonPath);
     331    logStringF(hModule, "InstallPythonAPI: Checking for win32api extensions ...");
     332
     333    uint32_t fProcess = 0;
     334#ifndef DEBUG
     335    uint32_t fProcess |= RTPROC_FLAGS_HIDDEN;
    141336#endif
    142     si.wShowWindow = SW_HIDE; /* For debugging: SW_SHOW; */
    143     si.cb = sizeof(si);
    144     ZeroMemory(&pi, sizeof(pi));
    145 
    146     logStringW(hModule, L"Executing command line: %s %s (Working Dir: %s)",
    147                pwszAppName, pwszCmdLine, pwszWorkDir == NULL ? L"Current" : pwszWorkDir);
    148 
    149     SetLastError(0);
    150     if (!CreateProcessW(pwszAppName,  /* Module name. */
    151                         pwszCmdLine,  /* Command line. */
    152                         NULL,         /* Process handle not inheritable. */
    153                         NULL,         /* Thread handle not inheritable. */
    154                         FALSE,        /* Set handle inheritance to FALSE .*/
    155                         0,            /* No creation flags. */
    156                         NULL,         /* Use parent's environment block. */
    157                         pwszWorkDir,  /* Use parent's starting directory. */
    158                         &si,          /* Pointer to STARTUPINFO structure. */
    159                         &pi))         /* Pointer to PROCESS_INFORMATION structure. */
    160     {
    161         rc = GetLastError();
    162         logStringW(hModule, L"Executing command line: CreateProcess() failed! Error: %ld", rc);
    163         return rc;
    164     }
    165 
    166     /* Wait until child process exits. */
    167     if (WAIT_FAILED == WaitForSingleObject(pi.hProcess, 30 * 1000 /* Wait 30 secs max. */))
    168     {
    169         rc = GetLastError();
    170         logStringW(hModule, L"Executing command line: WaitForSingleObject() failed! Error: %u", rc);
    171     }
    172     else
    173     {
    174         if (!GetExitCodeProcess(pi.hProcess, pdwExitCode))
    175         {
    176             rc = GetLastError();
    177             logStringW(hModule, L"Executing command line: GetExitCodeProcess() failed! Error: %u", rc);
    178         }
    179     }
    180 
    181     /* Close process and thread handles. */
    182     CloseHandle(pi.hProcess);
    183     CloseHandle(pi.hThread);
    184 
    185     logStringW(hModule, L"Executing command returned: %u (exit code %u)", rc, *pdwExitCode);
    186     return rc;
    187 }
    188 
    189 UINT __stdcall InstallPythonAPI(MSIHANDLE hModule)
    190 {
    191     logStringW(hModule, L"InstallPythonAPI: Checking for installed Python environment ...");
    192 
    193     HKEY hkPythonCore = NULL;
    194     BOOL bFound = FALSE;
    195     LONG rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Python\\PythonCore", 0, KEY_READ, &hkPythonCore);
    196     if (rc != ERROR_SUCCESS)
    197     {
    198         logStringW(hModule, L"InstallPythonAPI: Python seems not to be installed.");
    199         return ERROR_SUCCESS;
    200     }
    201 
    202     WCHAR wszPath[MAX_PATH] = { 0 };
    203     WCHAR wszVal[MAX_PATH] = { 0 };
    204 
    205     for (int i = 0;; ++i)
    206     {
    207         WCHAR wszRoot[MAX_PATH] = { 0 };
    208         DWORD dwLen = sizeof(wszPath);
    209         DWORD dwKeyType = REG_SZ;
    210 
    211         rc = RegEnumKeyExW(hkPythonCore, i, wszRoot, &dwLen, NULL, NULL, NULL, NULL);
    212         if (rc != ERROR_SUCCESS || dwLen <= 0)
    213             break;
    214 
    215         swprintf_s(wszPath, RT_ELEMENTS(wszPath), L"%s\\InstallPath", wszRoot);
    216         dwLen = sizeof(wszVal);
    217 
    218         HKEY hkPythonInstPath = NULL;
    219         rc = RegOpenKeyExW(hkPythonCore, wszPath, 0, KEY_READ,  &hkPythonInstPath);
    220         if (rc != ERROR_SUCCESS)
    221             continue;
    222 
    223         rc = RegQueryValueExW(hkPythonInstPath, L"", NULL, &dwKeyType, (LPBYTE)wszVal, &dwLen);
    224         if (rc == ERROR_SUCCESS)
    225             logStringW(hModule, L"InstallPythonAPI: Path \"%s\" detected.", wszVal);
    226 
    227         RegCloseKey(hkPythonInstPath);
    228     }
    229     RegCloseKey(hkPythonCore);
    230 
    231     /* Python path found? */
    232     WCHAR wszExec[MAX_PATH] = { 0 };
    233     WCHAR wszCmdLine[MAX_PATH] = { 0 };
    234     DWORD dwExitCode = 0;
    235     if (wcslen(wszVal) > 0)
    236     {
    237         /* Cool, check for installed Win32 extensions. */
    238         logStringW(hModule, L"InstallPythonAPI: Python installed. Checking for Win32 extensions ...");
    239         swprintf_s(wszExec, RT_ELEMENTS(wszExec), L"%s\\python.exe", wszVal);
    240         swprintf_s(wszCmdLine, RT_ELEMENTS(wszCmdLine), L"%s\\python.exe -c \"import win32api\"", wszVal);
    241 
    242         DWORD dwRetExec = Exec(hModule, wszExec, wszCmdLine, NULL, &dwExitCode);
    243         if (   (ERROR_SUCCESS == dwRetExec)
    244             && (            0 == dwExitCode))
    245         {
    246             /* Did we get the correct error level (=0)? */
    247             logStringW(hModule, L"InstallPythonAPI: Win32 extensions installed.");
    248             bFound = TRUE;
    249         }
    250         else
    251             logStringW(hModule, L"InstallPythonAPI: Win32 extensions not found.");
    252     }
    253 
    254     BOOL bInstalled = FALSE;
    255     if (bFound) /* Is Python and all required stuff installed? */
    256     {
    257         /* Get the VBoxAPI setup string. */
    258         WCHAR wszPathTargetDir[MAX_PATH] = {0};
    259         VBoxGetProperty(hModule, L"CustomActionData", wszPathTargetDir, sizeof(wszPathTargetDir));
    260         if (wcslen(wszPathTargetDir))
    261         {
    262             /* Set final path. */
    263             swprintf_s(wszPath, RT_ELEMENTS(wszPath), L"%s", wszPathTargetDir);
    264 
    265             /* Install our API module. */
    266             swprintf_s(wszCmdLine, RT_ELEMENTS(wszCmdLine), L"%s\\python.exe vboxapisetup.py install", wszVal);
    267 
    268             /* Set required environment variables. */
    269             if (!SetEnvironmentVariableW(L"VBOX_INSTALL_PATH", wszPathTargetDir))
    270                 logStringW(hModule, L"InstallPythonAPI: Could set environment variable VBOX_INSTALL_PATH!");
    271             else
    272             {
    273                 DWORD dwRetExec = Exec(hModule, wszExec, wszCmdLine, wszPath, &dwExitCode);
    274                 if (   (ERROR_SUCCESS == dwRetExec)
    275                     && (            0 == dwExitCode))
     337
     338    char szPythonPath[RTPATH_MAX] = { 0 };
     339    rc = RTPathAppend(szPythonPath, sizeof(szPythonPath), pszPythonPath);
     340    if (RT_SUCCESS(rc))
     341    {
     342        rc = RTPathAppend(szPythonPath, sizeof(szPythonPath), "python.exe");
     343        if (RT_SUCCESS(rc))
     344        {
     345            /*
     346             * Check if importing the win32api module works.
     347             * This is a prerequisite for setting up the VBox API.
     348             */
     349            RTPROCESS Process;
     350            RT_ZERO(Process);
     351            const char *papszArgs[4] = { szPythonPath, "-c", "import win32api", NULL};
     352            rc = RTProcCreate(szPythonPath, papszArgs, RTENV_DEFAULT, fProcess, &Process);
     353            if (RT_SUCCESS(rc))
     354            {
     355                RTPROCSTATUS ProcSts;
     356                rc = procWait(Process, RT_MS_30SEC, &ProcSts);
     357                if (RT_FAILURE(rc))
     358                    logStringF(hModule, "InstallPythonAPI: Importing the win32api failed with %d (exit reason: %d)\n",
     359                                   ProcSts.iStatus, ProcSts.enmReason);
     360            }
     361        }
     362    }
     363
     364    /*
     365     * Set up the VBox API.
     366     */
     367    if (RT_SUCCESS(rc))
     368    {
     369        /* Get the VBox API setup string. */
     370        char *pszVBoxSDKPath;
     371        rc = VBoxGetMsiPropUtf8(hModule, "CustomActionData", &pszVBoxSDKPath);
     372        if (RT_SUCCESS(rc))
     373        {
     374            /* Make sure our current working directory is the VBox installation path. */
     375            rc = RTPathSetCurrent(pszVBoxSDKPath);
     376            if (RT_SUCCESS(rc))
     377            {
     378                /* Set required environment variables. */
     379                rc = RTEnvSet("VBOX_INSTALL_PATH", pszVBoxSDKPath);
     380                if (RT_SUCCESS(rc))
    276381                {
    277                     /* All done! */
    278                     logStringW(hModule, L"InstallPythonAPI: VBoxAPI for Python successfully installed.");
    279                     bInstalled = TRUE;
     382                    RTPROCSTATUS ProcSts;
     383                    RT_ZERO(ProcSts);
     384
     385                    logStringF(hModule, "InstallPythonAPI: Invoking vboxapisetup.py in \"%s\" ...\n", pszVBoxSDKPath);
     386
     387                    RTPROCESS Process;
     388                    RT_ZERO(Process);
     389                    const char *papszArgs[4] = { szPythonPath, "vboxapisetup.py", "install", NULL};
     390                    rc = RTProcCreate(szPythonPath, papszArgs, RTENV_DEFAULT, fProcess, &Process);
     391                    if (RT_SUCCESS(rc))
     392                    {
     393                        rc = procWait(Process, RT_MS_30SEC, &ProcSts);
     394                        if (RT_SUCCESS(rc))
     395                            logStringF(hModule, "InstallPythonAPI: Installation of vboxapisetup.py successful\n");
     396                    }
     397
     398                    if (RT_FAILURE(rc))
     399                        logStringF(hModule, "InstallPythonAPI: Calling vboxapisetup.py failed with %Rrc (process status: %d, exit reason: %d)\n",
     400                                   rc, ProcSts.iStatus, ProcSts.enmReason);
    280401                }
    281402                else
    282                 {
    283                     if (dwRetExec)
    284                         logStringW(hModule, L"InstallPythonAPI: Error while executing installation of VBox API: %ld", dwRetExec);
    285                     else
    286                         logStringW(hModule, L"InstallPythonAPI: Python reported an error while installing VBox API: %ld", dwExitCode);
    287                 }
    288             }
     403                    logStringF(hModule, "InstallPythonAPI: Could set environment variable VBOX_INSTALL_PATH, rc=%Rrc\n", rc);
     404            }
     405            else
     406                logStringF(hModule, "InstallPythonAPI: Could set working directory to \"%s\", rc=%Rrc\n", pszVBoxSDKPath, rc);
     407
     408            RTStrFree(pszVBoxSDKPath);
    289409        }
    290410        else
    291             logStringW(hModule, L"InstallPythonAPI: Unable to retrieve VBox installation path!");
    292     }
    293 
    294     VBoxSetProperty(hModule, L"VBOX_PYTHON_IS_INSTALLED", bInstalled ? L"1" : L"0");
    295 
    296     if (!bInstalled)
    297         logStringW(hModule, L"InstallPythonAPI: VBox API not installed.");
     411            logStringF(hModule, "InstallPythonAPI: Unable to retrieve VBox installation directory, rc=%Rrc\n", rc);
     412    }
     413
     414    /*
     415     * Do some sanity checking if the VBox API works.
     416     */
     417    if (RT_SUCCESS(rc))
     418    {
     419        logStringF(hModule, "InstallPythonAPI: Validating VBox API ...\n");
     420
     421        RTPROCSTATUS ProcSts;
     422        RT_ZERO(ProcSts);
     423
     424        RTPROCESS Process;
     425        RT_ZERO(Process);
     426        const char *papszArgs[4] = { szPythonPath, "-c", "from vboxapi import VirtualBoxManager", NULL};
     427        rc = RTProcCreate(szPythonPath, papszArgs, RTENV_DEFAULT, fProcess, &Process);
     428        if (RT_SUCCESS(rc))
     429        {
     430            rc = procWait(Process, RT_MS_30SEC, &ProcSts);
     431            if (RT_SUCCESS(rc))
     432                logStringF(hModule, "InstallPythonAPI: VBox API looks good.\n");
     433        }
     434
     435        if (RT_FAILURE(rc))
     436            logStringF(hModule, "InstallPythonAPI: Validating VBox API failed with %Rrc (process status: %d, exit reason: %d)\n",
     437                       rc, ProcSts.iStatus, ProcSts.enmReason);
     438    }
     439
     440    RTStrFree(pszPythonPath);
     441
     442    VBoxSetMsiProp(hModule, L"VBOX_API_INSTALLED", RT_SUCCESS(rc) ? L"1" : L"0");
     443
     444    if (RT_FAILURE(rc))
     445        logStringF(hModule, "InstallPythonAPI: Installation failed with %Rrc\n", rc);
     446
    298447    return ERROR_SUCCESS; /* Do not fail here. */
    299448}
     
    327476                                (DWORD)wcslen(wszValue));
    328477            if (rc != ERROR_SUCCESS)
    329                 logStringW(hModule, L"InstallBranding: Could not write value %s! Error %ld", pwszValue, rc);
     478                logStringF(hModule, "InstallBranding: Could not write value %s! Error %ld", pwszValue, rc);
    330479            RegCloseKey (hkBranding);
    331480        }
     
    355504               FOF_NOERRORUI;
    356505
    357     logStringW(hModule, L"CopyDir: DestDir=%s, SourceDir=%s", wszDest, wszSource);
     506    logStringF(hModule, "CopyDir: DestDir=%s, SourceDir=%s", wszDest, wszSource);
    358507    int r = SHFileOperationW(&s);
    359508    if (r != 0)
    360509    {
    361         logStringW(hModule, L"CopyDir: Copy operation returned status 0x%x", r);
     510        logStringF(hModule, "CopyDir: Copy operation returned status 0x%x", r);
    362511        rc = ERROR_GEN_FAILURE;
    363512    }
     
    383532             | FOF_NOERRORUI;
    384533
    385     logStringW(hModule, L"RemoveDir: DestDir=%s", wszDest);
     534    logStringF(hModule, "RemoveDir: DestDir=%s", wszDest);
    386535    int r = SHFileOperationW(&s);
    387536    if (r != 0)
    388537    {
    389         logStringW(hModule, L"RemoveDir: Remove operation returned status 0x%x", r);
     538        logStringF(hModule, "RemoveDir: Remove operation returned status 0x%x", r);
    390539        rc = ERROR_GEN_FAILURE;
    391540    }
     
    414563             | FOF_NOERRORUI;
    415564
    416     logStringW(hModule, L"RenameDir: DestDir=%s, SourceDir=%s", wszDest, wszSource);
     565    logStringF(hModule, "RenameDir: DestDir=%s, SourceDir=%s", wszDest, wszSource);
    417566    int r = SHFileOperationW(&s);
    418567    if (r != 0)
    419568    {
    420         logStringW(hModule, L"RenameDir: Rename operation returned status 0x%x", r);
     569        logStringF(hModule, "RenameDir: Rename operation returned status 0x%x", r);
    421570        rc = ERROR_GEN_FAILURE;
    422571    }
     
    429578{
    430579    UINT rc;
    431     logStringW(hModule, L"UninstallBranding: Handling branding file ...");
     580    logStringF(hModule, "UninstallBranding: Handling branding file ...");
    432581
    433582    WCHAR wszPathTargetDir[_MAX_PATH];
    434583    WCHAR wszPathDest[_MAX_PATH];
    435584
    436     rc = VBoxGetProperty(hModule, L"CustomActionData", wszPathTargetDir, sizeof(wszPathTargetDir));
     585    rc = VBoxGetMsiProp(hModule, L"CustomActionData", wszPathTargetDir, sizeof(wszPathTargetDir));
    437586    if (rc == ERROR_SUCCESS)
    438587    {
     
    454603    }
    455604
    456     logStringW(hModule, L"UninstallBranding: Handling done. (rc=%u (ignored))", rc);
     605    logStringF(hModule, "UninstallBranding: Handling done. (rc=%u (ignored))", rc);
    457606    return ERROR_SUCCESS; /* Do not fail here. */
    458607}
     
    461610{
    462611    UINT rc;
    463     logStringW(hModule, L"InstallBranding: Handling branding file ...");
     612    logStringF(hModule, "InstallBranding: Handling branding file ...");
    464613
    465614    WCHAR wszPathMSI[_MAX_PATH];
    466     rc = VBoxGetProperty(hModule, L"SOURCEDIR", wszPathMSI, sizeof(wszPathMSI));
     615    rc = VBoxGetMsiProp(hModule, L"SOURCEDIR", wszPathMSI, sizeof(wszPathMSI));
    467616    if (rc == ERROR_SUCCESS)
    468617    {
    469618        WCHAR wszPathTargetDir[_MAX_PATH];
    470         rc = VBoxGetProperty(hModule, L"CustomActionData", wszPathTargetDir, sizeof(wszPathTargetDir));
     619        rc = VBoxGetMsiProp(hModule, L"CustomActionData", wszPathTargetDir, sizeof(wszPathTargetDir));
    471620        if (rc == ERROR_SUCCESS)
    472621        {
     
    487636    }
    488637
    489     logStringW(hModule, L"InstallBranding: Handling done. (rc=%u (ignored))", rc);
     638    logStringF(hModule, "InstallBranding: Handling done. (rc=%u (ignored))", rc);
    490639    return ERROR_SUCCESS; /* Do not fail here. */
    491640}
     
    518667        case VBOXDRVCFG_LOG_SEVERITY_REL:
    519668            if (g_hCurrentModule)
    520                 logString(g_hCurrentModule, pszMsg);
     669                logStringF(g_hCurrentModule, pszMsg);
    521670            break;
    522671        default:
     
    528677{
    529678    if (g_hCurrentModule)
    530         logString(g_hCurrentModule, pszString);
     679        logStringF(g_hCurrentModule, pszString);
    531680}
    532681
     
    565714        case NETCFG_S_REBOOT:
    566715        {
    567             logStringW(hModule, L"Reboot required, setting REBOOT property to \"force\"");
     716            logStringF(hModule, "Reboot required, setting REBOOT property to \"force\"");
    568717            HRESULT hr2 = MsiSetPropertyW(hModule, L"REBOOT", L"Force");
    569718            if (hr2 != ERROR_SUCCESS)
    570                 logStringW(hModule, L"Failed to set REBOOT property, error = 0x%x", hr2);
     719                logStringF(hModule, "Failed to set REBOOT property, error = 0x%x", hr2);
    571720            uRet = ERROR_SUCCESS; /* Never fail here. */
    572721            break;
     
    574723
    575724        default:
    576             logStringW(hModule, L"Converting unhandled HRESULT (0x%x) to ERROR_GEN_FAILURE", hr);
     725            logStringF(hModule, "Converting unhandled HRESULT (0x%x) to ERROR_GEN_FAILURE", hr);
    577726            uRet = ERROR_GEN_FAILURE;
    578727    }
     
    588737        if (uErr != ERROR_SUCCESS)
    589738        {
    590             logStringW(hModule, L"createNetCfgLockedMsgRecord: MsiRecordSetInteger failed, error = 0x%x", uErr);
     739            logStringF(hModule, "createNetCfgLockedMsgRecord: MsiRecordSetInteger failed, error = 0x%x", uErr);
    591740            MsiCloseHandle(hRecord);
    592741            hRecord = NULL;
     
    594743    }
    595744    else
    596         logStringW(hModule, L"createNetCfgLockedMsgRecord: Failed to create a record");
     745        logStringF(hModule, "createNetCfgLockedMsgRecord: Failed to create a record");
    597746
    598747    return hRecord;
     
    613762        {
    614763            if (FAILED(hr))
    615                 logStringW(hModule, L"doNetCfgInit: VBoxNetCfgWinQueryINetCfg failed, error = 0x%x", hr);
     764                logStringF(hModule, "doNetCfgInit: VBoxNetCfgWinQueryINetCfg failed, error = 0x%x", hr);
    616765            uErr = errorConvertFromHResult(hModule, hr);
    617766            break;
     
    622771        if (!lpszLockedBy)
    623772        {
    624             logStringW(hModule, L"doNetCfgInit: lpszLockedBy == NULL, breaking");
     773            logStringF(hModule, "doNetCfgInit: lpszLockedBy == NULL, breaking");
    625774            break;
    626775        }
     
    636785        {
    637786            cRetries++;
    638             logStringW(hModule, L"doNetCfgInit: lpszLockedBy is 6to4svc.dll, retrying %d out of %d", cRetries, VBOX_NETCFG_MAX_RETRIES);
     787            logStringF(hModule, "doNetCfgInit: lpszLockedBy is 6to4svc.dll, retrying %d out of %d", cRetries, VBOX_NETCFG_MAX_RETRIES);
    639788            MsgResult = IDRETRY;
    640789        }
     
    646795                if (!hMsg)
    647796                {
    648                     logStringW(hModule, L"doNetCfgInit: Failed to create a message record, breaking");
     797                    logStringF(hModule, "doNetCfgInit: Failed to create a message record, breaking");
    649798                    CoTaskMemFree(lpszLockedBy);
    650799                    break;
     
    656805            if (rTmp != ERROR_SUCCESS)
    657806            {
    658                 logStringW(hModule, L"doNetCfgInit: MsiRecordSetStringW failed, error = 0x%x", rTmp);
     807                logStringF(hModule, "doNetCfgInit: MsiRecordSetStringW failed, error = 0x%x", rTmp);
    659808                CoTaskMemFree(lpszLockedBy);
    660809                break;
     
    663812            MsgResult = MsiProcessMessage(hModule, (INSTALLMESSAGE)(INSTALLMESSAGE_USER | MB_RETRYCANCEL), hMsg);
    664813            NonStandardAssert(MsgResult == IDRETRY || MsgResult == IDCANCEL);
    665             logStringW(hModule, L"doNetCfgInit: MsiProcessMessage returned (0x%x)", MsgResult);
     814            logStringF(hModule, "doNetCfgInit: MsiProcessMessage returned (0x%x)", MsgResult);
    666815        }
    667816        CoTaskMemFree(lpszLockedBy);
     
    684833
    685834        wcsncat(pwszPtInf, NETFLT_PT_INF_REL_PATH, sizeof(NETFLT_PT_INF_REL_PATH));
    686         logStringW(hModule, L"vboxNetFltQueryInfArray: INF 1: %s", pwszPtInf);
     835        logStringF(hModule, "vboxNetFltQueryInfArray: INF 1: %s", pwszPtInf);
    687836
    688837        wcsncat(pwszMpInf, NETFLT_MP_INF_REL_PATH, sizeof(NETFLT_MP_INF_REL_PATH));
    689         logStringW(hModule, L"vboxNetFltQueryInfArray: INF 2: %s", pwszMpInf);
     838        logStringF(hModule, "vboxNetFltQueryInfArray: INF 2: %s", pwszMpInf);
    690839    }
    691840    else if (uErr != ERROR_SUCCESS)
    692         logStringW(hModule, L"vboxNetFltQueryInfArray: MsiGetPropertyW failed, error = 0x%x", uErr);
     841        logStringF(hModule, "vboxNetFltQueryInfArray: MsiGetPropertyW failed, error = 0x%x", uErr);
    693842    else
    694843    {
    695         logStringW(hModule, L"vboxNetFltQueryInfArray: Empty installation directory");
     844        logStringF(hModule, "vboxNetFltQueryInfArray: Empty installation directory");
    696845        uErr = ERROR_GEN_FAILURE;
    697846    }
     
    714863    __try
    715864    {
    716         logStringW(hModule, L"Uninstalling NetFlt");
     865        logStringF(hModule, "Uninstalling NetFlt");
    717866
    718867        uErr = doNetCfgInit(hModule, &pNetCfg, TRUE);
     
    721870            HRESULT hr = VBoxNetCfgWinNetFltUninstall(pNetCfg);
    722871            if (hr != S_OK)
    723                 logStringW(hModule, L"UninstallNetFlt: VBoxNetCfgWinUninstallComponent failed, error = 0x%x", hr);
     872                logStringF(hModule, "UninstallNetFlt: VBoxNetCfgWinUninstallComponent failed, error = 0x%x", hr);
    724873
    725874            uErr = errorConvertFromHResult(hModule, hr);
     
    727876            VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE);
    728877
    729             logStringW(hModule, L"Uninstalling NetFlt done, error = 0x%x", uErr);
     878            logStringF(hModule, "Uninstalling NetFlt done, error = 0x%x", uErr);
    730879        }
    731880        else
    732             logStringW(hModule, L"UninstallNetFlt: doNetCfgInit failed, error = 0x%x", uErr);
     881            logStringF(hModule, "UninstallNetFlt: doNetCfgInit failed, error = 0x%x", uErr);
    733882    }
    734883    __finally
     
    766915    {
    767916
    768         logStringW(hModule, L"InstallNetFlt: Installing NetFlt");
     917        logStringF(hModule, "InstallNetFlt: Installing NetFlt");
    769918
    770919        uErr = doNetCfgInit(hModule, &pNetCfg, TRUE);
     
    779928                HRESULT hr = VBoxNetCfgWinNetFltInstall(pNetCfg, &apwszInfs[0], RT_ELEMENTS(apwszInfs));
    780929                if (FAILED(hr))
    781                     logStringW(hModule, L"InstallNetFlt: VBoxNetCfgWinNetFltInstall failed, error = 0x%x", hr);
     930                    logStringF(hModule, "InstallNetFlt: VBoxNetCfgWinNetFltInstall failed, error = 0x%x", hr);
    782931
    783932                uErr = errorConvertFromHResult(hModule, hr);
    784933            }
    785934            else
    786                 logStringW(hModule, L"InstallNetFlt: vboxNetFltQueryInfArray failed, error = 0x%x", uErr);
     935                logStringF(hModule, "InstallNetFlt: vboxNetFltQueryInfArray failed, error = 0x%x", uErr);
    787936
    788937            VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE);
    789938
    790             logStringW(hModule, L"InstallNetFlt: Done");
     939            logStringF(hModule, "InstallNetFlt: Done");
    791940        }
    792941        else
    793             logStringW(hModule, L"InstallNetFlt: doNetCfgInit failed, error = 0x%x", uErr);
     942            logStringF(hModule, "InstallNetFlt: doNetCfgInit failed, error = 0x%x", uErr);
    794943    }
    795944    __finally
     
    827976    __try
    828977    {
    829         logStringW(hModule, L"Uninstalling NetLwf");
     978        logStringF(hModule, "Uninstalling NetLwf");
    830979
    831980        uErr = doNetCfgInit(hModule, &pNetCfg, TRUE);
     
    834983            HRESULT hr = VBoxNetCfgWinNetLwfUninstall(pNetCfg);
    835984            if (hr != S_OK)
    836                 logStringW(hModule, L"UninstallNetLwf: VBoxNetCfgWinUninstallComponent failed, error = 0x%x", hr);
     985                logStringF(hModule, "UninstallNetLwf: VBoxNetCfgWinUninstallComponent failed, error = 0x%x", hr);
    837986
    838987            uErr = errorConvertFromHResult(hModule, hr);
     
    840989            VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE);
    841990
    842             logStringW(hModule, L"Uninstalling NetLwf done, error = 0x%x", uErr);
     991            logStringF(hModule, "Uninstalling NetLwf done, error = 0x%x", uErr);
    843992        }
    844993        else
    845             logStringW(hModule, L"UninstallNetLwf: doNetCfgInit failed, error = 0x%x", uErr);
     994            logStringF(hModule, "UninstallNetLwf: doNetCfgInit failed, error = 0x%x", uErr);
    846995    }
    847996    __finally
     
    8791028    {
    8801029
    881         logStringW(hModule, L"InstallNetLwf: Installing NetLwf");
     1030        logStringF(hModule, "InstallNetLwf: Installing NetLwf");
    8821031
    8831032        uErr = doNetCfgInit(hModule, &pNetCfg, TRUE);
     
    9011050                    HRESULT hr = VBoxNetCfgWinNetLwfInstall(pNetCfg, wszInf);
    9021051                    if (FAILED(hr))
    903                         logStringW(hModule, L"InstallNetLwf: VBoxNetCfgWinNetLwfInstall failed, error = 0x%x", hr);
     1052                        logStringF(hModule, "InstallNetLwf: VBoxNetCfgWinNetLwfInstall failed, error = 0x%x", hr);
    9041053
    9051054                    uErr = errorConvertFromHResult(hModule, hr);
     
    9071056                else
    9081057                {
    909                     logStringW(hModule, L"vboxNetFltQueryInfArray: Empty installation directory");
     1058                    logStringF(hModule, "vboxNetFltQueryInfArray: Empty installation directory");
    9101059                    uErr = ERROR_GEN_FAILURE;
    9111060                }
    9121061            }
    9131062            else
    914                 logStringW(hModule, L"vboxNetFltQueryInfArray: MsiGetPropertyW failed, error = 0x%x", uErr);
     1063                logStringF(hModule, "vboxNetFltQueryInfArray: MsiGetPropertyW failed, error = 0x%x", uErr);
    9151064
    9161065            VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE);
    9171066
    918             logStringW(hModule, L"InstallNetLwf: Done");
     1067            logStringF(hModule, "InstallNetLwf: Done");
    9191068        }
    9201069        else
    921             logStringW(hModule, L"InstallNetLwf: doNetCfgInit failed, error = 0x%x", uErr);
     1070            logStringF(hModule, "InstallNetLwf: doNetCfgInit failed, error = 0x%x", uErr);
    9221071    }
    9231072    __finally
     
    10081157    BOOL fSetupModeInteractive = SetupSetNonInteractiveMode(FALSE);
    10091158
    1010     logStringW(hModule, L"CreateHostOnlyInterface: Creating host-only interface");
     1159    logStringF(hModule, "CreateHostOnlyInterface: Creating host-only interface");
    10111160
    10121161    HRESULT hr = E_FAIL;
     
    10211170        if (cchMpInf)
    10221171        {
    1023             logStringW(hModule, L"CreateHostOnlyInterface: NetAdpDir property = %s", wszMpInf);
     1172            logStringF(hModule, "CreateHostOnlyInterface: NetAdpDir property = %s", wszMpInf);
    10241173            if (wszMpInf[cchMpInf - 1] != L'\\')
    10251174            {
     
    10321181            fIsFile = true;
    10331182
    1034             logStringW(hModule, L"CreateHostOnlyInterface: Resulting INF path = %s", pwszInfPath);
     1183            logStringF(hModule, "CreateHostOnlyInterface: Resulting INF path = %s", pwszInfPath);
    10351184        }
    10361185        else
    1037             logStringW(hModule, L"CreateHostOnlyInterface: VBox installation path is empty");
     1186            logStringF(hModule, "CreateHostOnlyInterface: VBox installation path is empty");
    10381187    }
    10391188    else
    1040         logStringW(hModule, L"CreateHostOnlyInterface: Unable to retrieve VBox installation path, error = 0x%x", uErr);
     1189        logStringF(hModule, "CreateHostOnlyInterface: Unable to retrieve VBox installation path, error = 0x%x", uErr);
    10411190
    10421191    /* Make sure the inf file is installed. */
    10431192    if (pwszInfPath != NULL && fIsFile)
    10441193    {
    1045         logStringW(hModule, L"CreateHostOnlyInterface: Calling VBoxDrvCfgInfInstall(%s)", pwszInfPath);
     1194        logStringF(hModule, "CreateHostOnlyInterface: Calling VBoxDrvCfgInfInstall(%s)", pwszInfPath);
    10461195        hr = VBoxDrvCfgInfInstall(pwszInfPath);
    1047         logStringW(hModule, L"CreateHostOnlyInterface: VBoxDrvCfgInfInstall returns 0x%x", hr);
     1196        logStringF(hModule, "CreateHostOnlyInterface: VBoxDrvCfgInfInstall returns 0x%x", hr);
    10481197        if (FAILED(hr))
    1049             logStringW(hModule, L"CreateHostOnlyInterface: Failed to install INF file, error = 0x%x", hr);
     1198            logStringF(hModule, "CreateHostOnlyInterface: Failed to install INF file, error = 0x%x", hr);
    10501199    }
    10511200
     
    10591208            if (fRebootRequired)
    10601209            {
    1061                 logStringW(hModule, L"CreateHostOnlyInterface: Reboot required for update, setting REBOOT property to force");
     1210                logStringF(hModule, "CreateHostOnlyInterface: Reboot required for update, setting REBOOT property to force");
    10621211                HRESULT hr2 = MsiSetPropertyW(hModule, L"REBOOT", L"Force");
    10631212                if (hr2 != ERROR_SUCCESS)
    1064                     logStringW(hModule, L"CreateHostOnlyInterface: Failed to set REBOOT property for update, error = 0x%x", hr2);
     1213                    logStringF(hModule, "CreateHostOnlyInterface: Failed to set REBOOT property for update, error = 0x%x", hr2);
    10651214            }
    10661215        }
     
    10681217        {
    10691218            //in fail case call CreateHostOnlyInterface
    1070             logStringW(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinUpdateHostOnlyNetworkInterface failed, hr = 0x%x", hr);
    1071             logStringW(hModule, L"CreateHostOnlyInterface: calling VBoxNetCfgWinCreateHostOnlyNetworkInterface");
     1219            logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinUpdateHostOnlyNetworkInterface failed, hr = 0x%x", hr);
     1220            logStringF(hModule, "CreateHostOnlyInterface: calling VBoxNetCfgWinCreateHostOnlyNetworkInterface");
    10721221#ifdef VBOXNETCFG_DELAYEDRENAME
    10731222            BSTR devId;
     
    10761225            hr = VBoxNetCfgWinCreateHostOnlyNetworkInterface(pwszInfPath, fIsFile, NULL, &guid, NULL, NULL);
    10771226#endif /* !VBOXNETCFG_DELAYEDRENAME */
    1078             logStringW(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface returns 0x%x", hr);
     1227            logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface returns 0x%x", hr);
    10791228            if (SUCCEEDED(hr))
    10801229            {
    10811230                ULONG ip = inet_addr("192.168.56.1");
    10821231                ULONG mask = inet_addr("255.255.255.0");
    1083                 logStringW(hModule, L"CreateHostOnlyInterface: calling VBoxNetCfgWinEnableStaticIpConfig");
     1232                logStringF(hModule, "CreateHostOnlyInterface: calling VBoxNetCfgWinEnableStaticIpConfig");
    10841233                hr = VBoxNetCfgWinEnableStaticIpConfig(&guid, ip, mask);
    1085                 logStringW(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig returns 0x%x", hr);
     1234                logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig returns 0x%x", hr);
    10861235                if (FAILED(hr))
    1087                     logStringW(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig failed, error = 0x%x", hr);
     1236                    logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig failed, error = 0x%x", hr);
    10881237#ifdef VBOXNETCFG_DELAYEDRENAME
    10891238                hr = VBoxNetCfgWinRenameHostOnlyConnection(&guid, devId, NULL);
    10901239                if (FAILED(hr))
    1091                     logStringW(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinRenameHostOnlyConnection failed, error = 0x%x", hr);
     1240                    logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinRenameHostOnlyConnection failed, error = 0x%x", hr);
    10921241                SysFreeString(devId);
    10931242#endif /* VBOXNETCFG_DELAYEDRENAME */
    10941243            }
    10951244            else
    1096                 logStringW(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface failed, error = 0x%x", hr);
     1245                logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface failed, error = 0x%x", hr);
    10971246        }
    10981247    }
    10991248
    11001249    if (SUCCEEDED(hr))
    1101         logStringW(hModule, L"CreateHostOnlyInterface: Creating host-only interface done");
     1250        logStringF(hModule, "CreateHostOnlyInterface: Creating host-only interface done");
    11021251
    11031252    /* Restore original setup mode. */
    1104     logStringW(hModule, L"CreateHostOnlyInterface: Almost done...");
     1253    logStringF(hModule, "CreateHostOnlyInterface: Almost done...");
    11051254    if (fSetupModeInteractive)
    11061255        SetupSetNonInteractiveMode(fSetupModeInteractive);
     
    11101259#endif /* VBOX_WITH_NETFLT */
    11111260
    1112     logStringW(hModule, L"CreateHostOnlyInterface: Returns success (ignoring all failures)");
     1261    logStringF(hModule, "CreateHostOnlyInterface: Returns success (ignoring all failures)");
    11131262    /* Never fail the install even if we did not succeed. */
    11141263    return ERROR_SUCCESS;
     
    11301279    netCfgLoggerEnable(hModule);
    11311280
    1132     logStringW(hModule, L"RemoveHostOnlyInterfaces: Removing all host-only interfaces");
     1281    logStringF(hModule, "RemoveHostOnlyInterfaces: Removing all host-only interfaces");
    11331282
    11341283    BOOL fSetupModeInteractive = SetupSetNonInteractiveMode(FALSE);
     
    11401289        if (FAILED(hr))
    11411290        {
    1142             logStringW(hModule, L"RemoveHostOnlyInterfaces: NetAdp uninstalled successfully, but failed to remove INF files");
     1291            logStringF(hModule, "RemoveHostOnlyInterfaces: NetAdp uninstalled successfully, but failed to remove INF files");
    11431292        }
    11441293        else
    1145             logStringW(hModule, L"RemoveHostOnlyInterfaces: NetAdp uninstalled successfully");
     1294            logStringF(hModule, "RemoveHostOnlyInterfaces: NetAdp uninstalled successfully");
    11461295
    11471296    }
    11481297    else
    1149         logStringW(hModule, L"RemoveHostOnlyInterfaces: NetAdp uninstall failed, hr = 0x%x", hr);
     1298        logStringF(hModule, "RemoveHostOnlyInterfaces: NetAdp uninstall failed, hr = 0x%x", hr);
    11501299
    11511300    /* Restore original setup mode. */
     
    11701319    netCfgLoggerEnable(hModule);
    11711320
    1172     logStringW(hModule, L"StopHostOnlyInterfaces: Stopping all host-only interfaces");
     1321    logStringF(hModule, "StopHostOnlyInterfaces: Stopping all host-only interfaces");
    11731322
    11741323    BOOL fSetupModeInteractive = SetupSetNonInteractiveMode(FALSE);
     
    11771326    if (SUCCEEDED(hr))
    11781327    {
    1179         logStringW(hModule, L"StopHostOnlyInterfaces: Disabling host interfaces was successful, hr = 0x%x", hr);
     1328        logStringF(hModule, "StopHostOnlyInterfaces: Disabling host interfaces was successful, hr = 0x%x", hr);
    11801329    }
    11811330    else
    1182         logStringW(hModule, L"StopHostOnlyInterfaces: Disabling host interfaces failed, hr = 0x%x", hr);
     1331        logStringF(hModule, "StopHostOnlyInterfaces: Disabling host interfaces failed, hr = 0x%x", hr);
    11831332
    11841333    /* Restore original setup mode. */
     
    12031352    netCfgLoggerEnable(hModule);
    12041353
    1205     logStringW(hModule, L"UpdateHostOnlyInterfaces: Updating all host-only interfaces");
     1354    logStringF(hModule, "UpdateHostOnlyInterfaces: Updating all host-only interfaces");
    12061355
    12071356    BOOL fSetupModeInteractive = SetupSetNonInteractiveMode(FALSE);
     
    12161365        if (cchMpInf)
    12171366        {
    1218             logStringW(hModule, L"UpdateHostOnlyInterfaces: NetAdpDir property = %s", wszMpInf);
     1367            logStringF(hModule, "UpdateHostOnlyInterfaces: NetAdpDir property = %s", wszMpInf);
    12191368            if (wszMpInf[cchMpInf - 1] != L'\\')
    12201369            {
     
    12271376            fIsFile = true;
    12281377
    1229             logStringW(hModule, L"UpdateHostOnlyInterfaces: Resulting INF path = %s", pwszInfPath);
     1378            logStringF(hModule, "UpdateHostOnlyInterfaces: Resulting INF path = %s", pwszInfPath);
    12301379
    12311380            DWORD attrFile = GetFileAttributesW(pwszInfPath);
     
    12331382            {
    12341383                DWORD dwErr = GetLastError();
    1235                 logStringW(hModule, L"UpdateHostOnlyInterfaces: File \"%s\" not found, dwErr=%ld",
     1384                logStringF(hModule, "UpdateHostOnlyInterfaces: File \"%s\" not found, dwErr=%ld",
    12361385                           pwszInfPath, dwErr);
    12371386            }
    12381387            else
    12391388            {
    1240                 logStringW(hModule, L"UpdateHostOnlyInterfaces: File \"%s\" exists",
     1389                logStringF(hModule, "UpdateHostOnlyInterfaces: File \"%s\" exists",
    12411390                           pwszInfPath);
    12421391
     
    12471396                    if (fRebootRequired)
    12481397                    {
    1249                         logStringW(hModule, L"UpdateHostOnlyInterfaces: Reboot required, setting REBOOT property to force");
     1398                        logStringF(hModule, "UpdateHostOnlyInterfaces: Reboot required, setting REBOOT property to force");
    12501399                        HRESULT hr2 = MsiSetPropertyW(hModule, L"REBOOT", L"Force");
    12511400                        if (hr2 != ERROR_SUCCESS)
    1252                             logStringW(hModule, L"UpdateHostOnlyInterfaces: Failed to set REBOOT property, error = 0x%x", hr2);
     1401                            logStringF(hModule, "UpdateHostOnlyInterfaces: Failed to set REBOOT property, error = 0x%x", hr2);
    12531402                    }
    12541403                }
    12551404                else
    1256                     logStringW(hModule, L"UpdateHostOnlyInterfaces: VBoxNetCfgWinUpdateHostOnlyNetworkInterface failed, hr = 0x%x", hr);
     1405                    logStringF(hModule, "UpdateHostOnlyInterfaces: VBoxNetCfgWinUpdateHostOnlyNetworkInterface failed, hr = 0x%x", hr);
    12571406            }
    12581407        }
    12591408        else
    1260             logStringW(hModule, L"UpdateHostOnlyInterfaces: VBox installation path is empty");
     1409            logStringF(hModule, "UpdateHostOnlyInterfaces: VBox installation path is empty");
    12611410    }
    12621411    else
    1263         logStringW(hModule, L"UpdateHostOnlyInterfaces: Unable to retrieve VBox installation path, error = 0x%x", uErr);
     1412        logStringF(hModule, "UpdateHostOnlyInterfaces: Unable to retrieve VBox installation path, error = 0x%x", uErr);
    12641413
    12651414    /* Restore original setup mode. */
     
    12961445    __try
    12971446    {
    1298         logStringW(hModule, L"Uninstalling NetAdp");
     1447        logStringF(hModule, "Uninstalling NetAdp");
    12991448
    13001449        uErr = doNetCfgInit(hModule, &pNetCfg, TRUE);
     
    13031452            HRESULT hr = VBoxNetCfgWinNetAdpUninstall(pNetCfg, pwszId);
    13041453            if (hr != S_OK)
    1305                 logStringW(hModule, L"UninstallNetAdp: VBoxNetCfgWinUninstallComponent failed, error = 0x%x", hr);
     1454                logStringF(hModule, "UninstallNetAdp: VBoxNetCfgWinUninstallComponent failed, error = 0x%x", hr);
    13061455
    13071456            uErr = errorConvertFromHResult(hModule, hr);
     
    13091458            VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE);
    13101459
    1311             logStringW(hModule, L"Uninstalling NetAdp done, error = 0x%x", uErr);
     1460            logStringF(hModule, "Uninstalling NetAdp done, error = 0x%x", uErr);
    13121461        }
    13131462        else
    1314             logStringW(hModule, L"UninstallNetAdp: doNetCfgInit failed, error = 0x%x", uErr);
     1463            logStringF(hModule, "UninstallNetAdp: doNetCfgInit failed, error = 0x%x", uErr);
    13151464    }
    13161465    __finally
     
    13981547}
    13991548
     1549/** @todo r=andy BUGBUG WTF! Why do we a) set the rc to 0 (success), and b) need this macro at all!? */
    14001550#define SetErrBreak(args) \
    14011551    if (1) { \
    14021552        rc = 0; \
    1403         logStringW args; \
     1553        logStringF args; \
    14041554        break; \
    14051555    } else do {} while (0)
     
    14251575            LONG lStatus = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszRegLocation, 0, KEY_READ, &hkeyNetwork);
    14261576            if ((lStatus != ERROR_SUCCESS) || !hkeyNetwork)
    1427                 SetErrBreak((hModule, L"VBox HostInterfaces: Host interface network was not found in registry (%s)! [1]",
     1577                SetErrBreak((hModule, "VBox HostInterfaces: Host interface network was not found in registry (%s)! [1]",
    14281578                             wszRegLocation));
    14291579
    14301580            lStatus = RegOpenKeyExW(hkeyNetwork, L"Connection", 0, KEY_READ, &hkeyConnection);
    14311581            if ((lStatus != ERROR_SUCCESS) || !hkeyConnection)
    1432                 SetErrBreak((hModule, L"VBox HostInterfaces: Host interface network was not found in registry (%s)! [2]",
     1582                SetErrBreak((hModule, "VBox HostInterfaces: Host interface network was not found in registry (%s)! [2]",
    14331583                             wszRegLocation));
    14341584
     
    14381588                                       &dwKeyType, (LPBYTE)&wszPnPInstanceId[0], &len);
    14391589            if ((lStatus != ERROR_SUCCESS) || (dwKeyType != REG_SZ))
    1440                 SetErrBreak((hModule, L"VBox HostInterfaces: Host interface network was not found in registry (%s)! [3]",
     1590                SetErrBreak((hModule, "VBox HostInterfaces: Host interface network was not found in registry (%s)! [3]",
    14411591                             wszRegLocation));
    14421592        }
     
    14731623            if (hDeviceInfo == INVALID_HANDLE_VALUE)
    14741624            {
    1475                 logStringW(hModule, L"VBox HostInterfaces: SetupDiGetClassDevs failed (0x%08X)!", GetLastError());
    1476                 SetErrBreak((hModule, L"VBox HostInterfaces: Uninstallation failed!"));
     1625                logStringF(hModule, "VBox HostInterfaces: SetupDiGetClassDevs failed (0x%08X)!", GetLastError());
     1626                SetErrBreak((hModule, "VBox HostInterfaces: Uninstallation failed!"));
    14771627            }
    14781628
     
    15761726                if (!fResult)
    15771727                {
    1578                     logStringW(hModule, L"VBox HostInterfaces: SetupDiSetSelectedDevice failed (0x%08X)!", GetLastError());
    1579                     SetErrBreak((hModule, L"VBox HostInterfaces: Uninstallation failed!"));
     1728                    logStringF(hModule, "VBox HostInterfaces: SetupDiSetSelectedDevice failed (0x%08X)!", GetLastError());
     1729                    SetErrBreak((hModule, "VBox HostInterfaces: Uninstallation failed!"));
    15801730                }
    15811731
     
    15831733                if (!fResult)
    15841734                {
    1585                     logStringW(hModule, L"VBox HostInterfaces: SetupDiCallClassInstaller (DIF_REMOVE) failed (0x%08X)!", GetLastError());
    1586                     SetErrBreak((hModule, L"VBox HostInterfaces: Uninstallation failed!"));
     1735                    logStringF(hModule, "VBox HostInterfaces: SetupDiCallClassInstaller (DIF_REMOVE) failed (0x%08X)!", GetLastError());
     1736                    SetErrBreak((hModule, "VBox HostInterfaces: Uninstallation failed!"));
    15871737                }
    15881738            }
    15891739            else
    1590                 SetErrBreak((hModule, L"VBox HostInterfaces: Host interface network device not found!"));
     1740                SetErrBreak((hModule, "VBox HostInterfaces: Host interface network device not found!"));
    15911741        } while (0);
    15921742
     
    16061756    if (lStatus == ERROR_SUCCESS)
    16071757    {
    1608         logStringW(hModule, L"VBox HostInterfaces: Enumerating interfaces ...");
     1758        logStringF(hModule, "VBox HostInterfaces: Enumerating interfaces ...");
    16091759        for (int i = 0; ; ++i)
    16101760        {
     
    16171767                {
    16181768                    case ERROR_NO_MORE_ITEMS:
    1619                         logStringW(hModule, L"VBox HostInterfaces: No interfaces found.");
     1769                        logStringF(hModule, "VBox HostInterfaces: No interfaces found.");
    16201770                        break;
    16211771                    default:
    1622                         logStringW(hModule, L"VBox HostInterfaces: Enumeration failed: %ld", lStatus);
     1772                        logStringF(hModule, "VBox HostInterfaces: Enumeration failed: %ld", lStatus);
    16231773                        break;
    16241774                }
     
    16281778            if (isTAPDevice(wszNetworkGUID))
    16291779            {
    1630                 logStringW(hModule, L"VBox HostInterfaces: Removing interface \"%s\" ...", wszNetworkGUID);
     1780                logStringF(hModule, "VBox HostInterfaces: Removing interface \"%s\" ...", wszNetworkGUID);
    16311781                removeNetworkInterface(hModule, wszNetworkGUID);
    16321782                lStatus = RegDeleteKeyW(hCtrlNet, wszNetworkGUID);
     
    16341784        }
    16351785        RegCloseKey(hCtrlNet);
    1636         logStringW(hModule, L"VBox HostInterfaces: Removing interfaces done.");
     1786        logStringF(hModule, "VBox HostInterfaces: Removing interfaces done.");
    16371787    }
    16381788    return ERROR_SUCCESS;
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