本文整理汇总了C++中BinaryFileFactory::UnLoad方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryFileFactory::UnLoad方法的具体用法?C++ BinaryFileFactory::UnLoad怎么用?C++ BinaryFileFactory::UnLoad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryFileFactory
的用法示例。
在下文中一共展示了BinaryFileFactory::UnLoad方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testPentiumLoad
/*==============================================================================
* FUNCTION: LoaderTest::testPentiumLoad
* OVERVIEW: Test loading the pentium (Solaris) hello world program
*============================================================================*/
void LoaderTest::testPentiumLoad ()
{
std::ostringstream ost;
// Load Pentium hello world
BinaryFileFactory bff;
BinaryFile* pBF = bff.Load(HELLO_PENTIUM);
CPPUNIT_ASSERT(pBF != NULL);
int n;
SectionInfo* si;
n = pBF->GetNumSections();
ost << "Number of sections = " << std::dec << n << "\r\n\t";
si = pBF->GetSectionInfo(1);
ost << si->pSectionName << "\t";
si = pBF->GetSectionInfo(n-1);
ost << si->pSectionName;
pBF->UnLoad();
// Note: the string below needs to have embedded tabs. Edit with caution!
// (And slightly different string to the sparc test, e.g. rel vs rela)
std::string expected("Number of sections = 34\r\n\t"
".interp .strtab");
CPPUNIT_ASSERT_EQUAL(expected, ost.str());
bff.UnLoad();
}
示例2: testPalmLoad
/*==============================================================================
* FUNCTION: LoaderTest::testPalmLoad
* OVERVIEW: Test loading the Palm 68328 Starter.prc program
*============================================================================*/
void LoaderTest::testPalmLoad ()
{
std::ostringstream ost;
// Load Palm Starter.prc
BinaryFileFactory bff;
BinaryFile* pBF = bff.Load(STARTER_PALM);
CPPUNIT_ASSERT(pBF != NULL);
int n;
SectionInfo* si;
n = pBF->GetNumSections();
ost << "Number of sections = " << std::dec << n << "\r\n";
for (int i=0; i < n; i++)
{
si = pBF->GetSectionInfo(i);
ost << si->pSectionName << "\t";
}
pBF->UnLoad();
// Note: the string below needs to have embedded tabs. Edit with caution!
std::string expected("Number of sections = 8\r\n"
"code1 MBAR1000 tFRM1000 Talt1001 "
"data0 code0 tAIN1000 tver1000 ");
CPPUNIT_ASSERT_EQUAL(expected, ost.str());
bff.UnLoad();
}
示例3: testFindMain
void FrontPentTest::testFindMain()
{
// Test the algorithm for finding main, when there is a call to __libc_start_main
// Also tests the loader hack
BinaryFileFactory bff;
BinaryFile *pBF = bff.Load(FEDORA2_TRUE);
CPPUNIT_ASSERT(pBF != NULL);
Prog *prog = new Prog;
FrontEnd *pFE = new PentiumFrontEnd(pBF, prog, &bff);
prog->setFrontEnd(pFE);
CPPUNIT_ASSERT(pFE != NULL);
bool found;
ADDRESS addr = pFE->getMainEntryPoint(found);
ADDRESS expected = 0x8048b10;
CPPUNIT_ASSERT_EQUAL(expected, addr);
pBF->Close();
bff.UnLoad();
pBF = bff.Load(FEDORA3_TRUE);
CPPUNIT_ASSERT(pBF != NULL);
pFE = new PentiumFrontEnd(pBF, prog, &bff);
prog->setFrontEnd(pFE);
CPPUNIT_ASSERT(pFE != NULL);
addr = pFE->getMainEntryPoint(found);
expected = 0x8048c4a;
CPPUNIT_ASSERT_EQUAL(expected, addr);
pBF->Close();
bff.UnLoad();
pBF = bff.Load(SUSE_TRUE);
CPPUNIT_ASSERT(pBF != NULL);
pFE = new PentiumFrontEnd(pBF, prog, &bff);
prog->setFrontEnd(pFE);
CPPUNIT_ASSERT(pFE != NULL);
addr = pFE->getMainEntryPoint(found);
expected = 0x8048b60;
CPPUNIT_ASSERT_EQUAL(expected, addr);
pBF->Close();
delete pFE;
}
示例4: testSparcLoad
/*==============================================================================
* FUNCTION: LoaderTest::testSparcLoad
* OVERVIEW: Test loading the sparc hello world program
*============================================================================*/
void LoaderTest::testSparcLoad ()
{
std::ostringstream ost;
// Load SPARC hello world
BinaryFileFactory bff;
BinaryFile* pBF = bff.Load(HELLO_SPARC);
CPPUNIT_ASSERT(pBF != NULL);
int n;
SectionInfo* si;
n = pBF->GetNumSections();
ost << "Number of sections = " << std::dec << n << "\r\n\t";
// Just use the first (real one) and last sections
si = pBF->GetSectionInfo(1);
ost << si->pSectionName << "\t";
si = pBF->GetSectionInfo(n-1);
ost << si->pSectionName;
pBF->UnLoad();
// Note: the string below needs to have embedded tabs. Edit with caution!
std::string expected("Number of sections = 29\r\n\t"
".interp .stab.indexstr");
CPPUNIT_ASSERT_EQUAL(expected, ost.str());
bff.UnLoad();
}
示例5: testHppaLoad
/*==============================================================================
* FUNCTION: LoaderTest::testHppaLoad
* OVERVIEW: Test loading the sparc hello world program
*============================================================================*/
void LoaderTest::testHppaLoad ()
{
std::ostringstream ost;
// Load HPPA hello world
BinaryFileFactory bff;
BinaryFile* pBF = bff.Load(HELLO_HPPA);
CPPUNIT_ASSERT(pBF != NULL);
int n;
SectionInfo* si;
n = pBF->GetNumSections();
ost << "Number of sections = " << std::dec << n << "\r\n";
for (int i=0; i < n; i++)
{
si = pBF->GetSectionInfo(i);
ost << si->pSectionName << "\t";
}
pBF->UnLoad();
// Note: the string below needs to have embedded tabs. Edit with caution!
std::string expected("Number of sections = 4\r\n"
"$HEADER$ $TEXT$ $DATA$ $BSS$ ");
CPPUNIT_ASSERT_EQUAL(expected, ost.str());
bff.UnLoad();
}
示例6: testWinLoad
/*==============================================================================
* FUNCTION: LoaderTest::testWinLoad
* OVERVIEW: Test loading Windows programs
*============================================================================*/
void LoaderTest::testWinLoad ()
{
std::ostringstream ost;
#if 0 /* FIXME: these tests should use non-proprietary programs */
// Load Windows program calc.exe
BinaryFileFactory bff;
BinaryFile* pBF = bff.Load(CALC_WINDOWS);
CPPUNIT_ASSERT(pBF != NULL);
int n;
SectionInfo* si;
n = pBF->GetNumSections();
ost << "Number of sections = " << std::dec << n << "\r\n";
for (int i=0; i < n; i++)
{
si = pBF->GetSectionInfo(i);
ost << si->pSectionName << "\t";
}
// Note: the string below needs to have embedded tabs. Edit with caution!
std::string expected("Number of sections = 5\r\n"
".text .rdata .data .rsrc .reloc ");
std::string actual(ost.str());
CPPUNIT_ASSERT_EQUAL(expected, actual);
ADDRESS addr = pBF->GetMainEntryPoint();
CPPUNIT_ASSERT(addr != NO_ADDRESS);
// Test symbol table (imports)
const char* s = pBF->SymbolByAddress(0x1292060U);
if (s == 0)
actual = "<not found>";
else
actual = std::string(s);
expected = std::string("SetEvent");
CPPUNIT_ASSERT_EQUAL(expected, actual);
ADDRESS a = pBF->GetAddressByName("SetEvent");
ADDRESS expectedAddr = 0x1292060;
CPPUNIT_ASSERT_EQUAL(expectedAddr, a);
pBF->UnLoad();
bff.UnLoad();
// Test loading the "new style" exes, as found in winXP etc
pBF = bff.Load(CALC_WINXP);
CPPUNIT_ASSERT(pBF != NULL);
addr = pBF->GetMainEntryPoint();
std::ostringstream ost1;
ost1 << std::hex << addr;
actual = ost1.str();
expected = "1001f51";
CPPUNIT_ASSERT_EQUAL(expected, actual);
pBF->UnLoad();
bff.UnLoad();
// Test loading the calc.exe found in Windows 2000 (more NT based)
pBF = bff.Load(CALC_WIN2000);
CPPUNIT_ASSERT(pBF != NULL);
expected = "1001680";
addr = pBF->GetMainEntryPoint();
std::ostringstream ost2;
ost2 << std::hex << addr;
actual = ost2.str();
CPPUNIT_ASSERT_EQUAL(expected, actual);
pBF->UnLoad();
bff.UnLoad();
// Test loading the lpq.exe program - console mode PE file
pBF = bff.Load(LPQ_WINDOWS);
CPPUNIT_ASSERT(pBF != NULL);
addr = pBF->GetMainEntryPoint();
std::ostringstream ost3;
ost3 << std::hex << addr;
actual = ost3.str();
expected = "18c1000";
CPPUNIT_ASSERT_EQUAL(expected, actual);
pBF->UnLoad();
bff.UnLoad();
#endif
// Borland
BinaryFileFactory bff;
BinaryFile* pBF = bff.Load(SWITCH_BORLAND);
CPPUNIT_ASSERT(pBF != NULL);
ADDRESS addr = pBF->GetMainEntryPoint();
std::ostringstream ost4;
ost4 << std::hex << addr;
std::string actual(ost4.str());
std::string expected("401150");
CPPUNIT_ASSERT_EQUAL(expected, actual);
pBF->UnLoad();
bff.UnLoad();
}