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
1d96af36
Commit
1d96af36
authored
Mar 16, 2020
by
Jacek Caban
Committed by
Alexandre Julliard
Mar 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dbghelp: Introduce generic image_unmap_file.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
95a5f829
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
56 deletions
+65
-56
elf_module.c
dlls/dbghelp/elf_module.c
+27
-30
image_private.h
dlls/dbghelp/image_private.h
+10
-0
macho_module.c
dlls/dbghelp/macho_module.c
+1
-0
pe_module.c
dlls/dbghelp/pe_module.c
+27
-26
No files found.
dlls/dbghelp/elf_module.c
View file @
1d96af36
...
...
@@ -284,6 +284,27 @@ static unsigned elf_get_map_size(const struct image_section_map* ism)
return
ism
->
fmap
->
u
.
elf
.
sect
[
ism
->
sidx
].
shdr
.
sh_size
;
}
/******************************************************************
* elf_unmap_file
*
* Unmaps an ELF file from memory (previously mapped with elf_map_file)
*/
static
void
elf_unmap_file
(
struct
image_file_map
*
fmap
)
{
if
(
fmap
->
u
.
elf
.
handle
!=
INVALID_HANDLE_VALUE
)
{
struct
image_section_map
ism
;
ism
.
fmap
=
fmap
;
for
(
ism
.
sidx
=
0
;
ism
.
sidx
<
fmap
->
u
.
elf
.
elfhdr
.
e_shnum
;
ism
.
sidx
++
)
{
elf_unmap_section
(
&
ism
);
}
HeapFree
(
GetProcessHeap
(),
0
,
fmap
->
u
.
elf
.
sect
);
CloseHandle
(
fmap
->
u
.
elf
.
handle
);
}
HeapFree
(
GetProcessHeap
(),
0
,
fmap
->
u
.
elf
.
target_copy
);
}
static
const
struct
image_file_map_ops
elf_file_map_ops
=
{
elf_map_section
,
...
...
@@ -291,6 +312,7 @@ static const struct image_file_map_ops elf_file_map_ops =
elf_find_section
,
elf_get_map_rva
,
elf_get_map_size
,
elf_unmap_file
,
};
static
inline
void
elf_reset_file_map
(
struct
image_file_map
*
fmap
)
...
...
@@ -536,34 +558,9 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map*
return
TRUE
;
}
/******************************************************************
* elf_unmap_file
*
* Unmaps an ELF file from memory (previously mapped with elf_map_file)
*/
static
void
elf_unmap_file
(
struct
image_file_map
*
fmap
)
{
while
(
fmap
&&
fmap
->
modtype
==
DMT_ELF
)
{
if
(
fmap
->
u
.
elf
.
handle
!=
INVALID_HANDLE_VALUE
)
{
struct
image_section_map
ism
;
ism
.
fmap
=
fmap
;
for
(
ism
.
sidx
=
0
;
ism
.
sidx
<
fmap
->
u
.
elf
.
elfhdr
.
e_shnum
;
ism
.
sidx
++
)
{
elf_unmap_section
(
&
ism
);
}
HeapFree
(
GetProcessHeap
(),
0
,
fmap
->
u
.
elf
.
sect
);
CloseHandle
(
fmap
->
u
.
elf
.
handle
);
}
HeapFree
(
GetProcessHeap
(),
0
,
fmap
->
u
.
elf
.
target_copy
);
fmap
=
fmap
->
alternate
;
}
}
static
void
elf_module_remove
(
struct
process
*
pcs
,
struct
module_format
*
modfmt
)
{
elf
_unmap_file
(
&
modfmt
->
u
.
elf_info
->
file_map
);
image
_unmap_file
(
&
modfmt
->
u
.
elf_info
->
file_map
);
HeapFree
(
GetProcessHeap
(),
0
,
modfmt
);
}
...
...
@@ -994,7 +991,7 @@ static BOOL elf_check_debug_link(const WCHAR* file, struct image_file_map* fmap,
if
(
crc
!=
link_crc
)
{
WARN
(
"Bad CRC for file %s (got %08x while expecting %08x)
\n
"
,
debugstr_w
(
file
),
crc
,
link_crc
);
elf
_unmap_file
(
fmap
);
image
_unmap_file
(
fmap
);
return
FALSE
;
}
return
TRUE
;
...
...
@@ -1148,7 +1145,7 @@ static BOOL elf_locate_build_id_target(struct image_file_map* fmap, const BYTE*
}
image_unmap_section
(
&
buildid_sect
);
}
elf
_unmap_file
(
fmap_link
);
image
_unmap_file
(
fmap_link
);
}
TRACE
(
"not found
\n
"
);
...
...
@@ -1340,7 +1337,7 @@ BOOL elf_fetch_file_info(const WCHAR* name, DWORD_PTR* base,
if
(
base
)
*
base
=
fmap
.
u
.
elf
.
elf_start
;
*
size
=
fmap
.
u
.
elf
.
elf_size
;
*
checksum
=
calc_crc
(
fmap
.
u
.
elf
.
handle
);
elf
_unmap_file
(
&
fmap
);
image
_unmap_file
(
&
fmap
);
return
TRUE
;
}
...
...
@@ -1514,7 +1511,7 @@ static BOOL elf_load_file(struct process* pcs, const WCHAR* filename,
ret
=
elf_load_file_from_fmap
(
pcs
,
filename
,
&
fmap
,
load_offset
,
dyn_addr
,
elf_info
);
elf
_unmap_file
(
&
fmap
);
image
_unmap_file
(
&
fmap
);
return
ret
;
}
...
...
dlls/dbghelp/image_private.h
View file @
1d96af36
...
...
@@ -137,6 +137,7 @@ struct image_file_map_ops
BOOL
(
*
find_section
)(
struct
image_file_map
*
fmap
,
const
char
*
name
,
struct
image_section_map
*
ism
);
DWORD_PTR
(
*
get_map_rva
)(
const
struct
image_section_map
*
ism
);
unsigned
(
*
get_map_size
)(
const
struct
image_section_map
*
ism
);
void
(
*
unmap_file
)(
struct
image_file_map
*
fmap
);
};
static
inline
BOOL
image_find_section
(
struct
image_file_map
*
fmap
,
const
char
*
name
,
...
...
@@ -152,6 +153,15 @@ static inline BOOL image_find_section(struct image_file_map* fmap, const char* n
return
FALSE
;
}
static
inline
void
image_unmap_file
(
struct
image_file_map
*
fmap
)
{
while
(
fmap
)
{
fmap
->
ops
->
unmap_file
(
fmap
);
fmap
=
fmap
->
alternate
;
}
}
static
inline
const
char
*
image_map_section
(
struct
image_section_map
*
ism
)
{
return
ism
->
fmap
?
ism
->
fmap
->
ops
->
map_section
(
ism
)
:
NULL
;
...
...
dlls/dbghelp/macho_module.c
View file @
1d96af36
...
...
@@ -432,6 +432,7 @@ static const struct image_file_map_ops macho_file_map_ops =
macho_find_section
,
macho_get_map_rva
,
macho_get_map_size
,
macho_unmap_file
,
};
/******************************************************************
...
...
dlls/dbghelp/pe_module.c
View file @
1d96af36
...
...
@@ -182,6 +182,29 @@ static unsigned pe_get_map_size(const struct image_section_map* ism)
return
ism
->
fmap
->
u
.
pe
.
sect
[
ism
->
sidx
].
shdr
.
Misc
.
VirtualSize
;
}
/******************************************************************
* pe_unmap_file
*
* Unmaps an PE file from memory (previously mapped with pe_map_file)
*/
static
void
pe_unmap_file
(
struct
image_file_map
*
fmap
)
{
if
(
fmap
->
u
.
pe
.
hMap
!=
0
)
{
struct
image_section_map
ism
;
ism
.
fmap
=
fmap
;
for
(
ism
.
sidx
=
0
;
ism
.
sidx
<
fmap
->
u
.
pe
.
ntheader
.
FileHeader
.
NumberOfSections
;
ism
.
sidx
++
)
{
pe_unmap_section
(
&
ism
);
}
while
(
fmap
->
u
.
pe
.
full_count
)
pe_unmap_full
(
fmap
);
HeapFree
(
GetProcessHeap
(),
0
,
fmap
->
u
.
pe
.
sect
);
HeapFree
(
GetProcessHeap
(),
0
,
(
void
*
)
fmap
->
u
.
pe
.
strtable
);
/* FIXME ugly (see pe_map_file) */
CloseHandle
(
fmap
->
u
.
pe
.
hMap
);
fmap
->
u
.
pe
.
hMap
=
NULL
;
}
}
static
const
struct
image_file_map_ops
pe_file_map_ops
=
{
pe_map_section
,
...
...
@@ -189,6 +212,7 @@ static const struct image_file_map_ops pe_file_map_ops =
pe_find_section
,
pe_get_map_rva
,
pe_get_map_size
,
pe_unmap_file
,
};
/******************************************************************
...
...
@@ -297,29 +321,6 @@ error:
}
/******************************************************************
* pe_unmap_file
*
* Unmaps an PE file from memory (previously mapped with pe_map_file)
*/
static
void
pe_unmap_file
(
struct
image_file_map
*
fmap
)
{
if
(
fmap
->
u
.
pe
.
hMap
!=
0
)
{
struct
image_section_map
ism
;
ism
.
fmap
=
fmap
;
for
(
ism
.
sidx
=
0
;
ism
.
sidx
<
fmap
->
u
.
pe
.
ntheader
.
FileHeader
.
NumberOfSections
;
ism
.
sidx
++
)
{
pe_unmap_section
(
&
ism
);
}
while
(
fmap
->
u
.
pe
.
full_count
)
pe_unmap_full
(
fmap
);
HeapFree
(
GetProcessHeap
(),
0
,
fmap
->
u
.
pe
.
sect
);
HeapFree
(
GetProcessHeap
(),
0
,
(
void
*
)
fmap
->
u
.
pe
.
strtable
);
/* FIXME ugly (see pe_map_file) */
CloseHandle
(
fmap
->
u
.
pe
.
hMap
);
fmap
->
u
.
pe
.
hMap
=
NULL
;
}
}
/******************************************************************
* pe_map_directory
*
* Maps a directory content out of a PE file
...
...
@@ -340,7 +341,7 @@ const char* pe_map_directory(struct module* module, int dirno, DWORD* size)
static
void
pe_module_remove
(
struct
process
*
pcs
,
struct
module_format
*
modfmt
)
{
p
e_unmap_file
(
&
modfmt
->
u
.
pe_info
->
fmap
);
imag
e_unmap_file
(
&
modfmt
->
u
.
pe_info
->
fmap
);
HeapFree
(
GetProcessHeap
(),
0
,
modfmt
);
}
...
...
@@ -839,7 +840,7 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name,
if
(
pe_map_file
(
builtin_module
,
&
builtin_fmap
,
DMT_PE
))
{
TRACE
(
"reloaded %s from %s
\n
"
,
debugstr_w
(
loaded_name
),
debugstr_w
(
builtin_path
));
p
e_unmap_file
(
&
modfmt
->
u
.
pe_info
->
fmap
);
imag
e_unmap_file
(
&
modfmt
->
u
.
pe_info
->
fmap
);
modfmt
->
u
.
pe_info
->
fmap
=
builtin_fmap
;
}
CloseHandle
(
builtin_module
);
...
...
@@ -868,7 +869,7 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name,
{
ERR
(
"could not load the module '%s'
\n
"
,
debugstr_w
(
loaded_name
));
heap_free
(
module
->
real_path
);
p
e_unmap_file
(
&
modfmt
->
u
.
pe_info
->
fmap
);
imag
e_unmap_file
(
&
modfmt
->
u
.
pe_info
->
fmap
);
}
}
if
(
!
module
)
HeapFree
(
GetProcessHeap
(),
0
,
modfmt
);
...
...
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