preload.cpp revision e64031e20c39650a7bc902a3e1aba613b9415dee
/* $Id$ */
/** @file
* bin2c - Binary 2 C Structure Converter.
*/
/*
* 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 *
*******************************************************************************/
#ifdef RT_OS_WINDOWS
# include <Windows.h>
#else
# include <fcntl.h>
# include <unistd.h>
# include <errno.h>
#endif
#include <stdio.h>
#include <string.h>
{
#ifdef RT_OS_WINDOWS
NULL /*pSecurityAttributes*/,
NULL /*hTemplateFile*/);
if (hFile == INVALID_HANDLE_VALUE)
{
return 1;
}
? cbHigh == 0
? cbLow
: ~(DWORD)0 / 4
: 64;
NULL /*pAttributes*/,
0 /*dwMaximumSizeHigh -> file size*/,
0 /*dwMaximumSizeLow -> file size*/,
NULL /*pName*/);
if (hMap == INVALID_HANDLE_VALUE)
if (hMap == INVALID_HANDLE_VALUE)
return 1;
0 /*dwFileOffsetHigh*/,
0 /*dwFileOffsetLow*/,
0 /*dwNumberOfBytesToMap - file size */);
if (!pvWhere)
{
return 1;
}
#else
if (fd < 0)
{
return 1;
}
: ~(size_t)0 / 4;
if (pvWhere == MAP_FAILED)
if (pvWhere == MAP_FAILED)
return 1;
#endif
/* Touch the whole image... do a dummy crc to keep the optimizer from begin
smart with us. */
unsigned int uCrc = 0;
return 0;
}
{
printf("Generic executable image preloader.\n"
"Usage: %s [dll|exe|file []]\n", argv0);
return 1;
}
{
/*
* Check for options.
*/
for (int i = 1; i < argc; i++)
{
if (argv[i][0] == '-')
{
break;
{
return 1;
}
{
printf("$Revision$\n");
return 0;
}
return 1;
}
}
if (argc <= 1)
/*
* Do the loading.
*/
for (int i = 1; i < argc; i++)
{
continue;
if (argv[i][0] == '@')
{
if (pFile)
{
char szLine[4096];
{
psz++;
while ( off > 0
)
}
}
else
}
else
}
/*
* Sleep for ever.
*/
for (;;)
{
#ifdef RT_OS_WINDOWS
#else
sleep(3600);
#endif
}
return 0;
}