VBoxInstallHelper.cpp revision 056add8311718c0166b7036b31fd581858a607b3
3184fc1a3e65025cd55704cdb1629f4ab1f3ccd2vboxsync * VBoxInstallHelper - Various helper routines for Windows host installer.
056add8311718c0166b7036b31fd581858a607b3vboxsync * Copyright (C) 2008-2014 Oracle Corporation
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync * available from http://www.virtualbox.org. This file is free software;
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync * you can redistribute it and/or modify it under the terms of the GNU
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync * General Public License (GPL) as published by the Free Software
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync/*******************************************************************************
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync* Header Files *
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync*******************************************************************************/
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync#endif /* VBOX_WITH_NETFLT */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync/*******************************************************************************
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync* Header Files *
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync*******************************************************************************/
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsyncstatic void logString(MSIHANDLE hInstall, LPCSTR szString, ...)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync _vsnprintf(szBuffer, sizeof(szBuffer), szString, va);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync MsiProcessMessage(hInstall, INSTALLMESSAGE(INSTALLMESSAGE_INFO), newHandle);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync#if 0/*def DEBUG - wrong? What does '%s' expect, wchar or char? */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsyncstatic void logStringW(MSIHANDLE hInstall, LPCWSTR pwszString, ...)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync _vsnwprintf(szBuffer, RT_ELEMENTS(szBuffer), pwszString, va);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync MsiProcessMessage(hInstall, INSTALLMESSAGE(INSTALLMESSAGE_INFO), newHandle);
d97357e2036109245c83ba553d0290212e28ea40vboxsyncUINT __stdcall IsSerialCheckNeeded(MSIHANDLE hModule)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync const WCHAR *pwszAppName, WCHAR *pwszCmdLine, const WCHAR *pwszWorkDir,
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync si.wShowWindow = SW_HIDE; /* For debugging: SW_SHOW; */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"Executing command line: %s %s (Working Dir: %s)",
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync pwszAppName, pwszCmdLine, pwszWorkDir == NULL ? L"Current" : pwszWorkDir);
fba7ec2ca5a120ca53275eebdfa69425ce0e9829vboxsync if (!CreateProcessW(pwszAppName, /* Module name. */
fba7ec2ca5a120ca53275eebdfa69425ce0e9829vboxsync 0, /* No creation flags. */
fba7ec2ca5a120ca53275eebdfa69425ce0e9829vboxsync pwszWorkDir, /* Use parent's starting directory. */
fba7ec2ca5a120ca53275eebdfa69425ce0e9829vboxsync &pi)) /* Pointer to PROCESS_INFORMATION structure. */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"Executing command line: CreateProcess() failed! Error: %ld", rc);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* Wait until child process exits. */
254e593d079dbddd48135ebe2893334eb36dcbafvboxsync if (WAIT_FAILED == WaitForSingleObject(pi.hProcess, 30 * 1000 /* Wait 30 secs max. */))
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"Executing command line: WaitForSingleObject() failed! Error: %u", rc);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"Executing command line: GetExitCodeProcess() failed! Error: %u", rc);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* Close process and thread handles. */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"Executing command returned: %u (exit code %u)", rc, *pdwExitCode);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallPythonAPI: Checking for installed Python environment ...");
fba7ec2ca5a120ca53275eebdfa69425ce0e9829vboxsync LONG rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Python\\PythonCore", 0, KEY_READ, &hkPythonCore);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallPythonAPI: Python seems not to be installed.");
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync for (int i = 0;; ++i)
fba7ec2ca5a120ca53275eebdfa69425ce0e9829vboxsync rc = RegEnumKeyExW(hkPythonCore, i, wszRoot, &dwLen, NULL, NULL, NULL, NULL);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszPath, RT_ELEMENTS(wszPath), L"%s\\InstallPath", wszRoot);
fba7ec2ca5a120ca53275eebdfa69425ce0e9829vboxsync rc = RegOpenKeyExW(hkPythonCore, wszPath, 0, KEY_READ, &hkPythonInstPath);
fba7ec2ca5a120ca53275eebdfa69425ce0e9829vboxsync rc = RegQueryValueExW(hkPythonInstPath, L"", NULL, &dwKeyType, (LPBYTE)wszVal, &dwLen);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallPythonAPI: Path \"%s\" detected.", wszVal);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* Python path found? */
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* Cool, check for installed Win32 extensions. */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallPythonAPI: Python installed. Checking for Win32 extensions ...");
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszExec, RT_ELEMENTS(wszExec), L"%s\\python.exe", wszVal);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszCmdLine, RT_ELEMENTS(wszCmdLine), L"%s\\python.exe -c \"import win32api\"", wszVal);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync DWORD dwRetExec = Exec(hModule, wszExec, wszCmdLine, NULL, &dwExitCode);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* Did we get the correct error level (=0)? */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallPythonAPI: Win32 extensions installed.");
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallPythonAPI: Win32 extensions not found.");
d97357e2036109245c83ba553d0290212e28ea40vboxsync if (bFound) /* Is Python and all required stuff installed? */
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* Get the VBoxAPI setup string. */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync VBoxGetProperty(hModule, L"CustomActionData", wszPathTargetDir, sizeof(wszPathTargetDir));
254e593d079dbddd48135ebe2893334eb36dcbafvboxsync /* Set final path. */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszPath, RT_ELEMENTS(wszPath), L"%s\\sdk\\install", wszPathTargetDir);
254e593d079dbddd48135ebe2893334eb36dcbafvboxsync /* Install our API module. */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszCmdLine, RT_ELEMENTS(wszCmdLine), L"%s\\python.exe vboxapisetup.py install", wszVal);
254e593d079dbddd48135ebe2893334eb36dcbafvboxsync /* Set required environment variables. */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync if (!SetEnvironmentVariableW(L"VBOX_INSTALL_PATH", wszPathTargetDir))
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallPythonAPI: Could set environment variable VBOX_INSTALL_PATH!");
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync DWORD dwRetExec = Exec(hModule, wszExec, wszCmdLine, wszPath, &dwExitCode);
254e593d079dbddd48135ebe2893334eb36dcbafvboxsync /* All done! */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallPythonAPI: VBoxAPI for Python successfully installed.");
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallPythonAPI: Error while executing installation of VBox API: %ld", dwRetExec);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallPythonAPI: Python reported an error while installing VBox API: %ld", dwExitCode);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallPythonAPI: Unable to retrieve VBox installation path!");
056add8311718c0166b7036b31fd581858a607b3vboxsync VBoxSetProperty(hModule, L"VBOX_PYTHON_IS_INSTALLED", bInstalled ? L"1" : L"0");
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallPythonAPI: VBox API not installed.");
fba7ec2ca5a120ca53275eebdfa69425ce0e9829vboxsync if (GetPrivateProfileStringW(pwszSection, pwszValue, NULL,
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszKey, RT_ELEMENTS(wszKey), L"SOFTWARE\\%s\\VirtualBox\\Branding\\", VBOX_VENDOR_SHORT, pwszSection);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszKey, RT_ELEMENTS(wszKey), L"SOFTWARE\\%s\\VirtualBox\\Branding", VBOX_VENDOR_SHORT);
fba7ec2ca5a120ca53275eebdfa69425ce0e9829vboxsync rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszKey, 0, KEY_WRITE, &hkBranding);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallBranding: Could not write value %s! Error %ld", pwszValue, rc);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsyncUINT CopyDir(MSIHANDLE hModule, const WCHAR *pwszDestDir, const WCHAR *pwszSourceDir)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszDest, RT_ELEMENTS(wszDest), L"%s%c", pwszDestDir, '\0');
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszSource, RT_ELEMENTS(wszSource), L"%s%c", pwszSourceDir, '\0');
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"CopyDir: DestDir=%s, SourceDir=%s", wszDest, wszSource);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync if (r != 0)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"CopyDir: Copy operation returned status 0x%x", r);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsyncUINT RemoveDir(MSIHANDLE hModule, const WCHAR *pwszDestDir)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszDest, RT_ELEMENTS(wszDest), L"%s%c", pwszDestDir, '\0');
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"RemoveDir: DestDir=%s", wszDest);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync if (r != 0)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"RemoveDir: Remove operation returned status 0x%x", r);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsyncUINT RenameDir(MSIHANDLE hModule, const WCHAR *pwszDestDir, const WCHAR *pwszSourceDir)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszDest, RT_ELEMENTS(wszDest), L"%s%c", pwszDestDir, '\0');
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszSource, RT_ELEMENTS(wszSource), L"%s%c", pwszSourceDir, '\0');
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"RenameDir: DestDir=%s, SourceDir=%s", wszDest, wszSource);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync if (r != 0)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"RenameDir: Rename operation returned status 0x%x", r);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"UninstallBranding: Handling branding file ...");
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync rc = VBoxGetProperty(hModule, L"CustomActionData", wszPathTargetDir, sizeof(wszPathTargetDir));
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /** @todo Check trailing slash after %s. */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync/** @todo r=bird: using swprintf_s for formatting paths without checking for
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync * overflow not good. You're dodging the buffer overflow issue only to end up
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync * with incorrect behavior! (Truncated file/dir names)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync * This applies almost to all swprintf_s calls in this file!!
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszPathDest, RT_ELEMENTS(wszPathDest), L"%scustom", wszPathTargetDir);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* Check for hidden .custom directory and remove it. */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszPathDest, RT_ELEMENTS(wszPathDest), L"%s.custom", wszPathTargetDir);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"UninstallBranding: Handling done. (rc=%u (ignored))", rc);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallBranding: Handling branding file ...");
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync rc = VBoxGetProperty(hModule, L"SOURCEDIR", wszPathMSI, sizeof(wszPathMSI));
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync rc = VBoxGetProperty(hModule, L"CustomActionData", wszPathTargetDir, sizeof(wszPathTargetDir));
d97357e2036109245c83ba553d0290212e28ea40vboxsync /** @todo Check for trailing slash after %s. */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszPathDest, RT_ELEMENTS(wszPathDest), L"%s", wszPathTargetDir);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszPathSource, RT_ELEMENTS(wszPathSource), L"%s.custom", wszPathMSI);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszPathDest, RT_ELEMENTS(wszPathDest), L"%scustom", wszPathTargetDir);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync swprintf_s(wszPathSource, RT_ELEMENTS(wszPathSource), L"%s.custom", wszPathTargetDir);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync rc = RenameDir(hModule, wszPathDest, wszPathSource);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallBranding: Handling done. (rc=%u (ignored))", rc);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync/** @todo should use some real VBox app name */
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync#define VBOX_NETCFG_APP_NAME L"VirtualBox Installer"
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync#define NETFLT_PT_INF_REL_PATH L"drivers\\network\\netflt\\VBoxNetFlt.inf"
be6a7ee8f237a71cf075c128e8e391e6c3654687vboxsync#define NETFLT_MP_INF_REL_PATH L"drivers\\network\\netflt\\VBoxNetFltM.inf"
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync#define NETFLT_ID L"sun_VBoxNetFlt" /** @todo Needs to be changed (?). */
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync#define NETADP_ID L"sun_VBoxNetAdp" /** @todo Needs to be changed (?). */
d97357e2036109245c83ba553d0290212e28ea40vboxsync VBoxNetCfgWinSetLogging((LOG_ROUTINE)netCfgLoggerCallback);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsyncstatic UINT errorConvertFromHResult(MSIHANDLE hModule, HRESULT hr)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"Reboot required, setting REBOOT property to Force");
fba7ec2ca5a120ca53275eebdfa69425ce0e9829vboxsync HRESULT hr2 = MsiSetPropertyW(hModule, L"REBOOT", L"Force");
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"Failed to set REBOOT property, error = 0x%x", hr2);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"Converting unhandled HRESULT (0x%x) to ERROR_GEN_FAILURE", hr);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsyncstatic MSIHANDLE createNetCfgLockedMsgRecord(MSIHANDLE hModule)
d97357e2036109245c83ba553d0290212e28ea40vboxsync UINT uErr = MsiRecordSetInteger(hRecord, 1, 25001);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"createNetCfgLockedMsgRecord: MsiRecordSetInteger failed, error = 0x%x", uErr);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"createNetCfgLockedMsgRecord: Failed to create a record");
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsyncstatic UINT doNetCfgInit(MSIHANDLE hModule, INetCfg **ppnc, BOOL bWrite)
be6a7ee8f237a71cf075c128e8e391e6c3654687vboxsync HRESULT hr = VBoxNetCfgWinQueryINetCfg(ppnc, bWrite, VBOX_NETCFG_APP_NAME, 10000, &lpszLockedBy);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"doNetCfgInit: VBoxNetCfgWinQueryINetCfg failed, error = 0x%x", hr);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* hr == NETCFG_E_NO_WRITE_LOCK */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"doNetCfgInit: lpszLockedBy == NULL, breaking");
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* on vista the 6to4svc.dll periodically maintains the lock for some reason,
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync * if this is the case, increase the wait period by retrying multiple times
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync * NOTE: we could alternatively increase the wait timeout,
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync * however it seems unneeded for most cases, e.g. in case some network connection property
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync * dialog is opened, it would be better to post a notification to the user as soon as possible
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync * rather than waiting for a longer period of time before displaying it */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"doNetCfgInit: lpszLockedBy is 6to4svc.dll, retrying %d out of %d", cRetries, VBOX_NETCFG_MAX_RETRIES);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"doNetCfgInit: Failed to create a message record, breaking");
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync UINT rTmp = MsiRecordSetStringW(hMsg, 2, lpszLockedBy);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"doNetCfgInit: MsiRecordSetStringW failed, error = 0x%x", rTmp);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync MsgResult = MsiProcessMessage(hModule, (INSTALLMESSAGE)(INSTALLMESSAGE_USER | MB_RETRYCANCEL), hMsg);
1cede4c702f5b7f8734214a2a5d5bc516b47b330vboxsync NonStandardAssert(MsgResult == IDRETRY || MsgResult == IDCANCEL);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"doNetCfgInit: MsiProcessMessage returned (0x%x)", MsgResult);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsyncstatic UINT vboxNetFltQueryInfArray(MSIHANDLE hModule, OUT LPWSTR pwszPtInf, OUT LPWSTR pwszMpInf, DWORD dwSize)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync DWORD dwBuf = dwSize - RT_MAX(sizeof(NETFLT_PT_INF_REL_PATH), sizeof(NETFLT_MP_INF_REL_PATH));
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync UINT uErr = MsiGetPropertyW(hModule, L"CustomActionData", pwszPtInf, &dwBuf);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync wcsncat(pwszPtInf, NETFLT_PT_INF_REL_PATH, sizeof(NETFLT_PT_INF_REL_PATH));
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"vboxNetFltQueryInfArray: INF 1: %s", pwszPtInf);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync wcsncat(pwszMpInf, NETFLT_MP_INF_REL_PATH, sizeof(NETFLT_MP_INF_REL_PATH));
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"vboxNetFltQueryInfArray: INF 2: %s", pwszMpInf);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"vboxNetFltQueryInfArray: MsiGetPropertyW failed, error = 0x%x", uErr);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"vboxNetFltQueryInfArray: Empty installation directory");
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync#endif /*VBOX_WITH_NETFLT*/
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync BOOL bOldIntMode = SetupSetNonInteractiveMode(FALSE);
d97357e2036109245c83ba553d0290212e28ea40vboxsync HRESULT hr = VBoxNetCfgWinNetFltUninstall(pNetCfg);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"UninstallNetFlt: VBoxNetCfgWinUninstallComponent failed, error = 0x%x", hr);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"Uninstalling NetFlt done, error = 0x%x", uErr);
d97357e2036109245c83ba553d0290212e28ea40vboxsync /* Never fail on uninstall. */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"UninstallNetFlt: doNetCfgInit failed, error = 0x%x", uErr);
d97357e2036109245c83ba553d0290212e28ea40vboxsync /* The prev mode != FALSE, i.e. non-interactive. */
d97357e2036109245c83ba553d0290212e28ea40vboxsync#endif /* VBOX_WITH_NETFLT */
d97357e2036109245c83ba553d0290212e28ea40vboxsync /* Never fail the install even if we did not succeed. */
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync BOOL bOldIntMode = SetupSetNonInteractiveMode(FALSE);
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"InstallNetFlt: Installing NetFlt");
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync uErr = vboxNetFltQueryInfArray(hModule, wszPtInf, wszMpInf, sizeof(wszMpInf));
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync LPCWSTR const apwszInfs[] = { wszPtInf, wszMpInf };
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync HRESULT hr = VBoxNetCfgWinNetFltInstall(pNetCfg, &apwszInfs[0], RT_ELEMENTS(apwszInfs));
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallNetFlt: VBoxNetCfgWinNetFltInstall failed, error = 0x%x", hr);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallNetFlt: vboxNetFltQueryInfArray failed, error = 0x%x", uErr);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"InstallNetFlt: doNetCfgInit failed, error = 0x%x", uErr);
d97357e2036109245c83ba553d0290212e28ea40vboxsync /* The prev mode != FALSE, i.e. non-interactive. */
d97357e2036109245c83ba553d0290212e28ea40vboxsync#endif /* VBOX_WITH_NETFLT */
d97357e2036109245c83ba553d0290212e28ea40vboxsync /* Never fail the install even if we did not succeed. */
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsyncstatic BOOL RenameHostOnlyConnectionsCallback(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDev, PVOID pContext)
d97357e2036109245c83ba553d0290212e28ea40vboxsync if (SetupDiGetDeviceRegistryPropertyW(hDevInfo, pDev,
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync 0, /*IN DWORD HwProfile, */
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync L"NetCfgInstanceId", /*__in_opt LPCTSTR lpValueName,*/
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync HRESULT hr = VBoxNetCfgWinGenHostonlyConnectionName (DevName, ConnectoinName, &cbName);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync hr = VBoxNetCfgWinRenameConnection(guid, ConnectoinName);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsyncUINT __stdcall CreateHostOnlyInterface(MSIHANDLE hModule)
d97357e2036109245c83ba553d0290212e28ea40vboxsync BOOL bSetupModeInteractive = SetupSetNonInteractiveMode(FALSE);
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"CreateHostOnlyInterface: Creating host-only interface");
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync HRESULT hr = VBoxNetCfgWinRemoveAllNetDevicesOfId(NETADP_ID);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinRemoveAllNetDevicesOfId failed, error = 0x%x", hr);
0824e642d6a2ba2cde6077003d9c99b0197eab34vboxsync DWORD cchMpInf = RT_ELEMENTS(wszMpInf) - sizeof("drivers\\network\\netadp\\VBoxNetAdp.inf") - 1;
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync bool bIsFile = false;
0824e642d6a2ba2cde6077003d9c99b0197eab34vboxsync UINT uErr = MsiGetPropertyW(hModule, L"CustomActionData", wszMpInf, &cchMpInf);
0824e642d6a2ba2cde6077003d9c99b0197eab34vboxsync logStringW(hModule, L"CreateHostOnlyInterface: NetAdpDir property = %s", wszMpInf);
0824e642d6a2ba2cde6077003d9c99b0197eab34vboxsync wcscat(wszMpInf, L"drivers\\network\\netadp\\VBoxNetAdp.inf");
0824e642d6a2ba2cde6077003d9c99b0197eab34vboxsync logStringW(hModule, L"CreateHostOnlyInterface: Resulting INF path = %s", pwszInfPath);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"CreateHostOnlyInterface: NetAdpDir property value is empty");
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"CreateHostOnlyInterface: Failed to get NetAdpDir property, error = 0x%x", uErr);
d97357e2036109245c83ba553d0290212e28ea40vboxsync /* Make sure the inf file is installed. */
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"CreateHostOnlyInterface: Calling VBoxDrvCfgInfInstall(%s)", pwszInfPath);
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"CreateHostOnlyInterface: VBoxDrvCfgInfInstall returns 0x%x", hr);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"CreateHostOnlyInterface: Failed to install INF file, error = 0x%x", hr);
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"CreateHostOnlyInterface: calling VBoxNetCfgWinCreateHostOnlyNetworkInterface");
0824e642d6a2ba2cde6077003d9c99b0197eab34vboxsync hr = VBoxNetCfgWinCreateHostOnlyNetworkInterface(pwszInfPath, bIsFile, &guid, NULL, NULL);
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface returns 0x%x", hr);
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"CreateHostOnlyInterface: calling VBoxNetCfgWinEnableStaticIpConfig");
d97357e2036109245c83ba553d0290212e28ea40vboxsync hr = VBoxNetCfgWinEnableStaticIpConfig(&guid, ip, mask);
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig returns 0x%x", hr);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig failed, error = 0x%x", hr);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface failed, error = 0x%x", hr);
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"CreateHostOnlyInterface: Creating host-only interface done");
d97357e2036109245c83ba553d0290212e28ea40vboxsync /* Restore original setup mode. */
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"CreateHostOnlyInterface: Almost done...");
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync#endif /* VBOX_WITH_NETFLT */
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"CreateHostOnlyInterface: Returns success (ignoring all failures)");
d97357e2036109245c83ba553d0290212e28ea40vboxsync /* Never fail the install even if we did not succeed. */
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsyncUINT __stdcall RemoveHostOnlyInterfaces(MSIHANDLE hModule)
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"RemoveHostOnlyInterfaces: Removing all host-only interfaces");
d97357e2036109245c83ba553d0290212e28ea40vboxsync BOOL bSetupModeInteractive = SetupSetNonInteractiveMode(FALSE);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync HRESULT hr = VBoxNetCfgWinRemoveAllNetDevicesOfId(NETADP_ID);
2fa05a4e777b070ba9bf01e3dd46434c99cd06a3vboxsync hr = VBoxDrvCfgInfUninstallAllSetupDi(&GUID_DEVCLASS_NET, NETADP_ID, L"Net", 0/* could be SUOI_FORCEDELETE */);
950867fcd91ff725bbcc44623ae3d8888ed32da2vboxsync logStringW(hModule, L"RemoveHostOnlyInterfaces: NetAdp uninstalled successfully, but failed to remove infs");
950867fcd91ff725bbcc44623ae3d8888ed32da2vboxsync logStringW(hModule, L"RemoveHostOnlyInterfaces: NetAdp uninstall failed, hr = 0x%x", hr);
d97357e2036109245c83ba553d0290212e28ea40vboxsync /* Restore original setup mode. */
d97357e2036109245c83ba553d0290212e28ea40vboxsync#endif /* VBOX_WITH_NETFLT */
d97357e2036109245c83ba553d0290212e28ea40vboxsync /* Never fail the install even if we did not succeed. */
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsyncUINT __stdcall StopHostOnlyInterfaces(MSIHANDLE hModule)
950867fcd91ff725bbcc44623ae3d8888ed32da2vboxsync logStringW(hModule, L"StopHostOnlyInterfaces: Stopping all host-only interfaces");
c42011aa94dc0c1fdd2acefda7a48c5c8cd23d10vboxsync BOOL bSetupModeInteractive = SetupSetNonInteractiveMode(FALSE);
c42011aa94dc0c1fdd2acefda7a48c5c8cd23d10vboxsync HRESULT hr = VBoxNetCfgWinPropChangeAllNetDevicesOfId(NETADP_ID, VBOXNECTFGWINPROPCHANGE_TYPE_DISABLE);
c42011aa94dc0c1fdd2acefda7a48c5c8cd23d10vboxsync hr = VBoxDrvCfgInfUninstallAllSetupDi(&GUID_DEVCLASS_NET, NETADP_ID, L"Net", 0/* could be SUOI_FORCEDELETE */);
950867fcd91ff725bbcc44623ae3d8888ed32da2vboxsync logStringW(hModule, L"StopHostOnlyInterfaces: VBoxDrvCfgInfUninstallAllSetupDi failed, hr = 0x%x", hr);
950867fcd91ff725bbcc44623ae3d8888ed32da2vboxsync logStringW(hModule, L"StopHostOnlyInterfaces: Disabling host interfaces failed, hr = 0x%x", hr);
c42011aa94dc0c1fdd2acefda7a48c5c8cd23d10vboxsync /* Restore original setup mode. */
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync#endif /* VBOX_WITH_NETFLT */
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync /* Never fail the install even if we did not succeed. */
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsyncUINT __stdcall UpdateHostOnlyInterfaces(MSIHANDLE hModule)
950867fcd91ff725bbcc44623ae3d8888ed32da2vboxsync logStringW(hModule, L"UpdateHostOnlyInterfaces: Updating all host-only interfaces");
c42011aa94dc0c1fdd2acefda7a48c5c8cd23d10vboxsync BOOL bSetupModeInteractive = SetupSetNonInteractiveMode(FALSE);
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync DWORD cchMpInf = RT_ELEMENTS(wszMpInf) - sizeof("drivers\\network\\netadp\\VBoxNetAdp.inf") - 1;
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync bool bIsFile = false;
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync UINT uErr = MsiGetPropertyW(hModule, L"CustomActionData", wszMpInf, &cchMpInf);
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"UpdateHostOnlyInterfaces: NetAdpDir property = %s", wszMpInf);
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync wcscat(wszMpInf, L"drivers\\network\\netadp\\VBoxNetAdp.inf");
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"UpdateHostOnlyInterfaces: Resulting INF path = %s", pwszInfPath);
950867fcd91ff725bbcc44623ae3d8888ed32da2vboxsync logStringW(hModule, L"UpdateHostOnlyInterfaces: File \"%s\" not found, dwErr=%ld",
950867fcd91ff725bbcc44623ae3d8888ed32da2vboxsync logStringW(hModule, L"UpdateHostOnlyInterfaces: File \"%s\" exists",
950867fcd91ff725bbcc44623ae3d8888ed32da2vboxsync HRESULT hr = VBoxNetCfgWinUpdateHostOnlyNetworkInterface(pwszInfPath, &fRebootRequired);
950867fcd91ff725bbcc44623ae3d8888ed32da2vboxsync logStringW(hModule, L"UpdateHostOnlyInterfaces: Reboot required, setting REBOOT property to force");
950867fcd91ff725bbcc44623ae3d8888ed32da2vboxsync HRESULT hr2 = MsiSetPropertyW(hModule, L"REBOOT", L"Force");
950867fcd91ff725bbcc44623ae3d8888ed32da2vboxsync logStringW(hModule, L"UpdateHostOnlyInterfaces: Failed to set REBOOT property, error = 0x%x", hr2);
950867fcd91ff725bbcc44623ae3d8888ed32da2vboxsync logStringW(hModule, L"UpdateHostOnlyInterfaces: VBoxNetCfgWinUpdateHostOnlyNetworkInterface failed, hr = 0x%x", hr);
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"UpdateHostOnlyInterfaces: NetAdpDir property value is empty");
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync logStringW(hModule, L"UpdateHostOnlyInterfaces: Failed to get NetAdpDir property, error = 0x%x", uErr);
c42011aa94dc0c1fdd2acefda7a48c5c8cd23d10vboxsync /* Restore original setup mode. */
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync#endif /* VBOX_WITH_NETFLT */
46c75ae905ff2f34982b5b2b9aafdf3b32644eb0vboxsync /* Never fail the install even if we did not succeed. */
d97357e2036109245c83ba553d0290212e28ea40vboxsync bool bIsTapDevice = false;
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync L"SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}",
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync return false;
fba7ec2ca5a120ca53275eebdfa69425ce0e9829vboxsync lStatus = RegEnumKeyExW(hNetcard, i, wszEnumName, &dwLen, NULL, NULL, NULL, NULL);
fba7ec2ca5a120ca53275eebdfa69425ce0e9829vboxsync lStatus = RegOpenKeyExW(hNetcard, wszEnumName, 0, KEY_READ, &hNetCardGUID);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync lStatus = RegQueryValueExW(hNetCardGUID, L"NetCfgInstanceId", NULL, &dwKeyType, (LPBYTE)wszNetCfgInstanceId, &dwLen);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync lStatus = RegQueryValueExW(hNetCardGUID, L"ProductName", NULL, &dwKeyType, (LPBYTE)wszNetProductName, &dwLen);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync lStatus = RegQueryValueExW(hNetCardGUID, L"ProviderName", NULL, &dwKeyType, (LPBYTE)wszNetProviderName, &dwLen);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync && !wcscmp(wszNetProductName, L"VirtualBox TAP Adapter")
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync && ( (!wcscmp(wszNetProviderName, L"innotek GmbH")) /* Legacy stuff. */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync || (!wcscmp(wszNetProviderName, L"Sun Microsystems, Inc.")) /* Legacy stuff. */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync || (!wcscmp(wszNetProviderName, MY_WTEXT(VBOX_VENDOR))) /* Reflects current vendor string. */
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync } else do {} while (0)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsyncint removeNetworkInterface(MSIHANDLE hModule, const WCHAR *pwszGUID)
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* We have to find the device instance ID through a registry search */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync do /* break-loop */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s",
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync LONG lStatus = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszRegLocation, 0, KEY_READ, &hkeyNetwork);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync SetErrBreak((L"VBox HostInterfaces: Host interface network was not found in registry (%s)! [1]", wszRegLocation));
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync lStatus = RegOpenKeyExW(hkeyNetwork, L"Connection", 0, KEY_READ, &hkeyConnection);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync SetErrBreak((L"VBox HostInterfaces: Host interface network was not found in registry (%s)! [2]", wszRegLocation));
d97357e2036109245c83ba553d0290212e28ea40vboxsync lStatus = RegQueryValueExW(hkeyConnection, L"PnPInstanceID", NULL,
d97357e2036109245c83ba553d0290212e28ea40vboxsync if ((lStatus != ERROR_SUCCESS) || (dwKeyType != REG_SZ))
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync SetErrBreak((L"VBox HostInterfaces: Host interface network was not found in registry (%s)! [3]", wszRegLocation));
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync * Now we are going to enumerate all network devices and
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync * wait until we encounter the right device instance ID
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* initialize the structure size */
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* copy the net class GUID */
d97357e2036109245c83ba553d0290212e28ea40vboxsync memcpy(&netGuid, &GUID_DEVCLASS_NET, sizeof (GUID_DEVCLASS_NET));
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* return a device info set contains all installed devices of the Net class */
d97357e2036109245c83ba553d0290212e28ea40vboxsync hDeviceInfo = SetupDiGetClassDevs(&netGuid, NULL, NULL, DIGCF_PRESENT);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"VBox HostInterfaces: SetupDiGetClassDevs failed (0x%08X)!", GetLastError());
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync SetErrBreak(L"VBox HostInterfaces: Uninstallation failed!");
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* enumerate the driver info list */
d97357e2036109245c83ba553d0290212e28ea40vboxsync fResult = SetupDiEnumDeviceInfo(hDeviceInfo, index, &DeviceInfoData);
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* try to get the hardware ID registry property */
d97357e2036109245c83ba553d0290212e28ea40vboxsync fResult = SetupDiGetDeviceRegistryProperty(hDeviceInfo,
d97357e2036109245c83ba553d0290212e28ea40vboxsync fResult = SetupDiGetDeviceRegistryProperty(hDeviceInfo,
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* something is wrong. This shouldn't have worked with a NULL buffer */
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync t && *t && t < &pwszDeviceHwid[size / sizeof(WCHAR)];
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* get the device instance ID */
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* compare to what we determined before */
d97357e2036109245c83ba553d0290212e28ea40vboxsync fResult = SetupDiSetSelectedDevice(hDeviceInfo, &DeviceInfoData);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"VBox HostInterfaces: SetupDiSetSelectedDevice failed (0x%08X)!", GetLastError());
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync SetErrBreak(L"VBox HostInterfaces: Uninstallation failed!");
d97357e2036109245c83ba553d0290212e28ea40vboxsync fResult = SetupDiCallClassInstaller(DIF_REMOVE, hDeviceInfo, &DeviceInfoData);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"VBox HostInterfaces: SetupDiCallClassInstaller (DIF_REMOVE) failed (0x%08X)!", GetLastError());
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync SetErrBreak(L"VBox HostInterfaces: Uninstallation failed!");
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync SetErrBreak(L"VBox HostInterfaces: Host interface network device not found!");
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync /* clean up the device info set */
d97357e2036109245c83ba553d0290212e28ea40vboxsyncUINT __stdcall UninstallTAPInstances(MSIHANDLE hModule)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync static const WCHAR *s_wszNetworkKey = L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}";
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync LONG lStatus = RegOpenKeyExW(HKEY_LOCAL_MACHINE, s_wszNetworkKey, 0, KEY_READ, &hCtrlNet);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"VBox HostInterfaces: Enumerating interfaces ...");
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync for (int i = 0; ; ++i)
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync lStatus = RegEnumKeyExW(hCtrlNet, i, wszNetworkGUID, &dwLen, NULL, NULL, NULL, NULL);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"VBox HostInterfaces: No interfaces found.");
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"VBox HostInterfaces: Enumeration failed: %ld", lStatus);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"VBox HostInterfaces: Removing interface \"%s\" ...", wszNetworkGUID);
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync logStringW(hModule, L"VBox HostInterfaces: Removing interfaces done.");