VBCoInst.cpp revision 78a072e1b56619e3230735ae073668311232ec94
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
//+---------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1999.
//
// File: COINST.C
//
// Contents: co-installer hook.
//
// Notes: For a complete description of CoInstallers, please see the
// Microsoft Windows 2000 DDK Documentation
//
// Author: keithga 4 June 1999
//
// Revision History:
// Added FriendlyName interface (Eliyas Yakub Aug 2, 1999)
//
//----------------------------------------------------------------------------
#define _UNICODE
#endif
#include <windows.h>
#include <setupapi.h>
#include <stdio.h>
#include <tchar.h>
// #define LOG_ENABLED
#ifdef LOG_ENABLED
#include <stdio.h>
{
{
if (f)
{
fclose (f);
}
}
}
#else
#define dprintf(a) do {} while (0)
#endif /* LOG_ENABLED */
//+---------------------------------------------------------------------------
//
// WARNING!
//
// A Coinstaller must not generate any popup to the user.
// it should provide appropriate defaults.
//
// OutputDebugString should be fine...
//
#if DBG
#else
#endif
/** strip the filename and leave the slash. */
{
/* strip of the filename. */
{
}
if (pchSep)
*pchSep = '\0';
else
{
psz[0] = '.';
}
}
/**
Check the installation type.
This function checks if the currently used
INF file not OEMxx.inf. If yes, the user installs the guest additions by hand,
if no this is an automated installation.
*/
{
/* strip of the filename. */
{
}
if (pchSep)
{
return FALSE;
return TRUE;
}
return TRUE; /* We shouldn't end here... */
}
{
STARTUPINFO sInfo = { 0 };
PROCESS_INFORMATION pInfo = { 0 };
/* Check if we do an automated install */
dprintf(("startMouseInstallation: fNotAutomated = %d, filename = %s\n", fNotAutomated, pszVBoxGuestInfName));
if (fNotAutomated)
{
/* This is a normal guest installation done by inserting the ISO */
_sntprintf(szAppCmd, sizeof(szAppCmd), TEXT("rundll32.exe SETUPAPI.DLL,InstallHinfSection VBoxMouse 132 %sVBoxMouse.inf"), pszVBoxGuestInfName);
NULL, //lpThreadAttributes
FALSE, //bInheritHandles
0, //dwCreationFlags
NULL, //lpEnvironment
NULL, //lpCurrentDirectory,
&sInfo, //lpStartupInfo,
&pInfo)) //lpProcessInformation
{
DWORD dwExitCode = 0;
/* Wait for rundll32 to finish and then check the exit code; only then do we know if it succeeded or not! */
{
//
// hook the filter into the mouse class
//
dprintf(("startMouseInstallation: hooking\n"));
// first determine the GUID of the Mouse class
if (SetupDiClassGuidsFromNameEx("Mouse", &guid, 1, &numGuids, NULL, NULL) || (GetLastError() == ERROR_INSUFFICIENT_BUFFER))
{
// get the corresponding class registry key
if (hkey)
{
// hardcoded value, ours + the standard filter
}
}
dprintf(("startMouseInstallation: return ok\n"));
return 0;
}
} /* CreateProcess() */
} /* fNotAutomated */
else
{
/* This is an automated installation */
//
// hook the filter into the mouse class
//
dprintf(("startMouseInstallation: automated\n"));
// first determine the GUID of the Mouse class
if (SetupDiClassGuidsFromNameEx("Mouse", &guid, 1, &numGuids, NULL, NULL) || (GetLastError() == ERROR_INSUFFICIENT_BUFFER))
{
// get the corresponding class registry key
if (hkey)
{
// hardcoded value, ours + the standard filter
}
}
return 0;
}
/* bitch to debug output */
return -1;
}
//+---------------------------------------------------------------------------
//
// Function: VBoxCoInstaller
//
// Purpose: Responds to co-installer messages
//
// Arguments:
// InstallFunction [in]
// DeviceInfoSet [in]
// DeviceInfoData [in]
// Context [inout]
//
// Returns: NO_ERROR, ERROR_DI_POSTPROCESSING_REQUIRED, or an error code.
//
// This co-installer is used to install the mouse filter after installation of
// the VBoxGuest driver
extern "C"
)
{
switch (InstallFunction)
{
case DIF_INSTALLDEVICE:
{
{
dprintf(("Failed to get DeviceInstallParams\n"));
return NO_ERROR;
}
/* Reboot the system and do not dynamically load the driver. */
{
dprintf(("Failed to set DeviceInstallParams\n"));
return NO_ERROR;
}
return NO_ERROR;
}
// case DIF_REMOVE:
// {
// return NO_ERROR;
// } break;
#if 0
/* This request is only sent when the installation of the VBoxGuest
succeeded. Because VBoxMouse needs VBoxGuest to work this is
a nice installation prerequisite check, too. */
{
/* Get the path to the VBoxGuest INF. The VBoxMouse INF is in the same
directory. */
{
return NO_ERROR; /* Should return an error here? */
}
sizeof(SP_DRVINFO_DETAIL_DATA),
NULL))
{
{
// We don't need the extended information. Ignore.
}
else
{
return NO_ERROR; /* Should return an error here? */
}
}
break;
}
#endif
default:
break;
}
return NO_ERROR;
}