ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
September 2020
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
25 participants
382 discussions
Start a n
N
ew thread
[reactos] 114/179: [WINESYNC] dbghelp: Use loader_ops for enum_modules.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=afc1e47291569c6f51595…
commit afc1e47291569c6f51595d68449504e36e61851b Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:15:28 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:49 2020 +0200 [WINESYNC] dbghelp: Use loader_ops for enum_modules. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 16a3481bd22243183281c60ff375d4e61d5c4198 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp_private.h | 9 ++++----- dll/win32/dbghelp/elf_module.c | 8 ++------ dll/win32/dbghelp/macho_module.c | 8 ++------ dll/win32/dbghelp/minidump.c | 6 +----- dll/win32/dbghelp/module.c | 6 ++++++ sdk/tools/winesync/dbghelp.cfg | 2 +- 6 files changed, 16 insertions(+), 23 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index 80add9ef9c9..472b05a1b9d 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -418,9 +418,12 @@ struct module struct wine_rb_tree sources_offsets_tree; }; +typedef BOOL (*enum_modules_cb)(const WCHAR*, unsigned long addr, void* user); + struct loader_ops { BOOL (*synchronize_module_list)(struct process* process); + BOOL (*enum_modules)(struct process* process, enum_modules_cb callback, void* user); BOOL (*fetch_file_info)(struct process* process, const WCHAR* name, ULONG_PTR load_addr, DWORD_PTR* base, DWORD* size, DWORD* checksum); }; @@ -629,11 +632,7 @@ extern const char* wine_dbgstr_addr(const ADDRESS64* addr) DECLSPEC_HIDDEN; extern struct cpu* cpu_find(DWORD) DECLSPEC_HIDDEN; extern DWORD calc_crc32(HANDLE handle) DECLSPEC_HIDDEN; -typedef BOOL (*enum_modules_cb)(const WCHAR*, unsigned long addr, void* user); - /* elf_module.c */ -extern BOOL elf_enum_modules(struct process*, enum_modules_cb, void*) DECLSPEC_HIDDEN; -struct image_file_map; extern BOOL elf_load_debug_info(struct module* module) DECLSPEC_HIDDEN; extern struct module* elf_load_module(struct process* pcs, const WCHAR* name, unsigned long) DECLSPEC_HIDDEN; @@ -642,7 +641,6 @@ struct elf_thunk_area; extern int elf_is_in_thunk_area(unsigned long addr, const struct elf_thunk_area* thunks) DECLSPEC_HIDDEN; /* macho_module.c */ -extern BOOL macho_enum_modules(struct process*, enum_modules_cb, void*) DECLSPEC_HIDDEN; extern BOOL macho_load_debug_info(struct process *pcs, struct module* module) DECLSPEC_HIDDEN; extern struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsigned long) DECLSPEC_HIDDEN; @@ -740,6 +738,7 @@ extern BOOL stabs_parse(struct module* module, unsigned long load_offset stabs_def_cb callback, void* user) DECLSPEC_HIDDEN; /* dwarf.c */ +struct image_file_map; extern BOOL dwarf2_parse(struct module* module, unsigned long load_offset, const struct elf_thunk_area* thunks, struct image_file_map* fmap) DECLSPEC_HIDDEN; diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index dba4573afee..64c550a67bd 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1502,7 +1502,7 @@ static BOOL elf_enum_modules_translate(const WCHAR* name, unsigned long load_add * This function doesn't require that someone has called SymInitialize * on this very process. */ -BOOL elf_enum_modules(struct process* process, enum_modules_cb cb, void* user) +static BOOL elf_enum_modules(struct process* process, enum_modules_cb cb, void* user) { struct elf_info elf_info; BOOL ret; @@ -1706,6 +1706,7 @@ static BOOL elf_search_loader(struct process* pcs, struct elf_info* elf_info) static const struct loader_ops elf_loader_ops = { elf_synchronize_module_list, + elf_enum_modules, elf_fetch_file_info, }; @@ -1739,11 +1740,6 @@ BOOL elf_read_wine_loader_dbg_info(struct process* pcs) return FALSE; } -BOOL elf_enum_modules(struct process *process, enum_modules_cb cb, void* user) -{ - return FALSE; -} - struct module* elf_load_module(struct process* pcs, const WCHAR* name, unsigned long addr) { return NULL; diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 73d0575a4b0..df38129e12c 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -1730,7 +1730,7 @@ static BOOL macho_synchronize_module_list(struct process* pcs) * This function doesn't require that someone has called SymInitialize * on this very process. */ -BOOL macho_enum_modules(struct process* process, enum_modules_cb cb, void* user) +static BOOL macho_enum_modules(struct process* process, enum_modules_cb cb, void* user) { struct macho_info macho_info; BOOL ret; @@ -1906,6 +1906,7 @@ static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_in static const struct loader_ops macho_loader_ops = { macho_synchronize_module_list, + macho_enum_modules, macho_fetch_file_info, }; @@ -1935,11 +1936,6 @@ BOOL macho_read_wine_loader_dbg_info(struct process* pcs) return FALSE; } -BOOL macho_enum_modules(struct process *process, enum_modules_cb cb, void* user) -{ - return FALSE; -} - struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsigned long addr) { return NULL; diff --git a/dll/win32/dbghelp/minidump.c b/dll/win32/dbghelp/minidump.c index 27e3a8708ed..4730dedec94 100644 --- a/dll/win32/dbghelp/minidump.c +++ b/dll/win32/dbghelp/minidump.c @@ -320,11 +320,7 @@ static void fetch_modules_info(struct dump_context* dc) * And it's always a good idea to have a trace of the loaded ELF modules for * a given application in a post mortem debugging condition. */ - if (dc->process->dbg_hdr_addr) - { - elf_enum_modules(dc->process, fetch_host_module_info_cb, dc); - macho_enum_modules(dc->process, fetch_host_module_info_cb, dc); - } + dc->process->loader->enum_modules(dc->process, fetch_host_module_info_cb, dc); } static void fetch_module_versioninfo(LPCWSTR filename, VS_FIXEDFILEINFO* ffi) diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c index 7d7b101ac1c..61a069ec75b 100644 --- a/dll/win32/dbghelp/module.c +++ b/dll/win32/dbghelp/module.c @@ -1465,6 +1465,11 @@ static BOOL native_synchronize_module_list(struct process* pcs) return FALSE; } +static BOOL native_enum_modules(struct process *process, enum_modules_cb cb, void* user) +{ + return FALSE; +} + static BOOL native_fetch_file_info(struct process* process, const WCHAR* name, ULONG_PTR load_addr, DWORD_PTR* base, DWORD* size, DWORD* checksum) { @@ -1474,5 +1479,6 @@ static BOOL native_fetch_file_info(struct process* process, const WCHAR* name, U const struct loader_ops no_loader_ops = { native_synchronize_module_list, + native_enum_modules, native_fetch_file_info, }; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 95aa66e766f..06702ac9f61 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: 2a5160c4f2eb80dcc8770cd10d702a5d8233314f + wine: 16a3481bd22243183281c60ff375d4e61d5c4198
4 years, 3 months
1
0
0
0
[reactos] 113/179: [WINESYNC] dbghelp: Pass process struct to image_uses_split_segs.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=df9fadccb36d24b549543…
commit df9fadccb36d24b54954365fa331eae2c57833db Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:15:27 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:49 2020 +0200 [WINESYNC] dbghelp: Pass process struct to image_uses_split_segs. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 2a5160c4f2eb80dcc8770cd10d702a5d8233314f by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/macho_module.c | 15 +++++++-------- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 4847a434fda..73d0575a4b0 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -1255,18 +1255,17 @@ found: * The image header has to be loaded from the process's memory * because the relevant flag is only set in memory, not in the file. */ -static BOOL image_uses_split_segs(HANDLE process, unsigned long load_addr) +static BOOL image_uses_split_segs(struct process* process, unsigned long load_addr) { BOOL split_segs = FALSE; - if (process && load_addr) + if (load_addr) { - struct process *pcs = process_find_by_handle(process); - cpu_type_t target_cpu = (pcs->is_64bit) ? CPU_TYPE_X86_64 : CPU_TYPE_X86; - uint32_t target_magic = (pcs->is_64bit) ? MH_MAGIC_64 : MH_MAGIC; + cpu_type_t target_cpu = (process->is_64bit) ? CPU_TYPE_X86_64 : CPU_TYPE_X86; + uint32_t target_magic = (process->is_64bit) ? MH_MAGIC_64 : MH_MAGIC; struct mach_header header; - if (ReadProcessMemory(process, (void*)load_addr, &header, sizeof(header), NULL) && + if (ReadProcessMemory(process->handle, (void*)load_addr, &header, sizeof(header), NULL) && header.magic == target_magic && header.cputype == target_cpu && header.flags & MACHO_DYLD_IN_SHARED_CACHE) { @@ -1351,7 +1350,7 @@ static BOOL macho_fetch_file_info(struct process* process, const WCHAR* name, UL TRACE("(%s, %p, %p, %p)\n", debugstr_w(name), base, size, checksum); - split_segs = image_uses_split_segs(process->handle, load_addr); + split_segs = image_uses_split_segs(process, load_addr); if (!macho_map_file(process, name, split_segs, &fmap)) return FALSE; if (base) *base = fmap.u.macho.segs_start; *size = fmap.u.macho.segs_size; @@ -1449,7 +1448,7 @@ static BOOL macho_load_file(struct process* pcs, const WCHAR* filename, TRACE("(%p/%p, %s, 0x%08lx, %p/0x%08x)\n", pcs, pcs->handle, debugstr_w(filename), load_addr, macho_info, macho_info->flags); - split_segs = image_uses_split_segs(pcs->handle, load_addr); + split_segs = image_uses_split_segs(pcs, load_addr); if (!macho_map_file(pcs, filename, split_segs, &fmap)) return FALSE; /* Find the dynamic loader's table of images loaded into the process. diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 44688198f3d..95aa66e766f 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: 1bbd54409a546c26af8ac2a64f2603114d73a18c + wine: 2a5160c4f2eb80dcc8770cd10d702a5d8233314f
4 years, 3 months
1
0
0
0
[reactos] 112/179: [WINESYNC] dbghelp: Use loader_ops for fetch_file_info.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ba7ee56d528f59505ad03…
commit ba7ee56d528f59505ad034bdde3100a3c60f1ac3 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:14:18 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:49 2020 +0200 [WINESYNC] dbghelp: Use loader_ops for fetch_file_info. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 1bbd54409a546c26af8ac2a64f2603114d73a18c by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp_private.h | 3 +-- dll/win32/dbghelp/elf_module.c | 10 ++-------- dll/win32/dbghelp/macho_module.c | 19 +++++-------------- dll/win32/dbghelp/minidump.c | 36 +++++------------------------------- dll/win32/dbghelp/module.c | 7 +++++++ sdk/tools/winesync/dbghelp.cfg | 2 +- 6 files changed, 21 insertions(+), 56 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index ccd488b8680..80add9ef9c9 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -421,6 +421,7 @@ struct module struct loader_ops { BOOL (*synchronize_module_list)(struct process* process); + BOOL (*fetch_file_info)(struct process* process, const WCHAR* name, ULONG_PTR load_addr, DWORD_PTR* base, DWORD* size, DWORD* checksum); }; struct process @@ -632,7 +633,6 @@ typedef BOOL (*enum_modules_cb)(const WCHAR*, unsigned long addr, void* user); /* elf_module.c */ extern BOOL elf_enum_modules(struct process*, enum_modules_cb, void*) DECLSPEC_HIDDEN; -extern BOOL elf_fetch_file_info(const WCHAR* name, DWORD_PTR* base, DWORD* size, DWORD* checksum) DECLSPEC_HIDDEN; struct image_file_map; extern BOOL elf_load_debug_info(struct module* module) DECLSPEC_HIDDEN; extern struct module* @@ -643,7 +643,6 @@ extern int elf_is_in_thunk_area(unsigned long addr, const struct elf_th /* macho_module.c */ extern BOOL macho_enum_modules(struct process*, enum_modules_cb, void*) DECLSPEC_HIDDEN; -extern BOOL macho_fetch_file_info(HANDLE process, const WCHAR* name, unsigned long load_addr, DWORD_PTR* base, DWORD* size, DWORD* checksum) DECLSPEC_HIDDEN; extern BOOL macho_load_debug_info(struct process *pcs, struct module* module) DECLSPEC_HIDDEN; extern struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsigned long) DECLSPEC_HIDDEN; diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 2a4b349c49b..dba4573afee 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1068,8 +1068,7 @@ BOOL elf_load_debug_info(struct module* module) * * Gathers some more information for an ELF module from a given file */ -BOOL elf_fetch_file_info(const WCHAR* name, DWORD_PTR* base, - DWORD* size, DWORD* checksum) +static BOOL elf_fetch_file_info(struct process* process, const WCHAR* name, ULONG_PTR load_addr, DWORD_PTR* base, DWORD* size, DWORD* checksum) { struct image_file_map fmap; @@ -1707,6 +1706,7 @@ static BOOL elf_search_loader(struct process* pcs, struct elf_info* elf_info) static const struct loader_ops elf_loader_ops = { elf_synchronize_module_list, + elf_fetch_file_info, }; /****************************************************************** @@ -1734,12 +1734,6 @@ BOOL elf_map_handle(HANDLE handle, struct image_file_map* fmap) return FALSE; } -BOOL elf_fetch_file_info(const WCHAR* name, DWORD_PTR* base, - DWORD* size, DWORD* checksum) -{ - return FALSE; -} - BOOL elf_read_wine_loader_dbg_info(struct process* pcs) { return FALSE; diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 071d7bed5c5..4847a434fda 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -1343,20 +1343,16 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module) * * Gathers some more information for a Mach-O module from a given file */ -BOOL macho_fetch_file_info(HANDLE process, const WCHAR* name, unsigned long load_addr, DWORD_PTR* base, - DWORD* size, DWORD* checksum) +static BOOL macho_fetch_file_info(struct process* process, const WCHAR* name, ULONG_PTR load_addr, DWORD_PTR* base, + DWORD* size, DWORD* checksum) { struct image_file_map fmap; - struct process *pcs; BOOL split_segs; TRACE("(%s, %p, %p, %p)\n", debugstr_w(name), base, size, checksum); - pcs = process_find_by_handle(process); - if (!pcs) return FALSE; - - split_segs = image_uses_split_segs(process, load_addr); - if (!macho_map_file(pcs, name, split_segs, &fmap)) return FALSE; + split_segs = image_uses_split_segs(process->handle, load_addr); + if (!macho_map_file(process, 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.handle); @@ -1911,6 +1907,7 @@ static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_in static const struct loader_ops macho_loader_ops = { macho_synchronize_module_list, + macho_fetch_file_info, }; /****************************************************************** @@ -1934,12 +1931,6 @@ BOOL macho_read_wine_loader_dbg_info(struct process* pcs) #else /* HAVE_MACH_O_LOADER_H */ -BOOL macho_fetch_file_info(HANDLE process, const WCHAR* name, unsigned long load_addr, DWORD_PTR* base, - DWORD* size, DWORD* checksum) -{ - return FALSE; -} - BOOL macho_read_wine_loader_dbg_info(struct process* pcs) { return FALSE; diff --git a/dll/win32/dbghelp/minidump.c b/dll/win32/dbghelp/minidump.c index 899a88b8d15..27e3a8708ed 100644 --- a/dll/win32/dbghelp/minidump.c +++ b/dll/win32/dbghelp/minidump.c @@ -253,9 +253,9 @@ static BOOL WINAPI fetch_pe_module_info_cb(PCWSTR name, DWORD64 base, ULONG size /****************************************************************** * fetch_elf_module_info_cb * - * Callback for accumulating in dump_context an ELF modules set + * Callback for accumulating in dump_context an host modules set */ -static BOOL fetch_elf_module_info_cb(const WCHAR* name, unsigned long base, +static BOOL fetch_host_module_info_cb(const WCHAR* name, unsigned long base, void* user) { struct dump_context* dc = user; @@ -263,33 +263,7 @@ static BOOL fetch_elf_module_info_cb(const WCHAR* name, unsigned long base, DWORD size, checksum; /* FIXME: there's no relevant timestamp on ELF modules */ - /* NB: if we have a non-null base from the live-target use it (whenever - * the ELF module is relocatable or not). If we have a null base (ELF - * module isn't relocatable) then grab its base address from ELF file - */ - if (!elf_fetch_file_info(name, &rbase, &size, &checksum)) - size = checksum = 0; - add_module(dc, name, base ? base : rbase, size, 0 /* FIXME */, checksum, TRUE); - return TRUE; -} - -/****************************************************************** - * fetch_macho_module_info_cb - * - * Callback for accumulating in dump_context a Mach-O modules set - */ -static BOOL fetch_macho_module_info_cb(const WCHAR* name, unsigned long base, - void* user) -{ - struct dump_context* dc = (struct dump_context*)user; - DWORD_PTR rbase; - DWORD size, checksum; - - /* FIXME: there's no relevant timestamp on Mach-O modules */ - /* NB: if we have a non-null base from the live-target use it. If we have - * a null base, then grab its base address from Mach-O file. - */ - if (!macho_fetch_file_info(dc->process->handle, name, base, &rbase, &size, &checksum)) + if (!dc->process->loader->fetch_file_info(dc->process, name, base, &rbase, &size, &checksum)) size = checksum = 0; add_module(dc, name, base ? base : rbase, size, 0 /* FIXME */, checksum, TRUE); return TRUE; @@ -348,8 +322,8 @@ static void fetch_modules_info(struct dump_context* dc) */ if (dc->process->dbg_hdr_addr) { - elf_enum_modules(dc->process, fetch_elf_module_info_cb, dc); - macho_enum_modules(dc->process, fetch_macho_module_info_cb, dc); + elf_enum_modules(dc->process, fetch_host_module_info_cb, dc); + macho_enum_modules(dc->process, fetch_host_module_info_cb, dc); } } diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c index 444eac4ad1d..7d7b101ac1c 100644 --- a/dll/win32/dbghelp/module.c +++ b/dll/win32/dbghelp/module.c @@ -1465,7 +1465,14 @@ static BOOL native_synchronize_module_list(struct process* pcs) return FALSE; } +static BOOL native_fetch_file_info(struct process* process, const WCHAR* name, ULONG_PTR load_addr, DWORD_PTR* base, + DWORD* size, DWORD* checksum) +{ + return FALSE; +} + const struct loader_ops no_loader_ops = { native_synchronize_module_list, + native_fetch_file_info, }; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 528e63fee11..44688198f3d 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: adecdb1d01487af16f5f708ae92a05ba4707187e + wine: 1bbd54409a546c26af8ac2a64f2603114d73a18c
4 years, 3 months
1
0
0
0
[reactos] 111/179: [WINESYNC] dbghelp: Don't use elf_fetch_file_info and macho_fetch_file_info in module_find_cb.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f9b46d2c9f105614e2d34…
commit f9b46d2c9f105614e2d34a4f1a395bd88379aa2a Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:14:18 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:48 2020 +0200 [WINESYNC] dbghelp: Don't use elf_fetch_file_info and macho_fetch_file_info in module_find_cb. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id adecdb1d01487af16f5f708ae92a05ba4707187e by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/path.c | 45 +++++++++++++++++++----------------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/dll/win32/dbghelp/path.c b/dll/win32/dbghelp/path.c index a5b8b4fdd8d..023adfa1037 100644 --- a/dll/win32/dbghelp/path.c +++ b/dll/win32/dbghelp/path.c @@ -24,6 +24,7 @@ #include <string.h> #include "dbghelp_private.h" +#include "image_private.h" #include "winnls.h" #include "winternl.h" #include "wine/debug.h" @@ -523,34 +524,28 @@ static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user) if (timestamp == mf->dw1 && size == mf->dw2) matched++; } break; - case DMT_ELF: - if (elf_fetch_file_info(buffer, 0, &size, &checksum)) - { - matched++; - if (checksum == mf->dw1) matched++; - else - WARN("Found %s, but wrong checksums: %08x %08x\n", - debugstr_w(buffer), checksum, mf->dw1); - } - else - { - WARN("Couldn't read %s\n", debugstr_w(buffer)); - return FALSE; - } - break; case DMT_MACHO: - if (macho_fetch_file_info(NULL, buffer, 0, 0, &size, &checksum)) + case DMT_ELF: { - matched++; - if (checksum == mf->dw1) matched++; + HANDLE file; + + file = CreateFileW(buffer, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (file == INVALID_HANDLE_VALUE) break; + + checksum = calc_crc32(file); + if (checksum == mf->dw1) matched += 2; else - WARN("Found %s, but wrong checksums: %08x %08x\n", - debugstr_w(buffer), checksum, mf->dw1); - } - else - { - WARN("Couldn't read %s\n", debugstr_w(buffer)); - return FALSE; + { + struct image_file_map fmap; + WARN("Found %s, but wrong checksums: %08x %08x\n", debugstr_w(buffer), checksum, mf->dw1); + if (elf_map_handle(file, &fmap)) /* FIXME: validate macho files */ + { + image_unmap_file(&fmap); + matched++; + } + } + CloseHandle(file); } break; case DMT_PDB: diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 59039add5d6..528e63fee11 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: fec0157585e9d8bd03a8a71d1ed9b9d7ca59cb56 + wine: adecdb1d01487af16f5f708ae92a05ba4707187e
4 years, 3 months
1
0
0
0
[reactos] 110/179: [WINESYNC] dbghelp: Introduce loader_ops to abstract platform-specific loader and use it to synchronize module list.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=031700a760b278628e820…
commit 031700a760b278628e8200a0e4ef12be5596e14b Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:10:42 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:48 2020 +0200 [WINESYNC] dbghelp: Introduce loader_ops to abstract platform-specific loader and use it to synchronize module list. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id fec0157585e9d8bd03a8a71d1ed9b9d7ca59cb56 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp.c | 4 ++-- dll/win32/dbghelp/dbghelp_private.h | 9 +++++++-- dll/win32/dbghelp/elf_module.c | 18 ++++++++++-------- dll/win32/dbghelp/macho_module.c | 18 ++++++++++-------- dll/win32/dbghelp/module.c | 31 ++++++++++++------------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 6 files changed, 42 insertions(+), 40 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp.c b/dll/win32/dbghelp/dbghelp.c index da1649b80a9..6e03cc3d385 100644 --- a/dll/win32/dbghelp/dbghelp.c +++ b/dll/win32/dbghelp/dbghelp.c @@ -352,6 +352,7 @@ BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeP pcs->handle = hProcess; pcs->is_64bit = (sizeof(void *) == 8 || wow64) && !child_wow64; + pcs->loader = &no_loader_ops; /* platform-specific initialization will override it if loader debug info can be found */ if (UserSearchPath) { @@ -398,8 +399,7 @@ BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeP { if (fInvadeProcess) EnumerateLoadedModulesW64(hProcess, process_invade_cb, hProcess); - elf_synchronize_module_list(pcs); - macho_synchronize_module_list(pcs); + pcs->loader->synchronize_module_list(pcs); } else if (fInvadeProcess) { diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index 7c164fce219..ccd488b8680 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -418,10 +418,16 @@ struct module struct wine_rb_tree sources_offsets_tree; }; +struct loader_ops +{ + BOOL (*synchronize_module_list)(struct process* process); +}; + struct process { struct process* next; HANDLE handle; + const struct loader_ops* loader; WCHAR* search_path; PSYMBOL_REGISTERED_CALLBACK64 reg_cb; @@ -632,7 +638,6 @@ extern BOOL elf_load_debug_info(struct module* module) DECLSPEC_HIDDEN; extern struct module* elf_load_module(struct process* pcs, const WCHAR* name, unsigned long) DECLSPEC_HIDDEN; extern BOOL elf_read_wine_loader_dbg_info(struct process* pcs) DECLSPEC_HIDDEN; -extern BOOL elf_synchronize_module_list(struct process* pcs) DECLSPEC_HIDDEN; struct elf_thunk_area; extern int elf_is_in_thunk_area(unsigned long addr, const struct elf_thunk_area* thunks) DECLSPEC_HIDDEN; @@ -643,7 +648,6 @@ extern BOOL macho_load_debug_info(struct process *pcs, struct module* mo extern struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsigned long) DECLSPEC_HIDDEN; extern BOOL macho_read_wine_loader_dbg_info(struct process* pcs) DECLSPEC_HIDDEN; -extern BOOL macho_synchronize_module_list(struct process* pcs) DECLSPEC_HIDDEN; /* minidump.c */ void minidump_add_memory_block(struct dump_context* dc, ULONG64 base, ULONG size, ULONG rva) DECLSPEC_HIDDEN; @@ -652,6 +656,7 @@ void minidump_add_memory_block(struct dump_context* dc, ULONG64 base, ULONG size extern const WCHAR S_ElfW[] DECLSPEC_HIDDEN; extern const WCHAR S_WineLoaderW[] DECLSPEC_HIDDEN; extern const WCHAR S_SlashW[] DECLSPEC_HIDDEN; +extern const struct loader_ops no_loader_ops DECLSPEC_HIDDEN; extern struct module* module_find_by_addr(const struct process* pcs, DWORD64 addr, diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 1c7a77650b1..2a4b349c49b 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1623,7 +1623,7 @@ struct module* elf_load_module(struct process* pcs, const WCHAR* name, unsigned * - if a module is in debuggee and not in pcs, it's loaded into pcs * - if a module is in pcs and not in debuggee, it's unloaded from pcs */ -BOOL elf_synchronize_module_list(struct process* pcs) +static BOOL elf_synchronize_module_list(struct process* pcs) { struct module* module; struct elf_load el; @@ -1704,6 +1704,11 @@ static BOOL elf_search_loader(struct process* pcs, struct elf_info* elf_info) return ret; } +static const struct loader_ops elf_loader_ops = +{ + elf_synchronize_module_list, +}; + /****************************************************************** * elf_read_wine_loader_dbg_info * @@ -1714,10 +1719,12 @@ BOOL elf_read_wine_loader_dbg_info(struct process* pcs) struct elf_info elf_info; elf_info.flags = ELF_INFO_DEBUG_HEADER | ELF_INFO_MODULE; - if (!elf_search_loader(pcs, &elf_info)) return FALSE; + if (!elf_search_loader(pcs, &elf_info) || !elf_info.dbg_hdr_addr) return FALSE; elf_info.module->format_info[DFI_ELF]->u.elf_info->elf_loader = 1; module_set_module(elf_info.module, S_WineLoaderW); - return (pcs->dbg_hdr_addr = elf_info.dbg_hdr_addr) != 0; + pcs->dbg_hdr_addr = elf_info.dbg_hdr_addr; + pcs->loader = &elf_loader_ops; + return TRUE; } #else /* !__ELF__ */ @@ -1727,11 +1734,6 @@ BOOL elf_map_handle(HANDLE handle, struct image_file_map* fmap) return FALSE; } -BOOL elf_synchronize_module_list(struct process* pcs) -{ - return FALSE; -} - BOOL elf_fetch_file_info(const WCHAR* name, DWORD_PTR* base, DWORD* size, DWORD* checksum) { diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 93135c71e79..071d7bed5c5 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -1694,7 +1694,7 @@ static BOOL macho_enum_sync_cb(const WCHAR* name, unsigned long addr, void* user * - if a module is in debuggee and not in pcs, it's loaded into pcs * - if a module is in pcs and not in debuggee, it's unloaded from pcs */ -BOOL macho_synchronize_module_list(struct process* pcs) +static BOOL macho_synchronize_module_list(struct process* pcs) { struct module* module; struct macho_sync ms; @@ -1908,6 +1908,11 @@ static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_in return ret; } +static const struct loader_ops macho_loader_ops = +{ + macho_synchronize_module_list, +}; + /****************************************************************** * macho_read_wine_loader_dbg_info * @@ -1919,19 +1924,16 @@ BOOL macho_read_wine_loader_dbg_info(struct process* pcs) TRACE("(%p/%p)\n", pcs, pcs->handle); macho_info.flags = MACHO_INFO_DEBUG_HEADER | MACHO_INFO_MODULE; - if (!macho_search_loader(pcs, &macho_info)) return FALSE; + if (!macho_search_loader(pcs, &macho_info) || !macho_info.dbg_hdr_addr) return FALSE; macho_info.module->format_info[DFI_MACHO]->u.macho_info->is_loader = 1; module_set_module(macho_info.module, S_WineLoaderW); - return (pcs->dbg_hdr_addr = macho_info.dbg_hdr_addr) != 0; + pcs->dbg_hdr_addr = macho_info.dbg_hdr_addr; + pcs->loader = &macho_loader_ops; + return TRUE; } #else /* HAVE_MACH_O_LOADER_H */ -BOOL macho_synchronize_module_list(struct process* pcs) -{ - return FALSE; -} - BOOL macho_fetch_file_info(HANDLE process, const WCHAR* name, unsigned long load_addr, DWORD_PTR* base, DWORD* size, DWORD* checksum) { diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c index c04224f9532..444eac4ad1d 100644 --- a/dll/win32/dbghelp/module.c +++ b/dll/win32/dbghelp/module.c @@ -548,17 +548,6 @@ enum module_type module_get_type_by_name(const WCHAR* name) return DMT_PE; } -/****************************************************************** - * refresh_module_list - */ -#ifndef DBGHELP_STATIC_LIB -static BOOL refresh_module_list(struct process* pcs) -{ - /* force transparent ELF and Mach-O loading / unloading */ - return elf_synchronize_module_list(pcs) || macho_synchronize_module_list(pcs); -} -#endif - static BOOL image_check_debug_link(const WCHAR* file, struct image_file_map* fmap, DWORD link_crc) { DWORD read_bytes; @@ -906,9 +895,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam if (Flags & ~(SLMFLAG_VIRTUAL)) FIXME("Unsupported Flags %08x for %s\n", Flags, debugstr_w(wImageName)); -#ifndef DBGHELP_STATIC_LIB - refresh_module_list(pcs); -#endif + pcs->loader->synchronize_module_list(pcs); /* this is a Wine extension to the API just to redo the synchronisation */ if (!wImageName && !hFile) return 0; @@ -1447,11 +1434,7 @@ BOOL WINAPI SymRefreshModuleList(HANDLE hProcess) if (!(pcs = process_find_by_handle(hProcess))) return FALSE; -#ifndef DBGHELP_STATIC_LIB - return refresh_module_list(pcs); -#else - return TRUE; -#endif + return pcs->loader->synchronize_module_list(pcs); } /*********************************************************************** @@ -1476,3 +1459,13 @@ PVOID WINAPI SymFunctionTableAccess64(HANDLE hProcess, DWORD64 AddrBase) return dbghelp_current_cpu->find_runtime_function(module, AddrBase); } + +static BOOL native_synchronize_module_list(struct process* pcs) +{ + return FALSE; +} + +const struct loader_ops no_loader_ops = +{ + native_synchronize_module_list, +}; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 7e3c49cd25b..59039add5d6 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: f30fdd1822462326d3339a21b838d28b623e6486 + wine: fec0157585e9d8bd03a8a71d1ed9b9d7ca59cb56
4 years, 3 months
1
0
0
0
[reactos] 109/179: [WINESYNC] dbghelp: Move loader search functions to the end of module files.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=86173a5f26aa8cf36ee6b…
commit 86173a5f26aa8cf36ee6bb3e304b379330f17eb5 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:10:42 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:48 2020 +0200 [WINESYNC] dbghelp: Move loader search functions to the end of module files. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id f30fdd1822462326d3339a21b838d28b623e6486 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 116 ++++++++++++------------- dll/win32/dbghelp/macho_module.c | 181 +++++++++++++++++++-------------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 3 files changed, 149 insertions(+), 150 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 728025fa405..1c7a77650b1 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1483,64 +1483,6 @@ static BOOL elf_enum_modules_internal(const struct process* pcs, return TRUE; } -/****************************************************************** - * elf_search_loader - * - * Lookup in a running ELF process the loader, and sets its ELF link - * address (for accessing the list of loaded .so libs) in pcs. - * If flags is ELF_INFO_MODULE, the module for the loader is also - * added as a module into pcs. - */ -static BOOL elf_search_loader(struct process* pcs, struct elf_info* elf_info) -{ - WCHAR *loader = get_wine_loader_name(pcs); - PROCESS_BASIC_INFORMATION pbi; - ULONG_PTR base = 0; - BOOL ret; - - if (NtQueryInformationProcess( pcs->handle, ProcessBasicInformation, - &pbi, sizeof(pbi), NULL )) - return FALSE; - - if (!pcs->is_64bit) - { - PEB32 *peb32 = (PEB32 *)pbi.PebBaseAddress; - DWORD base32; - - if (!ReadProcessMemory( pcs->handle, &peb32->Reserved[0], &base32, - sizeof(base32), NULL )) - return FALSE; - - base = base32; - } - else - { - if (!ReadProcessMemory( pcs->handle, &pbi.PebBaseAddress->Reserved[0], - &base, sizeof(base), NULL )) - return FALSE; - } - - ret = elf_search_and_load_file(pcs, loader, base, 0, elf_info); - heap_free(loader); - return ret; -} - -/****************************************************************** - * elf_read_wine_loader_dbg_info - * - * Try to find a decent wine executable which could have loaded the debuggee - */ -BOOL elf_read_wine_loader_dbg_info(struct process* pcs) -{ - struct elf_info elf_info; - - elf_info.flags = ELF_INFO_DEBUG_HEADER | ELF_INFO_MODULE; - if (!elf_search_loader(pcs, &elf_info)) return FALSE; - elf_info.module->format_info[DFI_ELF]->u.elf_info->elf_loader = 1; - module_set_module(elf_info.module, S_WineLoaderW); - return (pcs->dbg_hdr_addr = elf_info.dbg_hdr_addr) != 0; -} - struct elf_enum_user { enum_modules_cb cb; @@ -1720,6 +1662,64 @@ BOOL elf_synchronize_module_list(struct process* pcs) return TRUE; } +/****************************************************************** + * elf_search_loader + * + * Lookup in a running ELF process the loader, and sets its ELF link + * address (for accessing the list of loaded .so libs) in pcs. + * If flags is ELF_INFO_MODULE, the module for the loader is also + * added as a module into pcs. + */ +static BOOL elf_search_loader(struct process* pcs, struct elf_info* elf_info) +{ + WCHAR *loader = get_wine_loader_name(pcs); + PROCESS_BASIC_INFORMATION pbi; + ULONG_PTR base = 0; + BOOL ret; + + if (NtQueryInformationProcess( pcs->handle, ProcessBasicInformation, + &pbi, sizeof(pbi), NULL )) + return FALSE; + + if (!pcs->is_64bit) + { + PEB32 *peb32 = (PEB32 *)pbi.PebBaseAddress; + DWORD base32; + + if (!ReadProcessMemory( pcs->handle, &peb32->Reserved[0], &base32, + sizeof(base32), NULL )) + return FALSE; + + base = base32; + } + else + { + if (!ReadProcessMemory( pcs->handle, &pbi.PebBaseAddress->Reserved[0], + &base, sizeof(base), NULL )) + return FALSE; + } + + ret = elf_search_and_load_file(pcs, loader, base, 0, elf_info); + heap_free(loader); + return ret; +} + +/****************************************************************** + * elf_read_wine_loader_dbg_info + * + * Try to find a decent wine executable which could have loaded the debuggee + */ +BOOL elf_read_wine_loader_dbg_info(struct process* pcs) +{ + struct elf_info elf_info; + + elf_info.flags = ELF_INFO_DEBUG_HEADER | ELF_INFO_MODULE; + if (!elf_search_loader(pcs, &elf_info)) return FALSE; + elf_info.module->format_info[DFI_ELF]->u.elf_info->elf_loader = 1; + module_set_module(elf_info.module, S_WineLoaderW); + return (pcs->dbg_hdr_addr = elf_info.dbg_hdr_addr) != 0; +} + #else /* !__ELF__ */ BOOL elf_map_handle(HANDLE handle, struct image_file_map* fmap) diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index a35ed5db732..93135c71e79 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -1373,7 +1373,6 @@ static void macho_module_remove(struct process* pcs, struct module_format* modfm HeapFree(GetProcessHeap(), 0, modfmt); } - /****************************************************************** * get_dyld_image_info_address */ @@ -1729,6 +1728,96 @@ BOOL macho_synchronize_module_list(struct process* pcs) return TRUE; } +/****************************************************************** + * macho_enum_modules + * + * Enumerates the Mach-O loaded modules from a running target (hProc) + * This function doesn't require that someone has called SymInitialize + * on this very process. + */ +BOOL macho_enum_modules(struct process* process, enum_modules_cb cb, void* user) +{ + struct macho_info macho_info; + BOOL ret; + + TRACE("(%p, %p, %p)\n", process->handle, cb, user); + macho_info.flags = MACHO_INFO_DEBUG_HEADER | MACHO_INFO_NAME; + ret = macho_enum_modules_internal(process, macho_info.module_name, cb, user); + HeapFree(GetProcessHeap(), 0, (char*)macho_info.module_name); + return ret; +} + +struct macho_load +{ + struct process* pcs; + struct macho_info macho_info; + const WCHAR* name; + BOOL ret; +}; + +/****************************************************************** + * macho_load_cb + * + * Callback for macho_load_module, used to walk the list of loaded + * modules. + */ +static BOOL macho_load_cb(const WCHAR* name, unsigned long addr, void* user) +{ + struct macho_load* ml = user; + const WCHAR* p; + + TRACE("(%s, 0x%08lx, %p)\n", debugstr_w(name), addr, user); + + /* memcmp is needed for matches when bufstr contains also version information + * ml->name: libc.so, name: libc.so.6.0 + */ + p = file_name(name); + if (!memcmp(p, ml->name, lstrlenW(ml->name) * sizeof(WCHAR))) + { + ml->ret = macho_search_and_load_file(ml->pcs, name, addr, &ml->macho_info); + return FALSE; + } + return TRUE; +} + +/****************************************************************** + * macho_load_module + * + * Loads a Mach-O module and stores it in process' module list. + * Also, find module real name and load address from + * the real loaded modules list in pcs address space. + */ +struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsigned long addr) +{ + struct macho_load ml; + + TRACE("(%p/%p, %s, 0x%08lx)\n", pcs, pcs->handle, debugstr_w(name), addr); + + ml.macho_info.flags = MACHO_INFO_MODULE; + ml.ret = FALSE; + + if (pcs->dbg_hdr_addr) /* we're debugging a live target */ + { + ml.pcs = pcs; + /* do only the lookup from the filename, not the path (as we lookup module + * name in the process' loaded module list) + */ + ml.name = file_name(name); + ml.ret = FALSE; + + if (!macho_enum_modules_internal(pcs, NULL, macho_load_cb, &ml)) + return NULL; + } + else if (addr) + { + ml.name = name; + ml.ret = macho_search_and_load_file(pcs, ml.name, addr, &ml.macho_info); + } + if (!ml.ret) return NULL; + assert(ml.macho_info.module); + return ml.macho_info.module; +} + /****************************************************************** * macho_search_loader * @@ -1836,96 +1925,6 @@ BOOL macho_read_wine_loader_dbg_info(struct process* pcs) return (pcs->dbg_hdr_addr = macho_info.dbg_hdr_addr) != 0; } -/****************************************************************** - * macho_enum_modules - * - * Enumerates the Mach-O loaded modules from a running target (hProc) - * This function doesn't require that someone has called SymInitialize - * on this very process. - */ -BOOL macho_enum_modules(struct process* process, enum_modules_cb cb, void* user) -{ - struct macho_info macho_info; - BOOL ret; - - TRACE("(%p, %p, %p)\n", process->handle, cb, user); - macho_info.flags = MACHO_INFO_DEBUG_HEADER | MACHO_INFO_NAME; - ret = macho_enum_modules_internal(process, macho_info.module_name, cb, user); - HeapFree(GetProcessHeap(), 0, (char*)macho_info.module_name); - return ret; -} - -struct macho_load -{ - struct process* pcs; - struct macho_info macho_info; - const WCHAR* name; - BOOL ret; -}; - -/****************************************************************** - * macho_load_cb - * - * Callback for macho_load_module, used to walk the list of loaded - * modules. - */ -static BOOL macho_load_cb(const WCHAR* name, unsigned long addr, void* user) -{ - struct macho_load* ml = user; - const WCHAR* p; - - TRACE("(%s, 0x%08lx, %p)\n", debugstr_w(name), addr, user); - - /* memcmp is needed for matches when bufstr contains also version information - * ml->name: libc.so, name: libc.so.6.0 - */ - p = file_name(name); - if (!memcmp(p, ml->name, lstrlenW(ml->name) * sizeof(WCHAR))) - { - ml->ret = macho_search_and_load_file(ml->pcs, name, addr, &ml->macho_info); - return FALSE; - } - return TRUE; -} - -/****************************************************************** - * macho_load_module - * - * Loads a Mach-O module and stores it in process' module list. - * Also, find module real name and load address from - * the real loaded modules list in pcs address space. - */ -struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsigned long addr) -{ - struct macho_load ml; - - TRACE("(%p/%p, %s, 0x%08lx)\n", pcs, pcs->handle, debugstr_w(name), addr); - - ml.macho_info.flags = MACHO_INFO_MODULE; - ml.ret = FALSE; - - if (pcs->dbg_hdr_addr) /* we're debugging a live target */ - { - ml.pcs = pcs; - /* do only the lookup from the filename, not the path (as we lookup module - * name in the process' loaded module list) - */ - ml.name = file_name(name); - ml.ret = FALSE; - - if (!macho_enum_modules_internal(pcs, NULL, macho_load_cb, &ml)) - return NULL; - } - else if (addr) - { - ml.name = name; - ml.ret = macho_search_and_load_file(pcs, ml.name, addr, &ml.macho_info); - } - if (!ml.ret) return NULL; - assert(ml.macho_info.module); - return ml.macho_info.module; -} - #else /* HAVE_MACH_O_LOADER_H */ BOOL macho_synchronize_module_list(struct process* pcs) diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index e3201a2b01f..7e3c49cd25b 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: 724f433f39f71e8869c49a5960364c5669759b08 + wine: f30fdd1822462326d3339a21b838d28b623e6486
4 years, 3 months
1
0
0
0
[reactos] 108/179: [WINESYNC] dbghelp: Pass process struct to elf_enum_modules and macho_enum_modules.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=58c50e916e04fca478789…
commit 58c50e916e04fca478789f1212691a1946ad211e Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:10:42 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:48 2020 +0200 [WINESYNC] dbghelp: Pass process struct to elf_enum_modules and macho_enum_modules. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 724f433f39f71e8869c49a5960364c5669759b08 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp_private.h | 4 ++-- dll/win32/dbghelp/elf_module.c | 12 ++++-------- dll/win32/dbghelp/macho_module.c | 13 ++++--------- dll/win32/dbghelp/minidump.c | 7 +++++-- sdk/tools/winesync/dbghelp.cfg | 2 +- 5 files changed, 16 insertions(+), 22 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index 4e2d9f414f9..7c164fce219 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -625,7 +625,7 @@ extern DWORD calc_crc32(HANDLE handle) DECLSPEC_HIDDEN; typedef BOOL (*enum_modules_cb)(const WCHAR*, unsigned long addr, void* user); /* elf_module.c */ -extern BOOL elf_enum_modules(HANDLE hProc, enum_modules_cb, void*) DECLSPEC_HIDDEN; +extern BOOL elf_enum_modules(struct process*, enum_modules_cb, void*) DECLSPEC_HIDDEN; extern BOOL elf_fetch_file_info(const WCHAR* name, DWORD_PTR* base, DWORD* size, DWORD* checksum) DECLSPEC_HIDDEN; struct image_file_map; extern BOOL elf_load_debug_info(struct module* module) DECLSPEC_HIDDEN; @@ -637,7 +637,7 @@ struct elf_thunk_area; extern int elf_is_in_thunk_area(unsigned long addr, const struct elf_thunk_area* thunks) DECLSPEC_HIDDEN; /* macho_module.c */ -extern BOOL macho_enum_modules(HANDLE hProc, enum_modules_cb, void*) DECLSPEC_HIDDEN; +extern BOOL macho_enum_modules(struct process*, enum_modules_cb, void*) DECLSPEC_HIDDEN; extern BOOL macho_fetch_file_info(HANDLE process, const WCHAR* name, unsigned long load_addr, DWORD_PTR* base, DWORD* size, DWORD* checksum) DECLSPEC_HIDDEN; extern BOOL macho_load_debug_info(struct process *pcs, struct module* module) DECLSPEC_HIDDEN; extern struct module* diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 0b60524fc44..728025fa405 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1561,21 +1561,17 @@ static BOOL elf_enum_modules_translate(const WCHAR* name, unsigned long load_add * This function doesn't require that someone has called SymInitialize * on this very process. */ -BOOL elf_enum_modules(HANDLE hProc, enum_modules_cb cb, void* user) +BOOL elf_enum_modules(struct process* process, enum_modules_cb cb, void* user) { - struct process pcs; struct elf_info elf_info; BOOL ret; struct elf_enum_user eeu; - memset(&pcs, 0, sizeof(pcs)); - pcs.handle = hProc; elf_info.flags = ELF_INFO_DEBUG_HEADER | ELF_INFO_NAME; - if (!elf_search_loader(&pcs, &elf_info)) return FALSE; - pcs.dbg_hdr_addr = elf_info.dbg_hdr_addr; + elf_info.module_name = NULL; eeu.cb = cb; eeu.user = user; - ret = elf_enum_modules_internal(&pcs, elf_info.module_name, elf_enum_modules_translate, &eeu); + ret = elf_enum_modules_internal(process, elf_info.module_name, elf_enum_modules_translate, &eeu); HeapFree(GetProcessHeap(), 0, (char*)elf_info.module_name); return ret; } @@ -1747,7 +1743,7 @@ BOOL elf_read_wine_loader_dbg_info(struct process* pcs) return FALSE; } -BOOL elf_enum_modules(HANDLE hProc, enum_modules_cb cb, void* user) +BOOL elf_enum_modules(struct process *process, enum_modules_cb cb, void* user) { return FALSE; } diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 193c97b0011..a35ed5db732 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -1843,19 +1843,14 @@ BOOL macho_read_wine_loader_dbg_info(struct process* pcs) * This function doesn't require that someone has called SymInitialize * on this very process. */ -BOOL macho_enum_modules(HANDLE hProc, enum_modules_cb cb, void* user) +BOOL macho_enum_modules(struct process* process, enum_modules_cb cb, void* user) { - struct process pcs; struct macho_info macho_info; BOOL ret; - TRACE("(%p, %p, %p)\n", hProc, cb, user); - memset(&pcs, 0, sizeof(pcs)); - pcs.handle = hProc; + TRACE("(%p, %p, %p)\n", process->handle, cb, user); macho_info.flags = MACHO_INFO_DEBUG_HEADER | MACHO_INFO_NAME; - if (!macho_search_loader(&pcs, &macho_info)) return FALSE; - pcs.dbg_hdr_addr = macho_info.dbg_hdr_addr; - ret = macho_enum_modules_internal(&pcs, macho_info.module_name, cb, user); + ret = macho_enum_modules_internal(process, macho_info.module_name, cb, user); HeapFree(GetProcessHeap(), 0, (char*)macho_info.module_name); return ret; } @@ -1949,7 +1944,7 @@ BOOL macho_read_wine_loader_dbg_info(struct process* pcs) return FALSE; } -BOOL macho_enum_modules(HANDLE hProc, enum_modules_cb cb, void* user) +BOOL macho_enum_modules(struct process *process, enum_modules_cb cb, void* user) { return FALSE; } diff --git a/dll/win32/dbghelp/minidump.c b/dll/win32/dbghelp/minidump.c index 04652c040cf..899a88b8d15 100644 --- a/dll/win32/dbghelp/minidump.c +++ b/dll/win32/dbghelp/minidump.c @@ -346,8 +346,11 @@ static void fetch_modules_info(struct dump_context* dc) * And it's always a good idea to have a trace of the loaded ELF modules for * a given application in a post mortem debugging condition. */ - elf_enum_modules(dc->process->handle, fetch_elf_module_info_cb, dc); - macho_enum_modules(dc->process->handle, fetch_macho_module_info_cb, dc); + if (dc->process->dbg_hdr_addr) + { + elf_enum_modules(dc->process, fetch_elf_module_info_cb, dc); + macho_enum_modules(dc->process, fetch_macho_module_info_cb, dc); + } } static void fetch_module_versioninfo(LPCWSTR filename, VS_FIXEDFILEINFO* ffi) diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 00802ca02d5..e3201a2b01f 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: 6b3018d03da983050516821caa2aada2f4814678 + wine: 724f433f39f71e8869c49a5960364c5669759b08
4 years, 3 months
1
0
0
0
[reactos] 107/179: [WINESYNC] dbghelp: Store process struct pointer in dump context.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ca7d01b33f8ba90f8ce5a…
commit ca7d01b33f8ba90f8ce5a62e58578b01d907ef5b Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:10:42 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:48 2020 +0200 [WINESYNC] dbghelp: Store process struct pointer in dump context. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 6b3018d03da983050516821caa2aada2f4814678 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/cpu_x86_64.c | 4 +-- dll/win32/dbghelp/dbghelp_private.h | 2 +- dll/win32/dbghelp/minidump.c | 49 +++++++++++++++++++++++-------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/dll/win32/dbghelp/cpu_x86_64.c b/dll/win32/dbghelp/cpu_x86_64.c index 83c1fb16bf7..57cfa112446 100644 --- a/dll/win32/dbghelp/cpu_x86_64.c +++ b/dll/win32/dbghelp/cpu_x86_64.c @@ -929,7 +929,7 @@ static BOOL x86_64_fetch_minidump_module(struct dump_context* dc, unsigned index const RUNTIME_FUNCTION* rtf; ULONG size; - if (!(pcs = process_find_by_handle(dc->hProcess)) || + if (!(pcs = process_find_by_handle(dc->process->handle)) || !(module = module_find_by_addr(pcs, dc->modules[index].base, DMT_UNKNOWN))) return FALSE; rtf = (const RUNTIME_FUNCTION*)pe_map_directory(module, IMAGE_DIRECTORY_ENTRY_EXCEPTION, &size); @@ -947,7 +947,7 @@ static BOOL x86_64_fetch_minidump_module(struct dump_context* dc, unsigned index /* we need to read into the other process */ /* rtf = (RUNTIME_FUNCTION*)(module->module.BaseOfImage + (rtf->UnwindData & ~1)); */ } - if (ReadProcessMemory(dc->hProcess, + if (ReadProcessMemory(dc->process->handle, (void*)(dc->modules[index].base + rtf->UnwindData), &ui, sizeof(ui), NULL)) minidump_add_memory_block(dc, dc->modules[index].base + rtf->UnwindData, diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index d98ccedf64a..4e2d9f414f9 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -529,7 +529,7 @@ struct dump_thread struct dump_context { /* process & thread information */ - HANDLE hProcess; + struct process *process; DWORD pid; unsigned flags_out; /* thread information */ diff --git a/dll/win32/dbghelp/minidump.c b/dll/win32/dbghelp/minidump.c index a6524771a80..04652c040cf 100644 --- a/dll/win32/dbghelp/minidump.c +++ b/dll/win32/dbghelp/minidump.c @@ -93,7 +93,7 @@ static void fetch_thread_stack(struct dump_context* dc, const void* teb_addr, NT_TIB tib; ADDRESS64 addr; - if (ReadProcessMemory(dc->hProcess, teb_addr, &tib, sizeof(tib), NULL) && + if (ReadProcessMemory(dc->process->handle, teb_addr, &tib, sizeof(tib), NULL) && dbghelp_current_cpu && dbghelp_current_cpu->get_addr(NULL /* FIXME */, ctx, cpu_addr_stack, &addr) && addr.Mode == AddrModeFlat) { @@ -170,9 +170,9 @@ static BOOL fetch_thread_info(struct dump_context* dc, int thd_idx, { EXCEPTION_POINTERS ep; - ReadProcessMemory(dc->hProcess, except->ExceptionPointers, + ReadProcessMemory(dc->process->handle, except->ExceptionPointers, &ep, sizeof(ep), NULL); - ReadProcessMemory(dc->hProcess, ep.ContextRecord, + ReadProcessMemory(dc->process->handle, ep.ContextRecord, &lctx, sizeof(lctx), NULL); pctx = &lctx; } @@ -215,7 +215,7 @@ static BOOL add_module(struct dump_context* dc, const WCHAR* name, return FALSE; } if (is_elf || - !GetModuleFileNameExW(dc->hProcess, (HMODULE)(DWORD_PTR)base, + !GetModuleFileNameExW(dc->process->handle, (HMODULE)(DWORD_PTR)base, dc->modules[dc->num_modules].name, ARRAY_SIZE(dc->modules[dc->num_modules].name))) lstrcpynW(dc->modules[dc->num_modules].name, name, @@ -243,7 +243,7 @@ static BOOL WINAPI fetch_pe_module_info_cb(PCWSTR name, DWORD64 base, ULONG size if (!validate_addr64(base)) return FALSE; - if (pe_load_nt_header(dc->hProcess, base, &nth)) + if (pe_load_nt_header(dc->process->handle, base, &nth)) add_module(user, name, base, size, nth.FileHeader.TimeDateStamp, nth.OptionalHeader.CheckSum, FALSE); @@ -289,7 +289,7 @@ static BOOL fetch_macho_module_info_cb(const WCHAR* name, unsigned long base, /* NB: if we have a non-null base from the live-target use it. If we have * a null base, then grab its base address from Mach-O file. */ - if (!macho_fetch_file_info(dc->hProcess, name, base, &rbase, &size, &checksum)) + if (!macho_fetch_file_info(dc->process->handle, name, base, &rbase, &size, &checksum)) size = checksum = 0; add_module(dc, name, base ? base : rbase, size, 0 /* FIXME */, checksum, TRUE); return TRUE; @@ -323,7 +323,7 @@ static void fetch_memory64_info(struct dump_context* dc) MEMORY_BASIC_INFORMATION mbi; addr = 0; - while (VirtualQueryEx(dc->hProcess, (LPCVOID)addr, &mbi, sizeof(mbi)) != 0) + while (VirtualQueryEx(dc->process->handle, (LPCVOID)addr, &mbi, sizeof(mbi)) != 0) { /* Memory regions with state MEM_COMMIT will be added to the dump */ if (mbi.State == MEM_COMMIT) @@ -340,14 +340,14 @@ static void fetch_memory64_info(struct dump_context* dc) static void fetch_modules_info(struct dump_context* dc) { - EnumerateLoadedModulesW64(dc->hProcess, fetch_pe_module_info_cb, dc); + EnumerateLoadedModulesW64(dc->process->handle, fetch_pe_module_info_cb, dc); /* Since we include ELF modules in a separate stream from the regular PE ones, * we can always include those ELF modules (they don't eat lots of space) * And it's always a good idea to have a trace of the loaded ELF modules for * a given application in a post mortem debugging condition. */ - elf_enum_modules(dc->hProcess, fetch_elf_module_info_cb, dc); - macho_enum_modules(dc->hProcess, fetch_macho_module_info_cb, dc); + elf_enum_modules(dc->process->handle, fetch_elf_module_info_cb, dc); + macho_enum_modules(dc->process->handle, fetch_macho_module_info_cb, dc); } static void fetch_module_versioninfo(LPCWSTR filename, VS_FIXEDFILEINFO* ffi) @@ -447,11 +447,11 @@ static unsigned dump_exception_info(struct dump_context* dc, { EXCEPTION_POINTERS ep; - ReadProcessMemory(dc->hProcess, + ReadProcessMemory(dc->process->handle, except->ExceptionPointers, &ep, sizeof(ep), NULL); - ReadProcessMemory(dc->hProcess, + ReadProcessMemory(dc->process->handle, ep.ExceptionRecord, &rec, sizeof(rec), NULL); - ReadProcessMemory(dc->hProcess, + ReadProcessMemory(dc->process->handle, ep.ContextRecord, &ctx, sizeof(ctx), NULL); prec = &rec; pctx = &ctx; @@ -537,7 +537,7 @@ static unsigned dump_modules(struct dump_context* dc, BOOL dump_elf) MINIDUMP_CALLBACK_OUTPUT cbout; cbin.ProcessId = dc->pid; - cbin.ProcessHandle = dc->hProcess; + cbin.ProcessHandle = dc->process->handle; cbin.CallbackType = ModuleCallback; cbin.u.Module.FullPath = ms->Buffer; @@ -804,7 +804,7 @@ static unsigned dump_threads(struct dump_context* dc, MINIDUMP_CALLBACK_OUTPUT cbout; cbin.ProcessId = dc->pid; - cbin.ProcessHandle = dc->hProcess; + cbin.ProcessHandle = dc->process->handle; cbin.CallbackType = ThreadCallback; cbin.u.Thread.ThreadId = dc->threads[i].tid; cbin.u.Thread.ThreadHandle = 0; /* FIXME */ @@ -881,7 +881,7 @@ static unsigned dump_memory_info(struct dump_context* dc) for (pos = 0; pos < dc->mem[i].size; pos += sizeof(tmp)) { len = min(dc->mem[i].size - pos, sizeof(tmp)); - if (ReadProcessMemory(dc->hProcess, + if (ReadProcessMemory(dc->process->handle, (void*)(DWORD_PTR)(dc->mem[i].base + pos), tmp, len, NULL)) WriteFile(dc->hFile, tmp, len, &written, NULL); @@ -939,7 +939,7 @@ static unsigned dump_memory64_info(struct dump_context* dc) for (pos = 0; pos < dc->mem64[i].size; pos += sizeof(tmp)) { len = min(dc->mem64[i].size - pos, sizeof(tmp)); - if (ReadProcessMemory(dc->hProcess, + if (ReadProcessMemory(dc->process->handle, (void*)(ULONG_PTR)(dc->mem64[i].base + pos), tmp, len, NULL)) WriteFile(dc->hFile, tmp, len, &written, NULL); @@ -982,8 +982,18 @@ BOOL WINAPI MiniDumpWriteDump(HANDLE hProcess, DWORD pid, HANDLE hFile, MINIDUMP_DIRECTORY mdDir; DWORD i, nStreams, idx_stream; struct dump_context dc; + BOOL sym_initialized = FALSE; + + if (!(dc.process = process_find_by_handle(hProcess))) + { + if (!(sym_initialized = SymInitializeW(hProcess, NULL, TRUE))) + { + WARN("failed to initialize process\n"); + return FALSE; + } + dc.process = process_find_by_handle(hProcess); + } - dc.hProcess = hProcess; dc.hFile = hFile; dc.pid = pid; dc.modules = NULL; @@ -1119,6 +1129,9 @@ BOOL WINAPI MiniDumpWriteDump(HANDLE hProcess, DWORD pid, HANDLE hFile, for (i = idx_stream; i < nStreams; i++) writeat(&dc, mdHead.StreamDirectoryRva + i * sizeof(emptyDir), &emptyDir, sizeof(emptyDir)); + if (sym_initialized) + SymCleanup(hProcess); + HeapFree(GetProcessHeap(), 0, dc.mem); HeapFree(GetProcessHeap(), 0, dc.mem64); HeapFree(GetProcessHeap(), 0, dc.modules); diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index b103048082c..00802ca02d5 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: be9072ec743e22ed6a20288e5539b8ba307f9280 + wine: 6b3018d03da983050516821caa2aada2f4814678
4 years, 3 months
1
0
0
0
[reactos] 106/179: [WINESYNC] dbghelp: Use search_dll_path to load seach macho files.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fbc5f830fc2ea756fbbd1…
commit fbc5f830fc2ea756fbbd1908bb64f004bff7b739 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:10:41 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:48 2020 +0200 [WINESYNC] dbghelp: Use search_dll_path to load seach macho files. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id be9072ec743e22ed6a20288e5539b8ba307f9280 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/macho_module.c | 41 +--------------------------------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 2 insertions(+), 41 deletions(-) diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 038319ce35c..193c97b0011 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -48,7 +48,6 @@ #define WIN32_NO_STATUS #include "dbghelp_private.h" #include "winternl.h" -#include "wine/library.h" #include "wine/debug.h" #include "wine/heap.h" #include "image_private.h" @@ -1536,44 +1535,6 @@ static BOOL macho_load_file_cb(void *param, HANDLE handle, const WCHAR *filename return macho_load_file(macho_load->process, filename, macho_load->load_addr, macho_load->macho_info); } -/****************************************************************** - * macho_load_file_from_dll_path - * - * Tries to load a Mach-O file from the dll path - */ -static BOOL macho_load_file_from_dll_path(struct process* pcs, - const WCHAR* filename, - unsigned long load_addr, - struct macho_info* macho_info) -{ - BOOL ret = FALSE; - unsigned int index = 0; - const char *path; - - TRACE("(%p/%p, %s, 0x%08lx, %p)\n", pcs, pcs->handle, debugstr_w(filename), load_addr, - macho_info); - - while (!ret && (path = wine_dll_enum_load_path( index++ ))) - { - WCHAR *name; - unsigned len; - - len = MultiByteToWideChar(CP_UNIXCP, 0, path, -1, NULL, 0); - - name = HeapAlloc( GetProcessHeap(), 0, - (len + lstrlenW(filename) + 2) * sizeof(WCHAR) ); - - if (!name) break; - MultiByteToWideChar(CP_UNIXCP, 0, path, -1, name, len); - strcatW( name, S_SlashW ); - strcatW( name, filename ); - ret = macho_load_file(pcs, name, load_addr, macho_info); - HeapFree( GetProcessHeap(), 0, name ); - } - TRACE(" => %d\n", ret); - return ret; -} - /****************************************************************** * macho_search_and_load_file * @@ -1628,7 +1589,7 @@ static BOOL macho_search_and_load_file(struct process* pcs, const WCHAR* filenam ret = search_unix_path(p, fallback, macho_load_file_cb, &load_params); } if (!ret && p == filename) - ret = macho_load_file_from_dll_path(pcs, filename, load_addr, macho_info); + ret = search_dll_path(filename, macho_load_file_cb, &load_params); return ret; } diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 0a7da2e8203..b103048082c 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: c3bb866bfc53b8c3b7b7355cb8311325a40a0a6b + wine: be9072ec743e22ed6a20288e5539b8ba307f9280
4 years, 3 months
1
0
0
0
[reactos] 105/179: [WINESYNC] dbghelp: Use search_unix_path to load seach macho files.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8194b5dee6d4d1341803e…
commit 8194b5dee6d4d1341803e848809e574166a1fb46 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:10:41 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:47 2020 +0200 [WINESYNC] dbghelp: Use search_unix_path to load seach macho files. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id c3bb866bfc53b8c3b7b7355cb8311325a40a0a6b by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/macho_module.c | 63 +++++++++++----------------------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 18 insertions(+), 47 deletions(-) diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 4bc0a3e903c..038319ce35c 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -1523,49 +1523,17 @@ leave: return ret; } -/****************************************************************** - * macho_load_file_from_path - * Tries to load a Mach-O file from a set of paths (separated by ':') - */ -static BOOL macho_load_file_from_path(struct process* pcs, - const WCHAR* filename, - unsigned long load_addr, - const char* path, - struct macho_info* macho_info) +struct macho_load_params { - BOOL ret = FALSE; - WCHAR *s, *t, *fn; - WCHAR* pathW = NULL; - unsigned len; - - TRACE("(%p/%p, %s, 0x%08lx, %s, %p)\n", pcs, pcs->handle, debugstr_w(filename), load_addr, - debugstr_a(path), macho_info); - - if (!path) return FALSE; - - len = MultiByteToWideChar(CP_UNIXCP, 0, path, -1, NULL, 0); - pathW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - if (!pathW) return FALSE; - MultiByteToWideChar(CP_UNIXCP, 0, path, -1, pathW, len); - - for (s = pathW; s && *s; s = (t) ? (t+1) : NULL) - { - t = strchrW(s, ':'); - if (t) *t = '\0'; - fn = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(filename) + 1 + lstrlenW(s) + 1) * sizeof(WCHAR)); - if (!fn) break; - strcpyW(fn, s); - strcatW(fn, S_SlashW); - strcatW(fn, filename); - ret = macho_load_file(pcs, fn, load_addr, macho_info); - HeapFree(GetProcessHeap(), 0, fn); - if (ret) break; - s = (t) ? (t+1) : NULL; - } + struct process *process; + ULONG_PTR load_addr; + struct macho_info *macho_info; +}; - TRACE(" => %d\n", ret); - HeapFree(GetProcessHeap(), 0, pathW); - return ret; +static BOOL macho_load_file_cb(void *param, HANDLE handle, const WCHAR *filename) +{ + struct macho_load_params *macho_load = param; + return macho_load_file(macho_load->process, filename, macho_load->load_addr, macho_load->macho_info); } /****************************************************************** @@ -1619,6 +1587,7 @@ static BOOL macho_search_and_load_file(struct process* pcs, const WCHAR* filenam struct module* module; static const WCHAR S_libstdcPPW[] = {'l','i','b','s','t','d','c','+','+','\0'}; const WCHAR* p; + struct macho_load_params load_params; TRACE("(%p/%p, %s, 0x%08lx, %p)\n", pcs, pcs->handle, debugstr_w(filename), load_addr, macho_info); @@ -1633,17 +1602,19 @@ static BOOL macho_search_and_load_file(struct process* pcs, const WCHAR* filenam if (strstrW(filename, S_libstdcPPW)) return FALSE; /* We know we can't do it */ + load_params.process = pcs; + load_params.load_addr = load_addr; + load_params.macho_info = macho_info; + /* If has no directories, try PATH first. */ p = file_name(filename); if (p == filename) { - ret = macho_load_file_from_path(pcs, filename, load_addr, - getenv("PATH"), macho_info); + ret = search_unix_path(filename, getenv("PATH"), macho_load_file_cb, &load_params); } /* Try DYLD_LIBRARY_PATH, with just the filename (no directories). */ if (!ret) - ret = macho_load_file_from_path(pcs, p, load_addr, - getenv("DYLD_LIBRARY_PATH"), macho_info); + ret = search_unix_path(p, getenv("DYLD_LIBRARY_PATH"), macho_load_file_cb, &load_params); /* Try the path as given. */ if (!ret) @@ -1654,7 +1625,7 @@ static BOOL macho_search_and_load_file(struct process* pcs, const WCHAR* filenam const char* fallback = getenv("DYLD_FALLBACK_LIBRARY_PATH"); if (!fallback) fallback = "/usr/local/lib:/lib:/usr/lib"; - ret = macho_load_file_from_path(pcs, p, load_addr, fallback, macho_info); + ret = search_unix_path(p, fallback, macho_load_file_cb, &load_params); } if (!ret && p == filename) ret = macho_load_file_from_dll_path(pcs, filename, load_addr, macho_info); diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index df209bd3ca0..0a7da2e8203 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: ca49552f646bf30b492da4668745f9f65b9de18d + wine: c3bb866bfc53b8c3b7b7355cb8311325a40a0a6b
4 years, 3 months
1
0
0
0
← Newer
1
...
14
15
16
17
18
19
20
...
39
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Results per page:
10
25
50
100
200