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] 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, 3 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, 3 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, 3 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, 3 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, 3 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, 3 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, 3 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, 3 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, 3 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, 3 months
1
0
0
0
← Newer
1
...
16
17
18
19
20
21
22
...
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