VBoxGuestInst.cpp revision e64031e20c39650a7bc902a3e1aba613b9415dee
/** @file
*
* Small tool to (un)install the VBoxGuest device driver
*
* Copyright (C) 2006-2007 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <VBox/VBoxGuest.h>
//#define TESTMODE
int installDriver(void)
{
/*
* Assume it didn't exist, so we'll create the service.
*/
if (!hSMgrCreate)
{
return -1;
}
"VBoxGuest Support Driver",
"System",
if (!hService)
{
} else
{
}
return hService ? 0 : -1;
}
int uninstallDriver(void)
{
int rc = -1;
if (!hSMgr)
{
return -1;
}
if (hService)
{
/*
* Delete the service.
*/
if (DeleteService(hService))
rc = 0;
else
}
else if (GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST)
rc = 0;
else
return rc;
}
HANDLE openDriver(void)
{
NULL,
NULL);
if (hDevice == INVALID_HANDLE_VALUE)
{
}
return hDevice;
}
{
return 0;
}
#ifdef TESTMODE
typedef struct TESTFOO
{
int values[16];
int performTest(void)
{
int rc = 0;
if (hDevice != INVALID_HANDLE_VALUE)
{
} else
{
printf("openDriver failed!\n");
}
return rc;
}
#endif
void displayHelpAndExit(char *programName)
{
exit(1);
}
{
bool installMode;
#ifdef TESTMODE
bool testMode = false;
#endif
if (argc != 2)
{
displayHelpAndExit(argv[0]);
}
{
installMode = true;
} else
{
installMode = false;
} else
#ifdef TESTMODE
{
testMode = true;
} else
#endif
{
displayHelpAndExit(argv[0]);
}
int rc;
#ifdef TESTMODE
if (testMode)
{
rc = performTest();
} else
#endif
if (installMode)
{
rc = installDriver();
} else
{
rc = uninstallDriver();
}
if (rc == 0)
{
printf("operation completed successfully!\n");
} else
{
}
return rc;
}