VirtualBox

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


Ignore:
Timestamp:
Jan 19, 2022 10:52:09 AM (3 years ago)
Author:
vboxsync
Message:

Installer/win/InstallHelper: Don't use IPRT in the helper DLL, causes trouble in ASAN build as we don't have a non-ASAN IPRT library. This saves a big of space too and make procRun do a non-polling wait for the child progress. Reworked the python path detection code a bit too, won't return empty paths any more. The procRun now returns a failure on non-zero child exit. bugref:8489 bugref:9841

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp

    r93115 r93340  
    22/** @file
    33 * VBoxCommon - Misc helper routines for install helper.
     4 *
     5 * This is used by internal/serial.cpp and VBoxInstallHelper.cpp.
    46 */
    57
     
    6062}
    6163
     64#if 0 /* unused */
    6265/**
    6366 * Retrieves a MSI property (in UTF-8).
     
    9093    return rc;
    9194}
     95#endif
    9296
    9397UINT VBoxSetMsiProp(MSIHANDLE hMsi, WCHAR *pwszName, WCHAR *pwszValue)
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxInstallHelper.cpp

    r93335 r93340  
    2323# include "VBox/VBoxNetCfg-win.h"
    2424# include "VBox/VBoxDrvCfg-win.h"
    25 #endif /* VBOX_WITH_NETFLT */
     25#endif
    2626
    2727#include <VBox/version.h>
     
    4343#include <devguid.h>
    4444
    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>
     45#include <iprt/alloca.h>
     46#include <iprt/string.h> /* RT_ZERO */
     47#include <iprt/path.h>   /* RTPATH_MAX, RTPATH_IS_SLASH */
    5148
    5249#include <iprt/win/objbase.h>
     
    7471
    7572
     73
     74/**
     75 * DLL entry point.
     76 */
    7677BOOL WINAPI DllMain(HANDLE hInst, ULONG uReason, LPVOID pReserved)
    7778{
    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 
     79    RT_NOREF(hInst, uReason, pReserved);
    9980    return TRUE;
    10081}
    10182
    102 static int logStringF(MSIHANDLE hInstall, const char *pcszFmt, ...)
     83/**
     84 * Format and add message to the MSI log.
     85 *
     86 * UTF-16 strings are formatted using '%s' (lowercase).
     87 * ANSI strings are formatted using '%S' (uppercase).
     88 */
     89static UINT logStringF(MSIHANDLE hInstall, const wchar_t *pwszFmt, ...)
    10390{
    10491    PMSIHANDLE hMSI = MsiCreateRecord(2 /* cParms */);
    105     if (!hMSI)
    106         return VERR_ACCESS_DENIED;
    107 
    108     RTUTF16 wszBuf[_1K] = { 0 };
    109 
    110     va_list va;
    111     va_start(va, pcszFmt);
    112     ssize_t cwch = RTUtf16PrintfV(wszBuf, RT_ELEMENTS(wszBuf), pcszFmt, va);
    113     va_end(va);
    114 
    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;
     92    if (hMSI)
     93    {
     94        wchar_t wszBuf[RTPATH_MAX + 256];
     95        va_list va;
     96        va_start(va, pwszFmt);
     97        ssize_t cwc = _vsnwprintf(wszBuf, RT_ELEMENTS(wszBuf), pwszFmt, va);
     98        va_end(va);
     99        wszBuf[RT_ELEMENTS(wszBuf) - 1] = '\0';
     100
     101        MsiRecordSetStringW(hMSI, 0, wszBuf);
     102        MsiProcessMessage(hInstall, INSTALLMESSAGE(INSTALLMESSAGE_INFO), hMSI);
     103
     104        MsiCloseHandle(hMSI);
     105        return cwc < RT_ELEMENTS(wszBuf) ? ERROR_SUCCESS : ERROR_BUFFER_OVERFLOW;
     106    }
     107    return ERROR_ACCESS_DENIED;
    123108}
    124109
     
    144129
    145130/**
    146  * Waits for a started process to terminate.
    147  *
    148  * @returns VBox status code.
    149  * @param   Process             Handle of process to wait for.
    150  * @param   msTimeout           Timeout (in ms) to wait for process to terminate.
    151  * @param   pProcSts            Pointer to process status on return.
    152  */
    153 static int procWait(RTPROCESS Process, RTMSINTERVAL msTimeout, PRTPROCSTATUS pProcSts)
    154 {
    155     uint64_t tsStartMs = RTTimeMilliTS();
    156 
    157     while (RTTimeMilliTS() - tsStartMs <= msTimeout)
    158     {
    159         int rc = RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, pProcSts);
    160         if (rc == VERR_PROCESS_RUNNING)
    161             Sleep(1); /* Don't spin uncontrolled. duh. */
    162         else if (RT_FAILURE(rc))
    163             return rc;
    164         else
    165         {
    166             if (   pProcSts->iStatus   != 0
    167                 || pProcSts->enmReason != RTPROCEXITREASON_NORMAL)
    168             {
    169                 /** @todo r=bird: This isn't returned, so what's the point here?  */
    170                 rc = VERR_GENERAL_FAILURE; /** @todo Fudge! */
    171             }
    172             return VINF_SUCCESS;
    173         }
    174     }
    175 
    176     return VERR_TIMEOUT;
    177 }
    178 
    179 /**
    180131 * Runs an executable on the OS.
    181132 *
    182  * @returns VBox status code.
    183  * @param   hModule             Windows installer module handle.
    184  * @param   pszImage            Absolute path of executable to run.
    185  * @param   papszArgs           Pointer to command line arguments to use for calling the executable.
     133 * @returns Windows error code.
     134 * @param   hModule     Windows installer module handle.
     135 * @param   pwszImage   The executable to run.
     136 * @param   pwszArgs    The arguments (command line w/o executable).
    186137 */
    187 static int procRun(MSIHANDLE hModule, const char *pszImage, const char * const *papszArgs)
    188 {
    189 #ifdef DEBUG
    190     uint32_t  const fProcess = 0;
    191 #else
    192     uint32_t  const fProcess = RTPROC_FLAGS_HIDDEN;
     138static UINT procRun(MSIHANDLE hModule, const wchar_t *pwszImage, wchar_t const *pwszArgs)
     139{
     140    /*
     141     * Construct a full command line.
     142     */
     143    size_t const cwcImage = wcslen(pwszImage);
     144    size_t const cwcArgs  = wcslen(pwszArgs);
     145
     146    wchar_t *pwszCmdLine = (wchar_t *)alloca((1 + cwcImage + 1 + 1 + cwcArgs + 1) * sizeof(wchar_t));
     147    pwszCmdLine[0] = '"';
     148    memcpy(&pwszCmdLine[1], pwszImage, cwcImage * sizeof(wchar_t));
     149    pwszCmdLine[1 + cwcImage] = '"';
     150    pwszCmdLine[1 + cwcImage + 1] = ' ';
     151    memcpy(&pwszCmdLine[1 + cwcImage + 1 + 1], pwszArgs, (cwcArgs + 1) * sizeof(wchar_t));
     152
     153    /*
     154     * Construct startup info.
     155     */
     156    STARTUPINFOW StartupInfo;
     157    RT_ZERO(StartupInfo);
     158    StartupInfo.cb          = sizeof(StartupInfo);
     159    StartupInfo.hStdInput  = GetStdHandle(STD_INPUT_HANDLE);
     160    StartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
     161    StartupInfo.hStdError  = GetStdHandle(STD_ERROR_HANDLE);
     162    StartupInfo.dwFlags     = STARTF_USESTDHANDLES;
     163#ifndef DEBUG
     164    StartupInfo.dwFlags    |= STARTF_USESHOWWINDOW;
     165    StartupInfo.wShowWindow = SW_HIDE;
    193166#endif
    194     RTPROCESS       Process  = NIL_RTPROCESS;
    195     int rc = RTProcCreate(pszImage, papszArgs, RTENV_DEFAULT, fProcess, &Process);
    196     if (RT_SUCCESS(rc))
    197     {
    198         RTPROCSTATUS ProcSts;
    199         RT_ZERO(ProcSts);
    200 
    201         rc = procWait(Process, RT_MS_30SEC, &ProcSts);
    202 
    203         if (RT_FAILURE(rc))
    204             logStringF(hModule, "procRun: Waiting for process \"%s\" failed with %Rrc (process status: %d (%#x), reason: %d)\n",
    205                        pszImage, rc, ProcSts.iStatus, ProcSts.iStatus, ProcSts.enmReason);
    206         else if (   ProcSts.iStatus   != 0
    207                  || ProcSts.enmReason != RTPROCEXITREASON_NORMAL)
    208             logStringF(hModule, "procRun: Process \"%s\" terminated with iStatus=%d (%#x) and enmReason=%d\n",
    209                        pszImage, ProcSts.iStatus, ProcSts.iStatus, ProcSts.enmReason);
     167
     168    /*
     169     * Start it.
     170     */
     171    UINT rcWin;
     172    PROCESS_INFORMATION ChildInfo = { NULL, NULL, 0, 0 };
     173    if (CreateProcessW(pwszImage, pwszCmdLine, NULL /*pProcessAttribs*/, NULL /*pThreadAttribs*/, TRUE /*fInheritHandles*/,
     174                       0 /*fFlags*/, NULL /*pwszEnv*/, NULL /*pwszCwd*/, &StartupInfo, &ChildInfo))
     175    {
     176        logStringF(hModule, L"procRun: Info: Started process %u: %s", ChildInfo.dwProcessId, pwszCmdLine);
     177        CloseHandle(ChildInfo.hThread);
     178        DWORD const dwWait = WaitForSingleObject(ChildInfo.hProcess, RT_MS_30SEC);
     179        DWORD dwExitCode = 0xf00dface;
     180        if (GetExitCodeProcess(ChildInfo.hProcess, &dwExitCode))
     181        {
     182            if (dwExitCode == 0)
     183            {
     184                logStringF(hModule, L"procRun: Info: Process '%s' terminated exit code zero", pwszCmdLine);
     185                rcWin = ERROR_SUCCESS;
     186            }
     187            else
     188            {
     189                logStringF(hModule, L"procRun: Process '%s' terminated with non-zero exit code: %u (%#x)",
     190                           pwszCmdLine, dwExitCode, dwExitCode);
     191                rcWin = ERROR_GEN_FAILURE;
     192            }
     193        }
     194        else
     195        {
     196            rcWin = GetLastError();
     197            logStringF(hModule, L"procRun: Process '%s' is probably still running: rcWin=%u dwWait=%u (%#x)",
     198                       pwszCmdLine, rcWin, dwWait, dwWait);
     199        }
    210200    }
    211201    else
    212         logStringF(hModule, "procRun: Creating process for \"%s\" failed with %Rrc\n", pszImage, rc);
    213 
    214     return rc;
     202    {
     203        rcWin = GetLastError();
     204        logStringF(hModule, L"procRun: Creating process '%s' failed: rcWin=%u\n", pwszCmdLine, rcWin);
     205    }
     206    return rcWin;
    215207}
    216208
     
    218210 * Tries to retrieve the Python installation path on the system, extended version.
    219211 *
    220  * @returns VBox status code.
    221  * @param   hModule             Windows installer module handle.
    222  * @param   hKeyRoot            Registry root key to use, e.g. HKEY_LOCAL_MACHINE.
    223  * @param   ppszPath            Where to store the allocated Python path on success.
    224  *                              Must be free'd by the caller using RTStrFree().
    225  * @remarks r=bird: This may return VINF_SUCCESS and *ppszPath = NULL if there
    226  *          are no keys under "SOFTWARE\\Python\\PythonCore" or none of them
    227  *          has an "InstallPath" key.  It seems to work out fine, though, as
    228  *          we'll just use python.exe w/o a full path.
    229  *
    230  * @todo    r=bird: On a more serious note, caller ASSUMES the returned path
    231  *          ends with a slash as it just appends the "python.exe" string to it.
     212 * @returns Windows error code.
     213 * @param   hModule         Windows installer module handle.
     214 * @param   hKeyRoot        Registry root key to use, e.g. HKEY_LOCAL_MACHINE.
     215 * @param   pwszPythonPath  Buffer to return the path for python.exe in.
     216 * @param   cwcPythonPath   Buffer size in UTF-16 units.
     217 * @param   fReturnExe      Return the path to python.exe if true, otherwise
     218 *                          just the python install directory.
    232219 */
    233 static int getPythonPathEx(MSIHANDLE hModule, HKEY hKeyRoot, char **ppszPath)
    234 {
    235     HKEY hkPythonCore = NULL;
    236     LSTATUS dwErr = RegOpenKeyExW(hKeyRoot, L"SOFTWARE\\Python\\PythonCore", 0, KEY_READ, &hkPythonCore);
     220static UINT getPythonPathEx(MSIHANDLE hModule, HKEY hKeyRoot, wchar_t *pwszPythonPath, size_t cwcPythonPath, bool fReturnExe)
     221{
     222    *pwszPythonPath = '\0';
     223
     224    /*
     225     * Enumerate the subkeys of python core installation key.
     226     *
     227     * Note: The loop ASSUMES that later found versions are higher, e.g. newer
     228     *       Python versions.  For now we always go by the newest version.
     229     */
     230    HKEY hKeyPythonCore = NULL;
     231    LSTATUS dwErr = RegOpenKeyExW(hKeyRoot, L"SOFTWARE\\Python\\PythonCore", 0, KEY_READ, &hKeyPythonCore);
    237232    if (dwErr != ERROR_SUCCESS)
    238         return RTErrConvertFromWin32(dwErr);
    239 
    240     char *pszPythonPath = NULL;
    241 
    242     int rc = VINF_SUCCESS;
    243 
    244     /* Note: The loop ASSUMES that later found versions are higher, e.g. newer Python versions.
    245      *       For now we always go by the newest version. */
    246     for (int i = 0;; ++i)
    247     {
    248         RTUTF16 wszKey[RTPATH_MAX];
    249         DWORD   dwKey     = sizeof(wszKey);
     233        return dwErr;
     234
     235    UINT rcWinRet = ERROR_PATH_NOT_FOUND;
     236    for (DWORD i = 0; i < 16384; ++i)
     237    {
     238        static wchar_t const s_wszInstallPath[] = L"\\InstallPath";
     239        static wchar_t const s_wszPythonExe[]   = L"python.exe";
     240
     241        /* Get key name: */
     242        wchar_t wszBuf[RTPATH_MAX + RT_MAX(RT_ELEMENTS(s_wszInstallPath), RT_ELEMENTS(s_wszPythonExe)) + 2];
     243        DWORD   cwcKeyNm  = RTPATH_MAX;
    250244        DWORD   dwKeyType = REG_SZ;
    251 
    252         /** @todo r=bird: Break on ERROR_NO_MORE_ITEMS, skip to the next one on
    253          *        errors. */
    254         dwErr = RegEnumKeyExW(hkPythonCore, i, wszKey, &dwKey, NULL, NULL, NULL, NULL);
    255         if (dwErr != ERROR_SUCCESS || dwKey <= 0)
     245        dwErr = RegEnumKeyExW(hKeyPythonCore, i, wszBuf, &cwcKeyNm, NULL, NULL, NULL, NULL);
     246        if (dwErr == ERROR_NO_MORE_ITEMS)
    256247            break;
    257         AssertBreakStmt(dwKey <= sizeof(wszKey), VERR_BUFFER_OVERFLOW);
    258 
    259         /** @todo r=bird: Waste of space + effort, just append "\\InstallPath" to
    260          *        wszKey, reserving sufficent room for it above. */
    261         RTUTF16 wszKey2[RTPATH_MAX];
    262         if (RTUtf16Printf(wszKey2, sizeof(wszKey2), "%ls\\InstallPath", wszKey) <= 0)
    263         {
    264             rc = VERR_BUFFER_OVERFLOW;
    265             break;
    266         }
    267 
    268         HKEY hkPythonInstPath = NULL;
    269         dwErr = RegOpenKeyExW(hkPythonCore, wszKey2, 0, KEY_READ,  &hkPythonInstPath);
    270248        if (dwErr != ERROR_SUCCESS)
    271249            continue;
    272 
    273         RTUTF16 wszVal[RTPATH_MAX] = { 0 };
    274         DWORD   cbValue = sizeof(wszVal) - sizeof(RTUTF16);
    275         dwErr = RegQueryValueExW(hkPythonInstPath, L"", NULL, &dwKeyType, (LPBYTE)wszVal, &cbValue);
    276         if (dwErr == ERROR_SUCCESS)
    277             logStringF(hModule, "getPythonPath: Path \"%ls\" found.", wszVal);
    278 
    279         if (pszPythonPath) /* Free former path, if any. */
    280         {
    281             RTStrFree(pszPythonPath);
    282             pszPythonPath = NULL;
    283         }
    284 
    285         rc = RTUtf16ToUtf8(wszVal, &pszPythonPath);
    286         AssertRCBreak(rc);
    287 
    288         if (!RTPathExists(pszPythonPath))
    289         {
    290             logStringF(hModule, "getPythonPath: Warning: Defined path \"%s\" does not exist, skipping.", wszVal);
    291             rc = VERR_PATH_NOT_FOUND;
    292         }
    293 
    294         RegCloseKey(hkPythonInstPath);
    295     }
    296 
    297     RegCloseKey(hkPythonCore);
    298 
    299     if (RT_FAILURE(rc))
    300         RTStrFree(pszPythonPath);
    301     else
    302         *ppszPath = pszPythonPath;
    303 
    304     return rc;
     250        if (dwKeyType != REG_SZ)
     251            continue;
     252        if (cwcKeyNm == 0)
     253            continue;
     254        NonStandardAssert(cwcKeyNm <= sizeof(wszBuf));
     255
     256        /* Try Open the InstallPath subkey: */
     257        memcpy(&wszBuf[cwcKeyNm], s_wszInstallPath, sizeof(s_wszInstallPath));
     258
     259        HKEY hKeyInstallPath = NULL;
     260        dwErr = RegOpenKeyExW(hKeyPythonCore, wszBuf, 0, KEY_READ, &hKeyInstallPath);
     261        if (dwErr != ERROR_SUCCESS)
     262            continue;
     263
     264        /* Query the value.  We double buffer this so we don't overwrite an okay
     265           return value with this.  Use the smaller of cwcPythonPath and wszValue
     266           so RegQueryValueExW can do all the buffer overflow checking for us.
     267           For paranoid reasons, we reserve a space for a terminator as well as
     268           a slash. (ASSUMES reasonably sized output buffer.) */
     269        NonStandardAssert(cwcPythonPath > RT_ELEMENTS(s_wszPythonExe) + 16);
     270        DWORD cbValue = (DWORD)RT_MIN(  cwcPythonPath * sizeof(wchar_t)
     271                                      - (fReturnExe ? sizeof(s_wszInstallPath) - sizeof(wchar_t) * 2 : sizeof(wchar_t) * 2),
     272                                      RTPATH_MAX * sizeof(wchar_t));
     273        DWORD dwValueType = REG_SZ;
     274        dwErr = RegQueryValueExW(hKeyInstallPath, L"", NULL, &dwValueType, (LPBYTE)wszBuf, &cbValue);
     275        RegCloseKey(hKeyInstallPath);
     276        if (   dwErr       == ERROR_SUCCESS
     277            && dwValueType == REG_SZ
     278            && cbValue     >= sizeof(L"C:\\") - sizeof(L""))
     279        {
     280            /* Find length in wchar_t unit w/o terminator: */
     281            DWORD cwc = cbValue / sizeof(wchar_t);
     282            while (cwc > 0 && wszBuf[cwc - 1] == '\0')
     283                cwc--;
     284            wszBuf[cwc] = '\0';
     285            if (cwc > 2)
     286            {
     287                /* Check if the path leads to a directory with a python.exe file in it. */
     288                if (!RTPATH_IS_SLASH(wszBuf[cwc - 1]))
     289                    wszBuf[cwc++] = '\\';
     290                memcpy(&wszBuf[cwc], s_wszPythonExe, sizeof(s_wszPythonExe));
     291                DWORD const fAttribs = GetFileAttributesW(wszBuf);
     292                if (fAttribs != INVALID_FILE_ATTRIBUTES)
     293                {
     294                    if (!(fAttribs & FILE_ATTRIBUTE_DIRECTORY))
     295                    {
     296                        /* Okay, we found something that can be returned. */
     297                        if (fReturnExe)
     298                            cwc += RT_ELEMENTS(s_wszPythonExe) - 1;
     299                        wszBuf[cwc] = '\0';
     300                        logStringF(hModule, L"getPythonPath: Found: \"%s\"", wszBuf);
     301
     302                        NonStandardAssert(cwcPythonPath > cwc);
     303                        memcpy(pwszPythonPath, wszBuf, cwc * sizeof(wchar_t));
     304                        pwszPythonPath[cwc] = '\0';
     305                        rcWinRet = ERROR_SUCCESS;
     306                    }
     307                    else
     308                        logStringF(hModule, L"getPythonPath: Warning: Skipping \"%s\": is a directory (%#x)", wszBuf, fAttribs);
     309                }
     310                else
     311                    logStringF(hModule, L"getPythonPath: Warning: Skipping \"%s\": Does not exist (%u)", wszBuf, GetLastError());
     312            }
     313        }
     314    }
     315
     316    RegCloseKey(hKeyPythonCore);
     317    if (rcWinRet != ERROR_SUCCESS)
     318        logStringF(hModule, L"getPythonPath: Unable to find python");
     319    return rcWinRet;
    305320}
    306321
     
    308323 * Retrieves the absolute path of the Python installation.
    309324 *
    310  * @returns VBox status code.
    311  * @param   hModule             Windows installer module handle.
    312  * @param   ppszPath            Where to store the absolute path of the Python installation.
    313  *                              Must be free'd by the caller.
     325 * @returns Windows error code.
     326 * @param   hModule         Windows installer module handle.
     327 * @param   pwszPythonPath  Buffer to return the path for python.exe in.
     328 * @param   cwcPythonPath   Buffer size in UTF-16 units.
     329 * @param   fReturnExe      Return the path to python.exe if true, otherwise
     330 *                          just the python install directory.
    314331 */
    315 static int getPythonPath(MSIHANDLE hModule, char **ppszPath)
    316 {
    317     int rc = getPythonPathEx(hModule, HKEY_LOCAL_MACHINE, ppszPath);
    318     if (RT_FAILURE(rc))
    319         rc = getPythonPathEx(hModule, HKEY_CURRENT_USER, ppszPath);
    320 
    321     return rc;
     332static UINT getPythonPath(MSIHANDLE hModule, wchar_t *pwszPythonPath, size_t cwcPythonPath, bool fReturnExe = false)
     333{
     334    UINT rcWin = getPythonPathEx(hModule, HKEY_LOCAL_MACHINE, pwszPythonPath, cwcPythonPath, fReturnExe);
     335    if (rcWin != ERROR_SUCCESS)
     336        rcWin = getPythonPathEx(hModule, HKEY_CURRENT_USER, pwszPythonPath, cwcPythonPath, fReturnExe);
     337    return rcWin;
    322338}
    323339
     
    325341 * Retrieves the absolute path of the Python executable.
    326342 *
    327  * @returns VBox status code.
    328  * @param   hModule             Windows installer module handle.
    329  * @param   ppszPythonExe       Where to store the absolute path of the Python executable.
    330  *                              Must be free'd by the caller.
     343 * @returns Windows error code.
     344 * @param   hModule         Windows installer module handle.
     345 * @param   pwszPythonExe   Buffer to return the path for python.exe in.
     346 * @param   cwcPythonExe    Buffer size in UTF-16 units.
    331347 */
    332 static int getPythonExe(MSIHANDLE hModule, char **ppszPythonExe)
    333 {
    334     int rc = getPythonPath(hModule, ppszPythonExe);
    335     if (RT_SUCCESS(rc))
    336         rc = RTStrAAppend(ppszPythonExe, "python.exe"); /** @todo Can this change? */
    337 
    338     return rc;
     348static UINT getPythonExe(MSIHANDLE hModule, wchar_t *pwszPythonExe, size_t cwcPythonExe)
     349{
     350    return getPythonPath(hModule, pwszPythonExe, cwcPythonExe, true /*fReturnExe*/);
    339351}
    340352
     
    344356 * @returns VBox status code, or error if depedencies are not met.
    345357 * @param   hModule             Windows installer module handle.
    346  * @param   pcszPythonExe       Path to Python interpreter image (.exe).
     358 * @param   pwszPythonExe       Path to Python interpreter image (.exe).
    347359 */
    348 static int checkPythonDependencies(MSIHANDLE hModule, const char *pcszPythonExe)
     360static int checkPythonDependencies(MSIHANDLE hModule, const wchar_t *pwszPythonExe)
    349361{
    350362    /*
     
    352364     * This is a prerequisite for setting up the VBox API.
    353365     */
    354     logStringF(hModule, "checkPythonDependencies: Checking for win32api extensions ...");
    355 
    356     const char *papszArgs[] = { pcszPythonExe, "-c", "import win32api", NULL};
    357 
    358     int rc = procRun(hModule, pcszPythonExe, papszArgs);
    359     if (RT_SUCCESS(rc))
    360         logStringF(hModule, "checkPythonDependencies: win32api found\n");
     366    logStringF(hModule, L"checkPythonDependencies: Checking for win32api extensions ...");
     367
     368    UINT rcWin = procRun(hModule, pwszPythonExe, L"-c \"import win32api\"");
     369    if (rcWin == ERROR_SUCCESS)
     370        logStringF(hModule, L"checkPythonDependencies: win32api found\n");
    361371    else
    362         logStringF(hModule, "checkPythonDependencies: Importing win32api failed with %Rrc\n", rc);
    363 
    364     return rc;
     372        logStringF(hModule, L"checkPythonDependencies: Importing win32api failed with %u (%#x)\n", rcWin, rcWin);
     373
     374    return rcWin;
    365375}
    366376
     
    378388UINT __stdcall IsPythonInstalled(MSIHANDLE hModule)
    379389{
    380     char *pszPythonPath;
    381     int rc = getPythonPath(hModule, &pszPythonPath);
    382     if (RT_SUCCESS(rc))
    383     {
    384         logStringF(hModule, "IsPythonInstalled: Python installation found at \"%s\"", pszPythonPath);
    385 
    386         PRTUTF16 pwszPythonPath;
    387         rc = RTStrToUtf16(pszPythonPath, &pwszPythonPath);
    388         if (RT_SUCCESS(rc))
    389         {
    390             VBoxSetMsiProp(hModule, L"VBOX_PYTHON_PATH", pwszPythonPath);
    391 
    392             RTUtf16Free(pwszPythonPath);
    393         }
    394         else
    395             logStringF(hModule, "IsPythonInstalled: Error: Unable to convert path, rc=%Rrc", rc);
    396 
    397         RTStrFree(pszPythonPath);
     390    wchar_t wszPythonPath[RTPATH_MAX];
     391    UINT rcWin = getPythonPath(hModule, wszPythonPath, RTPATH_MAX);
     392    if (rcWin == ERROR_SUCCESS)
     393    {
     394        logStringF(hModule, L"IsPythonInstalled: Python installation found at \"%s\"", wszPythonPath);
     395        VBoxSetMsiProp(hModule, L"VBOX_PYTHON_PATH", wszPythonPath);
     396        VBoxSetMsiProp(hModule, L"VBOX_PYTHON_INSTALLED", L"1");
    398397    }
    399398    else
    400         logStringF(hModule, "IsPythonInstalled: Error: No suitable Python installation found (%Rrc), skipping installation.", rc);
    401 
    402     if (RT_FAILURE(rc))
    403         logStringF(hModule, "IsPythonInstalled: Python seems not to be installed (%Rrc); please download + install the Python Core package.", rc);
    404 
    405     VBoxSetMsiProp(hModule, L"VBOX_PYTHON_INSTALLED", RT_SUCCESS(rc) ? L"1" : L"0");
     399    {
     400        logStringF(hModule, L"IsPythonInstalled: Error: No suitable Python installation found (%u), skipping installation.", rcWin);
     401        logStringF(hModule, L"IsPythonInstalled: Python seems not to be installed; please download + install the Python Core package.");
     402        VBoxSetMsiProp(hModule, L"VBOX_PYTHON_INSTALLED", L"0");
     403    }
    406404
    407405    return ERROR_SUCCESS; /* Never return failure. */
     
    420418UINT __stdcall ArePythonAPIDepsInstalled(MSIHANDLE hModule)
    421419{
    422     char *pszPythonExe;
    423     int rc = getPythonExe(hModule, &pszPythonExe);
    424     if (RT_SUCCESS(rc))
    425     {
    426         rc = checkPythonDependencies(hModule, pszPythonExe);
    427         if (RT_SUCCESS(rc))
    428             logStringF(hModule, "ArePythonAPIDepsInstalled: Dependencies look good.\n");
    429 
    430         RTStrFree(pszPythonExe);
    431     }
    432 
    433     if (RT_FAILURE(rc))
    434         logStringF(hModule, "ArePythonAPIDepsInstalled: Failed with %Rrc\n", rc);
    435 
    436     VBoxSetMsiProp(hModule, L"VBOX_PYTHON_DEPS_INSTALLED", RT_SUCCESS(rc) ? L"1" : L"0");
    437 
     420    wchar_t wszPythonExe[RTPATH_MAX];
     421    UINT dwErr = getPythonExe(hModule, wszPythonExe, RTPATH_MAX);
     422    if (dwErr == ERROR_SUCCESS)
     423    {
     424        dwErr = checkPythonDependencies(hModule, wszPythonExe);
     425        if (dwErr == ERROR_SUCCESS)
     426            logStringF(hModule, L"ArePythonAPIDepsInstalled: Dependencies look good.");
     427    }
     428
     429    if (dwErr != ERROR_SUCCESS)
     430        logStringF(hModule, L"ArePythonAPIDepsInstalled: Failed with dwErr=%u", dwErr);
     431
     432    VBoxSetMsiProp(hModule, L"VBOX_PYTHON_DEPS_INSTALLED", dwErr == ERROR_SUCCESS ? L"1" : L"0");
    438433    return ERROR_SUCCESS; /* Never return failure. */
    439434}
     
    451446UINT __stdcall InstallPythonAPI(MSIHANDLE hModule)
    452447{
    453     logStringF(hModule, "InstallPythonAPI: Checking for installed Python environment(s) ...");
    454 
    455     char *pszPythonExe;
    456     int rc = getPythonExe(hModule, &pszPythonExe);
    457     if (RT_FAILURE(rc))
     448    logStringF(hModule, L"InstallPythonAPI: Checking for installed Python environment(s) ...");
     449
     450    /** @todo r=bird: Can't we get the VBOX_PYTHON_PATH property here? */
     451    wchar_t wszPythonExe[RTPATH_MAX];
     452    UINT rcWin = getPythonExe(hModule, wszPythonExe, RTPATH_MAX);
     453    if (rcWin != ERROR_SUCCESS)
    458454    {
    459455        VBoxSetMsiProp(hModule, L"VBOX_API_INSTALLED", L"0");
     
    465461     */
    466462    /* Get the VBox API setup string. */
    467     char *pszVBoxSDKPath;
    468     rc = VBoxGetMsiPropUtf8(hModule, "CustomActionData", &pszVBoxSDKPath);
    469     if (RT_SUCCESS(rc))
     463    WCHAR wszVBoxSDKPath[RTPATH_MAX];
     464    rcWin = VBoxGetMsiProp(hModule, L"CustomActionData", wszVBoxSDKPath, sizeof(wszVBoxSDKPath));
     465    if (rcWin == ERROR_SUCCESS)
    470466    {
    471467        /* Make sure our current working directory is the VBox installation path. */
    472         rc = RTPathSetCurrent(pszVBoxSDKPath);
    473         if (RT_SUCCESS(rc))
     468        if (SetCurrentDirectoryW(wszVBoxSDKPath))
    474469        {
    475470            /* Set required environment variables. */
    476             rc = RTEnvSet("VBOX_INSTALL_PATH", pszVBoxSDKPath);
    477             if (RT_SUCCESS(rc))
    478             {
    479                 logStringF(hModule, "InstallPythonAPI: Invoking vboxapisetup.py in \"%s\" ...\n", pszVBoxSDKPath);
    480 
    481                 const char *papszArgs[] = { pszPythonExe, "vboxapisetup.py", "install", NULL};
    482 
    483                 rc = procRun(hModule, pszPythonExe, papszArgs);
    484                 if (RT_SUCCESS(rc))
    485                     logStringF(hModule, "InstallPythonAPI: Installation of vboxapisetup.py successful\n");
     471            if (SetEnvironmentVariableW(L"VBOX_INSTALL_PATH", wszVBoxSDKPath))
     472            {
     473                logStringF(hModule, L"InstallPythonAPI: Invoking vboxapisetup.py in \"%s\" ...", wszVBoxSDKPath);
     474
     475                rcWin = procRun(hModule, wszPythonExe, L"vboxapisetup.py install");
     476                if (rcWin == ERROR_SUCCESS)
     477                {
     478                    logStringF(hModule, L"InstallPythonAPI: Installation of vboxapisetup.py successful");
     479
     480                    /*
     481                     * Do some sanity checking if the VBox API works.
     482                     */
     483                    logStringF(hModule, L"InstallPythonAPI: Validating VBox API ...");
     484
     485                    rcWin = procRun(hModule, wszPythonExe, L"-c \"from vboxapi import VirtualBoxManager\"");
     486                    if (rcWin == ERROR_SUCCESS)
     487                    {
     488                        logStringF(hModule, L"InstallPythonAPI: VBox API looks good.");
     489                        VBoxSetMsiProp(hModule, L"VBOX_API_INSTALLED", L"1");
     490                        return ERROR_SUCCESS;
     491                    }
     492
     493                    /* failed */
     494                    logStringF(hModule, L"InstallPythonAPI: Validating VBox API failed with %u (%#x)", rcWin, rcWin);
     495                }
    486496                else
    487                     logStringF(hModule, "InstallPythonAPI: Calling vboxapisetup.py failed with %Rrc\n", rc);
     497                    logStringF(hModule, L"InstallPythonAPI: Calling vboxapisetup.py failed with %u (%#x)", rcWin, rcWin);
    488498            }
    489499            else
    490                 logStringF(hModule, "InstallPythonAPI: Could set environment variable VBOX_INSTALL_PATH, rc=%Rrc\n", rc);
     500                logStringF(hModule, L"InstallPythonAPI: Could set environment variable VBOX_INSTALL_PATH: LastError=%u",
     501                           GetLastError());
    491502        }
    492503        else
    493             logStringF(hModule, "InstallPythonAPI: Could set working directory to \"%s\", rc=%Rrc\n", pszVBoxSDKPath, rc);
    494 
    495         RTStrFree(pszVBoxSDKPath);
     504            logStringF(hModule, L"InstallPythonAPI: Could set working directory to \"%s\": LastError=%u",
     505                       wszVBoxSDKPath, GetLastError());
    496506    }
    497507    else
    498         logStringF(hModule, "InstallPythonAPI: Unable to retrieve VBox installation directory, rc=%Rrc\n", rc);
    499 
    500     /*
    501      * Do some sanity checking if the VBox API works.
    502      */
    503     if (RT_SUCCESS(rc))
    504     {
    505         logStringF(hModule, "InstallPythonAPI: Validating VBox API ...\n");
    506 
    507         const char *papszArgs[] = { pszPythonExe, "-c", "from vboxapi import VirtualBoxManager", NULL};
    508 
    509         rc = procRun(hModule, pszPythonExe, papszArgs);
    510         if (RT_SUCCESS(rc))
    511             logStringF(hModule, "InstallPythonAPI: VBox API looks good.\n");
    512         else
    513             logStringF(hModule, "InstallPythonAPI: Validating VBox API failed with %Rrc\n", rc);
    514     }
    515 
    516     RTStrFree(pszPythonExe);
    517 
    518     VBoxSetMsiProp(hModule, L"VBOX_API_INSTALLED", RT_SUCCESS(rc) ? L"1" : L"0");
    519 
    520     if (RT_FAILURE(rc))
    521         logStringF(hModule, "InstallPythonAPI: Installation failed with %Rrc\n", rc);
    522 
     508        logStringF(hModule, L"InstallPythonAPI: Unable to retrieve VBox installation directory: rcWin=%u (%#x)", rcWin, rcWin);
     509
     510    VBoxSetMsiProp(hModule, L"VBOX_API_INSTALLED", L"0");
     511    logStringF(hModule, L"InstallPythonAPI: Installation failed");
    523512    return ERROR_SUCCESS; /* Do not fail here. */
    524513}
     
    552541                                (DWORD)wcslen(wszValue));
    553542            if (rc != ERROR_SUCCESS)
    554                 logStringF(hModule, "InstallBranding: Could not write value %s! Error %ld", pwszValue, rc);
    555             RegCloseKey (hkBranding);
     543                logStringF(hModule, L"InstallBranding: Could not write value %s! Error %d", pwszValue, rc);
     544            RegCloseKey(hkBranding);
    556545        }
    557546    }
     
    575564    s.pTo = wszDest;
    576565    s.pFrom = wszSource;
    577     s.fFlags = FOF_SILENT |
    578                FOF_NOCONFIRMATION |
    579                FOF_NOCONFIRMMKDIR |
    580                FOF_NOERRORUI;
    581 
    582     logStringF(hModule, "CopyDir: DestDir=%s, SourceDir=%s", wszDest, wszSource);
     566    s.fFlags = FOF_SILENT
     567             | FOF_NOCONFIRMATION
     568             | FOF_NOCONFIRMMKDIR
     569             | FOF_NOERRORUI;
     570
     571    logStringF(hModule, L"CopyDir: DestDir=%s, SourceDir=%s", wszDest, wszSource);
    583572    int r = SHFileOperationW(&s);
    584     if (r != 0)
    585     {
    586         logStringF(hModule, "CopyDir: Copy operation returned status 0x%x", r);
     573    if (r == 0)
     574        rc = ERROR_SUCCESS;
     575    else
     576    {
     577        logStringF(hModule, L"CopyDir: Copy operation returned status %#x", r);
    587578        rc = ERROR_GEN_FAILURE;
    588579    }
    589     else
    590         rc = ERROR_SUCCESS;
    591580    return rc;
    592581}
     
    608597             | FOF_NOERRORUI;
    609598
    610     logStringF(hModule, "RemoveDir: DestDir=%s", wszDest);
     599    logStringF(hModule, L"RemoveDir: DestDir=%s", wszDest);
    611600    int r = SHFileOperationW(&s);
    612     if (r != 0)
    613     {
    614         logStringF(hModule, "RemoveDir: Remove operation returned status 0x%x", r);
     601    if (r == 0)
     602        rc = ERROR_SUCCESS;
     603    else
     604    {
     605        logStringF(hModule, L"RemoveDir: Remove operation returned status %#x", r);
    615606        rc = ERROR_GEN_FAILURE;
    616607    }
    617     else
    618         rc = ERROR_SUCCESS;
    619608    return rc;
    620609}
     
    639628             | FOF_NOERRORUI;
    640629
    641     logStringF(hModule, "RenameDir: DestDir=%s, SourceDir=%s", wszDest, wszSource);
     630    logStringF(hModule, L"RenameDir: DestDir=%s, SourceDir=%s", wszDest, wszSource);
    642631    int r = SHFileOperationW(&s);
    643     if (r != 0)
    644     {
    645         logStringF(hModule, "RenameDir: Rename operation returned status 0x%x", r);
     632    if (r == 0)
     633        rc = ERROR_SUCCESS;
     634    else
     635    {
     636        logStringF(hModule, L"RenameDir: Rename operation returned status %#x", r);
    646637        rc = ERROR_GEN_FAILURE;
    647638    }
    648     else
    649         rc = ERROR_SUCCESS;
    650639    return rc;
    651640}
     
    654643{
    655644    UINT rc;
    656     logStringF(hModule, "UninstallBranding: Handling branding file ...");
     645    logStringF(hModule, L"UninstallBranding: Handling branding file ...");
    657646
    658647    WCHAR wszPathTargetDir[_MAX_PATH];
    659     WCHAR wszPathDest[_MAX_PATH];
    660648
    661649    rc = VBoxGetMsiProp(hModule, L"CustomActionData", wszPathTargetDir, sizeof(wszPathTargetDir));
     
    669657 * This applies almost to all swprintf_s calls in this file!!
    670658 */
     659        WCHAR wszPathDest[_MAX_PATH];
    671660        swprintf_s(wszPathDest, RT_ELEMENTS(wszPathDest), L"%scustom", wszPathTargetDir);
    672661        rc = RemoveDir(hModule, wszPathDest);
     
    679668    }
    680669
    681     logStringF(hModule, "UninstallBranding: Handling done. (rc=%u (ignored))", rc);
     670    logStringF(hModule, L"UninstallBranding: Handling done. (rc=%u (ignored))", rc);
    682671    return ERROR_SUCCESS; /* Do not fail here. */
    683672}
     
    686675{
    687676    UINT rc;
    688     logStringF(hModule, "InstallBranding: Handling branding file ...");
     677    logStringF(hModule, L"InstallBranding: Handling branding file ...");
    689678
    690679    WCHAR wszPathMSI[_MAX_PATH];
     
    712701    }
    713702
    714     logStringF(hModule, "InstallBranding: Handling done. (rc=%u (ignored))", rc);
     703    logStringF(hModule, L"InstallBranding: Handling done. (rc=%u (ignored))", rc);
    715704    return ERROR_SUCCESS; /* Do not fail here. */
    716705}
     
    743732        case VBOXDRVCFG_LOG_SEVERITY_REL:
    744733            if (g_hCurrentModule)
    745                 logStringF(g_hCurrentModule, pszMsg);
     734                logStringF(g_hCurrentModule, L"%S", pszMsg);
    746735            break;
    747736        default:
     
    753742{
    754743    if (g_hCurrentModule)
    755         logStringF(g_hCurrentModule, pszString);
     744        logStringF(g_hCurrentModule, L"%S", pszString);
    756745}
    757746
     
    790779        case NETCFG_S_REBOOT:
    791780        {
    792             logStringF(hModule, "Reboot required, setting REBOOT property to \"force\"");
     781            logStringF(hModule, L"Reboot required, setting REBOOT property to \"force\"");
    793782            HRESULT hr2 = MsiSetPropertyW(hModule, L"REBOOT", L"Force");
    794783            if (hr2 != ERROR_SUCCESS)
    795                 logStringF(hModule, "Failed to set REBOOT property, error = 0x%x", hr2);
     784                logStringF(hModule, L"Failed to set REBOOT property, error = %#x", hr2);
    796785            uRet = ERROR_SUCCESS; /* Never fail here. */
    797786            break;
     
    799788
    800789        default:
    801             logStringF(hModule, "Converting unhandled HRESULT (0x%x) to ERROR_GEN_FAILURE", hr);
     790            logStringF(hModule, L"Converting unhandled HRESULT (%#x) to ERROR_GEN_FAILURE", hr);
    802791            uRet = ERROR_GEN_FAILURE;
    803792    }
     
    813802        if (uErr != ERROR_SUCCESS)
    814803        {
    815             logStringF(hModule, "createNetCfgLockedMsgRecord: MsiRecordSetInteger failed, error = 0x%x", uErr);
     804            logStringF(hModule, L"createNetCfgLockedMsgRecord: MsiRecordSetInteger failed, error = %#x", uErr);
    816805            MsiCloseHandle(hRecord);
    817806            hRecord = NULL;
     
    819808    }
    820809    else
    821         logStringF(hModule, "createNetCfgLockedMsgRecord: Failed to create a record");
     810        logStringF(hModule, L"createNetCfgLockedMsgRecord: Failed to create a record");
    822811
    823812    return hRecord;
     
    838827        {
    839828            if (FAILED(hr))
    840                 logStringF(hModule, "doNetCfgInit: VBoxNetCfgWinQueryINetCfg failed, error = 0x%x", hr);
     829                logStringF(hModule, L"doNetCfgInit: VBoxNetCfgWinQueryINetCfg failed, error = %#x", hr);
    841830            uErr = errorConvertFromHResult(hModule, hr);
    842831            break;
     
    847836        if (!lpszLockedBy)
    848837        {
    849             logStringF(hModule, "doNetCfgInit: lpszLockedBy == NULL, breaking");
     838            logStringF(hModule, L"doNetCfgInit: lpszLockedBy == NULL, breaking");
    850839            break;
    851840        }
     
    861850        {
    862851            cRetries++;
    863             logStringF(hModule, "doNetCfgInit: lpszLockedBy is 6to4svc.dll, retrying %d out of %d", cRetries, VBOX_NETCFG_MAX_RETRIES);
     852            logStringF(hModule, L"doNetCfgInit: lpszLockedBy is 6to4svc.dll, retrying %d out of %d", cRetries, VBOX_NETCFG_MAX_RETRIES);
    864853            MsgResult = IDRETRY;
    865854        }
     
    871860                if (!hMsg)
    872861                {
    873                     logStringF(hModule, "doNetCfgInit: Failed to create a message record, breaking");
     862                    logStringF(hModule, L"doNetCfgInit: Failed to create a message record, breaking");
    874863                    CoTaskMemFree(lpszLockedBy);
    875864                    break;
     
    881870            if (rTmp != ERROR_SUCCESS)
    882871            {
    883                 logStringF(hModule, "doNetCfgInit: MsiRecordSetStringW failed, error = 0x%x", rTmp);
     872                logStringF(hModule, L"doNetCfgInit: MsiRecordSetStringW failed, error = #%x", rTmp);
    884873                CoTaskMemFree(lpszLockedBy);
    885874                break;
     
    888877            MsgResult = MsiProcessMessage(hModule, (INSTALLMESSAGE)(INSTALLMESSAGE_USER | MB_RETRYCANCEL), hMsg);
    889878            NonStandardAssert(MsgResult == IDRETRY || MsgResult == IDCANCEL);
    890             logStringF(hModule, "doNetCfgInit: MsiProcessMessage returned (0x%x)", MsgResult);
     879            logStringF(hModule, L"doNetCfgInit: MsiProcessMessage returned (%#x)", MsgResult);
    891880        }
    892881        CoTaskMemFree(lpszLockedBy);
     
    909898
    910899        wcsncat(pwszPtInf, NETFLT_PT_INF_REL_PATH, sizeof(NETFLT_PT_INF_REL_PATH));
    911         logStringF(hModule, "vboxNetFltQueryInfArray: INF 1: %s", pwszPtInf);
     900        logStringF(hModule, L"vboxNetFltQueryInfArray: INF 1: %s", pwszPtInf);
    912901
    913902        wcsncat(pwszMpInf, NETFLT_MP_INF_REL_PATH, sizeof(NETFLT_MP_INF_REL_PATH));
    914         logStringF(hModule, "vboxNetFltQueryInfArray: INF 2: %s", pwszMpInf);
     903        logStringF(hModule, L"vboxNetFltQueryInfArray: INF 2: %s", pwszMpInf);
    915904    }
    916905    else if (uErr != ERROR_SUCCESS)
    917         logStringF(hModule, "vboxNetFltQueryInfArray: MsiGetPropertyW failed, error = 0x%x", uErr);
     906        logStringF(hModule, L"vboxNetFltQueryInfArray: MsiGetPropertyW failed, error = %#x", uErr);
    918907    else
    919908    {
    920         logStringF(hModule, "vboxNetFltQueryInfArray: Empty installation directory");
     909        logStringF(hModule, L"vboxNetFltQueryInfArray: Empty installation directory");
    921910        uErr = ERROR_GEN_FAILURE;
    922911    }
     
    939928    __try
    940929    {
    941         logStringF(hModule, "Uninstalling NetFlt");
     930        logStringF(hModule, L"Uninstalling NetFlt");
    942931
    943932        uErr = doNetCfgInit(hModule, &pNetCfg, TRUE);
     
    946935            HRESULT hr = VBoxNetCfgWinNetFltUninstall(pNetCfg);
    947936            if (hr != S_OK)
    948                 logStringF(hModule, "UninstallNetFlt: VBoxNetCfgWinUninstallComponent failed, error = 0x%x", hr);
     937                logStringF(hModule, L"UninstallNetFlt: VBoxNetCfgWinUninstallComponent failed, error = %#x", hr);
    949938
    950939            uErr = errorConvertFromHResult(hModule, hr);
     
    952941            VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE);
    953942
    954             logStringF(hModule, "Uninstalling NetFlt done, error = 0x%x", uErr);
     943            logStringF(hModule, L"Uninstalling NetFlt done, error = %#x", uErr);
    955944        }
    956945        else
    957             logStringF(hModule, "UninstallNetFlt: doNetCfgInit failed, error = 0x%x", uErr);
     946            logStringF(hModule, L"UninstallNetFlt: doNetCfgInit failed, error = %#x", uErr);
    958947    }
    959948    __finally
     
    991980    {
    992981
    993         logStringF(hModule, "InstallNetFlt: Installing NetFlt");
     982        logStringF(hModule, L"InstallNetFlt: Installing NetFlt");
    994983
    995984        uErr = doNetCfgInit(hModule, &pNetCfg, TRUE);
     
    1004993                HRESULT hr = VBoxNetCfgWinNetFltInstall(pNetCfg, &apwszInfs[0], RT_ELEMENTS(apwszInfs));
    1005994                if (FAILED(hr))
    1006                     logStringF(hModule, "InstallNetFlt: VBoxNetCfgWinNetFltInstall failed, error = 0x%x", hr);
     995                    logStringF(hModule, L"InstallNetFlt: VBoxNetCfgWinNetFltInstall failed, error = %#x", hr);
    1007996
    1008997                uErr = errorConvertFromHResult(hModule, hr);
    1009998            }
    1010999            else
    1011                 logStringF(hModule, "InstallNetFlt: vboxNetFltQueryInfArray failed, error = 0x%x", uErr);
     1000                logStringF(hModule, L"InstallNetFlt: vboxNetFltQueryInfArray failed, error = %#x", uErr);
    10121001
    10131002            VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE);
    10141003
    1015             logStringF(hModule, "InstallNetFlt: Done");
     1004            logStringF(hModule, L"InstallNetFlt: Done");
    10161005        }
    10171006        else
    1018             logStringF(hModule, "InstallNetFlt: doNetCfgInit failed, error = 0x%x", uErr);
     1007            logStringF(hModule, L"InstallNetFlt: doNetCfgInit failed, error = %#x", uErr);
    10191008    }
    10201009    __finally
     
    10521041    __try
    10531042    {
    1054         logStringF(hModule, "Uninstalling NetLwf");
     1043        logStringF(hModule, L"Uninstalling NetLwf");
    10551044
    10561045        uErr = doNetCfgInit(hModule, &pNetCfg, TRUE);
     
    10591048            HRESULT hr = VBoxNetCfgWinNetLwfUninstall(pNetCfg);
    10601049            if (hr != S_OK)
    1061                 logStringF(hModule, "UninstallNetLwf: VBoxNetCfgWinUninstallComponent failed, error = 0x%x", hr);
     1050                logStringF(hModule, L"UninstallNetLwf: VBoxNetCfgWinUninstallComponent failed, error = %#x", hr);
    10621051
    10631052            uErr = errorConvertFromHResult(hModule, hr);
     
    10651054            VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE);
    10661055
    1067             logStringF(hModule, "Uninstalling NetLwf done, error = 0x%x", uErr);
     1056            logStringF(hModule, L"Uninstalling NetLwf done, error = %#x", uErr);
    10681057        }
    10691058        else
    1070             logStringF(hModule, "UninstallNetLwf: doNetCfgInit failed, error = 0x%x", uErr);
     1059            logStringF(hModule, L"UninstallNetLwf: doNetCfgInit failed, error = %#x", uErr);
    10711060    }
    10721061    __finally
     
    11041093    {
    11051094
    1106         logStringF(hModule, "InstallNetLwf: Installing NetLwf");
     1095        logStringF(hModule, L"InstallNetLwf: Installing NetLwf");
    11071096
    11081097        uErr = doNetCfgInit(hModule, &pNetCfg, TRUE);
     
    11261115                    HRESULT hr = VBoxNetCfgWinNetLwfInstall(pNetCfg, wszInf);
    11271116                    if (FAILED(hr))
    1128                         logStringF(hModule, "InstallNetLwf: VBoxNetCfgWinNetLwfInstall failed, error = 0x%x", hr);
     1117                        logStringF(hModule, L"InstallNetLwf: VBoxNetCfgWinNetLwfInstall failed, error = %#x", hr);
    11291118
    11301119                    uErr = errorConvertFromHResult(hModule, hr);
     
    11321121                else
    11331122                {
    1134                     logStringF(hModule, "vboxNetFltQueryInfArray: Empty installation directory");
     1123                    logStringF(hModule, L"vboxNetFltQueryInfArray: Empty installation directory");
    11351124                    uErr = ERROR_GEN_FAILURE;
    11361125                }
    11371126            }
    11381127            else
    1139                 logStringF(hModule, "vboxNetFltQueryInfArray: MsiGetPropertyW failed, error = 0x%x", uErr);
     1128                logStringF(hModule, L"vboxNetFltQueryInfArray: MsiGetPropertyW failed, error = %#x", uErr);
    11401129
    11411130            VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE);
    11421131
    1143             logStringF(hModule, "InstallNetLwf: Done");
     1132            logStringF(hModule, L"InstallNetLwf: Done");
    11441133        }
    11451134        else
    1146             logStringF(hModule, "InstallNetLwf: doNetCfgInit failed, error = 0x%x", uErr);
     1135            logStringF(hModule, L"InstallNetLwf: doNetCfgInit failed, error = %#x", uErr);
    11471136    }
    11481137    __finally
     
    12331222    BOOL fSetupModeInteractive = SetupSetNonInteractiveMode(FALSE);
    12341223
    1235     logStringF(hModule, "CreateHostOnlyInterface: Creating host-only interface");
     1224    logStringF(hModule, L"CreateHostOnlyInterface: Creating host-only interface");
    12361225
    12371226    HRESULT hr = E_FAIL;
     
    12461235        if (cchMpInf)
    12471236        {
    1248             logStringF(hModule, "CreateHostOnlyInterface: NetAdpDir property = %s", wszMpInf);
     1237            logStringF(hModule, L"CreateHostOnlyInterface: NetAdpDir property = %s", wszMpInf);
    12491238            if (wszMpInf[cchMpInf - 1] != L'\\')
    12501239            {
     
    12571246            fIsFile = true;
    12581247
    1259             logStringF(hModule, "CreateHostOnlyInterface: Resulting INF path = %s", pwszInfPath);
     1248            logStringF(hModule, L"CreateHostOnlyInterface: Resulting INF path = %s", pwszInfPath);
    12601249        }
    12611250        else
    1262             logStringF(hModule, "CreateHostOnlyInterface: VBox installation path is empty");
     1251            logStringF(hModule, L"CreateHostOnlyInterface: VBox installation path is empty");
    12631252    }
    12641253    else
    1265         logStringF(hModule, "CreateHostOnlyInterface: Unable to retrieve VBox installation path, error = 0x%x", uErr);
     1254        logStringF(hModule, L"CreateHostOnlyInterface: Unable to retrieve VBox installation path, error = %#x", uErr);
    12661255
    12671256    /* Make sure the inf file is installed. */
    12681257    if (pwszInfPath != NULL && fIsFile)
    12691258    {
    1270         logStringF(hModule, "CreateHostOnlyInterface: Calling VBoxDrvCfgInfInstall(%s)", pwszInfPath);
     1259        logStringF(hModule, L"CreateHostOnlyInterface: Calling VBoxDrvCfgInfInstall(%s)", pwszInfPath);
    12711260        hr = VBoxDrvCfgInfInstall(pwszInfPath);
    1272         logStringF(hModule, "CreateHostOnlyInterface: VBoxDrvCfgInfInstall returns 0x%x", hr);
     1261        logStringF(hModule, L"CreateHostOnlyInterface: VBoxDrvCfgInfInstall returns %#x", hr);
    12731262        if (FAILED(hr))
    1274             logStringF(hModule, "CreateHostOnlyInterface: Failed to install INF file, error = 0x%x", hr);
     1263            logStringF(hModule, L"CreateHostOnlyInterface: Failed to install INF file, error = %#x", hr);
    12751264    }
    12761265
     
    12841273            if (fRebootRequired)
    12851274            {
    1286                 logStringF(hModule, "CreateHostOnlyInterface: Reboot required for update, setting REBOOT property to force");
     1275                logStringF(hModule, L"CreateHostOnlyInterface: Reboot required for update, setting REBOOT property to force");
    12871276                HRESULT hr2 = MsiSetPropertyW(hModule, L"REBOOT", L"Force");
    12881277                if (hr2 != ERROR_SUCCESS)
    1289                     logStringF(hModule, "CreateHostOnlyInterface: Failed to set REBOOT property for update, error = 0x%x", hr2);
     1278                    logStringF(hModule, L"CreateHostOnlyInterface: Failed to set REBOOT property for update, error = %#x", hr2);
    12901279            }
    12911280        }
     
    12931282        {
    12941283            //in fail case call CreateHostOnlyInterface
    1295             logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinUpdateHostOnlyNetworkInterface failed, hr = 0x%x", hr);
    1296             logStringF(hModule, "CreateHostOnlyInterface: calling VBoxNetCfgWinCreateHostOnlyNetworkInterface");
     1284            logStringF(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinUpdateHostOnlyNetworkInterface failed, hr = %#x", hr);
     1285            logStringF(hModule, L"CreateHostOnlyInterface: calling VBoxNetCfgWinCreateHostOnlyNetworkInterface");
    12971286#ifdef VBOXNETCFG_DELAYEDRENAME
    12981287            BSTR devId;
     
    13011290            hr = VBoxNetCfgWinCreateHostOnlyNetworkInterface(pwszInfPath, fIsFile, NULL, &guid, NULL, NULL);
    13021291#endif /* !VBOXNETCFG_DELAYEDRENAME */
    1303             logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface returns 0x%x", hr);
     1292            logStringF(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface returns %#x", hr);
    13041293            if (SUCCEEDED(hr))
    13051294            {
    13061295                ULONG ip = inet_addr("192.168.56.1");
    13071296                ULONG mask = inet_addr("255.255.255.0");
    1308                 logStringF(hModule, "CreateHostOnlyInterface: calling VBoxNetCfgWinEnableStaticIpConfig");
     1297                logStringF(hModule, L"CreateHostOnlyInterface: calling VBoxNetCfgWinEnableStaticIpConfig");
    13091298                hr = VBoxNetCfgWinEnableStaticIpConfig(&guid, ip, mask);
    1310                 logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig returns 0x%x", hr);
     1299                logStringF(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig returns %#x", hr);
    13111300                if (FAILED(hr))
    1312                     logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig failed, error = 0x%x", hr);
     1301                    logStringF(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig failed, error = %#x", hr);
    13131302#ifdef VBOXNETCFG_DELAYEDRENAME
    13141303                hr = VBoxNetCfgWinRenameHostOnlyConnection(&guid, devId, NULL);
    13151304                if (FAILED(hr))
    1316                     logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinRenameHostOnlyConnection failed, error = 0x%x", hr);
     1305                    logStringF(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinRenameHostOnlyConnection failed, error = %#x", hr);
    13171306                SysFreeString(devId);
    13181307#endif /* VBOXNETCFG_DELAYEDRENAME */
    13191308            }
    13201309            else
    1321                 logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface failed, error = 0x%x", hr);
     1310                logStringF(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface failed, error = %#x", hr);
    13221311        }
    13231312    }
    13241313
    13251314    if (SUCCEEDED(hr))
    1326         logStringF(hModule, "CreateHostOnlyInterface: Creating host-only interface done");
     1315        logStringF(hModule, L"CreateHostOnlyInterface: Creating host-only interface done");
    13271316
    13281317    /* Restore original setup mode. */
    1329     logStringF(hModule, "CreateHostOnlyInterface: Almost done...");
     1318    logStringF(hModule, L"CreateHostOnlyInterface: Almost done...");
    13301319    if (fSetupModeInteractive)
    13311320        SetupSetNonInteractiveMode(fSetupModeInteractive);
     
    13351324#endif /* VBOX_WITH_NETFLT */
    13361325
    1337     logStringF(hModule, "CreateHostOnlyInterface: Returns success (ignoring all failures)");
     1326    logStringF(hModule, L"CreateHostOnlyInterface: Returns success (ignoring all failures)");
    13381327    /* Never fail the install even if we did not succeed. */
    13391328    return ERROR_SUCCESS;
     
    13551344    netCfgLoggerEnable(hModule);
    13561345
    1357     logStringF(hModule, "RemoveHostOnlyInterfaces: Removing all host-only interfaces");
     1346    logStringF(hModule, L"RemoveHostOnlyInterfaces: Removing all host-only interfaces");
    13581347
    13591348    BOOL fSetupModeInteractive = SetupSetNonInteractiveMode(FALSE);
     
    13641353        hr = VBoxDrvCfgInfUninstallAllSetupDi(&GUID_DEVCLASS_NET, L"Net", pwszId, SUOI_FORCEDELETE/* could be SUOI_FORCEDELETE */);
    13651354        if (FAILED(hr))
    1366         {
    1367             logStringF(hModule, "RemoveHostOnlyInterfaces: NetAdp uninstalled successfully, but failed to remove INF files");
    1368         }
     1355            logStringF(hModule, L"RemoveHostOnlyInterfaces: NetAdp uninstalled successfully, but failed to remove INF files");
    13691356        else
    1370             logStringF(hModule, "RemoveHostOnlyInterfaces: NetAdp uninstalled successfully");
    1371 
     1357            logStringF(hModule, L"RemoveHostOnlyInterfaces: NetAdp uninstalled successfully");
    13721358    }
    13731359    else
    1374         logStringF(hModule, "RemoveHostOnlyInterfaces: NetAdp uninstall failed, hr = 0x%x", hr);
     1360        logStringF(hModule, L"RemoveHostOnlyInterfaces: NetAdp uninstall failed, hr = %#x", hr);
    13751361
    13761362    /* Restore original setup mode. */
     
    13951381    netCfgLoggerEnable(hModule);
    13961382
    1397     logStringF(hModule, "StopHostOnlyInterfaces: Stopping all host-only interfaces");
     1383    logStringF(hModule, L"StopHostOnlyInterfaces: Stopping all host-only interfaces");
    13981384
    13991385    BOOL fSetupModeInteractive = SetupSetNonInteractiveMode(FALSE);
     
    14011387    HRESULT hr = VBoxNetCfgWinPropChangeAllNetDevicesOfId(pwszId, VBOXNECTFGWINPROPCHANGE_TYPE_DISABLE);
    14021388    if (SUCCEEDED(hr))
    1403     {
    1404         logStringF(hModule, "StopHostOnlyInterfaces: Disabling host interfaces was successful, hr = 0x%x", hr);
    1405     }
     1389        logStringF(hModule, L"StopHostOnlyInterfaces: Disabling host interfaces was successful, hr = %#x", hr);
    14061390    else
    1407         logStringF(hModule, "StopHostOnlyInterfaces: Disabling host interfaces failed, hr = 0x%x", hr);
     1391        logStringF(hModule, L"StopHostOnlyInterfaces: Disabling host interfaces failed, hr = %#x", hr);
    14081392
    14091393    /* Restore original setup mode. */
     
    14281412    netCfgLoggerEnable(hModule);
    14291413
    1430     logStringF(hModule, "UpdateHostOnlyInterfaces: Updating all host-only interfaces");
     1414    logStringF(hModule, L"UpdateHostOnlyInterfaces: Updating all host-only interfaces");
    14311415
    14321416    BOOL fSetupModeInteractive = SetupSetNonInteractiveMode(FALSE);
     
    14411425        if (cchMpInf)
    14421426        {
    1443             logStringF(hModule, "UpdateHostOnlyInterfaces: NetAdpDir property = %s", wszMpInf);
     1427            logStringF(hModule, L"UpdateHostOnlyInterfaces: NetAdpDir property = %s", wszMpInf);
    14441428            if (wszMpInf[cchMpInf - 1] != L'\\')
    14451429            {
     
    14521436            fIsFile = true;
    14531437
    1454             logStringF(hModule, "UpdateHostOnlyInterfaces: Resulting INF path = %s", pwszInfPath);
     1438            logStringF(hModule, L"UpdateHostOnlyInterfaces: Resulting INF path = %s", pwszInfPath);
    14551439
    14561440            DWORD attrFile = GetFileAttributesW(pwszInfPath);
     
    14581442            {
    14591443                DWORD dwErr = GetLastError();
    1460                 logStringF(hModule, "UpdateHostOnlyInterfaces: File \"%s\" not found, dwErr=%ld",
    1461                            pwszInfPath, dwErr);
     1444                logStringF(hModule, L"UpdateHostOnlyInterfaces: File \"%s\" not found, dwErr=%ld", pwszInfPath, dwErr);
    14621445            }
    14631446            else
    14641447            {
    1465                 logStringF(hModule, "UpdateHostOnlyInterfaces: File \"%s\" exists",
    1466                            pwszInfPath);
     1448                logStringF(hModule, L"UpdateHostOnlyInterfaces: File \"%s\" exists", pwszInfPath);
    14671449
    14681450                BOOL fRebootRequired = FALSE;
     
    14721454                    if (fRebootRequired)
    14731455                    {
    1474                         logStringF(hModule, "UpdateHostOnlyInterfaces: Reboot required, setting REBOOT property to force");
     1456                        logStringF(hModule, L"UpdateHostOnlyInterfaces: Reboot required, setting REBOOT property to force");
    14751457                        HRESULT hr2 = MsiSetPropertyW(hModule, L"REBOOT", L"Force");
    14761458                        if (hr2 != ERROR_SUCCESS)
    1477                             logStringF(hModule, "UpdateHostOnlyInterfaces: Failed to set REBOOT property, error = 0x%x", hr2);
     1459                            logStringF(hModule, L"UpdateHostOnlyInterfaces: Failed to set REBOOT property, error = %#x", hr2);
    14781460                    }
    14791461                }
    14801462                else
    1481                     logStringF(hModule, "UpdateHostOnlyInterfaces: VBoxNetCfgWinUpdateHostOnlyNetworkInterface failed, hr = 0x%x", hr);
     1463                    logStringF(hModule, L"UpdateHostOnlyInterfaces: VBoxNetCfgWinUpdateHostOnlyNetworkInterface failed, hr = %#x", hr);
    14821464            }
    14831465        }
    14841466        else
    1485             logStringF(hModule, "UpdateHostOnlyInterfaces: VBox installation path is empty");
     1467            logStringF(hModule, L"UpdateHostOnlyInterfaces: VBox installation path is empty");
    14861468    }
    14871469    else
    1488         logStringF(hModule, "UpdateHostOnlyInterfaces: Unable to retrieve VBox installation path, error = 0x%x", uErr);
     1470        logStringF(hModule, L"UpdateHostOnlyInterfaces: Unable to retrieve VBox installation path, error = %#x", uErr);
    14891471
    14901472    /* Restore original setup mode. */
     
    15211503    __try
    15221504    {
    1523         logStringF(hModule, "Uninstalling NetAdp");
     1505        logStringF(hModule, L"Uninstalling NetAdp");
    15241506
    15251507        uErr = doNetCfgInit(hModule, &pNetCfg, TRUE);
     
    15281510            HRESULT hr = VBoxNetCfgWinNetAdpUninstall(pNetCfg, pwszId);
    15291511            if (hr != S_OK)
    1530                 logStringF(hModule, "UninstallNetAdp: VBoxNetCfgWinUninstallComponent failed, error = 0x%x", hr);
     1512                logStringF(hModule, L"UninstallNetAdp: VBoxNetCfgWinUninstallComponent failed, error = %#x", hr);
    15311513
    15321514            uErr = errorConvertFromHResult(hModule, hr);
     
    15341516            VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE);
    15351517
    1536             logStringF(hModule, "Uninstalling NetAdp done, error = 0x%x", uErr);
     1518            logStringF(hModule, L"Uninstalling NetAdp done, error = %#x", uErr);
    15371519        }
    15381520        else
    1539             logStringF(hModule, "UninstallNetAdp: doNetCfgInit failed, error = 0x%x", uErr);
     1521            logStringF(hModule, L"UninstallNetAdp: doNetCfgInit failed, error = %#x", uErr);
    15401522    }
    15411523    __finally
     
    16341616{
    16351617    int rc = 1;
    1636     do
     1618    do /* break-loop */
    16371619    {
    16381620        WCHAR wszPnPInstanceId[512] = {0};
     
    16511633            LONG lStatus = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszRegLocation, 0, KEY_READ, &hkeyNetwork);
    16521634            if ((lStatus != ERROR_SUCCESS) || !hkeyNetwork)
    1653                 SetErrBreak((hModule, "VBox HostInterfaces: Host interface network was not found in registry (%s)! [1]",
     1635                SetErrBreak((hModule, L"VBox HostInterfaces: Host interface network was not found in registry (%s)! [1]",
    16541636                             wszRegLocation));
    16551637
    16561638            lStatus = RegOpenKeyExW(hkeyNetwork, L"Connection", 0, KEY_READ, &hkeyConnection);
    16571639            if ((lStatus != ERROR_SUCCESS) || !hkeyConnection)
    1658                 SetErrBreak((hModule, "VBox HostInterfaces: Host interface network was not found in registry (%s)! [2]",
     1640                SetErrBreak((hModule, L"VBox HostInterfaces: Host interface network was not found in registry (%s)! [2]",
    16591641                             wszRegLocation));
    16601642
     
    16641646                                       &dwKeyType, (LPBYTE)&wszPnPInstanceId[0], &len);
    16651647            if ((lStatus != ERROR_SUCCESS) || (dwKeyType != REG_SZ))
    1666                 SetErrBreak((hModule, "VBox HostInterfaces: Host interface network was not found in registry (%s)! [3]",
     1648                SetErrBreak((hModule, L"VBox HostInterfaces: Host interface network was not found in registry (%s)! [3]",
    16671649                             wszRegLocation));
    16681650        }
     
    16821664        BOOL fResult;
    16831665
    1684         do
     1666        do /* break-loop */
    16851667        {
    16861668            GUID netGuid;
     
    16991681            if (hDeviceInfo == INVALID_HANDLE_VALUE)
    17001682            {
    1701                 logStringF(hModule, "VBox HostInterfaces: SetupDiGetClassDevs failed (0x%08X)!", GetLastError());
    1702                 SetErrBreak((hModule, "VBox HostInterfaces: Uninstallation failed!"));
     1683                logStringF(hModule, L"VBox HostInterfaces: SetupDiGetClassDevs failed (0x%08X)!", GetLastError());
     1684                SetErrBreak((hModule, L"VBox HostInterfaces: Uninstallation failed!"));
    17031685            }
    17041686
     
    18021784                if (!fResult)
    18031785                {
    1804                     logStringF(hModule, "VBox HostInterfaces: SetupDiSetSelectedDevice failed (0x%08X)!", GetLastError());
    1805                     SetErrBreak((hModule, "VBox HostInterfaces: Uninstallation failed!"));
     1786                    logStringF(hModule, L"VBox HostInterfaces: SetupDiSetSelectedDevice failed (0x%08X)!", GetLastError());
     1787                    SetErrBreak((hModule, L"VBox HostInterfaces: Uninstallation failed!"));
    18061788                }
    18071789
     
    18091791                if (!fResult)
    18101792                {
    1811                     logStringF(hModule, "VBox HostInterfaces: SetupDiCallClassInstaller (DIF_REMOVE) failed (0x%08X)!", GetLastError());
    1812                     SetErrBreak((hModule, "VBox HostInterfaces: Uninstallation failed!"));
     1793                    logStringF(hModule, L"VBox HostInterfaces: SetupDiCallClassInstaller (DIF_REMOVE) failed (0x%08X)!", GetLastError());
     1794                    SetErrBreak((hModule, L"VBox HostInterfaces: Uninstallation failed!"));
    18131795                }
    18141796            }
    18151797            else
    1816                 SetErrBreak((hModule, "VBox HostInterfaces: Host interface network device not found!"));
     1798                SetErrBreak((hModule, L"VBox HostInterfaces: Host interface network device not found!"));
    18171799        } while (0);
    18181800
     
    18261808UINT __stdcall UninstallTAPInstances(MSIHANDLE hModule)
    18271809{
    1828     static const WCHAR *s_wszNetworkKey = L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}";
     1810    static const wchar_t s_wszNetworkKey[] = L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}";
    18291811    HKEY hCtrlNet;
    18301812
     
    18321814    if (lStatus == ERROR_SUCCESS)
    18331815    {
    1834         logStringF(hModule, "VBox HostInterfaces: Enumerating interfaces ...");
     1816        logStringF(hModule, L"VBox HostInterfaces: Enumerating interfaces ...");
    18351817        for (int i = 0; ; ++i)
    18361818        {
     
    18431825                {
    18441826                    case ERROR_NO_MORE_ITEMS:
    1845                         logStringF(hModule, "VBox HostInterfaces: No interfaces found.");
     1827                        logStringF(hModule, L"VBox HostInterfaces: No interfaces found.");
    18461828                        break;
    18471829                    default:
    1848                         logStringF(hModule, "VBox HostInterfaces: Enumeration failed: %ld", lStatus);
     1830                        logStringF(hModule, L"VBox HostInterfaces: Enumeration failed: %ld", lStatus);
    18491831                        break;
    18501832                }
     
    18541836            if (isTAPDevice(wszNetworkGUID))
    18551837            {
    1856                 logStringF(hModule, "VBox HostInterfaces: Removing interface \"%s\" ...", wszNetworkGUID);
     1838                logStringF(hModule, L"VBox HostInterfaces: Removing interface \"%s\" ...", wszNetworkGUID);
    18571839                removeNetworkInterface(hModule, wszNetworkGUID);
    18581840                lStatus = RegDeleteKeyW(hCtrlNet, wszNetworkGUID);
     
    18601842        }
    18611843        RegCloseKey(hCtrlNet);
    1862         logStringF(hModule, "VBox HostInterfaces: Removing interfaces done.");
     1844        logStringF(hModule, L"VBox HostInterfaces: Removing interfaces done.");
    18631845    }
    18641846    return ERROR_SUCCESS;
     
    18951877            QueryServiceStatus(hService, &Status);
    18961878            if (Status.dwCurrentState == SERVICE_STOPPED)
    1897                 logStringF(hModule, "VBoxDrv: The service old service was already stopped");
     1879                logStringF(hModule, L"VBoxDrv: The service old service was already stopped");
    18981880            else
    18991881            {
    1900                 logStringF(hModule, "VBoxDrv: Stopping the service (state %u)", Status.dwCurrentState);
     1882                logStringF(hModule, L"VBoxDrv: Stopping the service (state %u)", Status.dwCurrentState);
    19011883                if (ControlService(hService, SERVICE_CONTROL_STOP, &Status))
    19021884                {
     
    19101892
    19111893                    if (Status.dwCurrentState == SERVICE_STOPPED)
    1912                         logStringF(hModule, "VBoxDrv: Stopped service");
     1894                        logStringF(hModule, L"VBoxDrv: Stopped service");
    19131895                    else
    1914                         logStringF(hModule, "VBoxDrv: Failed to stop the service, status: %u", Status.dwCurrentState);
     1896                        logStringF(hModule, L"VBoxDrv: Failed to stop the service, status: %u", Status.dwCurrentState);
    19151897                }
    19161898                else
     
    19191901                    if (   Status.dwCurrentState == SERVICE_STOP_PENDING
    19201902                        && dwErr == ERROR_SERVICE_CANNOT_ACCEPT_CTRL)
    1921                         logStringF(hModule, "VBoxDrv: Failed to stop the service: stop pending, not accepting control messages");
     1903                        logStringF(hModule, L"VBoxDrv: Failed to stop the service: stop pending, not accepting control messages");
    19221904                    else
    1923                         logStringF(hModule, "VBoxDrv: Failed to stop the service: dwErr=%u status=%u", dwErr, Status.dwCurrentState);
     1905                        logStringF(hModule, L"VBoxDrv: Failed to stop the service: dwErr=%u status=%u", dwErr, Status.dwCurrentState);
    19241906                }
    19251907            }
     
    19291911             */
    19301912            if (DeleteService(hService))
    1931                 logStringF(hModule, "VBoxDrv: Successfully delete service");
     1913                logStringF(hModule, L"VBoxDrv: Successfully delete service");
    19321914            else
    1933                 logStringF(hModule, "VBoxDrv: Failed to delete the service: %u", GetLastError());
     1915                logStringF(hModule, L"VBoxDrv: Failed to delete the service: %u", GetLastError());
    19341916
    19351917            CloseServiceHandle(hService);
     
    19391921            DWORD const dwErr = GetLastError();
    19401922            if (dwErr == ERROR_SERVICE_DOES_NOT_EXIST)
    1941                 logStringF(hModule, "VBoxDrv: Nothing to do, the old service does not exist");
     1923                logStringF(hModule, L"VBoxDrv: Nothing to do, the old service does not exist");
    19421924            else
    1943                 logStringF(hModule, "VBoxDrv: Failed to open the service: %u", dwErr);
     1925                logStringF(hModule, L"VBoxDrv: Failed to open the service: %u", dwErr);
    19441926        }
    19451927
     
    19471929    }
    19481930    else
    1949         logStringF(hModule, "VBoxDrv: Failed to open service manager (%u).", GetLastError());
     1931        logStringF(hModule, L"VBoxDrv: Failed to open service manager (%u).", GetLastError());
    19501932
    19511933    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