Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
7928f546
Commit
7928f546
authored
Dec 07, 2006
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Dec 07, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winedump: Handle properly partial optional COFF headers.
Export dump_file_header() and dump_optional_header() for use outside of pe.c.
parent
cb7453ff
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
20 deletions
+50
-20
pe.c
tools/winedump/pe.c
+43
-20
winedump.h
tools/winedump/winedump.h
+7
-0
No files found.
tools/winedump/pe.c
View file @
7928f546
...
...
@@ -91,7 +91,7 @@ static const IMAGE_NT_HEADERS32 *get_nt_header( void )
const
IMAGE_DOS_HEADER
*
dos
;
dos
=
PRD
(
0
,
sizeof
(
*
dos
));
if
(
!
dos
)
return
NULL
;
return
PRD
(
dos
->
e_lfanew
,
sizeof
(
IMAGE_NT_HEADERS32
));
return
PRD
(
dos
->
e_lfanew
,
sizeof
(
DWORD
)
+
sizeof
(
IMAGE_FILE_HEADER
));
}
static
int
is_fake_dll
(
void
)
...
...
@@ -223,8 +223,16 @@ static inline void print_datadirectory(DWORD n, const IMAGE_DATA_DIRECTORY *dire
}
}
static
void
dump_optional_header32
(
const
IMAGE_OPTIONAL_HEADER32
*
optionalHeader
)
static
void
dump_optional_header32
(
const
IMAGE_OPTIONAL_HEADER32
*
image_oh
,
UINT
header_size
)
{
IMAGE_OPTIONAL_HEADER32
oh
;
const
IMAGE_OPTIONAL_HEADER32
*
optionalHeader
;
/* in case optional header is missing or partial */
memset
(
&
oh
,
0
,
sizeof
(
oh
));
memcpy
(
&
oh
,
image_oh
,
min
(
header_size
,
sizeof
(
oh
)));
optionalHeader
=
&
oh
;
print_word
(
"Magic"
,
optionalHeader
->
Magic
);
print_ver
(
"linker version"
,
optionalHeader
->
MajorLinkerVersion
,
optionalHeader
->
MinorLinkerVersion
);
...
...
@@ -257,10 +265,19 @@ static void dump_optional_header32(const IMAGE_OPTIONAL_HEADER32 *optionalHeader
print_dword
(
"RVAs & sizes"
,
optionalHeader
->
NumberOfRvaAndSizes
);
printf
(
"
\n
"
);
print_datadirectory
(
optionalHeader
->
NumberOfRvaAndSizes
,
optionalHeader
->
DataDirectory
);
printf
(
"
\n
"
);
}
static
void
dump_optional_header64
(
const
IMAGE_OPTIONAL_HEADER64
*
optionalHeader
)
static
void
dump_optional_header64
(
const
IMAGE_OPTIONAL_HEADER64
*
image_oh
,
UINT
header_size
)
{
IMAGE_OPTIONAL_HEADER64
oh
;
const
IMAGE_OPTIONAL_HEADER64
*
optionalHeader
;
/* in case optional header is missing or partial */
memset
(
&
oh
,
0
,
sizeof
(
oh
));
memcpy
(
&
oh
,
image_oh
,
min
(
header_size
,
sizeof
(
oh
)));
optionalHeader
=
&
oh
;
print_word
(
"Magic"
,
optionalHeader
->
Magic
);
print_ver
(
"linker version"
,
optionalHeader
->
MajorLinkerVersion
,
optionalHeader
->
MinorLinkerVersion
);
...
...
@@ -292,14 +309,29 @@ static void dump_optional_header64(const IMAGE_OPTIONAL_HEADER64 *optionalHeader
print_dword
(
"RVAs & sizes"
,
optionalHeader
->
NumberOfRvaAndSizes
);
printf
(
"
\n
"
);
print_datadirectory
(
optionalHeader
->
NumberOfRvaAndSizes
,
optionalHeader
->
DataDirectory
);
printf
(
"
\n
"
);
}
static
void
dump_pe_header
(
void
)
void
dump_optional_header
(
const
IMAGE_OPTIONAL_HEADER32
*
optionalHeader
,
UINT
header_size
)
{
const
IMAGE_FILE_HEADER
*
fileHeader
;
printf
(
"Optional Header (%s)
\n
"
,
get_magic_type
(
optionalHeader
->
Magic
));
switch
(
optionalHeader
->
Magic
)
{
case
IMAGE_NT_OPTIONAL_HDR32_MAGIC
:
dump_optional_header32
(
optionalHeader
,
header_size
);
break
;
case
IMAGE_NT_OPTIONAL_HDR64_MAGIC
:
dump_optional_header64
((
const
IMAGE_OPTIONAL_HEADER64
*
)
optionalHeader
,
header_size
);
break
;
default:
printf
(
" Unknown optional header magic: 0x%-4X
\n
"
,
optionalHeader
->
Magic
);
break
;
}
}
void
dump_file_header
(
const
IMAGE_FILE_HEADER
*
fileHeader
)
{
printf
(
"File Header
\n
"
);
fileHeader
=
&
PE_nt_headers
->
FileHeader
;
printf
(
" Machine: %04X (%s)
\n
"
,
fileHeader
->
Machine
,
get_machine_str
(
fileHeader
->
Machine
));
...
...
@@ -330,21 +362,12 @@ static void dump_pe_header(void)
X
(
IMAGE_FILE_BYTES_REVERSED_HI
,
"BYTES_REVERSED_HI"
);
#undef X
printf
(
"
\n
"
);
}
/* hope we have the right size */
printf
(
"Optional Header (%s)
\n
"
,
get_magic_type
(
PE_nt_headers
->
OptionalHeader
.
Magic
));
switch
(
PE_nt_headers
->
OptionalHeader
.
Magic
)
{
case
IMAGE_NT_OPTIONAL_HDR32_MAGIC
:
dump_optional_header32
((
const
IMAGE_OPTIONAL_HEADER32
*
)
&
PE_nt_headers
->
OptionalHeader
);
break
;
case
IMAGE_NT_OPTIONAL_HDR64_MAGIC
:
dump_optional_header64
((
const
IMAGE_OPTIONAL_HEADER64
*
)
&
PE_nt_headers
->
OptionalHeader
);
break
;
default:
printf
(
" Unknown header magic: 0x%-4X
\n
"
,
PE_nt_headers
->
OptionalHeader
.
Magic
);
break
;
}
printf
(
"
\n
"
);
static
void
dump_pe_header
(
void
)
{
dump_file_header
(
&
PE_nt_headers
->
FileHeader
);
dump_optional_header
((
const
IMAGE_OPTIONAL_HEADER32
*
)
&
PE_nt_headers
->
OptionalHeader
,
PE_nt_headers
->
FileHeader
.
SizeOfOptionalHeader
);
}
static
void
dump_sections
(
const
void
*
addr
,
unsigned
num_sect
)
...
...
tools/winedump/winedump.h
View file @
7928f546
...
...
@@ -47,6 +47,11 @@
#include <assert.h>
#include <stdarg.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
/* Argument type constants */
#define MAX_FUNCTION_ARGS 32
...
...
@@ -230,6 +235,8 @@ void dump_data( const unsigned char *ptr, unsigned int size, const ch
const
char
*
get_time_str
(
unsigned
long
);
unsigned
int
strlenW
(
const
unsigned
short
*
str
);
void
dump_unicode_str
(
const
unsigned
short
*
str
,
int
len
);
void
dump_file_header
(
const
IMAGE_FILE_HEADER
*
);
void
dump_optional_header
(
const
IMAGE_OPTIONAL_HEADER32
*
,
UINT
);
enum
FileSig
get_kind_exec
(
void
);
void
pe_dump
(
void
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment