tstLdr-2.cpp revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* $Id$ */
/** @file
* InnoTek Portable Runtime - Testcase for parts of RTLdr*, manual inspection.
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* 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 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.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
{
int32_t i = 0;
while (i < cbMax)
{
char szOutput[256];
return false;
/* next */
i += cbInstr;
}
return true;
}
/**
* Resolve an external symbol during RTLdrGetBits().
*
* @returns iprt status code.
* @param hLdrMod The loader module handle.
* @param pszModule Module name.
* @param pszSymbol Symbol name, NULL if uSymbol should be used.
* @param uSymbol Symbol ordinal, ~0 if pszSymbol should be used.
* @param pValue Where to store the symbol value (address).
* @param pvUser User argument.
*/
static DECLCALLBACK(int) testGetImport(RTLDRMOD hLdrMod, const char *pszModule, const char *pszSymbol, unsigned uSymbol, RTUINTPTR *pValue, void *pvUser)
{
/* check the name format and only permit certain names */
*pValue = 0xf0f0f0f0;
return VINF_SUCCESS;
}
/**
* One test iteration with one file.
*
* The test is very simple, we load the the file three times
* into two different regions. The first two into each of the
* regions the for compare usage. The third is loaded into one
* and then relocated between the two and other locations a few times.
*
* @returns number of errors.
* @param pszFilename The file to load the mess with.
*/
static int testLdrOne(const char *pszFilename)
{
if (RT_FAILURE(rc))
{
return 1;
}
int rcRet = 1;
if (cb > 100)
{
if (pvBits)
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
{
DISCPUSTATE Cpu = {0};
{
if (RT_SUCCESS(rc))
{
rcRet = 0;
else
RTPrintf("tstLdr: Disassembly failed!\n");
}
else
RTPrintf("tstLdr: Relocate of '%s' from %#x to %#x failed, rc=%Vrc. Aborting test.\n",
}
else
RTPrintf("tstLdr: Disassembly failed!\n");
}
else
RTPrintf("tstLdr: Invalid value for symbol '%s' in '%s'. off=%#x Value=%#x\n",
}
else
RTPrintf("tstLdr: Failed to resolve symbol '%s' in '%s', rc=%Vrc.\n", "Entrypoint", pszFilename, rc);
}
else
}
else
}
else
/* cleanup */
if (RT_FAILURE(rc))
{
rcRet++;
}
return rcRet;
}
{
RTR3Init();
int rcRet = 0;
if (argc <= 1)
{
return 1;
}
/*
* Iterate the files.
*/
{
}
/*
* Test result summary.
*/
if (!rcRet)
RTPrintf("tstLdr: SUCCESS\n");
else
return !!rcRet;
}