readpe 支持 x64 了
#define DUMP_SECTIONS() do{ \
printf("ImageBase:\t" READPE_PTR_FMT "\n", ((READEPE_NT_HEADERS*)nt_header)->OptionalHeader.ImageBase); \
printf("StackCommit:\t" READPE_PTR_FMT "\n", ((READEPE_NT_HEADERS*)nt_header)->OptionalHeader.SizeOfStackCommit); \
\
puts(""); \
\
puts("Sections\n============"); \
IMAGE_SECTION_HEADER* section = (IMAGE_SECTION_HEADER*)xmalloc(sizeof(IMAGE_SECTION_HEADER)); \
fseek(file, dos_header->e_lfanew, SEEK_SET); \
fseek(file, (size_t)IMAGE_FIRST_SECTION(((READEPE_NT_HEADERS*)nt_header)) - (size_t)nt_header, SEEK_CUR); \
fread(section, sizeof(IMAGE_SECTION_HEADER), 1, file); \
puts("## Name FLAGS virtaddr[ size ] fileaddr[ size ]"); \
puts("------------------------------------------------------------------"); \
for (int i = 0; i < ((READEPE_NT_HEADERS*)nt_header)->FileHeader.NumberOfSections; ++i) \
{ \
printf("%02d %8.8s\t%5s\t" READPE_PTR_FMT "[" "%08lx" "]\t" "%08lx" "[" "%08lx" "]\n", \
i, \
section->Name, \
get_section_flags(section->Characteristics), \
section->VirtualAddress + ((READEPE_NT_HEADERS*)nt_header)->OptionalHeader.ImageBase, \
section->Misc.VirtualSize, \
section->PointerToRawData, \
section->SizeOfRawData); \
\
fread(section, sizeof(IMAGE_SECTION_HEADER), 1, file); \
} \
free(section); \
}while(0)