VBoxVMMPreload.cpp revision ebf8c55b09887a27267e578f664308a386d5c106
/* $Id$ */
/** @file
* VBoxVMMPreload - Preload VBox the ring-0 modules.
*/
/*
* Copyright (C) 2012 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 <iprt/buildconfig.h>
#include <iprt/initterm.h>
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/**
* Known modules and their associated data (there are only known modules!).
*/
static struct
{
const char *pszName;
bool fPreload;
void *pvImageBase;
} g_aModules[] =
{
{ "VMMR0.r0", true, NULL },
{ "VBoxDDR0.r0", true, NULL },
{ "VBoxDD2R0.r0", true, NULL },
};
/**
* Parses the options.
*
* @returns RTEXITCODE_SUCCESS on success.
* @param argc Argument count .
* @param argv Argument vector.
* @param pfExit Set to @c true if we should exit.
*/
{
/*
* Parse arguments.
*/
static const RTGETOPTDEF s_aOptions[] =
{
};
bool fAll = true;
int ch;
{
switch(ch)
{
case 'o':
{
uint32_t i;
if (fAll)
{
fAll = false;
for (i = 0; i < RT_ELEMENTS(g_aModules); i++)
g_aModules[i].fPreload = false;
}
i = RT_ELEMENTS(g_aModules);
while (i-- > 0)
{
g_aModules[i].fPreload = true;
break;
}
if (i > RT_ELEMENTS(g_aModules))
break;
}
case 'v':
g_cVerbose++;
break;
case 'q':
g_cVerbose = 0;
break;
case 'h':
"All rights reserved.\n"
"\n"
"Usage: VBoxVMMPreload [-hqvV] [-o|--only <mod>]\n"
"\n");
*pfExit = true;
return RTEXITCODE_SUCCESS;
case 'V':
*pfExit = true;
return RTEXITCODE_SUCCESS;
default:
}
}
return RTEXITCODE_SUCCESS;
}
/**
* Loads the modules.
*
* @returns RTEXITCODE_SUCCESS on success.
*/
static RTEXITCODE LoadModules(void)
{
{
if (g_aModules[i].fPreload)
{
char szPath[RTPATH_MAX];
if (RT_SUCCESS(rc))
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPathAppPrivateArch or RTPathAppend returned %Rrc", rc);
if (RT_FAILURE(rc))
if (g_cVerbose >= 1)
}
}
return RTEXITCODE_SUCCESS;
}
/**
* Entry point.
*/
{
bool fExit = false;
{
rcExit = LoadModules();
if (rcExit == RTEXITCODE_SUCCESS)
{
for (;;)
}
}
return rcExit;
}
#ifndef VBOX_WITH_HARDENING
/**
* Main entry point.
*/
{
if (RT_FAILURE(rc))
return RTMsgInitFailure(rc);
}
#endif /* !VBOX_WITH_HARDENING */