Changeset 22472 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt
- Timestamp:
- Aug 26, 2009 2:19:20 PM (15 years ago)
- Location:
- trunk/src/VBox/HostDrivers/VBoxNetFlt/win
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/NetAdpInstall.cpp
r21343 r22472 23 23 #include <stdio.h> 24 24 25 #define VBOX_NETADP_INF L".\\VBoxNetAdp.inf" 26 25 27 static VOID winNetCfgLogger (LPCWSTR szString) 26 28 { … … 30 32 static int InstallNetAdp() 31 33 { 32 int r = 0;34 int r = 1; 33 35 VBoxNetCfgWinSetLogging(winNetCfgLogger); 34 36 … … 46 48 BSTR name, errMsg; 47 49 printf("adding host-only interface..\n"); 48 hr = VBoxNetCfgWinCreateHostOnlyNetworkInterface (&guid, &name, &errMsg); 49 if(hr == S_OK) 50 DWORD WinEr; 51 WCHAR MpInf[MAX_PATH]; 52 GetFullPathNameW(VBOX_NETADP_INF, sizeof(MpInf)/sizeof(MpInf[0]), MpInf, NULL); 53 WinEr = GetLastError(); 54 if(WinEr == ERROR_SUCCESS) 50 55 { 51 ULONG ip, mask; 52 hr = VBoxNetCfgWinGenHostOnlyNetworkNetworkIp(&ip, &mask); 56 hr = VBoxNetCfgWinCreateHostOnlyNetworkInterface (MpInf, true, &guid, &name, &errMsg); 53 57 if(hr == S_OK) 54 58 { 55 /* ip returned by VBoxNetCfgWinGenHostOnlyNetworkNetworkIp is a network ip, 56 * i.e. 192.168.xxx.0, assign 192.168.xxx.1 for the hostonly adapter */ 57 ip = ip | (1 << 24); 58 hr = VBoxNetCfgWinEnableStaticIpConfig(&guid, ip, mask); 59 if(hr != S_OK) 59 ULONG ip, mask; 60 hr = VBoxNetCfgWinGenHostOnlyNetworkNetworkIp(&ip, &mask); 61 if(hr == S_OK) 60 62 { 61 printf("VBoxNetCfgWinEnableStaticIpConfig failed: hr = 0x%x\n", hr); 63 /* ip returned by VBoxNetCfgWinGenHostOnlyNetworkNetworkIp is a network ip, 64 * i.e. 192.168.xxx.0, assign 192.168.xxx.1 for the hostonly adapter */ 65 ip = ip | (1 << 24); 66 hr = VBoxNetCfgWinEnableStaticIpConfig(&guid, ip, mask); 67 if(hr != S_OK) 68 { 69 printf("VBoxNetCfgWinEnableStaticIpConfig failed: hr = 0x%x\n", hr); 70 } 71 else 72 { 73 r = 0; 74 } 75 } 76 else 77 { 78 printf("VBoxNetCfgWinGenHostOnlyNetworkNetworkIp failed: hr = 0x%x\n", hr); 62 79 } 63 80 } 64 81 else 65 82 { 66 printf("VBoxNetCfgWin GenHostOnlyNetworkNetworkIpfailed: hr = 0x%x\n", hr);83 printf("VBoxNetCfgWinCreateHostOnlyNetworkInterface failed: hr = 0x%x\n", hr); 67 84 } 68 85 } 69 86 else 70 87 { 71 printf(" VBoxNetCfgWinCreateHostOnlyNetworkInterface failed: hr = 0x%x\n", hr);88 printf("GetFullPathNameW failed: winEr = %d\n", WinEr); 72 89 } 73 90 #endif 74 75 r = 1;76 91 77 92 CoUninitialize(); … … 80 95 { 81 96 wprintf(L"Error initializing COM (0x%x)\n", hr); 82 r = 1;83 97 } 84 98 -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/WinNetConfig.cpp
r21343 r22472 2192 2192 } 2193 2193 2194 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinCreateHostOnlyNetworkInterface (GUID *pGuid, BSTR *lppszName, BSTR *pErrMsg) 2194 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinCreateHostOnlyNetworkInterface (LPCWSTR pInfPath, bool bIsInfPathFile, /* <- input params */ 2195 GUID *pGuid, BSTR *lppszName, BSTR *pErrMsg) /* <- output params */ 2195 2196 { 2196 2197 HRESULT hrc = S_OK; … … 2257 2258 SetErrBreak ((L"SetupDiSetSelectedDevice failed (0x%08X)", 2258 2259 GetLastError())); 2260 2261 if(pInfPath) 2262 { 2263 /* get the device install parameters and disable filecopy */ 2264 DeviceInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS); 2265 ok = SetupDiGetDeviceInstallParams (hDeviceInfo, &DeviceInfoData, 2266 &DeviceInstallParams); 2267 if (ok) 2268 { 2269 memset(DeviceInstallParams.DriverPath, 0, sizeof(DeviceInstallParams.DriverPath)); 2270 int pathLenght = wcslen(pInfPath) + 1/* null terminator */; 2271 if(pathLenght < sizeof(DeviceInstallParams.DriverPath)/sizeof(DeviceInstallParams.DriverPath[0])) 2272 { 2273 memcpy(DeviceInstallParams.DriverPath, pInfPath, pathLenght*sizeof(DeviceInstallParams.DriverPath[0])); 2274 2275 if(bIsInfPathFile) 2276 { 2277 DeviceInstallParams.Flags |= DI_ENUMSINGLEINF; 2278 } 2279 2280 ok = SetupDiSetDeviceInstallParams (hDeviceInfo, &DeviceInfoData, 2281 &DeviceInstallParams); 2282 if(!ok) 2283 { 2284 DWORD winEr = GetLastError(); 2285 Log(L"SetupDiSetDeviceInstallParams: SetupDiSetDeviceInstallParams failed, winEr (%d)\n", winEr); 2286 Assert(0); 2287 break; 2288 } 2289 } 2290 else 2291 { 2292 Log(L"SetupDiSetDeviceInstallParams: inf path is too long\n"); 2293 Assert(0); 2294 break; 2295 } 2296 } 2297 else 2298 { 2299 DWORD winEr = GetLastError(); 2300 Assert(0); 2301 Log(L"VBoxNetCfgWinCreateHostOnlyNetworkInterface: SetupDiGetDeviceInstallParams failed, winEr (%d)\n", winEr); 2302 } 2303 2304 } 2259 2305 2260 2306 /* build a list of class drivers */
Note:
See TracChangeset
for help on using the changeset viewer.