Jacek Caban : dbghelp: Call GetSystemInfo in DllMain.
Alexandre Julliard
julliard at winehq.org
Fri Mar 20 17:08:21 CDT 2020
Module: wine
Branch: master
Commit: 7544b9f6fb0bf39c714452968e20e478efaa104a
URL: https://source.winehq.org/git/wine.git/?a=commit;h=7544b9f6fb0bf39c714452968e20e478efaa104a
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Mar 20 18:09:12 2020 +0100
dbghelp: Call GetSystemInfo in DllMain.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dbghelp/dbghelp.c | 13 +++++++++++++
dlls/dbghelp/dbghelp_private.h | 1 +
dlls/dbghelp/elf_module.c | 2 --
dlls/dbghelp/macho_module.c | 2 --
4 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/dlls/dbghelp/dbghelp.c b/dlls/dbghelp/dbghelp.c
index 03e721f0c9..a8e04c7303 100644
--- a/dlls/dbghelp/dbghelp.c
+++ b/dlls/dbghelp/dbghelp.c
@@ -68,9 +68,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
unsigned dbghelp_options = SYMOPT_UNDNAME;
BOOL dbghelp_opt_native = FALSE;
+SYSTEM_INFO sysinfo;
static struct process* process_first /* = NULL */;
+BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
+{
+ switch (reason)
+ {
+ case DLL_PROCESS_ATTACH:
+ GetSystemInfo(&sysinfo);
+ DisableThreadLibraryCalls(instance);
+ break;
+ }
+ return TRUE;
+}
+
/******************************************************************
* process_find_by_handle
*
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index d55b018fa7..8fa9e799c0 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -115,6 +115,7 @@ void* hash_table_iter_up(struct hash_table_iter* hti) DECLSPEC_HIDDEN;
extern unsigned dbghelp_options DECLSPEC_HIDDEN;
extern BOOL dbghelp_opt_native DECLSPEC_HIDDEN;
+extern SYSTEM_INFO sysinfo DECLSPEC_HIDDEN;
enum location_kind {loc_error, /* reg is the error code */
loc_unavailable, /* location is not available */
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c
index 142f2f036a..5a6bef947a 100644
--- a/dlls/dbghelp/elf_module.c
+++ b/dlls/dbghelp/elf_module.c
@@ -137,7 +137,6 @@ struct elf_module_info
static const char* elf_map_section(struct image_section_map* ism)
{
struct elf_file_map* fmap = &ism->fmap->u.elf;
- SYSTEM_INFO sysinfo;
SIZE_T ofst, size;
HANDLE mapping;
@@ -152,7 +151,6 @@ static const char* elf_map_section(struct image_section_map* ism)
}
/* align required information on allocation granularity */
- GetSystemInfo(&sysinfo);
ofst = fmap->sect[ism->sidx].shdr.sh_offset & ~(sysinfo.dwAllocationGranularity - 1);
size = fmap->sect[ism->sidx].shdr.sh_offset + fmap->sect[ism->sidx].shdr.sh_size - ofst;
if (!(mapping = CreateFileMappingW(fmap->handle, NULL, PAGE_READONLY, 0, ofst + size, NULL)))
diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c
index 725363b316..f10dc78eec 100644
--- a/dlls/dbghelp/macho_module.c
+++ b/dlls/dbghelp/macho_module.c
@@ -164,11 +164,9 @@ static void macho_calc_range(const struct macho_file_map* fmap, unsigned long of
unsigned long len, unsigned long* out_aligned_offset,
unsigned long* out_aligned_end, unsigned long* out_misalign)
{
- SYSTEM_INFO sysinfo;
unsigned long pagemask;
unsigned long file_offset, misalign;
- GetSystemInfo(&sysinfo);
pagemask = sysinfo.dwAllocationGranularity - 1;
file_offset = fmap->arch_offset + offset;
misalign = file_offset & pagemask;
More information about the wine-cvs
mailing list