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
2025
May
April
March
February
January
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
----- 2025 -----
May 2025
April 2025
March 2025
February 2025
January 2025
----- 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] 124/179: [WINESYNC] dbghelp: Use DWARF registry mapping quirk only for actual macho modules.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d6dca1da171f0768ac8a0…
commit d6dca1da171f0768ac8a0530f9e9febc6f03008d Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 18:46:08 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:50 2020 +0200 [WINESYNC] dbghelp: Use DWARF registry mapping quirk only for actual macho modules. Fixes handling DWARF in PE on macOS. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 3b6c268380d703079fa3c5ca06f67b6feb02487f by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/cpu_i386.c | 4 +--- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dll/win32/dbghelp/cpu_i386.c b/dll/win32/dbghelp/cpu_i386.c index 1528b603221..78f477115d7 100644 --- a/dll/win32/dbghelp/cpu_i386.c +++ b/dll/win32/dbghelp/cpu_i386.c @@ -526,13 +526,11 @@ static unsigned i386_map_dwarf_register(unsigned regno, const struct module* mod case 3: reg = CV_REG_EBX; break; case 4: case 5: -#ifdef __APPLE__ /* On OS X, DWARF eh_frame uses a different mapping for the registers. It's apparently the mapping as emitted by GCC, at least at some point in its history. */ - if (eh_frame) + if (eh_frame && module->type == DMT_MACHO) reg = (regno == 4) ? CV_REG_EBP : CV_REG_ESP; else -#endif reg = (regno == 4) ? CV_REG_ESP : CV_REG_EBP; break; case 6: reg = CV_REG_ESI; break; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 4cfa407ebcf..85f89bf51d8 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: 5d8067c6088a30cdb4fe6945e6ae1cda0da85467 + wine: 3b6c268380d703079fa3c5ca06f67b6feb02487f
4 years, 8 months
1
0
0
0
[reactos] 123/179: [WINESYNC] dbghelp: Pass module to map_dwarf_register.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0b8d0e0a613a3486c91eb…
commit 0b8d0e0a613a3486c91eb7aa168dfc912c6a2ec8 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 18:45:02 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:50 2020 +0200 [WINESYNC] dbghelp: Pass module to map_dwarf_register. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 5d8067c6088a30cdb4fe6945e6ae1cda0da85467 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/cpu_arm.c | 2 +- dll/win32/dbghelp/cpu_arm64.c | 2 +- dll/win32/dbghelp/cpu_i386.c | 2 +- dll/win32/dbghelp/cpu_ppc.c | 2 +- dll/win32/dbghelp/cpu_x86_64.c | 2 +- dll/win32/dbghelp/dbghelp_private.h | 2 +- dll/win32/dbghelp/dwarf.c | 84 ++++++++++++++++++------------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 8 files changed, 49 insertions(+), 49 deletions(-) diff --git a/dll/win32/dbghelp/cpu_arm.c b/dll/win32/dbghelp/cpu_arm.c index 9385e2e4eb5..a05bd90c9ae 100644 --- a/dll/win32/dbghelp/cpu_arm.c +++ b/dll/win32/dbghelp/cpu_arm.c @@ -161,7 +161,7 @@ static BOOL arm_stack_walk(struct cpu_stack_walk *csw, STACKFRAME64 *frame, } #endif -static unsigned arm_map_dwarf_register(unsigned regno, BOOL eh_frame) +static unsigned arm_map_dwarf_register(unsigned regno, const struct module* module, BOOL eh_frame) { if (regno <= 15) return CV_ARM_R0 + regno; if (regno == 128) return CV_ARM_CPSR; diff --git a/dll/win32/dbghelp/cpu_arm64.c b/dll/win32/dbghelp/cpu_arm64.c index f3ab0936ebe..515294fe95c 100644 --- a/dll/win32/dbghelp/cpu_arm64.c +++ b/dll/win32/dbghelp/cpu_arm64.c @@ -155,7 +155,7 @@ static BOOL arm64_stack_walk(struct cpu_stack_walk* csw, STACKFRAME64 *frame, } #endif -static unsigned arm64_map_dwarf_register(unsigned regno, BOOL eh_frame) +static unsigned arm64_map_dwarf_register(unsigned regno, const struct module* module, BOOL eh_frame) { if (regno <= 28) return CV_ARM64_X0 + regno; if (regno == 29) return CV_ARM64_FP; diff --git a/dll/win32/dbghelp/cpu_i386.c b/dll/win32/dbghelp/cpu_i386.c index 6c10107ba3d..1528b603221 100644 --- a/dll/win32/dbghelp/cpu_i386.c +++ b/dll/win32/dbghelp/cpu_i386.c @@ -514,7 +514,7 @@ done_err: } #endif /* DBGHELP_STATIC_LIB */ -static unsigned i386_map_dwarf_register(unsigned regno, BOOL eh_frame) +static unsigned i386_map_dwarf_register(unsigned regno, const struct module* module, BOOL eh_frame) { unsigned reg; diff --git a/dll/win32/dbghelp/cpu_ppc.c b/dll/win32/dbghelp/cpu_ppc.c index e1e1cb332ca..80db2be704b 100644 --- a/dll/win32/dbghelp/cpu_ppc.c +++ b/dll/win32/dbghelp/cpu_ppc.c @@ -55,7 +55,7 @@ static BOOL ppc_stack_walk(struct cpu_stack_walk* csw, STACKFRAME64 *frame, return FALSE; } -static unsigned ppc_map_dwarf_register(unsigned regno, BOOL eh_frame) +static unsigned ppc_map_dwarf_register(unsigned regno, const struct module* module, BOOL eh_frame) { FIXME("not done\n"); return 0; diff --git a/dll/win32/dbghelp/cpu_x86_64.c b/dll/win32/dbghelp/cpu_x86_64.c index 57cfa112446..f0c12207357 100644 --- a/dll/win32/dbghelp/cpu_x86_64.c +++ b/dll/win32/dbghelp/cpu_x86_64.c @@ -724,7 +724,7 @@ static void* x86_64_find_runtime_function(struct module* module, DWORD64 addr return NULL; } -static unsigned x86_64_map_dwarf_register(unsigned regno, BOOL eh_frame) +static unsigned x86_64_map_dwarf_register(unsigned regno, const struct module* module, BOOL eh_frame) { unsigned reg; diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index 6608c78ad53..521f64881ad 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -587,7 +587,7 @@ struct cpu void* (*find_runtime_function)(struct module*, DWORD64 addr); /* dwarf dedicated information */ - unsigned (*map_dwarf_register)(unsigned regno, BOOL eh_frame); + unsigned (*map_dwarf_register)(unsigned regno, const struct module* module, BOOL eh_frame); /* context related manipulation */ void * (*fetch_context_reg)(union ctx *ctx, unsigned regno, unsigned *size); diff --git a/dll/win32/dbghelp/dwarf.c b/dll/win32/dbghelp/dwarf.c index bf7fb9ce232..04985003653 100644 --- a/dll/win32/dbghelp/dwarf.c +++ b/dll/win32/dbghelp/dwarf.c @@ -655,18 +655,18 @@ static void dwarf2_load_one_entry(dwarf2_parse_context_t*, dwarf2_debug_info_t*) #define Wine_DW_no_register 0x7FFFFFFF -static unsigned dwarf2_map_register(int regno) +static unsigned dwarf2_map_register(int regno, const struct module* module) { if (regno == Wine_DW_no_register) { FIXME("What the heck map reg 0x%x\n",regno); return 0; } - return dbghelp_current_cpu->map_dwarf_register(regno, FALSE); + return dbghelp_current_cpu->map_dwarf_register(regno, module, FALSE); } static enum location_error -compute_location(dwarf2_traverse_context_t* ctx, struct location* loc, +compute_location(const struct module *module, dwarf2_traverse_context_t* ctx, struct location* loc, HANDLE hproc, const struct location* frame) { DWORD_PTR tmp, stack[64]; @@ -693,7 +693,7 @@ compute_location(dwarf2_traverse_context_t* ctx, struct location* loc, */ if (!piece_found) { - DWORD cvreg = dwarf2_map_register(op - DW_OP_reg0); + DWORD cvreg = dwarf2_map_register(op - DW_OP_reg0, module); if (loc->reg != Wine_DW_no_register) FIXME("Only supporting one reg (%s/%d -> %s/%d)\n", dbghelp_current_cpu->fetch_regname(loc->reg), loc->reg, @@ -710,7 +710,7 @@ compute_location(dwarf2_traverse_context_t* ctx, struct location* loc, */ if (!piece_found) { - DWORD cvreg = dwarf2_map_register(op - DW_OP_breg0); + DWORD cvreg = dwarf2_map_register(op - DW_OP_breg0, module); if (loc->reg != Wine_DW_no_register) FIXME("Only supporting one breg (%s/%d -> %s/%d)\n", dbghelp_current_cpu->fetch_regname(loc->reg), loc->reg, @@ -769,7 +769,7 @@ compute_location(dwarf2_traverse_context_t* ctx, struct location* loc, { if (loc->reg != Wine_DW_no_register) FIXME("Only supporting one reg\n"); - loc->reg = dwarf2_map_register(tmp); + loc->reg = dwarf2_map_register(tmp, module); } loc->kind = loc_register; break; @@ -777,7 +777,7 @@ compute_location(dwarf2_traverse_context_t* ctx, struct location* loc, tmp = dwarf2_leb128_as_unsigned(ctx); if (loc->reg != Wine_DW_no_register) FIXME("Only supporting one regx\n"); - loc->reg = dwarf2_map_register(tmp); + loc->reg = dwarf2_map_register(tmp, module); stack[++stk] = dwarf2_leb128_as_signed(ctx); loc->kind = loc_regrel; break; @@ -936,7 +936,7 @@ static BOOL dwarf2_compute_location_attr(dwarf2_parse_context_t* ctx, lctx.end_data = xloc.u.block.ptr + xloc.u.block.size; lctx.word_size = ctx->module->format_info[DFI_DWARF]->u.dwarf2_info->word_size; - err = compute_location(&lctx, loc, NULL, frame); + err = compute_location(ctx->module, &lctx, loc, NULL, frame); if (err < 0) { loc->kind = loc_error; @@ -949,7 +949,7 @@ static BOOL dwarf2_compute_location_attr(dwarf2_parse_context_t* ctx, *ptr = xloc.u.block.size; memcpy(ptr + 1, xloc.u.block.ptr, xloc.u.block.size); loc->offset = (ULONG_PTR)ptr; - compute_location(&lctx, loc, NULL, frame); + compute_location(ctx->module, &lctx, loc, NULL, frame); } } return TRUE; @@ -2546,7 +2546,7 @@ static enum location_error loc_compute_frame(struct process* pcs, modfmt->u.dwarf2_info->debug_loc.address + pframe->offset, ip, &lctx)) return loc_err_out_of_scope; - if ((err = compute_location(&lctx, frame, pcs->handle, NULL)) < 0) return err; + if ((err = compute_location(modfmt->module, &lctx, frame, pcs->handle, NULL)) < 0) return err; if (frame->kind >= loc_user) { WARN("Couldn't compute runtime frame location\n"); @@ -2800,7 +2800,7 @@ static int valid_reg(ULONG_PTR reg) return (reg < NB_FRAME_REGS); } -static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, +static void execute_cfa_instructions(struct module* module, dwarf2_traverse_context_t* ctx, ULONG_PTR last_ip, struct frame_info *info) { while (ctx->data < ctx->end_data && info->ip <= last_ip + info->signal_frame) @@ -2825,7 +2825,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_offset %s, %ld\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE)), + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), offset); info->state.regs[reg] = offset; info->state.rules[reg] = RULE_CFA_OFFSET; @@ -2837,7 +2837,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_restore %s\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE))); + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); info->state.rules[reg] = RULE_UNSET; break; } @@ -2884,7 +2884,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_offset_extended %s, %ld\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE)), + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), offset); info->state.regs[reg] = offset; info->state.rules[reg] = RULE_CFA_OFFSET; @@ -2896,7 +2896,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_restore_extended %s\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE))); + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); info->state.rules[reg] = RULE_UNSET; break; } @@ -2906,7 +2906,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_undefined %s\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE))); + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); info->state.rules[reg] = RULE_UNDEFINED; break; } @@ -2916,7 +2916,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_same_value %s\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE))); + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); info->state.regs[reg] = reg; info->state.rules[reg] = RULE_SAME; break; @@ -2928,8 +2928,8 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg) || !valid_reg(reg2)) break; TRACE("%lx: DW_CFA_register %s == %s\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE)), - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg2, TRUE))); + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg2, module, TRUE))); info->state.regs[reg] = reg2; info->state.rules[reg] = RULE_OTHER_REG; break; @@ -2957,7 +2957,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_def_cfa %s, %ld\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE)), + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), offset); info->state.cfa_reg = reg; info->state.cfa_offset = offset; @@ -2970,7 +2970,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_def_cfa_register %s\n", info->ip, - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE))); + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE))); info->state.cfa_reg = reg; info->state.cfa_rule = RULE_CFA_OFFSET; break; @@ -3004,7 +3004,7 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, if (!valid_reg(reg)) break; TRACE("%lx: DW_CFA_%sexpression %s %lx-%lx\n", info->ip, (op == DW_CFA_expression) ? "" : "val_", - dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, TRUE)), + dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)), expr, expr + len); info->state.regs[reg] = expr; info->state.rules[reg] = (op == DW_CFA_expression) ? RULE_EXPRESSION : RULE_VAL_EXPRESSION; @@ -3027,10 +3027,10 @@ static void execute_cfa_instructions(dwarf2_traverse_context_t* ctx, } /* retrieve a context register from its dwarf number */ -static DWORD64 get_context_reg(struct cpu_stack_walk *csw, union ctx *context, +static DWORD64 get_context_reg(const struct module* module, struct cpu_stack_walk *csw, union ctx *context, ULONG_PTR dw_reg) { - unsigned regno = csw->cpu->map_dwarf_register(dw_reg, TRUE), sz; + unsigned regno = csw->cpu->map_dwarf_register(dw_reg, module, TRUE), sz; void* ptr = csw->cpu->fetch_context_reg(context, regno, &sz); if (sz == 8) @@ -3043,10 +3043,10 @@ static DWORD64 get_context_reg(struct cpu_stack_walk *csw, union ctx *context, } /* set a context register from its dwarf number */ -static void set_context_reg(struct cpu_stack_walk* csw, union ctx *context, +static void set_context_reg(const struct module* module, struct cpu_stack_walk* csw, union ctx *context, ULONG_PTR dw_reg, ULONG_PTR val, BOOL isdebuggee) { - unsigned regno = csw->cpu->map_dwarf_register(dw_reg, TRUE), sz; + unsigned regno = csw->cpu->map_dwarf_register(dw_reg, module, TRUE), sz; ULONG_PTR* ptr = csw->cpu->fetch_context_reg(context, regno, &sz); if (isdebuggee) @@ -3077,12 +3077,12 @@ static void set_context_reg(struct cpu_stack_walk* csw, union ctx *context, } /* copy a register from one context to another using dwarf number */ -static void copy_context_reg(struct cpu_stack_walk *csw, +static void copy_context_reg(const struct module* module, struct cpu_stack_walk *csw, union ctx *dstcontext, ULONG_PTR dwregdst, union ctx *srccontext, ULONG_PTR dwregsrc) { - unsigned regdstno = csw->cpu->map_dwarf_register(dwregdst, TRUE), szdst; - unsigned regsrcno = csw->cpu->map_dwarf_register(dwregsrc, TRUE), szsrc; + unsigned regdstno = csw->cpu->map_dwarf_register(dwregdst, module, TRUE), szdst; + unsigned regsrcno = csw->cpu->map_dwarf_register(dwregsrc, module, TRUE), szsrc; ULONG_PTR* ptrdst = csw->cpu->fetch_context_reg(dstcontext, regdstno, &szdst); ULONG_PTR* ptrsrc = csw->cpu->fetch_context_reg(srccontext, regsrcno, &szsrc); @@ -3117,9 +3117,9 @@ static ULONG_PTR eval_expression(const struct module* module, struct cpu_stack_w if (opcode >= DW_OP_lit0 && opcode <= DW_OP_lit31) stack[++sp] = opcode - DW_OP_lit0; else if (opcode >= DW_OP_reg0 && opcode <= DW_OP_reg31) - stack[++sp] = get_context_reg(csw, context, opcode - DW_OP_reg0); + stack[++sp] = get_context_reg(module, csw, context, opcode - DW_OP_reg0); else if (opcode >= DW_OP_breg0 && opcode <= DW_OP_breg31) - stack[++sp] = get_context_reg(csw, context, opcode - DW_OP_breg0) + stack[++sp] = get_context_reg(module, csw, context, opcode - DW_OP_breg0) + dwarf2_leb128_as_signed(&ctx); else switch (opcode) { @@ -3178,12 +3178,12 @@ static ULONG_PTR eval_expression(const struct module* module, struct cpu_stack_w stack[++sp] = dwarf2_parse_augmentation_ptr(&ctx, tmp); break; case DW_OP_regx: - stack[++sp] = get_context_reg(csw, context, dwarf2_leb128_as_unsigned(&ctx)); + stack[++sp] = get_context_reg(module, csw, context, dwarf2_leb128_as_unsigned(&ctx)); break; case DW_OP_bregx: reg = dwarf2_leb128_as_unsigned(&ctx); tmp = dwarf2_leb128_as_signed(&ctx); - stack[++sp] = get_context_reg(csw, context, reg) + tmp; + stack[++sp] = get_context_reg(module, csw, context, reg) + tmp; break; case DW_OP_deref_size: sz = dwarf2_parse_byte(&ctx); @@ -3230,7 +3230,7 @@ static void apply_frame_state(const struct module* module, struct cpu_stack_walk *cfa = eval_expression(module, csw, (const unsigned char*)state->cfa_offset, context); break; default: - *cfa = get_context_reg(csw, context, state->cfa_reg) + state->cfa_offset; + *cfa = get_context_reg(module, csw, context, state->cfa_reg) + state->cfa_offset; break; } if (!*cfa) return; @@ -3244,18 +3244,18 @@ static void apply_frame_state(const struct module* module, struct cpu_stack_walk case RULE_SAME: break; case RULE_CFA_OFFSET: - set_context_reg(csw, &new_context, i, *cfa + state->regs[i], TRUE); + set_context_reg(module, csw, &new_context, i, *cfa + state->regs[i], TRUE); break; case RULE_OTHER_REG: - copy_context_reg(csw, &new_context, i, context, state->regs[i]); + copy_context_reg(module, csw, &new_context, i, context, state->regs[i]); break; case RULE_EXPRESSION: value = eval_expression(module, csw, (const unsigned char*)state->regs[i], context); - set_context_reg(csw, &new_context, i, value, TRUE); + set_context_reg(module, csw, &new_context, i, value, TRUE); break; case RULE_VAL_EXPRESSION: value = eval_expression(module, csw, (const unsigned char*)state->regs[i], context); - set_context_reg(csw, &new_context, i, value, FALSE); + set_context_reg(module, csw, &new_context, i, value, FALSE); break; } } @@ -3307,11 +3307,11 @@ BOOL dwarf2_virtual_unwind(struct cpu_stack_walk *csw, ULONG_PTR ip, TRACE("function %lx/%lx code_align %lu data_align %ld retaddr %s\n", ip, info.ip, info.code_align, info.data_align, - csw->cpu->fetch_regname(csw->cpu->map_dwarf_register(info.retaddr_reg, TRUE))); + csw->cpu->fetch_regname(csw->cpu->map_dwarf_register(info.retaddr_reg, pair.effective, TRUE))); /* if at very beginning of function, return and use default unwinder */ if (ip == info.ip) return FALSE; - execute_cfa_instructions(&cie_ctx, ip, &info); + execute_cfa_instructions(pair.effective, &cie_ctx, ip, &info); if (info.aug_z_format) /* get length of augmentation data */ { @@ -3322,7 +3322,7 @@ BOOL dwarf2_virtual_unwind(struct cpu_stack_walk *csw, ULONG_PTR ip, dwarf2_parse_augmentation_ptr(&fde_ctx, info.lsda_encoding); /* handler_data */ if (end) fde_ctx.data = end; - execute_cfa_instructions(&fde_ctx, ip, &info); + execute_cfa_instructions(pair.effective, &fde_ctx, ip, &info); /* if there is no information about retaddr, use default unwinder */ if (info.state.rules[info.retaddr_reg] == RULE_UNSET) return FALSE; @@ -3375,7 +3375,7 @@ static void dwarf2_location_compute(struct process* pcs, } do_compute: /* now get the variable */ - err = compute_location(&lctx, loc, pcs->handle, &frame); + err = compute_location(modfmt->module, &lctx, loc, pcs->handle, &frame); break; case loc_register: case loc_regrel: diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 89e893dadfe..4cfa407ebcf 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: f7a091af4812ef692fb2b1ec835b8146668aec5c + wine: 5d8067c6088a30cdb4fe6945e6ae1cda0da85467
4 years, 8 months
1
0
0
0
[reactos] 122/179: [WINESYNC] dbghelp: Define NT_GNU_BUILD_ID regardless of whether __ELF__ is defined.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e656f48c38be87b0ee646…
commit e656f48c38be87b0ee6467a2f2a09ea596ea022b Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 18:45:01 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:50 2020 +0200 [WINESYNC] dbghelp: Define NT_GNU_BUILD_ID regardless of whether __ELF__ is defined. Signed-off-by: Gerald Pfeifer <gerald(a)pfeifer.com> Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id f7a091af4812ef692fb2b1ec835b8146668aec5c by Gerald Pfeifer <gerald(a)pfeifer.com> --- dll/win32/dbghelp/image_private.h | 5 +---- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/dll/win32/dbghelp/image_private.h b/dll/win32/dbghelp/image_private.h index e07dea4d267..e614fda237c 100644 --- a/dll/win32/dbghelp/image_private.h +++ b/dll/win32/dbghelp/image_private.h @@ -54,14 +54,11 @@ #ifndef SHT_NULL #define SHT_NULL 0 #endif -#ifndef NT_GNU_BUILD_ID -#define NT_GNU_BUILD_ID 3 #endif -#elif defined(__REACTOS__) + #ifndef NT_GNU_BUILD_ID #define NT_GNU_BUILD_ID 3 #endif -#endif /* structure holding information while handling an ELF image * allows one by one section mapping for memory savings diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index a144f573d98..89e893dadfe 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: f803da493aeb4cf118fb9b076e8042c2535fbcdb + wine: f7a091af4812ef692fb2b1ec835b8146668aec5c
4 years, 8 months
1
0
0
0
[reactos] 121/179: [WINESYNC] dbghelp: Use LONG_PTR instead of long type.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9b31d0349d1f6d4820582…
commit 9b31d0349d1f6d4820582b1e59ee6317321bbe29 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 18:39:26 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:50 2020 +0200 [WINESYNC] dbghelp: Use LONG_PTR instead of long type. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id f803da493aeb4cf118fb9b076e8042c2535fbcdb by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/cpu_i386.c | 2 +- dll/win32/dbghelp/dbghelp_private.h | 72 ++++++++++++------------- dll/win32/dbghelp/dwarf.c | 104 +++++++++++++++++------------------- dll/win32/dbghelp/elf_module.c | 50 ++++++++--------- dll/win32/dbghelp/image_private.h | 2 +- dll/win32/dbghelp/macho_module.c | 70 ++++++++++++------------ dll/win32/dbghelp/minidump.c | 2 +- dll/win32/dbghelp/module.c | 4 +- dll/win32/dbghelp/msc.c | 6 +-- dll/win32/dbghelp/stabs.c | 54 +++++++++---------- dll/win32/dbghelp/storage.c | 8 +-- dll/win32/dbghelp/symbol.c | 18 +++---- dll/win32/dbghelp/type.c | 2 +- sdk/tools/winesync/dbghelp.cfg | 2 +- 14 files changed, 194 insertions(+), 202 deletions(-) diff --git a/dll/win32/dbghelp/cpu_i386.c b/dll/win32/dbghelp/cpu_i386.c index 420549b40d8..6c10107ba3d 100644 --- a/dll/win32/dbghelp/cpu_i386.c +++ b/dll/win32/dbghelp/cpu_i386.c @@ -52,7 +52,7 @@ static ADDRESS_MODE get_selector_type(HANDLE hThread, const CONTEXT* ctx, WORD s } static BOOL i386_build_addr(HANDLE hThread, const CONTEXT* ctx, ADDRESS64* addr, - unsigned seg, unsigned long offset) + unsigned seg, ULONG_PTR offset) { addr->Mode = AddrModeFlat; addr->Segment = seg; diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index 49cf51fff24..6608c78ad53 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -84,8 +84,8 @@ struct sparse_array }; void sparse_array_init(struct sparse_array* sa, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN; -void* sparse_array_find(const struct sparse_array* sa, unsigned long idx) DECLSPEC_HIDDEN; -void* sparse_array_add(struct sparse_array* sa, unsigned long key, struct pool* pool) DECLSPEC_HIDDEN; +void* sparse_array_find(const struct sparse_array* sa, ULONG_PTR idx) DECLSPEC_HIDDEN; +void* sparse_array_add(struct sparse_array* sa, ULONG_PTR key, struct pool* pool) DECLSPEC_HIDDEN; unsigned sparse_array_length(const struct sparse_array* sa) DECLSPEC_HIDDEN; struct hash_table_elt @@ -153,11 +153,7 @@ struct location { unsigned kind : 8, reg; -#ifndef __REACTOS__ - unsigned long offset; -#else - uintptr_t offset; -#endif + ULONG_PTR offset; }; struct symt @@ -175,8 +171,8 @@ struct symt_ht struct symt_block { struct symt symt; - unsigned long address; - unsigned long size; + ULONG_PTR address; + ULONG_PTR size; struct symt* container; /* block, or func */ struct vector vchildren; /* sub-blocks & local variables */ }; @@ -184,7 +180,7 @@ struct symt_block struct symt_compiland { struct symt symt; - unsigned long address; + ULONG_PTR address; unsigned source; struct vector vchildren; /* global variables & functions */ }; @@ -213,8 +209,8 @@ struct symt_data /* DataIs{Member} (all values are in bits, not bytes) */ struct { - long offset; - unsigned long length; + LONG_PTR offset; + ULONG_PTR length; } member; /* DataIsConstant */ VARIANT value; @@ -225,10 +221,10 @@ struct symt_function { struct symt symt; struct hash_table_elt hash_elt; /* if global symbol */ - unsigned long address; + ULONG_PTR address; struct symt* container; /* compiland */ struct symt* type; /* points to function_signature */ - unsigned long size; + ULONG_PTR size; struct vector vlines; struct vector vchildren; /* locals, params, blocks, start/end, labels */ }; @@ -247,8 +243,8 @@ struct symt_public struct hash_table_elt hash_elt; struct symt* container; /* compiland */ BOOL is_function; - unsigned long address; - unsigned long size; + ULONG_PTR address; + ULONG_PTR size; }; struct symt_thunk @@ -256,8 +252,8 @@ struct symt_thunk struct symt symt; struct hash_table_elt hash_elt; struct symt* container; /* compiland */ - unsigned long address; - unsigned long size; + ULONG_PTR address; + ULONG_PTR size; THUNK_ORDINAL ordinal; /* FIXME: doesn't seem to be accessible */ }; @@ -276,7 +272,7 @@ struct symt_basic struct symt symt; struct hash_table_elt hash_elt; enum BasicType bt; - unsigned long size; + ULONG_PTR size; }; struct symt_enum @@ -306,7 +302,7 @@ struct symt_pointer { struct symt symt; struct symt* pointsto; - unsigned long size; + ULONG_PTR size; }; struct symt_typedef @@ -418,7 +414,7 @@ struct module struct wine_rb_tree sources_offsets_tree; }; -typedef BOOL (*enum_modules_cb)(const WCHAR*, unsigned long addr, void* user); +typedef BOOL (*enum_modules_cb)(const WCHAR*, ULONG_PTR addr, void* user); struct loader_ops { @@ -442,7 +438,7 @@ struct process DWORD64 reg_user; struct module* lmodules; - unsigned long dbg_hdr_addr; + ULONG_PTR dbg_hdr_addr; IMAGEHLP_STACK_FRAME ctx_frame; @@ -454,13 +450,13 @@ struct process struct line_info { - unsigned long is_first : 1, + ULONG_PTR is_first : 1, is_last : 1, is_source_file : 1, line_number; union { - unsigned long pc_offset; /* if is_source_file isn't set */ + ULONG_PTR pc_offset; /* if is_source_file isn't set */ unsigned source_file; /* if is_source_file is set */ } u; }; @@ -637,7 +633,7 @@ extern DWORD calc_crc32(HANDLE handle) DECLSPEC_HIDDEN; /* elf_module.c */ extern BOOL elf_read_wine_loader_dbg_info(struct process* pcs, ULONG_PTR addr) DECLSPEC_HIDDEN; struct elf_thunk_area; -extern int elf_is_in_thunk_area(unsigned long addr, const struct elf_thunk_area* thunks) DECLSPEC_HIDDEN; +extern int elf_is_in_thunk_area(ULONG_PTR addr, const struct elf_thunk_area* thunks) DECLSPEC_HIDDEN; /* macho_module.c */ extern BOOL macho_read_wine_loader_dbg_info(struct process* pcs, ULONG_PTR addr) DECLSPEC_HIDDEN; @@ -668,7 +664,7 @@ extern struct module* module_new(struct process* pcs, const WCHAR* name, enum module_type type, BOOL virtual, DWORD64 addr, DWORD64 size, - unsigned long stamp, unsigned long checksum) DECLSPEC_HIDDEN; + ULONG_PTR stamp, ULONG_PTR checksum) DECLSPEC_HIDDEN; extern struct module* module_get_containee(const struct process* pcs, const struct module* inner) DECLSPEC_HIDDEN; @@ -722,18 +718,18 @@ extern const char* source_get(const struct module* module, unsigned idx) DECLSP extern int source_rb_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN; /* stabs.c */ -typedef void (*stabs_def_cb)(struct module* module, unsigned long load_offset, - const char* name, unsigned long offset, +typedef void (*stabs_def_cb)(struct module* module, ULONG_PTR load_offset, + const char* name, ULONG_PTR offset, BOOL is_public, BOOL is_global, unsigned char other, struct symt_compiland* compiland, void* user); -extern BOOL stabs_parse(struct module* module, unsigned long load_offset, +extern BOOL stabs_parse(struct module* module, ULONG_PTR load_offset, const char* stabs, int stablen, const char* strs, int strtablen, 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, +extern BOOL dwarf2_parse(struct module* module, ULONG_PTR load_offset, const struct elf_thunk_area* thunks, struct image_file_map* fmap) DECLSPEC_HIDDEN; extern BOOL dwarf2_virtual_unwind(struct cpu_stack_walk *csw, DWORD_PTR ip, @@ -762,33 +758,33 @@ extern void copy_symbolW(SYMBOL_INFOW* siw, const SYMBOL_INFO* si) DECLS extern struct symt_ht* symt_find_nearest(struct module* module, DWORD_PTR addr) DECLSPEC_HIDDEN; extern struct symt_compiland* - symt_new_compiland(struct module* module, unsigned long address, + symt_new_compiland(struct module* module, ULONG_PTR address, unsigned src_idx) DECLSPEC_HIDDEN; extern struct symt_public* symt_new_public(struct module* module, struct symt_compiland* parent, const char* typename, BOOL is_function, - unsigned long address, + ULONG_PTR address, unsigned size) DECLSPEC_HIDDEN; extern struct symt_data* symt_new_global_variable(struct module* module, struct symt_compiland* parent, const char* name, unsigned is_static, - struct location loc, unsigned long size, + struct location loc, ULONG_PTR size, struct symt* type) DECLSPEC_HIDDEN; extern struct symt_function* symt_new_function(struct module* module, struct symt_compiland* parent, const char* name, - unsigned long addr, unsigned long size, + ULONG_PTR addr, ULONG_PTR size, struct symt* type) DECLSPEC_HIDDEN; extern BOOL symt_normalize_function(struct module* module, const struct symt_function* func) DECLSPEC_HIDDEN; extern void symt_add_func_line(struct module* module, struct symt_function* func, unsigned source_idx, int line_num, - unsigned long offset) DECLSPEC_HIDDEN; + ULONG_PTR offset) DECLSPEC_HIDDEN; extern struct symt_data* symt_add_func_local(struct module* module, struct symt_function* func, @@ -818,7 +814,7 @@ extern struct symt_thunk* symt_new_thunk(struct module* module, struct symt_compiland* parent, const char* name, THUNK_ORDINAL ord, - unsigned long addr, unsigned long size) DECLSPEC_HIDDEN; + ULONG_PTR addr, ULONG_PTR size) DECLSPEC_HIDDEN; extern struct symt_data* symt_new_constant(struct module* module, struct symt_compiland* parent, @@ -827,7 +823,7 @@ extern struct symt_data* extern struct symt_hierarchy_point* symt_new_label(struct module* module, struct symt_compiland* compiland, - const char* name, unsigned long address) DECLSPEC_HIDDEN; + const char* name, ULONG_PTR address) DECLSPEC_HIDDEN; extern struct symt* symt_index2ptr(struct module* module, DWORD id) DECLSPEC_HIDDEN; extern DWORD symt_ptr2index(struct module* module, const struct symt* sym) DECLSPEC_HIDDEN; @@ -867,7 +863,7 @@ extern BOOL symt_add_function_signature_parameter(struct module* module, extern struct symt_pointer* symt_new_pointer(struct module* module, struct symt* ref_type, - unsigned long size) DECLSPEC_HIDDEN; + ULONG_PTR size) DECLSPEC_HIDDEN; extern struct symt_typedef* symt_new_typedef(struct module* module, struct symt* ref, const char* name) DECLSPEC_HIDDEN; diff --git a/dll/win32/dbghelp/dwarf.c b/dll/win32/dbghelp/dwarf.c index 6d3fb534d98..bf7fb9ce232 100644 --- a/dll/win32/dbghelp/dwarf.c +++ b/dll/win32/dbghelp/dwarf.c @@ -124,15 +124,15 @@ static void dump(const void* ptr, unsigned len) typedef struct dwarf2_abbrev_entry_attr_s { - unsigned long attribute; - unsigned long form; + ULONG_PTR attribute; + ULONG_PTR form; struct dwarf2_abbrev_entry_attr_s* next; } dwarf2_abbrev_entry_attr_t; typedef struct dwarf2_abbrev_entry_s { - unsigned long entry_code; - unsigned long tag; + ULONG_PTR entry_code; + ULONG_PTR tag; unsigned char have_child; unsigned num_attr; dwarf2_abbrev_entry_attr_t* attrs; @@ -146,13 +146,13 @@ struct dwarf2_block struct attribute { - unsigned long form; + ULONG_PTR form; enum {attr_direct, attr_abstract_origin, attr_specification} gotten_from; union { - unsigned long uvalue; + ULONG_PTR uvalue; ULONGLONG lluvalue; - long svalue; + LONG_PTR svalue; const char* string; struct dwarf2_block block; } u; @@ -201,8 +201,8 @@ typedef struct dwarf2_parse_context_s const struct elf_thunk_area*thunks; struct sparse_array abbrev_table; struct sparse_array debug_info_table; - unsigned long load_offset; - unsigned long ref_offset; + ULONG_PTR load_offset; + ULONG_PTR ref_offset; struct symt* symt_cache[sc_num]; /* void, int1, int2, int4 */ char* cpp_name; } dwarf2_parse_context_t; @@ -246,14 +246,14 @@ static unsigned short dwarf2_parse_u2(dwarf2_traverse_context_t* ctx) return uvalue; } -static unsigned long dwarf2_get_u4(const unsigned char* ptr) +static ULONG_PTR dwarf2_get_u4(const unsigned char* ptr) { return *(const UINT32*)ptr; } -static unsigned long dwarf2_parse_u4(dwarf2_traverse_context_t* ctx) +static ULONG_PTR dwarf2_parse_u4(dwarf2_traverse_context_t* ctx) { - unsigned long uvalue = dwarf2_get_u4(ctx->data); + ULONG_PTR uvalue = dwarf2_get_u4(ctx->data); ctx->data += 4; return uvalue; } @@ -270,9 +270,9 @@ static DWORD64 dwarf2_parse_u8(dwarf2_traverse_context_t* ctx) return uvalue; } -static unsigned long dwarf2_get_leb128_as_unsigned(const unsigned char* ptr, const unsigned char** end) +static ULONG_PTR dwarf2_get_leb128_as_unsigned(const unsigned char* ptr, const unsigned char** end) { - unsigned long ret = 0; + ULONG_PTR ret = 0; unsigned char byte; unsigned shift = 0; @@ -287,9 +287,9 @@ static unsigned long dwarf2_get_leb128_as_unsigned(const unsigned char* ptr, con return ret; } -static unsigned long dwarf2_leb128_as_unsigned(dwarf2_traverse_context_t* ctx) +static ULONG_PTR dwarf2_leb128_as_unsigned(dwarf2_traverse_context_t* ctx) { - unsigned long ret; + ULONG_PTR ret; assert(ctx); @@ -298,9 +298,9 @@ static unsigned long dwarf2_leb128_as_unsigned(dwarf2_traverse_context_t* ctx) return ret; } -static long dwarf2_get_leb128_as_signed(const unsigned char* ptr, const unsigned char** end) +static LONG_PTR dwarf2_get_leb128_as_signed(const unsigned char* ptr, const unsigned char** end) { - long ret = 0; + LONG_PTR ret = 0; unsigned char byte; unsigned shift = 0; const unsigned size = sizeof(int) * 8; @@ -323,9 +323,9 @@ static long dwarf2_get_leb128_as_signed(const unsigned char* ptr, const unsigned return ret; } -static long dwarf2_leb128_as_signed(dwarf2_traverse_context_t* ctx) +static LONG_PTR dwarf2_leb128_as_signed(dwarf2_traverse_context_t* ctx) { - long ret = 0; + LONG_PTR ret = 0; assert(ctx); @@ -347,9 +347,9 @@ static unsigned dwarf2_leb128_length(const dwarf2_traverse_context_t* ctx) * We assume that in all cases word size from Dwarf matches the size of * addresses in platform where the exec is compiled. */ -static unsigned long dwarf2_get_addr(const unsigned char* ptr, unsigned word_size) +static ULONG_PTR dwarf2_get_addr(const unsigned char* ptr, unsigned word_size) { - unsigned long ret; + ULONG_PTR ret; switch (word_size) { @@ -366,9 +366,9 @@ static unsigned long dwarf2_get_addr(const unsigned char* ptr, unsigned word_siz return ret; } -static unsigned long dwarf2_parse_addr(dwarf2_traverse_context_t* ctx) +static ULONG_PTR dwarf2_parse_addr(dwarf2_traverse_context_t* ctx) { - unsigned long ret = dwarf2_get_addr(ctx->data, ctx->word_size); + ULONG_PTR ret = dwarf2_get_addr(ctx->data, ctx->word_size); ctx->data += ctx->word_size; return ret; } @@ -392,7 +392,7 @@ static const char* dwarf2_debug_di(const dwarf2_debug_info_t* di) static dwarf2_abbrev_entry_t* dwarf2_abbrev_table_find_entry(const struct sparse_array* abbrev_table, - unsigned long entry_code) + ULONG_PTR entry_code) { assert( NULL != abbrev_table ); return sparse_array_find(abbrev_table, entry_code); @@ -402,12 +402,12 @@ static void dwarf2_parse_abbrev_set(dwarf2_traverse_context_t* abbrev_ctx, struct sparse_array* abbrev_table, struct pool* pool) { - unsigned long entry_code; + ULONG_PTR entry_code; dwarf2_abbrev_entry_t* abbrev_entry; dwarf2_abbrev_entry_attr_t* new = NULL; dwarf2_abbrev_entry_attr_t* last = NULL; - unsigned long attribute; - unsigned long form; + ULONG_PTR attribute; + ULONG_PTR form; assert( NULL != abbrev_ctx ); @@ -580,7 +580,7 @@ static void dwarf2_fill_attr(const dwarf2_parse_context_t* ctx, case DW_FORM_strp: { - unsigned long offset = dwarf2_get_u4(data); + ULONG_PTR offset = dwarf2_get_u4(data); attr->u.string = (const char*)ctx->sections[section_string].address + offset; } TRACE("strp<%s>\n", debugstr_a(attr->u.string)); @@ -895,7 +895,7 @@ compute_location(dwarf2_traverse_context_t* ctx, struct location* loc, static BOOL dwarf2_compute_location_attr(dwarf2_parse_context_t* ctx, const dwarf2_debug_info_t* di, - unsigned long dw, + ULONG_PTR dw, struct location* loc, const struct location* frame) { @@ -948,11 +948,7 @@ static BOOL dwarf2_compute_location_attr(dwarf2_parse_context_t* ctx, sizeof(unsigned) + xloc.u.block.size); *ptr = xloc.u.block.size; memcpy(ptr + 1, xloc.u.block.ptr, xloc.u.block.size); -#ifndef __REACTOS__ - loc->offset = (unsigned long)ptr; -#else - loc->offset = (uintptr_t)ptr; -#endif + loc->offset = (ULONG_PTR)ptr; compute_location(&lctx, loc, NULL, frame); } } @@ -1040,14 +1036,14 @@ static const char* dwarf2_get_cpp_name(dwarf2_parse_context_t* ctx, dwarf2_debug * in all cases, range is relative to beginning of compilation unit */ static BOOL dwarf2_read_range(dwarf2_parse_context_t* ctx, const dwarf2_debug_info_t* di, - unsigned long* plow, unsigned long* phigh) + ULONG_PTR* plow, ULONG_PTR* phigh) { struct attribute range; if (dwarf2_find_attribute(ctx, di, DW_AT_ranges, &range)) { dwarf2_traverse_context_t traverse; - unsigned long low, high; + ULONG_PTR low, high; traverse.data = ctx->sections[section_ranges].address + range.u.uvalue; traverse.end_data = ctx->sections[section_ranges].address + @@ -1095,8 +1091,8 @@ static BOOL dwarf2_read_one_debug_info(dwarf2_parse_context_t* ctx, dwarf2_debug_info_t** pdi) { const dwarf2_abbrev_entry_t*abbrev; - unsigned long entry_code; - unsigned long offset; + ULONG_PTR entry_code; + ULONG_PTR offset; dwarf2_debug_info_t* di; dwarf2_debug_info_t* child; dwarf2_debug_info_t** where; @@ -1439,7 +1435,7 @@ static void dwarf2_parse_udt_member(dwarf2_parse_context_t* ctx, { DWORD64 size; nbytes.u.uvalue = symt_get_info(ctx->module, elt_type, TI_GET_LENGTH, &size) ? - (unsigned long)size : 0; + (ULONG_PTR)size : 0; } bit_offset.u.uvalue = nbytes.u.uvalue * 8 - bit_offset.u.uvalue - bit_size.u.uvalue; } @@ -1771,7 +1767,7 @@ static void dwarf2_parse_inlined_subroutine(dwarf2_subprogram_t* subpgm, dwarf2_debug_info_t* di) { struct symt_block* block; - unsigned long low_pc, high_pc; + ULONG_PTR low_pc, high_pc; struct vector* children; dwarf2_debug_info_t*child; unsigned int i; @@ -1825,7 +1821,7 @@ static void dwarf2_parse_subprogram_block(dwarf2_subprogram_t* subpgm, dwarf2_debug_info_t* di) { struct symt_block* block; - unsigned long low_pc, high_pc; + ULONG_PTR low_pc, high_pc; struct vector* children; dwarf2_debug_info_t*child; unsigned int i; @@ -1906,7 +1902,7 @@ static struct symt* dwarf2_parse_subprogram(dwarf2_parse_context_t* ctx, dwarf2_debug_info_t* di) { struct attribute name; - unsigned long low_pc, high_pc; + ULONG_PTR low_pc, high_pc; struct attribute is_decl; struct attribute inline_flags; struct symt* ret_type; @@ -2176,7 +2172,7 @@ static void dwarf2_load_one_entry(dwarf2_parse_context_t* ctx, } } -static void dwarf2_set_line_number(struct module* module, unsigned long address, +static void dwarf2_set_line_number(struct module* module, ULONG_PTR address, const struct vector* v, unsigned file, unsigned line) { struct symt_function* func; @@ -2196,10 +2192,10 @@ static void dwarf2_set_line_number(struct module* module, unsigned long address, static BOOL dwarf2_parse_line_numbers(const dwarf2_section_t* sections, dwarf2_parse_context_t* ctx, const char* compile_dir, - unsigned long offset) + ULONG_PTR offset) { dwarf2_traverse_context_t traverse; - unsigned long length; + ULONG_PTR length; unsigned insn_size, default_stmt; unsigned line_range, opcode_base; int line_base; @@ -2289,7 +2285,7 @@ static BOOL dwarf2_parse_line_numbers(const dwarf2_section_t* sections, while (traverse.data < traverse.end_data) { - unsigned long address = 0; + ULONG_PTR address = 0; unsigned file = 1; unsigned line = 1; unsigned is_stmt = default_stmt; @@ -2387,16 +2383,16 @@ static BOOL dwarf2_parse_compilation_unit(const dwarf2_section_t* sections, struct module* module, const struct elf_thunk_area* thunks, dwarf2_traverse_context_t* mod_ctx, - unsigned long load_offset) + ULONG_PTR load_offset) { dwarf2_parse_context_t ctx; dwarf2_traverse_context_t abbrev_ctx; dwarf2_debug_info_t* di; dwarf2_traverse_context_t cu_ctx; const unsigned char* comp_unit_start = mod_ctx->data; - unsigned long cu_length; + ULONG_PTR cu_length; unsigned short cu_version; - unsigned long cu_abbrev_offset; + ULONG_PTR cu_abbrev_offset; BOOL ret = FALSE; cu_length = dwarf2_parse_u4(mod_ctx); @@ -2493,7 +2489,7 @@ static BOOL dwarf2_parse_compilation_unit(const dwarf2_section_t* sections, } static BOOL dwarf2_lookup_loclist(const struct module_format* modfmt, const BYTE* start, - unsigned long ip, dwarf2_traverse_context_t* lctx) + ULONG_PTR ip, dwarf2_traverse_context_t* lctx) { DWORD_PTR beg, end; const BYTE* ptr = start; @@ -2727,7 +2723,7 @@ static BOOL parse_cie_details(dwarf2_traverse_context_t* ctx, struct frame_info* return TRUE; } -static BOOL dwarf2_get_cie(unsigned long addr, struct module* module, DWORD_PTR delta, +static BOOL dwarf2_get_cie(ULONG_PTR addr, struct module* module, DWORD_PTR delta, dwarf2_traverse_context_t* fde_ctx, dwarf2_traverse_context_t* cie_ctx, struct frame_info* info, BOOL in_eh_frame) { @@ -2735,7 +2731,7 @@ static BOOL dwarf2_get_cie(unsigned long addr, struct module* module, DWORD_PTR const unsigned char* cie_ptr; const unsigned char* last_cie_ptr = (const unsigned char*)~0; unsigned len, id; - unsigned long start, range; + ULONG_PTR start, range; unsigned cie_id; const BYTE* start_data = fde_ctx->data; @@ -3528,7 +3524,7 @@ static void dwarf2_module_remove(struct process* pcs, struct module_format* modf HeapFree(GetProcessHeap(), 0, modfmt); } -BOOL dwarf2_parse(struct module* module, unsigned long load_offset, +BOOL dwarf2_parse(struct module* module, ULONG_PTR load_offset, const struct elf_thunk_area* thunks, struct image_file_map* fmap) { diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 50ad89f53f7..01759cd18ee 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -116,13 +116,13 @@ struct elf_thunk_area { const char* symname; THUNK_ORDINAL ordinal; - unsigned long rva_start; - unsigned long rva_end; + ULONG_PTR rva_start; + ULONG_PTR rva_end; }; struct elf_module_info { - unsigned long elf_addr; + ULONG_PTR elf_addr; unsigned short elf_mark : 1, elf_loader : 1; struct image_file_map file_map; @@ -355,7 +355,7 @@ static BOOL elf_map_file_read(struct image_file_map* fmap, struct elf_map_file_d return ReadFile(fmap->u.elf.handle, buf, len, &bytes_read, NULL); case from_process: return ReadProcessMemory(emfd->u.process.handle, - (void*)((unsigned long)emfd->u.process.load_addr + (unsigned long)off), + (void*)((ULONG_PTR)emfd->u.process.load_addr + (ULONG_PTR)off), buf, len, &dw) && dw == len; default: assert(0); @@ -559,7 +559,7 @@ static void elf_module_remove(struct process* pcs, struct module_format* modfmt) * Check whether an address lies within one of the thunk area we * know of. */ -int elf_is_in_thunk_area(unsigned long addr, +int elf_is_in_thunk_area(ULONG_PTR addr, const struct elf_thunk_area* thunks) { unsigned i; @@ -1085,8 +1085,8 @@ static BOOL elf_fetch_file_info(struct process* process, const WCHAR* name, ULON } static BOOL elf_load_file_from_fmap(struct process* pcs, const WCHAR* filename, - struct image_file_map* fmap, unsigned long load_offset, - unsigned long dyn_addr, struct elf_info* elf_info) + struct image_file_map* fmap, ULONG_PTR load_offset, + ULONG_PTR dyn_addr, struct elf_info* elf_info) { BOOL ret = FALSE; @@ -1097,7 +1097,7 @@ static BOOL elf_load_file_from_fmap(struct process* pcs, const WCHAR* filename, if (elf_find_section_type(fmap, ".dynamic", SHT_DYNAMIC, &ism)) { char* ptr = (char*)(ULONG_PTR)fmap->u.elf.sect[ism.sidx].shdr.sh_addr; - unsigned long len; + ULONG_PTR len; if (load_offset) ptr += load_offset - fmap->u.elf.elf_start; @@ -1154,14 +1154,14 @@ static BOOL elf_load_file_from_fmap(struct process* pcs, const WCHAR* filename, struct elf_module_info *elf_module_info; struct module_format* modfmt; struct image_section_map ism; - unsigned long modbase = load_offset; + ULONG_PTR modbase = load_offset; if (elf_find_section_type(fmap, ".dynamic", SHT_DYNAMIC, &ism)) { - unsigned long rva_dyn = elf_get_map_rva(&ism); + ULONG_PTR rva_dyn = elf_get_map_rva(&ism); TRACE("For module %s, got ELF (start=%lx dyn=%lx), link_map (start=%lx dyn=%lx)\n", - debugstr_w(filename), (unsigned long)fmap->u.elf.elf_start, rva_dyn, + debugstr_w(filename), (ULONG_PTR)fmap->u.elf.elf_start, rva_dyn, load_offset, dyn_addr); if (dyn_addr && load_offset + rva_dyn != dyn_addr) { @@ -1231,7 +1231,7 @@ static BOOL elf_load_file_from_fmap(struct process* pcs, const WCHAR* filename, * 1 on success */ static BOOL elf_load_file(struct process* pcs, const WCHAR* filename, - unsigned long load_offset, unsigned long dyn_addr, + ULONG_PTR load_offset, ULONG_PTR dyn_addr, struct elf_info* elf_info) { BOOL ret = FALSE; @@ -1279,7 +1279,7 @@ static BOOL elf_load_file_cb(void *param, HANDLE handle, const WCHAR *filename) * * locate some a value from the debuggee auxiliary vector */ -static BOOL elf_search_auxv(const struct process* pcs, unsigned type, unsigned long* val) +static BOOL elf_search_auxv(const struct process* pcs, unsigned type, ULONG_PTR* val) { char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME]; SYMBOL_INFO*si = (SYMBOL_INFO*)buffer; @@ -1350,7 +1350,7 @@ static BOOL elf_search_auxv(const struct process* pcs, unsigned type, unsigned l * lookup a file in standard ELF locations, and if found, load it */ static BOOL elf_search_and_load_file(struct process* pcs, const WCHAR* filename, - unsigned long load_offset, unsigned long dyn_addr, + ULONG_PTR load_offset, ULONG_PTR dyn_addr, struct elf_info* elf_info) { BOOL ret = FALSE; @@ -1384,8 +1384,8 @@ static BOOL elf_search_and_load_file(struct process* pcs, const WCHAR* filename, return ret; } -typedef BOOL (*enum_elf_modules_cb)(const WCHAR*, unsigned long load_addr, - unsigned long dyn_addr, BOOL is_system, void* user); +typedef BOOL (*enum_elf_modules_cb)(const WCHAR*, ULONG_PTR load_addr, + ULONG_PTR dyn_addr, BOOL is_system, void* user); /****************************************************************** * elf_enum_modules_internal @@ -1427,7 +1427,7 @@ static BOOL elf_enum_modules_internal(const struct process* pcs, bufstr[sizeof(bufstr) - 1] = '\0'; MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW, ARRAY_SIZE(bufstrW)); if (main_name && !bufstrW[0]) strcpyW(bufstrW, main_name); - if (!cb(bufstrW, (unsigned long)lm.l_addr, (unsigned long)lm.l_ld, FALSE, user)) + if (!cb(bufstrW, (ULONG_PTR)lm.l_addr, (ULONG_PTR)lm.l_ld, FALSE, user)) break; } } @@ -1461,7 +1461,7 @@ static BOOL elf_enum_modules_internal(const struct process* pcs, bufstr[sizeof(bufstr) - 1] = '\0'; MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW, ARRAY_SIZE(bufstrW)); if (main_name && !bufstrW[0]) strcpyW(bufstrW, main_name); - if (!cb(bufstrW, (unsigned long)lm.l_addr, (unsigned long)lm.l_ld, FALSE, user)) + if (!cb(bufstrW, (ULONG_PTR)lm.l_addr, (ULONG_PTR)lm.l_ld, FALSE, user)) break; } } @@ -1470,7 +1470,7 @@ static BOOL elf_enum_modules_internal(const struct process* pcs, #ifdef AT_SYSINFO_EHDR if (!lm_addr) { - unsigned long ehdr_addr; + ULONG_PTR ehdr_addr; if (elf_search_auxv(pcs, AT_SYSINFO_EHDR, &ehdr_addr)) { @@ -1488,8 +1488,8 @@ struct elf_enum_user void* user; }; -static BOOL elf_enum_modules_translate(const WCHAR* name, unsigned long load_addr, - unsigned long dyn_addr, BOOL is_system, void* user) +static BOOL elf_enum_modules_translate(const WCHAR* name, ULONG_PTR load_addr, + ULONG_PTR dyn_addr, BOOL is_system, void* user) { struct elf_enum_user* eeu = user; return eeu->cb(name, load_addr, eeu->user); @@ -1531,8 +1531,8 @@ struct elf_load * Callback for elf_load_module, used to walk the list of loaded * modules. */ -static BOOL elf_load_cb(const WCHAR* name, unsigned long load_addr, - unsigned long dyn_addr, BOOL is_system, void* user) +static BOOL elf_load_cb(const WCHAR* name, ULONG_PTR load_addr, + ULONG_PTR dyn_addr, BOOL is_system, void* user) { struct elf_load* el = user; BOOL ret = TRUE; @@ -1583,7 +1583,7 @@ static BOOL elf_load_cb(const WCHAR* name, unsigned long load_addr, * Also, find module real name and load address from * the real loaded modules list in pcs address space */ -static struct module* elf_load_module(struct process* pcs, const WCHAR* name, unsigned long addr) +static struct module* elf_load_module(struct process* pcs, const WCHAR* name, ULONG_PTR addr) { struct elf_load el; @@ -1707,7 +1707,7 @@ BOOL elf_read_wine_loader_dbg_info(struct process* pcs, ULONG_PTR addr) return FALSE; } -int elf_is_in_thunk_area(unsigned long addr, +int elf_is_in_thunk_area(ULONG_PTR addr, const struct elf_thunk_area* thunks) { return -1; diff --git a/dll/win32/dbghelp/image_private.h b/dll/win32/dbghelp/image_private.h index 253f1252101..e07dea4d267 100644 --- a/dll/win32/dbghelp/image_private.h +++ b/dll/win32/dbghelp/image_private.h @@ -136,7 +136,7 @@ struct image_file_map struct image_section_map { struct image_file_map* fmap; - long sidx; + LONG_PTR sidx; }; BOOL image_check_alternate(struct image_file_map* fmap, const struct module* module) DECLSPEC_HIDDEN; diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 43a98c9c726..d10e402de27 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -118,7 +118,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_macho); struct macho_module_info { struct image_file_map file_map; - unsigned long load_addr; + ULONG_PTR load_addr; unsigned short in_use : 1, is_loader : 1; }; @@ -157,12 +157,12 @@ static char* format_uuid(const uint8_t uuid[16], char out[UUID_STRING_LEN]) * that encompasses it. For a fat binary, the architecture will * itself be offset within the file, so take that into account. */ -static void macho_calc_range(const struct macho_file_map* fmap, unsigned long offset, - unsigned long len, unsigned long* out_aligned_offset, - unsigned long* out_aligned_end, unsigned long* out_misalign) +static void macho_calc_range(const struct macho_file_map* fmap, ULONG_PTR offset, + ULONG_PTR len, ULONG_PTR* out_aligned_offset, + ULONG_PTR* out_aligned_end, ULONG_PTR* out_misalign) { - unsigned long pagemask; - unsigned long file_offset, misalign; + ULONG_PTR pagemask; + ULONG_PTR file_offset, misalign; pagemask = sysinfo.dwAllocationGranularity - 1; file_offset = fmap->arch_offset + offset; @@ -178,10 +178,10 @@ static void macho_calc_range(const struct macho_file_map* fmap, unsigned long of * * Maps a range (offset, length in bytes) from a Mach-O file into memory */ -static const char* macho_map_range(const struct macho_file_map* fmap, unsigned long offset, unsigned long len, +static const char* macho_map_range(const struct macho_file_map* fmap, ULONG_PTR offset, ULONG_PTR len, const char** base) { - unsigned long misalign, aligned_offset, aligned_map_end; + ULONG_PTR misalign, aligned_offset, aligned_map_end; const void* aligned_ptr; HANDLE mapping; @@ -215,13 +215,13 @@ static const char* macho_map_range(const struct macho_file_map* fmap, unsigned l * Unmaps a range (offset, length in bytes) of a Mach-O file from memory */ static void macho_unmap_range(const char** base, const void** mapped, const struct macho_file_map* fmap, - unsigned long offset, unsigned long len) + ULONG_PTR offset, ULONG_PTR len) { TRACE("(%p, %p, %p/%p, 0x%08lx, 0x%08lx)\n", base, mapped, fmap, fmap->handle, offset, len); if ((mapped && *mapped != IMAGE_NO_MAP) || (base && *base != IMAGE_NO_MAP)) { - unsigned long misalign, aligned_offset, aligned_map_end; + ULONG_PTR misalign, aligned_offset, aligned_map_end; void* aligned_ptr; macho_calc_range(fmap, offset, len, &aligned_offset, &aligned_map_end, &misalign); @@ -247,12 +247,12 @@ static void macho_unmap_range(const char** base, const void** mapped, const stru * the munmap doesn't fragment the mapping. */ static BOOL macho_map_ranges(const struct macho_file_map* fmap, - unsigned long offset1, unsigned long len1, - unsigned long offset2, unsigned long len2, + ULONG_PTR offset1, ULONG_PTR len1, + ULONG_PTR offset2, ULONG_PTR len2, const void** mapped1, const void** mapped2) { - unsigned long aligned_offset1, aligned_map_end1; - unsigned long aligned_offset2, aligned_map_end2; + ULONG_PTR aligned_offset1, aligned_map_end1; + ULONG_PTR aligned_offset2, aligned_map_end2; TRACE("(%p/%p, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx, %p, %p)\n", fmap, fmap->handle, offset1, len1, offset2, len2, mapped1, mapped2); @@ -299,12 +299,12 @@ static BOOL macho_map_ranges(const struct macho_file_map* fmap, * macho_map_ranges. */ static void macho_unmap_ranges(const struct macho_file_map* fmap, - unsigned long offset1, unsigned long len1, - unsigned long offset2, unsigned long len2, + ULONG_PTR offset1, ULONG_PTR len1, + ULONG_PTR offset2, ULONG_PTR len2, const void** mapped1, const void** mapped2) { - unsigned long aligned_offset1, aligned_map_end1; - unsigned long aligned_offset2, aligned_map_end2; + ULONG_PTR aligned_offset1, aligned_map_end1; + ULONG_PTR aligned_offset2, aligned_map_end2; TRACE("(%p/%p, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx, %p/%p, %p/%p)\n", fmap, fmap->handle, offset1, len1, offset2, len2, mapped1, *mapped1, mapped2, *mapped2); @@ -566,7 +566,7 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load struct section_info* info = user; BOOL ignore; int i; - unsigned long tmp, page_mask = sysinfo.dwPageSize - 1; + ULONG_PTR tmp, page_mask = sysinfo.dwPageSize - 1; uint64_t vmaddr, vmsize; char segname[16]; uint32_t nsects; @@ -592,9 +592,9 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load } TRACE("(%p/%p, %p, %p) before: 0x%08lx - 0x%08lx\n", fmap, fmap->handle, lc, user, - (unsigned long)fmap->segs_start, (unsigned long)fmap->segs_size); - TRACE("Segment command vm: 0x%08lx - 0x%08lx\n", (unsigned long)vmaddr, - (unsigned long)(vmaddr + vmsize)); + (ULONG_PTR)fmap->segs_start, (ULONG_PTR)fmap->segs_size); + TRACE("Segment command vm: 0x%08lx - 0x%08lx\n", (ULONG_PTR)vmaddr, + (ULONG_PTR)(vmaddr + vmsize)); /* Images in the dyld shared cache have their segments mapped non-contiguously. We don't know how to properly locate any of the segments other than __TEXT, @@ -617,7 +617,7 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load tmp = (vmaddr + vmsize + page_mask) & ~page_mask; if (fmap->segs_size < tmp) fmap->segs_size = tmp; - TRACE("after: 0x%08lx - 0x%08lx\n", (unsigned long)fmap->segs_start, (unsigned long)fmap->segs_size); + TRACE("after: 0x%08lx - 0x%08lx\n", (ULONG_PTR)fmap->segs_start, (ULONG_PTR)fmap->segs_size); } for (i = 0; i < nsects; i++) @@ -787,8 +787,8 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW, } fmap->segs_size -= fmap->segs_start; - TRACE("segs_start: 0x%08lx, segs_size: 0x%08lx\n", (unsigned long)fmap->segs_start, - (unsigned long)fmap->segs_size); + TRACE("segs_start: 0x%08lx, segs_size: 0x%08lx\n", (ULONG_PTR)fmap->segs_start, + (ULONG_PTR)fmap->segs_size); if (macho_enum_load_commands(ifm, LC_UUID, find_uuid, NULL) < 0) goto done; @@ -873,7 +873,7 @@ struct symtab_elt { struct hash_table_elt ht_elt; struct symt_compiland* compiland; - unsigned long addr; + ULONG_PTR addr; unsigned char is_code:1, is_public:1, is_global:1, @@ -893,8 +893,8 @@ struct macho_debug_info * * Callback for stabs_parse. Collect symbol definitions. */ -static void macho_stabs_def_cb(struct module* module, unsigned long load_offset, - const char* name, unsigned long offset, +static void macho_stabs_def_cb(struct module* module, ULONG_PTR load_offset, + const char* name, ULONG_PTR offset, BOOL is_public, BOOL is_global, unsigned char sectidx, struct symt_compiland* compiland, void* user) { @@ -1253,7 +1253,7 @@ 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(struct process* process, unsigned long load_addr) +static BOOL image_uses_split_segs(struct process* process, ULONG_PTR load_addr) { BOOL split_segs = FALSE; @@ -1412,7 +1412,7 @@ static ULONG_PTR get_dyld_image_info_address(struct process* pcs) * TRUE on success */ static BOOL macho_load_file(struct process* pcs, const WCHAR* filename, - unsigned long load_addr, struct macho_info* macho_info) + ULONG_PTR load_addr, struct macho_info* macho_info) { BOOL ret = TRUE; BOOL split_segs; @@ -1500,7 +1500,7 @@ static BOOL macho_load_file_cb(void *param, HANDLE handle, const WCHAR *filename * Lookup a file in standard Mach-O locations, and if found, load it */ static BOOL macho_search_and_load_file(struct process* pcs, const WCHAR* filename, - unsigned long load_addr, + ULONG_PTR load_addr, struct macho_info* macho_info) { BOOL ret = FALSE; @@ -1564,7 +1564,7 @@ static BOOL macho_enum_modules_internal(const struct process* pcs, { union wine_all_image_infos image_infos; union wine_image_info* info_array = NULL; - unsigned long len; + ULONG_PTR len; int i; char bufstr[256]; WCHAR bufstrW[MAX_PATH]; @@ -1637,7 +1637,7 @@ struct macho_sync struct macho_info macho_info; }; -static BOOL macho_enum_sync_cb(const WCHAR* name, unsigned long addr, void* user) +static BOOL macho_enum_sync_cb(const WCHAR* name, ULONG_PTR addr, void* user) { struct macho_sync* ms = user; @@ -1721,7 +1721,7 @@ struct macho_load * 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) +static BOOL macho_load_cb(const WCHAR* name, ULONG_PTR addr, void* user) { struct macho_load* ml = user; const WCHAR* p; @@ -1747,7 +1747,7 @@ static BOOL macho_load_cb(const WCHAR* name, unsigned long addr, void* user) * Also, find module real name and load address from * the real loaded modules list in pcs address space. */ -static struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsigned long addr) +static struct module* macho_load_module(struct process* pcs, const WCHAR* name, ULONG_PTR addr) { struct macho_load ml; diff --git a/dll/win32/dbghelp/minidump.c b/dll/win32/dbghelp/minidump.c index 4730dedec94..f8b4015c23c 100644 --- a/dll/win32/dbghelp/minidump.c +++ b/dll/win32/dbghelp/minidump.c @@ -255,7 +255,7 @@ static BOOL WINAPI fetch_pe_module_info_cb(PCWSTR name, DWORD64 base, ULONG size * * Callback for accumulating in dump_context an host modules set */ -static BOOL fetch_host_module_info_cb(const WCHAR* name, unsigned long base, +static BOOL fetch_host_module_info_cb(const WCHAR* name, ULONG_PTR base, void* user) { struct dump_context* dc = user; diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c index e4cd98b224a..80a484e94ae 100644 --- a/dll/win32/dbghelp/module.c +++ b/dll/win32/dbghelp/module.c @@ -197,7 +197,7 @@ static const char* get_module_type(enum module_type type, BOOL virtual) struct module* module_new(struct process* pcs, const WCHAR* name, enum module_type type, BOOL virtual, DWORD64 mod_addr, DWORD64 size, - unsigned long stamp, unsigned long checksum) + ULONG_PTR stamp, ULONG_PTR checksum) { struct module* module; unsigned i; @@ -1380,7 +1380,7 @@ static BOOL native_synchronize_module_list(struct process* pcs) return FALSE; } -static struct module* native_load_module(struct process* pcs, const WCHAR* name, unsigned long addr) +static struct module* native_load_module(struct process* pcs, const WCHAR* name, ULONG_PTR addr) { return NULL; } diff --git a/dll/win32/dbghelp/msc.c b/dll/win32/dbghelp/msc.c index 6696fa02e4e..82fc44965ac 100644 --- a/dll/win32/dbghelp/msc.c +++ b/dll/win32/dbghelp/msc.c @@ -1393,7 +1393,7 @@ static BOOL codeview_parse_type_table(struct codeview_type_parse* ctp) /*======================================================================== * Process CodeView line number information. */ -static unsigned long codeview_get_address(const struct msc_debug_info* msc_dbg, +static ULONG_PTR codeview_get_address(const struct msc_debug_info* msc_dbg, unsigned seg, unsigned offset); static void codeview_snarf_linetab(const struct msc_debug_info* msc_dbg, const BYTE* linetab, @@ -1408,7 +1408,7 @@ static void codeview_snarf_linetab(const struct msc_debug_info* msc_dbg, const B const unsigned short* linenos; const struct startend* start; unsigned source; - unsigned long addr, func_addr0; + ULONG_PTR addr, func_addr0; struct symt_function* func; const struct codeview_linetab_block* ltb; @@ -1555,7 +1555,7 @@ static unsigned int codeview_map_offset(const struct msc_debug_info* msc_dbg, return 0; } -static unsigned long codeview_get_address(const struct msc_debug_info* msc_dbg, +static ULONG_PTR codeview_get_address(const struct msc_debug_info* msc_dbg, unsigned seg, unsigned offset) { int nsect = msc_dbg->nsect; diff --git a/dll/win32/dbghelp/stabs.c b/dll/win32/dbghelp/stabs.c index 09e451c7d2f..07f5142893f 100644 --- a/dll/win32/dbghelp/stabs.c +++ b/dll/win32/dbghelp/stabs.c @@ -161,7 +161,7 @@ static void stab_strcpy(char* dest, int sz, const char* source) typedef struct { char* name; - unsigned long value; + ULONG_PTR value; struct symt** vector; int nrofentries; } include_def; @@ -177,7 +177,7 @@ static struct symt** cu_vector = NULL; static int cu_nrofentries = 0; static struct symt_basic* stabs_basic[36]; -static int stabs_new_include(const char* file, unsigned long val) +static int stabs_new_include(const char* file, ULONG_PTR val) { if (num_include_def == num_alloc_include_def) { @@ -202,7 +202,7 @@ static int stabs_new_include(const char* file, unsigned long val) return num_include_def++; } -static int stabs_find_include(const char* file, unsigned long val) +static int stabs_find_include(const char* file, ULONG_PTR val) { int i; @@ -256,7 +256,7 @@ static void stabs_free_includes(void) cu_nrofentries = 0; } -static struct symt** stabs_find_ref(long filenr, long subnr) +static struct symt** stabs_find_ref(LONG_PTR filenr, LONG_PTR subnr) { struct symt** ret; @@ -302,7 +302,7 @@ static struct symt** stabs_find_ref(long filenr, long subnr) static struct symt** stabs_read_type_enum(const char** x) { - long filenr, subnr; + LONG_PTR filenr, subnr; const char* iter; char* end; @@ -426,7 +426,7 @@ static int stabs_pts_read_id(struct ParseTypedefData* ptd) return -1; } -static int stabs_pts_read_number(struct ParseTypedefData* ptd, long* v) +static int stabs_pts_read_number(struct ParseTypedefData* ptd, LONG_PTR* v) { char* last; @@ -437,7 +437,7 @@ static int stabs_pts_read_number(struct ParseTypedefData* ptd, long* v) } static int stabs_pts_read_type_reference(struct ParseTypedefData* ptd, - long* filenr, long* subnr) + LONG_PTR* filenr, LONG_PTR* subnr) { if (*ptd->ptr == '(') { @@ -612,7 +612,7 @@ static inline int stabs_pts_read_method_info(struct ParseTypedefData* ptd) ptd->ptr++; if (mthd == '*') { - long int ofs; + LONG_PTR ofs; PTS_ABORTIF(ptd, stabs_pts_read_number(ptd, &ofs) == -1); PTS_ABORTIF(ptd, *ptd->ptr++ != ';'); @@ -628,7 +628,7 @@ static inline int stabs_pts_read_method_info(struct ParseTypedefData* ptd) static inline int stabs_pts_read_aggregate(struct ParseTypedefData* ptd, struct symt_udt* sdt) { - long sz, ofs; + LONG_PTR sz, ofs; struct symt* adt; struct symt* dt = NULL; int idx; @@ -639,7 +639,7 @@ static inline int stabs_pts_read_aggregate(struct ParseTypedefData* ptd, doadd = symt_set_udt_size(ptd->module, sdt, sz); if (*ptd->ptr == '!') /* C++ inheritance */ { - long num_classes; + LONG_PTR num_classes; ptd->ptr++; PTS_ABORTIF(ptd, stabs_pts_read_number(ptd, &num_classes) == -1); @@ -686,7 +686,7 @@ static inline int stabs_pts_read_aggregate(struct ParseTypedefData* ptd, if (ptd->ptr[0] == '$' && ptd->ptr[1] == 'v') { - long x; + LONG_PTR x; if (ptd->ptr[2] == 'f') { @@ -770,7 +770,7 @@ static inline int stabs_pts_read_aggregate(struct ParseTypedefData* ptd, static inline int stabs_pts_read_enum(struct ParseTypedefData* ptd, struct symt_enum* edt) { - long value; + LONG_PTR value; int idx; while (*ptd->ptr != ';') @@ -789,7 +789,7 @@ static inline int stabs_pts_read_enum(struct ParseTypedefData* ptd, static inline int stabs_pts_read_array(struct ParseTypedefData* ptd, struct symt** adt) { - long lo, hi; + LONG_PTR lo, hi; struct symt* range_dt; struct symt* base_dt; @@ -814,10 +814,10 @@ static int stabs_pts_read_type_def(struct ParseTypedefData* ptd, const char* typ struct symt** ret_dt) { int idx; - long sz = -1; + LONG_PTR sz = -1; struct symt* new_dt = NULL; /* newly created data type */ struct symt* ref_dt; /* referenced data type (pointer...) */ - long filenr1, subnr1, tmp; + LONG_PTR filenr1, subnr1, tmp; /* things are a bit complicated because of the way the typedefs are stored inside * the file, because addresses can change when realloc is done, so we must call @@ -978,8 +978,8 @@ static int stabs_pts_read_type_def(struct ParseTypedefData* ptd, const char* typ break; case 'R': { - long type, len, unk; - int basic; + LONG_PTR type, len, unk; + int basic; PTS_ABORTIF(ptd, stabs_pts_read_number(ptd, &type) == -1); PTS_ABORTIF(ptd, *ptd->ptr++ != ';'); /* ';' */ @@ -1130,8 +1130,8 @@ struct pending_line { int source_idx; int line_num; - unsigned long offset; - unsigned long load_offset; + ULONG_PTR offset; + ULONG_PTR load_offset; }; struct pending_object @@ -1183,8 +1183,8 @@ static inline void pending_add_var(struct pending_list* pending, const char* nam } static inline void pending_add_line(struct pending_list* pending, int source_idx, - int line_num, unsigned long offset, - unsigned long load_offset) + int line_num, ULONG_PTR offset, + ULONG_PTR load_offset) { pending_make_room(pending); pending->objs[pending->num].tag = PENDING_LINE; @@ -1233,7 +1233,7 @@ static void pending_flush(struct pending_list* pending, struct module* module, * function (assuming that current function ends where next function starts) */ static void stabs_finalize_function(struct module* module, struct symt_function* func, - unsigned long size) + ULONG_PTR size) { IMAGEHLP_LINE64 il; struct location loc; @@ -1269,7 +1269,7 @@ static inline void stabbuf_append(char **buf, unsigned *buf_size, const char *st strcpy(*buf+buf_len, str); } -BOOL stabs_parse(struct module* module, unsigned long load_offset, +BOOL stabs_parse(struct module* module, ULONG_PTR load_offset, const char* pv_stab_ptr, int stablen, const char* strs, int strtablen, stabs_def_cb callback, void* user) @@ -1486,7 +1486,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, case 35: case 36: loc.reg = CV_REG_MM0 + n_value - 29; break; default: - FIXME("Unknown register value (%lu)\n", (unsigned long)n_value); + FIXME("Unknown register value (%lu)\n", (ULONG_PTR)n_value); loc.reg = CV_REG_NONE; break; } @@ -1520,7 +1520,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, assert(source_idx >= 0); if (curr_func != NULL) { - unsigned long offset = n_value; + ULONG_PTR offset = n_value; if (module->type == DMT_MACHO) offset -= curr_func->address - load_offset; symt_add_func_line(module, curr_func, source_idx, @@ -1636,7 +1636,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, case N_EXCL: if (stabs_add_include(stabs_find_include(ptr, n_value)) < 0) { - ERR("Excluded header not found (%s,%ld)\n", ptr, (unsigned long)n_value); + ERR("Excluded header not found (%s,%ld)\n", ptr, (ULONG_PTR)n_value); module_reset_debug_info(module); ret = FALSE; goto done; @@ -1683,7 +1683,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, } stabbuff[0] = '\0'; TRACE("0x%02x %lx %s\n", - stab_ptr->n_type, (unsigned long)n_value, debugstr_a(strs + stab_ptr->n_strx)); + stab_ptr->n_type, (ULONG_PTR)n_value, debugstr_a(strs + stab_ptr->n_strx)); } module->module.SymType = SymDia; module->module.CVSig = 'S' | ('T' << 8) | ('A' << 16) | ('B' << 24); diff --git a/dll/win32/dbghelp/storage.c b/dll/win32/dbghelp/storage.c index 7750ce64673..dd9d0583233 100644 --- a/dll/win32/dbghelp/storage.c +++ b/dll/win32/dbghelp/storage.c @@ -207,7 +207,7 @@ void* vector_add(struct vector* v, struct pool* pool) */ struct key2index { - unsigned long key; + ULONG_PTR key; unsigned index; }; @@ -223,7 +223,7 @@ void sparse_array_init(struct sparse_array* sa, unsigned elt_sz, unsigned bucket * Returns the first index which key is >= at passed key */ static struct key2index* sparse_array_lookup(const struct sparse_array* sa, - unsigned long key, unsigned* idx) + ULONG_PTR key, unsigned* idx) { struct key2index* pk2i; unsigned low, high; @@ -269,7 +269,7 @@ static struct key2index* sparse_array_lookup(const struct sparse_array* sa, return pk2i; } -void* sparse_array_find(const struct sparse_array* sa, unsigned long key) +void* sparse_array_find(const struct sparse_array* sa, ULONG_PTR key) { unsigned idx; struct key2index* pk2i; @@ -279,7 +279,7 @@ void* sparse_array_find(const struct sparse_array* sa, unsigned long key) return NULL; } -void* sparse_array_add(struct sparse_array* sa, unsigned long key, +void* sparse_array_add(struct sparse_array* sa, ULONG_PTR key, struct pool* pool) { unsigned idx, i; diff --git a/dll/win32/dbghelp/symbol.c b/dll/win32/dbghelp/symbol.c index 037641e0166..60859c6d0f1 100644 --- a/dll/win32/dbghelp/symbol.c +++ b/dll/win32/dbghelp/symbol.c @@ -207,7 +207,7 @@ static WCHAR* file_regex(const char* srcfile) } struct symt_compiland* symt_new_compiland(struct module* module, - unsigned long address, unsigned src_idx) + ULONG_PTR address, unsigned src_idx) { struct symt_compiland* sym; @@ -227,7 +227,7 @@ struct symt_public* symt_new_public(struct module* module, struct symt_compiland* compiland, const char* name, BOOL is_function, - unsigned long address, unsigned size) + ULONG_PTR address, unsigned size) { struct symt_public* sym; struct symt** p; @@ -258,7 +258,7 @@ struct symt_public* symt_new_public(struct module* module, struct symt_data* symt_new_global_variable(struct module* module, struct symt_compiland* compiland, const char* name, unsigned is_static, - struct location loc, unsigned long size, + struct location loc, ULONG_PTR size, struct symt* type) { struct symt_data* sym; @@ -295,7 +295,7 @@ struct symt_data* symt_new_global_variable(struct module* module, struct symt_function* symt_new_function(struct module* module, struct symt_compiland* compiland, const char* name, - unsigned long addr, unsigned long size, + ULONG_PTR addr, ULONG_PTR size, struct symt* sig_type) { struct symt_function* sym; @@ -326,7 +326,7 @@ struct symt_function* symt_new_function(struct module* module, } void symt_add_func_line(struct module* module, struct symt_function* func, - unsigned source_idx, int line_num, unsigned long offset) + unsigned source_idx, int line_num, ULONG_PTR offset) { struct line_info* dli; BOOL last_matches = FALSE; @@ -498,7 +498,7 @@ BOOL symt_normalize_function(struct module* module, const struct symt_function* struct symt_thunk* symt_new_thunk(struct module* module, struct symt_compiland* compiland, const char* name, THUNK_ORDINAL ord, - unsigned long addr, unsigned long size) + ULONG_PTR addr, ULONG_PTR size) { struct symt_thunk* sym; @@ -555,7 +555,7 @@ struct symt_data* symt_new_constant(struct module* module, struct symt_hierarchy_point* symt_new_label(struct module* module, struct symt_compiland* compiland, - const char* name, unsigned long address) + const char* name, ULONG_PTR address) { struct symt_hierarchy_point* sym; @@ -680,8 +680,8 @@ static void symt_fill_sym_info(struct module_pair* pair, switch (data->u.value.n1.n2.vt) { case VT_I4: sym_info->Value = (ULONG)data->u.value.n1.n2.n3.lVal; break; - case VT_I2: sym_info->Value = (ULONG)(long)data->u.value.n1.n2.n3.iVal; break; - case VT_I1: sym_info->Value = (ULONG)(long)data->u.value.n1.n2.n3.cVal; break; + case VT_I2: sym_info->Value = (ULONG)(LONG_PTR)data->u.value.n1.n2.n3.iVal; break; + case VT_I1: sym_info->Value = (ULONG)(LONG_PTR)data->u.value.n1.n2.n3.cVal; break; case VT_UI4: sym_info->Value = (ULONG)data->u.value.n1.n2.n3.ulVal; break; case VT_UI2: sym_info->Value = (ULONG)data->u.value.n1.n2.n3.uiVal; break; case VT_UI1: sym_info->Value = (ULONG)data->u.value.n1.n2.n3.bVal; break; diff --git a/dll/win32/dbghelp/type.c b/dll/win32/dbghelp/type.c index e069231b282..d020462f6d6 100644 --- a/dll/win32/dbghelp/type.c +++ b/dll/win32/dbghelp/type.c @@ -412,7 +412,7 @@ BOOL symt_add_function_signature_parameter(struct module* module, return TRUE; } -struct symt_pointer* symt_new_pointer(struct module* module, struct symt* ref_type, unsigned long size) +struct symt_pointer* symt_new_pointer(struct module* module, struct symt* ref_type, ULONG_PTR size) { struct symt_pointer* sym; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 60e8ae6e85e..a144f573d98 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: 8d702a3aa54fc61bd146f584e66364a12a0ee3a0 + wine: f803da493aeb4cf118fb9b076e8042c2535fbcdb
4 years, 8 months
1
0
0
0
[reactos] 120/179: [WINESYNC] dbghelp: Remove unused code in module_find_cb.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=31d5e64eb89e6ce8305bc…
commit 31d5e64eb89e6ce8305bc940a3441b26507617fb Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 18:39:25 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:50 2020 +0200 [WINESYNC] dbghelp: Remove unused code 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 8d702a3aa54fc61bd146f584e66364a12a0ee3a0 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/path.c | 26 +------------------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/dll/win32/dbghelp/path.c b/dll/win32/dbghelp/path.c index 4e7354f93ad..d404e483ae1 100644 --- a/dll/win32/dbghelp/path.c +++ b/dll/win32/dbghelp/path.c @@ -474,7 +474,7 @@ struct module_find static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user) { struct module_find* mf = user; - DWORD size, checksum, timestamp; + DWORD size, timestamp; unsigned matched = 0; /* the matching weights: @@ -524,30 +524,6 @@ static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user) if (timestamp == mf->dw1 && size == mf->dw2) matched++; } break; - case DMT_MACHO: - case DMT_ELF: - { - 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 - { - 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: { struct pdb_lookup pdb_lookup; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 323dc44f9fa..60e8ae6e85e 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: e3354e44f17d74f0ac4547d8a4494c83ea3d6d37 + wine: 8d702a3aa54fc61bd146f584e66364a12a0ee3a0
4 years, 8 months
1
0
0
0
[reactos] 119/179: [WINESYNC] dbghelp: Move reading debug base address from PEB to check_live_target.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e0db46fa2eab7e6d5987a…
commit e0db46fa2eab7e6d5987a8e24fa2c003f71da7f2 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 18:29:52 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:50 2020 +0200 [WINESYNC] dbghelp: Move reading debug base address from PEB to check_live_target. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id e3354e44f17d74f0ac4547d8a4494c83ea3d6d37 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp.c | 26 ++++++++++++--- dll/win32/dbghelp/dbghelp_private.h | 4 +-- dll/win32/dbghelp/elf_module.c | 55 ++++++------------------------- dll/win32/dbghelp/macho_module.c | 66 +++++++++---------------------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 5 files changed, 50 insertions(+), 103 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp.c b/dll/win32/dbghelp/dbghelp.c index 6e03cc3d385..a5acc786606 100644 --- a/dll/win32/dbghelp/dbghelp.c +++ b/dll/win32/dbghelp/dbghelp.c @@ -284,20 +284,36 @@ static BOOL WINAPI process_invade_cb(PCWSTR name, ULONG64 base, ULONG size, PVOI return TRUE; } +#ifndef DBGHELP_STATIC_LIB /****************************************************************** * check_live_target * */ static BOOL check_live_target(struct process* pcs) { + PROCESS_BASIC_INFORMATION pbi; + ULONG_PTR base = 0; + if (!GetProcessId(pcs->handle)) return FALSE; if (GetEnvironmentVariableA("DBGHELP_NOLIVE", NULL, 0)) return FALSE; -#ifndef DBGHELP_STATIC_LIB - if (!elf_read_wine_loader_dbg_info(pcs)) - macho_read_wine_loader_dbg_info(pcs); -#endif - return TRUE; + + if (NtQueryInformationProcess( pcs->handle, ProcessBasicInformation, + &pbi, sizeof(pbi), NULL )) + return FALSE; + + if (!pcs->is_64bit) + { + PEB32 *peb32 = (PEB32 *)pbi.PebBaseAddress; + DWORD base32 = 0; + ReadProcessMemory(pcs->handle, &peb32->Reserved[0], &base32, sizeof(base32), NULL); + base = base32; + } + else ReadProcessMemory(pcs->handle, &pbi.PebBaseAddress->Reserved[0], &base, sizeof(base), NULL); + + TRACE("got debug info address %#lx from PEB %p\n", base, pbi.PebBaseAddress); + return elf_read_wine_loader_dbg_info(pcs, base) || macho_read_wine_loader_dbg_info(pcs, base); } +#endif /****************************************************************** * SymInitializeW (DBGHELP.@) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index d2f4b27bf90..49cf51fff24 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -635,12 +635,12 @@ extern struct cpu* cpu_find(DWORD) DECLSPEC_HIDDEN; extern DWORD calc_crc32(HANDLE handle) DECLSPEC_HIDDEN; /* elf_module.c */ -extern BOOL elf_read_wine_loader_dbg_info(struct process* pcs) DECLSPEC_HIDDEN; +extern BOOL elf_read_wine_loader_dbg_info(struct process* pcs, ULONG_PTR addr) DECLSPEC_HIDDEN; 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_read_wine_loader_dbg_info(struct process* pcs) DECLSPEC_HIDDEN; +extern BOOL macho_read_wine_loader_dbg_info(struct process* pcs, ULONG_PTR addr) DECLSPEC_HIDDEN; /* minidump.c */ void minidump_add_memory_block(struct dump_context* dc, ULONG64 base, ULONG size, ULONG rva) DECLSPEC_HIDDEN; diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 20c68dc1ab3..50ad89f53f7 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1661,48 +1661,6 @@ static 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; -} - static const struct loader_ops elf_loader_ops = { elf_synchronize_module_list, @@ -1717,12 +1675,19 @@ static const struct loader_ops elf_loader_ops = * * Try to find a decent wine executable which could have loaded the debuggee */ -BOOL elf_read_wine_loader_dbg_info(struct process* pcs) +BOOL elf_read_wine_loader_dbg_info(struct process* pcs, ULONG_PTR addr) { struct elf_info elf_info; + WCHAR *loader; + BOOL ret; elf_info.flags = ELF_INFO_DEBUG_HEADER | ELF_INFO_MODULE; - if (!elf_search_loader(pcs, &elf_info) || !elf_info.dbg_hdr_addr) return FALSE; + loader = get_wine_loader_name(pcs); + ret = elf_search_and_load_file(pcs, loader, addr, 0, &elf_info); + heap_free(loader); + if (!ret || !elf_info.dbg_hdr_addr) return FALSE; + + TRACE("Found ELF debug header %#lx\n", elf_info.dbg_hdr_addr); elf_info.module->format_info[DFI_ELF]->u.elf_info->elf_loader = 1; module_set_module(elf_info.module, S_WineLoaderW); pcs->dbg_hdr_addr = elf_info.dbg_hdr_addr; @@ -1737,7 +1702,7 @@ BOOL elf_map_handle(HANDLE handle, struct image_file_map* fmap) return FALSE; } -BOOL elf_read_wine_loader_dbg_info(struct process* pcs) +BOOL elf_read_wine_loader_dbg_info(struct process* pcs, ULONG_PTR addr) { return FALSE; } diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 8e2fa796e03..43a98c9c726 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -129,14 +129,12 @@ struct section_info unsigned int section_index; }; -#define MACHO_INFO_DEBUG_HEADER 0x0001 -#define MACHO_INFO_MODULE 0x0002 -#define MACHO_INFO_NAME 0x0004 +#define MACHO_INFO_MODULE 0x0001 +#define MACHO_INFO_NAME 0x0002 struct macho_info { unsigned flags; /* IN one (or several) of the MACHO_INFO constants */ - unsigned long dbg_hdr_addr; /* OUT address of debug header (if MACHO_INFO_DEBUG_HEADER is set) */ struct module* module; /* OUT loaded module (if MACHO_INFO_MODULE is set) */ const WCHAR* module_name; /* OUT found module name (if MACHO_INFO_NAME is set) */ }; @@ -1373,32 +1371,7 @@ static void macho_module_remove(struct process* pcs, struct module_format* modfm */ static ULONG_PTR get_dyld_image_info_address(struct process* pcs) { - NTSTATUS status; - PROCESS_BASIC_INFORMATION pbi; ULONG_PTR dyld_image_info_address = 0; - BOOL ret; - - /* Get address of PEB */ - status = NtQueryInformationProcess(pcs->handle, ProcessBasicInformation, &pbi, sizeof(pbi), NULL); - if (status == STATUS_SUCCESS) - { - /* Read dyld image info address from PEB */ - if (pcs->is_64bit) - ret = ReadProcessMemory(pcs->handle, &pbi.PebBaseAddress->Reserved[0], - &dyld_image_info_address, sizeof(dyld_image_info_address), NULL); - else - { - PEB32 *peb32 = (PEB32 *)pbi.PebBaseAddress; - ULONG addr32; - ret = ReadProcessMemory(pcs->handle, &peb32->Reserved[0], &addr32, - sizeof(addr32), NULL); - dyld_image_info_address = addr32; - } - - if (ret) - TRACE("got dyld_image_info_address %#lx from PEB %p\n", - dyld_image_info_address, pbi.PebBaseAddress); - } #ifndef __LP64__ /* No reading the symtab with nlist(3) in LP64 */ if (!dyld_image_info_address) @@ -1451,14 +1424,6 @@ static BOOL macho_load_file(struct process* pcs, const WCHAR* filename, 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. - */ - if (macho_info->flags & MACHO_INFO_DEBUG_HEADER) - { - macho_info->dbg_hdr_addr = (unsigned long)get_dyld_image_info_address(pcs); - ret = TRUE; - } - if (macho_info->flags & MACHO_INFO_MODULE) { struct macho_module_info *macho_module_info; @@ -1736,7 +1701,7 @@ static BOOL macho_enum_modules(struct process* process, enum_modules_cb cb, void BOOL ret; TRACE("(%p, %p, %p)\n", process->handle, cb, user); - macho_info.flags = MACHO_INFO_DEBUG_HEADER | MACHO_INFO_NAME; + macho_info.flags = 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; @@ -1823,9 +1788,7 @@ static struct module* macho_load_module(struct process* pcs, const WCHAR* name, */ static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_info) { - WCHAR *loader = get_wine_loader_name(pcs); BOOL ret = FALSE; - ULONG_PTR dyld_image_info_address; union wine_all_image_infos image_infos; union wine_image_info image_info; uint32_t len; @@ -1836,9 +1799,8 @@ static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_in len = sizeof(image_infos.infos64); else len = sizeof(image_infos.infos32); - dyld_image_info_address = get_dyld_image_info_address(pcs); - if (dyld_image_info_address && - ReadProcessMemory(pcs->handle, (void*)dyld_image_info_address, &image_infos, len, NULL)) + if (pcs->dbg_hdr_addr && + ReadProcessMemory(pcs->handle, (void*)pcs->dbg_hdr_addr, &image_infos, len, NULL)) { if (pcs->is_64bit) len = sizeof(image_info.info64); @@ -1898,8 +1860,11 @@ static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_in } if (!ret) - ret = macho_search_and_load_file(pcs, loader, 0, macho_info); - heap_free(loader); + { + WCHAR *loader = get_wine_loader_name(pcs); + ret = loader && macho_search_and_load_file(pcs, loader, 0, macho_info); + heap_free(loader); + } return ret; } @@ -1917,23 +1882,24 @@ static const struct loader_ops macho_loader_ops = * * Try to find a decent wine executable which could have loaded the debuggee */ -BOOL macho_read_wine_loader_dbg_info(struct process* pcs) +BOOL macho_read_wine_loader_dbg_info(struct process* pcs, ULONG_PTR addr) { struct macho_info macho_info; TRACE("(%p/%p)\n", pcs, pcs->handle); - macho_info.flags = MACHO_INFO_DEBUG_HEADER | MACHO_INFO_MODULE; - if (!macho_search_loader(pcs, &macho_info) || !macho_info.dbg_hdr_addr) return FALSE; + pcs->dbg_hdr_addr = addr ? addr : get_dyld_image_info_address(pcs); + macho_info.flags = MACHO_INFO_MODULE; + if (!macho_search_loader(pcs, &macho_info)) return FALSE; macho_info.module->format_info[DFI_MACHO]->u.macho_info->is_loader = 1; module_set_module(macho_info.module, S_WineLoaderW); - pcs->dbg_hdr_addr = macho_info.dbg_hdr_addr; pcs->loader = &macho_loader_ops; + TRACE("Found macho debug header %#lx\n", pcs->dbg_hdr_addr); return TRUE; } #else /* HAVE_MACH_O_LOADER_H */ -BOOL macho_read_wine_loader_dbg_info(struct process* pcs) +BOOL macho_read_wine_loader_dbg_info(struct process* pcs, ULONG_PTR addr) { return FALSE; } diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index b547254b48b..323dc44f9fa 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: 635506921a28c65bfc9b339d59c63d96092d97d8 + wine: e3354e44f17d74f0ac4547d8a4494c83ea3d6d37
4 years, 8 months
1
0
0
0
[reactos] 118/179: [WINESYNC] dbghelp: Use PE type for virtual modules.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ab49d97a84f646dd278fd…
commit ab49d97a84f646dd278fd93559c5228c9cb7aeda Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 18:27:48 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:50 2020 +0200 [WINESYNC] dbghelp: Use PE type for virtual modules. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 635506921a28c65bfc9b339d59c63d96092d97d8 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/module.c | 61 +----------------------------------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 2 insertions(+), 61 deletions(-) diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c index dcc73aa40ff..e4cd98b224a 100644 --- a/dll/win32/dbghelp/module.c +++ b/dll/win32/dbghelp/module.c @@ -41,9 +41,6 @@ const WCHAR S_ElfW[] = {'<','e','l','f','>','\0'}; const WCHAR S_WineLoaderW[] = {'<','w','i','n','e','-','l','o','a','d','e','r','>','\0'}; #endif static const WCHAR S_DotSoW[] = {'.','s','o','\0'}; -static const WCHAR S_DotDylibW[] = {'.','d','y','l','i','b','\0'}; -static const WCHAR S_DotPdbW[] = {'.','p','d','b','\0'}; -static const WCHAR S_DotDbgW[] = {'.','d','b','g','\0'}; const WCHAR S_SlashW[] = {'/','\0'}; static const WCHAR S_AcmW[] = {'.','a','c','m','\0'}; @@ -480,61 +477,6 @@ static BOOL module_is_container_loaded(const struct process* pcs, return FALSE; } -/****************************************************************** - * module_get_type_by_name - * - * Guesses a filename type from its extension - */ -enum module_type module_get_type_by_name(const WCHAR* name) -{ - int len = strlenW(name); - - /* Skip all version extensions (.[digits]) regex: "(\.\d+)*$" */ - do - { - int i = len; - - while (i && name[i - 1] >= '0' && name[i - 1] <= '9') i--; - - if (i && name[i - 1] == '.') - len = i - 1; - else - break; - } while (len); - - /* check for terminating .so or .so.[digit] */ - /* FIXME: Can't rely solely on extension; have to check magic or - * stop using .so on Mac OS X. For now, base on platform. */ - if (len > 3 && !memcmp(name + len - 3, S_DotSoW, 3)) -#ifdef __APPLE__ - return DMT_MACHO; -#else - return DMT_ELF; -#endif - - if (len > 6 && !strncmpiW(name + len - 6, S_DotDylibW, 6)) - return DMT_MACHO; - - if (len > 4 && !strncmpiW(name + len - 4, S_DotPdbW, 4)) - return DMT_PDB; - - if (len > 4 && !strncmpiW(name + len - 4, S_DotDbgW, 4)) - return DMT_DBG; - - /* wine is also a native module (Mach-O on Mac OS X, ELF elsewhere) */ -#ifndef __REACTOS__ - if (is_wine_loader(name)) - { -#ifdef __APPLE__ - return DMT_MACHO; -#else - return DMT_ELF; -#endif - } -#endif - return DMT_PE; -} - static BOOL image_check_debug_link(const WCHAR* file, struct image_file_map* fmap, DWORD link_crc) { DWORD read_bytes; @@ -871,8 +813,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam if (Flags & SLMFLAG_VIRTUAL) { if (!wImageName) return FALSE; - module = module_new(pcs, wImageName, module_get_type_by_name(wImageName), - TRUE, BaseOfDll, SizeOfDll, 0, 0); + module = module_new(pcs, wImageName, DMT_PE, TRUE, BaseOfDll, SizeOfDll, 0, 0); if (!module) return FALSE; if (wModuleName) module_set_module(module, wModuleName); module->module.SymType = SymVirtual; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index c4d061cf398..b547254b48b 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: c8b5a3be55963fcda51b8e13c10bcd45ecc4bc97 + wine: 635506921a28c65bfc9b339d59c63d96092d97d8
4 years, 8 months
1
0
0
0
[reactos] 117/179: [WINESYNC] dbghelp: Explicitly pass file type to path_find_symbol_file.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=065f0d9772fe95f3cb2b4…
commit 065f0d9772fe95f3cb2b48716ea7173e187d23e6 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 18:27:43 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:49 2020 +0200 [WINESYNC] dbghelp: Explicitly pass file type to path_find_symbol_file. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id c8b5a3be55963fcda51b8e13c10bcd45ecc4bc97 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp_private.h | 4 +--- dll/win32/dbghelp/msc.c | 4 ++-- dll/win32/dbghelp/path.c | 4 ++-- dll/win32/dbghelp/pe_module.c | 2 +- sdk/tools/winesync/dbghelp.cfg | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index 39394ead267..d2f4b27bf90 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -672,8 +672,6 @@ extern struct module* extern struct module* module_get_containee(const struct process* pcs, const struct module* inner) DECLSPEC_HIDDEN; -extern enum module_type - module_get_type_by_name(const WCHAR* name) DECLSPEC_HIDDEN; extern void module_reset_debug_info(struct module* module) DECLSPEC_HIDDEN; extern BOOL module_remove(struct process* pcs, struct module* module) DECLSPEC_HIDDEN; @@ -698,7 +696,7 @@ extern BOOL pdb_virtual_unwind(struct cpu_stack_walk *csw, DWORD_PTR ip, /* path.c */ extern BOOL path_find_symbol_file(const struct process* pcs, const struct module* module, - PCSTR full_path, const GUID* guid, DWORD dw1, DWORD dw2, + PCSTR full_path, enum module_type type, const GUID* guid, DWORD dw1, DWORD dw2, WCHAR *buffer, BOOL* is_unmatched) DECLSPEC_HIDDEN; extern WCHAR *get_dos_file_name(const WCHAR *filename) DECLSPEC_HIDDEN; extern BOOL search_dll_path(const WCHAR *name, BOOL (*match)(void*, HANDLE, const WCHAR*), void *param) DECLSPEC_HIDDEN; diff --git a/dll/win32/dbghelp/msc.c b/dll/win32/dbghelp/msc.c index 4be0cb244da..6696fa02e4e 100644 --- a/dll/win32/dbghelp/msc.c +++ b/dll/win32/dbghelp/msc.c @@ -2458,11 +2458,11 @@ static HANDLE map_pdb_file(const struct process* pcs, switch (lookup->kind) { case PDB_JG: - ret = path_find_symbol_file(pcs, module, lookup->filename, NULL, lookup->timestamp, + ret = path_find_symbol_file(pcs, module, lookup->filename, DMT_PDB, NULL, lookup->timestamp, lookup->age, dbg_file_path, &module->module.PdbUnmatched); break; case PDB_DS: - ret = path_find_symbol_file(pcs, module, lookup->filename, &lookup->guid, 0, + ret = path_find_symbol_file(pcs, module, lookup->filename, DMT_PDB, &lookup->guid, 0, lookup->age, dbg_file_path, &module->module.PdbUnmatched); break; } diff --git a/dll/win32/dbghelp/path.c b/dll/win32/dbghelp/path.c index 023adfa1037..4e7354f93ad 100644 --- a/dll/win32/dbghelp/path.c +++ b/dll/win32/dbghelp/path.c @@ -619,7 +619,7 @@ static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user) } BOOL path_find_symbol_file(const struct process* pcs, const struct module* module, - PCSTR full_path, const GUID* guid, DWORD dw1, DWORD dw2, + PCSTR full_path, enum module_type type, const GUID* guid, DWORD dw1, DWORD dw2, WCHAR *buffer, BOOL* is_unmatched) { struct module_find mf; @@ -638,7 +638,7 @@ BOOL path_find_symbol_file(const struct process* pcs, const struct module* modul MultiByteToWideChar(CP_ACP, 0, full_path, -1, full_pathW, MAX_PATH); filename = file_name(full_pathW); - mf.kind = module_get_type_by_name(filename); + mf.kind = type; *is_unmatched = FALSE; /* first check full path to file */ diff --git a/dll/win32/dbghelp/pe_module.c b/dll/win32/dbghelp/pe_module.c index 62328bb8d49..b915911d6ce 100644 --- a/dll/win32/dbghelp/pe_module.c +++ b/dll/win32/dbghelp/pe_module.c @@ -577,7 +577,7 @@ static BOOL pe_load_dbg_file(const struct process* pcs, struct module* module, TRACE("Processing DBG file %s\n", debugstr_a(dbg_name)); - if (path_find_symbol_file(pcs, module, dbg_name, NULL, timestamp, 0, tmp, &module->module.DbgUnmatched) && + if (path_find_symbol_file(pcs, module, dbg_name, DMT_DBG, NULL, timestamp, 0, tmp, &module->module.DbgUnmatched) && (hFile = CreateFileW(tmp, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE && ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) && diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 0225532289a..c4d061cf398 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: a676c5785ea56fede37370cd6d5e4508e9d8c62a + wine: c8b5a3be55963fcda51b8e13c10bcd45ecc4bc97
4 years, 8 months
1
0
0
0
[reactos] 116/179: [WINESYNC] dbghelp: Use loader_ops for load_debug_info.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=87c943516fa3c2547d28d…
commit 87c943516fa3c2547d28d80da716cca782043461 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:17:04 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 load_debug_info. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id a676c5785ea56fede37370cd6d5e4508e9d8c62a 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 | 7 ++----- dll/win32/dbghelp/module.c | 25 +++++++++---------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 5 files changed, 16 insertions(+), 31 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index a232547a514..39394ead267 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -424,6 +424,7 @@ struct loader_ops { BOOL (*synchronize_module_list)(struct process* process); struct module* (*load_module)(struct process* process, const WCHAR* name, ULONG_PTR addr); + BOOL (*load_debug_info)(struct process *process, struct module* module); 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); }; @@ -634,13 +635,11 @@ extern struct cpu* cpu_find(DWORD) DECLSPEC_HIDDEN; extern DWORD calc_crc32(HANDLE handle) DECLSPEC_HIDDEN; /* elf_module.c */ -extern BOOL elf_load_debug_info(struct module* module) DECLSPEC_HIDDEN; extern BOOL elf_read_wine_loader_dbg_info(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; /* macho_module.c */ -extern BOOL macho_load_debug_info(struct process *pcs, struct module* module) DECLSPEC_HIDDEN; extern BOOL macho_read_wine_loader_dbg_info(struct process* pcs) DECLSPEC_HIDDEN; /* minidump.c */ diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 038a552e429..20c68dc1ab3 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1041,7 +1041,7 @@ static BOOL elf_load_debug_info_from_map(struct module* module, * * Loads ELF debugging information from the module image file. */ -BOOL elf_load_debug_info(struct module* module) +static BOOL elf_load_debug_info(struct process* process, struct module* module) { BOOL ret = TRUE; struct pool pool; @@ -1198,7 +1198,7 @@ static BOOL elf_load_file_from_fmap(struct process* pcs, const WCHAR* filename, elf_info->module->module.SymType = SymDeferred; ret = TRUE; } - else ret = elf_load_debug_info(elf_info->module); + else ret = elf_load_debug_info(pcs, elf_info->module); elf_module_info->elf_mark = 1; elf_module_info->elf_loader = 0; @@ -1707,6 +1707,7 @@ static const struct loader_ops elf_loader_ops = { elf_synchronize_module_list, elf_load_module, + elf_load_debug_info, elf_enum_modules, elf_fetch_file_info, }; @@ -1741,11 +1742,6 @@ BOOL elf_read_wine_loader_dbg_info(struct process* pcs) return FALSE; } -BOOL elf_load_debug_info(struct module* module) -{ - return FALSE; -} - int elf_is_in_thunk_area(unsigned long addr, const struct elf_thunk_area* thunks) { diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index c55443905b0..8e2fa796e03 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -1281,7 +1281,7 @@ static BOOL image_uses_split_segs(struct process* process, unsigned long load_ad * * Loads Mach-O debugging information from the module image file. */ -BOOL macho_load_debug_info(struct process *pcs, struct module* module) +static BOOL macho_load_debug_info(struct process *pcs, struct module* module) { BOOL ret = FALSE; struct macho_debug_info mdi; @@ -1907,6 +1907,7 @@ static const struct loader_ops macho_loader_ops = { macho_synchronize_module_list, macho_load_module, + macho_load_debug_info, macho_enum_modules, macho_fetch_file_info, }; @@ -1937,8 +1938,4 @@ BOOL macho_read_wine_loader_dbg_info(struct process* pcs) return FALSE; } -BOOL macho_load_debug_info(struct process *pcs, struct module* module) -{ - return FALSE; -} #endif /* HAVE_MACH_O_LOADER_H */ diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c index 4634893eb82..dcc73aa40ff 100644 --- a/dll/win32/dbghelp/module.c +++ b/dll/win32/dbghelp/module.c @@ -387,14 +387,8 @@ BOOL module_get_debug(struct module_pair* pair) BOOL ret; if (pair->effective->is_virtual) ret = FALSE; - else switch (pair->effective->type) + else if (pair->effective->type == DMT_PE) { -#ifndef DBGHELP_STATIC_LIB - case DMT_ELF: - ret = elf_load_debug_info(pair->effective); - break; -#endif - case DMT_PE: idslW64.SizeOfStruct = sizeof(idslW64); idslW64.BaseOfImage = pair->effective->module.BaseOfImage; idslW64.CheckSum = pair->effective->module.CheckSum; @@ -409,16 +403,9 @@ BOOL module_get_debug(struct module_pair* pair) pcs_callback(pair->pcs, ret ? CBA_DEFERRED_SYMBOL_LOAD_COMPLETE : CBA_DEFERRED_SYMBOL_LOAD_FAILURE, &idslW64); - break; -#ifndef DBGHELP_STATIC_LIB - case DMT_MACHO: - ret = macho_load_debug_info(pair->pcs, pair->effective); - break; -#endif - default: - ret = FALSE; - break; } + else ret = pair->pcs->loader->load_debug_info(pair->pcs, pair->effective); + if (!ret) pair->effective->module.SymType = SymNone; assert(pair->effective->module.SymType != SymDeferred); pair->effective->module.NumSyms = pair->effective->ht_symbols.num_elts; @@ -1457,6 +1444,11 @@ static struct module* native_load_module(struct process* pcs, const WCHAR* name, return NULL; } +static BOOL native_load_debug_info(struct process* process, struct module* module) +{ + return FALSE; +} + static BOOL native_enum_modules(struct process *process, enum_modules_cb cb, void* user) { return FALSE; @@ -1472,6 +1464,7 @@ const struct loader_ops no_loader_ops = { native_synchronize_module_list, native_load_module, + native_load_debug_info, native_enum_modules, native_fetch_file_info, }; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 7a4f813471b..0225532289a 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: 5ae3f969d4ec525a14a8109a5ee4c5a2e2238405 + wine: a676c5785ea56fede37370cd6d5e4508e9d8c62a
4 years, 8 months
1
0
0
0
[reactos] 115/179: [WINESYNC] dbghelp: Use loader_ops for load_module.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f308fa857b45f6d9c7314…
commit f308fa857b45f6d9c7314d8dac9e02b04da3be1f Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:15:29 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 load_module. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 5ae3f969d4ec525a14a8109a5ee4c5a2e2238405 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp_private.h | 5 +---- dll/win32/dbghelp/elf_module.c | 8 ++------ dll/win32/dbghelp/macho_module.c | 8 ++------ dll/win32/dbghelp/module.c | 21 +++++++-------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 5 files changed, 13 insertions(+), 31 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index 472b05a1b9d..a232547a514 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -423,6 +423,7 @@ typedef BOOL (*enum_modules_cb)(const WCHAR*, unsigned long addr, void* user); struct loader_ops { BOOL (*synchronize_module_list)(struct process* process); + struct module* (*load_module)(struct process* process, const WCHAR* name, ULONG_PTR addr); 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); }; @@ -634,16 +635,12 @@ extern DWORD calc_crc32(HANDLE handle) DECLSPEC_HIDDEN; /* elf_module.c */ 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; 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_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; extern BOOL macho_read_wine_loader_dbg_info(struct process* pcs) DECLSPEC_HIDDEN; /* minidump.c */ diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 64c550a67bd..038a552e429 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1583,7 +1583,7 @@ static BOOL elf_load_cb(const WCHAR* name, unsigned long load_addr, * Also, find module real name and load address from * the real loaded modules list in pcs address space */ -struct module* elf_load_module(struct process* pcs, const WCHAR* name, unsigned long addr) +static struct module* elf_load_module(struct process* pcs, const WCHAR* name, unsigned long addr) { struct elf_load el; @@ -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_load_module, elf_enum_modules, elf_fetch_file_info, }; @@ -1740,11 +1741,6 @@ BOOL elf_read_wine_loader_dbg_info(struct process* pcs) return FALSE; } -struct module* elf_load_module(struct process* pcs, const WCHAR* name, unsigned long addr) -{ - return NULL; -} - BOOL elf_load_debug_info(struct module* module) { return FALSE; diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index df38129e12c..c55443905b0 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -1782,7 +1782,7 @@ static BOOL macho_load_cb(const WCHAR* name, unsigned long addr, void* user) * 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) +static struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsigned long addr) { struct macho_load ml; @@ -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_load_module, macho_enum_modules, macho_fetch_file_info, }; @@ -1936,11 +1937,6 @@ BOOL macho_read_wine_loader_dbg_info(struct process* pcs) return FALSE; } -struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsigned long addr) -{ - return NULL; -} - BOOL macho_load_debug_info(struct process *pcs, struct module* module) { return FALSE; diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c index 61a069ec75b..4634893eb82 100644 --- a/dll/win32/dbghelp/module.c +++ b/dll/win32/dbghelp/module.c @@ -919,20 +919,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam wImageName) { /* and finally an ELF or Mach-O module */ -#ifndef DBGHELP_STATIC_LIB - switch (module_get_type_by_name(wImageName)) - { - case DMT_ELF: - module = elf_load_module(pcs, wImageName, BaseOfDll); - break; - case DMT_MACHO: - module = macho_load_module(pcs, wImageName, BaseOfDll); - break; - default: - /* Ignored */ - break; - } -#endif + module = pcs->loader->load_module(pcs, wImageName, BaseOfDll); } } if (!module) @@ -1465,6 +1452,11 @@ static BOOL native_synchronize_module_list(struct process* pcs) return FALSE; } +static struct module* native_load_module(struct process* pcs, const WCHAR* name, unsigned long addr) +{ + return NULL; +} + static BOOL native_enum_modules(struct process *process, enum_modules_cb cb, void* user) { return FALSE; @@ -1479,6 +1471,7 @@ 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_load_module, native_enum_modules, native_fetch_file_info, }; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 06702ac9f61..7a4f813471b 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: 16a3481bd22243183281c60ff375d4e61d5c4198 + wine: 5ae3f969d4ec525a14a8109a5ee4c5a2e2238405
4 years, 8 months
1
0
0
0
[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, 8 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, 8 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, 8 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, 8 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, 8 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, 8 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, 8 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, 8 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, 8 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, 8 months
1
0
0
0
[reactos] 104/179: [WINESYNC] dbghelp: Introduce search_unix_path helper and use it in elf_search_and_load_file.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=73bb9b5ffdadeda94e09d…
commit 73bb9b5ffdadeda94e09d53c92bf756b8be5ff3b 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: Introduce search_unix_path helper and use it in elf_search_and_load_file. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id ca49552f646bf30b492da4668745f9f65b9de18d by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp_private.h | 1 + dll/win32/dbghelp/elf_module.c | 49 +++---------------------------------- dll/win32/dbghelp/path.c | 43 ++++++++++++++++++++++++++++++++ sdk/tools/winesync/dbghelp.cfg | 2 +- 4 files changed, 48 insertions(+), 47 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index ac528c5dbe5..d98ccedf64a 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -704,6 +704,7 @@ extern BOOL path_find_symbol_file(const struct process* pcs, const struc WCHAR *buffer, BOOL* is_unmatched) DECLSPEC_HIDDEN; extern WCHAR *get_dos_file_name(const WCHAR *filename) DECLSPEC_HIDDEN; extern BOOL search_dll_path(const WCHAR *name, BOOL (*match)(void*, HANDLE, const WCHAR*), void *param) DECLSPEC_HIDDEN; +extern BOOL search_unix_path(const WCHAR *name, const char *path, BOOL (*match)(void*, HANDLE, const WCHAR*), void *param) DECLSPEC_HIDDEN; extern const WCHAR* file_name(const WCHAR* str) DECLSPEC_HIDDEN; extern const char* file_nameA(const char* str) DECLSPEC_HIDDEN; diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 0433bf77e05..0b60524fc44 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1274,47 +1274,6 @@ static BOOL elf_load_file_cb(void *param, HANDLE handle, const WCHAR *filename) return elf_load_file(load_file->process, filename, load_file->load_offset, load_file->dyn_addr, load_file->elf_info); } -/****************************************************************** - * elf_load_file_from_path - * tries to load an ELF file from a set of paths (separated by ':') - */ -static BOOL elf_load_file_from_path(HANDLE hProcess, - const WCHAR* filename, - unsigned long load_offset, - unsigned long dyn_addr, - const char* path, - struct elf_info* elf_info) -{ - BOOL ret = FALSE; - WCHAR *s, *t, *fn; - WCHAR* pathW = NULL; - unsigned len; - - 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 = elf_load_file(hProcess, fn, load_offset, dyn_addr, elf_info); - HeapFree(GetProcessHeap(), 0, fn); - if (ret) break; - } - - HeapFree(GetProcessHeap(), 0, pathW); - return ret; -} - #ifdef AT_SYSINFO_EHDR /****************************************************************** * elf_search_auxv @@ -1418,11 +1377,9 @@ static BOOL elf_search_and_load_file(struct process* pcs, const WCHAR* filename, load_elf.dyn_addr = dyn_addr; load_elf.elf_info = elf_info; - ret = elf_load_file_from_path(pcs, filename, load_offset, dyn_addr, - getenv("PATH"), elf_info) || - elf_load_file_from_path(pcs, filename, load_offset, dyn_addr, - getenv("LD_LIBRARY_PATH"), elf_info); - if (!ret) ret = search_dll_path(filename, elf_load_file_cb, &load_elf); + ret = search_unix_path(filename, getenv("PATH"), elf_load_file_cb, &load_elf) + || search_unix_path(filename, getenv("LD_LIBRARY_PATH"), elf_load_file_cb, &load_elf) + || search_dll_path(filename, elf_load_file_cb, &load_elf); } return ret; diff --git a/dll/win32/dbghelp/path.c b/dll/win32/dbghelp/path.c index e10318d35c6..a5b8b4fdd8d 100644 --- a/dll/win32/dbghelp/path.c +++ b/dll/win32/dbghelp/path.c @@ -807,4 +807,47 @@ found: heap_free(buf); return TRUE; } + +BOOL search_unix_path(const WCHAR *name, const char *path, BOOL (*match)(void*, HANDLE, const WCHAR*), void *param) +{ + const char *iter, *next; + size_t size, len; + WCHAR *dos_path; + char *buf; + BOOL ret = FALSE; + + if (!path) return FALSE; + name = file_name(name); + + size = WideCharToMultiByte(CP_UNIXCP, 0, name, -1, NULL, 0, NULL, NULL) + strlen(path) + 1; + if (!(buf = heap_alloc(size))) return FALSE; + + for (iter = path;; iter = next + 1) + { + if (!(next = strchr(iter, ':'))) next = iter + strlen(iter); + if (*iter == '/') + { + len = next - iter; + memcpy(buf, iter, len); + if (buf[len - 1] != '/') buf[len++] = '/'; + WideCharToMultiByte(CP_UNIXCP, 0, name, -1, buf + len, size - len, NULL, NULL); + if ((dos_path = wine_get_dos_file_name(buf))) + { + HANDLE file = CreateFileW(dos_path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (file != INVALID_HANDLE_VALUE) + { + ret = match(param, file, dos_path); + CloseHandle(file); + if (ret) TRACE("found %s\n", debugstr_w(dos_path)); + } + heap_free(dos_path); + if (ret) break; + } + } + if (*next != ':') break; + } + + heap_free(buf); + return ret; +} #endif diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 719150f9ac5..df209bd3ca0 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: ee5d29b7aa85c109bf9ad5ac59fbe484f53da0ea + wine: ca49552f646bf30b492da4668745f9f65b9de18d
4 years, 8 months
1
0
0
0
[reactos] 103/179: [WINESYNC] dbghelp: Use search_dll_path in elf_search_and_load_file.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bf9bb9c911cc91b343a39…
commit bf9bb9c911cc91b343a3928007b37a1443fb1500 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_dll_path in elf_search_and_load_file. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id ee5d29b7aa85c109bf9ad5ac59fbe484f53da0ea by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 59 +++++++++++++++--------------------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 22 insertions(+), 39 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 34fffdae5bd..0433bf77e05 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -38,7 +38,6 @@ #include "image_private.h" -#include "wine/library.h" #include "wine/debug.h" #include "wine/heap.h" @@ -1261,6 +1260,20 @@ static BOOL elf_load_file(struct process* pcs, const WCHAR* filename, return ret; } +struct elf_load_file_params +{ + struct process *process; + ULONG_PTR load_offset; + ULONG_PTR dyn_addr; + struct elf_info *elf_info; +}; + +static BOOL elf_load_file_cb(void *param, HANDLE handle, const WCHAR *filename) +{ + struct elf_load_file_params *load_file = param; + return elf_load_file(load_file->process, filename, load_file->load_offset, load_file->dyn_addr, load_file->elf_info); +} + /****************************************************************** * elf_load_file_from_path * tries to load an ELF file from a set of paths (separated by ':') @@ -1302,41 +1315,6 @@ static BOOL elf_load_file_from_path(HANDLE hProcess, return ret; } -/****************************************************************** - * elf_load_file_from_dll_path - * - * Tries to load an ELF file from the dll path - */ -static BOOL elf_load_file_from_dll_path(HANDLE hProcess, - const WCHAR* filename, - unsigned long load_offset, - unsigned long dyn_addr, - struct elf_info* elf_info) -{ - BOOL ret = FALSE; - unsigned int index = 0; - const char *path; - - 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 = elf_load_file(hProcess, name, load_offset, dyn_addr, elf_info); - HeapFree( GetProcessHeap(), 0, name ); - } - return ret; -} - #ifdef AT_SYSINFO_EHDR /****************************************************************** * elf_search_auxv @@ -1434,12 +1412,17 @@ static BOOL elf_search_and_load_file(struct process* pcs, const WCHAR* filename, /* if relative pathname, try some absolute base dirs */ if (!ret && filename == file_name(filename)) { + struct elf_load_file_params load_elf; + load_elf.process = pcs; + load_elf.load_offset = load_offset; + load_elf.dyn_addr = dyn_addr; + load_elf.elf_info = elf_info; + ret = elf_load_file_from_path(pcs, filename, load_offset, dyn_addr, getenv("PATH"), elf_info) || elf_load_file_from_path(pcs, filename, load_offset, dyn_addr, getenv("LD_LIBRARY_PATH"), elf_info); - if (!ret) ret = elf_load_file_from_dll_path(pcs, filename, - load_offset, dyn_addr, elf_info); + if (!ret) ret = search_dll_path(filename, elf_load_file_cb, &load_elf); } return ret; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index d0e56271d9c..719150f9ac5 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: 21af2e194792aaa263c144c8fb42fe678ad2ecd7 + wine: ee5d29b7aa85c109bf9ad5ac59fbe484f53da0ea
4 years, 8 months
1
0
0
0
[reactos] 102/179: [WINESYNC] dbghelp: Make dll builtin PE path search helper more generic.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e01d28abd821f1bdac444…
commit e01d28abd821f1bdac44479581046e280736057c 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: Make dll builtin PE path search helper more generic. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 21af2e194792aaa263c144c8fb42fe678ad2ecd7 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp_private.h | 1 + dll/win32/dbghelp/path.c | 88 +++++++++++++++++++++++++++++++++++ dll/win32/dbghelp/pe_module.c | 91 ++++++++----------------------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 4 files changed, 110 insertions(+), 72 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index 661a939eec8..ac528c5dbe5 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -703,6 +703,7 @@ extern BOOL path_find_symbol_file(const struct process* pcs, const struc PCSTR full_path, const GUID* guid, DWORD dw1, DWORD dw2, WCHAR *buffer, BOOL* is_unmatched) DECLSPEC_HIDDEN; extern WCHAR *get_dos_file_name(const WCHAR *filename) DECLSPEC_HIDDEN; +extern BOOL search_dll_path(const WCHAR *name, BOOL (*match)(void*, HANDLE, const WCHAR*), void *param) DECLSPEC_HIDDEN; extern const WCHAR* file_name(const WCHAR* str) DECLSPEC_HIDDEN; extern const char* file_nameA(const char* str) DECLSPEC_HIDDEN; diff --git a/dll/win32/dbghelp/path.c b/dll/win32/dbghelp/path.c index 1b04d97e136..e10318d35c6 100644 --- a/dll/win32/dbghelp/path.c +++ b/dll/win32/dbghelp/path.c @@ -720,3 +720,91 @@ WCHAR *get_dos_file_name(const WCHAR *filename) } return dos_path; } + +#ifndef __REACTOS__ +BOOL search_dll_path(const WCHAR *name, BOOL (*match)(void*, HANDLE, const WCHAR*), void *param) +{ + size_t len, i; + HANDLE file; + WCHAR *buf; + BOOL ret; + + static const WCHAR winebuilddirW[] = {'W','I','N','E','B','U','I','L','D','D','I','R',0}; + static const WCHAR winedlldirW[] = {'W','I','N','E','D','L','L','D','I','R','%','u',0}; + + name = file_name(name); + + if ((len = GetEnvironmentVariableW(winebuilddirW, NULL, 0))) + { + WCHAR *p, *end; + const WCHAR dllsW[] = { '\\','d','l','l','s','\\' }; + const WCHAR programsW[] = { '\\','p','r','o','g','r','a','m','s','\\' }; + const WCHAR dot_dllW[] = {'.','d','l','l',0}; + const WCHAR dot_exeW[] = {'.','e','x','e',0}; + const WCHAR dot_soW[] = {'.','s','o',0}; + + if (!(buf = heap_alloc((len + 8 + 3 * lstrlenW(name)) * sizeof(WCHAR)))) return FALSE; + end = buf + GetEnvironmentVariableW(winebuilddirW, buf, len); + + memcpy(end, dllsW, sizeof(dllsW)); + strcpyW(end + ARRAY_SIZE(dllsW), name); + if ((p = strrchrW(end, '.')) && !lstrcmpW(p, dot_soW)) *p = 0; + if ((p = strrchrW(end, '.')) && !lstrcmpW(p, dot_dllW)) *p = 0; + p = end + strlenW(end); + *p++ = '\\'; + strcpyW(p, name); + file = CreateFileW(buf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (file != INVALID_HANDLE_VALUE) + { + ret = match(param, file, buf); + CloseHandle(file); + if (ret) goto found; + } + + memcpy(end, programsW, sizeof(programsW)); + end += ARRAY_SIZE(programsW); + strcpyW(end, name); + if ((p = strrchrW(end, '.')) && !lstrcmpW(p, dot_soW)) *p = 0; + if ((p = strrchrW(end, '.')) && !lstrcmpW(p, dot_exeW)) *p = 0; + p = end + strlenW(end); + *p++ = '\\'; + strcpyW(p, name); + file = CreateFileW(buf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (file != INVALID_HANDLE_VALUE) + { + ret = match(param, file, buf); + CloseHandle(file); + if (ret) goto found; + } + + heap_free(buf); + } + + for (i = 0;; i++) + { + WCHAR env_name[64]; + sprintfW(env_name, winedlldirW, i); + if (!(len = GetEnvironmentVariableW(env_name, NULL, 0))) break; + if (!(buf = heap_alloc((len + lstrlenW(name) + 2) * sizeof(WCHAR)))) return FALSE; + + len = GetEnvironmentVariableW(env_name, buf, len); + buf[len++] = '\\'; + strcpyW(buf + len, name); + file = CreateFileW(buf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (file != INVALID_HANDLE_VALUE) + { + ret = match(param, file, buf); + CloseHandle(file); + if (ret) goto found; + } + heap_free(buf); + } + + return FALSE; + +found: + TRACE("found %s\n", debugstr_w(buf)); + heap_free(buf); + return TRUE; +} +#endif diff --git a/dll/win32/dbghelp/pe_module.c b/dll/win32/dbghelp/pe_module.c index 0eb97e9e0c7..62328bb8d49 100644 --- a/dll/win32/dbghelp/pe_module.c +++ b/dll/win32/dbghelp/pe_module.c @@ -775,68 +775,23 @@ BOOL pe_load_debug_info(const struct process* pcs, struct module* module) } #ifndef __REACTOS__ -static WCHAR *find_builtin_pe(const WCHAR *path, HANDLE *file) +struct builtin_search { - const WCHAR *base_name; - size_t len, i; - WCHAR *buf; + WCHAR *path; + struct image_file_map fmap; +}; - static const WCHAR winebuilddirW[] = {'W','I','N','E','B','U','I','L','D','D','I','R',0}; - static const WCHAR winedlldirW[] = {'W','I','N','E','D','L','L','D','I','R','%','u',0}; +static BOOL search_builtin_pe(void *param, HANDLE handle, const WCHAR *path) +{ + struct builtin_search *search = param; + size_t size; - if ((base_name = strrchrW(path, '\\'))) base_name++; - else base_name = path; + if (!pe_map_file(handle, &search->fmap, DMT_PE)) return FALSE; - if ((len = GetEnvironmentVariableW(winebuilddirW, NULL, 0))) - { - WCHAR *p, *end; - const WCHAR dllsW[] = { '\\','d','l','l','s','\\' }; - const WCHAR programsW[] = { '\\','p','r','o','g','r','a','m','s','\\' }; - const WCHAR dot_dllW[] = {'.','d','l','l',0}; - const WCHAR dot_exeW[] = {'.','e','x','e',0}; - - if (!(buf = heap_alloc((len + 8 + 2 * lstrlenW(base_name)) * sizeof(WCHAR)))) return NULL; - end = buf + GetEnvironmentVariableW(winebuilddirW, buf, len); - - memcpy(end, dllsW, sizeof(dllsW)); - strcpyW(end + ARRAY_SIZE(dllsW), base_name); - if ((p = strchrW(end, '.')) && !lstrcmpW(p, dot_dllW)) *p = 0; - p = end + strlenW(end); - *p++ = '\\'; - strcpyW(p, base_name); - *file = CreateFileW(buf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (*file != INVALID_HANDLE_VALUE) return buf; - - memcpy(end, programsW, sizeof(programsW)); - end += ARRAY_SIZE(programsW); - strcpyW(end, base_name); - if ((p = strchrW(end, '.')) && !lstrcmpW(p, dot_exeW)) *p = 0; - p = end + strlenW(end); - *p++ = '\\'; - strcpyW(p, base_name); - *file = CreateFileW(buf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (*file != INVALID_HANDLE_VALUE) return buf; - - heap_free(buf); - } - - for (i = 0;; i++) - { - WCHAR name[64]; - sprintfW(name, winedlldirW, i); - if (!(len = GetEnvironmentVariableW(name, NULL, 0))) break; - if (!(buf = heap_alloc((len + lstrlenW(base_name) + 2) * sizeof(WCHAR)))) return NULL; - - GetEnvironmentVariableW(name, buf, len); - buf[len++] = '\\'; - strcpyW(buf + len, base_name); - *file = CreateFileW(buf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (*file != INVALID_HANDLE_VALUE) return buf; - - heap_free(buf); - } - - return NULL; + size = (lstrlenW(path) + 1) * sizeof(WCHAR); + if ((search->path = heap_alloc(size))) + memcpy(search->path, path, size); + return TRUE; } #endif @@ -870,18 +825,12 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, if (pe_map_file(hFile, &modfmt->u.pe_info->fmap, DMT_PE)) { #ifndef __REACTOS__ - WCHAR *builtin_path = NULL; - HANDLE builtin_module; - if (modfmt->u.pe_info->fmap.u.pe.builtin && (builtin_path = find_builtin_pe(loaded_name, &builtin_module))) + struct builtin_search builtin = { NULL }; + if (modfmt->u.pe_info->fmap.u.pe.builtin && search_dll_path(loaded_name, search_builtin_pe, &builtin)) { - struct image_file_map builtin_fmap; - if (pe_map_file(builtin_module, &builtin_fmap, DMT_PE)) - { - TRACE("reloaded %s from %s\n", debugstr_w(loaded_name), debugstr_w(builtin_path)); - image_unmap_file(&modfmt->u.pe_info->fmap); - modfmt->u.pe_info->fmap = builtin_fmap; - } - CloseHandle(builtin_module); + TRACE("reloaded %s from %s\n", debugstr_w(loaded_name), debugstr_w(builtin.path)); + image_unmap_file(&modfmt->u.pe_info->fmap); + modfmt->u.pe_info->fmap = builtin.fmap; } #endif if (!base) base = modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.ImageBase; @@ -895,7 +844,7 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, #ifdef __REACTOS__ module->real_path = NULL; #else - module->real_path = builtin_path; + module->real_path = builtin.path; #endif modfmt->module = module; modfmt->remove = pe_module_remove; @@ -912,7 +861,7 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, { ERR("could not load the module '%s'\n", debugstr_w(loaded_name)); #ifndef __REACTOS__ - heap_free(module->real_path); + heap_free(builtin.path); #endif image_unmap_file(&modfmt->u.pe_info->fmap); } diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 3ef3ca41a9b..d0e56271d9c 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: 77e880e6d22ef9be031f783fbb4b6a5e8c8826e8 + wine: 21af2e194792aaa263c144c8fb42fe678ad2ecd7
4 years, 8 months
1
0
0
0
[reactos] 101/179: [WINESYNC] dbghelp: Use file_name helper in more places.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=981f24bd1a7cb595b06e6…
commit 981f24bd1a7cb595b06e6b344590c370a37b2392 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:10:40 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:47 2020 +0200 [WINESYNC] dbghelp: Use file_name helper in more places. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 77e880e6d22ef9be031f783fbb4b6a5e8c8826e8 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp_private.h | 2 ++ dll/win32/dbghelp/elf_module.c | 14 +++++--------- dll/win32/dbghelp/macho_module.c | 21 +++++++-------------- dll/win32/dbghelp/module.c | 4 ++-- dll/win32/dbghelp/path.c | 4 ++-- sdk/tools/winesync/dbghelp.cfg | 2 +- 6 files changed, 19 insertions(+), 28 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index bfb193635e7..661a939eec8 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -703,6 +703,8 @@ extern BOOL path_find_symbol_file(const struct process* pcs, const struc PCSTR full_path, const GUID* guid, DWORD dw1, DWORD dw2, WCHAR *buffer, BOOL* is_unmatched) DECLSPEC_HIDDEN; extern WCHAR *get_dos_file_name(const WCHAR *filename) DECLSPEC_HIDDEN; +extern const WCHAR* file_name(const WCHAR* str) DECLSPEC_HIDDEN; +extern const char* file_nameA(const char* str) DECLSPEC_HIDDEN; /* pe_module.c */ extern BOOL pe_load_nt_header(HANDLE hProc, DWORD64 base, IMAGE_NT_HEADERS* nth) DECLSPEC_HIDDEN; diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index a11e73a0e13..34fffdae5bd 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -727,8 +727,7 @@ static const Elf64_Sym *elf_lookup_symtab(const struct module* module, { compiland_name = source_get(module, ((const struct symt_compiland*)compiland)->source); - compiland_basename = strrchr(compiland_name, '/'); - if (!compiland_basename++) compiland_basename = compiland_name; + compiland_basename = file_nameA(compiland_name); } else compiland_name = compiland_basename = NULL; @@ -745,8 +744,7 @@ static const Elf64_Sym *elf_lookup_symtab(const struct module* module, const char* filename = source_get(module, ste->compiland->source); if (strcmp(filename, compiland_name)) { - base = strrchr(filename, '/'); - if (!base++) base = filename; + base = file_nameA(filename); if (strcmp(base, compiland_basename)) continue; } } @@ -1434,7 +1432,7 @@ static BOOL elf_search_and_load_file(struct process* pcs, const WCHAR* filename, if (strstrW(filename, S_libstdcPPW)) return FALSE; /* We know we can't do it */ ret = elf_load_file(pcs, filename, load_offset, dyn_addr, elf_info); /* if relative pathname, try some absolute base dirs */ - if (!ret && !strchrW(filename, '/')) + if (!ret && filename == file_name(filename)) { ret = elf_load_file_from_path(pcs, filename, load_offset, dyn_addr, getenv("PATH"), elf_info) || @@ -1689,8 +1687,7 @@ static BOOL elf_load_cb(const WCHAR* name, unsigned long load_addr, /* memcmp is needed for matches when bufstr contains also version information * el->name: libc.so, name: libc.so.6.0 */ - p = strrchrW(name, '/'); - if (!p++) p = name; + p = file_name(name); } if (!el->name || !memcmp(p, el->name, lstrlenW(el->name) * sizeof(WCHAR))) @@ -1724,8 +1721,7 @@ struct module* elf_load_module(struct process* pcs, const WCHAR* name, unsigned /* do only the lookup from the filename, not the path (as we lookup module * name in the process' loaded module list) */ - el.name = strrchrW(name, '/'); - if (!el.name++) el.name = name; + el.name = file_name(name); el.ret = FALSE; if (!elf_enum_modules_internal(pcs, NULL, elf_load_cb, &el)) diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 8fa05d312ac..4bc0a3e903c 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -1193,10 +1193,7 @@ static void find_and_map_dsym(struct process *pcs, struct module* module) if (!fmap->uuid) return; - if ((p = strrchrW(module->module.LoadedImageName, '/'))) - p++; - else - p = module->module.LoadedImageName; + p = file_name(module->module.LoadedImageName); len = strlenW(module->module.LoadedImageName) + strlenW(dot_dsym) + strlenW(dsym_subpath) + strlenW(p) + 1; path = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (!path) @@ -1637,19 +1634,17 @@ 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 */ /* If has no directories, try PATH first. */ - if (!strchrW(filename, '/')) + p = file_name(filename); + if (p == filename) { ret = macho_load_file_from_path(pcs, filename, load_addr, getenv("PATH"), macho_info); } /* Try DYLD_LIBRARY_PATH, with just the filename (no directories). */ if (!ret) - { - if ((p = strrchrW(filename, '/'))) p++; - else p = filename; ret = macho_load_file_from_path(pcs, p, load_addr, getenv("DYLD_LIBRARY_PATH"), macho_info); - } + /* Try the path as given. */ if (!ret) ret = macho_load_file(pcs, filename, load_addr, macho_info); @@ -1661,7 +1656,7 @@ static BOOL macho_search_and_load_file(struct process* pcs, const WCHAR* filenam fallback = "/usr/local/lib:/lib:/usr/lib"; ret = macho_load_file_from_path(pcs, p, load_addr, fallback, macho_info); } - if (!ret && !strchrW(filename, '/')) + if (!ret && p == filename) ret = macho_load_file_from_dll_path(pcs, filename, load_addr, macho_info); return ret; @@ -1957,8 +1952,7 @@ static BOOL macho_load_cb(const WCHAR* name, unsigned long addr, void* user) /* memcmp is needed for matches when bufstr contains also version information * ml->name: libc.so, name: libc.so.6.0 */ - p = strrchrW(name, '/'); - if (!p++) p = name; + 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); @@ -1989,8 +1983,7 @@ struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsign /* do only the lookup from the filename, not the path (as we lookup module * name in the process' loaded module list) */ - ml.name = strrchrW(name, '/'); - if (!ml.name++) ml.name = name; + ml.name = file_name(name); ml.ret = FALSE; if (!macho_enum_modules_internal(pcs, NULL, macho_load_cb, &ml)) diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c index df2dc178c4e..c04224f9532 100644 --- a/dll/win32/dbghelp/module.c +++ b/dll/win32/dbghelp/module.c @@ -87,14 +87,14 @@ static BOOL is_wine_loader(const WCHAR *module) static const WCHAR wineW[] = {'w','i','n','e',0}; static const WCHAR suffixW[] = {'6','4',0}; const WCHAR *filename = get_filename(module, NULL); - const char *ptr, *p; + const char *ptr; BOOL ret = FALSE; WCHAR *buffer; DWORD len; if ((ptr = getenv("WINELOADER"))) { - if ((p = strrchr(ptr, '/'))) ptr = p + 1; + ptr = file_nameA(ptr); len = 2 + MultiByteToWideChar( CP_UNIXCP, 0, ptr, -1, NULL, 0 ); buffer = heap_alloc( len * sizeof(WCHAR) ); MultiByteToWideChar( CP_UNIXCP, 0, ptr, -1, buffer, len ); diff --git a/dll/win32/dbghelp/path.c b/dll/win32/dbghelp/path.c index 704fbbdee35..1b04d97e136 100644 --- a/dll/win32/dbghelp/path.c +++ b/dll/win32/dbghelp/path.c @@ -34,7 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); static inline BOOL is_sepA(char ch) {return ch == '/' || ch == '\\';} static inline BOOL is_sep(WCHAR ch) {return ch == '/' || ch == '\\';} -static inline const char* file_nameA(const char* str) +const char* file_nameA(const char* str) { const char* p; @@ -42,7 +42,7 @@ static inline const char* file_nameA(const char* str) return p + 1; } -static inline const WCHAR* file_name(const WCHAR* str) +const WCHAR* file_name(const WCHAR* str) { const WCHAR* p; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index c7908ce19ac..3ef3ca41a9b 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: 63d41a41f21c4d9f32b484d6c7ed78c9d7b2a48d + wine: 77e880e6d22ef9be031f783fbb4b6a5e8c8826e8
4 years, 8 months
1
0
0
0
[reactos] 100/179: [WINESYNC] dbghelp: Rename helpers to make unicode variants default.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eaa0c1a8d79dbabec7dd8…
commit eaa0c1a8d79dbabec7dd87b63afcce82323d68e4 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:10:40 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:47 2020 +0200 [WINESYNC] dbghelp: Rename helpers to make unicode variants default. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 63d41a41f21c4d9f32b484d6c7ed78c9d7b2a48d by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/path.c | 24 ++++++++++++------------ sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dll/win32/dbghelp/path.c b/dll/win32/dbghelp/path.c index feb951ad55d..704fbbdee35 100644 --- a/dll/win32/dbghelp/path.c +++ b/dll/win32/dbghelp/path.c @@ -31,22 +31,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); -static inline BOOL is_sep(char ch) {return ch == '/' || ch == '\\';} -static inline BOOL is_sepW(WCHAR ch) {return ch == '/' || ch == '\\';} +static inline BOOL is_sepA(char ch) {return ch == '/' || ch == '\\';} +static inline BOOL is_sep(WCHAR ch) {return ch == '/' || ch == '\\';} -static inline const char* file_name(const char* str) +static inline const char* file_nameA(const char* str) { const char* p; - for (p = str + strlen(str) - 1; p >= str && !is_sep(*p); p--); + for (p = str + strlen(str) - 1; p >= str && !is_sepA(*p); p--); return p + 1; } -static inline const WCHAR* file_nameW(const WCHAR* str) +static inline const WCHAR* file_name(const WCHAR* str) { const WCHAR* p; - for (p = str + strlenW(str) - 1; p >= str && !is_sepW(*p); p--); + for (p = str + strlenW(str) - 1; p >= str && !is_sep(*p); p--); return p + 1; } @@ -54,7 +54,7 @@ static inline void file_pathW(const WCHAR *src, WCHAR *dst) { int len; - for (len = strlenW(src) - 1; (len > 0) && (!is_sepW(src[len])); len--); + for (len = strlenW(src) - 1; (len > 0) && (!is_sep(src[len])); len--); memcpy( dst, src, len * sizeof(WCHAR) ); dst[len] = 0; } @@ -71,7 +71,7 @@ HANDLE WINAPI FindDebugInfoFile(PCSTR FileName, PCSTR SymbolPath, PSTR DebugFile OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (h == INVALID_HANDLE_VALUE) { - if (!SearchPathA(SymbolPath, file_name(FileName), NULL, MAX_PATH, DebugFilePath, NULL)) + if (!SearchPathA(SymbolPath, file_nameA(FileName), NULL, MAX_PATH, DebugFilePath, NULL)) return NULL; h = CreateFileA(DebugFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); @@ -181,7 +181,7 @@ BOOL WINAPI SymMatchFileNameW(PCWSTR file, PCWSTR match, while (fptr >= file && mptr >= match) { - if (toupperW(*fptr) != toupperW(*mptr) && !(is_sepW(*fptr) && is_sepW(*mptr))) + if (toupperW(*fptr) != toupperW(*mptr) && !(is_sep(*fptr) && is_sep(*mptr))) break; fptr--; mptr--; } @@ -208,7 +208,7 @@ BOOL WINAPI SymMatchFileName(PCSTR file, PCSTR match, while (fptr >= file && mptr >= match) { - if (toupper(*fptr) != toupper(*mptr) && !(is_sep(*fptr) && is_sep(*mptr))) + if (toupper(*fptr) != toupper(*mptr) && !(is_sepA(*fptr) && is_sepA(*mptr))) break; fptr--; mptr--; } @@ -385,7 +385,7 @@ BOOL WINAPI SymFindFileInPathW(HANDLE hProcess, PCWSTR searchPath, PCWSTR full_p s.cb = cb; s.user = user; - filename = file_nameW(full_path); + filename = file_name(full_path); /* first check full path to file */ if (sffip_cb(full_path, &s)) @@ -642,7 +642,7 @@ BOOL path_find_symbol_file(const struct process* pcs, const struct module* modul mf.matched = 0; MultiByteToWideChar(CP_ACP, 0, full_path, -1, full_pathW, MAX_PATH); - filename = file_nameW(full_pathW); + filename = file_name(full_pathW); mf.kind = module_get_type_by_name(filename); *is_unmatched = FALSE; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 7d82868d7c7..c7908ce19ac 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: 1ece841d9354296f374228b9e16246a076f57196 + wine: 63d41a41f21c4d9f32b484d6c7ed78c9d7b2a48d
4 years, 8 months
1
0
0
0
[reactos] 99/179: [WINESYNC] dbghelp: Use page size from sysinfo.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cf4c36cd267418c768608…
commit cf4c36cd267418c768608fb8a8f3501de531e94f Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:10:39 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:47 2020 +0200 [WINESYNC] dbghelp: Use page size from sysinfo. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 1ece841d9354296f374228b9e16246a076f57196 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 2 +- dll/win32/dbghelp/macho_module.c | 2 +- sdk/tools/winesync/dbghelp.cfg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 5a6bef947ac..a11e73a0e13 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -403,7 +403,7 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map* { static const BYTE elf_signature[4] = { ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3 }; unsigned int i; - size_t tmp, page_mask = sysconf( _SC_PAGESIZE ) - 1; + size_t tmp, page_mask = sysinfo.dwPageSize - 1; WCHAR *dos_path; unsigned char e_ident[EI_NIDENT]; diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index f10dc78eec8..8fa05d312ac 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -569,7 +569,7 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load struct section_info* info = user; BOOL ignore; int i; - unsigned long tmp, page_mask = sysconf( _SC_PAGESIZE ) - 1; + unsigned long tmp, page_mask = sysinfo.dwPageSize - 1; uint64_t vmaddr, vmsize; char segname[16]; uint32_t nsects; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index aa34cee7d51..7d82868d7c7 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: 7544b9f6fb0bf39c714452968e20e478efaa104a + wine: 1ece841d9354296f374228b9e16246a076f57196
4 years, 8 months
1
0
0
0
[reactos] 98/179: [WINESYNC] dbghelp: Call GetSystemInfo in DllMain.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e2e4ea2f5f0bebd00f156…
commit e2e4ea2f5f0bebd00f156fb92d223f733f8a856b Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:10:39 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:46 2020 +0200 [WINESYNC] dbghelp: Call GetSystemInfo in DllMain. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 7544b9f6fb0bf39c714452968e20e478efaa104a by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp.c | 17 +++++++++++++++++ dll/win32/dbghelp/dbghelp_private.h | 3 +++ dll/win32/dbghelp/elf_module.c | 2 -- dll/win32/dbghelp/macho_module.c | 2 -- sdk/tools/winesync/dbghelp.cfg | 2 +- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp.c b/dll/win32/dbghelp/dbghelp.c index b59ee6a269c..da1649b80a9 100644 --- a/dll/win32/dbghelp/dbghelp.c +++ b/dll/win32/dbghelp/dbghelp.c @@ -73,9 +73,26 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); unsigned dbghelp_options = SYMOPT_UNDNAME; BOOL dbghelp_opt_native = FALSE; +#ifndef __REACTOS__ +SYSTEM_INFO sysinfo; +#endif static struct process* process_first /* = NULL */; +#ifndef __REACTOS__ +BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) +{ + switch (reason) + { + case DLL_PROCESS_ATTACH: + GetSystemInfo(&sysinfo); + DisableThreadLibraryCalls(instance); + break; + } + return TRUE; +} +#endif + /****************************************************************** * process_find_by_handle * diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index aecde06ac62..bfb193635e7 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -128,6 +128,9 @@ 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; +#ifndef __REACTOS__ +extern SYSTEM_INFO sysinfo DECLSPEC_HIDDEN; +#endif enum location_kind {loc_error, /* reg is the error code */ loc_unavailable, /* location is not available */ diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 142f2f036af..5a6bef947ac 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/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/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 725363b316f..f10dc78eec8 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/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; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index ae9cbda6d4c..aa34cee7d51 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: ebf57f01f4890b726a0af702ab7751258f5ab03d + wine: 7544b9f6fb0bf39c714452968e20e478efaa104a
4 years, 8 months
1
0
0
0
[reactos] 97/179: [WINESYNC] dbghelp: Use Windows API to map macho files.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6a54330242f9d9382a4b0…
commit 6a54330242f9d9382a4b09330e9a34699df8e305 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:10:38 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:46 2020 +0200 [WINESYNC] dbghelp: Use Windows API to map macho files. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id ebf57f01f4890b726a0af702ab7751258f5ab03d by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/image_private.h | 2 +- dll/win32/dbghelp/macho_module.c | 136 +++++++++++++++++--------------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 3 files changed, 62 insertions(+), 78 deletions(-) diff --git a/dll/win32/dbghelp/image_private.h b/dll/win32/dbghelp/image_private.h index b6f864aa84d..253f1252101 100644 --- a/dll/win32/dbghelp/image_private.h +++ b/dll/win32/dbghelp/image_private.h @@ -94,7 +94,7 @@ struct image_file_map { size_t segs_size; size_t segs_start; - int fd; + HANDLE handle; struct image_file_map* dsym; /* the debug symbols file associated with this one */ #ifdef HAVE_MACH_O_LOADER_H diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 5960b0dfc37..725363b316f 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -152,18 +152,6 @@ 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 * @@ -174,18 +162,18 @@ static DWORD macho_calc_crc32(int fd) */ static void macho_calc_range(const struct macho_file_map* fmap, unsigned long offset, unsigned long len, unsigned long* out_aligned_offset, - unsigned long* out_aligned_end, unsigned long* out_aligned_len, - unsigned long* out_misalign) + unsigned long* out_aligned_end, unsigned long* out_misalign) { - unsigned long pagemask = sysconf( _SC_PAGESIZE ) - 1; + 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; *out_aligned_offset = file_offset - misalign; - *out_aligned_end = (file_offset + len + pagemask) & ~pagemask; - if (out_aligned_len) - *out_aligned_len = *out_aligned_end - *out_aligned_offset; + *out_aligned_end = file_offset + len; if (out_misalign) *out_misalign = misalign; } @@ -198,19 +186,29 @@ static void macho_calc_range(const struct macho_file_map* fmap, unsigned long of static const char* macho_map_range(const struct macho_file_map* fmap, unsigned long offset, unsigned long len, const char** base) { - unsigned long misalign, aligned_offset, aligned_map_end, map_size; + unsigned long misalign, aligned_offset, aligned_map_end; const void* aligned_ptr; + HANDLE mapping; - TRACE("(%p/%d, 0x%08lx, 0x%08lx)\n", fmap, fmap->fd, offset, len); + TRACE("(%p/%p, 0x%08lx, 0x%08lx)\n", fmap, fmap->handle, offset, len); - macho_calc_range(fmap, offset, len, &aligned_offset, &aligned_map_end, - &map_size, &misalign); + macho_calc_range(fmap, offset, len, &aligned_offset, &aligned_map_end, &misalign); - aligned_ptr = mmap(NULL, map_size, PROT_READ, MAP_PRIVATE, fmap->fd, aligned_offset); + if (!(mapping = CreateFileMappingW(fmap->handle, NULL, PAGE_READONLY, 0, 0, NULL))) + { + ERR("map creation %p failed %u size %lu\n", fmap->handle, GetLastError(), aligned_map_end); + return IMAGE_NO_MAP; + } + aligned_ptr = MapViewOfFile(mapping, FILE_MAP_READ, 0, aligned_offset, aligned_map_end - aligned_offset); + CloseHandle(mapping); + if (!aligned_ptr) + { + ERR("map failed %u\n", GetLastError()); + return IMAGE_NO_MAP; + } TRACE("Mapped (0x%08lx - 0x%08lx) to %p\n", aligned_offset, aligned_map_end, aligned_ptr); - if (aligned_ptr == MAP_FAILED) return IMAGE_NO_MAP; if (base) *base = aligned_ptr; return (const char*)aligned_ptr + misalign; @@ -224,23 +222,21 @@ static const char* macho_map_range(const struct macho_file_map* fmap, unsigned l static void macho_unmap_range(const char** base, const void** mapped, const struct macho_file_map* fmap, unsigned long offset, unsigned long len) { - TRACE("(%p, %p, %p/%d, 0x%08lx, 0x%08lx)\n", base, mapped, fmap, fmap->fd, offset, len); + TRACE("(%p, %p, %p/%p, 0x%08lx, 0x%08lx)\n", base, mapped, fmap, fmap->handle, offset, len); if ((mapped && *mapped != IMAGE_NO_MAP) || (base && *base != IMAGE_NO_MAP)) { - unsigned long misalign, aligned_offset, aligned_map_end, map_size; + unsigned long misalign, aligned_offset, aligned_map_end; void* aligned_ptr; - macho_calc_range(fmap, offset, len, &aligned_offset, &aligned_map_end, - &map_size, &misalign); + macho_calc_range(fmap, offset, len, &aligned_offset, &aligned_map_end, &misalign); if (mapped) aligned_ptr = (char*)*mapped - misalign; else aligned_ptr = (void*)*base; - if (munmap(aligned_ptr, map_size) < 0) + if (!UnmapViewOfFile(aligned_ptr)) WARN("Couldn't unmap the range\n"); - TRACE("Unmapped (0x%08lx - 0x%08lx) from %p - %p\n", aligned_offset, aligned_map_end, aligned_ptr, (char*)aligned_ptr + map_size); if (mapped) *mapped = IMAGE_NO_MAP; if (base) @@ -263,11 +259,11 @@ static BOOL macho_map_ranges(const struct macho_file_map* fmap, unsigned long aligned_offset1, aligned_map_end1; unsigned long aligned_offset2, aligned_map_end2; - TRACE("(%p/%d, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx, %p, %p)\n", fmap, fmap->fd, + TRACE("(%p/%p, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx, %p, %p)\n", fmap, fmap->handle, offset1, len1, offset2, len2, mapped1, mapped2); - macho_calc_range(fmap, offset1, len1, &aligned_offset1, &aligned_map_end1, NULL, NULL); - macho_calc_range(fmap, offset2, len2, &aligned_offset2, &aligned_map_end2, NULL, NULL); + macho_calc_range(fmap, offset1, len1, &aligned_offset1, &aligned_map_end1, NULL); + macho_calc_range(fmap, offset2, len2, &aligned_offset2, &aligned_map_end2, NULL); if (aligned_map_end1 < aligned_offset2 || aligned_map_end2 < aligned_offset1) { @@ -315,11 +311,11 @@ static void macho_unmap_ranges(const struct macho_file_map* fmap, unsigned long aligned_offset1, aligned_map_end1; unsigned long aligned_offset2, aligned_map_end2; - TRACE("(%p/%d, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx, %p/%p, %p/%p)\n", fmap, fmap->fd, + TRACE("(%p/%p, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx, %p/%p, %p/%p)\n", fmap, fmap->handle, offset1, len1, offset2, len2, mapped1, *mapped1, mapped2, *mapped2); - macho_calc_range(fmap, offset1, len1, &aligned_offset1, &aligned_map_end1, NULL, NULL); - macho_calc_range(fmap, offset2, len2, &aligned_offset2, &aligned_map_end2, NULL, NULL); + macho_calc_range(fmap, offset1, len1, &aligned_offset1, &aligned_map_end1, NULL); + macho_calc_range(fmap, offset2, len2, &aligned_offset2, &aligned_map_end2, NULL); if (aligned_map_end1 < aligned_offset2 || aligned_map_end2 < aligned_offset1) { @@ -509,7 +505,7 @@ static int macho_enum_load_commands(struct image_file_map *ifm, unsigned cmd, int i; int count = 0; - TRACE("(%p/%d, %u, %p, %p)\n", fmap, fmap->fd, cmd, cb, user); + TRACE("(%p/%p, %u, %p, %p)\n", fmap, fmap->handle, cmd, cb, user); if ((lc = macho_map_load_commands(fmap)) == IMAGE_NO_MAP) return -1; @@ -555,7 +551,7 @@ static int macho_count_sections(struct image_file_map* ifm, const struct load_co nsects = sc->nsects; } - TRACE("(%p/%d, %p, %p) segment %s\n", ifm, ifm->u.macho.fd, lc, user, + TRACE("(%p/%p, %p, %p) segment %s\n", ifm, ifm->u.macho.handle, lc, user, debugstr_an(segname, sizeof(segname))); ifm->u.macho.num_sections += nsects; @@ -600,7 +596,7 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load sections = (const void *)(sc + 1); } - TRACE("(%p/%d, %p, %p) before: 0x%08lx - 0x%08lx\n", fmap, fmap->fd, lc, user, + TRACE("(%p/%p, %p, %p) before: 0x%08lx - 0x%08lx\n", fmap, fmap->handle, lc, user, (unsigned long)fmap->segs_start, (unsigned long)fmap->segs_size); TRACE("Segment command vm: 0x%08lx - 0x%08lx\n", (unsigned long)vmaddr, (unsigned long)(vmaddr + vmsize)); @@ -674,7 +670,7 @@ static inline void reset_file_map(struct image_file_map* ifm) { struct macho_file_map* fmap = &ifm->u.macho; - fmap->fd = -1; + fmap->handle = INVALID_HANDLE_VALUE; fmap->dsym = NULL; fmap->load_commands = IMAGE_NO_MAP; fmap->uuid = NULL; @@ -692,15 +688,14 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW, { struct macho_file_map* fmap = &ifm->u.macho; struct fat_header fat_header; - struct stat statbuf; int i; - char* filename; - unsigned len; + WCHAR* filename; struct section_info info; BOOL ret = FALSE; 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; uint32_t target_cmd = (pcs->is_64bit) ? LC_SEGMENT_64 : LC_SEGMENT; + DWORD bytes_read; TRACE("(%s, %p)\n", debugstr_w(filenameW), fmap); @@ -712,31 +707,19 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW, ifm->addr_size = (pcs->is_64bit) ? 64 : 32; fmap->header_size = (pcs->is_64bit) ? sizeof(struct mach_header_64) : sizeof(struct mach_header); - len = WideCharToMultiByte(CP_UNIXCP, 0, filenameW, -1, NULL, 0, NULL, NULL); - if (!(filename = HeapAlloc(GetProcessHeap(), 0, len))) - { - WARN("failed to allocate filename buffer\n"); - return FALSE; - } - WideCharToMultiByte(CP_UNIXCP, 0, filenameW, -1, filename, len, NULL, NULL); - - /* check that the file exists */ - if (stat(filename, &statbuf) == -1 || S_ISDIR(statbuf.st_mode)) - { - TRACE("stat() failed or %s is directory: %s\n", debugstr_a(filename), strerror(errno)); - goto done; - } + if (!(filename = get_dos_file_name(filenameW))) return FALSE; - /* Now open the file, so that we can mmap() it. */ - if ((fmap->fd = open(filename, O_RDONLY)) == -1) + /* Now open the file, so that we can map it. */ + fmap->handle = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + if (fmap->handle == INVALID_HANDLE_VALUE) { - TRACE("failed to open file %s: %d\n", debugstr_a(filename), errno); + TRACE("failed to open file %s: %d\n", debugstr_w(filename), errno); goto done; } - if (read(fmap->fd, &fat_header, sizeof(fat_header)) != sizeof(fat_header)) + if (!ReadFile(fmap->handle, &fat_header, sizeof(fat_header), &bytes_read, NULL) || bytes_read != sizeof(fat_header)) { - TRACE("failed to read fat header: %d\n", errno); + TRACE("failed to read fat header: %u\n", GetLastError()); goto done; } TRACE("... got possible fat header\n"); @@ -748,7 +731,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW, for (i = 0; i < narch; i++) { struct fat_arch fat_arch; - if (read(fmap->fd, &fat_arch, sizeof(fat_arch)) != sizeof(fat_arch)) + if (!ReadFile(fmap->handle, &fat_arch, sizeof(fat_arch), &bytes_read, NULL) || bytes_read != sizeof(fat_arch)) goto done; if (swap_ulong_be_to_host(fat_arch.cputype) == target_cpu) { @@ -766,8 +749,9 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW, } /* Individual architecture (standalone or within a fat file) is in its native byte order. */ - lseek(fmap->fd, fmap->arch_offset, SEEK_SET); - if (read(fmap->fd, &fmap->mach_header, sizeof(fmap->mach_header)) != sizeof(fmap->mach_header)) + SetFilePointer(fmap->handle, fmap->arch_offset, 0, FILE_BEGIN); + if (!ReadFile(fmap->handle, &fmap->mach_header, sizeof(fmap->mach_header), &bytes_read, NULL) + || bytes_read != sizeof(fmap->mach_header)) goto done; TRACE("... got possible Mach header\n"); /* and check for a Mach-O header */ @@ -838,14 +822,14 @@ static void macho_unmap_file(struct image_file_map* ifm) { struct image_file_map* cursor; - TRACE("(%p/%d)\n", ifm, ifm->u.macho.fd); + TRACE("(%p/%p)\n", ifm, ifm->u.macho.handle); cursor = ifm; while (cursor) { struct image_file_map* next; - if (ifm->u.macho.fd != -1) + if (ifm->u.macho.handle != INVALID_HANDLE_VALUE) { struct image_section_map ism; @@ -855,8 +839,8 @@ static void macho_unmap_file(struct image_file_map* ifm) HeapFree(GetProcessHeap(), 0, ifm->u.macho.sect); macho_unmap_load_commands(&ifm->u.macho); - close(ifm->u.macho.fd); - ifm->u.macho.fd = -1; + CloseHandle(ifm->u.macho.handle); + ifm->u.macho.handle = INVALID_HANDLE_VALUE; } next = cursor->u.macho.dsym; @@ -877,7 +861,7 @@ static BOOL macho_sect_is_code(struct macho_file_map* fmap, unsigned char sectid { BOOL ret; - TRACE("(%p/%d, %u)\n", fmap, fmap->fd, sectidx); + TRACE("(%p/%p, %u)\n", fmap, fmap->handle, sectidx); if (!sectidx) return FALSE; @@ -922,9 +906,9 @@ static void macho_stabs_def_cb(struct module* module, unsigned long load_offset, struct macho_debug_info* mdi = user; struct symtab_elt* ste; - TRACE("(%p, 0x%08lx, %s, 0x%08lx, %d, %d, %u, %p, %p/%p/%d)\n", module, load_offset, + TRACE("(%p, 0x%08lx, %s, 0x%08lx, %d, %d, %u, %p, %p/%p/%p)\n", module, load_offset, debugstr_a(name), offset, is_public, is_global, sectidx, - compiland, mdi, mdi->fmap, mdi->fmap->fd); + compiland, mdi, mdi->fmap, mdi->fmap->handle); /* Defer the creation of new non-debugging symbols until after we've * finished parsing the stabs. */ @@ -956,7 +940,7 @@ static int macho_parse_symtab(struct image_file_map* ifm, size_t stabsize = (ifm->addr_size == 32) ? sizeof(struct nlist) : sizeof(struct nlist_64); const char *stab; - TRACE("(%p/%d, %p, %p) %u syms at 0x%08x, strings 0x%08x - 0x%08x\n", fmap, fmap->fd, lc, + TRACE("(%p/%p, %p, %p) %u syms at 0x%08x, strings 0x%08x - 0x%08x\n", fmap, fmap->handle, lc, user, sc->nsyms, sc->symoff, sc->stroff, sc->stroff + sc->strsize); if (!macho_map_ranges(fmap, sc->symoff, sc->nsyms * stabsize, @@ -1321,7 +1305,7 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module) ifm = &module->format_info[DFI_MACHO]->u.macho_info->file_map; fmap = &ifm->u.macho; - TRACE("(%p, %p/%d)\n", module, fmap, fmap->fd); + TRACE("(%p, %p/%p)\n", module, fmap, fmap->handle); module->module.SymType = SymExport; @@ -1381,7 +1365,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 = macho_calc_crc32(fmap.u.macho.fd); + *checksum = calc_crc32(fmap.u.macho.handle); macho_unmap_file(&fmap); return TRUE; } @@ -1496,7 +1480,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, macho_calc_crc32(fmap.u.macho.fd)); + fmap.u.macho.segs_size, 0, calc_crc32(fmap.u.macho.handle)); if (!macho_info->module) { HeapFree(GetProcessHeap(), 0, modfmt); diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 0c61d2beac1..ae9cbda6d4c 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: 838de56e0ac5b91e2ffa27a696d33e0f09179b2e + wine: ebf57f01f4890b726a0af702ab7751258f5ab03d
4 years, 8 months
1
0
0
0
[reactos] 96/179: [WINESYNC] dbghelp: Lookup real image paths in image_locate_debug_link.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=429c6cd3aa5cafebe01e9…
commit 429c6cd3aa5cafebe01e98269394c583c2d384f9 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:10:37 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:46 2020 +0200 [WINESYNC] dbghelp: Lookup real image paths in image_locate_debug_link. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 838de56e0ac5b91e2ffa27a696d33e0f09179b2e by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/module.c | 13 +++++++++++-- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c index 3429f0a2f60..df2dc178c4e 100644 --- a/dll/win32/dbghelp/module.c +++ b/dll/win32/dbghelp/module.c @@ -637,6 +637,7 @@ static BOOL image_locate_debug_link(const struct module* module, struct image_fi filename_len = MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, NULL, 0); path_len = strlenW(module->module.LoadedImageName); + if (module->real_path) path_len = max(path_len, strlenW(module->real_path)); p = HeapAlloc(GetProcessHeap(), 0, (globalDebugDirLen + path_len + 6 + 1 + filename_len + 1) * sizeof(WCHAR)); if (!p) goto found; @@ -656,14 +657,22 @@ static BOOL image_locate_debug_link(const struct module* module, struct image_fi MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash + ARRAY_SIZE(dotDebugW), filename_len); if (image_check_debug_link(p, fmap_link, crc)) goto found; -#ifndef __REACTOS__ + if (module->real_path) + { + strcpyW(p, module->real_path); + slash = p; + if ((slash2 = strrchrW(slash, '/'))) slash = slash2 + 1; + if ((slash2 = strrchrW(slash, '\\'))) slash = slash2 + 1; + MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash, filename_len); + if (image_check_debug_link(p, fmap_link, crc)) goto found; + } + /* testing globaldebugdir/execdir/filename */ memmove(p + globalDebugDirLen, p, (slash - p) * sizeof(WCHAR)); memcpy(p, globalDebugDirW, globalDebugDirLen * sizeof(WCHAR)); slash += globalDebugDirLen; MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash, filename_len); if (image_check_debug_link(p, fmap_link, crc)) goto found; -#endif /* finally testing filename */ if (image_check_debug_link(slash, fmap_link, crc)) goto found; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 008fc706f1e..0c61d2beac1 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: 2642f43eabe6c61341daee24487372b57723894d + wine: 838de56e0ac5b91e2ffa27a696d33e0f09179b2e
4 years, 8 months
1
0
0
0
[reactos] 95/179: [WINESYNC] dbghelp: Support PE debug link files.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5768b7b75c7e0f49b33b2…
commit 5768b7b75c7e0f49b33b240f3b57c55806e7eb47 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:10:37 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:46 2020 +0200 [WINESYNC] dbghelp: Support PE debug link files. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 2642f43eabe6c61341daee24487372b57723894d by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/CMakeLists.txt | 1 - dll/win32/dbghelp/elf_module.c | 10 ---------- dll/win32/dbghelp/image_private.h | 1 + dll/win32/dbghelp/module.c | 12 +++++++++++- sdk/tools/winesync/dbghelp.cfg | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dll/win32/dbghelp/CMakeLists.txt b/dll/win32/dbghelp/CMakeLists.txt index 59e160b21ee..c4e3929e7b9 100644 --- a/dll/win32/dbghelp/CMakeLists.txt +++ b/dll/win32/dbghelp/CMakeLists.txt @@ -15,7 +15,6 @@ if(NOT CMAKE_CROSSCOMPILING) compat.c dbghelp.c dwarf.c - elf_module.c module.c pe_module.c source.c diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 7a6d9bed125..142f2f036af 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1,12 +1,3 @@ -#ifdef __REACTOS__ -#ifdef DBGHELP_STATIC_LIB -#undef __ELF__ -#include "compat.h" -#else -#endif -#include "dbghelp_private.h" -#include "image_private.h" -#else /* * File elf.c - processing of ELF files * @@ -50,7 +41,6 @@ #include "wine/library.h" #include "wine/debug.h" #include "wine/heap.h" -#endif /* __REACTOS__ */ #ifdef __ELF__ diff --git a/dll/win32/dbghelp/image_private.h b/dll/win32/dbghelp/image_private.h index 579d7af37cf..b6f864aa84d 100644 --- a/dll/win32/dbghelp/image_private.h +++ b/dll/win32/dbghelp/image_private.h @@ -142,6 +142,7 @@ struct image_section_map BOOL image_check_alternate(struct image_file_map* fmap, const struct module* module) DECLSPEC_HIDDEN; BOOL elf_map_handle(HANDLE handle, struct image_file_map* fmap) DECLSPEC_HIDDEN; +BOOL pe_map_file(HANDLE file, struct image_file_map* fmap, enum module_type mt) DECLSPEC_HIDDEN; struct image_file_map_ops { diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c index 16d6670a737..3429f0a2f60 100644 --- a/dll/win32/dbghelp/module.c +++ b/dll/win32/dbghelp/module.c @@ -561,10 +561,12 @@ static BOOL refresh_module_list(struct process* pcs) static BOOL image_check_debug_link(const WCHAR* file, struct image_file_map* fmap, DWORD link_crc) { + DWORD read_bytes; HANDLE handle; #ifndef DBGHELP_STATIC_LIB WCHAR *path; #endif + WORD magic; BOOL ret; #ifndef DBGHELP_STATIC_LIB @@ -587,7 +589,15 @@ static BOOL image_check_debug_link(const WCHAR* file, struct image_file_map* fma } } - ret = elf_map_handle(handle, fmap); + SetFilePointer(handle, 0, 0, FILE_BEGIN); + if (ReadFile(handle, &magic, sizeof(magic), &read_bytes, NULL) && magic == IMAGE_DOS_SIGNATURE) + ret = pe_map_file(handle, fmap, DMT_PE); + else +#ifndef __REACTOS__ + ret = elf_map_handle(handle, fmap); +#else + ret = FALSE; +#endif CloseHandle(handle); return ret; } diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 6e7eeb08789..008fc706f1e 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: 0dd495868846f30d9bb8f15f389d2b1ff6f383cb + wine: 2642f43eabe6c61341daee24487372b57723894d
4 years, 8 months
1
0
0
0
[reactos] 94/179: [WINESYNC] dbghelp: Support GNU debug link and build id in PE files.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=710c080147179af6b2791…
commit 710c080147179af6b2791f84b2be9aa55be40153 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:08:57 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:46 2020 +0200 [WINESYNC] dbghelp: Support GNU debug link and build id in PE files. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 0dd495868846f30d9bb8f15f389d2b1ff6f383cb by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/pe_module.c | 3 ++- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dll/win32/dbghelp/pe_module.c b/dll/win32/dbghelp/pe_module.c index b50a3cb8e35..0eb97e9e0c7 100644 --- a/dll/win32/dbghelp/pe_module.c +++ b/dll/win32/dbghelp/pe_module.c @@ -753,7 +753,8 @@ BOOL pe_load_debug_info(const struct process* pcs, struct module* module) if (!(dbghelp_options & SYMOPT_PUBLICS_ONLY)) { - ret = pe_load_stabs(pcs, module); + ret = image_check_alternate(&module->format_info[DFI_PE]->u.pe_info->fmap, module); + ret = pe_load_stabs(pcs, module) || ret; ret = pe_load_dwarf(module) || ret; #ifndef DBGHELP_STATIC_LIB ret = pe_load_msc_debug_info(pcs, module) || ret; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 50838ce5e31..6e7eeb08789 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: 4694801e4f58f0e856327d251ac98cfb573fd83b + wine: 0dd495868846f30d9bb8f15f389d2b1ff6f383cb
4 years, 8 months
1
0
0
0
[reactos] 93/179: [WINESYNC] dbghelp: Move elf_check_alternate implementation to module.c.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ebdb2b35d9ee6d285581a…
commit ebdb2b35d9ee6d285581a1a05a4dd94eb52fe78e Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:05:18 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:46 2020 +0200 [WINESYNC] dbghelp: Move elf_check_alternate implementation to module.c. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 4694801e4f58f0e856327d251ac98cfb573fd83b by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/CMakeLists.txt | 1 + dll/win32/dbghelp/compat.c | 110 ++++++++++++++++ dll/win32/dbghelp/compat.h | 8 ++ dll/win32/dbghelp/dbghelp.c | 3 - dll/win32/dbghelp/elf_module.c | 257 +++----------------------------------- dll/win32/dbghelp/image_private.h | 11 ++ dll/win32/dbghelp/module.c | 249 +++++++++++++++++++++++++++++++++++- dll/win32/dbghelp/path.c | 2 - sdk/tools/winesync/dbghelp.cfg | 2 +- 9 files changed, 395 insertions(+), 248 deletions(-) diff --git a/dll/win32/dbghelp/CMakeLists.txt b/dll/win32/dbghelp/CMakeLists.txt index c4e3929e7b9..59e160b21ee 100644 --- a/dll/win32/dbghelp/CMakeLists.txt +++ b/dll/win32/dbghelp/CMakeLists.txt @@ -15,6 +15,7 @@ if(NOT CMAKE_CROSSCOMPILING) compat.c dbghelp.c dwarf.c + elf_module.c module.c pe_module.c source.c diff --git a/dll/win32/dbghelp/compat.c b/dll/win32/dbghelp/compat.c index dfd9ec13d29..8ef4d551e65 100644 --- a/dll/win32/dbghelp/compat.c +++ b/dll/win32/dbghelp/compat.c @@ -166,6 +166,31 @@ HANDLE __CreateFileW( return res; } +BOOL __ReadFile(HANDLE file, PVOID buffer, DWORD len, PDWORD outlen, PVOID overlap) +{ + size_t read; + + assert(overlap == NULL); + + read = fread(buffer, 1, len, file); + + if (ferror(file) != 0) + return FALSE; + + *outlen = (DWORD)read; + return TRUE; +} + +DWORD __SetFilePointer(HANDLE file,LONG low, PLONG high, DWORD move) +{ + assert(move == FILE_BEGIN); + assert(high == NULL); + + if (fseek(file, low, SEEK_SET)) + return INVALID_SET_FILE_POINTER; + return low; +} + void* __MapViewOfFile(HANDLE file,DWORD d1,DWORD d2,DWORD d3,SIZE_T s) { FILE *f = (FILE*)file; @@ -400,3 +425,88 @@ BOOL __IsWow64Process(HANDLE Process, BOOL* is_wow64) *is_wow64 = FALSE; return TRUE; } + +/* from sdk/lib/rtl/crc2.c */ +/* This work is based off of rtl.c in Wine. + * Please give credit where credit is due: + * + * Copyright 2003 Thomas Mertes + * Crc32 code Copyright 1986 Gary S. Brown (Public domain) + */ + +/* CRC polynomial 0xedb88320 */ +static const ULONG CrcTable[256] = +{ + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, + 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, + 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, + 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, + 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, + 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, + 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, + 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, + 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, + 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, + 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, + 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, + 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, + 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, + 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, + 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, + 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, + 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d +}; + +/********************************************************************* + * RtlComputeCrc32 [NTDLL.@] + * + * Calculate the CRC32 checksum of a block of bytes + * + * PARAMS + * Initial [I] Initial CRC value + * Data [I] Data block + * Length [I] Length of the byte block + * + * RETURNS + * The cumulative CRC32 of Initial and Length bytes of the Data block. + * + * @implemented + */ +ULONG +__RtlComputeCrc32(ULONG Initial, PUCHAR Data, ULONG Length) +{ + ULONG CrcValue = ~Initial; + + while (Length > 0) + { + CrcValue = CrcTable[(CrcValue ^ *Data) & 0xff] ^ (CrcValue >> 8); + Data++; + Length--; + } + return ~CrcValue; +} diff --git a/dll/win32/dbghelp/compat.h b/dll/win32/dbghelp/compat.h index b249fe1ef79..1485a78e024 100644 --- a/dll/win32/dbghelp/compat.h +++ b/dll/win32/dbghelp/compat.h @@ -470,6 +470,7 @@ typedef struct _EXCEPTION_REGISTRATION_RECORD // winbase.h #define INVALID_HANDLE_VALUE (HANDLE)(-1) +#define INVALID_SET_FILE_POINTER ((DWORD)-1) #define HeapAlloc __HeapAlloc #define HeapReAlloc __HeapReAlloc #define HeapFree(x,y,z) free(z) @@ -479,6 +480,8 @@ typedef struct _EXCEPTION_REGISTRATION_RECORD #define CloseHandle __CloseHandle #define CreateFileA(a,b,c,d,e,f,g) fopen(a, "rb") #define CreateFileW __CreateFileW +#define ReadFile(a,b,c,d,e) __ReadFile +#define SetFilePointer __SetFilePointer #define CreateFileMappingW(a,b,c,d,e,f) a #define MapViewOfFile __MapViewOfFile #define UnmapViewOfFile __UnmapViewOfFile @@ -496,12 +499,15 @@ typedef struct _EXCEPTION_REGISTRATION_RECORD #define ReadProcessMemory(a,b,c,d,e) 0 #define GetCurrentProcess() (HANDLE)1 #define IsWow64Process __IsWow64Process +#define FILE_BEGIN 0 void* __HeapAlloc(int heap, int flags, size_t size); void* __HeapReAlloc(int heap, DWORD d2, void *slab, SIZE_T newsize); WCHAR* __lstrcpynW(WCHAR* lpString1, const WCHAR* lpString2, int iMaxLength); BOOL __CloseHandle(HANDLE handle); HANDLE __CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); +BOOL __ReadFile(HANDLE,PVOID,DWORD,PDWORD,/*LPOVERLAPPED*/ PVOID); +DWORD __SetFilePointer(HANDLE,LONG,PLONG,DWORD); void* __MapViewOfFile(HANDLE file,DWORD d1,DWORD d2,DWORD d3,SIZE_T s); BOOL __UnmapViewOfFile(const void*); LPSTR __lstrcpynA(LPSTR,LPCSTR,int); @@ -542,6 +548,7 @@ typedef LONG KPRIORITY; #define RtlImageRvaToVa __RtlImageRvaToVa #define RtlImageRvaToSection __RtlImageRvaToSection #define RtlImageDirectoryEntryToData __RtlImageDirectoryEntryToData +#define RtlComputeCrc32 __RtlComputeCrc32 #ifdef _MSC_VER #define RtlUlongByteSwap(_x) _byteswap_ulong((_x)) @@ -552,6 +559,7 @@ typedef LONG KPRIORITY; PIMAGE_NT_HEADERS __RtlImageNtHeader(void *data); PVOID __RtlImageRvaToVa (const IMAGE_NT_HEADERS* NtHeader, PVOID BaseAddress, ULONG Rva, PIMAGE_SECTION_HEADER *SectionHeader); PVOID __RtlImageDirectoryEntryToData(PVOID BaseAddress, BOOLEAN MappedAsImage, USHORT Directory, PULONG Size); +ULONG __RtlComputeCrc32(ULONG Initial, PUCHAR Data, ULONG Length); typedef struct _CLIENT_ID { diff --git a/dll/win32/dbghelp/dbghelp.c b/dll/win32/dbghelp/dbghelp.c index bb69d671961..b59ee6a269c 100644 --- a/dll/win32/dbghelp/dbghelp.c +++ b/dll/win32/dbghelp/dbghelp.c @@ -739,7 +739,6 @@ void WINAPI WinDbgExtensionDllInit(PWINDBG_EXTENSION_APIS lpExtensionApis, { } -#ifndef DBGHELP_STATIC_LIB DWORD calc_crc32(HANDLE handle) { BYTE buffer[8192]; @@ -751,5 +750,3 @@ DWORD calc_crc32(HANDLE handle) crc = RtlComputeCrc32(crc, buffer, len); return crc; } -#endif - diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 75f046105c7..7a6d9bed125 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1,3 +1,12 @@ +#ifdef __REACTOS__ +#ifdef DBGHELP_STATIC_LIB +#undef __ELF__ +#include "compat.h" +#else +#endif +#include "dbghelp_private.h" +#include "image_private.h" +#else /* * File elf.c - processing of ELF files * @@ -41,6 +50,7 @@ #include "wine/library.h" #include "wine/debug.h" #include "wine/heap.h" +#endif /* __REACTOS__ */ #ifdef __ELF__ @@ -542,7 +552,7 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map* return TRUE; } -static BOOL elf_map_handle(HANDLE handle, struct image_file_map* fmap) +BOOL elf_map_handle(HANDLE handle, struct image_file_map* fmap) { struct elf_map_file_data emfd; emfd.kind = from_handle; @@ -958,244 +968,6 @@ static int elf_new_public_symbols(struct module* module, const struct hash_table return TRUE; } -static BOOL elf_check_debug_link(const WCHAR* file, struct image_file_map* fmap, DWORD link_crc) -{ - HANDLE handle; - WCHAR *path; - BOOL ret; - - path = get_dos_file_name(file); - handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - heap_free(path); - if (handle == INVALID_HANDLE_VALUE) return FALSE; - - if (link_crc) - { - DWORD crc = calc_crc32(handle); - if (crc != link_crc) - { - WARN("Bad CRC for file %s (got %08x while expecting %08x)\n", debugstr_w(file), crc, link_crc); - CloseHandle(handle); - return FALSE; - } - } - - ret = elf_map_handle(handle, fmap); - CloseHandle(handle); - return ret; -} - -/****************************************************************** - * elf_locate_debug_link - * - * Locate a filename from a .gnu_debuglink section, using the same - * strategy as gdb: - * "If the full name of the directory containing the executable is - * execdir, and the executable has a debug link that specifies the - * name debugfile, then GDB will automatically search for the - * debugging information file in three places: - * - the directory containing the executable file (that is, it - * will look for a file named `execdir/debugfile', - * - a subdirectory of that directory named `.debug' (that is, the - * file `execdir/.debug/debugfile', and - * - a subdirectory of the global debug file directory that includes - * the executable's full path, and the name from the link (that is, - * the file `globaldebugdir/execdir/debugfile', where globaldebugdir - * is the global debug file directory, and execdir has been turned - * into a relative path)." (from GDB manual) - */ -static BOOL elf_locate_debug_link(const struct module* module, struct image_file_map* fmap, const char* filename, DWORD crc) -{ - static const WCHAR globalDebugDirW[] = {'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/'}; - static const WCHAR dotDebugW[] = {'.','d','e','b','u','g','/'}; - const size_t globalDebugDirLen = ARRAY_SIZE(globalDebugDirW); - size_t filename_len, path_len; - WCHAR* p = NULL; - WCHAR* slash; - WCHAR* slash2; - struct image_file_map* fmap_link = NULL; - - fmap_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link)); - if (!fmap_link) return FALSE; - - filename_len = MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, NULL, 0); - path_len = strlenW(module->module.LoadedImageName); - p = HeapAlloc(GetProcessHeap(), 0, - (globalDebugDirLen + path_len + 6 + 1 + filename_len + 1) * sizeof(WCHAR)); - if (!p) goto found; - - /* we prebuild the string with "execdir" */ - strcpyW(p, module->module.LoadedImageName); - slash = p; - if ((slash2 = strrchrW(slash, '/'))) slash = slash2 + 1; - if ((slash2 = strrchrW(slash, '\\'))) slash = slash2 + 1; - - /* testing execdir/filename */ - MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash, filename_len); - if (elf_check_debug_link(p, fmap_link, crc)) goto found; - - /* testing execdir/.debug/filename */ - memcpy(slash, dotDebugW, sizeof(dotDebugW)); - MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash + ARRAY_SIZE(dotDebugW), filename_len); - if (elf_check_debug_link(p, fmap_link, crc)) goto found; - - /* testing globaldebugdir/execdir/filename */ - memmove(p + globalDebugDirLen, p, (slash - p) * sizeof(WCHAR)); - memcpy(p, globalDebugDirW, globalDebugDirLen * sizeof(WCHAR)); - slash += globalDebugDirLen; - MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash, filename_len); - if (elf_check_debug_link(p, fmap_link, crc)) goto found; - - /* finally testing filename */ - if (elf_check_debug_link(slash, fmap_link, crc)) goto found; - - - WARN("Couldn't locate or map %s\n", filename); - HeapFree(GetProcessHeap(), 0, p); - HeapFree(GetProcessHeap(), 0, fmap_link); - return FALSE; - -found: - TRACE("Located debug information file %s at %s\n", filename, debugstr_w(p)); - HeapFree(GetProcessHeap(), 0, p); - fmap->alternate = fmap_link; - return TRUE; -} - -/****************************************************************** - * elf_locate_build_id_target - * - * Try to find the .so file containing the debug info out of the build-id note information - */ -static BOOL elf_locate_build_id_target(struct image_file_map* fmap, const BYTE* id, unsigned idlen) -{ - static const WCHAR globalDebugDirW[] = {'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/'}; - static const WCHAR buildidW[] = {'.','b','u','i','l','d','-','i','d','/'}; - static const WCHAR dotDebug0W[] = {'.','d','e','b','u','g',0}; - struct image_file_map* fmap_link = NULL; - WCHAR* p; - WCHAR* z; - const BYTE* idend = id + idlen; - - fmap_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link)); - if (!fmap_link) return FALSE; - - p = HeapAlloc(GetProcessHeap(), 0, - sizeof(globalDebugDirW) + sizeof(buildidW) + - (idlen * 2 + 1) * sizeof(WCHAR) + sizeof(dotDebug0W)); - z = p; - memcpy(z, globalDebugDirW, sizeof(globalDebugDirW)); - z += ARRAY_SIZE(globalDebugDirW); - memcpy(z, buildidW, sizeof(buildidW)); - z += ARRAY_SIZE(buildidW); - - if (id < idend) - { - *z++ = "0123456789abcdef"[*id >> 4 ]; - *z++ = "0123456789abcdef"[*id & 0x0F]; - id++; - } - if (id < idend) - *z++ = '/'; - while (id < idend) - { - *z++ = "0123456789abcdef"[*id >> 4 ]; - *z++ = "0123456789abcdef"[*id & 0x0F]; - id++; - } - memcpy(z, dotDebug0W, sizeof(dotDebug0W)); - TRACE("checking %s\n", wine_dbgstr_w(p)); - - if (elf_check_debug_link(p, fmap_link, 0)) - { - struct image_section_map buildid_sect; - if (image_find_section(fmap_link, ".note.gnu.build-id", &buildid_sect)) - { - const uint32_t* note; - - note = (const uint32_t*)image_map_section(&buildid_sect); - if (note != IMAGE_NO_MAP) - { - /* the usual ELF note structure: name-size desc-size type <name> <desc> */ - if (note[2] == NT_GNU_BUILD_ID) - { - if (note[1] == idlen && - !memcmp(note + 3 + ((note[0] + 3) >> 2), idend - idlen, idlen)) - { - TRACE("Located debug information file at %s\n", debugstr_w(p)); - HeapFree(GetProcessHeap(), 0, p); - fmap->alternate = fmap_link; - return TRUE; - } - WARN("mismatch in buildid information for %s\n", wine_dbgstr_w(p)); - } - } - image_unmap_section(&buildid_sect); - } - image_unmap_file(fmap_link); - } - - TRACE("not found\n"); - HeapFree(GetProcessHeap(), 0, p); - HeapFree(GetProcessHeap(), 0, fmap_link); - return FALSE; -} - -/****************************************************************** - * elf_check_alternate - * - * Load alternate files for a given ELF file, looking at either .note.gnu_build-id - * or .gnu_debuglink sections. - */ -static BOOL elf_check_alternate(struct image_file_map* fmap, const struct module* module) -{ - BOOL ret = FALSE; - BOOL found = FALSE; - struct image_section_map buildid_sect, debuglink_sect; - - /* if present, add the .gnu_debuglink file as an alternate to current one */ - if (image_find_section(fmap, ".note.gnu.build-id", &buildid_sect)) - { - const uint32_t* note; - - found = TRUE; - note = (const uint32_t*)image_map_section(&buildid_sect); - if (note != IMAGE_NO_MAP) - { - /* the usual ELF note structure: name-size desc-size type <name> <desc> */ - if (note[2] == NT_GNU_BUILD_ID) - { - ret = elf_locate_build_id_target(fmap, (const BYTE*)(note + 3 + ((note[0] + 3) >> 2)), note[1]); - } - } - image_unmap_section(&buildid_sect); - } - /* if present, add the .gnu_debuglink file as an alternate to current one */ - if (!ret && image_find_section(fmap, ".gnu_debuglink", &debuglink_sect)) - { - const char* dbg_link; - - found = TRUE; - dbg_link = (const char*)image_map_section(&debuglink_sect); - if (dbg_link != IMAGE_NO_MAP) - { - /* The content of a debug link section is: - * 1/ a NULL terminated string, containing the file name for the - * debug info - * 2/ padding on 4 byte boundary - * 3/ CRC of the linked ELF file - */ - DWORD crc = *(const DWORD*)(dbg_link + ((DWORD_PTR)(strlen(dbg_link) + 4) & ~3)); - ret = elf_locate_debug_link(module, fmap, dbg_link, crc); - if (!ret) - WARN("Couldn't load linked debug file for %s\n", - debugstr_w(module->module.ModuleName)); - } - image_unmap_section(&debuglink_sect); - } - return found ? ret : TRUE; -} - /****************************************************************** * elf_load_debug_info_from_map * @@ -1236,7 +1008,7 @@ static BOOL elf_load_debug_info_from_map(struct module* module, struct image_section_map stab_sect, stabstr_sect; /* check if we need an alternate file (from debuglink or build-id) */ - ret = elf_check_alternate(fmap, module); + ret = image_check_alternate(fmap, module); if (image_find_section(fmap, ".stab", &stab_sect) && image_find_section(fmap, ".stabstr", &stabstr_sect)) @@ -2030,6 +1802,11 @@ BOOL elf_synchronize_module_list(struct process* pcs) #else /* !__ELF__ */ +BOOL elf_map_handle(HANDLE handle, struct image_file_map* fmap) +{ + return FALSE; +} + BOOL elf_synchronize_module_list(struct process* pcs) { return FALSE; diff --git a/dll/win32/dbghelp/image_private.h b/dll/win32/dbghelp/image_private.h index 8a8cd9a4454..579d7af37cf 100644 --- a/dll/win32/dbghelp/image_private.h +++ b/dll/win32/dbghelp/image_private.h @@ -54,6 +54,13 @@ #ifndef SHT_NULL #define SHT_NULL 0 #endif +#ifndef NT_GNU_BUILD_ID +#define NT_GNU_BUILD_ID 3 +#endif +#elif defined(__REACTOS__) +#ifndef NT_GNU_BUILD_ID +#define NT_GNU_BUILD_ID 3 +#endif #endif /* structure holding information while handling an ELF image @@ -132,6 +139,10 @@ struct image_section_map long sidx; }; +BOOL image_check_alternate(struct image_file_map* fmap, const struct module* module) DECLSPEC_HIDDEN; + +BOOL elf_map_handle(HANDLE handle, struct image_file_map* fmap) DECLSPEC_HIDDEN; + struct image_file_map_ops { const char* (*map_section)(struct image_section_map* ism); diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c index 5243b53a829..16d6670a737 100644 --- a/dll/win32/dbghelp/module.c +++ b/dll/win32/dbghelp/module.c @@ -26,14 +26,13 @@ #include <assert.h> #include "dbghelp_private.h" +#include "image_private.h" #ifndef DBGHELP_STATIC_LIB #include "psapi.h" #include "winternl.h" #include "wine/debug.h" -#ifndef __REACTOS__ #include "wine/heap.h" #endif -#endif WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); @@ -560,6 +559,252 @@ static BOOL refresh_module_list(struct process* pcs) } #endif +static BOOL image_check_debug_link(const WCHAR* file, struct image_file_map* fmap, DWORD link_crc) +{ + HANDLE handle; +#ifndef DBGHELP_STATIC_LIB + WCHAR *path; +#endif + BOOL ret; + +#ifndef DBGHELP_STATIC_LIB + path = get_dos_file_name(file); + handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + heap_free(path); +#else + handle = CreateFileW(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); +#endif + if (handle == INVALID_HANDLE_VALUE) return FALSE; + + if (link_crc) + { + DWORD crc = calc_crc32(handle); + if (crc != link_crc) + { + WARN("Bad CRC for file %s (got %08x while expecting %08x)\n", debugstr_w(file), crc, link_crc); + CloseHandle(handle); + return FALSE; + } + } + + ret = elf_map_handle(handle, fmap); + CloseHandle(handle); + return ret; +} + +/****************************************************************** + * image_locate_debug_link + * + * Locate a filename from a .gnu_debuglink section, using the same + * strategy as gdb: + * "If the full name of the directory containing the executable is + * execdir, and the executable has a debug link that specifies the + * name debugfile, then GDB will automatically search for the + * debugging information file in three places: + * - the directory containing the executable file (that is, it + * will look for a file named `execdir/debugfile', + * - a subdirectory of that directory named `.debug' (that is, the + * file `execdir/.debug/debugfile', and + * - a subdirectory of the global debug file directory that includes + * the executable's full path, and the name from the link (that is, + * the file `globaldebugdir/execdir/debugfile', where globaldebugdir + * is the global debug file directory, and execdir has been turned + * into a relative path)." (from GDB manual) + */ +static BOOL image_locate_debug_link(const struct module* module, struct image_file_map* fmap, const char* filename, DWORD crc) +{ + static const WCHAR globalDebugDirW[] = {'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/'}; + static const WCHAR dotDebugW[] = {'.','d','e','b','u','g','/'}; + const size_t globalDebugDirLen = ARRAY_SIZE(globalDebugDirW); + size_t filename_len, path_len; + WCHAR* p = NULL; + WCHAR* slash; + WCHAR* slash2; + struct image_file_map* fmap_link = NULL; + + fmap_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link)); + if (!fmap_link) return FALSE; + + filename_len = MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, NULL, 0); + path_len = strlenW(module->module.LoadedImageName); + p = HeapAlloc(GetProcessHeap(), 0, + (globalDebugDirLen + path_len + 6 + 1 + filename_len + 1) * sizeof(WCHAR)); + if (!p) goto found; + + /* we prebuild the string with "execdir" */ + strcpyW(p, module->module.LoadedImageName); + slash = p; + if ((slash2 = strrchrW(slash, '/'))) slash = slash2 + 1; + if ((slash2 = strrchrW(slash, '\\'))) slash = slash2 + 1; + + /* testing execdir/filename */ + MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash, filename_len); + if (image_check_debug_link(p, fmap_link, crc)) goto found; + + /* testing execdir/.debug/filename */ + memcpy(slash, dotDebugW, sizeof(dotDebugW)); + MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash + ARRAY_SIZE(dotDebugW), filename_len); + if (image_check_debug_link(p, fmap_link, crc)) goto found; + +#ifndef __REACTOS__ + /* testing globaldebugdir/execdir/filename */ + memmove(p + globalDebugDirLen, p, (slash - p) * sizeof(WCHAR)); + memcpy(p, globalDebugDirW, globalDebugDirLen * sizeof(WCHAR)); + slash += globalDebugDirLen; + MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash, filename_len); + if (image_check_debug_link(p, fmap_link, crc)) goto found; +#endif + + /* finally testing filename */ + if (image_check_debug_link(slash, fmap_link, crc)) goto found; + + + WARN("Couldn't locate or map %s\n", filename); + HeapFree(GetProcessHeap(), 0, p); + HeapFree(GetProcessHeap(), 0, fmap_link); + return FALSE; + +found: + TRACE("Located debug information file %s at %s\n", filename, debugstr_w(p)); + HeapFree(GetProcessHeap(), 0, p); + fmap->alternate = fmap_link; + return TRUE; +} + +/****************************************************************** + * image_locate_build_id_target + * + * Try to find the .so file containing the debug info out of the build-id note information + */ +static BOOL image_locate_build_id_target(struct image_file_map* fmap, const BYTE* id, unsigned idlen) +{ + static const WCHAR globalDebugDirW[] = {'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/'}; + static const WCHAR buildidW[] = {'.','b','u','i','l','d','-','i','d','/'}; + static const WCHAR dotDebug0W[] = {'.','d','e','b','u','g',0}; + struct image_file_map* fmap_link = NULL; + WCHAR* p; + WCHAR* z; + const BYTE* idend = id + idlen; + + fmap_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link)); + if (!fmap_link) return FALSE; + + p = HeapAlloc(GetProcessHeap(), 0, + sizeof(globalDebugDirW) + sizeof(buildidW) + + (idlen * 2 + 1) * sizeof(WCHAR) + sizeof(dotDebug0W)); + z = p; + memcpy(z, globalDebugDirW, sizeof(globalDebugDirW)); + z += ARRAY_SIZE(globalDebugDirW); + memcpy(z, buildidW, sizeof(buildidW)); + z += ARRAY_SIZE(buildidW); + + if (id < idend) + { + *z++ = "0123456789abcdef"[*id >> 4 ]; + *z++ = "0123456789abcdef"[*id & 0x0F]; + id++; + } + if (id < idend) + *z++ = '/'; + while (id < idend) + { + *z++ = "0123456789abcdef"[*id >> 4 ]; + *z++ = "0123456789abcdef"[*id & 0x0F]; + id++; + } + memcpy(z, dotDebug0W, sizeof(dotDebug0W)); + TRACE("checking %s\n", wine_dbgstr_w(p)); + + if (image_check_debug_link(p, fmap_link, 0)) + { + struct image_section_map buildid_sect; + if (image_find_section(fmap_link, ".note.gnu.build-id", &buildid_sect)) + { + const UINT32* note; + + note = (const UINT32*)image_map_section(&buildid_sect); + if (note != IMAGE_NO_MAP) + { + /* the usual ELF note structure: name-size desc-size type <name> <desc> */ + if (note[2] == NT_GNU_BUILD_ID) + { + if (note[1] == idlen && + !memcmp(note + 3 + ((note[0] + 3) >> 2), idend - idlen, idlen)) + { + TRACE("Located debug information file at %s\n", debugstr_w(p)); + HeapFree(GetProcessHeap(), 0, p); + fmap->alternate = fmap_link; + return TRUE; + } + WARN("mismatch in buildid information for %s\n", wine_dbgstr_w(p)); + } + } + image_unmap_section(&buildid_sect); + } + image_unmap_file(fmap_link); + } + + TRACE("not found\n"); + HeapFree(GetProcessHeap(), 0, p); + HeapFree(GetProcessHeap(), 0, fmap_link); + return FALSE; +} + +/****************************************************************** + * image_check_alternate + * + * Load alternate files for a given image file, looking at either .note.gnu_build-id + * or .gnu_debuglink sections. + */ +BOOL image_check_alternate(struct image_file_map* fmap, const struct module* module) +{ + BOOL ret = FALSE; + BOOL found = FALSE; + struct image_section_map buildid_sect, debuglink_sect; + + /* if present, add the .gnu_debuglink file as an alternate to current one */ + if (image_find_section(fmap, ".note.gnu.build-id", &buildid_sect)) + { + const UINT32* note; + + found = TRUE; + note = (const UINT32*)image_map_section(&buildid_sect); + if (note != IMAGE_NO_MAP) + { + /* the usual ELF note structure: name-size desc-size type <name> <desc> */ + if (note[2] == NT_GNU_BUILD_ID) + { + ret = image_locate_build_id_target(fmap, (const BYTE*)(note + 3 + ((note[0] + 3) >> 2)), note[1]); + } + } + image_unmap_section(&buildid_sect); + } + /* if present, add the .gnu_debuglink file as an alternate to current one */ + if (!ret && image_find_section(fmap, ".gnu_debuglink", &debuglink_sect)) + { + const char* dbg_link; + + found = TRUE; + dbg_link = (const char*)image_map_section(&debuglink_sect); + if (dbg_link != IMAGE_NO_MAP) + { + /* The content of a debug link section is: + * 1/ a NULL terminated string, containing the file name for the + * debug info + * 2/ padding on 4 byte boundary + * 3/ CRC of the linked file + */ + DWORD crc = *(const DWORD*)(dbg_link + ((DWORD_PTR)(strlen(dbg_link) + 4) & ~3)); + ret = image_locate_debug_link(module, fmap, dbg_link, crc); + if (!ret) + WARN("Couldn't load linked debug file for %s\n", + debugstr_w(module->module.ModuleName)); + } + image_unmap_section(&debuglink_sect); + } + return found ? ret : TRUE; +} + /*********************************************************************** * SymLoadModule (DBGHELP.@) */ diff --git a/dll/win32/dbghelp/path.c b/dll/win32/dbghelp/path.c index 21ff3ac5dfc..feb951ad55d 100644 --- a/dll/win32/dbghelp/path.c +++ b/dll/win32/dbghelp/path.c @@ -698,7 +698,6 @@ BOOL path_find_symbol_file(const struct process* pcs, const struct module* modul return FALSE; } -#ifndef __REACTOS__ WCHAR *get_dos_file_name(const WCHAR *filename) { WCHAR *dos_path; @@ -721,4 +720,3 @@ WCHAR *get_dos_file_name(const WCHAR *filename) } return dos_path; } -#endif diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index edd9c2dc5d4..50838ce5e31 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: d38682397997c56359f6d161467a56ffe5bfa9fa + wine: 4694801e4f58f0e856327d251ac98cfb573fd83b
4 years, 8 months
1
0
0
0
[reactos] 92/179: [WINESYNC] dbghelp: Move get_dos_file_name to path.c.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1a2b28fc644600c07fad6…
commit 1a2b28fc644600c07fad6375e3c933aaf8b0611b Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:05:18 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:45 2020 +0200 [WINESYNC] dbghelp: Move get_dos_file_name to path.c. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id d38682397997c56359f6d161467a56ffe5bfa9fa by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp_private.h | 1 + dll/win32/dbghelp/elf_module.c | 23 ----------------------- dll/win32/dbghelp/path.c | 26 ++++++++++++++++++++++++++ sdk/tools/winesync/dbghelp.cfg | 2 +- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index 3288167ae0a..aecde06ac62 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -699,6 +699,7 @@ extern BOOL pdb_virtual_unwind(struct cpu_stack_walk *csw, DWORD_PTR ip, extern BOOL path_find_symbol_file(const struct process* pcs, const struct module* module, PCSTR full_path, const GUID* guid, DWORD dw1, DWORD dw2, WCHAR *buffer, BOOL* is_unmatched) DECLSPEC_HIDDEN; +extern WCHAR *get_dos_file_name(const WCHAR *filename) DECLSPEC_HIDDEN; /* pe_module.c */ extern BOOL pe_load_nt_header(HANDLE hProc, DWORD64 base, IMAGE_NT_HEADERS* nth) DECLSPEC_HIDDEN; diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index c89292a644e..75f046105c7 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -396,29 +396,6 @@ static BOOL elf_map_shdr(struct elf_map_file_data* emfd, struct image_file_map* return TRUE; } -static WCHAR *get_dos_file_name(const WCHAR *filename) -{ - WCHAR *dos_path; - size_t len; - - if (*filename == '/') - { - char *unix_path; - len = WideCharToMultiByte(CP_UNIXCP, 0, filename, -1, NULL, 0, NULL, NULL); - unix_path = heap_alloc(len * sizeof(WCHAR)); - WideCharToMultiByte(CP_UNIXCP, 0, filename, -1, unix_path, len, NULL, NULL); - dos_path = wine_get_dos_file_name(unix_path); - heap_free(unix_path); - } - else - { - len = lstrlenW(filename); - dos_path = heap_alloc((len + 1) * sizeof(WCHAR)); - memcpy(dos_path, filename, (len + 1) * sizeof(WCHAR)); - } - return dos_path; -} - /****************************************************************** * elf_map_file * diff --git a/dll/win32/dbghelp/path.c b/dll/win32/dbghelp/path.c index 014c79c4790..21ff3ac5dfc 100644 --- a/dll/win32/dbghelp/path.c +++ b/dll/win32/dbghelp/path.c @@ -27,6 +27,7 @@ #include "winnls.h" #include "winternl.h" #include "wine/debug.h" +#include "wine/heap.h" WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); @@ -696,3 +697,28 @@ BOOL path_find_symbol_file(const struct process* pcs, const struct module* modul } return FALSE; } + +#ifndef __REACTOS__ +WCHAR *get_dos_file_name(const WCHAR *filename) +{ + WCHAR *dos_path; + size_t len; + + if (*filename == '/') + { + char *unix_path; + len = WideCharToMultiByte(CP_UNIXCP, 0, filename, -1, NULL, 0, NULL, NULL); + unix_path = heap_alloc(len * sizeof(WCHAR)); + WideCharToMultiByte(CP_UNIXCP, 0, filename, -1, unix_path, len, NULL, NULL); + dos_path = wine_get_dos_file_name(unix_path); + heap_free(unix_path); + } + else + { + len = lstrlenW(filename); + dos_path = heap_alloc((len + 1) * sizeof(WCHAR)); + memcpy(dos_path, filename, (len + 1) * sizeof(WCHAR)); + } + return dos_path; +} +#endif diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index db527a2f157..edd9c2dc5d4 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: 171c6fadab8eb444968c1b3a4b364e2e978a639a + wine: d38682397997c56359f6d161467a56ffe5bfa9fa
4 years, 8 months
1
0
0
0
[reactos] 91/179: [WINESYNC] dbghelp: Use elf_check_debug_link in elf_locate_build_id_target.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=56b57ef7c518da75d8d8e…
commit 56b57ef7c518da75d8d8e53af6b9378266ea86af Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:05:17 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:45 2020 +0200 [WINESYNC] dbghelp: Use elf_check_debug_link in elf_locate_build_id_target. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 171c6fadab8eb444968c1b3a4b364e2e978a639a by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 24 +++++++++++++----------- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 1ad37a24ed1..c89292a644e 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -985,20 +985,25 @@ static BOOL elf_check_debug_link(const WCHAR* file, struct image_file_map* fmap, { HANDLE handle; WCHAR *path; - DWORD crc; - BOOL ret = FALSE; + BOOL ret; path = get_dos_file_name(file); handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); heap_free(path); if (handle == INVALID_HANDLE_VALUE) return FALSE; - crc = calc_crc32(handle); - if (crc != link_crc) - WARN("Bad CRC for file %s (got %08x while expecting %08x)\n", debugstr_w(file), crc, link_crc); - else - ret = elf_map_handle(handle, fmap); + if (link_crc) + { + DWORD crc = calc_crc32(handle); + if (crc != link_crc) + { + WARN("Bad CRC for file %s (got %08x while expecting %08x)\n", debugstr_w(file), crc, link_crc); + CloseHandle(handle); + return FALSE; + } + } + ret = elf_map_handle(handle, fmap); CloseHandle(handle); return ret; } @@ -1094,7 +1099,6 @@ static BOOL elf_locate_build_id_target(struct image_file_map* fmap, const BYTE* WCHAR* p; WCHAR* z; const BYTE* idend = id + idlen; - struct elf_map_file_data emfd; fmap_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link)); if (!fmap_link) return FALSE; @@ -1125,9 +1129,7 @@ static BOOL elf_locate_build_id_target(struct image_file_map* fmap, const BYTE* memcpy(z, dotDebug0W, sizeof(dotDebug0W)); TRACE("checking %s\n", wine_dbgstr_w(p)); - emfd.kind = from_file; - emfd.u.file.filename = p; - if (elf_map_file(&emfd, fmap_link)) + if (elf_check_debug_link(p, fmap_link, 0)) { struct image_section_map buildid_sect; if (image_find_section(fmap_link, ".note.gnu.build-id", &buildid_sect)) diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 15bcb22091d..db527a2f157 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: c1d867fa872fafe1e6cc54ba6da63868fb7a4a6f + wine: 171c6fadab8eb444968c1b3a4b364e2e978a639a
4 years, 8 months
1
0
0
0
[reactos] 90/179: [WINESYNC] dbghelp: Check checksum before mapping elf file.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3d39743d1b7e116916995…
commit 3d39743d1b7e116916995db8a1d857f4eb068b70 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:05:17 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:45 2020 +0200 [WINESYNC] dbghelp: Check checksum before mapping elf file. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id c1d867fa872fafe1e6cc54ba6da63868fb7a4a6f by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 40 +++++++++++++++++++++++++++++----------- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 6bfd58b917a..1ad37a24ed1 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -326,7 +326,7 @@ static inline void elf_reset_file_map(struct image_file_map* fmap) struct elf_map_file_data { - enum {from_file, from_process} kind; + enum {from_file, from_process, from_handle} kind; union { struct @@ -338,6 +338,7 @@ struct elf_map_file_data HANDLE handle; void* load_addr; } process; + HANDLE handle; } u; }; @@ -351,6 +352,7 @@ static BOOL elf_map_file_read(struct image_file_map* fmap, struct elf_map_file_d switch (emfd->kind) { case from_file: + case from_handle: li.QuadPart = off; if (!SetFilePointerEx(fmap->u.elf.handle, li, NULL, FILE_BEGIN)) return FALSE; 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); if (fmap->u.elf.handle == INVALID_HANDLE_VALUE) return FALSE; 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: break; } @@ -539,6 +545,7 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map* switch (emfd->kind) { + case from_handle: case from_file: break; case from_process: 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; } +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) { 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) { - struct elf_map_file_data emfd; + HANDLE handle; + WCHAR *path; DWORD crc; + BOOL ret = FALSE; - emfd.kind = from_file; - emfd.u.file.filename = file; - if (!elf_map_file(&emfd, fmap)) return FALSE; + path = get_dos_file_name(file); + handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + 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) - { WARN("Bad CRC for file %s (got %08x while expecting %08x)\n", debugstr_w(file), crc, link_crc); - image_unmap_file(fmap); - return FALSE; - } - return TRUE; + else + ret = elf_map_handle(handle, fmap); + + CloseHandle(handle); + return ret; } /****************************************************************** diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index c5ab997e646..15bcb22091d 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: 5ba1c5960e716bdec9052efeb9f3ddfba3cf9e0c + wine: c1d867fa872fafe1e6cc54ba6da63868fb7a4a6f
4 years, 8 months
1
0
0
0
[reactos] 89/179: [WINESYNC] dbghelp: Pass module struct to elf_locate_debug_link.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9743bd26bd744a26ea68a…
commit 9743bd26bd744a26ea68a5ed3f2a453d82bce5b0 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: Pass module struct to elf_locate_debug_link. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 5ba1c5960e716bdec9052efeb9f3ddfba3cf9e0c by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 9 ++++----- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 0d190e549cd..6bfd58b917a 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1004,8 +1004,7 @@ static BOOL elf_check_debug_link(const WCHAR* file, struct image_file_map* fmap, * is the global debug file directory, and execdir has been turned * into a relative path)." (from GDB manual) */ -static BOOL elf_locate_debug_link(struct image_file_map* fmap, const char* filename, - const WCHAR* loaded_file, DWORD crc) +static BOOL elf_locate_debug_link(const struct module* module, struct image_file_map* fmap, const char* filename, DWORD crc) { static const WCHAR globalDebugDirW[] = {'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/'}; static const WCHAR dotDebugW[] = {'.','d','e','b','u','g','/'}; @@ -1020,13 +1019,13 @@ static BOOL elf_locate_debug_link(struct image_file_map* fmap, const char* filen if (!fmap_link) return FALSE; filename_len = MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, NULL, 0); - path_len = strlenW(loaded_file); + path_len = strlenW(module->module.LoadedImageName); p = HeapAlloc(GetProcessHeap(), 0, (globalDebugDirLen + path_len + 6 + 1 + filename_len + 1) * sizeof(WCHAR)); if (!p) goto found; /* we prebuild the string with "execdir" */ - strcpyW(p, loaded_file); + strcpyW(p, module->module.LoadedImageName); slash = p; if ((slash2 = strrchrW(slash, '/'))) slash = slash2 + 1; if ((slash2 = strrchrW(slash, '\\'))) slash = slash2 + 1; @@ -1190,7 +1189,7 @@ static BOOL elf_check_alternate(struct image_file_map* fmap, const struct module * 3/ CRC of the linked ELF file */ DWORD crc = *(const DWORD*)(dbg_link + ((DWORD_PTR)(strlen(dbg_link) + 4) & ~3)); - ret = elf_locate_debug_link(fmap, dbg_link, module->module.LoadedImageName, crc); + ret = elf_locate_debug_link(module, fmap, dbg_link, crc); if (!ret) WARN("Couldn't load linked debug file for %s\n", debugstr_w(module->module.ModuleName)); diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 63f6c9fd2db..c5ab997e646 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: e1b28a9c988ef0ff49d7254fd7ba05316f1c9b98 + wine: 5ba1c5960e716bdec9052efeb9f3ddfba3cf9e0c
4 years, 8 months
1
0
0
0
[reactos] 88/179: [WINESYNC] dbghelp: Support Windows paths in elf_locate_debug_link.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f71124fa11fd3476892f4…
commit f71124fa11fd3476892f447e5172c92a76321ba4 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: Support Windows paths in elf_locate_debug_link. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id e1b28a9c988ef0ff49d7254fd7ba05316f1c9b98 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 11 +++++++---- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index e0ae195cd89..0d190e549cd 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1010,23 +1010,26 @@ static BOOL elf_locate_debug_link(struct image_file_map* fmap, const char* filen static const WCHAR globalDebugDirW[] = {'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/'}; static const WCHAR dotDebugW[] = {'.','d','e','b','u','g','/'}; const size_t globalDebugDirLen = ARRAY_SIZE(globalDebugDirW); - size_t filename_len; + size_t filename_len, path_len; WCHAR* p = NULL; WCHAR* slash; + WCHAR* slash2; struct image_file_map* fmap_link = NULL; fmap_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link)); if (!fmap_link) return FALSE; filename_len = MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, NULL, 0); + path_len = strlenW(loaded_file); p = HeapAlloc(GetProcessHeap(), 0, - (globalDebugDirLen + strlenW(loaded_file) + 6 + 1 + filename_len + 1) * sizeof(WCHAR)); + (globalDebugDirLen + path_len + 6 + 1 + filename_len + 1) * sizeof(WCHAR)); if (!p) goto found; /* we prebuild the string with "execdir" */ strcpyW(p, loaded_file); - slash = strrchrW(p, '/'); - if (slash == NULL) slash = p; else slash++; + slash = p; + if ((slash2 = strrchrW(slash, '/'))) slash = slash2 + 1; + if ((slash2 = strrchrW(slash, '\\'))) slash = slash2 + 1; /* testing execdir/filename */ MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash, filename_len); diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 3a1ee0fa5aa..63f6c9fd2db 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: a5a6b0dcb65d8e3576e34d350c80f4789dcfdb7a + wine: e1b28a9c988ef0ff49d7254fd7ba05316f1c9b98
4 years, 8 months
1
0
0
0
[reactos] 87/179: [WINESYNC] dbghelp: Move HANDLE-based crc32 helper to dbghelp.c.
by winesync
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
4 years, 8 months
1
0
0
0
[reactos] 86/179: [WINESYNC] dbghelp: Introduce generic image_unmap_file.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6a1595b09d010232727dd…
commit 6a1595b09d010232727dd88879403ab97f923973 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: Introduce generic image_unmap_file. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 1d96af362789aa8aaa0be94a046b0afba2ecefb3 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 57 +++++++++++++++++++-------------------- dll/win32/dbghelp/image_private.h | 10 +++++++ dll/win32/dbghelp/macho_module.c | 1 + dll/win32/dbghelp/pe_module.c | 53 ++++++++++++++++++------------------ sdk/tools/winesync/dbghelp.cfg | 2 +- 5 files changed, 66 insertions(+), 57 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 300926f88b9..961fece7462 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -284,6 +284,27 @@ static unsigned elf_get_map_size(const struct image_section_map* ism) return ism->fmap->u.elf.sect[ism->sidx].shdr.sh_size; } +/****************************************************************** + * elf_unmap_file + * + * Unmaps an ELF file from memory (previously mapped with elf_map_file) + */ +static void elf_unmap_file(struct image_file_map* fmap) +{ + if (fmap->u.elf.handle != INVALID_HANDLE_VALUE) + { + struct image_section_map ism; + ism.fmap = fmap; + for (ism.sidx = 0; ism.sidx < fmap->u.elf.elfhdr.e_shnum; ism.sidx++) + { + elf_unmap_section(&ism); + } + HeapFree(GetProcessHeap(), 0, fmap->u.elf.sect); + CloseHandle(fmap->u.elf.handle); + } + HeapFree(GetProcessHeap(), 0, fmap->u.elf.target_copy); +} + static const struct image_file_map_ops elf_file_map_ops = { elf_map_section, @@ -291,6 +312,7 @@ static const struct image_file_map_ops elf_file_map_ops = elf_find_section, elf_get_map_rva, elf_get_map_size, + elf_unmap_file, }; static inline void elf_reset_file_map(struct image_file_map* fmap) @@ -536,34 +558,9 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map* return TRUE; } -/****************************************************************** - * elf_unmap_file - * - * Unmaps an ELF file from memory (previously mapped with elf_map_file) - */ -static void elf_unmap_file(struct image_file_map* fmap) -{ - while (fmap && fmap->modtype == DMT_ELF) - { - if (fmap->u.elf.handle != INVALID_HANDLE_VALUE) - { - struct image_section_map ism; - ism.fmap = fmap; - for (ism.sidx = 0; ism.sidx < fmap->u.elf.elfhdr.e_shnum; ism.sidx++) - { - elf_unmap_section(&ism); - } - HeapFree(GetProcessHeap(), 0, fmap->u.elf.sect); - CloseHandle(fmap->u.elf.handle); - } - HeapFree(GetProcessHeap(), 0, fmap->u.elf.target_copy); - fmap = fmap->alternate; - } -} - static void elf_module_remove(struct process* pcs, struct module_format* modfmt) { - elf_unmap_file(&modfmt->u.elf_info->file_map); + image_unmap_file(&modfmt->u.elf_info->file_map); HeapFree(GetProcessHeap(), 0, modfmt); } @@ -994,7 +991,7 @@ static BOOL elf_check_debug_link(const WCHAR* file, struct image_file_map* fmap, if (crc != link_crc) { WARN("Bad CRC for file %s (got %08x while expecting %08x)\n", debugstr_w(file), crc, link_crc); - elf_unmap_file(fmap); + image_unmap_file(fmap); return FALSE; } return TRUE; @@ -1148,7 +1145,7 @@ static BOOL elf_locate_build_id_target(struct image_file_map* fmap, const BYTE* } image_unmap_section(&buildid_sect); } - elf_unmap_file(fmap_link); + image_unmap_file(fmap_link); } TRACE("not found\n"); @@ -1340,7 +1337,7 @@ BOOL elf_fetch_file_info(const WCHAR* name, DWORD_PTR* base, if (base) *base = fmap.u.elf.elf_start; *size = fmap.u.elf.elf_size; *checksum = calc_crc(fmap.u.elf.handle); - elf_unmap_file(&fmap); + image_unmap_file(&fmap); return TRUE; } @@ -1514,7 +1511,7 @@ static BOOL elf_load_file(struct process* pcs, const WCHAR* filename, ret = elf_load_file_from_fmap(pcs, filename, &fmap, load_offset, dyn_addr, elf_info); - elf_unmap_file(&fmap); + image_unmap_file(&fmap); return ret; } diff --git a/dll/win32/dbghelp/image_private.h b/dll/win32/dbghelp/image_private.h index 8543cdc2e84..8a8cd9a4454 100644 --- a/dll/win32/dbghelp/image_private.h +++ b/dll/win32/dbghelp/image_private.h @@ -139,6 +139,7 @@ struct image_file_map_ops BOOL (*find_section)(struct image_file_map* fmap, const char* name, struct image_section_map* ism); DWORD_PTR (*get_map_rva)(const struct image_section_map* ism); unsigned (*get_map_size)(const struct image_section_map* ism); + void (*unmap_file)(struct image_file_map *fmap); }; static inline BOOL image_find_section(struct image_file_map* fmap, const char* name, @@ -154,6 +155,15 @@ static inline BOOL image_find_section(struct image_file_map* fmap, const char* n return FALSE; } +static inline void image_unmap_file(struct image_file_map* fmap) +{ + while (fmap) + { + fmap->ops->unmap_file(fmap); + fmap = fmap->alternate; + } +} + static inline const char* image_map_section(struct image_section_map* ism) { return ism->fmap ? ism->fmap->ops->map_section(ism) : NULL; diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index a9a086ea767..9d4fc4e47a2 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -432,6 +432,7 @@ static const struct image_file_map_ops macho_file_map_ops = macho_find_section, macho_get_map_rva, macho_get_map_size, + macho_unmap_file, }; /****************************************************************** diff --git a/dll/win32/dbghelp/pe_module.c b/dll/win32/dbghelp/pe_module.c index d92e4333a5d..b50a3cb8e35 100644 --- a/dll/win32/dbghelp/pe_module.c +++ b/dll/win32/dbghelp/pe_module.c @@ -184,6 +184,29 @@ static unsigned pe_get_map_size(const struct image_section_map* ism) return ism->fmap->u.pe.sect[ism->sidx].shdr.Misc.VirtualSize; } +/****************************************************************** + * pe_unmap_file + * + * Unmaps an PE file from memory (previously mapped with pe_map_file) + */ +static void pe_unmap_file(struct image_file_map* fmap) +{ + if (fmap->u.pe.hMap != 0) + { + struct image_section_map ism; + ism.fmap = fmap; + for (ism.sidx = 0; ism.sidx < fmap->u.pe.ntheader.FileHeader.NumberOfSections; ism.sidx++) + { + pe_unmap_section(&ism); + } + while (fmap->u.pe.full_count) pe_unmap_full(fmap); + HeapFree(GetProcessHeap(), 0, fmap->u.pe.sect); + HeapFree(GetProcessHeap(), 0, (void*)fmap->u.pe.strtable); /* FIXME ugly (see pe_map_file) */ + CloseHandle(fmap->u.pe.hMap); + fmap->u.pe.hMap = NULL; + } +} + static const struct image_file_map_ops pe_file_map_ops = { pe_map_section, @@ -191,6 +214,7 @@ static const struct image_file_map_ops pe_file_map_ops = pe_find_section, pe_get_map_rva, pe_get_map_size, + pe_unmap_file, }; /****************************************************************** @@ -298,29 +322,6 @@ error: return FALSE; } -/****************************************************************** - * pe_unmap_file - * - * Unmaps an PE file from memory (previously mapped with pe_map_file) - */ -static void pe_unmap_file(struct image_file_map* fmap) -{ - if (fmap->u.pe.hMap != 0) - { - struct image_section_map ism; - ism.fmap = fmap; - for (ism.sidx = 0; ism.sidx < fmap->u.pe.ntheader.FileHeader.NumberOfSections; ism.sidx++) - { - pe_unmap_section(&ism); - } - while (fmap->u.pe.full_count) pe_unmap_full(fmap); - HeapFree(GetProcessHeap(), 0, fmap->u.pe.sect); - HeapFree(GetProcessHeap(), 0, (void*)fmap->u.pe.strtable); /* FIXME ugly (see pe_map_file) */ - CloseHandle(fmap->u.pe.hMap); - fmap->u.pe.hMap = NULL; - } -} - /****************************************************************** * pe_map_directory * @@ -342,7 +343,7 @@ const char* pe_map_directory(struct module* module, int dirno, DWORD* size) static void pe_module_remove(struct process* pcs, struct module_format* modfmt) { - pe_unmap_file(&modfmt->u.pe_info->fmap); + image_unmap_file(&modfmt->u.pe_info->fmap); HeapFree(GetProcessHeap(), 0, modfmt); } @@ -876,7 +877,7 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, if (pe_map_file(builtin_module, &builtin_fmap, DMT_PE)) { TRACE("reloaded %s from %s\n", debugstr_w(loaded_name), debugstr_w(builtin_path)); - pe_unmap_file(&modfmt->u.pe_info->fmap); + image_unmap_file(&modfmt->u.pe_info->fmap); modfmt->u.pe_info->fmap = builtin_fmap; } CloseHandle(builtin_module); @@ -912,7 +913,7 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, #ifndef __REACTOS__ heap_free(module->real_path); #endif - pe_unmap_file(&modfmt->u.pe_info->fmap); + image_unmap_file(&modfmt->u.pe_info->fmap); } } if (!module) HeapFree(GetProcessHeap(), 0, modfmt); diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index a172fa15fd5..de1470784a2 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: 95a5f8296188d7dd8ffb86afd4f0c3280e2f5656 + wine: 1d96af362789aa8aaa0be94a046b0afba2ecefb3
4 years, 8 months
1
0
0
0
[reactos] 85/179: [WINESYNC] dbghelp: Use vtbl to handle different image_file_map types.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fff3c0ca2c4c1054212cf…
commit fff3c0ca2c4c1054212cf70d379db4a1f93f88a1 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 17:01:17 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:44 2020 +0200 [WINESYNC] dbghelp: Use vtbl to handle different image_file_map types. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 95a5f8296188d7dd8ffb86afd4f0c3280e2f5656 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 44 +++++++------------ dll/win32/dbghelp/image_private.h | 89 ++++++--------------------------------- dll/win32/dbghelp/macho_module.c | 41 +++++++----------- dll/win32/dbghelp/pe_module.c | 24 ++++++++--- sdk/tools/winesync/dbghelp.cfg | 2 +- 5 files changed, 63 insertions(+), 137 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index a5b7c1dc5ca..300926f88b9 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -134,7 +134,7 @@ struct elf_module_info * * Maps a single section into memory from an ELF file */ -const char* elf_map_section(struct image_section_map* ism) +static const char* elf_map_section(struct image_section_map* ism) { struct elf_file_map* fmap = &ism->fmap->u.elf; SYSTEM_INFO sysinfo; @@ -176,7 +176,7 @@ const char* elf_map_section(struct image_section_map* ism) * Finds a section by name (and type) into memory from an ELF file * or its alternate if any */ -BOOL elf_find_section(struct image_file_map* _fmap, const char* name, struct image_section_map* ism) +static BOOL elf_find_section(struct image_file_map* _fmap, const char* name, struct image_section_map* ism) { struct elf_file_map* fmap = &_fmap->u.elf; unsigned i; @@ -233,7 +233,7 @@ static BOOL elf_find_section_type(struct image_file_map* _fmap, const char* name * * Unmaps a single section from memory */ -void elf_unmap_section(struct image_section_map* ism) +static void elf_unmap_section(struct image_section_map* ism) { struct elf_file_map* fmap = &ism->fmap->u.elf; @@ -265,7 +265,7 @@ static void elf_end_find(struct image_file_map* fmap) * * Get the RVA of an ELF section */ -DWORD_PTR elf_get_map_rva(const struct image_section_map* ism) +static DWORD_PTR elf_get_map_rva(const struct image_section_map* ism) { if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.elf.elfhdr.e_shnum) return 0; @@ -277,15 +277,25 @@ DWORD_PTR elf_get_map_rva(const struct image_section_map* ism) * * Get the size of an ELF section */ -unsigned elf_get_map_size(const struct image_section_map* ism) +static unsigned elf_get_map_size(const struct image_section_map* ism) { if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.elf.elfhdr.e_shnum) return 0; return ism->fmap->u.elf.sect[ism->sidx].shdr.sh_size; } +static const struct image_file_map_ops elf_file_map_ops = +{ + elf_map_section, + elf_unmap_section, + elf_find_section, + elf_get_map_rva, + elf_get_map_size, +}; + static inline void elf_reset_file_map(struct image_file_map* fmap) { + fmap->ops = &elf_file_map_ops; fmap->alternate = NULL; fmap->u.elf.handle = INVALID_HANDLE_VALUE; fmap->u.elf.shstrtab = IMAGE_NO_MAP; @@ -2036,30 +2046,6 @@ BOOL elf_synchronize_module_list(struct process* pcs) #else /* !__ELF__ */ -BOOL elf_find_section(struct image_file_map* fmap, const char* name, - struct image_section_map* ism) -{ - return FALSE; -} - -const char* elf_map_section(struct image_section_map* ism) -{ - return NULL; -} - -void elf_unmap_section(struct image_section_map* ism) -{} - -unsigned elf_get_map_size(const struct image_section_map* ism) -{ - return 0; -} - -DWORD_PTR elf_get_map_rva(const struct image_section_map* ism) -{ - return 0; -} - BOOL elf_synchronize_module_list(struct process* pcs) { return FALSE; diff --git a/dll/win32/dbghelp/image_private.h b/dll/win32/dbghelp/image_private.h index 072c956c3e5..8543cdc2e84 100644 --- a/dll/win32/dbghelp/image_private.h +++ b/dll/win32/dbghelp/image_private.h @@ -62,6 +62,7 @@ struct image_file_map { enum module_type modtype; + const struct image_file_map_ops *ops; unsigned addr_size; /* either 16 (not used), 32 or 64 */ struct image_file_map* alternate; /* another file linked to this one */ union @@ -131,47 +132,21 @@ struct image_section_map long sidx; }; -extern BOOL elf_find_section(struct image_file_map* fmap, const char* name, - struct image_section_map* ism) DECLSPEC_HIDDEN; -extern const char* elf_map_section(struct image_section_map* ism) DECLSPEC_HIDDEN; -extern void elf_unmap_section(struct image_section_map* ism) DECLSPEC_HIDDEN; -extern DWORD_PTR elf_get_map_rva(const struct image_section_map* ism) DECLSPEC_HIDDEN; -extern unsigned elf_get_map_size(const struct image_section_map* ism) DECLSPEC_HIDDEN; - -extern BOOL macho_find_section(struct image_file_map* ifm, const char* segname, - const char* sectname, struct image_section_map* ism) DECLSPEC_HIDDEN; -extern const char* macho_map_section(struct image_section_map* ism) DECLSPEC_HIDDEN; -extern void macho_unmap_section(struct image_section_map* ism) DECLSPEC_HIDDEN; -extern DWORD_PTR macho_get_map_rva(const struct image_section_map* ism) DECLSPEC_HIDDEN; -extern unsigned macho_get_map_size(const struct image_section_map* ism) DECLSPEC_HIDDEN; - -extern BOOL pe_find_section(struct image_file_map* fmap, const char* name, - struct image_section_map* ism) DECLSPEC_HIDDEN; -extern const char* pe_map_section(struct image_section_map* psm) DECLSPEC_HIDDEN; -extern void pe_unmap_section(struct image_section_map* psm) DECLSPEC_HIDDEN; -extern DWORD_PTR pe_get_map_rva(const struct image_section_map* psm) DECLSPEC_HIDDEN; -extern unsigned pe_get_map_size(const struct image_section_map* psm) DECLSPEC_HIDDEN; +struct image_file_map_ops +{ + const char* (*map_section)(struct image_section_map* ism); + void (*unmap_section)(struct image_section_map* ism); + BOOL (*find_section)(struct image_file_map* fmap, const char* name, struct image_section_map* ism); + DWORD_PTR (*get_map_rva)(const struct image_section_map* ism); + unsigned (*get_map_size)(const struct image_section_map* ism); +}; static inline BOOL image_find_section(struct image_file_map* fmap, const char* name, struct image_section_map* ism) { while (fmap) { - switch (fmap->modtype) - { -#ifndef DBGHELP_STATIC_LIB - case DMT_ELF: - if (elf_find_section(fmap, name, ism)) return TRUE; - break; - case DMT_MACHO: - if (macho_find_section(fmap, NULL, name, ism)) return TRUE; - break; -#endif - case DMT_PE: - if (pe_find_section(fmap, name, ism)) return TRUE; - break; - default: assert(0); return FALSE; - } + if (fmap->ops->find_section(fmap, name, ism)) return TRUE; fmap = fmap->alternate; } ism->fmap = NULL; @@ -181,56 +156,20 @@ static inline BOOL image_find_section(struct image_file_map* fmap, const char* n static inline const char* image_map_section(struct image_section_map* ism) { - if (!ism->fmap) return NULL; - switch (ism->fmap->modtype) - { -#ifndef DBGHELP_STATIC_LIB - case DMT_ELF: return elf_map_section(ism); - case DMT_MACHO: return macho_map_section(ism); -#endif - case DMT_PE: return pe_map_section(ism); - default: assert(0); return NULL; - } + return ism->fmap ? ism->fmap->ops->map_section(ism) : NULL; } static inline void image_unmap_section(struct image_section_map* ism) { - if (!ism->fmap) return; - switch (ism->fmap->modtype) - { -#ifndef DBGHELP_STATIC_LIB - case DMT_ELF: elf_unmap_section(ism); break; - case DMT_MACHO: macho_unmap_section(ism); break; -#endif - case DMT_PE: pe_unmap_section(ism); break; - default: assert(0); return; - } + if (ism->fmap) ism->fmap->ops->unmap_section(ism); } static inline DWORD_PTR image_get_map_rva(const struct image_section_map* ism) { - if (!ism->fmap) return 0; - switch (ism->fmap->modtype) - { -#ifndef DBGHELP_STATIC_LIB - case DMT_ELF: return elf_get_map_rva(ism); - case DMT_MACHO: return macho_get_map_rva(ism); -#endif - case DMT_PE: return pe_get_map_rva(ism); - default: assert(0); return 0; - } + return ism->fmap ? ism->fmap->ops->get_map_rva(ism) : 0; } static inline unsigned image_get_map_size(const struct image_section_map* ism) { - if (!ism->fmap) return 0; - switch (ism->fmap->modtype) - { -#ifndef DBGHELP_STATIC_LIB - case DMT_ELF: return elf_get_map_size(ism); - case DMT_MACHO: return macho_get_map_size(ism); -#endif - case DMT_PE: return pe_get_map_size(ism); - default: assert(0); return 0; - } + return ism->fmap ? ism->fmap->ops->get_map_size(ism) : 0; } diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 1df48c8a951..a9a086ea767 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -332,7 +332,7 @@ static void macho_unmap_ranges(const struct macho_file_map* fmap, /****************************************************************** * macho_find_section */ -BOOL macho_find_section(struct image_file_map* ifm, const char* segname, const char* sectname, struct image_section_map* ism) +static BOOL macho_find_segment_section(struct image_file_map* ifm, const char* segname, const char* sectname, struct image_section_map* ism) { struct macho_file_map* fmap; unsigned i; @@ -369,6 +369,11 @@ BOOL macho_find_section(struct image_file_map* ifm, const char* segname, const c return FALSE; } +static BOOL macho_find_section(struct image_file_map* ifm, const char* sectname, struct image_section_map* ism) +{ + return macho_find_segment_section(ifm, NULL, sectname, ism); +} + /****************************************************************** * macho_map_section */ @@ -420,6 +425,15 @@ unsigned macho_get_map_size(const struct image_section_map* ism) return ism->fmap->u.macho.sect[ism->sidx].section.size; } +static const struct image_file_map_ops macho_file_map_ops = +{ + macho_map_section, + macho_unmap_section, + macho_find_section, + macho_get_map_rva, + macho_get_map_size, +}; + /****************************************************************** * macho_map_load_commands * @@ -680,6 +694,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW, reset_file_map(ifm); ifm->modtype = DMT_MACHO; + ifm->ops = &macho_file_map_ops; ifm->alternate = NULL; ifm->addr_size = (pcs->is_64bit) ? 64 : 32; fmap->header_size = (pcs->is_64bit) ? sizeof(struct mach_header_64) : sizeof(struct mach_header); @@ -1998,30 +2013,6 @@ struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsign #else /* HAVE_MACH_O_LOADER_H */ -BOOL macho_find_section(struct image_file_map* ifm, const char* segname, const char* sectname, struct image_section_map* ism) -{ - return FALSE; -} - -const char* macho_map_section(struct image_section_map* ism) -{ - return NULL; -} - -void macho_unmap_section(struct image_section_map* ism) -{ -} - -DWORD_PTR macho_get_map_rva(const struct image_section_map* ism) -{ - return 0; -} - -unsigned macho_get_map_size(const struct image_section_map* ism) -{ - return 0; -} - BOOL macho_synchronize_module_list(struct process* pcs) { return FALSE; diff --git a/dll/win32/dbghelp/pe_module.c b/dll/win32/dbghelp/pe_module.c index 2134804ccaa..d92e4333a5d 100644 --- a/dll/win32/dbghelp/pe_module.c +++ b/dll/win32/dbghelp/pe_module.c @@ -75,7 +75,7 @@ static void pe_unmap_full(struct image_file_map* fmap) * * Maps a single section into memory from an PE file */ -const char* pe_map_section(struct image_section_map* ism) +static const char* pe_map_section(struct image_section_map* ism) { void* mapping; struct pe_file_map* fmap = &ism->fmap->u.pe; @@ -113,8 +113,8 @@ const char* pe_map_section(struct image_section_map* ism) * Finds a section by name (and type) into memory from an PE file * or its alternate if any */ -BOOL pe_find_section(struct image_file_map* fmap, const char* name, - struct image_section_map* ism) +static BOOL pe_find_section(struct image_file_map* fmap, const char* name, + struct image_section_map* ism) { const char* sectname; unsigned i; @@ -150,7 +150,7 @@ BOOL pe_find_section(struct image_file_map* fmap, const char* name, * * Unmaps a single section from memory */ -void pe_unmap_section(struct image_section_map* ism) +static void pe_unmap_section(struct image_section_map* ism) { if (ism->sidx >= 0 && ism->sidx < ism->fmap->u.pe.ntheader.FileHeader.NumberOfSections && ism->fmap->u.pe.sect[ism->sidx].mapped != IMAGE_NO_MAP) @@ -165,7 +165,7 @@ void pe_unmap_section(struct image_section_map* ism) * * Get the RVA of an PE section */ -DWORD_PTR pe_get_map_rva(const struct image_section_map* ism) +static DWORD_PTR pe_get_map_rva(const struct image_section_map* ism) { if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.pe.ntheader.FileHeader.NumberOfSections) return 0; @@ -177,13 +177,22 @@ DWORD_PTR pe_get_map_rva(const struct image_section_map* ism) * * Get the size of a PE section */ -unsigned pe_get_map_size(const struct image_section_map* ism) +static unsigned pe_get_map_size(const struct image_section_map* ism) { if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.pe.ntheader.FileHeader.NumberOfSections) return 0; return ism->fmap->u.pe.sect[ism->sidx].shdr.Misc.VirtualSize; } +static const struct image_file_map_ops pe_file_map_ops = +{ + pe_map_section, + pe_unmap_section, + pe_find_section, + pe_get_map_rva, + pe_get_map_size, +}; + /****************************************************************** * pe_is_valid_pointer_table * @@ -208,11 +217,12 @@ static BOOL pe_is_valid_pointer_table(const IMAGE_NT_HEADERS* nthdr, const void* * * Maps an PE file into memory (and checks it's a real PE file) */ -static BOOL pe_map_file(HANDLE file, struct image_file_map* fmap, enum module_type mt) +BOOL pe_map_file(HANDLE file, struct image_file_map* fmap, enum module_type mt) { void* mapping; fmap->modtype = mt; + fmap->ops = &pe_file_map_ops; fmap->alternate = NULL; fmap->u.pe.hMap = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL); if (fmap->u.pe.hMap == 0) return FALSE; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index d04078ef2a3..a172fa15fd5 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: 02dfd959ca6f2295ca279ab65f6b6429cd53673c + wine: 95a5f8296188d7dd8ffb86afd4f0c3280e2f5656
4 years, 8 months
1
0
0
0
[reactos] 84/179: [WINESYNC] dbghelp: Move alternate file map pointer to generic image_file_map.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2fc432db924a44a30d144…
commit 2fc432db924a44a30d144dbfd587446477fd5440 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 16:57:26 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:44 2020 +0200 [WINESYNC] dbghelp: Move alternate file map pointer to generic image_file_map. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 02dfd959ca6f2295ca279ab65f6b6429cd53673c by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 61 ++++++++++++++++++++++++++------------- dll/win32/dbghelp/image_private.h | 29 ++++++++++++++----- dll/win32/dbghelp/macho_module.c | 1 + dll/win32/dbghelp/pe_module.c | 1 + sdk/tools/winesync/dbghelp.cfg | 2 +- 5 files changed, 65 insertions(+), 29 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 1013b70749a..a5b7c1dc5ca 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -176,14 +176,36 @@ const char* elf_map_section(struct image_section_map* ism) * Finds a section by name (and type) into memory from an ELF file * or its alternate if any */ -BOOL elf_find_section(struct image_file_map* _fmap, const char* name, - unsigned sht, struct image_section_map* ism) +BOOL elf_find_section(struct image_file_map* _fmap, const char* name, struct image_section_map* ism) +{ + struct elf_file_map* fmap = &_fmap->u.elf; + unsigned i; + + if (fmap->shstrtab == IMAGE_NO_MAP) + { + struct image_section_map hdr_ism = {_fmap, fmap->elfhdr.e_shstrndx}; + if ((fmap->shstrtab = elf_map_section(&hdr_ism)) == IMAGE_NO_MAP) return FALSE; + } + for (i = 0; i < fmap->elfhdr.e_shnum; i++) + { + if (strcmp(fmap->shstrtab + fmap->sect[i].shdr.sh_name, name) == 0) + { + ism->fmap = _fmap; + ism->sidx = i; + return TRUE; + } + } + return FALSE; +} + +static BOOL elf_find_section_type(struct image_file_map* _fmap, const char* name, unsigned sht, struct image_section_map* ism) { struct elf_file_map* fmap; unsigned i; while (_fmap) { + if (_fmap->modtype != DMT_ELF) break; fmap = &_fmap->u.elf; if (fmap->shstrtab == IMAGE_NO_MAP) { @@ -192,15 +214,14 @@ BOOL elf_find_section(struct image_file_map* _fmap, const char* name, } for (i = 0; i < fmap->elfhdr.e_shnum; i++) { - if (strcmp(fmap->shstrtab + fmap->sect[i].shdr.sh_name, name) == 0 && - (sht == SHT_NULL || sht == fmap->sect[i].shdr.sh_type)) + if (strcmp(fmap->shstrtab + fmap->sect[i].shdr.sh_name, name) == 0 && sht == fmap->sect[i].shdr.sh_type) { ism->fmap = _fmap; ism->sidx = i; return TRUE; } } - _fmap = fmap->alternate; + _fmap = _fmap->alternate; } ism->fmap = NULL; ism->sidx = -1; @@ -229,13 +250,13 @@ static void elf_end_find(struct image_file_map* fmap) { struct image_section_map ism; - while (fmap) + while (fmap && fmap->modtype == DMT_ELF) { ism.fmap = fmap; ism.sidx = fmap->u.elf.elfhdr.e_shstrndx; elf_unmap_section(&ism); fmap->u.elf.shstrtab = IMAGE_NO_MAP; - fmap = fmap->u.elf.alternate; + fmap = fmap->alternate; } } @@ -265,9 +286,9 @@ unsigned elf_get_map_size(const struct image_section_map* ism) static inline void elf_reset_file_map(struct image_file_map* fmap) { + fmap->alternate = NULL; fmap->u.elf.handle = INVALID_HANDLE_VALUE; fmap->u.elf.shstrtab = IMAGE_NO_MAP; - fmap->u.elf.alternate = NULL; fmap->u.elf.target_copy = NULL; } @@ -512,7 +533,7 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map* */ static void elf_unmap_file(struct image_file_map* fmap) { - while (fmap) + while (fmap && fmap->modtype == DMT_ELF) { if (fmap->u.elf.handle != INVALID_HANDLE_VALUE) { @@ -526,7 +547,7 @@ static void elf_unmap_file(struct image_file_map* fmap) CloseHandle(fmap->u.elf.handle); } HeapFree(GetProcessHeap(), 0, fmap->u.elf.target_copy); - fmap = fmap->u.elf.alternate; + fmap = fmap->alternate; } } @@ -573,8 +594,8 @@ static void elf_hash_symtab(struct module* module, struct pool* pool, struct image_section_map ism, ism_str; const char *symtab; - if (!elf_find_section(fmap, ".symtab", SHT_SYMTAB, &ism) && - !elf_find_section(fmap, ".dynsym", SHT_DYNSYM, &ism)) return; + if (!elf_find_section_type(fmap, ".symtab", SHT_SYMTAB, &ism) && + !elf_find_section_type(fmap, ".dynsym", SHT_DYNSYM, &ism)) return; if ((symtab = image_map_section(&ism)) == IMAGE_NO_MAP) return; ism_str.fmap = ism.fmap; ism_str.sidx = fmap->u.elf.sect[ism.sidx].shdr.sh_link; @@ -1040,7 +1061,7 @@ static BOOL elf_locate_debug_link(struct image_file_map* fmap, const char* filen found: TRACE("Located debug information file %s at %s\n", filename, debugstr_w(p)); HeapFree(GetProcessHeap(), 0, p); - fmap->u.elf.alternate = fmap_link; + fmap->alternate = fmap_link; return TRUE; } @@ -1094,7 +1115,7 @@ static BOOL elf_locate_build_id_target(struct image_file_map* fmap, const BYTE* if (elf_map_file(&emfd, fmap_link)) { struct image_section_map buildid_sect; - if (elf_find_section(fmap_link, ".note.gnu.build-id", SHT_NULL, &buildid_sect)) + if (image_find_section(fmap_link, ".note.gnu.build-id", &buildid_sect)) { const uint32_t* note; @@ -1109,7 +1130,7 @@ static BOOL elf_locate_build_id_target(struct image_file_map* fmap, const BYTE* { TRACE("Located debug information file at %s\n", debugstr_w(p)); HeapFree(GetProcessHeap(), 0, p); - fmap->u.elf.alternate = fmap_link; + fmap->alternate = fmap_link; return TRUE; } WARN("mismatch in buildid information for %s\n", wine_dbgstr_w(p)); @@ -1223,8 +1244,8 @@ static BOOL elf_load_debug_info_from_map(struct module* module, /* check if we need an alternate file (from debuglink or build-id) */ ret = elf_check_alternate(fmap, module); - if (elf_find_section(fmap, ".stab", SHT_NULL, &stab_sect) && - elf_find_section(fmap, ".stabstr", SHT_NULL, &stabstr_sect)) + if (image_find_section(fmap, ".stab", &stab_sect) && + image_find_section(fmap, ".stabstr", &stabstr_sect)) { const char* stab; const char* stabstr; @@ -1323,7 +1344,7 @@ static BOOL elf_load_file_from_fmap(struct process* pcs, const WCHAR* filename, { struct image_section_map ism; - if (elf_find_section(fmap, ".dynamic", SHT_DYNAMIC, &ism)) + if (elf_find_section_type(fmap, ".dynamic", SHT_DYNAMIC, &ism)) { char* ptr = (char*)(ULONG_PTR)fmap->u.elf.sect[ism.sidx].shdr.sh_addr; unsigned long len; @@ -1385,7 +1406,7 @@ static BOOL elf_load_file_from_fmap(struct process* pcs, const WCHAR* filename, struct image_section_map ism; unsigned long modbase = load_offset; - if (elf_find_section(fmap, ".dynamic", SHT_DYNAMIC, &ism)) + if (elf_find_section_type(fmap, ".dynamic", SHT_DYNAMIC, &ism)) { unsigned long rva_dyn = elf_get_map_rva(&ism); @@ -2016,7 +2037,7 @@ BOOL elf_synchronize_module_list(struct process* pcs) #else /* !__ELF__ */ BOOL elf_find_section(struct image_file_map* fmap, const char* name, - unsigned sht, struct image_section_map* ism) + struct image_section_map* ism) { return FALSE; } diff --git a/dll/win32/dbghelp/image_private.h b/dll/win32/dbghelp/image_private.h index 2d9b354f7a6..072c956c3e5 100644 --- a/dll/win32/dbghelp/image_private.h +++ b/dll/win32/dbghelp/image_private.h @@ -63,6 +63,7 @@ struct image_file_map { enum module_type modtype; unsigned addr_size; /* either 16 (not used), 32 or 64 */ + struct image_file_map* alternate; /* another file linked to this one */ union { struct elf_file_map @@ -71,7 +72,6 @@ struct image_file_map size_t elf_start; HANDLE handle; const char* shstrtab; - struct image_file_map* alternate; /* another ELF file (linked to this one) */ char* target_copy; #if defined(__ELF__) && !defined(DBGHELP_STATIC_LIB) Elf64_Ehdr elfhdr; @@ -132,7 +132,7 @@ struct image_section_map }; extern BOOL elf_find_section(struct image_file_map* fmap, const char* name, - unsigned sht, struct image_section_map* ism) DECLSPEC_HIDDEN; + struct image_section_map* ism) DECLSPEC_HIDDEN; extern const char* elf_map_section(struct image_section_map* ism) DECLSPEC_HIDDEN; extern void elf_unmap_section(struct image_section_map* ism) DECLSPEC_HIDDEN; extern DWORD_PTR elf_get_map_rva(const struct image_section_map* ism) DECLSPEC_HIDDEN; @@ -155,15 +155,28 @@ extern unsigned pe_get_map_size(const struct image_section_map* psm) DECLSPE static inline BOOL image_find_section(struct image_file_map* fmap, const char* name, struct image_section_map* ism) { - switch (fmap->modtype) + while (fmap) { + switch (fmap->modtype) + { #ifndef DBGHELP_STATIC_LIB - case DMT_ELF: return elf_find_section(fmap, name, SHT_NULL, ism); - case DMT_MACHO: return macho_find_section(fmap, NULL, name, ism); -#endif - case DMT_PE: return pe_find_section(fmap, name, ism); - default: assert(0); return FALSE; + case DMT_ELF: + if (elf_find_section(fmap, name, ism)) return TRUE; + break; + case DMT_MACHO: + if (macho_find_section(fmap, NULL, name, ism)) return TRUE; + break; +#endif + case DMT_PE: + if (pe_find_section(fmap, name, ism)) return TRUE; + break; + default: assert(0); return FALSE; + } + fmap = fmap->alternate; } + ism->fmap = NULL; + ism->sidx = -1; + return FALSE; } static inline const char* image_map_section(struct image_section_map* ism) diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index f957439d435..1df48c8a951 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -680,6 +680,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW, reset_file_map(ifm); ifm->modtype = DMT_MACHO; + ifm->alternate = NULL; ifm->addr_size = (pcs->is_64bit) ? 64 : 32; fmap->header_size = (pcs->is_64bit) ? sizeof(struct mach_header_64) : sizeof(struct mach_header); diff --git a/dll/win32/dbghelp/pe_module.c b/dll/win32/dbghelp/pe_module.c index 1217a8edd0c..2134804ccaa 100644 --- a/dll/win32/dbghelp/pe_module.c +++ b/dll/win32/dbghelp/pe_module.c @@ -213,6 +213,7 @@ static BOOL pe_map_file(HANDLE file, struct image_file_map* fmap, enum module_ty void* mapping; fmap->modtype = mt; + fmap->alternate = NULL; fmap->u.pe.hMap = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL); if (fmap->u.pe.hMap == 0) return FALSE; fmap->u.pe.full_count = 0; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index b5e65c980e9..d04078ef2a3 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: a3e1c7fa02351b032de60fc2a685f14e9f7308fe + wine: 02dfd959ca6f2295ca279ab65f6b6429cd53673c
4 years, 8 months
1
0
0
0
[reactos] 83/179: [WINESYNC] dbghelp: Use generic image_find_section in elf_check_alternate.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bf6f0cfe9b75374ee68bb…
commit bf6f0cfe9b75374ee68bb88d55fc1cd18a056b51 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 16:57:26 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:44 2020 +0200 [WINESYNC] dbghelp: Use generic image_find_section in elf_check_alternate. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id a3e1c7fa02351b032de60fc2a685f14e9f7308fe by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 4 ++-- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 648169b9806..1013b70749a 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1139,7 +1139,7 @@ static BOOL elf_check_alternate(struct image_file_map* fmap, const struct module struct image_section_map buildid_sect, debuglink_sect; /* if present, add the .gnu_debuglink file as an alternate to current one */ - if (elf_find_section(fmap, ".note.gnu.build-id", SHT_NULL, &buildid_sect)) + if (image_find_section(fmap, ".note.gnu.build-id", &buildid_sect)) { const uint32_t* note; @@ -1156,7 +1156,7 @@ static BOOL elf_check_alternate(struct image_file_map* fmap, const struct module image_unmap_section(&buildid_sect); } /* if present, add the .gnu_debuglink file as an alternate to current one */ - if (!ret && elf_find_section(fmap, ".gnu_debuglink", SHT_NULL, &debuglink_sect)) + if (!ret && image_find_section(fmap, ".gnu_debuglink", &debuglink_sect)) { const char* dbg_link; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index dc32ebbc6fe..b5e65c980e9 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: a60b3985bf37827fd0b0f7583c31dcf52069b4a8 + wine: a3e1c7fa02351b032de60fc2a685f14e9f7308fe
4 years, 8 months
1
0
0
0
[reactos] 82/179: [WINESYNC] dbghelp: Use Windows API to map ELF files.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4fc82fc5bda5360f006c7…
commit 4fc82fc5bda5360f006c7dff35a5bfd527e66e04 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 16:57:25 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:44 2020 +0200 [WINESYNC] dbghelp: Use Windows API to map ELF files. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id a60b3985bf37827fd0b0f7583c31dcf52069b4a8 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 168 +++++++++++++++++++++----------------- dll/win32/dbghelp/image_private.h | 2 +- sdk/tools/winesync/dbghelp.cfg | 2 +- 3 files changed, 95 insertions(+), 77 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 96b16fd5c0c..648169b9806 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -32,16 +32,6 @@ #include <assert.h> #include <stdio.h> #include <stdlib.h> -#ifdef HAVE_SYS_STAT_H -# include <sys/stat.h> -#endif -#include <fcntl.h> -#ifdef HAVE_SYS_MMAN_H -#include <sys/mman.h> -#endif -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif #include "dbghelp_private.h" #include "winternl.h" @@ -147,7 +137,9 @@ struct elf_module_info const char* elf_map_section(struct image_section_map* ism) { struct elf_file_map* fmap = &ism->fmap->u.elf; - size_t ofst, size, pgsz = sysconf( _SC_PAGESIZE ); + SYSTEM_INFO sysinfo; + SIZE_T ofst, size; + HANDLE mapping; assert(ism->fmap->modtype == DMT_ELF); if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.elf.elfhdr.e_shnum || @@ -158,14 +150,24 @@ const char* elf_map_section(struct image_section_map* ism) { return fmap->target_copy + fmap->sect[ism->sidx].shdr.sh_offset; } - /* align required information on page size (we assume pagesize is a power of 2) */ - ofst = fmap->sect[ism->sidx].shdr.sh_offset & ~(pgsz - 1); - size = ((fmap->sect[ism->sidx].shdr.sh_offset + - fmap->sect[ism->sidx].shdr.sh_size + pgsz - 1) & ~(pgsz - 1)) - ofst; - fmap->sect[ism->sidx].mapped = mmap(NULL, size, PROT_READ, MAP_PRIVATE, - fmap->fd, ofst); - if (fmap->sect[ism->sidx].mapped == IMAGE_NO_MAP) return IMAGE_NO_MAP; - return fmap->sect[ism->sidx].mapped + (fmap->sect[ism->sidx].shdr.sh_offset & (pgsz - 1)); + + /* 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))) + { + ERR("map creation %p failed %u offset %lu %lu size %lu\n", fmap->handle, GetLastError(), ofst, ofst % 4096, size); + return IMAGE_NO_MAP; + } + fmap->sect[ism->sidx].mapped = MapViewOfFile(mapping, FILE_MAP_READ, 0, ofst, size); + CloseHandle(mapping); + if (!fmap->sect[ism->sidx].mapped) + { + ERR("map %p failed %u offset %lu %lu size %lu\n", fmap->handle, GetLastError(), ofst, ofst % 4096, size); + return IMAGE_NO_MAP; + } + return fmap->sect[ism->sidx].mapped + (fmap->sect[ism->sidx].shdr.sh_offset & (sysinfo.dwAllocationGranularity - 1)); } /****************************************************************** @@ -215,15 +217,11 @@ void elf_unmap_section(struct image_section_map* ism) struct elf_file_map* fmap = &ism->fmap->u.elf; if (ism->sidx >= 0 && ism->sidx < fmap->elfhdr.e_shnum && !fmap->target_copy && - fmap->sect[ism->sidx].mapped != IMAGE_NO_MAP) + fmap->sect[ism->sidx].mapped) { - size_t pgsz = sysconf( _SC_PAGESIZE ); - size_t ofst = fmap->sect[ism->sidx].shdr.sh_offset & ~(pgsz - 1); - size_t size = ((fmap->sect[ism->sidx].shdr.sh_offset + - fmap->sect[ism->sidx].shdr.sh_size + pgsz - 1) & ~(pgsz - 1)) - ofst; - if (munmap((char*)fmap->sect[ism->sidx].mapped, size) < 0) + if (!UnmapViewOfFile(fmap->sect[ism->sidx].mapped)) WARN("Couldn't unmap the section\n"); - fmap->sect[ism->sidx].mapped = IMAGE_NO_MAP; + fmap->sect[ism->sidx].mapped = NULL; } } @@ -267,7 +265,7 @@ unsigned elf_get_map_size(const struct image_section_map* ism) static inline void elf_reset_file_map(struct image_file_map* fmap) { - fmap->u.elf.fd = -1; + fmap->u.elf.handle = INVALID_HANDLE_VALUE; fmap->u.elf.shstrtab = IMAGE_NO_MAP; fmap->u.elf.alternate = NULL; fmap->u.elf.target_copy = NULL; @@ -293,12 +291,16 @@ struct elf_map_file_data static BOOL elf_map_file_read(struct image_file_map* fmap, struct elf_map_file_data* emfd, void* buf, size_t len, off_t off) { + LARGE_INTEGER li; + DWORD bytes_read; SIZE_T dw; switch (emfd->kind) { case from_file: - return pread(fmap->u.elf.fd, buf, len, off) == len; + li.QuadPart = off; + if (!SetFilePointerEx(fmap->u.elf.handle, li, NULL, FILE_BEGIN)) return FALSE; + return ReadFile(fmap->u.elf.handle, buf, len, &bytes_read, NULL); case from_process: return ReadProcessMemory(emfd->u.process.handle, (void*)((unsigned long)emfd->u.process.load_addr + (unsigned long)off), @@ -339,6 +341,29 @@ static BOOL elf_map_shdr(struct elf_map_file_data* emfd, struct image_file_map* return TRUE; } +static WCHAR *get_dos_file_name(const WCHAR *filename) +{ + WCHAR *dos_path; + size_t len; + + if (*filename == '/') + { + char *unix_path; + len = WideCharToMultiByte(CP_UNIXCP, 0, filename, -1, NULL, 0, NULL, NULL); + unix_path = heap_alloc(len * sizeof(WCHAR)); + WideCharToMultiByte(CP_UNIXCP, 0, filename, -1, unix_path, len, NULL, NULL); + dos_path = wine_get_dos_file_name(unix_path); + heap_free(unix_path); + } + else + { + len = lstrlenW(filename); + dos_path = heap_alloc((len + 1) * sizeof(WCHAR)); + memcpy(dos_path, filename, (len + 1) * sizeof(WCHAR)); + } + return dos_path; +} + /****************************************************************** * elf_map_file * @@ -347,53 +372,35 @@ static BOOL elf_map_shdr(struct elf_map_file_data* emfd, struct image_file_map* static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map* fmap) { static const BYTE elf_signature[4] = { ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3 }; - struct stat statbuf; unsigned int i; size_t tmp, page_mask = sysconf( _SC_PAGESIZE ) - 1; - char* filename; - unsigned len; - BOOL ret = FALSE; + WCHAR *dos_path; unsigned char e_ident[EI_NIDENT]; - switch (emfd->kind) - { - case from_file: - len = WideCharToMultiByte(CP_UNIXCP, 0, emfd->u.file.filename, -1, NULL, 0, NULL, NULL); - if (!(filename = HeapAlloc(GetProcessHeap(), 0, len))) return FALSE; - WideCharToMultiByte(CP_UNIXCP, 0, emfd->u.file.filename, -1, filename, len, NULL, NULL); - break; - case from_process: - filename = NULL; - break; - default: assert(0); - return FALSE; - } - elf_reset_file_map(fmap); fmap->modtype = DMT_ELF; - fmap->u.elf.fd = -1; + fmap->u.elf.handle = INVALID_HANDLE_VALUE; fmap->u.elf.target_copy = NULL; switch (emfd->kind) { case from_file: - /* check that the file exists, and that the module hasn't been loaded yet */ - if (stat(filename, &statbuf) == -1 || S_ISDIR(statbuf.st_mode)) goto done; - - /* Now open the file, so that we can mmap() it. */ - if ((fmap->u.elf.fd = open(filename, O_RDONLY)) == -1) goto done; + if (!(dos_path = get_dos_file_name(emfd->u.file.filename))) return FALSE; + fmap->u.elf.handle = CreateFileW(dos_path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + heap_free(dos_path); + if (fmap->u.elf.handle == INVALID_HANDLE_VALUE) return FALSE; break; case from_process: break; } if (!elf_map_file_read(fmap, emfd, e_ident, sizeof(e_ident), 0)) - goto done; + return FALSE; /* and check for an ELF header */ if (memcmp(e_ident, elf_signature, sizeof(elf_signature))) - goto done; + return FALSE; fmap->addr_size = e_ident[EI_CLASS] == ELFCLASS64 ? 64 : 32; @@ -402,7 +409,7 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map* Elf32_Ehdr elfhdr32; if (!elf_map_file_read(fmap, emfd, &elfhdr32, sizeof(elfhdr32), 0)) - goto done; + return FALSE; memcpy(fmap->u.elf.elfhdr.e_ident, elfhdr32.e_ident, EI_NIDENT); fmap->u.elf.elfhdr.e_type = elfhdr32.e_type; @@ -422,12 +429,12 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map* else { if (!elf_map_file_read(fmap, emfd, &fmap->u.elf.elfhdr, sizeof(fmap->u.elf.elfhdr), 0)) - goto done; + return FALSE; } fmap->u.elf.sect = HeapAlloc(GetProcessHeap(), 0, fmap->u.elf.elfhdr.e_shnum * sizeof(fmap->u.elf.sect[0])); - if (!fmap->u.elf.sect) goto done; + if (!fmap->u.elf.sect) return FALSE; for (i = 0; i < fmap->u.elf.elfhdr.e_shnum; i++) { @@ -435,9 +442,9 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map* { HeapFree(GetProcessHeap(), 0, fmap->u.elf.sect); fmap->u.elf.sect = NULL; - goto done; + return FALSE; } - fmap->u.elf.sect[i].mapped = IMAGE_NO_MAP; + fmap->u.elf.sect[i].mapped = NULL; } /* grab size of module once loaded in memory */ @@ -484,21 +491,18 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map* if (!(fmap->u.elf.target_copy = HeapAlloc(GetProcessHeap(), 0, fmap->u.elf.elf_size))) { HeapFree(GetProcessHeap(), 0, fmap->u.elf.sect); - goto done; + return FALSE; } if (!ReadProcessMemory(emfd->u.process.handle, emfd->u.process.load_addr, fmap->u.elf.target_copy, fmap->u.elf.elf_size, NULL)) { HeapFree(GetProcessHeap(), 0, fmap->u.elf.target_copy); HeapFree(GetProcessHeap(), 0, fmap->u.elf.sect); - goto done; + return FALSE; } break; } - ret = TRUE; -done: - HeapFree(GetProcessHeap(), 0, filename); - return ret; + return TRUE; } /****************************************************************** @@ -510,7 +514,7 @@ static void elf_unmap_file(struct image_file_map* fmap) { while (fmap) { - if (fmap->u.elf.fd != -1) + if (fmap->u.elf.handle != INVALID_HANDLE_VALUE) { struct image_section_map ism; ism.fmap = fmap; @@ -519,7 +523,7 @@ static void elf_unmap_file(struct image_file_map* fmap) elf_unmap_section(&ism); } HeapFree(GetProcessHeap(), 0, fmap->u.elf.sect); - close(fmap->u.elf.fd); + CloseHandle(fmap->u.elf.handle); } HeapFree(GetProcessHeap(), 0, fmap->u.elf.target_copy); fmap = fmap->u.elf.alternate; @@ -934,21 +938,35 @@ static int elf_new_public_symbols(struct module* module, const struct hash_table return TRUE; } -static BOOL elf_check_debug_link(const WCHAR* file, struct image_file_map* fmap, DWORD crc) +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) { - BOOL ret; struct elf_map_file_data emfd; + DWORD crc; emfd.kind = from_file; emfd.u.file.filename = file; if (!elf_map_file(&emfd, fmap)) return FALSE; - if (!(ret = crc == calc_crc32(fmap->u.elf.fd))) + + crc = calc_crc(fmap->u.elf.handle); + if (crc != link_crc) { - WARN("Bad CRC for file %s (got %08x while expecting %08x)\n", - debugstr_w(file), calc_crc32(fmap->u.elf.fd), crc); + WARN("Bad CRC for file %s (got %08x while expecting %08x)\n", debugstr_w(file), crc, link_crc); elf_unmap_file(fmap); + return FALSE; } - return ret; + return TRUE; } /****************************************************************** @@ -1290,7 +1308,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_crc32(fmap.u.elf.fd); + *checksum = calc_crc(fmap.u.elf.handle); elf_unmap_file(&fmap); return TRUE; } @@ -1386,7 +1404,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_crc32(fmap->u.elf.fd)); + fmap->u.elf.elf_size, 0, calc_crc(fmap->u.elf.handle)); if (!elf_info->module) { HeapFree(GetProcessHeap(), 0, modfmt); diff --git a/dll/win32/dbghelp/image_private.h b/dll/win32/dbghelp/image_private.h index fd5a7c91d69..2d9b354f7a6 100644 --- a/dll/win32/dbghelp/image_private.h +++ b/dll/win32/dbghelp/image_private.h @@ -69,7 +69,7 @@ struct image_file_map { size_t elf_size; size_t elf_start; - int fd; + HANDLE handle; const char* shstrtab; struct image_file_map* alternate; /* another ELF file (linked to this one) */ char* target_copy; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index abdb0e40ad3..dc32ebbc6fe 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: d731208602393877709d3bb0bdeb28c80f9719b0 + wine: a60b3985bf37827fd0b0f7583c31dcf52069b4a8
4 years, 8 months
1
0
0
0
[reactos] 81/179: [WINESYNC] dbghelp: Search also real path location in path_find_symbol_file.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c82f34344e88b2e6b68a8…
commit c82f34344e88b2e6b68a8cbe0b4d5ab78f8c44dd Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 16:57:23 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:44 2020 +0200 [WINESYNC] dbghelp: Search also real path location in path_find_symbol_file. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id d731208602393877709d3bb0bdeb28c80f9719b0 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/path.c | 5 +++++ sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dll/win32/dbghelp/path.c b/dll/win32/dbghelp/path.c index f8a7f3d890a..014c79c4790 100644 --- a/dll/win32/dbghelp/path.c +++ b/dll/win32/dbghelp/path.c @@ -664,6 +664,11 @@ BOOL path_find_symbol_file(const struct process* pcs, const struct module* modul /* 2. check module-path */ file_pathW(module->module.LoadedImageName, buffer); if (do_searchW(filename, buffer, FALSE, module_find_cb, &mf)) return TRUE; + if (module->real_path) + { + file_pathW(module->real_path, buffer); + if (do_searchW(filename, buffer, FALSE, module_find_cb, &mf)) return TRUE; + } while (searchPath) { diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 3b36c85191e..abdb0e40ad3 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: e21b61392cbc3a4879f837316c869c44b8dcf685 + wine: d731208602393877709d3bb0bdeb28c80f9719b0
4 years, 8 months
1
0
0
0
[reactos] 80/179: [WINESYNC] dbghelp: Try loading builtin modules from unix installation.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=95f6a74d855565e92caf3…
commit 95f6a74d855565e92caf3c9de4c873ff945ee765 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 16:56:27 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:44 2020 +0200 [WINESYNC] dbghelp: Try loading builtin modules from unix installation. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id e21b61392cbc3a4879f837316c869c44b8dcf685 by Jacek Caban <jacek(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp_private.h | 1 + dll/win32/dbghelp/image_private.h | 1 + dll/win32/dbghelp/module.c | 1 + dll/win32/dbghelp/pe_module.c | 94 +++++++++++++++++++++++++++++++++++++ sdk/tools/winesync/dbghelp.cfg | 2 +- 5 files changed, 98 insertions(+), 1 deletion(-) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index 27cb8f2f453..d9cddae5f02 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -384,6 +384,7 @@ struct module enum module_type type : 16; unsigned short is_virtual : 1; DWORD64 reloc_delta; + WCHAR* real_path; /* specific information for debug types */ struct module_format* format_info[DFI_LAST]; diff --git a/dll/win32/dbghelp/image_private.h b/dll/win32/dbghelp/image_private.h index 46275481f96..fd5a7c91d69 100644 --- a/dll/win32/dbghelp/image_private.h +++ b/dll/win32/dbghelp/image_private.h @@ -112,6 +112,7 @@ struct image_file_map { HANDLE hMap; IMAGE_NT_HEADERS ntheader; + BOOL builtin; unsigned full_count; void* full_map; struct diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c index 4dca1cf0a9b..5243b53a829 100644 --- a/dll/win32/dbghelp/module.c +++ b/dll/win32/dbghelp/module.c @@ -732,6 +732,7 @@ BOOL module_remove(struct process* pcs, struct module* module) hash_table_destroy(&module->ht_types); HeapFree(GetProcessHeap(), 0, module->sources); HeapFree(GetProcessHeap(), 0, module->addr_sorttab); + HeapFree(GetProcessHeap(), 0, module->real_path); pool_destroy(&module->pool); /* native dbghelp doesn't invoke registered callback(,CBA_SYMBOLS_UNLOADED,) here * so do we diff --git a/dll/win32/dbghelp/pe_module.c b/dll/win32/dbghelp/pe_module.c index 54a830c5420..1217a8edd0c 100644 --- a/dll/win32/dbghelp/pe_module.c +++ b/dll/win32/dbghelp/pe_module.c @@ -34,6 +34,7 @@ #ifndef DBGHELP_STATIC_LIB #include "winternl.h" #include "wine/debug.h" +#include "wine/heap.h" #endif WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); @@ -43,6 +44,8 @@ struct pe_module_info struct image_file_map fmap; }; +static const char builtin_signature[] = "Wine builtin DLL"; + static void* pe_map_full(struct image_file_map* fmap, IMAGE_NT_HEADERS** nth) { if (!fmap->u.pe.full_map) @@ -232,6 +235,8 @@ static BOOL pe_map_file(HANDLE file, struct image_file_map* fmap, enum module_ty case 0x20b: fmap->addr_size = 64; break; default: return FALSE; } + + fmap->u.pe.builtin = !memcmp((const IMAGE_DOS_HEADER*)mapping + 1, builtin_signature, sizeof(builtin_signature)); section = (IMAGE_SECTION_HEADER*) ((char*)&nthdr->OptionalHeader + nthdr->FileHeader.SizeOfOptionalHeader); fmap->u.pe.sect = HeapAlloc(GetProcessHeap(), 0, @@ -756,6 +761,72 @@ BOOL pe_load_debug_info(const struct process* pcs, struct module* module) return ret; } +#ifndef __REACTOS__ +static WCHAR *find_builtin_pe(const WCHAR *path, HANDLE *file) +{ + const WCHAR *base_name; + size_t len, i; + WCHAR *buf; + + static const WCHAR winebuilddirW[] = {'W','I','N','E','B','U','I','L','D','D','I','R',0}; + static const WCHAR winedlldirW[] = {'W','I','N','E','D','L','L','D','I','R','%','u',0}; + + if ((base_name = strrchrW(path, '\\'))) base_name++; + else base_name = path; + + if ((len = GetEnvironmentVariableW(winebuilddirW, NULL, 0))) + { + WCHAR *p, *end; + const WCHAR dllsW[] = { '\\','d','l','l','s','\\' }; + const WCHAR programsW[] = { '\\','p','r','o','g','r','a','m','s','\\' }; + const WCHAR dot_dllW[] = {'.','d','l','l',0}; + const WCHAR dot_exeW[] = {'.','e','x','e',0}; + + if (!(buf = heap_alloc((len + 8 + 2 * lstrlenW(base_name)) * sizeof(WCHAR)))) return NULL; + end = buf + GetEnvironmentVariableW(winebuilddirW, buf, len); + + memcpy(end, dllsW, sizeof(dllsW)); + strcpyW(end + ARRAY_SIZE(dllsW), base_name); + if ((p = strchrW(end, '.')) && !lstrcmpW(p, dot_dllW)) *p = 0; + p = end + strlenW(end); + *p++ = '\\'; + strcpyW(p, base_name); + *file = CreateFileW(buf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (*file != INVALID_HANDLE_VALUE) return buf; + + memcpy(end, programsW, sizeof(programsW)); + end += ARRAY_SIZE(programsW); + strcpyW(end, base_name); + if ((p = strchrW(end, '.')) && !lstrcmpW(p, dot_exeW)) *p = 0; + p = end + strlenW(end); + *p++ = '\\'; + strcpyW(p, base_name); + *file = CreateFileW(buf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (*file != INVALID_HANDLE_VALUE) return buf; + + heap_free(buf); + } + + for (i = 0;; i++) + { + WCHAR name[64]; + sprintfW(name, winedlldirW, i); + if (!(len = GetEnvironmentVariableW(name, NULL, 0))) break; + if (!(buf = heap_alloc((len + lstrlenW(base_name) + 2) * sizeof(WCHAR)))) return NULL; + + GetEnvironmentVariableW(name, buf, len); + buf[len++] = '\\'; + strcpyW(buf + len, base_name); + *file = CreateFileW(buf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (*file != INVALID_HANDLE_VALUE) return buf; + + heap_free(buf); + } + + return NULL; +} +#endif + /****************************************************************** * pe_load_native_module * @@ -785,6 +856,21 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, modfmt->u.pe_info = (struct pe_module_info*)(modfmt + 1); if (pe_map_file(hFile, &modfmt->u.pe_info->fmap, DMT_PE)) { +#ifndef __REACTOS__ + WCHAR *builtin_path = NULL; + HANDLE builtin_module; + if (modfmt->u.pe_info->fmap.u.pe.builtin && (builtin_path = find_builtin_pe(loaded_name, &builtin_module))) + { + struct image_file_map builtin_fmap; + if (pe_map_file(builtin_module, &builtin_fmap, DMT_PE)) + { + TRACE("reloaded %s from %s\n", debugstr_w(loaded_name), debugstr_w(builtin_path)); + pe_unmap_file(&modfmt->u.pe_info->fmap); + modfmt->u.pe_info->fmap = builtin_fmap; + } + CloseHandle(builtin_module); + } +#endif if (!base) base = modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.ImageBase; if (!size) size = modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.SizeOfImage; @@ -793,6 +879,11 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.CheckSum); if (module) { +#ifdef __REACTOS__ + module->real_path = NULL; +#else + module->real_path = builtin_path; +#endif modfmt->module = module; modfmt->remove = pe_module_remove; modfmt->loc_compute = NULL; @@ -807,6 +898,9 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, else { ERR("could not load the module '%s'\n", debugstr_w(loaded_name)); +#ifndef __REACTOS__ + heap_free(module->real_path); +#endif pe_unmap_file(&modfmt->u.pe_info->fmap); } } diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 80fc0c075da..3b36c85191e 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: 7e16acf3806f9e810884d710c640f5f82c158093 + wine: e21b61392cbc3a4879f837316c869c44b8dcf685
4 years, 8 months
1
0
0
0
[reactos] 79/179: [WINESYNC] dbghelp: Use RtlImageDirectoryEntryToData in pe_load_msc_debug_info.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a6145efdfd9e2645320d0…
commit a6145efdfd9e2645320d0c7a87f92711684a1b00 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 16:53:38 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:43 2020 +0200 [WINESYNC] dbghelp: Use RtlImageDirectoryEntryToData in pe_load_msc_debug_info. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 7e16acf3806f9e810884d710c640f5f82c158093 by Piotr Caban <piotr(a)codeweavers.com> --- dll/win32/dbghelp/pe_module.c | 29 ++++++++--------------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/dll/win32/dbghelp/pe_module.c b/dll/win32/dbghelp/pe_module.c index 7fcaf27e6c7..54a830c5420 100644 --- a/dll/win32/dbghelp/pe_module.c +++ b/dll/win32/dbghelp/pe_module.c @@ -465,7 +465,7 @@ static BOOL pe_load_coff_symbol_table(struct module* module) /****************************************************************** * pe_load_stabs * - * look for stabs information in PE header (it's how the mingw compiler provides + * look for stabs information in PE header (it's how the mingw compiler provides * its debugging information) */ static BOOL pe_load_stabs(const struct process* pcs, struct module* module) @@ -601,28 +601,15 @@ static BOOL pe_load_msc_debug_info(const struct process* pcs, struct module* mod { struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap; BOOL ret = FALSE; - const IMAGE_DATA_DIRECTORY* dir; - const IMAGE_DEBUG_DIRECTORY*dbg = NULL; - int nDbg; + const IMAGE_DEBUG_DIRECTORY*dbg; + ULONG nDbg; void* mapping; IMAGE_NT_HEADERS* nth; if (!(mapping = pe_map_full(fmap, &nth))) return FALSE; /* Read in debug directory */ - dir = nth->OptionalHeader.DataDirectory + IMAGE_DIRECTORY_ENTRY_DEBUG; - nDbg = dir->Size / sizeof(IMAGE_DEBUG_DIRECTORY); - if (!nDbg) goto done; - - dbg = RtlImageRvaToVa(nth, mapping, dir->VirtualAddress, NULL); - -#ifdef __REACTOS__ - if (!dbg) - { - ERR("Debug directory not found in module %s\n", - debugstr_w(module->module.ModuleName)); - goto done; - } -#endif + dbg = RtlImageDirectoryEntryToData( mapping, FALSE, IMAGE_DIRECTORY_ENTRY_DEBUG, &nDbg ); + if (!dbg || !(nDbg /= sizeof(IMAGE_DEBUG_DIRECTORY))) goto done; /* Parse debug directory */ if (nth->FileHeader.Characteristics & IMAGE_FILE_DEBUG_STRIPPED) @@ -676,18 +663,18 @@ static BOOL pe_load_export_debug_info(const struct process* pcs, struct module* /* FIXME: module.ModuleName isn't correctly set yet if it's passed in SymLoadModule */ symt_new_public(module, NULL, module->module.ModuleName, FALSE, base, 1); #endif - + /* Add entry point */ symt_new_public(module, NULL, "EntryPoint", FALSE, base + nth->OptionalHeader.AddressOfEntryPoint, 1); #if 0 - /* FIXME: we'd better store addresses linked to sections rather than + /* FIXME: we'd better store addresses linked to sections rather than absolute values */ IMAGE_SECTION_HEADER* section; /* Add start of sections */ section = (IMAGE_SECTION_HEADER*) ((char*)&nth->OptionalHeader + nth->FileHeader.SizeOfOptionalHeader); - for (i = 0; i < nth->FileHeader.NumberOfSections; i++, section++) + for (i = 0; i < nth->FileHeader.NumberOfSections; i++, section++) { symt_new_public(module, NULL, section->Name, FALSE, RtlImageRvaToVa(nth, mapping, section->VirtualAddress, NULL), 1); diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index dcca9791c8c..80fc0c075da 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: ab4c64a4093b98ca7a74ec29a9d947333791b26d + wine: 7e16acf3806f9e810884d710c640f5f82c158093
4 years, 8 months
1
0
0
0
[reactos] 78/179: [WINESYNC] dbghelp: Support 32 and 64-bit binaries in ImageDirectoryEntryToDataEx.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e27e4dbaee71dc7fe527b…
commit e27e4dbaee71dc7fe527b88b07bc08336ceb6df4 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 16:53:37 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:43 2020 +0200 [WINESYNC] dbghelp: Support 32 and 64-bit binaries in ImageDirectoryEntryToDataEx. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id ab4c64a4093b98ca7a74ec29a9d947333791b26d by Piotr Caban <piotr(a)codeweavers.com> --- dll/win32/dbghelp/pe_module.c | 22 ++++++++++++++++++---- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/dll/win32/dbghelp/pe_module.c b/dll/win32/dbghelp/pe_module.c index f458b8aa516..7fcaf27e6c7 100644 --- a/dll/win32/dbghelp/pe_module.c +++ b/dll/win32/dbghelp/pe_module.c @@ -896,11 +896,25 @@ PVOID WINAPI ImageDirectoryEntryToDataEx( PVOID base, BOOLEAN image, USHORT dir, if (section) *section = NULL; if (!(nt = RtlImageNtHeader( base ))) return NULL; - if (dir >= nt->OptionalHeader.NumberOfRvaAndSizes) return NULL; - if (!(addr = nt->OptionalHeader.DataDirectory[dir].VirtualAddress)) return NULL; + if (nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) + { + const IMAGE_NT_HEADERS64 *nt64 = (const IMAGE_NT_HEADERS64 *)nt; - *size = nt->OptionalHeader.DataDirectory[dir].Size; - if (image || addr < nt->OptionalHeader.SizeOfHeaders) return (char *)base + addr; + if (dir >= nt64->OptionalHeader.NumberOfRvaAndSizes) return NULL; + if (!(addr = nt64->OptionalHeader.DataDirectory[dir].VirtualAddress)) return NULL; + *size = nt64->OptionalHeader.DataDirectory[dir].Size; + if (image || addr < nt64->OptionalHeader.SizeOfHeaders) return (char *)base + addr; + } + else if (nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) + { + const IMAGE_NT_HEADERS32 *nt32 = (const IMAGE_NT_HEADERS32 *)nt; + + if (dir >= nt32->OptionalHeader.NumberOfRvaAndSizes) return NULL; + if (!(addr = nt32->OptionalHeader.DataDirectory[dir].VirtualAddress)) return NULL; + *size = nt32->OptionalHeader.DataDirectory[dir].Size; + if (image || addr < nt32->OptionalHeader.SizeOfHeaders) return (char *)base + addr; + } + else return NULL; return RtlImageRvaToVa( nt, base, addr, section ); } diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 3a6c57148d7..dcca9791c8c 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: 8000b5415d2c249176bda3d8b49f8fc9978e1623 + wine: ab4c64a4093b98ca7a74ec29a9d947333791b26d
4 years, 8 months
1
0
0
0
[reactos] 77/179: [WINESYNC] dbghelp: Look for .eh_fram if no .eh_frame is found.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b7d8c1b1c2a7baf2dfcf1…
commit b7d8c1b1c2a7baf2dfcf1d7e324b194de3b903b6 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 16:53:27 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:43 2020 +0200 [WINESYNC] dbghelp: Look for .eh_fram if no .eh_frame is found. lld produces these, because '.eh_frame' misses the eight-character limit by one character, but '.eh_fram' does not. This allows it to avoid producing a string table for this common section. Signed-off-by: Chip Davis <cdavis(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 8000b5415d2c249176bda3d8b49f8fc9978e1623 by Chip Davis <cdavis(a)codeweavers.com> --- dll/win32/dbghelp/dwarf.c | 4 +++- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dll/win32/dbghelp/dwarf.c b/dll/win32/dbghelp/dwarf.c index 1c227d5f23d..6d3fb534d98 100644 --- a/dll/win32/dbghelp/dwarf.c +++ b/dll/win32/dbghelp/dwarf.c @@ -3539,7 +3539,9 @@ BOOL dwarf2_parse(struct module* module, unsigned long load_offset, BOOL ret = TRUE; struct module_format* dwarf2_modfmt; - dwarf2_init_section(&eh_frame, fmap, ".eh_frame", NULL, &eh_frame_sect); + if (!dwarf2_init_section(&eh_frame, fmap, ".eh_frame", NULL, &eh_frame_sect)) + /* lld produces .eh_fram to avoid generating a long name */ + dwarf2_init_section(&eh_frame, fmap, ".eh_fram", NULL, &eh_frame_sect); dwarf2_init_section(§ion[section_debug], fmap, ".debug_info", ".zdebug_info", &debug_sect); dwarf2_init_section(§ion[section_abbrev], fmap, ".debug_abbrev", ".zdebug_abbrev", &debug_abbrev_sect); dwarf2_init_section(§ion[section_string], fmap, ".debug_str", ".zdebug_str", &debug_str_sect); diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index d06f4b1040f..3a6c57148d7 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: 7a567d1bb00ea2cdac0e972220b1985800ab445e + wine: 8000b5415d2c249176bda3d8b49f8fc9978e1623
4 years, 8 months
1
0
0
0
[reactos] 76/179: [WINESYNC] dbghelp: Fix MiniDumpWriteDump spec file entry.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dfead9b2ca59048d1897d…
commit dfead9b2ca59048d1897d2a300f10b5391e203a3 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 16:49:24 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:43 2020 +0200 [WINESYNC] dbghelp: Fix MiniDumpWriteDump spec file entry. Signed-off-by: André Hentschel <nerv(a)dawncrow.de> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 7a567d1bb00ea2cdac0e972220b1985800ab445e by André Hentschel <nerv(a)dawncrow.de> --- sdk/tools/winesync/dbghelp.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 0ba2c849dc3..d06f4b1040f 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: 4b9defe09a24e77547cde4e8211f701a4984681b + wine: 7a567d1bb00ea2cdac0e972220b1985800ab445e
4 years, 8 months
1
0
0
0
[reactos] 75/179: [WINESYNC] dbghelp: Fix reading the target's dyld image info, based on its CPU architecture.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=82a89ba33caf815923cc5…
commit 82a89ba33caf815923cc587b4c4361c49cbb93e3 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 16:49:21 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:43 2020 +0200 [WINESYNC] dbghelp: Fix reading the target's dyld image info, based on its CPU architecture. Signed-off-by: Ken Thomases <ken(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 4b9defe09a24e77547cde4e8211f701a4984681b by Ken Thomases <ken(a)codeweavers.com> --- dll/win32/dbghelp/macho_module.c | 134 ++++++++++++++++++++++++++++----------- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 98 insertions(+), 38 deletions(-) diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 8eda11ab91c..f957439d435 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -60,23 +60,39 @@ #include <mach-o/nlist.h> #include <mach-o/dyld.h> -#ifdef HAVE_MACH_O_DYLD_IMAGES_H -#include <mach-o/dyld_images.h> -#else -struct dyld_image_info { - const struct mach_header *imageLoadAddress; - const char *imageFilePath; - uintptr_t imageFileModDate; +struct dyld_image_info32 { + uint32_t /* const struct mach_header* */ imageLoadAddress; + uint32_t /* const char* */ imageFilePath; + uint32_t /* uintptr_t */ imageFileModDate; }; -struct dyld_all_image_infos { - uint32_t version; - uint32_t infoArrayCount; - const struct dyld_image_info *infoArray; - void* notification; - int processDetachedFromSharedRegion; +struct dyld_all_image_infos32 { + uint32_t version; + uint32_t infoArrayCount; + uint32_t /* const struct dyld_image_info* */ infoArray; +}; + +struct dyld_image_info64 { + uint64_t /* const struct mach_header* */ imageLoadAddress; + uint64_t /* const char* */ imageFilePath; + uint64_t /* uintptr_t */ imageFileModDate; +}; + +struct dyld_all_image_infos64 { + uint32_t version; + uint32_t infoArrayCount; + uint64_t /* const struct dyld_image_info* */ infoArray; +}; + +union wine_image_info { + struct dyld_image_info32 info32; + struct dyld_image_info64 info64; +}; + +union wine_all_image_infos { + struct dyld_all_image_infos32 infos32; + struct dyld_all_image_infos64 infos64; }; -#endif #ifdef WORDS_BIGENDIAN #define swap_ulong_be_to_host(n) (n) @@ -1649,8 +1665,8 @@ static BOOL macho_enum_modules_internal(const struct process* pcs, const WCHAR* main_name, enum_modules_cb cb, void* user) { - struct dyld_all_image_infos image_infos; - struct dyld_image_info* info_array = NULL; + union wine_all_image_infos image_infos; + union wine_image_info* info_array = NULL; unsigned long len; int i; char bufstr[256]; @@ -1660,31 +1676,55 @@ static BOOL macho_enum_modules_internal(const struct process* pcs, TRACE("(%p/%p, %s, %p, %p)\n", pcs, pcs->handle, debugstr_w(main_name), cb, user); + if (pcs->is_64bit) + len = sizeof(image_infos.infos64); + else + len = sizeof(image_infos.infos32); if (!pcs->dbg_hdr_addr || !ReadProcessMemory(pcs->handle, (void*)pcs->dbg_hdr_addr, - &image_infos, sizeof(image_infos), NULL) || - !image_infos.infoArray) + &image_infos, len, NULL)) goto done; - TRACE("Process has %u image infos at %p\n", image_infos.infoArrayCount, image_infos.infoArray); + if (!pcs->is_64bit) + { + struct dyld_all_image_infos32 temp = image_infos.infos32; + image_infos.infos64.infoArrayCount = temp.infoArrayCount; + image_infos.infos64.infoArray = temp.infoArray; + } + if (!image_infos.infos64.infoArray) + goto done; + TRACE("Process has %u image infos at %p\n", image_infos.infos64.infoArrayCount, (void*)image_infos.infos64.infoArray); - len = image_infos.infoArrayCount * sizeof(info_array[0]); + if (pcs->is_64bit) + len = sizeof(info_array->info64); + else + len = sizeof(info_array->info32); + len *= image_infos.infos64.infoArrayCount; info_array = HeapAlloc(GetProcessHeap(), 0, len); if (!info_array || - !ReadProcessMemory(pcs->handle, image_infos.infoArray, + !ReadProcessMemory(pcs->handle, (void*)image_infos.infos64.infoArray, info_array, len, NULL)) goto done; TRACE("... read image infos\n"); - for (i = 0; i < image_infos.infoArrayCount; i++) + for (i = 0; i < image_infos.infos64.infoArrayCount; i++) { - if (info_array[i].imageFilePath != NULL && - ReadProcessMemory(pcs->handle, info_array[i].imageFilePath, bufstr, sizeof(bufstr), NULL)) + struct dyld_image_info64 info; + if (pcs->is_64bit) + info = info_array[i].info64; + else + { + struct dyld_image_info32 *info32 = &info_array->info32 + i; + info.imageLoadAddress = info32->imageLoadAddress; + info.imageFilePath = info32->imageFilePath; + } + if (info.imageFilePath && + ReadProcessMemory(pcs->handle, (void*)info.imageFilePath, bufstr, sizeof(bufstr), NULL)) { bufstr[sizeof(bufstr) - 1] = '\0'; TRACE("[%d] image file %s\n", i, debugstr_a(bufstr)); MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW, ARRAY_SIZE(bufstrW)); if (main_name && !bufstrW[0]) strcpyW(bufstrW, main_name); - if (!cb(bufstrW, (unsigned long)info_array[i].imageLoadAddress, user)) break; + if (!cb(bufstrW, info.imageLoadAddress, user)) break; } } @@ -1764,27 +1804,47 @@ static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_in WCHAR *loader = get_wine_loader_name(pcs); BOOL ret = FALSE; ULONG_PTR dyld_image_info_address; - struct dyld_all_image_infos image_infos; - struct dyld_image_info image_info; + union wine_all_image_infos image_infos; + union wine_image_info image_info; uint32_t len; char path[PATH_MAX]; BOOL got_path = FALSE; + if (pcs->is_64bit) + len = sizeof(image_infos.infos64); + else + len = sizeof(image_infos.infos32); dyld_image_info_address = get_dyld_image_info_address(pcs); if (dyld_image_info_address && - ReadProcessMemory(pcs->handle, (void*)dyld_image_info_address, &image_infos, sizeof(image_infos), NULL) && - image_infos.infoArray && image_infos.infoArrayCount && - ReadProcessMemory(pcs->handle, image_infos.infoArray, &image_info, sizeof(image_info), NULL) && - image_info.imageFilePath) + ReadProcessMemory(pcs->handle, (void*)dyld_image_info_address, &image_infos, len, NULL)) { - for (len = sizeof(path); len > 0; len /= 2) + if (pcs->is_64bit) + len = sizeof(image_info.info64); + else { - if (ReadProcessMemory(pcs->handle, image_info.imageFilePath, path, len, NULL)) + struct dyld_all_image_infos32 temp = image_infos.infos32; + image_infos.infos64.infoArrayCount = temp.infoArrayCount; + image_infos.infos64.infoArray = temp.infoArray; + len = sizeof(image_info.info32); + } + if (image_infos.infos64.infoArray && image_infos.infos64.infoArrayCount && + ReadProcessMemory(pcs->handle, (void*)image_infos.infos64.infoArray, &image_info, len, NULL)) + { + if (!pcs->is_64bit) { - path[len - 1] = 0; - got_path = TRUE; - TRACE("got executable path from target's dyld image info: %s\n", debugstr_a(path)); - break; + struct dyld_image_info32 temp = image_info.info32; + image_info.info64.imageLoadAddress = temp.imageLoadAddress; + image_info.info64.imageFilePath = temp.imageFilePath; + } + for (len = sizeof(path); image_info.info64.imageFilePath && len > 0; len /= 2) + { + if (ReadProcessMemory(pcs->handle, (void*)image_info.info64.imageFilePath, path, len, NULL)) + { + path[len - 1] = 0; + got_path = TRUE; + TRACE("got executable path from target's dyld image info: %s\n", debugstr_a(path)); + break; + } } } } diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 24fb63533e3..0ba2c849dc3 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: 28a25b052d21a9e2e4fc3c7790711b290d44a488 + wine: 4b9defe09a24e77547cde4e8211f701a4984681b
4 years, 8 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
Older →
Jump to page:
1
2
3
4
5
6
7
8
Results per page:
10
25
50
100
200