https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9a74d137ed7d57498a1f7…
commit 9a74d137ed7d57498a1f7aff02af099e6293cabe
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Fri Sep 11 17:05:16 2020 +0200
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Wed Sep 16 10:35:45 2020 +0200
[WINESYNC] dbghelp: Move HANDLE-based crc32 helper to dbghelp.c.
Signed-off-by: Jacek Caban <jacek(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id a5a6b0dcb65d8e3576e34d350c80f4789dcfdb7a by Jacek Caban
<jacek(a)codeweavers.com>
---
dll/win32/dbghelp/dbghelp.c | 8 ++++----
dll/win32/dbghelp/dbghelp_private.h | 2 +-
dll/win32/dbghelp/elf_module.c | 18 +++---------------
dll/win32/dbghelp/macho_module.c | 16 ++++++++++++++--
sdk/tools/winesync/dbghelp.cfg | 2 +-
5 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/dll/win32/dbghelp/dbghelp.c b/dll/win32/dbghelp/dbghelp.c
index 40bcb3dd229..bb69d671961 100644
--- a/dll/win32/dbghelp/dbghelp.c
+++ b/dll/win32/dbghelp/dbghelp.c
@@ -740,14 +740,14 @@ void WINAPI WinDbgExtensionDllInit(PWINDBG_EXTENSION_APIS
lpExtensionApis,
}
#ifndef DBGHELP_STATIC_LIB
-DWORD calc_crc32(int fd)
+DWORD calc_crc32(HANDLE handle)
{
BYTE buffer[8192];
DWORD crc = 0;
- int len;
+ DWORD len;
- lseek(fd, 0, SEEK_SET);
- while ((len = read(fd, buffer, sizeof(buffer))) > 0)
+ SetFilePointer(handle, 0, 0, FILE_BEGIN);
+ while (ReadFile(handle, buffer, sizeof(buffer), &len, NULL) && len)
crc = RtlComputeCrc32(crc, buffer, len);
return crc;
}
diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h
index d9cddae5f02..3288167ae0a 100644
--- a/dll/win32/dbghelp/dbghelp_private.h
+++ b/dll/win32/dbghelp/dbghelp_private.h
@@ -617,7 +617,7 @@ extern BOOL pcs_callback(const struct process* pcs, ULONG
action, void*
extern void* fetch_buffer(struct process* pcs, unsigned size) DECLSPEC_HIDDEN;
extern const char* wine_dbgstr_addr(const ADDRESS64* addr) DECLSPEC_HIDDEN;
extern struct cpu* cpu_find(DWORD) DECLSPEC_HIDDEN;
-extern DWORD calc_crc32(int fd) DECLSPEC_HIDDEN;
+extern DWORD calc_crc32(HANDLE handle) DECLSPEC_HIDDEN;
typedef BOOL (*enum_modules_cb)(const WCHAR*, unsigned long addr, void* user);
diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c
index 961fece7462..e0ae195cd89 100644
--- a/dll/win32/dbghelp/elf_module.c
+++ b/dll/win32/dbghelp/elf_module.c
@@ -966,18 +966,6 @@ static int elf_new_public_symbols(struct module* module, const struct
hash_table
return TRUE;
}
-static DWORD calc_crc(HANDLE handle)
-{
- BYTE buffer[8192];
- DWORD crc = 0;
- DWORD len;
-
- SetFilePointer(handle, 0, 0, FILE_BEGIN);
- while (ReadFile(handle, buffer, sizeof(buffer), &len, NULL) && len)
- crc = RtlComputeCrc32(crc, buffer, len);
- return crc;
-}
-
static BOOL elf_check_debug_link(const WCHAR* file, struct image_file_map* fmap, DWORD
link_crc)
{
struct elf_map_file_data emfd;
@@ -987,7 +975,7 @@ static BOOL elf_check_debug_link(const WCHAR* file, struct
image_file_map* fmap,
emfd.u.file.filename = file;
if (!elf_map_file(&emfd, fmap)) return FALSE;
- crc = calc_crc(fmap->u.elf.handle);
+ crc = calc_crc32(fmap->u.elf.handle);
if (crc != link_crc)
{
WARN("Bad CRC for file %s (got %08x while expecting %08x)\n",
debugstr_w(file), crc, link_crc);
@@ -1336,7 +1324,7 @@ BOOL elf_fetch_file_info(const WCHAR* name, DWORD_PTR* base,
if (!elf_map_file(&emfd, &fmap)) return FALSE;
if (base) *base = fmap.u.elf.elf_start;
*size = fmap.u.elf.elf_size;
- *checksum = calc_crc(fmap.u.elf.handle);
+ *checksum = calc_crc32(fmap.u.elf.handle);
image_unmap_file(&fmap);
return TRUE;
}
@@ -1432,7 +1420,7 @@ static BOOL elf_load_file_from_fmap(struct process* pcs, const
WCHAR* filename,
sizeof(struct module_format) + sizeof(struct
elf_module_info));
if (!modfmt) return FALSE;
elf_info->module = module_new(pcs, filename, DMT_ELF, FALSE, modbase,
- fmap->u.elf.elf_size, 0,
calc_crc(fmap->u.elf.handle));
+ fmap->u.elf.elf_size, 0,
calc_crc32(fmap->u.elf.handle));
if (!elf_info->module)
{
HeapFree(GetProcessHeap(), 0, modfmt);
diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c
index 9d4fc4e47a2..5960b0dfc37 100644
--- a/dll/win32/dbghelp/macho_module.c
+++ b/dll/win32/dbghelp/macho_module.c
@@ -152,6 +152,18 @@ static char* format_uuid(const uint8_t uuid[16], char
out[UUID_STRING_LEN])
return out;
}
+static DWORD macho_calc_crc32(int fd)
+{
+ BYTE buffer[8192];
+ DWORD crc = 0;
+ int len;
+
+ lseek(fd, 0, SEEK_SET);
+ while ((len = read(fd, buffer, sizeof(buffer))) > 0)
+ crc = RtlComputeCrc32(crc, buffer, len);
+ return crc;
+}
+
/******************************************************************
* macho_calc_range
*
@@ -1369,7 +1381,7 @@ BOOL macho_fetch_file_info(HANDLE process, const WCHAR* name,
unsigned long load
if (!macho_map_file(pcs, name, split_segs, &fmap)) return FALSE;
if (base) *base = fmap.u.macho.segs_start;
*size = fmap.u.macho.segs_size;
- *checksum = calc_crc32(fmap.u.macho.fd);
+ *checksum = macho_calc_crc32(fmap.u.macho.fd);
macho_unmap_file(&fmap);
return TRUE;
}
@@ -1484,7 +1496,7 @@ static BOOL macho_load_file(struct process* pcs, const WCHAR*
filename,
if (!load_addr)
load_addr = fmap.u.macho.segs_start;
macho_info->module = module_new(pcs, filename, DMT_MACHO, FALSE, load_addr,
- fmap.u.macho.segs_size, 0,
calc_crc32(fmap.u.macho.fd));
+ fmap.u.macho.segs_size, 0,
macho_calc_crc32(fmap.u.macho.fd));
if (!macho_info->module)
{
HeapFree(GetProcessHeap(), 0, modfmt);
diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg
index de1470784a2..3a1ee0fa5aa 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: 1d96af362789aa8aaa0be94a046b0afba2ecefb3
+ wine: a5a6b0dcb65d8e3576e34d350c80f4789dcfdb7a