[PATCH v3 0/1] MR3382: winebuild: Zero space between Wine signature and PE header in "builtin" files.
Signed-off-by: Konstantin Demin <rockdrilla(a)gmail.com> -- v3: winebuild: Zero space between Wine signature and PE header in "builtin" files. https://gitlab.winehq.org/wine/wine/-/merge_requests/3382
From: Konstantin Demin <rockdrilla(a)gmail.com> Signed-off-by: Konstantin Demin <rockdrilla(a)gmail.com> --- tools/winebuild/spec32.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index 6e4131bd910..74ebde37e20 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -1360,7 +1360,11 @@ void output_def_file( DLLSPEC *spec, int import_only ) */ void make_builtin_files( struct strarray files ) { - int i, fd; + int i, fd, n, k; + unsigned int pos; + unsigned short dll_charact; + unsigned char pad[32]; + struct { unsigned short e_magic; @@ -1368,6 +1372,7 @@ void make_builtin_files( struct strarray files ) unsigned int e_lfanew; } header; + memset( pad, 0, sizeof(pad) ); for (i = 0; i < files.count; i++) { if ((fd = open( files.str[i], O_RDWR | O_BINARY )) == -1) @@ -1378,10 +1383,20 @@ void make_builtin_files( struct strarray files ) fatal_error( "%s: Not enough space (%x) for Wine signature\n", files.str[i], header.e_lfanew ); write( fd, builtin_signature, sizeof(builtin_signature) ); + /* zero remaining space between Wine signature and PE header */ + n = (int) header.e_lfanew - (int) (sizeof(header) + sizeof(builtin_signature)); + if (n > 0) + { + for (k = n / sizeof(pad); k; k--) + write( fd, &pad, sizeof(pad) ); + + if ((k = n % sizeof(pad))) + write( fd, &pad, k ); + } + if (prefer_native) { - unsigned int pos = header.e_lfanew + 0x5e; /* OptionalHeader.DllCharacteristics */ - unsigned short dll_charact; + pos = header.e_lfanew + 0x5e; /* OptionalHeader.DllCharacteristics */ lseek( fd, pos, SEEK_SET ); if (read( fd, &dll_charact, sizeof(dll_charact) ) == sizeof(dll_charact)) { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3382
Please explain why this is necessary. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3382#note_39923
This is mostly cosmetic change to wipe remaining "garbage" after Wine builtin signature and before PE header. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3382#note_39928
That doesn't seem necessary. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3382#note_39929
Another try: current code is not ISO C90 compliant. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3382#note_39984
Another try: current code is not ISO C90 compliant.
If you mean the variable declarations, it's perfectly compliant. Please don't change things without a good reason. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3382#note_40024
This merge request was closed by Alexandre Julliard. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3382
participants (3)
-
Alexandre Julliard (@julliard) -
Konstantin Demin -
Konstantin Demin (@rockdrilla)