https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8d51a38cbcd0d1ed738a09170007f2fd628bd06a

commit 8d51a38cbcd0d1ed738a09170007f2fd628bd06a
Author:     Amine Khaldi <[email protected]>
AuthorDate: Sun Mar 4 23:54:20 2018 +0100
Commit:     Amine Khaldi <[email protected]>
CommitDate: Sun Mar 4 23:54:20 2018 +0100

    [DBGHELP] Sync with Wine Staging 3.3. CORE-14434
---
 dll/win32/dbghelp/CMakeLists.txt    |  4 +--
 dll/win32/dbghelp/coff.c            | 19 ++++++++++++
 dll/win32/dbghelp/cpu_arm.c         |  6 ++++
 dll/win32/dbghelp/cpu_arm64.c       |  8 +++++
 dll/win32/dbghelp/cpu_i386.c        | 15 ++++++----
 dll/win32/dbghelp/cpu_ppc.c         |  6 ++++
 dll/win32/dbghelp/cpu_x86_64.c      |  9 ++++++
 dll/win32/dbghelp/crc32.c           |  5 ++++
 dll/win32/dbghelp/dbghelp.c         | 14 +++++++--
 dll/win32/dbghelp/dbghelp_private.h | 59 ++++++++++---------------------------
 dll/win32/dbghelp/dwarf.c           | 41 +++++++++++++++++++++++++-
 dll/win32/dbghelp/elf_module.c      | 30 +++++++++++++++----
 dll/win32/dbghelp/image.c           |  7 +++++
 dll/win32/dbghelp/macho_module.c    | 34 ++++++++++++++++++---
 dll/win32/dbghelp/minidump.c        | 12 ++++++--
 dll/win32/dbghelp/module.c          | 55 ++++++++++++++++++++--------------
 dll/win32/dbghelp/msc.c             | 24 +++++++++++++--
 dll/win32/dbghelp/path.c            |  8 +++++
 dll/win32/dbghelp/pe_module.c       | 13 ++++++++
 dll/win32/dbghelp/precomp.h         | 39 ++++++++++++++++++++++++
 dll/win32/dbghelp/rosstubs.c        |  4 +++
 dll/win32/dbghelp/rsym.c            |  1 +
 dll/win32/dbghelp/source.c          |  8 +++++
 dll/win32/dbghelp/stabs.c           | 33 ++++++++++++++++++++-
 dll/win32/dbghelp/stack.c           |  7 +++++
 dll/win32/dbghelp/storage.c         |  9 +++++-
 dll/win32/dbghelp/symbol.c          | 16 ++++++++++
 dll/win32/dbghelp/type.c            | 13 ++++++++
 media/doc/README.WINE               |  2 +-
 sdk/include/reactos/wine/mscvpdb.h  |  2 ++
 30 files changed, 411 insertions(+), 92 deletions(-)

diff --git a/dll/win32/dbghelp/CMakeLists.txt b/dll/win32/dbghelp/CMakeLists.txt
index 7b0c3843ac..66229f410a 100644
--- a/dll/win32/dbghelp/CMakeLists.txt
+++ b/dll/win32/dbghelp/CMakeLists.txt
@@ -70,7 +70,7 @@ else()
         storage.c
         symbol.c
         type.c
-        dbghelp_private.h
+        precomp.h
         ${CMAKE_CURRENT_BINARY_DIR}/dbghelp_stubs.c)
 
     add_library(dbghelp SHARED
@@ -82,7 +82,7 @@ else()
     target_link_libraries(dbghelp wine ${PSEH_LIB} oldnames zlib)
     add_delay_importlibs(dbghelp version)
     add_importlibs(dbghelp psapi msvcrt kernel32 ntdll)
-    add_pch(dbghelp dbghelp_private.h SOURCE)
+    add_pch(dbghelp precomp.h SOURCE)
     add_cd_file(TARGET dbghelp DESTINATION reactos/system32 FOR all)
 
 endif()
diff --git a/dll/win32/dbghelp/coff.c b/dll/win32/dbghelp/coff.c
index a9d983eb92..01c5826c7f 100644
--- a/dll/win32/dbghelp/coff.c
+++ b/dll/win32/dbghelp/coff.c
@@ -32,7 +32,26 @@
  *     Add symbol size to internal symbol table.
  */
 
+#include "config.h"
+#include "wine/port.h"
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+#include "winternl.h"
+
+#include "wine/exception.h"
+#include "wine/debug.h"
 #include "dbghelp_private.h"
+#include "wine/mscvpdb.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_coff);
 
diff --git a/dll/win32/dbghelp/cpu_arm.c b/dll/win32/dbghelp/cpu_arm.c
index 5aae67d34c..52461606a8 100644
--- a/dll/win32/dbghelp/cpu_arm.c
+++ b/dll/win32/dbghelp/cpu_arm.c
@@ -19,7 +19,13 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include <assert.h>
+
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
 #include "dbghelp_private.h"
+#include "winternl.h"
+#include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
diff --git a/dll/win32/dbghelp/cpu_arm64.c b/dll/win32/dbghelp/cpu_arm64.c
index a2a0bb4df9..dd2ccfb883 100644
--- a/dll/win32/dbghelp/cpu_arm64.c
+++ b/dll/win32/dbghelp/cpu_arm64.c
@@ -19,7 +19,15 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include <assert.h>
+
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
 #include "dbghelp_private.h"
+#include "winternl.h"
+#include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
diff --git a/dll/win32/dbghelp/cpu_i386.c b/dll/win32/dbghelp/cpu_i386.c
index c713049cf2..592f56edde 100644
--- a/dll/win32/dbghelp/cpu_i386.c
+++ b/dll/win32/dbghelp/cpu_i386.c
@@ -18,10 +18,15 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "dbghelp_private.h"
+#include <assert.h>
 
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
+#include "dbghelp_private.h"
 #ifndef DBGHELP_STATIC_LIB
-#include <wine/winbase16.h>
+#include "wine/winbase16.h"
+#include "winternl.h"
+#include "wine/debug.h"
 #endif
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
@@ -215,16 +220,16 @@ static BOOL i386_stack_walk(struct cpu_stack_walk* csw, 
LPSTACKFRAME64 frame, CO
         /* Init done */
         set_curr_mode((frame->AddrPC.Mode == AddrModeFlat) ? stm_32bit : 
stm_16bit);
 
-        /* cur_switch holds address of WOW32Reserved field in TEB in debuggee
+        /* cur_switch holds address of SystemReserved1[0] field in TEB in 
debuggee
          * address space
          */
         if (NtQueryInformationThread(csw->hThread, ThreadBasicInformation, 
&info,
                                      sizeof(info), NULL) == STATUS_SUCCESS)
         {
-            curr_switch = (DWORD_PTR)info.TebBaseAddress + FIELD_OFFSET(TEB, 
WOW32Reserved);
+            curr_switch = (DWORD_PTR)info.TebBaseAddress + FIELD_OFFSET(TEB, 
SystemReserved1[0]);
             if (!sw_read_mem(csw, curr_switch, &p, sizeof(p)))
             {
-                WARN("Can't read TEB:WOW32Reserved\n");
+                WARN("Can't read TEB:SystemReserved1[0]\n");
                 goto done_err;
             }
             next_switch = p;
diff --git a/dll/win32/dbghelp/cpu_ppc.c b/dll/win32/dbghelp/cpu_ppc.c
index 6c382451a9..a48168594e 100644
--- a/dll/win32/dbghelp/cpu_ppc.c
+++ b/dll/win32/dbghelp/cpu_ppc.c
@@ -18,7 +18,13 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include <assert.h>
+
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
 #include "dbghelp_private.h"
+#include "winternl.h"
+#include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
diff --git a/dll/win32/dbghelp/cpu_x86_64.c b/dll/win32/dbghelp/cpu_x86_64.c
index 5beb6dfab8..aa659fafe0 100644
--- a/dll/win32/dbghelp/cpu_x86_64.c
+++ b/dll/win32/dbghelp/cpu_x86_64.c
@@ -19,7 +19,15 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include <assert.h>
+
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
 #include "dbghelp_private.h"
+#include "winternl.h"
+#include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
@@ -702,6 +710,7 @@ static void*    x86_64_find_runtime_function(struct module* 
module, DWORD64 addr
             while (rtf->UnwindData & 1)  /* follow chained entry */
             {
                 FIXME("RunTime_Function outside 
IMAGE_DIRECTORY_ENTRY_EXCEPTION unimplemented yet!\n");
+                return NULL;
                 /* we need to read into the other process */
                 /* rtf = (RUNTIME_FUNCTION*)(module->module.BaseOfImage + 
(rtf->UnwindData & ~1)); */
             }
diff --git a/dll/win32/dbghelp/crc32.c b/dll/win32/dbghelp/crc32.c
index 64901338bc..73042fefbc 100644
--- a/dll/win32/dbghelp/crc32.c
+++ b/dll/win32/dbghelp/crc32.c
@@ -19,6 +19,11 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdio.h>
+
 #include "dbghelp_private.h"
 
 /* Copyright (C) 1986 Gary S. Brown
diff --git a/dll/win32/dbghelp/dbghelp.c b/dll/win32/dbghelp/dbghelp.c
index 3fa5765a32..6779e9ae98 100644
--- a/dll/win32/dbghelp/dbghelp.c
+++ b/dll/win32/dbghelp/dbghelp.c
@@ -18,9 +18,19 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "dbghelp_private.h"
+#ifndef DBGHELP_STATIC_LIB
+#include "config.h"
 
+#include "dbghelp_private.h"
+#include "winerror.h"
+#include "psapi.h"
+#include "wine/debug.h"
+#include "wdbgexts.h"
+#include "winnls.h"
+#else
+#include "dbghelp_private.h"
 #include "wdbgexts.h"
+#endif
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
@@ -355,7 +365,7 @@ BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR 
UserSearchPath, BOOL fInvadeP
     pcs->dbg_hdr_addr = 0;
     pcs->next = process_first;
     process_first = pcs;
-
+    
 #ifndef DBGHELP_STATIC_LIB
     if (check_live_target(pcs))
     {
diff --git a/dll/win32/dbghelp/dbghelp_private.h 
b/dll/win32/dbghelp/dbghelp_private.h
index d6b2bbe075..9848acb110 100644
--- a/dll/win32/dbghelp/dbghelp_private.h
+++ b/dll/win32/dbghelp/dbghelp_private.h
@@ -21,58 +21,32 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#ifndef _DBGHELP_PRIVATE_H_
-#define _DBGHELP_PRIVATE_H_
+#pragma once
 
-#include <config.h>
-
-#include <assert.h>
-#include <stdio.h>
-
-#ifdef HAVE_SYS_MMAN_H
-# include <sys/mman.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
-
-#define NONAMELESSUNION
-#define NONAMELESSSTRUCT
+#include <stdarg.h>
 
 #ifndef DBGHELP_STATIC_LIB
 
-#include <wine/port.h>
+#include "windef.h"
+#include "winbase.h"
+#include "winver.h"
+#include "dbghelp.h"
+#include "objbase.h"
+#include "oaidl.h"
+#include "winnls.h"
+#include "wine/list.h"
+#include "wine/unicode.h"
+#include "wine/rbtree.h"
 
-#include <ntstatus.h>
-#define WIN32_NO_STATUS
-#include <windef.h>
-#include <winbase.h>
-#include <winver.h>
-#include <winternl.h>
-#include <dbghelp.h>
-#include <objbase.h>
-#include <cvconst.h>
-#include <psapi.h>
-
-#include <wine/debug.h>
-#include <wine/mscvpdb.h>
-#include <wine/unicode.h>
+#include "cvconst.h"
 
 #else /* DBGHELP_STATIC_LIB */
 
 #include <string.h>
 #include "compat.h"
-
-#endif /* DBGHELP_STATIC_LIB */
-
 #include <wine/list.h>
 #include <wine/rbtree.h>
+#endif /* DBGHELP_STATIC_LIB */
 
 /* #define USE_STATS */
 
@@ -401,6 +375,7 @@ struct module
 {
     struct process*             process;
     IMAGEHLP_MODULEW64          module;
+    WCHAR                       modulename[64]; /* used for enumeration */
     struct module*              next;
     enum module_type           type : 16;
     unsigned short              is_virtual : 1;
@@ -844,7 +819,3 @@ extern struct symt_pointer*
 extern struct symt_typedef*
                     symt_new_typedef(struct module* module, struct symt* ref, 
                                      const char* name) DECLSPEC_HIDDEN;
-
-#include "image_private.h"
-
-#endif /* _DBGHELP_PRIVATE_H_ */
diff --git a/dll/win32/dbghelp/dwarf.c b/dll/win32/dbghelp/dwarf.c
index 7b338d1750..0d51792918 100644
--- a/dll/win32/dbghelp/dwarf.c
+++ b/dll/win32/dbghelp/dwarf.c
@@ -20,12 +20,51 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "dbghelp_private.h"
+#ifndef DBGHELP_STATIC_LIB
+
+#define NONAMELESSUNION
+
+#include "config.h"
+
+#include <sys/types.h>
+#include <fcntl.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <stdio.h>
+#include <assert.h>
+#include <stdarg.h>
 
 #ifdef HAVE_ZLIB
 #include <zlib.h>
 #endif
 
+#include "windef.h"
+#include "winternl.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "ole2.h"
+#include "oleauto.h"
+
+#include "dbghelp_private.h"
+#include "image_private.h"
+
+#include "wine/debug.h"
+
+#else
+#include "dbghelp_private.h"
+#include "image_private.h"
+#endif /* !DBGHELP_STATIC_LIB */
+
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_dwarf);
 
 /* FIXME:
diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c
index 2edab86b70..066c2f5166 100644
--- a/dll/win32/dbghelp/elf_module.c
+++ b/dll/win32/dbghelp/elf_module.c
@@ -19,7 +19,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "dbghelp_private.h"
+#include "config.h"
+#include "wine/port.h"
 
 #if defined(__svr4__) || defined(__sun)
 #define __ELF__ 1
@@ -28,10 +29,27 @@
 #define _FILE_OFFSET_BITS 32
 #endif
 
+#include <assert.h>
+#include <stdio.h>
 #include <stdlib.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #include <fcntl.h>
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include "dbghelp_private.h"
+#include "winternl.h"
+
+#include "image_private.h"
 
-#include <wine/library.h>
+#include "wine/library.h"
+#include "wine/debug.h"
 
 #ifdef __ELF__
 
@@ -1471,9 +1489,11 @@ static BOOL elf_search_and_load_file(struct process* 
pcs, const WCHAR* filename,
     if (!ret && !strchrW(filename, '/'))
     {
         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);
+                                      getenv("PATH"), elf_info);
+        if (!ret) ret = elf_load_file_from_path(pcs, filename, load_offset, 
dyn_addr,
+                                                getenv("LD_LIBRARY_PATH"), 
elf_info);
+        if (!ret) ret = elf_load_file_from_path(pcs, filename, load_offset, 
dyn_addr,
+                                                BINDIR, elf_info);
         if (!ret) ret = elf_load_file_from_dll_path(pcs, filename,
                                                     load_offset, dyn_addr, 
elf_info);
     }
diff --git a/dll/win32/dbghelp/image.c b/dll/win32/dbghelp/image.c
index 3420caa961..ef94ef6638 100644
--- a/dll/win32/dbghelp/image.c
+++ b/dll/win32/dbghelp/image.c
@@ -18,7 +18,14 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
 #include "dbghelp_private.h"
+#include "winternl.h"
+#include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c
index cc991a7610..01fa300eff 100644
--- a/dll/win32/dbghelp/macho_module.c
+++ b/dll/win32/dbghelp/macho_module.c
@@ -21,7 +21,37 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+#include "wine/port.h"
+
+#ifdef HAVE_MACH_O_LOADER_H
+#include <CoreFoundation/CFString.h>
+#define LoadResource mac_LoadResource
+#define GetCurrentThread mac_GetCurrentThread
+#include <CoreServices/CoreServices.h>
+#undef LoadResource
+#undef GetCurrentThread
+#undef DPRINTF
+#endif
+
+#include <stdio.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <errno.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_MMAN_H
+# include <sys/mman.h>
+#endif
+
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
 #include "dbghelp_private.h"
+#include "winternl.h"
+#include "wine/library.h"
+#include "wine/debug.h"
+#include "image_private.h"
 
 #ifdef HAVE_MACH_O_LOADER_H
 
@@ -48,10 +78,6 @@ struct dyld_all_image_infos {
 };
 #endif
 
-#include "winternl.h"
-#include "wine/library.h"
-#include "wine/debug.h"
-
 #ifdef WORDS_BIGENDIAN
 #define swap_ulong_be_to_host(n) (n)
 #else
diff --git a/dll/win32/dbghelp/minidump.c b/dll/win32/dbghelp/minidump.c
index e861ccabda..4dead52b92 100644
--- a/dll/win32/dbghelp/minidump.c
+++ b/dll/win32/dbghelp/minidump.c
@@ -18,10 +18,18 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "dbghelp_private.h"
-
 #include <time.h>
 
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
+#include "dbghelp_private.h"
+#include "winternl.h"
+#include "psapi.h"
+#include "wine/debug.h"
+
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
 /******************************************************************
diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c
index c0084ec1c0..0173469bd6 100644
--- a/dll/win32/dbghelp/module.c
+++ b/dll/win32/dbghelp/module.c
@@ -19,7 +19,18 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
 #include "dbghelp_private.h"
+#ifndef DBGHELP_STATIC_LIB
+#include "psapi.h"
+#include "winternl.h"
+#include "wine/debug.h"
+#endif
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
@@ -91,7 +102,9 @@ static void module_fill_module(const WCHAR* in, WCHAR* out, 
size_t size)
 
 void module_set_module(struct module* module, const WCHAR* name)
 {
-    module_fill_module(name, module->module.ModuleName, 
sizeof(module->module.ModuleName));
+    module_fill_module(name, module->module.ModuleName,
+            sizeof(module->module.ModuleName) / 
sizeof(module->module.ModuleName[0]));
+    module_fill_module(name, module->modulename, sizeof(module->modulename) / 
sizeof(module->modulename[0]));
 }
 
 const WCHAR *get_wine_loader_name(void)
@@ -815,7 +828,7 @@ BOOL  WINAPI SymEnumerateModulesW64(HANDLE hProcess,
         if (!(dbghelp_options & SYMOPT_WINE_WITH_NATIVE_MODULES) &&
             (module->type == DMT_ELF || module->type == DMT_MACHO))
             continue;
-        if (!EnumModulesCallback(module->module.ModuleName,
+        if (!EnumModulesCallback(module->modulename,
                                  module->module.BaseOfImage, UserContext))
             break;
     }
@@ -915,7 +928,7 @@ BOOL  WINAPI EnumerateLoadedModulesW64(HANDLE hProcess,
         if (!GetModuleInformation(hProcess, hMods[i], &mi, sizeof(mi)) ||
             !GetModuleBaseNameW(hProcess, hMods[i], baseW, sizeof(baseW) / 
sizeof(WCHAR)))
             continue;
-        module_fill_module(baseW, modW, sizeof(modW) / sizeof(CHAR));
+        module_fill_module(baseW, modW, sizeof(modW) / sizeof(modW[0]));
         EnumLoadedModulesCallback(modW, (DWORD_PTR)mi.lpBaseOfDll, 
mi.SizeOfImage,
                                   UserContext);
     }
@@ -926,6 +939,12 @@ BOOL  WINAPI EnumerateLoadedModulesW64(HANDLE hProcess,
 
 #endif /* DBGHELP_STATIC_LIB */
 
+static void dbghelp_str_WtoA(const WCHAR *src, char *dst, int dst_len)
+{
+    WideCharToMultiByte(CP_ACP, 0, src, -1, dst, dst_len - 1, NULL, NULL);
+    dst[dst_len - 1] = 0;
+}
+
 /******************************************************************
  *             SymGetModuleInfo (DBGHELP.@)
  *
@@ -941,19 +960,16 @@ BOOL  WINAPI SymGetModuleInfo(HANDLE hProcess, DWORD 
dwAddr,
     miw64.SizeOfStruct = sizeof(miw64);
     if (!SymGetModuleInfoW64(hProcess, dwAddr, &miw64)) return FALSE;
 
-    mi.SizeOfStruct  = miw64.SizeOfStruct;
+    mi.SizeOfStruct  = ModuleInfo->SizeOfStruct;
     mi.BaseOfImage   = miw64.BaseOfImage;
     mi.ImageSize     = miw64.ImageSize;
     mi.TimeDateStamp = miw64.TimeDateStamp;
     mi.CheckSum      = miw64.CheckSum;
     mi.NumSyms       = miw64.NumSyms;
     mi.SymType       = miw64.SymType;
-    WideCharToMultiByte(CP_ACP, 0, miw64.ModuleName, -1,
-                        mi.ModuleName, sizeof(mi.ModuleName), NULL, NULL);
-    WideCharToMultiByte(CP_ACP, 0, miw64.ImageName, -1,
-                        mi.ImageName, sizeof(mi.ImageName), NULL, NULL);
-    WideCharToMultiByte(CP_ACP, 0, miw64.LoadedImageName, -1,
-                        mi.LoadedImageName, sizeof(mi.LoadedImageName), NULL, 
NULL);
+    dbghelp_str_WtoA(miw64.ModuleName, mi.ModuleName, sizeof(mi.ModuleName));
+    dbghelp_str_WtoA(miw64.ImageName, mi.ImageName, sizeof(mi.ImageName));
+    dbghelp_str_WtoA(miw64.LoadedImageName, mi.LoadedImageName, 
sizeof(mi.LoadedImageName));
 
     memcpy(ModuleInfo, &mi, ModuleInfo->SizeOfStruct);
 
@@ -975,7 +991,7 @@ BOOL  WINAPI SymGetModuleInfoW(HANDLE hProcess, DWORD 
dwAddr,
     miw64.SizeOfStruct = sizeof(miw64);
     if (!SymGetModuleInfoW64(hProcess, dwAddr, &miw64)) return FALSE;
 
-    miw.SizeOfStruct  = miw64.SizeOfStruct;
+    miw.SizeOfStruct  = ModuleInfo->SizeOfStruct;
     miw.BaseOfImage   = miw64.BaseOfImage;
     miw.ImageSize     = miw64.ImageSize;
     miw.TimeDateStamp = miw64.TimeDateStamp;
@@ -1010,25 +1026,20 @@ BOOL  WINAPI SymGetModuleInfo64(HANDLE hProcess, 
DWORD64 dwAddr,
     miw64.SizeOfStruct = sizeof(miw64);
     if (!SymGetModuleInfoW64(hProcess, dwAddr, &miw64)) return FALSE;
 
-    mi64.SizeOfStruct  = miw64.SizeOfStruct;
+    mi64.SizeOfStruct  = ModuleInfo->SizeOfStruct;
     mi64.BaseOfImage   = miw64.BaseOfImage;
     mi64.ImageSize     = miw64.ImageSize;
     mi64.TimeDateStamp = miw64.TimeDateStamp;
     mi64.CheckSum      = miw64.CheckSum;
     mi64.NumSyms       = miw64.NumSyms;
     mi64.SymType       = miw64.SymType;
-    WideCharToMultiByte(CP_ACP, 0, miw64.ModuleName, -1,
-                        mi64.ModuleName, sizeof(mi64.ModuleName), NULL, NULL);
-    WideCharToMultiByte(CP_ACP, 0, miw64.ImageName, -1,
-                        mi64.ImageName, sizeof(mi64.ImageName), NULL, NULL);
-    WideCharToMultiByte(CP_ACP, 0, miw64.LoadedImageName, -1,
-                        mi64.LoadedImageName, sizeof(mi64.LoadedImageName), 
NULL, NULL);
-    WideCharToMultiByte(CP_ACP, 0, miw64.LoadedPdbName, -1,
-                        mi64.LoadedPdbName, sizeof(mi64.LoadedPdbName), NULL, 
NULL);
+    dbghelp_str_WtoA(miw64.ModuleName, mi64.ModuleName, 
sizeof(mi64.ModuleName));
+    dbghelp_str_WtoA(miw64.ImageName, mi64.ImageName, sizeof(mi64.ImageName));
+    dbghelp_str_WtoA(miw64.LoadedImageName, mi64.LoadedImageName, 
sizeof(mi64.LoadedImageName));
+    dbghelp_str_WtoA(miw64.LoadedPdbName, mi64.LoadedPdbName, 
sizeof(mi64.LoadedPdbName));
 
     mi64.CVSig         = miw64.CVSig;
-    WideCharToMultiByte(CP_ACP, 0, miw64.CVData, -1,
-                        mi64.CVData, sizeof(mi64.CVData), NULL, NULL);
+    dbghelp_str_WtoA(miw64.CVData, mi64.CVData, sizeof(mi64.CVData));
     mi64.PdbSig        = miw64.PdbSig;
     mi64.PdbSig70      = miw64.PdbSig70;
     mi64.PdbAge        = miw64.PdbAge;
diff --git a/dll/win32/dbghelp/msc.c b/dll/win32/dbghelp/msc.c
index 8fe509b59a..eba26498cb 100644
--- a/dll/win32/dbghelp/msc.c
+++ b/dll/win32/dbghelp/msc.c
@@ -32,9 +32,29 @@
  *     Add symbol size to internal symbol table.
  */
 
-#include "dbghelp_private.h"
+#define NONAMELESSUNION
+
+#include "config.h"
+#include "wine/port.h"
 
-#include <wine/exception.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+#include "winternl.h"
+
+#include "wine/exception.h"
+#include "wine/debug.h"
+#include "dbghelp_private.h"
+#include "wine/mscvpdb.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_msc);
 
diff --git a/dll/win32/dbghelp/path.c b/dll/win32/dbghelp/path.c
index bd4893b6d3..8c74426eec 100644
--- a/dll/win32/dbghelp/path.c
+++ b/dll/win32/dbghelp/path.c
@@ -18,7 +18,15 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
 #include "dbghelp_private.h"
+#include "winnls.h"
+#include "winternl.h"
+#include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
diff --git a/dll/win32/dbghelp/pe_module.c b/dll/win32/dbghelp/pe_module.c
index dac94bb907..b629213d76 100644
--- a/dll/win32/dbghelp/pe_module.c
+++ b/dll/win32/dbghelp/pe_module.c
@@ -21,7 +21,20 @@
  *
  */
 
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
 #include "dbghelp_private.h"
+#include "image_private.h"
+#ifndef DBGHELP_STATIC_LIB
+#include "winternl.h"
+#include "wine/debug.h"
+#endif
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
diff --git a/dll/win32/dbghelp/precomp.h b/dll/win32/dbghelp/precomp.h
new file mode 100644
index 0000000000..e359f21aca
--- /dev/null
+++ b/dll/win32/dbghelp/precomp.h
@@ -0,0 +1,39 @@
+
+#ifndef _DBGHELP_PRECOMP_H_
+#define _DBGHELP_PRECOMP_H_
+
+#include <wine/config.h>
+#include <wine/port.h>
+
+#include <assert.h>
+#include <stdio.h>
+
+#ifdef HAVE_SYS_MMAN_H
+# include <sys/mman.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+
+#include <ntstatus.h>
+#define WIN32_NO_STATUS
+
+#include "dbghelp_private.h"
+
+#include <winternl.h>
+#include <psapi.h>
+#include <wine/debug.h>
+#include <wine/mscvpdb.h>
+
+#include "image_private.h"
+
+#endif /* !_DBGHELP_PRECOMP_H_ */
diff --git a/dll/win32/dbghelp/rosstubs.c b/dll/win32/dbghelp/rosstubs.c
index 85bd67ff73..7ac6026aea 100644
--- a/dll/win32/dbghelp/rosstubs.c
+++ b/dll/win32/dbghelp/rosstubs.c
@@ -18,8 +18,12 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include <assert.h>
+
 #include "dbghelp_private.h"
+#include "image_private.h"
 
+#include <wine/debug.h>
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
 #define PDBGHELP_CREATE_USER_DUMP_CALLBACK PVOID
diff --git a/dll/win32/dbghelp/rsym.c b/dll/win32/dbghelp/rsym.c
index 05c27250e0..9b7bf4ee1d 100644
--- a/dll/win32/dbghelp/rsym.c
+++ b/dll/win32/dbghelp/rsym.c
@@ -8,6 +8,7 @@
 #include "dbghelp_private.h"
 #include <reactos/rossym.h>
 
+#include <wine/debug.h>
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_rsym);
 
 
diff --git a/dll/win32/dbghelp/source.c b/dll/win32/dbghelp/source.c
index 29123e1280..e98f780b16 100644
--- a/dll/win32/dbghelp/source.c
+++ b/dll/win32/dbghelp/source.c
@@ -18,8 +18,16 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  *
  */
+#include "config.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
 
 #include "dbghelp_private.h"
+#ifndef DBGHELP_STATIC_LIB
+#include "wine/debug.h"
+#endif
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
diff --git a/dll/win32/dbghelp/stabs.c b/dll/win32/dbghelp/stabs.c
index faa9f47985..1ec0065bb7 100644
--- a/dll/win32/dbghelp/stabs.c
+++ b/dll/win32/dbghelp/stabs.c
@@ -29,12 +29,43 @@
  *     available (hopefully) from http://sources.redhat.com/gdb/onlinedocs
  */
 
-#include "dbghelp_private.h"
+#include "config.h"
+#include "wine/port.h"
+
+#include <sys/types.h>
+#include <fcntl.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <stdio.h>
+#include <assert.h>
+#include <stdarg.h>
 
 #ifdef HAVE_MACH_O_NLIST_H
 # include <mach-o/nlist.h>
 #endif
 
+#ifndef DBGHELP_STATIC_LIB
+#include "windef.h"
+#include "winbase.h"
+#include "winnls.h"
+#endif
+
+#include "dbghelp_private.h"
+
+#ifndef DBGHELP_STATIC_LIB
+#include "wine/debug.h"
+#endif
+
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_stabs);
 
 #ifndef DBGHELP_STATIC_LIB
diff --git a/dll/win32/dbghelp/stack.c b/dll/win32/dbghelp/stack.c
index ffb4b31858..21412f6051 100644
--- a/dll/win32/dbghelp/stack.c
+++ b/dll/win32/dbghelp/stack.c
@@ -21,7 +21,14 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
 #include "dbghelp_private.h"
+#include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
diff --git a/dll/win32/dbghelp/storage.c b/dll/win32/dbghelp/storage.c
index 32e80d46ef..7750ce6467 100644
--- a/dll/win32/dbghelp/storage.c
+++ b/dll/win32/dbghelp/storage.c
@@ -19,8 +19,15 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "dbghelp_private.h"
 
+#include "config.h"
+#include <assert.h>
+#include <stdlib.h>
+#ifndef DBGHELP_STATIC_LIB
+#include "wine/debug.h"
+#endif
+
+#include "dbghelp_private.h"
 #ifdef USE_STATS
 #include <math.h>
 #endif
diff --git a/dll/win32/dbghelp/symbol.c b/dll/win32/dbghelp/symbol.c
index 9efb474e42..633aa45d31 100644
--- a/dll/win32/dbghelp/symbol.c
+++ b/dll/win32/dbghelp/symbol.c
@@ -19,7 +19,23 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#define NONAMELESSUNION
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <sys/types.h>
+#include <assert.h>
+#ifndef DBGHELP_STATIC_LIB
+#include "wine/debug.h"
+#endif
 #include "dbghelp_private.h"
+#ifndef DBGHELP_STATIC_LIB
+#include "winnls.h"
+#endif
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 WINE_DECLARE_DEBUG_CHANNEL(dbghelp_symt);
diff --git a/dll/win32/dbghelp/type.c b/dll/win32/dbghelp/type.c
index d55332ebf2..e069231b28 100644
--- a/dll/win32/dbghelp/type.c
+++ b/dll/win32/dbghelp/type.c
@@ -22,6 +22,19 @@
  * upon which full support for datatype handling will eventually be built.
  */
 
+#define NONAMELESSUNION
+
+#include "config.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#ifndef DBGHELP_STATIC_LIB
+#include "windef.h"
+#include "winbase.h"
+#include "winnls.h"
+#include "wine/debug.h"
+#endif
 #include "dbghelp_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
diff --git a/media/doc/README.WINE b/media/doc/README.WINE
index ef3c0456d4..24c72fb703 100644
--- a/media/doc/README.WINE
+++ b/media/doc/README.WINE
@@ -63,7 +63,7 @@ reactos/dll/win32/cryptdlg            # Synced to 
WineStaging-2.9
 reactos/dll/win32/cryptdll            # Synced to WineStaging-2.9
 reactos/dll/win32/cryptnet            # Synced to WineStaging-2.9
 reactos/dll/win32/cryptui             # Synced to WineStaging-2.16
-reactos/dll/win32/dbghelp             # Synced to Wine-3.0
+reactos/dll/win32/dbghelp             # Synced to WineStaging-3.3
 reactos/dll/win32/dciman32            # Synced to WineStaging-2.9
 reactos/dll/win32/faultrep            # Synced to WineStaging-2.9
 reactos/dll/win32/fontsub             # Synced to WineStaging-2.9
diff --git a/sdk/include/reactos/wine/mscvpdb.h 
b/sdk/include/reactos/wine/mscvpdb.h
index 2f0b47998f..744c17faba 100644
--- a/sdk/include/reactos/wine/mscvpdb.h
+++ b/sdk/include/reactos/wine/mscvpdb.h
@@ -96,6 +96,8 @@
  * types, they are not completely linked together.
  */
 
+#pragma once
+
 #include "pshpack1.h"
 
 /* ======================================== *

Reply via email to