ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
September 2020
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
25 participants
382 discussions
Start a n
N
ew thread
[reactos] 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, 3 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, 3 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, 3 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, 3 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, 3 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, 3 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, 3 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, 3 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, 3 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, 3 months
1
0
0
0
← Newer
1
...
15
16
17
18
19
20
21
...
39
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Results per page:
10
25
50
100
200