VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxNetFlt/win/NetAdpInstall.cpp@ 22472

Last change on this file since 22472 was 22472, checked in by vboxsync, 15 years ago

netadp/win: install from specified inf (first step to pure non-DIFX install)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/* $Id: NetAdpInstall.cpp 22472 2009-08-26 14:19:20Z vboxsync $ */
2/** @file
3 * NetAdpInstall - VBoxNetAdp installer command line tool
4 */
5
6/*
7 * Copyright (C) 2009 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#include <vbox/WinNetConfig.h>
23#include <stdio.h>
24
25#define VBOX_NETADP_INF L".\\VBoxNetAdp.inf"
26
27static VOID winNetCfgLogger (LPCWSTR szString)
28{
29 wprintf(L"%s", szString);
30}
31
32static int InstallNetAdp()
33{
34 int r = 1;
35 VBoxNetCfgWinSetLogging(winNetCfgLogger);
36
37 HRESULT hr = CoInitialize(NULL);
38 if(hr == S_OK)
39 {
40#ifndef DEBUG_misha
41 printf("not implemented yet, please use device manager for Host-Only net interface installation.. sorry :( \n");
42#else
43 /* this installs the Net Adp from the pre-installed driver package,
44 * it does NOT install the new driver package, so the installation might use old drivers
45 * or fail in case no NetAdp package is currently installed
46 * the code is here for debugging NetAdp installation only */
47 GUID guid;
48 BSTR name, errMsg;
49 printf("adding host-only interface..\n");
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)
55 {
56 hr = VBoxNetCfgWinCreateHostOnlyNetworkInterface (MpInf, true, &guid, &name, &errMsg);
57 if(hr == S_OK)
58 {
59 ULONG ip, mask;
60 hr = VBoxNetCfgWinGenHostOnlyNetworkNetworkIp(&ip, &mask);
61 if(hr == S_OK)
62 {
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);
79 }
80 }
81 else
82 {
83 printf("VBoxNetCfgWinCreateHostOnlyNetworkInterface failed: hr = 0x%x\n", hr);
84 }
85 }
86 else
87 {
88 printf("GetFullPathNameW failed: winEr = %d\n", WinEr);
89 }
90#endif
91
92 CoUninitialize();
93 }
94 else
95 {
96 wprintf(L"Error initializing COM (0x%x)\n", hr);
97 }
98
99 VBoxNetCfgWinSetLogging(NULL);
100
101 return r;
102}
103
104int __cdecl main(int argc, char **argv)
105{
106 return InstallNetAdp();
107}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette