Changeset 96572 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools
- Timestamp:
- Sep 1, 2022 8:36:22 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 153448
- Location:
- trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetAdpInstall.cpp
r96407 r96572 41 41 #include <VBox/VBoxNetCfg-win.h> 42 42 #include <VBox/VBoxDrvCfg-win.h> 43 #include <stdio.h>44 43 #include <devguid.h> 44 45 #include <iprt/initterm.h> 46 #include <iprt/message.h> 47 #include <iprt/process.h> 48 #include <iprt/stream.h> 45 49 46 50 … … 60 64 static DECLCALLBACK(void) winNetCfgLogger(const char *pszString) 61 65 { 62 printf("%s\n", pszString);66 RTMsgInfo("%s", pszString); 63 67 } 64 68 … … 109 113 static int VBoxNetAdpInstall(void) 110 114 { 111 VBoxNetCfgWinSetLogging(winNetCfgLogger); 112 113 HRESULT hr = CoInitialize(NULL); 114 if (SUCCEEDED(hr)) 115 { 116 wprintf(L"adding host-only interface..\n"); 117 115 RTMsgInfo("Adding host-only interface..."); 116 VBoxNetCfgWinSetLogging(winNetCfgLogger); 117 118 HRESULT hr = CoInitialize(NULL); 119 if (SUCCEEDED(hr)) 120 { 118 121 WCHAR wszInfFile[MAX_PATH]; 119 122 DWORD cwcInfFile = MyGetfullPathNameW(VBOX_NETADP_INF, RT_ELEMENTS(wszInfFile), wszInfFile); … … 129 132 130 133 if (hr == S_OK) 131 wprintf(L"installed successfully\n");134 RTMsgInfo("Installed successfully!"); 132 135 else 133 wprintf(L"error installing VBoxNetAdp (%#lx)\n", hr);136 RTMsgError("failed to install VBoxNetAdp: %Rhrc", hr); 134 137 135 138 VBoxNetCfgWinReleaseINetCfg(pnc, TRUE); 136 139 } 137 140 else 138 wprintf(L"VBoxNetCfgWinQueryINetCfg failed: hr=%#lx\n", hr);141 RTMsgError("VBoxNetCfgWinQueryINetCfg failed: %Rhrc", hr); 139 142 /* 140 143 hr = VBoxDrvCfgInfInstall(MpInf); … … 171 174 { 172 175 DWORD dwErr = GetLastError(); 173 wprintf(L"GetFullPathNameW failed: winEr = %lu\n", dwErr);176 RTMsgError("MyGetfullPathNameW failed: %Rwc", dwErr); 174 177 hr = HRESULT_FROM_WIN32(dwErr); 175 178 } … … 177 180 } 178 181 else 179 wprintf(L"Error initializing COM (%#lx)\n", hr);182 RTMsgError("Failed initializing COM: %Rhrc", hr); 180 183 181 184 VBoxNetCfgWinSetLogging(NULL); … … 186 189 static int VBoxNetAdpUninstall(void) 187 190 { 188 VBoxNetCfgWinSetLogging(winNetCfgLogger); 189 190 printf("uninstalling all host-only interfaces..\n"); 191 RTMsgInfo("Uninstalling all host-only interfaces..."); 192 VBoxNetCfgWinSetLogging(winNetCfgLogger); 191 193 192 194 HRESULT hr = CoInitialize(NULL); … … 198 200 hr = VBoxDrvCfgInfUninstallAllSetupDi(&GUID_DEVCLASS_NET, L"Net", VBOX_NETADP_HWID, 0/* could be SUOI_FORCEDELETE */); 199 201 if (SUCCEEDED(hr)) 200 printf("uninstallation successful\n");202 RTMsgInfo("Uninstallation successful!"); 201 203 else 202 printf("uninstalled successfully, but failed to remove infs\n");203 } 204 else 205 printf("uninstall failed, hr=%#lx\n", hr);206 CoUninitialize(); 207 } 208 else 209 printf("Error initializing COM (%#lx)\n", hr);204 RTMsgWarning("uninstalled successfully, but failed to remove infs (%Rhrc)\n", hr); 205 } 206 else 207 RTMsgError("uninstall failed: %Rhrc", hr); 208 CoUninitialize(); 209 } 210 else 211 RTMsgError("Failed initializing COM: %Rhrc", hr); 210 212 211 213 VBoxNetCfgWinSetLogging(NULL); … … 216 218 static int VBoxNetAdpUpdate(void) 217 219 { 218 VBoxNetCfgWinSetLogging(winNetCfgLogger); 219 220 printf("uninstalling all host-only interfaces..\n"); 220 RTMsgInfo("Uninstalling all host-only interfaces..."); 221 VBoxNetCfgWinSetLogging(winNetCfgLogger); 221 222 222 223 HRESULT hr = CoInitialize(NULL); … … 235 236 { 236 237 if (fRebootRequired) 237 printf("!!REBOOT REQUIRED!!\n");238 printf("updated successfully\n");239 } 240 else 241 printf("update failed, hr=%#lx\n", hr);242 243 CoUninitialize(); 244 } 245 else 246 printf("Error initializing COM (%#lx)\n", hr);238 RTMsgWarning("!!REBOOT REQUIRED!!"); 239 RTMsgInfo("Updated successfully!"); 240 } 241 else 242 RTMsgError("update failed: %Rhrc", hr); 243 244 CoUninitialize(); 245 } 246 else 247 RTMsgError("Failed initializing COM: %Rhrc", hr); 247 248 248 249 VBoxNetCfgWinSetLogging(NULL); … … 253 254 static int VBoxNetAdpDisable(void) 254 255 { 255 VBoxNetCfgWinSetLogging(winNetCfgLogger); 256 257 printf("disabling all host-only interfaces..\n"); 256 RTMsgInfo("Disabling all host-only interfaces..."); 257 VBoxNetCfgWinSetLogging(winNetCfgLogger); 258 258 259 259 HRESULT hr = CoInitialize(NULL); … … 262 262 hr = VBoxNetCfgWinPropChangeAllNetDevicesOfId(VBOX_NETADP_HWID, VBOXNECTFGWINPROPCHANGE_TYPE_DISABLE); 263 263 if (SUCCEEDED(hr)) 264 printf("disabling successful\n");265 else 266 printf("disable failed, hr=%#lx\n", hr);267 268 CoUninitialize(); 269 } 270 else 271 printf("Error initializing COM (%#lx)\n", hr);264 RTMsgInfo("Disabling successful"); 265 else 266 RTMsgError("disable failed: %Rhrc", hr); 267 268 CoUninitialize(); 269 } 270 else 271 RTMsgError("Failed initializing COM: %Rhrc", hr); 272 272 273 273 VBoxNetCfgWinSetLogging(NULL); … … 278 278 static int VBoxNetAdpEnable(void) 279 279 { 280 VBoxNetCfgWinSetLogging(winNetCfgLogger); 281 282 printf("enabling all host-only interfaces..\n"); 280 RTMsgInfo("Enabling all host-only interfaces..."); 281 VBoxNetCfgWinSetLogging(winNetCfgLogger); 283 282 284 283 HRESULT hr = CoInitialize(NULL); … … 287 286 hr = VBoxNetCfgWinPropChangeAllNetDevicesOfId(VBOX_NETADP_HWID, VBOXNECTFGWINPROPCHANGE_TYPE_ENABLE); 288 287 if (SUCCEEDED(hr)) 289 printf("enabling successful\n");290 else 291 printf("enabling failed, hr=%#lx\n", hr);292 293 CoUninitialize(); 294 } 295 else 296 printf("Error initializing COM (%#lx)\n", hr);288 RTMsgInfo("Enabling successful!"); 289 else 290 RTMsgError("enabling failed: %hrc", hr); 291 292 CoUninitialize(); 293 } 294 else 295 RTMsgError("Failed initializing COM: %Rhrc", hr); 297 296 298 297 VBoxNetCfgWinSetLogging(NULL); … … 303 302 static void printUsage(void) 304 303 { 305 printf("host-only network adapter configuration tool\n" 306 " Usage: VBoxNetAdpInstall [cmd]\n" 307 " cmd can be one of the following values:\n" 308 " i - install a new host-only interface (default command)\n" 309 " u - uninstall all host-only interfaces\n" 310 " a - update the host-only driver\n" 311 " d - disable all host-only interfaces\n" 312 " e - enable all host-only interfaces\n" 313 " h - print this message\n"); 304 RTPrintf("host-only network adapter configuration tool\n" 305 " Usage: %s [cmd]\n" 306 " cmd can be one of the following values:\n" 307 " i - install a new host-only interface (default command)\n" 308 " u - uninstall all host-only interfaces\n" 309 " a - update the host-only driver\n" 310 " d - disable all host-only interfaces\n" 311 " e - enable all host-only interfaces\n" 312 " h - print this message\n", 313 RTProcShortName()); 314 314 } 315 315 316 316 int __cdecl main(int argc, char **argv) 317 317 { 318 RTR3InitExe(argc, &argv, 0); 319 318 320 if (argc < 2) 319 321 return VBoxNetAdpInstall(); -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetAdpUninstall.cpp
r96407 r96572 35 35 */ 36 36 37 38 /********************************************************************************************************************************* 39 * Header Files * 40 *********************************************************************************************************************************/ 37 41 #include <VBox/VBoxNetCfg-win.h> 38 42 #include <VBox/VBoxDrvCfg-win.h> 39 #include <stdio.h>40 43 41 44 #include <devguid.h> 42 45 46 #include <iprt/initterm.h> 47 #include <iprt/message.h> 48 49 50 /********************************************************************************************************************************* 51 * Defined Constants And Macros * 52 *********************************************************************************************************************************/ 43 53 #ifdef NDIS60 44 54 # define VBOX_NETADP_HWID L"sun_VBoxNetAdp6" … … 47 57 #endif 48 58 59 49 60 static DECLCALLBACK(void) winNetCfgLogger(const char *pszString) 50 61 { 51 printf("%s", pszString);62 RTMsgInfo("%s", pszString); 52 63 } 53 64 54 65 static int VBoxNetAdpUninstall(void) 55 66 { 67 RTMsgInfo("Uninstalling all Host-Only interfaces ..."); 68 56 69 int rcExit = RTEXITCODE_FAILURE; 57 70 VBoxNetCfgWinSetLogging(winNetCfgLogger); 58 59 printf("uninstalling all Host-Only interfaces..\n");60 71 61 72 HRESULT hr = CoInitialize(NULL); … … 67 78 hr = VBoxDrvCfgInfUninstallAllSetupDi(&GUID_DEVCLASS_NET, L"Net", VBOX_NETADP_HWID, 0/* could be SUOI_FORCEDELETE */); 68 79 if (hr == S_OK) 69 printf("uninstalled successfully\n");80 RTMsgInfo("Uninstalled successfully!"); 70 81 else 71 printf("uninstalled successfully, but failed to remove infs\n");82 RTMsgError("uninstalled successfully, but failed to remove infs (%Rhrc)\n", hr); 72 83 rcExit = RTEXITCODE_SUCCESS; 73 84 } 74 85 else 75 printf("uninstall failed, hr=%#lx\n", hr);86 RTMsgError("uninstall failed: %Rhrc", hr); 76 87 77 88 CoUninitialize(); 78 89 } 79 90 else 80 wprintf(L"Error initializing COM (%#lx)\n", hr);91 RTMsgError("Failed initializing COM: %Rhrc", hr); 81 92 82 93 VBoxNetCfgWinSetLogging(NULL); … … 87 98 int __cdecl main(int argc, char **argv) 88 99 { 89 RT_NOREF2(argc, argv); 100 RTR3InitExeNoArguments(0); 101 if (argc != 1) 102 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "This utility takes no arguments\n"); 103 NOREF(argv); 104 90 105 return VBoxNetAdpUninstall(); 91 106 } 107 -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetFltInstall.cpp
r96407 r96572 35 35 */ 36 36 37 38 /********************************************************************************************************************************* 39 * Header Files * 40 *********************************************************************************************************************************/ 37 41 #include <VBox/VBoxNetCfg-win.h> 38 42 #include <devguid.h> 39 43 #include <stdio.h> 40 44 45 #include <iprt/initterm.h> 46 #include <iprt/message.h> 47 48 49 /********************************************************************************************************************************* 50 * Header Files * 51 *********************************************************************************************************************************/ 41 52 #define NETFLT_ID L"sun_VBoxNetFlt" 42 53 #define VBOX_NETCFG_APP_NAME L"NetFltInstall" … … 181 192 int __cdecl main(int argc, char **argv) 182 193 { 183 RT_NOREF2(argc, argv); 194 RTR3InitExeNoArguments(0); 195 if (argc != 1) 196 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "This utility takes no arguments\n"); 197 NOREF(argv); 198 184 199 return VBoxNetFltInstall(); 185 200 } 201 -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetFltUninstall.cpp
r96407 r96572 35 35 */ 36 36 37 38 /********************************************************************************************************************************* 39 * Header Files * 40 *********************************************************************************************************************************/ 37 41 #include <VBox/VBoxNetCfg-win.h> 38 42 #include <stdio.h> 39 43 44 #include <iprt/initterm.h> 45 #include <iprt/message.h> 46 47 48 /********************************************************************************************************************************* 49 * Defined Constants And Macros * 50 *********************************************************************************************************************************/ 40 51 #define NETFLT_ID L"sun_VBoxNetFlt" 41 52 #define VBOX_NETCFG_APP_NAME L"NetFltUninstall" … … 43 54 #define VBOX_NETFLT_MP_INF L".\\VBoxNetFltM.inf" 44 55 #define VBOX_NETFLT_RETRIES 10 56 45 57 46 58 static DECLCALLBACK(void) winNetCfgLogger(const char *pszString) … … 112 124 int __cdecl main(int argc, char **argv) 113 125 { 114 RT_NOREF2(argc, argv); 126 RTR3InitExeNoArguments(0); 127 if (argc != 1) 128 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "This utility takes no arguments\n"); 129 NOREF(argv); 130 115 131 return VBoxNetFltUninstall(); 116 132 } 133 -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetLwfInstall.cpp
r96407 r96572 35 35 */ 36 36 37 38 /********************************************************************************************************************************* 39 * Header Files * 40 *********************************************************************************************************************************/ 37 41 #include <VBox/VBoxNetCfg-win.h> 38 42 #include <devguid.h> 39 #include <stdio.h>40 43 44 #include <iprt/initterm.h> 45 #include <iprt/message.h> 46 #include <iprt/utf16.h> 47 48 49 /********************************************************************************************************************************* 50 * Defined Constants And Macros * 51 *********************************************************************************************************************************/ 41 52 #define VBOX_NETCFG_APP_NAME L"NetLwfInstall" 42 53 #define VBOX_NETLWF_INF L".\\VBoxNetLwf.inf" … … 46 57 static DECLCALLBACK(void) winNetCfgLogger(const char *pszString) 47 58 { 48 printf("%s", pszString);59 RTMsgInfo("%s", pszString); 49 60 } 50 61 … … 116 127 if (hr == S_OK) 117 128 { 118 wprintf(L"installed successfully\n");129 RTMsgInfo("Installed successfully!"); 119 130 rcExit = RTEXITCODE_SUCCESS; 120 131 } 121 132 else 122 wprintf(L"error installing VBoxNetLwf (%#lx)\n", hr);133 RTMsgError("Failed installing VBoxNetLwf: %Rhrc", hr); 123 134 } 124 135 else 125 136 { 126 137 hr = HRESULT_FROM_WIN32(GetLastError()); 127 wprintf(L"error getting full inf path for VBoxNetLwf.inf (%#lx)\n", hr);138 RTMsgError("Failed getting full inf path for VBoxNetLwf.inf: %Rhrc", hr); 128 139 } 129 140 … … 134 145 if (hr == NETCFG_E_NO_WRITE_LOCK && pwszLockedBy) 135 146 { 136 if (i < VBOX_NETLWF_RETRIES && !wcscmp(pwszLockedBy, L"6to4svc.dll"))147 if (i < VBOX_NETLWF_RETRIES && RTUtf16ICmpAscii(pwszLockedBy, "6to4svc.dll") == 0) 137 148 { 138 wprintf(L"6to4svc.dll is holding the lock,retrying %d out of %d\n", i + 1, VBOX_NETLWF_RETRIES);149 RTMsgInfo("6to4svc.dll is holding the lock - retrying %d out of %d\n", i + 1, VBOX_NETLWF_RETRIES); 139 150 CoTaskMemFree(pwszLockedBy); 140 151 } 141 152 else 142 153 { 143 wprintf(L"Error: write lock is owned by another application (%s), close the application and retry installing\n",144 pwszLockedBy);154 RTMsgError("write lock is owned by another application (%ls), close the application and retry installing", 155 pwszLockedBy); 145 156 CoTaskMemFree(pwszLockedBy); 146 157 break; … … 149 160 else 150 161 { 151 wprintf(L"Error getting the INetCfg interface (%#lx)\n", hr);162 RTMsgError("Failed getting the INetCfg interface: %Rhrc", hr); 152 163 break; 153 164 } … … 157 168 } 158 169 else 159 wprintf(L"Error initializing COM (%#lx)\n", hr);170 RTMsgError("Failed initializing COM: %Rhrc", hr); 160 171 161 172 VBoxNetCfgWinSetLogging(NULL); … … 166 177 int __cdecl main(int argc, char **argv) 167 178 { 168 RT_NOREF2(argc, argv); 179 RTR3InitExeNoArguments(0); 180 if (argc != 1) 181 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "This utility takes no arguments\n"); 182 NOREF(argv); 183 169 184 return VBoxNetLwfInstall(); 170 185 } 186 -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetLwfUninstall.cpp
r96407 r96572 35 35 */ 36 36 37 38 /********************************************************************************************************************************* 39 * Header Files * 40 *********************************************************************************************************************************/ 37 41 #include <VBox/VBoxNetCfg-win.h> 38 #include <stdio.h>39 42 43 #include <iprt/initterm.h> 44 #include <iprt/message.h> 45 #include <iprt/utf16.h> 46 47 48 /********************************************************************************************************************************* 49 * Defined Constants And Macros * 50 *********************************************************************************************************************************/ 40 51 #define VBOX_NETCFG_APP_NAME L"NetLwfUninstall" 41 52 #define VBOX_NETLWF_RETRIES 10 42 53 54 43 55 static DECLCALLBACK(void) winNetCfgLogger(const char *pszString) 44 56 { 45 printf("%s", pszString);57 RTMsgInfo("%s", pszString); 46 58 } 47 59 48 60 static int VBoxNetLwfUninstall() 49 61 { 50 INetCfg *pnc;51 62 int rcExit = RTEXITCODE_FAILURE; 52 63 … … 59 70 { 60 71 LPWSTR pwszLockedBy = NULL; 72 INetCfg *pnc = NULL; 61 73 hr = VBoxNetCfgWinQueryINetCfg(&pnc, TRUE, VBOX_NETCFG_APP_NAME, 10000, &pwszLockedBy); 62 74 if (hr == S_OK) … … 65 77 if (hr == S_OK) 66 78 { 67 wprintf(L"uninstalled successfully\n");79 RTMsgInfo("uninstalled successfully!"); 68 80 rcExit = RTEXITCODE_SUCCESS; 69 81 } 70 82 else 71 wprintf(L"error uninstalling VBoxNetLwf (%#lx)\n", hr);83 RTMsgError("error uninstalling VBoxNetLwf: %Rhrc"); 72 84 73 85 VBoxNetCfgWinReleaseINetCfg(pnc, TRUE); … … 77 89 if (hr == NETCFG_E_NO_WRITE_LOCK && pwszLockedBy) 78 90 { 79 if (i < VBOX_NETLWF_RETRIES && !wcscmp(pwszLockedBy, L"6to4svc.dll"))91 if (i < VBOX_NETLWF_RETRIES && RTUtf16ICmpAscii(pwszLockedBy, "6to4svc.dll") == 0) 80 92 { 81 wprintf(L"6to4svc.dll is holding the lock, retrying %d out of %d\n", i + 1, VBOX_NETLWF_RETRIES);93 RTMsgInfo("6to4svc.dll is holding the lock - retry %d out of %d ...", i + 1, VBOX_NETLWF_RETRIES); 82 94 CoTaskMemFree(pwszLockedBy); 83 95 } 84 96 else 85 97 { 86 wprintf(L"Error: write lock is owned by another application (%s), close the application and retry uninstalling\n",87 pwszLockedBy);98 RTMsgError("Write lock is owned by another application (%ls), close the application and retry uninstalling", 99 pwszLockedBy); 88 100 CoTaskMemFree(pwszLockedBy); 89 101 break; … … 92 104 else 93 105 { 94 wprintf(L"Error getting the INetCfg interface (%#lx)\n", hr);106 RTMsgError("Failed getting the INetCfg interface: %Rhrc", hr); 95 107 break; 96 108 } … … 100 112 } 101 113 else 102 wprintf(L"Error initializing COM (%#lx)\n", hr);114 RTMsgError("Failed initializing COM: %Rhrc", hr); 103 115 104 116 VBoxNetCfgWinSetLogging(NULL); … … 109 121 int __cdecl main(int argc, char **argv) 110 122 { 111 RT_NOREF2(argc, argv); 123 RTR3InitExeNoArguments(0); 124 if (argc != 1) 125 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "This utility takes no arguments\n"); 126 NOREF(argv); 127 112 128 return VBoxNetLwfUninstall(); 113 129 } 130
Note:
See TracChangeset
for help on using the changeset viewer.