本文整理汇总了C++中BinaryFile::DisplayDetails方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryFile::DisplayDetails方法的具体用法?C++ BinaryFile::DisplayDetails怎么用?C++ BinaryFile::DisplayDetails使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryFile
的用法示例。
在下文中一共展示了BinaryFile::DisplayDetails方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
// Usage
if (argc != 2) {
printf ("Usage: %s <filename>\n", argv[0]);
printf ("%s dumps the contents of the given executable file\n", argv[0]);
return 1;
}
// Load the file
BinaryFile *pbf = NULL;
BinaryFileFactory bff;
pbf = bff.Load(argv[1]);
if (pbf == NULL) {
return 2;
}
// Display program and section information
// If the DisplayDetails() function has not been implemented
// in the derived class (ElfBinaryFile in this case), then
// uncomment the commented code below to display section information.
pbf->DisplayDetails (argv[0]);
// This is an alternative way of displaying binary-file information
// by using individual sections. The above approach is more general.
/*
printf ("%d sections:\n", pbf->GetNumSections());
for (int i=0; i < pbf->GetNumSections(); i++)
{
SectionInfo* pSect = pbf->GetSectionInfo(i);
printf(" Section %s at %X\n", pSect->pSectionName, pSect->uNativeAddr);
}
printf("\n");
*/
// Display the code section in raw hexadecimal notation
// Note: this is traditionally the ".text" section in Elf binaries.
// In the case of Prc files (Palm), the code section is named "code0".
for (int i=0; i < pbf->GetNumSections(); i++) {
SectionInfo* pSect = pbf->GetSectionInfo(i);
if (pSect->bCode) {
printf(" Code section:\n");
ADDRESS a = pSect->uNativeAddr;
unsigned char* p = (unsigned char*) pSect->uHostAddr;
for (unsigned off = 0; off < pSect->uSectionSize; ) {
printf("%04X: ", a);
for (int j=0; (j < 16) && (off < pSect->uSectionSize); j++) {
printf("%02X ", *p++);
a++;
off++;
}
printf("\n");
}
printf("\n");
}
}
// Display the data section(s) in raw hexadecimal notation
for (int i=0; i < pbf->GetNumSections(); i++) {
SectionInfo* pSect = pbf->GetSectionInfo(i);
if (pSect->bData) {
printf(" Data section: %s\n", pSect->pSectionName);
ADDRESS a = pSect->uNativeAddr;
unsigned char* p = (unsigned char*) pSect->uHostAddr;
for (unsigned off = 0; off < pSect->uSectionSize; ) {
printf("%04X: ", a);
for (int j=0; (j < 16) && (off < pSect->uSectionSize); j++) {
printf("%02X ", *p++);
a++;
off++;
}
printf("\n");
}
printf("\n");
}
}
pbf->UnLoad();
return 0;
}