dbghelp: Move HANDLE-based crc32 helper to dbghelp.c.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1d96af3627
commit
a5a6b0dcb6
|
@ -723,14 +723,14 @@ void WINAPI WinDbgExtensionDllInit(PWINDBG_EXTENSION_APIS lpExtensionApis,
|
|||
{
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -588,7 +588,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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue