[PATCH] [WineDump]: fake dlls
Eric Pouech
eric.pouech at wanadoo.fr
Mon Apr 10 13:53:58 CDT 2006
- now that setupapi generates fake DLLs, add the recognition of
those in winedump
A+
---
tools/winedump/dump.c | 30 +++++++++++++++++-------------
tools/winedump/pe.c | 16 +++++++++++++---
tools/winedump/pe.h | 2 +-
tools/winedump/winedump.h | 2 +-
4 files changed, 32 insertions(+), 18 deletions(-)
diff --git a/tools/winedump/dump.c b/tools/winedump/dump.c
index 0382889..ddd2a7a 100644
--- a/tools/winedump/dump.c
+++ b/tools/winedump/dump.c
@@ -144,24 +144,25 @@ unsigned long Offset(const void* ptr)
return (char*)ptr - (char*)dump_base;
}
-static void do_dump( enum FileSig sig, const void* pmt )
+static void do_dump( enum FileSig sig, const void* pmt, unsigned delta )
{
- if (sig == SIG_NE)
+ switch (sig)
{
+ case SIG_NE:
ne_dump( dump_base, dump_total_len );
- return;
- }
-
- if (sig == SIG_LE)
- {
+ break;
+ case SIG_LE:
le_dump( dump_base, dump_total_len );
- return;
+ break;
+ case SIG_PE:
+ pe_dump(pmt, delta);
+ break;
+ default:
+ assert(0);
}
-
- pe_dump(pmt);
}
-static enum FileSig check_headers(const void** pmt)
+static enum FileSig check_headers(const void** pmt, unsigned* delta)
{
const WORD* pw;
const DWORD* pdw;
@@ -171,6 +172,7 @@ static enum FileSig check_headers(const
pw = PRD(0, sizeof(WORD));
if (!pw) {printf("Can't get main signature, aborting\n"); return 0;}
+ *delta = 0;
*pmt = NULL;
switch (*pw)
{
@@ -179,6 +181,7 @@ static enum FileSig check_headers(const
dh = PRD(0, sizeof(IMAGE_DOS_HEADER));
if (dh && dh->e_lfanew >= sizeof(*dh)) /* reasonable DOS header ? */
{
+ *delta = dh->e_lfanew - sizeof(*dh);
/* the signature is the first DWORD */
pdw = PRD(dh->e_lfanew, sizeof(DWORD));
if (pdw)
@@ -232,6 +235,7 @@ int dump_analysis(const char* name, file
int ret = 1;
struct stat s;
const void* pmt;
+ unsigned delta;
setbuf(stdout, NULL);
@@ -249,7 +253,7 @@ int dump_analysis(const char* name, file
if ((unsigned long)read( fd, (void*)dump_base, dump_total_len ) != dump_total_len) fatal( "Cannot read file" );
}
- effective_sig = check_headers(&pmt);
+ effective_sig = check_headers(&pmt, &delta);
if (effective_sig == SIG_UNKNOWN)
{
@@ -266,7 +270,7 @@ int dump_analysis(const char* name, file
case SIG_NE:
case SIG_LE:
printf("Contents of \"%s\": %ld bytes\n\n", name, dump_total_len);
- (*fn)(effective_sig, pmt);
+ (*fn)(effective_sig, pmt, delta);
break;
case SIG_DBG:
dump_separate_dbg();
diff --git a/tools/winedump/pe.c b/tools/winedump/pe.c
index d09e896..987307b 100644
--- a/tools/winedump/pe.c
+++ b/tools/winedump/pe.c
@@ -46,7 +46,7 @@
#include "winedump.h"
#include "pe.h"
-static const IMAGE_NT_HEADERS32* PE_nt_headers;
+static const IMAGE_NT_HEADERS32* PE_nt_headers;
static const char* get_machine_str(DWORD mach)
{
@@ -1060,9 +1060,19 @@ static void dump_dir_resource(void)
printf( "\n\n" );
}
-void pe_dump(const void* pmt)
+static const char fakedll_signature[] = "Wine placeholder DLL";
+
+void pe_dump(const void* pmt, unsigned delta)
{
int all = (globals.dumpsect != NULL) && strcmp(globals.dumpsect, "ALL") == 0;
+ if (delta >= sizeof(fakedll_signature))
+ {
+ const char* tmp = (const char*)pmt - delta;
+ if (!strcmp(tmp, fakedll_signature))
+ printf("********************************\n"
+ "*** This is a Wine fake DLL! ***\n"
+ "********************************\n\n");
+ }
PE_nt_headers = pmt;
if (globals.do_dumpheader)
@@ -1136,7 +1146,7 @@ static void dll_close (void)
}
*/
-static void do_grab_sym( enum FileSig sig, const void* pmt )
+static void do_grab_sym( enum FileSig sig, const void* pmt, unsigned delta )
{
const IMAGE_EXPORT_DIRECTORY*exportDir;
unsigned i, j;
diff --git a/tools/winedump/pe.h b/tools/winedump/pe.h
index cf09b0a..cd82085 100644
--- a/tools/winedump/pe.h
+++ b/tools/winedump/pe.h
@@ -22,4 +22,4 @@ extern void dump_codeview(unsigned long
extern void dump_coff(unsigned long coffbase, unsigned long len, const void* sect_map);
extern void dump_frame_pointer_omission(unsigned long base, unsigned long len);
extern void dump_separate_dbg(void);
-extern void pe_dump(const void*);
+extern void pe_dump(const void*, unsigned);
diff --git a/tools/winedump/winedump.h b/tools/winedump/winedump.h
index 9e725df..bc4842b 100644
--- a/tools/winedump/winedump.h
+++ b/tools/winedump/winedump.h
@@ -228,7 +228,7 @@ enum FileSig {SIG_UNKNOWN, SIG_DOS, SIG_
const void* PRD(unsigned long prd, unsigned long len);
unsigned long Offset(const void* ptr);
-typedef void (*file_dumper)(enum FileSig, const void*);
+typedef void (*file_dumper)(enum FileSig, const void*, unsigned);
int dump_analysis(const char*, file_dumper, enum FileSig);
void dump_data( const unsigned char *ptr, unsigned int size, const char *prefix );
More information about the wine-patches
mailing list