mirror of
https://github.com/reactos/reactos.git
synced 2024-10-04 16:36:11 +00:00
[WINESYNC] dbghelp: Check checksum before mapping elf file.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> wine commit id c1d867fa872fafe1e6cc54ba6da63868fb7a4a6f by Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
parent
9743bd26bd
commit
3d39743d1b
|
@ -326,7 +326,7 @@ static inline void elf_reset_file_map(struct image_file_map* fmap)
|
||||||
|
|
||||||
struct elf_map_file_data
|
struct elf_map_file_data
|
||||||
{
|
{
|
||||||
enum {from_file, from_process} kind;
|
enum {from_file, from_process, from_handle} kind;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
|
@ -338,6 +338,7 @@ struct elf_map_file_data
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
void* load_addr;
|
void* load_addr;
|
||||||
} process;
|
} process;
|
||||||
|
HANDLE handle;
|
||||||
} u;
|
} u;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -351,6 +352,7 @@ static BOOL elf_map_file_read(struct image_file_map* fmap, struct elf_map_file_d
|
||||||
switch (emfd->kind)
|
switch (emfd->kind)
|
||||||
{
|
{
|
||||||
case from_file:
|
case from_file:
|
||||||
|
case from_handle:
|
||||||
li.QuadPart = off;
|
li.QuadPart = off;
|
||||||
if (!SetFilePointerEx(fmap->u.elf.handle, li, NULL, FILE_BEGIN)) return FALSE;
|
if (!SetFilePointerEx(fmap->u.elf.handle, li, NULL, FILE_BEGIN)) return FALSE;
|
||||||
return ReadFile(fmap->u.elf.handle, buf, len, &bytes_read, NULL);
|
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);
|
heap_free(dos_path);
|
||||||
if (fmap->u.elf.handle == INVALID_HANDLE_VALUE) return FALSE;
|
if (fmap->u.elf.handle == INVALID_HANDLE_VALUE) return FALSE;
|
||||||
break;
|
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:
|
case from_process:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -539,6 +545,7 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map*
|
||||||
|
|
||||||
switch (emfd->kind)
|
switch (emfd->kind)
|
||||||
{
|
{
|
||||||
|
case from_handle:
|
||||||
case from_file: break;
|
case from_file: break;
|
||||||
case from_process:
|
case from_process:
|
||||||
if (!(fmap->u.elf.target_copy = HeapAlloc(GetProcessHeap(), 0, fmap->u.elf.elf_size)))
|
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;
|
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)
|
static void elf_module_remove(struct process* pcs, struct module_format* modfmt)
|
||||||
{
|
{
|
||||||
image_unmap_file(&modfmt->u.elf_info->file_map);
|
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)
|
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;
|
DWORD crc;
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
emfd.kind = from_file;
|
path = get_dos_file_name(file);
|
||||||
emfd.u.file.filename = file;
|
handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||||
if (!elf_map_file(&emfd, fmap)) return FALSE;
|
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)
|
if (crc != link_crc)
|
||||||
{
|
|
||||||
WARN("Bad CRC for file %s (got %08x while expecting %08x)\n", debugstr_w(file), 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);
|
else
|
||||||
return FALSE;
|
ret = elf_map_handle(handle, fmap);
|
||||||
}
|
|
||||||
return TRUE;
|
CloseHandle(handle);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
|
|
|
@ -4,4 +4,4 @@ files:
|
||||||
include/dbghelp.h: sdk/include/psdk/dbghelp.h
|
include/dbghelp.h: sdk/include/psdk/dbghelp.h
|
||||||
include/wine/mscvpdb.h: sdk/include/reactos/wine/mscvpdb.h
|
include/wine/mscvpdb.h: sdk/include/reactos/wine/mscvpdb.h
|
||||||
tags:
|
tags:
|
||||||
wine: 5ba1c5960e716bdec9052efeb9f3ddfba3cf9e0c
|
wine: c1d867fa872fafe1e6cc54ba6da63868fb7a4a6f
|
||||||
|
|
Loading…
Reference in a new issue