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
339953cc
Commit
339953cc
authored
Aug 31, 2021
by
Eric Pouech
Committed by
Alexandre Julliard
Aug 31, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dbghelp: Split storage of PE header.
Signed-off-by:
Eric Pouech
<
eric.pouech@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
25869075
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
25 deletions
+27
-25
image_private.h
dlls/dbghelp/image_private.h
+2
-1
pe_module.c
dlls/dbghelp/pe_module.c
+25
-24
No files found.
dlls/dbghelp/image_private.h
View file @
339953cc
...
...
@@ -150,7 +150,8 @@ struct image_file_map
struct
pe_file_map
{
HANDLE
hMap
;
IMAGE_NT_HEADERS
ntheader
;
IMAGE_FILE_HEADER
file_header
;
IMAGE_OPTIONAL_HEADER
opt_header
;
BOOL
builtin
;
unsigned
full_count
;
void
*
full_map
;
...
...
dlls/dbghelp/pe_module.c
View file @
339953cc
...
...
@@ -75,7 +75,7 @@ static const char* pe_map_section(struct image_section_map* ism)
void
*
mapping
;
struct
pe_file_map
*
fmap
=
&
ism
->
fmap
->
u
.
pe
;
if
(
ism
->
sidx
>=
0
&&
ism
->
sidx
<
fmap
->
ntheader
.
FileH
eader
.
NumberOfSections
&&
if
(
ism
->
sidx
>=
0
&&
ism
->
sidx
<
fmap
->
file_h
eader
.
NumberOfSections
&&
fmap
->
sect
[
ism
->
sidx
].
mapped
==
IMAGE_NO_MAP
)
{
IMAGE_NT_HEADERS
*
nth
;
...
...
@@ -115,7 +115,7 @@ static BOOL pe_find_section(struct image_file_map* fmap, const char* name,
unsigned
i
;
char
tmp
[
IMAGE_SIZEOF_SHORT_NAME
+
1
];
for
(
i
=
0
;
i
<
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
NumberOfSections
;
i
++
)
for
(
i
=
0
;
i
<
fmap
->
u
.
pe
.
file_h
eader
.
NumberOfSections
;
i
++
)
{
sectname
=
(
const
char
*
)
fmap
->
u
.
pe
.
sect
[
i
].
shdr
.
Name
;
/* long section names start with a '/' (at least on MinGW32) */
...
...
@@ -147,7 +147,7 @@ static BOOL pe_find_section(struct image_file_map* fmap, const char* name,
*/
static
void
pe_unmap_section
(
struct
image_section_map
*
ism
)
{
if
(
ism
->
sidx
>=
0
&&
ism
->
sidx
<
ism
->
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
NumberOfSections
&&
if
(
ism
->
sidx
>=
0
&&
ism
->
sidx
<
ism
->
fmap
->
u
.
pe
.
file_h
eader
.
NumberOfSections
&&
ism
->
fmap
->
u
.
pe
.
sect
[
ism
->
sidx
].
mapped
!=
IMAGE_NO_MAP
)
{
pe_unmap_full
(
ism
->
fmap
);
...
...
@@ -162,7 +162,7 @@ static void pe_unmap_section(struct image_section_map* ism)
*/
static
DWORD_PTR
pe_get_map_rva
(
const
struct
image_section_map
*
ism
)
{
if
(
ism
->
sidx
<
0
||
ism
->
sidx
>=
ism
->
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
NumberOfSections
)
if
(
ism
->
sidx
<
0
||
ism
->
sidx
>=
ism
->
fmap
->
u
.
pe
.
file_h
eader
.
NumberOfSections
)
return
0
;
return
ism
->
fmap
->
u
.
pe
.
sect
[
ism
->
sidx
].
shdr
.
VirtualAddress
;
}
...
...
@@ -174,7 +174,7 @@ static DWORD_PTR pe_get_map_rva(const struct image_section_map* ism)
*/
static
unsigned
pe_get_map_size
(
const
struct
image_section_map
*
ism
)
{
if
(
ism
->
sidx
<
0
||
ism
->
sidx
>=
ism
->
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
NumberOfSections
)
if
(
ism
->
sidx
<
0
||
ism
->
sidx
>=
ism
->
fmap
->
u
.
pe
.
file_h
eader
.
NumberOfSections
)
return
0
;
return
ism
->
fmap
->
u
.
pe
.
sect
[
ism
->
sidx
].
shdr
.
Misc
.
VirtualSize
;
}
...
...
@@ -190,7 +190,7 @@ static void pe_unmap_file(struct image_file_map* fmap)
{
struct
image_section_map
ism
;
ism
.
fmap
=
fmap
;
for
(
ism
.
sidx
=
0
;
ism
.
sidx
<
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
NumberOfSections
;
ism
.
sidx
++
)
for
(
ism
.
sidx
=
0
;
ism
.
sidx
<
fmap
->
u
.
pe
.
file_h
eader
.
NumberOfSections
;
ism
.
sidx
++
)
{
pe_unmap_section
(
&
ism
);
}
...
...
@@ -258,7 +258,8 @@ BOOL pe_map_file(HANDLE file, struct image_file_map* fmap, enum module_type mt)
unsigned
i
;
if
(
!
(
nthdr
=
RtlImageNtHeader
(
mapping
)))
goto
error
;
memcpy
(
&
fmap
->
u
.
pe
.
ntheader
,
nthdr
,
sizeof
(
fmap
->
u
.
pe
.
ntheader
));
memcpy
(
&
fmap
->
u
.
pe
.
file_header
,
&
nthdr
->
FileHeader
,
sizeof
(
fmap
->
u
.
pe
.
file_header
));
memcpy
(
&
fmap
->
u
.
pe
.
opt_header
,
&
nthdr
->
OptionalHeader
,
sizeof
(
fmap
->
u
.
pe
.
opt_header
));
switch
(
nthdr
->
OptionalHeader
.
Magic
)
{
case
0x10b
:
fmap
->
addr_size
=
32
;
break
;
...
...
@@ -298,8 +299,8 @@ BOOL pe_map_file(HANDLE file, struct image_file_map* fmap, enum module_type mt)
{
WARN
(
"Bad coff table... wipping out
\n
"
);
/* we have bad information here, wipe it out */
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
PointerToSymbolTable
=
0
;
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
NumberOfSymbols
=
0
;
fmap
->
u
.
pe
.
file_h
eader
.
PointerToSymbolTable
=
0
;
fmap
->
u
.
pe
.
file_h
eader
.
NumberOfSymbols
=
0
;
fmap
->
u
.
pe
.
strtable
=
NULL
;
}
}
...
...
@@ -362,16 +363,16 @@ static BOOL pe_locate_with_coff_symbol_table(struct module* module)
struct
symt_data
*
sym
;
const
char
*
mapping
;
numsym
=
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
NumberOfSymbols
;
if
(
!
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
PointerToSymbolTable
||
!
numsym
)
numsym
=
fmap
->
u
.
pe
.
file_h
eader
.
NumberOfSymbols
;
if
(
!
fmap
->
u
.
pe
.
file_h
eader
.
PointerToSymbolTable
||
!
numsym
)
return
TRUE
;
if
(
!
(
mapping
=
pe_map_full
(
fmap
,
NULL
)))
return
FALSE
;
isym
=
(
const
IMAGE_SYMBOL
*
)(
mapping
+
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
PointerToSymbolTable
);
isym
=
(
const
IMAGE_SYMBOL
*
)(
mapping
+
fmap
->
u
.
pe
.
file_h
eader
.
PointerToSymbolTable
);
for
(
i
=
0
;
i
<
numsym
;
i
+=
naux
,
isym
+=
naux
)
{
if
(
isym
->
StorageClass
==
IMAGE_SYM_CLASS_EXTERNAL
&&
isym
->
SectionNumber
>
0
&&
isym
->
SectionNumber
<=
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
NumberOfSections
)
isym
->
SectionNumber
>
0
&&
isym
->
SectionNumber
<=
fmap
->
u
.
pe
.
file_h
eader
.
NumberOfSections
)
{
if
(
isym
->
N
.
Name
.
Short
)
{
...
...
@@ -424,11 +425,11 @@ static BOOL pe_load_coff_symbol_table(struct module* module)
const
IMAGE_SECTION_HEADER
*
sect
;
const
char
*
mapping
;
numsym
=
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
NumberOfSymbols
;
if
(
!
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
PointerToSymbolTable
||
!
numsym
)
numsym
=
fmap
->
u
.
pe
.
file_h
eader
.
NumberOfSymbols
;
if
(
!
fmap
->
u
.
pe
.
file_h
eader
.
PointerToSymbolTable
||
!
numsym
)
return
TRUE
;
if
(
!
(
mapping
=
pe_map_full
(
fmap
,
NULL
)))
return
FALSE
;
isym
=
(
const
IMAGE_SYMBOL
*
)(
mapping
+
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
PointerToSymbolTable
);
isym
=
(
const
IMAGE_SYMBOL
*
)(
mapping
+
fmap
->
u
.
pe
.
file_h
eader
.
PointerToSymbolTable
);
/* FIXME: no way to get strtable size */
strtable
=
(
const
char
*
)
&
isym
[
numsym
];
sect
=
IMAGE_FIRST_SECTION
(
RtlImageNtHeader
((
HMODULE
)
mapping
));
...
...
@@ -441,7 +442,7 @@ static BOOL pe_load_coff_symbol_table(struct module* module)
compiland
=
NULL
;
}
if
(
isym
->
StorageClass
==
IMAGE_SYM_CLASS_EXTERNAL
&&
isym
->
SectionNumber
>
0
&&
isym
->
SectionNumber
<=
fmap
->
u
.
pe
.
ntheader
.
FileH
eader
.
NumberOfSections
)
isym
->
SectionNumber
>
0
&&
isym
->
SectionNumber
<=
fmap
->
u
.
pe
.
file_h
eader
.
NumberOfSections
)
{
if
(
isym
->
N
.
Name
.
Short
)
{
...
...
@@ -496,7 +497,7 @@ static BOOL pe_load_stabs(const struct process* pcs, struct module* module)
if
(
stab
!=
IMAGE_NO_MAP
&&
stabstr
!=
IMAGE_NO_MAP
)
{
ret
=
stabs_parse
(
module
,
module
->
module
.
BaseOfImage
-
fmap
->
u
.
pe
.
ntheader
.
OptionalH
eader
.
ImageBase
,
module
->
module
.
BaseOfImage
-
fmap
->
u
.
pe
.
opt_h
eader
.
ImageBase
,
stab
,
image_get_map_size
(
&
sect_stabs
)
/
sizeof
(
struct
stab_nlist
),
sizeof
(
struct
stab_nlist
),
stabstr
,
image_get_map_size
(
&
sect_stabstr
),
NULL
,
NULL
);
...
...
@@ -522,7 +523,7 @@ static BOOL pe_load_dwarf(struct module* module)
BOOL
ret
;
ret
=
dwarf2_parse
(
module
,
module
->
module
.
BaseOfImage
-
fmap
->
u
.
pe
.
ntheader
.
OptionalH
eader
.
ImageBase
,
module
->
module
.
BaseOfImage
-
fmap
->
u
.
pe
.
opt_h
eader
.
ImageBase
,
NULL
,
/* FIXME: some thunks to deal with ? */
fmap
);
TRACE
(
"%s the DWARF debug info
\n
"
,
ret
?
"successfully loaded"
:
"failed to load"
);
...
...
@@ -792,12 +793,12 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name,
image_unmap_file
(
&
modfmt
->
u
.
pe_info
->
fmap
);
modfmt
->
u
.
pe_info
->
fmap
=
builtin
.
fmap
;
}
if
(
!
base
)
base
=
modfmt
->
u
.
pe_info
->
fmap
.
u
.
pe
.
ntheader
.
OptionalH
eader
.
ImageBase
;
if
(
!
size
)
size
=
modfmt
->
u
.
pe_info
->
fmap
.
u
.
pe
.
ntheader
.
OptionalH
eader
.
SizeOfImage
;
if
(
!
base
)
base
=
modfmt
->
u
.
pe_info
->
fmap
.
u
.
pe
.
opt_h
eader
.
ImageBase
;
if
(
!
size
)
size
=
modfmt
->
u
.
pe_info
->
fmap
.
u
.
pe
.
opt_h
eader
.
SizeOfImage
;
module
=
module_new
(
pcs
,
loaded_name
,
DMT_PE
,
FALSE
,
base
,
size
,
modfmt
->
u
.
pe_info
->
fmap
.
u
.
pe
.
ntheader
.
FileH
eader
.
TimeDateStamp
,
modfmt
->
u
.
pe_info
->
fmap
.
u
.
pe
.
ntheader
.
OptionalH
eader
.
CheckSum
);
modfmt
->
u
.
pe_info
->
fmap
.
u
.
pe
.
file_h
eader
.
TimeDateStamp
,
modfmt
->
u
.
pe_info
->
fmap
.
u
.
pe
.
opt_h
eader
.
CheckSum
);
if
(
module
)
{
module
->
real_path
=
builtin
.
path
;
...
...
@@ -810,7 +811,7 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name,
module
->
module
.
SymType
=
SymDeferred
;
else
pe_load_debug_info
(
pcs
,
module
);
module
->
reloc_delta
=
base
-
modfmt
->
u
.
pe_info
->
fmap
.
u
.
pe
.
ntheader
.
OptionalH
eader
.
ImageBase
;
module
->
reloc_delta
=
base
-
modfmt
->
u
.
pe_info
->
fmap
.
u
.
pe
.
opt_h
eader
.
ImageBase
;
}
else
{
...
...
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