Alexandre Julliard : winegcc: Add option to put a builtin dll signature in the DOS header of PE files.

Alexandre Julliard julliard at winehq.org
Mon Apr 22 16:30:38 CDT 2019


Module: wine
Branch: master
Commit: 11ee7a7051e86395e3697491f8fed345ac4b6940
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=11ee7a7051e86395e3697491f8fed345ac4b6940

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Apr 22 11:34:14 2019 +0200

winegcc: Add option to put a builtin dll signature in the DOS header of PE files.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 tools/winegcc/winegcc.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
index 674d1a3..46b67ce 100644
--- a/tools/winegcc/winegcc.c
+++ b/tools/winegcc/winegcc.c
@@ -205,6 +205,7 @@ struct options
     int compile_only;
     int force_pointer_size;
     int large_address_aware;
+    int wine_builtin;
     int unwind_tables;
     int strip;
     const char* wine_objdir;
@@ -515,6 +516,28 @@ static int check_platform( struct options *opts, const char *file )
     return ret;
 }
 
+static void make_wine_builtin( const char *file )
+{
+    static const char wine_magic[32] = "Wine builtin DLL";
+    int fd;
+    struct
+    {
+        unsigned short e_magic;
+        unsigned short unused[29];
+        unsigned int   e_lfanew;
+    } header;
+
+    if ((fd = open( file, O_RDWR | O_BINARY )) == -1) error( "Failed to add signature to %s\n", file );
+
+    if (read( fd, &header, sizeof(header) ) == sizeof(header) && !memcmp( &header.e_magic, "MZ", 2 ))
+    {
+        if (header.e_lfanew < sizeof(header) + sizeof(wine_magic))
+            error( "Not enough space (%x) for Wine signature\n", header.e_lfanew );
+        write( fd, wine_magic, sizeof(wine_magic) );
+    }
+    close( fd );
+}
+
 static const char *get_multiarch_dir( enum target_cpu cpu )
 {
    switch(cpu)
@@ -1131,6 +1154,8 @@ static void build(struct options* opts)
     spawn(opts->prefix, link_args, 0);
     strarray_free (link_args);
 
+    if (is_pe && opts->wine_builtin) make_wine_builtin( output_path );
+
     /* set the base address with prelink if linker support is not present */
     if (opts->prelink && !opts->target)
     {
@@ -1549,6 +1574,11 @@ int main(int argc, char **argv)
                                 opts.large_address_aware = 1;
                                 continue;
                             }
+                            if (!strcmp(Wl->base[j], "--wine-builtin"))
+                            {
+                                opts.wine_builtin = 1;
+                                continue;
+                            }
                             if (!strcmp(Wl->base[j], "--subsystem") && j < Wl->size - 1)
                             {
                                 opts.subsystem = strdup( Wl->base[++j] );




More information about the wine-cvs mailing list