https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3d39743d1b7e116916995…
commit 3d39743d1b7e116916995db8a1d857f4eb068b70
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Fri Sep 11 17:05:17 2020 +0200
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Wed Sep 16 10:35:45 2020 +0200
[WINESYNC] dbghelp: Check checksum before mapping elf file.
Signed-off-by: Jacek Caban <jacek(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id c1d867fa872fafe1e6cc54ba6da63868fb7a4a6f by Jacek Caban
<jacek(a)codeweavers.com>
---
dll/win32/dbghelp/elf_module.c | 40 +++++++++++++++++++++++++++++-----------
sdk/tools/winesync/dbghelp.cfg | 2 +-
2 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c
index 6bfd58b917a..1ad37a24ed1 100644
--- a/dll/win32/dbghelp/elf_module.c
+++ b/dll/win32/dbghelp/elf_module.c
@@ -326,7 +326,7 @@ static inline void elf_reset_file_map(struct image_file_map* fmap)
struct elf_map_file_data
{
- enum {from_file, from_process} kind;
+ enum {from_file, from_process, from_handle} kind;
union
{
struct
@@ -338,6 +338,7 @@ struct elf_map_file_data
HANDLE handle;
void* load_addr;
} process;
+ HANDLE handle;
} u;
};
@@ -351,6 +352,7 @@ static BOOL elf_map_file_read(struct image_file_map* fmap, struct
elf_map_file_d
switch (emfd->kind)
{
case from_file:
+ case from_handle:
li.QuadPart = off;
if (!SetFilePointerEx(fmap->u.elf.handle, li, NULL, FILE_BEGIN)) return
FALSE;
return ReadFile(fmap->u.elf.handle, buf, len, &bytes_read, NULL);
@@ -444,6 +446,10 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct
image_file_map*
heap_free(dos_path);
if (fmap->u.elf.handle == INVALID_HANDLE_VALUE) return FALSE;
break;
+ case from_handle:
+ if (!DuplicateHandle(GetCurrentProcess(), emfd->u.handle, GetCurrentProcess(),
&fmap->u.elf.handle, GENERIC_READ, FALSE, 0))
+ return FALSE;
+ break;
case from_process:
break;
}
@@ -539,6 +545,7 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct
image_file_map*
switch (emfd->kind)
{
+ case from_handle:
case from_file: break;
case from_process:
if (!(fmap->u.elf.target_copy = HeapAlloc(GetProcessHeap(), 0,
fmap->u.elf.elf_size)))
@@ -558,6 +565,14 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct
image_file_map*
return TRUE;
}
+static BOOL elf_map_handle(HANDLE handle, struct image_file_map* fmap)
+{
+ struct elf_map_file_data emfd;
+ emfd.kind = from_handle;
+ emfd.u.handle = handle;
+ return elf_map_file(&emfd, fmap);
+}
+
static void elf_module_remove(struct process* pcs, struct module_format* modfmt)
{
image_unmap_file(&modfmt->u.elf_info->file_map);
@@ -968,21 +983,24 @@ static int elf_new_public_symbols(struct module* module, const
struct hash_table
static BOOL elf_check_debug_link(const WCHAR* file, struct image_file_map* fmap, DWORD
link_crc)
{
- struct elf_map_file_data emfd;
+ HANDLE handle;
+ WCHAR *path;
DWORD crc;
+ BOOL ret = FALSE;
- emfd.kind = from_file;
- emfd.u.file.filename = file;
- if (!elf_map_file(&emfd, fmap)) return FALSE;
+ path = get_dos_file_name(file);
+ handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0,
NULL);
+ heap_free(path);
+ if (handle == INVALID_HANDLE_VALUE) return FALSE;
- crc = calc_crc32(fmap->u.elf.handle);
+ crc = calc_crc32(handle);
if (crc != link_crc)
- {
WARN("Bad CRC for file %s (got %08x while expecting %08x)\n",
debugstr_w(file), crc, link_crc);
- image_unmap_file(fmap);
- return FALSE;
- }
- return TRUE;
+ else
+ ret = elf_map_handle(handle, fmap);
+
+ CloseHandle(handle);
+ return ret;
}
/******************************************************************
diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg
index c5ab997e646..15bcb22091d 100644
--- a/sdk/tools/winesync/dbghelp.cfg
+++ b/sdk/tools/winesync/dbghelp.cfg
@@ -4,4 +4,4 @@ files:
include/dbghelp.h: sdk/include/psdk/dbghelp.h
include/wine/mscvpdb.h: sdk/include/reactos/wine/mscvpdb.h
tags:
- wine: 5ba1c5960e716bdec9052efeb9f3ddfba3cf9e0c
+ wine: c1d867fa872fafe1e6cc54ba6da63868fb7a4a6f