Changeset 93340 in vbox for trunk/src/VBox/Installer/win
- Timestamp:
- Jan 19, 2022 10:52:09 AM (3 years ago)
- Location:
- trunk/src/VBox/Installer/win/InstallHelper
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp
r93115 r93340 2 2 /** @file 3 3 * VBoxCommon - Misc helper routines for install helper. 4 * 5 * This is used by internal/serial.cpp and VBoxInstallHelper.cpp. 4 6 */ 5 7 … … 60 62 } 61 63 64 #if 0 /* unused */ 62 65 /** 63 66 * Retrieves a MSI property (in UTF-8). … … 90 93 return rc; 91 94 } 95 #endif 92 96 93 97 UINT VBoxSetMsiProp(MSIHANDLE hMsi, WCHAR *pwszName, WCHAR *pwszValue) -
trunk/src/VBox/Installer/win/InstallHelper/VBoxInstallHelper.cpp
r93335 r93340 23 23 # include "VBox/VBoxNetCfg-win.h" 24 24 # include "VBox/VBoxDrvCfg-win.h" 25 #endif /* VBOX_WITH_NETFLT */25 #endif 26 26 27 27 #include <VBox/version.h> … … 43 43 #include <devguid.h> 44 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> 45 #include <iprt/alloca.h> 46 #include <iprt/string.h> /* RT_ZERO */ 47 #include <iprt/path.h> /* RTPATH_MAX, RTPATH_IS_SLASH */ 51 48 52 49 #include <iprt/win/objbase.h> … … 74 71 75 72 73 74 /** 75 * DLL entry point. 76 */ 76 77 BOOL WINAPI DllMain(HANDLE hInst, ULONG uReason, LPVOID pReserved) 77 78 { 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); 99 80 return TRUE; 100 81 } 101 82 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 */ 89 static UINT logStringF(MSIHANDLE hInstall, const wchar_t *pwszFmt, ...) 103 90 { 104 91 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; 123 108 } 124 109 … … 144 129 145 130 /** 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 else165 {166 if ( pProcSts->iStatus != 0167 || 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 /**180 131 * Runs an executable on the OS. 181 132 * 182 * @returns VBox statuscode.183 * @param hModule 184 * @param p szImage Absolute path ofexecutable to run.185 * @param p apszArgs 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). 186 137 */ 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; 138 static 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; 193 166 #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 } 210 200 } 211 201 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; 215 207 } 216 208 … … 218 210 * Tries to retrieve the Python installation path on the system, extended version. 219 211 * 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. 232 219 */ 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); 220 static 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); 237 232 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; 250 244 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) 256 247 break; 257 AssertBreakStmt(dwKey <= sizeof(wszKey), VERR_BUFFER_OVERFLOW);258 259 /** @todo r=bird: Waste of space + effort, just append "\\InstallPath" to260 * 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);270 248 if (dwErr != ERROR_SUCCESS) 271 249 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; 305 320 } 306 321 … … 308 323 * Retrieves the absolute path of the Python installation. 309 324 * 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. 314 331 */ 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; 332 static 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; 322 338 } 323 339 … … 325 341 * Retrieves the absolute path of the Python executable. 326 342 * 327 * @returns VBox statuscode.328 * @param hModule 329 * @param p pszPythonExe 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. 331 347 */ 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; 348 static UINT getPythonExe(MSIHANDLE hModule, wchar_t *pwszPythonExe, size_t cwcPythonExe) 349 { 350 return getPythonPath(hModule, pwszPythonExe, cwcPythonExe, true /*fReturnExe*/); 339 351 } 340 352 … … 344 356 * @returns VBox status code, or error if depedencies are not met. 345 357 * @param hModule Windows installer module handle. 346 * @param p cszPythonExe Path to Python interpreter image (.exe).358 * @param pwszPythonExe Path to Python interpreter image (.exe). 347 359 */ 348 static int checkPythonDependencies(MSIHANDLE hModule, const char *pcszPythonExe)360 static int checkPythonDependencies(MSIHANDLE hModule, const wchar_t *pwszPythonExe) 349 361 { 350 362 /* … … 352 364 * This is a prerequisite for setting up the VBox API. 353 365 */ 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"); 361 371 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; 365 375 } 366 376 … … 378 388 UINT __stdcall IsPythonInstalled(MSIHANDLE hModule) 379 389 { 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"); 398 397 } 399 398 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 } 406 404 407 405 return ERROR_SUCCESS; /* Never return failure. */ … … 420 418 UINT __stdcall ArePythonAPIDepsInstalled(MSIHANDLE hModule) 421 419 { 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"); 438 433 return ERROR_SUCCESS; /* Never return failure. */ 439 434 } … … 451 446 UINT __stdcall InstallPythonAPI(MSIHANDLE hModule) 452 447 { 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) 458 454 { 459 455 VBoxSetMsiProp(hModule, L"VBOX_API_INSTALLED", L"0"); … … 465 461 */ 466 462 /* 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) 470 466 { 471 467 /* Make sure our current working directory is the VBox installation path. */ 472 rc = RTPathSetCurrent(pszVBoxSDKPath); 473 if (RT_SUCCESS(rc)) 468 if (SetCurrentDirectoryW(wszVBoxSDKPath)) 474 469 { 475 470 /* 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 } 486 496 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); 488 498 } 489 499 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()); 491 502 } 492 503 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()); 496 506 } 497 507 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"); 523 512 return ERROR_SUCCESS; /* Do not fail here. */ 524 513 } … … 552 541 (DWORD)wcslen(wszValue)); 553 542 if (rc != ERROR_SUCCESS) 554 logStringF(hModule, "InstallBranding: Could not write value %s! Error %ld", pwszValue, rc);555 RegCloseKey 543 logStringF(hModule, L"InstallBranding: Could not write value %s! Error %d", pwszValue, rc); 544 RegCloseKey(hkBranding); 556 545 } 557 546 } … … 575 564 s.pTo = wszDest; 576 565 s.pFrom = wszSource; 577 s.fFlags = FOF_SILENT |578 FOF_NOCONFIRMATION |579 FOF_NOCONFIRMMKDIR |580 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); 583 572 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); 587 578 rc = ERROR_GEN_FAILURE; 588 579 } 589 else590 rc = ERROR_SUCCESS;591 580 return rc; 592 581 } … … 608 597 | FOF_NOERRORUI; 609 598 610 logStringF(hModule, "RemoveDir: DestDir=%s", wszDest);599 logStringF(hModule, L"RemoveDir: DestDir=%s", wszDest); 611 600 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); 615 606 rc = ERROR_GEN_FAILURE; 616 607 } 617 else618 rc = ERROR_SUCCESS;619 608 return rc; 620 609 } … … 639 628 | FOF_NOERRORUI; 640 629 641 logStringF(hModule, "RenameDir: DestDir=%s, SourceDir=%s", wszDest, wszSource);630 logStringF(hModule, L"RenameDir: DestDir=%s, SourceDir=%s", wszDest, wszSource); 642 631 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); 646 637 rc = ERROR_GEN_FAILURE; 647 638 } 648 else649 rc = ERROR_SUCCESS;650 639 return rc; 651 640 } … … 654 643 { 655 644 UINT rc; 656 logStringF(hModule, "UninstallBranding: Handling branding file ...");645 logStringF(hModule, L"UninstallBranding: Handling branding file ..."); 657 646 658 647 WCHAR wszPathTargetDir[_MAX_PATH]; 659 WCHAR wszPathDest[_MAX_PATH];660 648 661 649 rc = VBoxGetMsiProp(hModule, L"CustomActionData", wszPathTargetDir, sizeof(wszPathTargetDir)); … … 669 657 * This applies almost to all swprintf_s calls in this file!! 670 658 */ 659 WCHAR wszPathDest[_MAX_PATH]; 671 660 swprintf_s(wszPathDest, RT_ELEMENTS(wszPathDest), L"%scustom", wszPathTargetDir); 672 661 rc = RemoveDir(hModule, wszPathDest); … … 679 668 } 680 669 681 logStringF(hModule, "UninstallBranding: Handling done. (rc=%u (ignored))", rc);670 logStringF(hModule, L"UninstallBranding: Handling done. (rc=%u (ignored))", rc); 682 671 return ERROR_SUCCESS; /* Do not fail here. */ 683 672 } … … 686 675 { 687 676 UINT rc; 688 logStringF(hModule, "InstallBranding: Handling branding file ...");677 logStringF(hModule, L"InstallBranding: Handling branding file ..."); 689 678 690 679 WCHAR wszPathMSI[_MAX_PATH]; … … 712 701 } 713 702 714 logStringF(hModule, "InstallBranding: Handling done. (rc=%u (ignored))", rc);703 logStringF(hModule, L"InstallBranding: Handling done. (rc=%u (ignored))", rc); 715 704 return ERROR_SUCCESS; /* Do not fail here. */ 716 705 } … … 743 732 case VBOXDRVCFG_LOG_SEVERITY_REL: 744 733 if (g_hCurrentModule) 745 logStringF(g_hCurrentModule, pszMsg);734 logStringF(g_hCurrentModule, L"%S", pszMsg); 746 735 break; 747 736 default: … … 753 742 { 754 743 if (g_hCurrentModule) 755 logStringF(g_hCurrentModule, pszString);744 logStringF(g_hCurrentModule, L"%S", pszString); 756 745 } 757 746 … … 790 779 case NETCFG_S_REBOOT: 791 780 { 792 logStringF(hModule, "Reboot required, setting REBOOT property to \"force\"");781 logStringF(hModule, L"Reboot required, setting REBOOT property to \"force\""); 793 782 HRESULT hr2 = MsiSetPropertyW(hModule, L"REBOOT", L"Force"); 794 783 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); 796 785 uRet = ERROR_SUCCESS; /* Never fail here. */ 797 786 break; … … 799 788 800 789 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); 802 791 uRet = ERROR_GEN_FAILURE; 803 792 } … … 813 802 if (uErr != ERROR_SUCCESS) 814 803 { 815 logStringF(hModule, "createNetCfgLockedMsgRecord: MsiRecordSetInteger failed, error = 0x%x", uErr);804 logStringF(hModule, L"createNetCfgLockedMsgRecord: MsiRecordSetInteger failed, error = %#x", uErr); 816 805 MsiCloseHandle(hRecord); 817 806 hRecord = NULL; … … 819 808 } 820 809 else 821 logStringF(hModule, "createNetCfgLockedMsgRecord: Failed to create a record");810 logStringF(hModule, L"createNetCfgLockedMsgRecord: Failed to create a record"); 822 811 823 812 return hRecord; … … 838 827 { 839 828 if (FAILED(hr)) 840 logStringF(hModule, "doNetCfgInit: VBoxNetCfgWinQueryINetCfg failed, error = 0x%x", hr);829 logStringF(hModule, L"doNetCfgInit: VBoxNetCfgWinQueryINetCfg failed, error = %#x", hr); 841 830 uErr = errorConvertFromHResult(hModule, hr); 842 831 break; … … 847 836 if (!lpszLockedBy) 848 837 { 849 logStringF(hModule, "doNetCfgInit: lpszLockedBy == NULL, breaking");838 logStringF(hModule, L"doNetCfgInit: lpszLockedBy == NULL, breaking"); 850 839 break; 851 840 } … … 861 850 { 862 851 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); 864 853 MsgResult = IDRETRY; 865 854 } … … 871 860 if (!hMsg) 872 861 { 873 logStringF(hModule, "doNetCfgInit: Failed to create a message record, breaking");862 logStringF(hModule, L"doNetCfgInit: Failed to create a message record, breaking"); 874 863 CoTaskMemFree(lpszLockedBy); 875 864 break; … … 881 870 if (rTmp != ERROR_SUCCESS) 882 871 { 883 logStringF(hModule, "doNetCfgInit: MsiRecordSetStringW failed, error = 0x%x", rTmp);872 logStringF(hModule, L"doNetCfgInit: MsiRecordSetStringW failed, error = #%x", rTmp); 884 873 CoTaskMemFree(lpszLockedBy); 885 874 break; … … 888 877 MsgResult = MsiProcessMessage(hModule, (INSTALLMESSAGE)(INSTALLMESSAGE_USER | MB_RETRYCANCEL), hMsg); 889 878 NonStandardAssert(MsgResult == IDRETRY || MsgResult == IDCANCEL); 890 logStringF(hModule, "doNetCfgInit: MsiProcessMessage returned (0x%x)", MsgResult);879 logStringF(hModule, L"doNetCfgInit: MsiProcessMessage returned (%#x)", MsgResult); 891 880 } 892 881 CoTaskMemFree(lpszLockedBy); … … 909 898 910 899 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); 912 901 913 902 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); 915 904 } 916 905 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); 918 907 else 919 908 { 920 logStringF(hModule, "vboxNetFltQueryInfArray: Empty installation directory");909 logStringF(hModule, L"vboxNetFltQueryInfArray: Empty installation directory"); 921 910 uErr = ERROR_GEN_FAILURE; 922 911 } … … 939 928 __try 940 929 { 941 logStringF(hModule, "Uninstalling NetFlt");930 logStringF(hModule, L"Uninstalling NetFlt"); 942 931 943 932 uErr = doNetCfgInit(hModule, &pNetCfg, TRUE); … … 946 935 HRESULT hr = VBoxNetCfgWinNetFltUninstall(pNetCfg); 947 936 if (hr != S_OK) 948 logStringF(hModule, "UninstallNetFlt: VBoxNetCfgWinUninstallComponent failed, error = 0x%x", hr);937 logStringF(hModule, L"UninstallNetFlt: VBoxNetCfgWinUninstallComponent failed, error = %#x", hr); 949 938 950 939 uErr = errorConvertFromHResult(hModule, hr); … … 952 941 VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE); 953 942 954 logStringF(hModule, "Uninstalling NetFlt done, error = 0x%x", uErr);943 logStringF(hModule, L"Uninstalling NetFlt done, error = %#x", uErr); 955 944 } 956 945 else 957 logStringF(hModule, "UninstallNetFlt: doNetCfgInit failed, error = 0x%x", uErr);946 logStringF(hModule, L"UninstallNetFlt: doNetCfgInit failed, error = %#x", uErr); 958 947 } 959 948 __finally … … 991 980 { 992 981 993 logStringF(hModule, "InstallNetFlt: Installing NetFlt");982 logStringF(hModule, L"InstallNetFlt: Installing NetFlt"); 994 983 995 984 uErr = doNetCfgInit(hModule, &pNetCfg, TRUE); … … 1004 993 HRESULT hr = VBoxNetCfgWinNetFltInstall(pNetCfg, &apwszInfs[0], RT_ELEMENTS(apwszInfs)); 1005 994 if (FAILED(hr)) 1006 logStringF(hModule, "InstallNetFlt: VBoxNetCfgWinNetFltInstall failed, error = 0x%x", hr);995 logStringF(hModule, L"InstallNetFlt: VBoxNetCfgWinNetFltInstall failed, error = %#x", hr); 1007 996 1008 997 uErr = errorConvertFromHResult(hModule, hr); 1009 998 } 1010 999 else 1011 logStringF(hModule, "InstallNetFlt: vboxNetFltQueryInfArray failed, error = 0x%x", uErr);1000 logStringF(hModule, L"InstallNetFlt: vboxNetFltQueryInfArray failed, error = %#x", uErr); 1012 1001 1013 1002 VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE); 1014 1003 1015 logStringF(hModule, "InstallNetFlt: Done");1004 logStringF(hModule, L"InstallNetFlt: Done"); 1016 1005 } 1017 1006 else 1018 logStringF(hModule, "InstallNetFlt: doNetCfgInit failed, error = 0x%x", uErr);1007 logStringF(hModule, L"InstallNetFlt: doNetCfgInit failed, error = %#x", uErr); 1019 1008 } 1020 1009 __finally … … 1052 1041 __try 1053 1042 { 1054 logStringF(hModule, "Uninstalling NetLwf");1043 logStringF(hModule, L"Uninstalling NetLwf"); 1055 1044 1056 1045 uErr = doNetCfgInit(hModule, &pNetCfg, TRUE); … … 1059 1048 HRESULT hr = VBoxNetCfgWinNetLwfUninstall(pNetCfg); 1060 1049 if (hr != S_OK) 1061 logStringF(hModule, "UninstallNetLwf: VBoxNetCfgWinUninstallComponent failed, error = 0x%x", hr);1050 logStringF(hModule, L"UninstallNetLwf: VBoxNetCfgWinUninstallComponent failed, error = %#x", hr); 1062 1051 1063 1052 uErr = errorConvertFromHResult(hModule, hr); … … 1065 1054 VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE); 1066 1055 1067 logStringF(hModule, "Uninstalling NetLwf done, error = 0x%x", uErr);1056 logStringF(hModule, L"Uninstalling NetLwf done, error = %#x", uErr); 1068 1057 } 1069 1058 else 1070 logStringF(hModule, "UninstallNetLwf: doNetCfgInit failed, error = 0x%x", uErr);1059 logStringF(hModule, L"UninstallNetLwf: doNetCfgInit failed, error = %#x", uErr); 1071 1060 } 1072 1061 __finally … … 1104 1093 { 1105 1094 1106 logStringF(hModule, "InstallNetLwf: Installing NetLwf");1095 logStringF(hModule, L"InstallNetLwf: Installing NetLwf"); 1107 1096 1108 1097 uErr = doNetCfgInit(hModule, &pNetCfg, TRUE); … … 1126 1115 HRESULT hr = VBoxNetCfgWinNetLwfInstall(pNetCfg, wszInf); 1127 1116 if (FAILED(hr)) 1128 logStringF(hModule, "InstallNetLwf: VBoxNetCfgWinNetLwfInstall failed, error = 0x%x", hr);1117 logStringF(hModule, L"InstallNetLwf: VBoxNetCfgWinNetLwfInstall failed, error = %#x", hr); 1129 1118 1130 1119 uErr = errorConvertFromHResult(hModule, hr); … … 1132 1121 else 1133 1122 { 1134 logStringF(hModule, "vboxNetFltQueryInfArray: Empty installation directory");1123 logStringF(hModule, L"vboxNetFltQueryInfArray: Empty installation directory"); 1135 1124 uErr = ERROR_GEN_FAILURE; 1136 1125 } 1137 1126 } 1138 1127 else 1139 logStringF(hModule, "vboxNetFltQueryInfArray: MsiGetPropertyW failed, error = 0x%x", uErr);1128 logStringF(hModule, L"vboxNetFltQueryInfArray: MsiGetPropertyW failed, error = %#x", uErr); 1140 1129 1141 1130 VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE); 1142 1131 1143 logStringF(hModule, "InstallNetLwf: Done");1132 logStringF(hModule, L"InstallNetLwf: Done"); 1144 1133 } 1145 1134 else 1146 logStringF(hModule, "InstallNetLwf: doNetCfgInit failed, error = 0x%x", uErr);1135 logStringF(hModule, L"InstallNetLwf: doNetCfgInit failed, error = %#x", uErr); 1147 1136 } 1148 1137 __finally … … 1233 1222 BOOL fSetupModeInteractive = SetupSetNonInteractiveMode(FALSE); 1234 1223 1235 logStringF(hModule, "CreateHostOnlyInterface: Creating host-only interface");1224 logStringF(hModule, L"CreateHostOnlyInterface: Creating host-only interface"); 1236 1225 1237 1226 HRESULT hr = E_FAIL; … … 1246 1235 if (cchMpInf) 1247 1236 { 1248 logStringF(hModule, "CreateHostOnlyInterface: NetAdpDir property = %s", wszMpInf);1237 logStringF(hModule, L"CreateHostOnlyInterface: NetAdpDir property = %s", wszMpInf); 1249 1238 if (wszMpInf[cchMpInf - 1] != L'\\') 1250 1239 { … … 1257 1246 fIsFile = true; 1258 1247 1259 logStringF(hModule, "CreateHostOnlyInterface: Resulting INF path = %s", pwszInfPath);1248 logStringF(hModule, L"CreateHostOnlyInterface: Resulting INF path = %s", pwszInfPath); 1260 1249 } 1261 1250 else 1262 logStringF(hModule, "CreateHostOnlyInterface: VBox installation path is empty");1251 logStringF(hModule, L"CreateHostOnlyInterface: VBox installation path is empty"); 1263 1252 } 1264 1253 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); 1266 1255 1267 1256 /* Make sure the inf file is installed. */ 1268 1257 if (pwszInfPath != NULL && fIsFile) 1269 1258 { 1270 logStringF(hModule, "CreateHostOnlyInterface: Calling VBoxDrvCfgInfInstall(%s)", pwszInfPath);1259 logStringF(hModule, L"CreateHostOnlyInterface: Calling VBoxDrvCfgInfInstall(%s)", pwszInfPath); 1271 1260 hr = VBoxDrvCfgInfInstall(pwszInfPath); 1272 logStringF(hModule, "CreateHostOnlyInterface: VBoxDrvCfgInfInstall returns 0x%x", hr);1261 logStringF(hModule, L"CreateHostOnlyInterface: VBoxDrvCfgInfInstall returns %#x", hr); 1273 1262 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); 1275 1264 } 1276 1265 … … 1284 1273 if (fRebootRequired) 1285 1274 { 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"); 1287 1276 HRESULT hr2 = MsiSetPropertyW(hModule, L"REBOOT", L"Force"); 1288 1277 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); 1290 1279 } 1291 1280 } … … 1293 1282 { 1294 1283 //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"); 1297 1286 #ifdef VBOXNETCFG_DELAYEDRENAME 1298 1287 BSTR devId; … … 1301 1290 hr = VBoxNetCfgWinCreateHostOnlyNetworkInterface(pwszInfPath, fIsFile, NULL, &guid, NULL, NULL); 1302 1291 #endif /* !VBOXNETCFG_DELAYEDRENAME */ 1303 logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface returns 0x%x", hr);1292 logStringF(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface returns %#x", hr); 1304 1293 if (SUCCEEDED(hr)) 1305 1294 { 1306 1295 ULONG ip = inet_addr("192.168.56.1"); 1307 1296 ULONG mask = inet_addr("255.255.255.0"); 1308 logStringF(hModule, "CreateHostOnlyInterface: calling VBoxNetCfgWinEnableStaticIpConfig");1297 logStringF(hModule, L"CreateHostOnlyInterface: calling VBoxNetCfgWinEnableStaticIpConfig"); 1309 1298 hr = VBoxNetCfgWinEnableStaticIpConfig(&guid, ip, mask); 1310 logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig returns 0x%x", hr);1299 logStringF(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig returns %#x", hr); 1311 1300 if (FAILED(hr)) 1312 logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig failed, error = 0x%x", hr);1301 logStringF(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig failed, error = %#x", hr); 1313 1302 #ifdef VBOXNETCFG_DELAYEDRENAME 1314 1303 hr = VBoxNetCfgWinRenameHostOnlyConnection(&guid, devId, NULL); 1315 1304 if (FAILED(hr)) 1316 logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinRenameHostOnlyConnection failed, error = 0x%x", hr);1305 logStringF(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinRenameHostOnlyConnection failed, error = %#x", hr); 1317 1306 SysFreeString(devId); 1318 1307 #endif /* VBOXNETCFG_DELAYEDRENAME */ 1319 1308 } 1320 1309 else 1321 logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface failed, error = 0x%x", hr);1310 logStringF(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface failed, error = %#x", hr); 1322 1311 } 1323 1312 } 1324 1313 1325 1314 if (SUCCEEDED(hr)) 1326 logStringF(hModule, "CreateHostOnlyInterface: Creating host-only interface done");1315 logStringF(hModule, L"CreateHostOnlyInterface: Creating host-only interface done"); 1327 1316 1328 1317 /* Restore original setup mode. */ 1329 logStringF(hModule, "CreateHostOnlyInterface: Almost done...");1318 logStringF(hModule, L"CreateHostOnlyInterface: Almost done..."); 1330 1319 if (fSetupModeInteractive) 1331 1320 SetupSetNonInteractiveMode(fSetupModeInteractive); … … 1335 1324 #endif /* VBOX_WITH_NETFLT */ 1336 1325 1337 logStringF(hModule, "CreateHostOnlyInterface: Returns success (ignoring all failures)");1326 logStringF(hModule, L"CreateHostOnlyInterface: Returns success (ignoring all failures)"); 1338 1327 /* Never fail the install even if we did not succeed. */ 1339 1328 return ERROR_SUCCESS; … … 1355 1344 netCfgLoggerEnable(hModule); 1356 1345 1357 logStringF(hModule, "RemoveHostOnlyInterfaces: Removing all host-only interfaces");1346 logStringF(hModule, L"RemoveHostOnlyInterfaces: Removing all host-only interfaces"); 1358 1347 1359 1348 BOOL fSetupModeInteractive = SetupSetNonInteractiveMode(FALSE); … … 1364 1353 hr = VBoxDrvCfgInfUninstallAllSetupDi(&GUID_DEVCLASS_NET, L"Net", pwszId, SUOI_FORCEDELETE/* could be SUOI_FORCEDELETE */); 1365 1354 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"); 1369 1356 else 1370 logStringF(hModule, "RemoveHostOnlyInterfaces: NetAdp uninstalled successfully"); 1371 1357 logStringF(hModule, L"RemoveHostOnlyInterfaces: NetAdp uninstalled successfully"); 1372 1358 } 1373 1359 else 1374 logStringF(hModule, "RemoveHostOnlyInterfaces: NetAdp uninstall failed, hr = 0x%x", hr);1360 logStringF(hModule, L"RemoveHostOnlyInterfaces: NetAdp uninstall failed, hr = %#x", hr); 1375 1361 1376 1362 /* Restore original setup mode. */ … … 1395 1381 netCfgLoggerEnable(hModule); 1396 1382 1397 logStringF(hModule, "StopHostOnlyInterfaces: Stopping all host-only interfaces");1383 logStringF(hModule, L"StopHostOnlyInterfaces: Stopping all host-only interfaces"); 1398 1384 1399 1385 BOOL fSetupModeInteractive = SetupSetNonInteractiveMode(FALSE); … … 1401 1387 HRESULT hr = VBoxNetCfgWinPropChangeAllNetDevicesOfId(pwszId, VBOXNECTFGWINPROPCHANGE_TYPE_DISABLE); 1402 1388 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); 1406 1390 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); 1408 1392 1409 1393 /* Restore original setup mode. */ … … 1428 1412 netCfgLoggerEnable(hModule); 1429 1413 1430 logStringF(hModule, "UpdateHostOnlyInterfaces: Updating all host-only interfaces");1414 logStringF(hModule, L"UpdateHostOnlyInterfaces: Updating all host-only interfaces"); 1431 1415 1432 1416 BOOL fSetupModeInteractive = SetupSetNonInteractiveMode(FALSE); … … 1441 1425 if (cchMpInf) 1442 1426 { 1443 logStringF(hModule, "UpdateHostOnlyInterfaces: NetAdpDir property = %s", wszMpInf);1427 logStringF(hModule, L"UpdateHostOnlyInterfaces: NetAdpDir property = %s", wszMpInf); 1444 1428 if (wszMpInf[cchMpInf - 1] != L'\\') 1445 1429 { … … 1452 1436 fIsFile = true; 1453 1437 1454 logStringF(hModule, "UpdateHostOnlyInterfaces: Resulting INF path = %s", pwszInfPath);1438 logStringF(hModule, L"UpdateHostOnlyInterfaces: Resulting INF path = %s", pwszInfPath); 1455 1439 1456 1440 DWORD attrFile = GetFileAttributesW(pwszInfPath); … … 1458 1442 { 1459 1443 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); 1462 1445 } 1463 1446 else 1464 1447 { 1465 logStringF(hModule, "UpdateHostOnlyInterfaces: File \"%s\" exists", 1466 pwszInfPath); 1448 logStringF(hModule, L"UpdateHostOnlyInterfaces: File \"%s\" exists", pwszInfPath); 1467 1449 1468 1450 BOOL fRebootRequired = FALSE; … … 1472 1454 if (fRebootRequired) 1473 1455 { 1474 logStringF(hModule, "UpdateHostOnlyInterfaces: Reboot required, setting REBOOT property to force");1456 logStringF(hModule, L"UpdateHostOnlyInterfaces: Reboot required, setting REBOOT property to force"); 1475 1457 HRESULT hr2 = MsiSetPropertyW(hModule, L"REBOOT", L"Force"); 1476 1458 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); 1478 1460 } 1479 1461 } 1480 1462 else 1481 logStringF(hModule, "UpdateHostOnlyInterfaces: VBoxNetCfgWinUpdateHostOnlyNetworkInterface failed, hr = 0x%x", hr);1463 logStringF(hModule, L"UpdateHostOnlyInterfaces: VBoxNetCfgWinUpdateHostOnlyNetworkInterface failed, hr = %#x", hr); 1482 1464 } 1483 1465 } 1484 1466 else 1485 logStringF(hModule, "UpdateHostOnlyInterfaces: VBox installation path is empty");1467 logStringF(hModule, L"UpdateHostOnlyInterfaces: VBox installation path is empty"); 1486 1468 } 1487 1469 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); 1489 1471 1490 1472 /* Restore original setup mode. */ … … 1521 1503 __try 1522 1504 { 1523 logStringF(hModule, "Uninstalling NetAdp");1505 logStringF(hModule, L"Uninstalling NetAdp"); 1524 1506 1525 1507 uErr = doNetCfgInit(hModule, &pNetCfg, TRUE); … … 1528 1510 HRESULT hr = VBoxNetCfgWinNetAdpUninstall(pNetCfg, pwszId); 1529 1511 if (hr != S_OK) 1530 logStringF(hModule, "UninstallNetAdp: VBoxNetCfgWinUninstallComponent failed, error = 0x%x", hr);1512 logStringF(hModule, L"UninstallNetAdp: VBoxNetCfgWinUninstallComponent failed, error = %#x", hr); 1531 1513 1532 1514 uErr = errorConvertFromHResult(hModule, hr); … … 1534 1516 VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE); 1535 1517 1536 logStringF(hModule, "Uninstalling NetAdp done, error = 0x%x", uErr);1518 logStringF(hModule, L"Uninstalling NetAdp done, error = %#x", uErr); 1537 1519 } 1538 1520 else 1539 logStringF(hModule, "UninstallNetAdp: doNetCfgInit failed, error = 0x%x", uErr);1521 logStringF(hModule, L"UninstallNetAdp: doNetCfgInit failed, error = %#x", uErr); 1540 1522 } 1541 1523 __finally … … 1634 1616 { 1635 1617 int rc = 1; 1636 do 1618 do /* break-loop */ 1637 1619 { 1638 1620 WCHAR wszPnPInstanceId[512] = {0}; … … 1651 1633 LONG lStatus = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszRegLocation, 0, KEY_READ, &hkeyNetwork); 1652 1634 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]", 1654 1636 wszRegLocation)); 1655 1637 1656 1638 lStatus = RegOpenKeyExW(hkeyNetwork, L"Connection", 0, KEY_READ, &hkeyConnection); 1657 1639 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]", 1659 1641 wszRegLocation)); 1660 1642 … … 1664 1646 &dwKeyType, (LPBYTE)&wszPnPInstanceId[0], &len); 1665 1647 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]", 1667 1649 wszRegLocation)); 1668 1650 } … … 1682 1664 BOOL fResult; 1683 1665 1684 do 1666 do /* break-loop */ 1685 1667 { 1686 1668 GUID netGuid; … … 1699 1681 if (hDeviceInfo == INVALID_HANDLE_VALUE) 1700 1682 { 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!")); 1703 1685 } 1704 1686 … … 1802 1784 if (!fResult) 1803 1785 { 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!")); 1806 1788 } 1807 1789 … … 1809 1791 if (!fResult) 1810 1792 { 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!")); 1813 1795 } 1814 1796 } 1815 1797 else 1816 SetErrBreak((hModule, "VBox HostInterfaces: Host interface network device not found!"));1798 SetErrBreak((hModule, L"VBox HostInterfaces: Host interface network device not found!")); 1817 1799 } while (0); 1818 1800 … … 1826 1808 UINT __stdcall UninstallTAPInstances(MSIHANDLE hModule) 1827 1809 { 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}"; 1829 1811 HKEY hCtrlNet; 1830 1812 … … 1832 1814 if (lStatus == ERROR_SUCCESS) 1833 1815 { 1834 logStringF(hModule, "VBox HostInterfaces: Enumerating interfaces ...");1816 logStringF(hModule, L"VBox HostInterfaces: Enumerating interfaces ..."); 1835 1817 for (int i = 0; ; ++i) 1836 1818 { … … 1843 1825 { 1844 1826 case ERROR_NO_MORE_ITEMS: 1845 logStringF(hModule, "VBox HostInterfaces: No interfaces found.");1827 logStringF(hModule, L"VBox HostInterfaces: No interfaces found."); 1846 1828 break; 1847 1829 default: 1848 logStringF(hModule, "VBox HostInterfaces: Enumeration failed: %ld", lStatus);1830 logStringF(hModule, L"VBox HostInterfaces: Enumeration failed: %ld", lStatus); 1849 1831 break; 1850 1832 } … … 1854 1836 if (isTAPDevice(wszNetworkGUID)) 1855 1837 { 1856 logStringF(hModule, "VBox HostInterfaces: Removing interface \"%s\" ...", wszNetworkGUID);1838 logStringF(hModule, L"VBox HostInterfaces: Removing interface \"%s\" ...", wszNetworkGUID); 1857 1839 removeNetworkInterface(hModule, wszNetworkGUID); 1858 1840 lStatus = RegDeleteKeyW(hCtrlNet, wszNetworkGUID); … … 1860 1842 } 1861 1843 RegCloseKey(hCtrlNet); 1862 logStringF(hModule, "VBox HostInterfaces: Removing interfaces done.");1844 logStringF(hModule, L"VBox HostInterfaces: Removing interfaces done."); 1863 1845 } 1864 1846 return ERROR_SUCCESS; … … 1895 1877 QueryServiceStatus(hService, &Status); 1896 1878 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"); 1898 1880 else 1899 1881 { 1900 logStringF(hModule, "VBoxDrv: Stopping the service (state %u)", Status.dwCurrentState);1882 logStringF(hModule, L"VBoxDrv: Stopping the service (state %u)", Status.dwCurrentState); 1901 1883 if (ControlService(hService, SERVICE_CONTROL_STOP, &Status)) 1902 1884 { … … 1910 1892 1911 1893 if (Status.dwCurrentState == SERVICE_STOPPED) 1912 logStringF(hModule, "VBoxDrv: Stopped service");1894 logStringF(hModule, L"VBoxDrv: Stopped service"); 1913 1895 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); 1915 1897 } 1916 1898 else … … 1919 1901 if ( Status.dwCurrentState == SERVICE_STOP_PENDING 1920 1902 && 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"); 1922 1904 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); 1924 1906 } 1925 1907 } … … 1929 1911 */ 1930 1912 if (DeleteService(hService)) 1931 logStringF(hModule, "VBoxDrv: Successfully delete service");1913 logStringF(hModule, L"VBoxDrv: Successfully delete service"); 1932 1914 else 1933 logStringF(hModule, "VBoxDrv: Failed to delete the service: %u", GetLastError());1915 logStringF(hModule, L"VBoxDrv: Failed to delete the service: %u", GetLastError()); 1934 1916 1935 1917 CloseServiceHandle(hService); … … 1939 1921 DWORD const dwErr = GetLastError(); 1940 1922 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"); 1942 1924 else 1943 logStringF(hModule, "VBoxDrv: Failed to open the service: %u", dwErr);1925 logStringF(hModule, L"VBoxDrv: Failed to open the service: %u", dwErr); 1944 1926 } 1945 1927 … … 1947 1929 } 1948 1930 else 1949 logStringF(hModule, "VBoxDrv: Failed to open service manager (%u).", GetLastError());1931 logStringF(hModule, L"VBoxDrv: Failed to open service manager (%u).", GetLastError()); 1950 1932 1951 1933 return ERROR_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.