/** @file
*
* instdrvmain - Install guest drivers on NT4
*
* Copyright (C) 2006-2010 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.
*/
/**
* @todo
* The spacing in this file is horrible! Here are some simple rules:
* - tabs are forbidden
* - indentation is 4 spaces
*/
#include <windows.h>
#include <setupapi.h>
#include <regstr.h>
#include <DEVGUID.h>
#include <stdio.h>
#include "tchar.h"
#include "string.h"
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** The video service name. */
/** The video inf file name */
/////////////////////////////////////////////////////////////////////////////
/**
* Do some cleanup of data we used. Called by installVideoDriver()
*/
{
}
/**
* Install the VBox video driver.
*
* @returns TRUE on success.
* @returns FALSE on failure.
* @param szDriverDir The base directory where we find the INF.
*/
{
/* Vars used for reading the INF */
/* Create an empty list */
NULL);
if (hDevInfo == INVALID_HANDLE_VALUE)
return FALSE;
NULL,
if(!rc)
return FALSE;
DI_ENUMSINGLEINF; /* .DriverPath specifies an inf file */
/* Path to inf file */
TEXT("%ws\\%ws"),
NULL,
if(!rc)
return FALSE;
/* Read the drivers from the inf file */
{
return FALSE;
}
/* Get the first found driver.
Our Inf file only contains one so this is fine */
0, &drvInfoData)){
return FALSE;
}
/* Get necessary driver details */
if (!(!SetupDiGetDriverInfoDetail(hDevInfo,
NULL,
&&GetLastError()== ERROR_INSUFFICIENT_BUFFER) )
{
return FALSE;
}
if (hInf == INVALID_HANDLE_VALUE)
{
return FALSE;
}
/* First install the service */
{
/* No service line?? Can't be... */
return FALSE;
}
/* Get the name */
1,
sizeof(szServiceData),
NULL);
NULL, //Do we need a description here?
NULL, //No user interface
0,
&deviceInfoData) &&
0,
NULL,
NULL,
NULL)) )
{
/* We created a new key in the registry */
DI_ENUMSINGLEINF; //Use our INF file only
/* Path to inf file */
TEXT("%ws\\%ws"),
{
return FALSE;
}
0,
&drvInfoData))
{
return FALSE;
}
&drvInfoData))
{
return FALSE;
}
{
return FALSE;
}
}
/* Make sure the device is enabled */
sizeof(DWORD),
NULL)
&& (configFlags & CONFIGFLAG_DISABLED))
{
(LPBYTE) &configFlags,
sizeof(DWORD));
}
TEXT("System\\CurrentControlSet\\Services\\%ws\\Device%d"),
szServiceData, 0); //We only have one device
0,
NULL,
NULL,
&hkey,
&disp) == ERROR_SUCCESS)
{
/* Insert description */
TEXT("Device Description"),
0,
sizeof(TCHAR) );
TEXT("%ws.SoftwareSettings"),
hInf,
hkey,
NULL,
0,
NULL,
NULL,
NULL,
NULL))
{
return FALSE;
}
}
/* Install OpenGL stuff */
TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\OpenGLDrivers"),
0,
NULL,
NULL,
&hkey,
&disp) == ERROR_SUCCESS)
{
/* Do installation here if ever necessary. Currently there is no OpenGL stuff */
}
/* Cleanup */
#if 0
/* If this key is inserted into the registry, windows will show the desktop
applet on next boot. We decide in the installer if we want that so the code
is disabled here. */
/* Set registry keys so windows picks up the changes */
TEXT("SYSTEM\\CurrentControlSet\\Control\\GraphicsDrivers\\NewDisplay"),
0,
NULL,
NULL,
&hkey,
&disp) == ERROR_SUCCESS)
{
}
#endif
/* We must reboot at some point */
TEXT("SYSTEM\\CurrentControlSet\\Control\\GraphicsDrivers\\RebootNecessary"),
0,
NULL,
NULL,
&hkey,
&disp) == ERROR_SUCCESS)
{
}
return TRUE;
}
{
printf("Installs VirtualBox Guest Additions for Windows NT 4.0\n\n");
printf("\n\t/i - perform Guest Additions installation\n");
printf("\t/u: - perform Guest Additions uninstallation\n");
exit(1);
}
/**
* Check if we are running on NT4.
*
* @returns TRUE if NT 4.
* @returns FALSE otherwise.
*/
{
switch (osVersion.dwPlatformId)
{
case VER_PLATFORM_WIN32s:
return FALSE;
case VER_PLATFORM_WIN32_NT:
return TRUE;
else
return FALSE;
default:
break;
}
return FALSE;
}
/**
* Video driver uninstallation will be added later if necessary.
*/
int uninstallDrivers(void)
{
return 0;
}
{
/** @todo r=bird:
* And by the way, we're only missing the coding style dmik uses now
* and this file would contain the complete set. */
displayHelpAndExit(argv[0]);
/* This program is only for installing drivers on NT4 */
if(!isNT4()){
printf("This program only runs on NT4\n");
return -1;
}
{
return -1;
}
if (!lastBackslash)
{
printf("Invalid path name!\n");
return -1;
}
*lastBackslash=L'\0';
/* Install video driver. Mouse driver installation is done by overwriting
the image path in the setup script. */
}
else{
/* No video driver uninstallation yet. Do we need it? */
}
printf("Some failure occurred during driver installation.\n");
return !rc; /* Return != 0 on failure. */
}