From 968a9068f4d5423af95cd99f9273d0a39340e55c Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Sat, 25 May 2019 15:17:50 -0500 Subject: [PATCH] winebuild-Fake_Dlls: Also change fake DLL syscall thunks. Thanks to Andrew Wesie. --- ...uild-Add-syscall-thunks-in-fake-dlls.patch | 24 ++++++++----------- ...ebuild-Add-syscall-thunks-for-64-bit.patch | 21 +++++++++++----- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/patches/winebuild-Fake_Dlls/0006-winebuild-Add-syscall-thunks-in-fake-dlls.patch b/patches/winebuild-Fake_Dlls/0006-winebuild-Add-syscall-thunks-in-fake-dlls.patch index 777a2552..21421fd3 100644 --- a/patches/winebuild-Fake_Dlls/0006-winebuild-Add-syscall-thunks-in-fake-dlls.patch +++ b/patches/winebuild-Fake_Dlls/0006-winebuild-Add-syscall-thunks-in-fake-dlls.patch @@ -1,18 +1,18 @@ -From b58ac41eb56c6e1e0eef8ecfa0d3faeede91ea11 Mon Sep 17 00:00:00 2001 +From 4e2ff25e0e50d37975ec152bcc40fa130ff130b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Mon, 15 May 2017 17:56:48 +0200 -Subject: winebuild: Add syscall thunks in fake dlls. +Subject: [PATCH] winebuild: Add syscall thunks in fake dlls. --- dlls/kernel32/tests/loader.c | 1 - - tools/winebuild/spec32.c | 31 +++++++++++++++++++++++++++++-- - 2 files changed, 29 insertions(+), 3 deletions(-) + tools/winebuild/spec32.c | 27 +++++++++++++++++++++++++-- + 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c -index cfbee0851b5..a8f9e1f12d3 100644 +index cf4920ec0..e05a81fac 100644 --- a/dlls/kernel32/tests/loader.c +++ b/dlls/kernel32/tests/loader.c -@@ -898,7 +898,6 @@ static void test_FakeDLL(void) +@@ -1592,7 +1592,6 @@ static void test_FakeDLL(void) /* check function content */ map_func = RVAToAddr(map_rva, ptr); @@ -21,10 +21,10 @@ index cfbee0851b5..a8f9e1f12d3 100644 if (!strcmp(func_name, "NtSetEvent")) diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c -index 4367b03b0d2..5a245b5ae81 100644 +index 3caadf78c..c1ace3d32 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c -@@ -718,13 +718,40 @@ static void create_stub_exports_text( DLLSPEC *spec ) +@@ -863,13 +863,36 @@ static void create_stub_exports_text( DLLSPEC *spec ) int i, nr_exports = spec->base <= spec->limit ? spec->limit - spec->base + 1 : 0; size_t rva, thunk; @@ -36,12 +36,8 @@ index 4367b03b0d2..5a245b5ae81 100644 + align_output_rva( 16, 16 ); + put_label( odp->link_name ); + put_byte( 0xb8 ); put_dword( i ); /* mov eax, SYSCALL */ -+ put_byte( 0x33 ); put_byte( 0xc9 ); /* xor ecx, ecx */ -+ put_byte( 0x8d ); put_byte( 0x54 ); /* lea edx, [esp + 4] */ -+ put_byte( 0x24 ); put_byte( 0x04 ); + put_byte( 0x64 ); put_byte( 0xff ); /* call dword ptr fs:[0C0h] */ + put_byte( 0x15 ); put_dword( 0xc0 ); -+ put_byte( 0x83 ); put_byte( 0xc4 ); put_byte( 0x04 ); /* add esp, 4 */ + put_byte( 0xc2 ); put_word( get_args_size(odp) ); /* ret X */ + } + @@ -66,7 +62,7 @@ index 4367b03b0d2..5a245b5ae81 100644 put_label( name ); put_byte( 0x8b ); put_byte( 0xff ); /* mov edi, edi */ put_byte( 0x55 ); /* push ebp */ -@@ -815,7 +842,7 @@ static void create_stub_exports_text( DLLSPEC *spec ) +@@ -960,7 +983,7 @@ static void create_stub_exports_text( DLLSPEC *spec ) ORDDEF *odp = spec->ordinals[i]; if (odp) { @@ -76,5 +72,5 @@ index 4367b03b0d2..5a245b5ae81 100644 } else -- -2.12.2 +2.21.0 diff --git a/patches/winebuild-Fake_Dlls/0010-tools-winebuild-Add-syscall-thunks-for-64-bit.patch b/patches/winebuild-Fake_Dlls/0010-tools-winebuild-Add-syscall-thunks-for-64-bit.patch index 33fbe883..f2c1c71b 100644 --- a/patches/winebuild-Fake_Dlls/0010-tools-winebuild-Add-syscall-thunks-for-64-bit.patch +++ b/patches/winebuild-Fake_Dlls/0010-tools-winebuild-Add-syscall-thunks-for-64-bit.patch @@ -1,4 +1,4 @@ -From 0271fdb03e27e20d21305fcc263e588fc2ecb2a5 Mon Sep 17 00:00:00 2001 +From 53e0dc2abac3e34db45b1e491cc508e4bf655261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 7 Sep 2017 00:38:09 +0200 Subject: [PATCH] tools/winebuild: Add syscall thunks for 64 bit. @@ -9,8 +9,8 @@ Subject: [PATCH] tools/winebuild: Add syscall thunks for 64 bit. dlls/ntdll/thread.c | 10 ++ libs/wine/loader.c | 4 + tools/winebuild/parser.c | 2 +- - tools/winebuild/spec32.c | 221 ++++++++++++++++++++++++++++++++++- - 6 files changed, 239 insertions(+), 8 deletions(-) + tools/winebuild/spec32.c | 230 ++++++++++++++++++++++++++++++++++- + 6 files changed, 248 insertions(+), 8 deletions(-) diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c index d9b349408..6f9673286 100644 @@ -118,7 +118,7 @@ index da832de0e..a09b9954b 100644 if (odp->flags & (FLAG_FORWARD | FLAG_REGISTER)) return 0; diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c -index 5be9f4088..358431efb 100644 +index 997ab9963..c065c5703 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -372,11 +372,11 @@ static void output_relay_debug( DLLSPEC *spec ) @@ -268,7 +268,7 @@ index 5be9f4088..358431efb 100644 { int i, nr_exports = spec->base <= spec->limit ? spec->limit - spec->base + 1 : 0; size_t rva, thunk; -@@ -1033,6 +1132,113 @@ static void create_stub_exports_text( DLLSPEC *spec ) +@@ -1029,6 +1128,122 @@ static void create_stub_exports_text( DLLSPEC *spec ) } @@ -283,7 +283,16 @@ index 5be9f4088..358431efb 100644 + + align_output_rva( 16, 16 ); + put_label( odp->link_name ); ++ put_byte( 0x4c ); put_byte( 0x8b ); put_byte( 0xd1 ); /* mov r10, rcx */ + put_byte( 0xb8 ); put_dword( i ); /* mov eax, SYSCALL */ ++ put_byte( 0xf6 ); put_byte( 0x04 ); put_byte( 0x25 ); /* test byte ptr [0x7ffe0308], 1 */ ++ put_byte( 0x08 ); put_byte( 0x03 ); put_byte( 0xfe ); ++ put_byte( 0x7f ); put_byte( 0x01 ); ++ put_byte( 0x75 ); put_byte( 0x03 ); /* jne */ ++ put_byte( 0x0f ); put_byte( 0x05 ); /* syscall */ ++ put_byte( 0xc3 ); /* ret */ ++ put_byte( 0xeb ); put_byte( 0x01 ); /* jmp */ ++ put_byte( 0xc3 ); /* ret */ + if (target_platform == PLATFORM_APPLE) + { + put_byte( 0xff ); put_byte( 0x14 ); /* call [0x7ffe1000] */ @@ -382,7 +391,7 @@ index 5be9f4088..358431efb 100644 static void create_stub_exports_data( DLLSPEC *spec ) { int i; -@@ -1232,7 +1438,10 @@ static void output_fake_module_pass( DLLSPEC *spec ) +@@ -1228,7 +1443,10 @@ static void output_fake_module_pass( DLLSPEC *spec ) if (needs_stub_exports( spec )) { put_label( "text_start" );