https://git.reactos.org/?p=reactos.git;a=commitdiff;h=00783527e0c31a767111a24f8bb0c7c1669c19d2

commit 00783527e0c31a767111a24f8bb0c7c1669c19d2
Author:     winesync <[email protected]>
AuthorDate: Fri Sep 11 18:59:48 2020 +0200
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Wed Sep 16 10:35:54 2020 +0200

    [WINESYNC] dbghelp: Don't store entire mach header in image_file_map.
    
    Signed-off-by: Jacek Caban <[email protected]>
    Signed-off-by: Alexandre Julliard <[email protected]>
    
    wine commit id 7254579417f337063734933975b25d21da4d31f3 by Jacek Caban 
<[email protected]>
---
 dll/win32/dbghelp/image_private.h |  5 +++--
 dll/win32/dbghelp/macho_module.c  | 20 +++++++++++---------
 sdk/tools/winesync/dbghelp.cfg    |  2 +-
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/dll/win32/dbghelp/image_private.h 
b/dll/win32/dbghelp/image_private.h
index 5da4c1e113e..6406c2e43e3 100644
--- a/dll/win32/dbghelp/image_private.h
+++ b/dll/win32/dbghelp/image_private.h
@@ -96,10 +96,11 @@ struct image_file_map
             size_t                      segs_start;
             HANDLE                      handle;
             struct image_file_map*      dsym;   /* the debug symbols file 
associated with this one */
+            size_t                      header_size; /* size of real header in 
file */
+            size_t                      commands_size;
+            size_t                      commands_count;
 
 #ifdef HAVE_MACH_O_LOADER_H
-            struct mach_header          mach_header;
-            size_t                      header_size; /* size of real header in 
file */
             const struct load_command*  load_commands;
             const struct uuid_command*  uuid;
 
diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c
index 1e01d84c192..5d3f8615e87 100644
--- a/dll/win32/dbghelp/macho_module.c
+++ b/dll/win32/dbghelp/macho_module.c
@@ -448,7 +448,7 @@ static const struct load_command* 
macho_map_load_commands(struct macho_file_map*
     if (fmap->load_commands == IMAGE_NO_MAP)
     {
         fmap->load_commands = (const struct load_command*) macho_map_range(
-                fmap, fmap->header_size, fmap->mach_header.sizeofcmds, NULL);
+                fmap, fmap->header_size, fmap->commands_size, NULL);
         TRACE("Mapped load commands: %p\n", fmap->load_commands);
     }
 
@@ -466,7 +466,7 @@ static void macho_unmap_load_commands(struct 
macho_file_map* fmap)
     {
         TRACE("Unmapping load commands: %p\n", fmap->load_commands);
         macho_unmap_range(NULL, (const void**)&fmap->load_commands, fmap,
-                    fmap->header_size, fmap->mach_header.sizeofcmds);
+                    fmap->header_size, fmap->commands_size);
     }
 }
 
@@ -504,9 +504,9 @@ static int macho_enum_load_commands(struct image_file_map 
*ifm, unsigned cmd,
 
     if ((lc = macho_map_load_commands(fmap)) == IMAGE_NO_MAP) return -1;
 
-    TRACE("%d total commands\n", fmap->mach_header.ncmds);
+    TRACE("%lu total commands\n", fmap->commands_count);
 
-    for (i = 0; i < fmap->mach_header.ncmds; i++, lc = 
macho_next_load_command(lc))
+    for (i = 0; i < fmap->commands_count; i++, lc = 
macho_next_load_command(lc))
     {
         int result;
 
@@ -683,6 +683,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR 
*filenameW,
 {
     struct macho_file_map* fmap = &ifm->u.macho;
     struct fat_header   fat_header;
+    struct mach_header  mach_header;
     int                 i;
     WCHAR*              filename;
     struct section_info info;
@@ -745,15 +746,16 @@ static BOOL macho_map_file(struct process *pcs, const 
WCHAR *filenameW,
 
     /* Individual architecture (standalone or within a fat file) is in its 
native byte order. */
     SetFilePointer(fmap->handle, fmap->arch_offset, 0, FILE_BEGIN);
-    if (!ReadFile(fmap->handle, &fmap->mach_header, sizeof(fmap->mach_header), 
&bytes_read, NULL)
-        || bytes_read != sizeof(fmap->mach_header))
+    if (!ReadFile(fmap->handle, &mach_header, sizeof(mach_header), 
&bytes_read, NULL)
+        || bytes_read != sizeof(mach_header))
         goto done;
     TRACE("... got possible Mach header\n");
     /* and check for a Mach-O header */
-    if (fmap->mach_header.magic != target_magic ||
-        fmap->mach_header.cputype != target_cpu) goto done;
+    if (mach_header.magic != target_magic || mach_header.cputype != 
target_cpu) goto done;
+    fmap->commands_size = mach_header.sizeofcmds;
+    fmap->commands_count = mach_header.ncmds;
     /* Make sure the file type is one of the ones we expect. */
-    switch (fmap->mach_header.filetype)
+    switch (mach_header.filetype)
     {
         case MH_EXECUTE:
         case MH_DYLIB:
diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg
index a9c29f900c8..504be41c2ab 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: b664ae8e60e08224cdc3025c28a37cb22356aaa4
+  wine: 7254579417f337063734933975b25d21da4d31f3

Reply via email to