Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
97d2e9d9
Commit
97d2e9d9
authored
Feb 01, 2023
by
Eric Pouech
Committed by
Alexandre Julliard
Feb 02, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winedump: Introduce a helper to print PE section's characteristics.
Signed-off-by:
Eric Pouech
<
eric.pouech@gmail.com
>
parent
edc479ee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
65 deletions
+72
-65
pe.c
tools/winedump/pe.c
+71
-65
winedump.h
tools/winedump/winedump.h
+1
-0
No files found.
tools/winedump/pe.c
View file @
97d2e9d9
...
...
@@ -381,27 +381,9 @@ static void dump_pe_header(void)
dump_optional_header
((
const
IMAGE_OPTIONAL_HEADER32
*
)
&
PE_nt_headers
->
OptionalHeader
,
PE_nt_headers
->
FileHeader
.
SizeOfOptionalHeader
);
}
void
dump_section
(
const
IMAGE_SECTION_HEADER
*
sectHead
,
const
char
*
strtable
)
void
dump_section
_characteristics
(
DWORD
characteristics
,
const
char
*
sep
)
{
unsigned
offset
;
/* long section name ? */
if
(
strtable
&&
sectHead
->
Name
[
0
]
==
'/'
&&
((
offset
=
atoi
((
const
char
*
)
sectHead
->
Name
+
1
))
<
*
(
const
DWORD
*
)
strtable
))
printf
(
" %.8s (%s)"
,
sectHead
->
Name
,
strtable
+
offset
);
else
printf
(
" %-8.8s"
,
sectHead
->
Name
);
printf
(
" VirtSize: 0x%08x VirtAddr: 0x%08x
\n
"
,
(
UINT
)
sectHead
->
Misc
.
VirtualSize
,
(
UINT
)
sectHead
->
VirtualAddress
);
printf
(
" raw data offs: 0x%08x raw data size: 0x%08x
\n
"
,
(
UINT
)
sectHead
->
PointerToRawData
,
(
UINT
)
sectHead
->
SizeOfRawData
);
printf
(
" relocation offs: 0x%08x relocations: 0x%08x
\n
"
,
(
UINT
)
sectHead
->
PointerToRelocations
,
(
UINT
)
sectHead
->
NumberOfRelocations
);
printf
(
" line # offs: %-8u line #'s: %-8u
\n
"
,
(
UINT
)
sectHead
->
PointerToLinenumbers
,
(
UINT
)
sectHead
->
NumberOfLinenumbers
);
printf
(
" characteristics: 0x%08x
\n
"
,
(
UINT
)
sectHead
->
Characteristics
);
printf
(
" "
);
#define X(b,s) if (sectHead->Characteristics & b) printf(" " s)
#define X(b,s) if (characteristics & b) printf("%s%s", sep, s)
/* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
/* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
/* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
...
...
@@ -409,57 +391,81 @@ void dump_section(const IMAGE_SECTION_HEADER *sectHead, const char* strtable)
/* #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 - Reserved */
/* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
X
(
IMAGE_SCN_CNT_CODE
,
"CODE"
);
X
(
IMAGE_SCN_CNT_INITIALIZED_DATA
,
"INITIALIZED_DATA"
);
X
(
IMAGE_SCN_CNT_UNINITIALIZED_DATA
,
"UNINITIALIZED_DATA"
);
X
(
IMAGE_SCN_CNT_CODE
,
"CODE"
);
X
(
IMAGE_SCN_CNT_INITIALIZED_DATA
,
"INITIALIZED_DATA"
);
X
(
IMAGE_SCN_CNT_UNINITIALIZED_DATA
,
"UNINITIALIZED_DATA"
);
X
(
IMAGE_SCN_LNK_OTHER
,
"LNK_OTHER"
);
X
(
IMAGE_SCN_LNK_INFO
,
"LNK_INFO"
);
X
(
IMAGE_SCN_LNK_OTHER
,
"LNK_OTHER"
);
X
(
IMAGE_SCN_LNK_INFO
,
"LNK_INFO"
);
/* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
X
(
IMAGE_SCN_LNK_REMOVE
,
"LNK_REMOVE"
);
X
(
IMAGE_SCN_LNK_COMDAT
,
"LNK_COMDAT"
);
/*
0x00002000 - Reserved */
/* #define IMAGE_SCN_MEM_PROTECTED
0x00004000 - Obsolete */
X
(
IMAGE_SCN_MEM_FARDATA
,
"MEM_FARDATA"
);
/* #define IMAGE_SCN_MEM_SYSHEAP
0x00010000 - Obsolete */
X
(
IMAGE_SCN_MEM_PURGEABLE
,
"MEM_PURGEABLE"
);
X
(
IMAGE_SCN_MEM_16BIT
,
"MEM_16BIT"
);
X
(
IMAGE_SCN_MEM_LOCKED
,
"MEM_LOCKED"
);
X
(
IMAGE_SCN_MEM_PRELOAD
,
"MEM_PRELOAD"
);
switch
(
sectHead
->
C
haracteristics
&
IMAGE_SCN_ALIGN_MASK
)
{
#define X2(b,s) case b: printf("
"
s); break
X2
(
IMAGE_SCN_ALIGN_1BYTES
,
"ALIGN_1BYTES"
);
X2
(
IMAGE_SCN_ALIGN_2BYTES
,
"ALIGN_2BYTES"
);
X2
(
IMAGE_SCN_ALIGN_4BYTES
,
"ALIGN_4BYTES"
);
X2
(
IMAGE_SCN_ALIGN_8BYTES
,
"ALIGN_8BYTES"
);
X2
(
IMAGE_SCN_ALIGN_16BYTES
,
"ALIGN_16BYTES"
);
X2
(
IMAGE_SCN_ALIGN_32BYTES
,
"ALIGN_32BYTES"
);
X2
(
IMAGE_SCN_ALIGN_64BYTES
,
"ALIGN_64BYTES"
);
X2
(
IMAGE_SCN_ALIGN_128BYTES
,
"ALIGN_128BYTES"
);
X2
(
IMAGE_SCN_ALIGN_256BYTES
,
"ALIGN_256BYTES"
);
X2
(
IMAGE_SCN_ALIGN_512BYTES
,
"ALIGN_512BYTES"
);
X2
(
IMAGE_SCN_ALIGN_1024BYTES
,
"ALIGN_1024BYTES"
);
X2
(
IMAGE_SCN_ALIGN_2048BYTES
,
"ALIGN_2048BYTES"
);
X2
(
IMAGE_SCN_ALIGN_4096BYTES
,
"ALIGN_4096BYTES"
);
X2
(
IMAGE_SCN_ALIGN_8192BYTES
,
"ALIGN_8192BYTES"
);
X
(
IMAGE_SCN_LNK_REMOVE
,
"LNK_REMOVE"
);
X
(
IMAGE_SCN_LNK_COMDAT
,
"LNK_COMDAT"
);
/* 0x00002000 - Reserved */
/* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
X
(
IMAGE_SCN_MEM_FARDATA
,
"MEM_FARDATA"
);
/* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
X
(
IMAGE_SCN_MEM_PURGEABLE
,
"MEM_PURGEABLE"
);
X
(
IMAGE_SCN_MEM_16BIT
,
"MEM_16BIT"
);
X
(
IMAGE_SCN_MEM_LOCKED
,
"MEM_LOCKED"
);
X
(
IMAGE_SCN_MEM_PRELOAD
,
"MEM_PRELOAD"
);
switch
(
c
haracteristics
&
IMAGE_SCN_ALIGN_MASK
)
{
#define X2(b,s) case b: printf("
%s%s", sep,
s); break
X2
(
IMAGE_SCN_ALIGN_1BYTES
,
"ALIGN_1BYTES"
);
X2
(
IMAGE_SCN_ALIGN_2BYTES
,
"ALIGN_2BYTES"
);
X2
(
IMAGE_SCN_ALIGN_4BYTES
,
"ALIGN_4BYTES"
);
X2
(
IMAGE_SCN_ALIGN_8BYTES
,
"ALIGN_8BYTES"
);
X2
(
IMAGE_SCN_ALIGN_16BYTES
,
"ALIGN_16BYTES"
);
X2
(
IMAGE_SCN_ALIGN_32BYTES
,
"ALIGN_32BYTES"
);
X2
(
IMAGE_SCN_ALIGN_64BYTES
,
"ALIGN_64BYTES"
);
X2
(
IMAGE_SCN_ALIGN_128BYTES
,
"ALIGN_128BYTES"
);
X2
(
IMAGE_SCN_ALIGN_256BYTES
,
"ALIGN_256BYTES"
);
X2
(
IMAGE_SCN_ALIGN_512BYTES
,
"ALIGN_512BYTES"
);
X2
(
IMAGE_SCN_ALIGN_1024BYTES
,
"ALIGN_1024BYTES"
);
X2
(
IMAGE_SCN_ALIGN_2048BYTES
,
"ALIGN_2048BYTES"
);
X2
(
IMAGE_SCN_ALIGN_4096BYTES
,
"ALIGN_4096BYTES"
);
X2
(
IMAGE_SCN_ALIGN_8192BYTES
,
"ALIGN_8192BYTES"
);
#undef X2
}
}
X
(
IMAGE_SCN_LNK_NRELOC_OVFL
,
"LNK_NRELOC_OVFL"
);
X
(
IMAGE_SCN_LNK_NRELOC_OVFL
,
"LNK_NRELOC_OVFL"
);
X
(
IMAGE_SCN_MEM_DISCARDABLE
,
"MEM_DISCARDABLE"
);
X
(
IMAGE_SCN_MEM_NOT_CACHED
,
"MEM_NOT_CACHED"
);
X
(
IMAGE_SCN_MEM_NOT_PAGED
,
"MEM_NOT_PAGED"
);
X
(
IMAGE_SCN_MEM_SHARED
,
"MEM_SHARED"
);
X
(
IMAGE_SCN_MEM_EXECUTE
,
"MEM_EXECUTE"
);
X
(
IMAGE_SCN_MEM_READ
,
"MEM_READ"
);
X
(
IMAGE_SCN_MEM_WRITE
,
"MEM_WRITE"
);
X
(
IMAGE_SCN_MEM_DISCARDABLE
,
"MEM_DISCARDABLE"
);
X
(
IMAGE_SCN_MEM_NOT_CACHED
,
"MEM_NOT_CACHED"
);
X
(
IMAGE_SCN_MEM_NOT_PAGED
,
"MEM_NOT_PAGED"
);
X
(
IMAGE_SCN_MEM_SHARED
,
"MEM_SHARED"
);
X
(
IMAGE_SCN_MEM_EXECUTE
,
"MEM_EXECUTE"
);
X
(
IMAGE_SCN_MEM_READ
,
"MEM_READ"
);
X
(
IMAGE_SCN_MEM_WRITE
,
"MEM_WRITE"
);
#undef X
printf
(
"
\n\n
"
);
}
void
dump_section
(
const
IMAGE_SECTION_HEADER
*
sectHead
,
const
char
*
strtable
)
{
unsigned
offset
;
/* long section name ? */
if
(
strtable
&&
sectHead
->
Name
[
0
]
==
'/'
&&
((
offset
=
atoi
((
const
char
*
)
sectHead
->
Name
+
1
))
<
*
(
const
DWORD
*
)
strtable
))
printf
(
" %.8s (%s)"
,
sectHead
->
Name
,
strtable
+
offset
);
else
printf
(
" %-8.8s"
,
sectHead
->
Name
);
printf
(
" VirtSize: 0x%08x VirtAddr: 0x%08x
\n
"
,
(
UINT
)
sectHead
->
Misc
.
VirtualSize
,
(
UINT
)
sectHead
->
VirtualAddress
);
printf
(
" raw data offs: 0x%08x raw data size: 0x%08x
\n
"
,
(
UINT
)
sectHead
->
PointerToRawData
,
(
UINT
)
sectHead
->
SizeOfRawData
);
printf
(
" relocation offs: 0x%08x relocations: 0x%08x
\n
"
,
(
UINT
)
sectHead
->
PointerToRelocations
,
(
UINT
)
sectHead
->
NumberOfRelocations
);
printf
(
" line # offs: %-8u line #'s: %-8u
\n
"
,
(
UINT
)
sectHead
->
PointerToLinenumbers
,
(
UINT
)
sectHead
->
NumberOfLinenumbers
);
printf
(
" characteristics: 0x%08x
\n
"
,
(
UINT
)
sectHead
->
Characteristics
);
printf
(
" "
);
dump_section_characteristics
(
sectHead
->
Characteristics
,
" "
);
printf
(
"
\n\n
"
);
}
static
void
dump_sections
(
const
void
*
base
,
const
void
*
addr
,
unsigned
num_sect
)
...
...
tools/winedump/winedump.h
View file @
97d2e9d9
...
...
@@ -233,6 +233,7 @@ void print_fake_dll(void);
void
dump_file_header
(
const
IMAGE_FILE_HEADER
*
);
void
dump_optional_header
(
const
IMAGE_OPTIONAL_HEADER32
*
,
UINT
);
void
dump_section
(
const
IMAGE_SECTION_HEADER
*
,
const
char
*
strtable
);
void
dump_section_characteristics
(
DWORD
characteristics
,
const
char
*
sep
);
enum
FileSig
get_kind_exec
(
void
);
void
dos_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