USBInstall.cpp revision c58f1213e628a545081c70e26c6b67a841cff880
/** @file
*
* VBox host drivers - USB drivers - Filter & driver installation
*
* Installation code
*
* Copyright (C) 2006-2011 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 <setupapi.h>
#include <newdev.h>
#include <iprt/initterm.h>
#include <stdio.h>
#include <VBox/VBoxDrvCfg-win.h>
static DECLCALLBACK(void) vboxUsbLog(VBOXDRVCFG_LOG_SEVERITY enmSeverity, char * msg, void * pvContext)
{
switch (enmSeverity)
{
break;
break;
default:
break;
}
}
{
AssertFailed();
}
int usblibOsCreateService(void);
{
{
printf("Could not init IPRT!\n");
return 1;
}
RTPrintf("USB installation\n");
int rc = usblibOsCreateService();
if (RT_SUCCESS(rc))
{
{
RTPrintf("Installation successful.\n");
}
else
{
rc = -1;
}
}
if (RT_SUCCESS(rc))
rc = 0;
/** @todo RTR3Term(); */
return rc;
}
/** The support service name. */
#define SERVICE_NAME "VBoxUSBMon"
/** Win32 Device name. */
#define DEVICE_NAME "\\\\.\\VBoxUSBMon"
/** NT Device name. */
#define DEVICE_NAME_NT L"\\Device\\VBoxUSBMon"
/** Win32 Symlink name. */
#define DEVICE_NAME_DOS L"\\DosDevices\\VBoxUSBMon"
/**
* Changes the USB driver service to specified driver path.
*
* @returns 0 on success.
* @returns < 0 on failure.
*/
int usblibOsChangeService(const char *pszDriverPath)
{
if (hSMgrCreate)
{
{
AssertMsg(hService, ("OpenService failed! LastError=%Rwa, pszDriver=%s\n", dwLastError, pszDriverPath));
}
else
{
/* We only gonna change the driver image path, the rest remains like it already is */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL))
{
}
else
{
AssertMsg(hService, ("ChangeServiceConfig failed! LastError=%Rwa, pszDriver=%s\n", dwLastError, pszDriverPath));
}
}
}
return rc;
}
/**
* Creates the service.
*
* @returns 0 on success.
* @returns < 0 on failure.
*/
int usblibOsCreateService(void)
{
/*
* Assume it didn't exist, so we'll create the service.
*/
if (hSMgrCreate)
{
char szDriver[RTPATH_MAX];
if (RT_SUCCESS(rc))
{
"VBox USB Monitor Driver",
if (dwLastError == ERROR_SERVICE_EXISTS)
{
RTPrintf("USB monitor driver service already exists, skipping creation.\n");
}
else
{
AssertMsg(hService, ("CreateService failed! LastError=%Rwa, szDriver=%s\n", dwLastError, szDriver));
}
}
}
return rc;
}