Module: wine Branch: master Commit: e27c7e0648c05a28e550254e295abfb7ea9049b5 URL: https://source.winehq.org/git/wine.git/?a=commit;h=e27c7e0648c05a28e550254e2...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Feb 18 11:11:33 2021 +0100
winedump: Print the "prefer native" Wine flag.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
tools/winedump/output.c | 36 ++++++++++-------------------------- tools/winedump/pe.c | 13 ++++++++++--- 2 files changed, 20 insertions(+), 29 deletions(-)
diff --git a/tools/winedump/output.c b/tools/winedump/output.c index bbbb1ac0397..5911f22f6c8 100644 --- a/tools/winedump/output.c +++ b/tools/winedump/output.c @@ -234,41 +234,25 @@ void output_c_preamble (void) puts ("Creating a forwarding DLL");
fputs ("\nHMODULE hDLL=0; /* DLL to call */\n\n", cfile); - }
- fprintf (cfile, - "BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void " - "*reserved)\n{\n" + fprintf (cfile, + "BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)\n{\n" " TRACE("(%%p, %%u, %%p)\n", instance, reason, reserved);\n\n" " switch (reason)\n" " {\n" - " case DLL_WINE_PREATTACH:\n" - " return FALSE; /* prefer native version */\n" - " case DLL_PROCESS_ATTACH:\n"); - - if (globals.forward_dll) - fprintf (cfile, + " case DLL_PROCESS_ATTACH:\n" " hDLL = LoadLibraryA("%s");\n" - " TRACE("Forwarding DLL (%s) loaded (%%p)\n", hDLL);\n", - globals.forward_dll, globals.forward_dll); - else - fprintf (cfile, - " DisableThreadLibraryCalls(instance);\n"); - - fprintf (cfile, - " break;\n"); - - if (globals.forward_dll) - fprintf (cfile, + " TRACE("Forwarding DLL (%s) loaded (%%p)\n", hDLL);\n" + " DisableThreadLibraryCalls(instance);\n" + " break;\n" " case DLL_PROCESS_DETACH:\n" " FreeLibrary(hDLL);\n" " TRACE("Forwarding DLL (%s) freed\n");\n" - " break;\n", - globals.forward_dll); - - fprintf (cfile, + " break;\n" " }\n\n" - " return TRUE;\n}\n"); + " return TRUE;\n}\n", + globals.forward_dll, globals.forward_dll, globals.forward_dll); + } }
diff --git a/tools/winedump/pe.c b/tools/winedump/pe.c index 19ccd172da2..aa679103e59 100644 --- a/tools/winedump/pe.c +++ b/tools/winedump/pe.c @@ -45,8 +45,14 @@ #include "winbase.h" #include "winedump.h"
+#define IMAGE_DLLCHARACTERISTICS_PREFER_NATIVE 0x0010 /* Wine extension */ + static const IMAGE_NT_HEADERS32* PE_nt_headers;
+static const char builtin_signature[] = "Wine builtin DLL"; +static const char fakedll_signature[] = "Wine placeholder DLL"; +static int is_builtin; + const char *get_machine_str(int mach) { switch (mach) @@ -95,13 +101,13 @@ static const IMAGE_NT_HEADERS32 *get_nt_header( void ) const IMAGE_DOS_HEADER *dos; dos = PRD(0, sizeof(*dos)); if (!dos) return NULL; + is_builtin = (dos->e_lfanew >= sizeof(*dos) + 32 && + !memcmp( dos + 1, builtin_signature, sizeof(builtin_signature) )); return PRD(dos->e_lfanew, sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER)); }
void print_fake_dll( void ) { - static const char builtin_signature[] = "Wine builtin DLL"; - static const char fakedll_signature[] = "Wine placeholder DLL"; const IMAGE_DOS_HEADER *dos;
dos = PRD(0, sizeof(*dos) + 32); @@ -214,7 +220,8 @@ static inline void print_subsys(const char *title, WORD value) static inline void print_dllflags(const char *title, WORD value) { printf(" %-34s 0x%04X\n", title, value); -#define X(f,s) if (value & f) printf(" %s\n", s) +#define X(f,s) do { if (value & f) printf(" %s\n", s); } while(0) + if (is_builtin) X(IMAGE_DLLCHARACTERISTICS_PREFER_NATIVE, "PREFER_NATIVE (Wine extension)"); X(IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA, "HIGH_ENTROPY_VA"); X(IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE, "DYNAMIC_BASE"); X(IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY, "FORCE_INTEGRITY");