本文整理汇总了C++中BinaryFile::GetMainEntryPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryFile::GetMainEntryPoint方法的具体用法?C++ BinaryFile::GetMainEntryPoint怎么用?C++ BinaryFile::GetMainEntryPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryFile
的用法示例。
在下文中一共展示了BinaryFile::GetMainEntryPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}