VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetLwfUninstall.cpp@ 79409

Last change on this file since 79409 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/* $Id: VBoxNetLwfUninstall.cpp 76553 2019-01-01 01:45:53Z vboxsync $ */
2/** @file
3 * NetLwfUninstall - VBoxNetLwf uninstaller command line tool
4 */
5
6/*
7 * Copyright (C) 2014-2019 Oracle Corporation
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 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#include <VBox/VBoxNetCfg-win.h>
28#include <stdio.h>
29
30#define VBOX_NETCFG_APP_NAME L"NetLwfUninstall"
31#define VBOX_NETLWF_RETRIES 10
32
33static VOID winNetCfgLogger (LPCSTR szString)
34{
35 printf("%s", szString);
36}
37
38static int VBoxNetLwfUninstall()
39{
40 INetCfg *pnc;
41 LPWSTR lpszLockedBy = NULL;
42 int r;
43
44 VBoxNetCfgWinSetLogging(winNetCfgLogger);
45
46 HRESULT hr = CoInitialize(NULL);
47 if (hr == S_OK)
48 {
49 int i = 0;
50 do
51 {
52 hr = VBoxNetCfgWinQueryINetCfg(&pnc, TRUE, VBOX_NETCFG_APP_NAME, 10000, &lpszLockedBy);
53 if (hr == S_OK)
54 {
55 hr = VBoxNetCfgWinNetLwfUninstall(pnc);
56 if (hr != S_OK)
57 {
58 wprintf(L"error uninstalling VBoxNetLwf (0x%x)\n", hr);
59 r = 1;
60 }
61 else
62 {
63 wprintf(L"uninstalled successfully\n");
64 r = 0;
65 }
66
67 VBoxNetCfgWinReleaseINetCfg(pnc, TRUE);
68 break;
69 }
70 else if (hr == NETCFG_E_NO_WRITE_LOCK && lpszLockedBy)
71 {
72 if (i < VBOX_NETLWF_RETRIES && !wcscmp(lpszLockedBy, L"6to4svc.dll"))
73 {
74 wprintf(L"6to4svc.dll is holding the lock, retrying %d out of %d\n", ++i, VBOX_NETLWF_RETRIES);
75 CoTaskMemFree(lpszLockedBy);
76 }
77 else
78 {
79 wprintf(L"Error: write lock is owned by another application (%s), close the application and retry uninstalling\n", lpszLockedBy);
80 r = 1;
81 CoTaskMemFree(lpszLockedBy);
82 break;
83 }
84 }
85 else
86 {
87 wprintf(L"Error getting the INetCfg interface (0x%x)\n", hr);
88 r = 1;
89 break;
90 }
91 } while (true);
92
93 CoUninitialize();
94 }
95 else
96 {
97 wprintf(L"Error initializing COM (0x%x)\n", hr);
98 r = 1;
99 }
100
101 VBoxNetCfgWinSetLogging(NULL);
102
103 return r;
104}
105
106int __cdecl main(int argc, char **argv)
107{
108 RT_NOREF2(argc, argv);
109 return VBoxNetLwfUninstall();
110}
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