From ddf57d26affbe15286284bd6be867909a03b58b5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Hentschel?= Date: Tue, 21 Jul 2015 23:19:31 +0200 Subject: [PATCH] winedump: Dump load config when available. --- tools/winedump/main.c | 2 +- tools/winedump/pe.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/tools/winedump/main.c b/tools/winedump/main.c index dfd15b07154..a4ebb4359ea 100644 --- a/tools/winedump/main.c +++ b/tools/winedump/main.c @@ -228,7 +228,7 @@ static const struct my_option option_table[] = { {"-C", DUMP, 0, do_symdmngl, "-C Turn on symbol demangling"}, {"-f", DUMP, 0, do_dumphead, "-f Dump file header information"}, {"-G", DUMP, 0, do_rawdebug, "-G Dump raw debug information"}, - {"-j", DUMP, 1, do_dumpsect, "-j Dump only the content of section 'sect_name' (import, export, debug, resource, tls, clr, reloc, except)"}, + {"-j", DUMP, 1, do_dumpsect, "-j Dump only the content of section 'sect_name' (import, export, debug, resource, tls, loadcfg, clr, reloc, except)"}, {"-t", DUMP, 0, do_symtable, "-t Dump symbol table"}, {"-x", DUMP, 0, do_dumpall, "-x Dump everything"}, {NULL, NONE, 0, NULL, NULL} diff --git a/tools/winedump/pe.c b/tools/winedump/pe.c index dbe5d8f97d1..54250e4b32b 100644 --- a/tools/winedump/pe.c +++ b/tools/winedump/pe.c @@ -1266,6 +1266,52 @@ static void dump_dir_imported_functions(void) printf("\n"); } +static void dump_dir_loadconfig(void) +{ + const IMAGE_LOAD_CONFIG_DIRECTORY32 *loadcfg32 = get_dir(IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG); + const IMAGE_LOAD_CONFIG_DIRECTORY64 *loadcfg64 = (void*)loadcfg32; + + if (!loadcfg32) return; + + printf( "Loadconfig\n" ); + print_dword( "Size", loadcfg32->Size ); + print_dword( "TimeDateStamp", loadcfg32->TimeDateStamp ); + print_word( "MajorVersion", loadcfg32->MajorVersion ); + print_word( "MinorVersion", loadcfg32->MinorVersion ); + print_dword( "GlobalFlagsClear", loadcfg32->GlobalFlagsClear ); + print_dword( "GlobalFlagsSet", loadcfg32->GlobalFlagsSet ); + print_dword( "CriticalSectionDefaultTimeout", loadcfg32->CriticalSectionDefaultTimeout ); + + if(PE_nt_headers->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) + { + print_longlong( "DeCommitFreeBlockThreshold", loadcfg64->DeCommitFreeBlockThreshold ); + print_longlong( "DeCommitTotalFreeThreshold", loadcfg64->DeCommitTotalFreeThreshold ); + print_longlong( "MaximumAllocationSize", loadcfg64->MaximumAllocationSize ); + print_longlong( "VirtualMemoryThreshold", loadcfg64->VirtualMemoryThreshold ); + print_dword( "ProcessHeapFlags", loadcfg64->ProcessHeapFlags ); + print_longlong( "ProcessAffinityMask", loadcfg64->ProcessAffinityMask ); + print_word( "CSDVersion", loadcfg64->CSDVersion ); + print_word( "Reserved", loadcfg64->Reserved1 ); + print_longlong( "SecurityCookie", loadcfg64->SecurityCookie ); + print_longlong( "SEHandlerTable", loadcfg64->SEHandlerTable ); + print_longlong( "SEHandlerCount", loadcfg64->SEHandlerCount ); + } + else + { + print_dword( "DeCommitFreeBlockThreshold", loadcfg32->DeCommitFreeBlockThreshold ); + print_dword( "DeCommitTotalFreeThreshold", loadcfg32->DeCommitTotalFreeThreshold ); + print_dword( "MaximumAllocationSize", loadcfg32->MaximumAllocationSize ); + print_dword( "VirtualMemoryThreshold", loadcfg32->VirtualMemoryThreshold ); + print_dword( "ProcessHeapFlags", loadcfg32->ProcessHeapFlags ); + print_dword( "ProcessAffinityMask", loadcfg32->ProcessAffinityMask ); + print_word( "CSDVersion", loadcfg32->CSDVersion ); + print_word( "Reserved", loadcfg32->Reserved1 ); + print_dword( "SecurityCookie", loadcfg32->SecurityCookie ); + print_dword( "SEHandlerTable", loadcfg32->SEHandlerTable ); + print_dword( "SEHandlerCount", loadcfg32->SEHandlerCount ); + } +} + static void dump_dir_delay_imported_functions(void) { unsigned directorySize; @@ -1930,6 +1976,8 @@ void pe_dump(void) dump_dir_resource(); if (all || !strcmp(globals.dumpsect, "tls")) dump_dir_tls(); + if (all || !strcmp(globals.dumpsect, "loadcfg")) + dump_dir_loadconfig(); if (all || !strcmp(globals.dumpsect, "clr")) dump_dir_clr_header(); if (all || !strcmp(globals.dumpsect, "reloc")) -- 2.11.4.GIT