From ca73dc62cd617617642d512aaf7775fe7551c197 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Fri, 1 May 2020 14:18:09 +0300 Subject: [PATCH] Updated winebuild-Fake_Dlls, ntdll-Syscall_Emulation patchsets. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49065 --- ...dll-Support-x86_64-syscall-emulation.patch | 38 +++--- ...-tests-Add-basic-tests-for-fake-dlls.patch | 12 +- ...-not-abuse-WOW32Reserved-field-for-1.patch | 128 +++++++++--------- ...ate-syscall-thunks-for-ntdll-exports.patch | 12 +- ...ltipass-label-system-to-generate-fak.patch | 40 +++--- ...uild-Add-stub-functions-in-fake-dlls.patch | 10 +- ...uild-Add-syscall-thunks-in-fake-dlls.patch | 14 +- ...ze-of-relocation-information-in-fake.patch | 10 +- ...-make-sure-RVA-matches-between-fake-.patch | 20 +-- ...me-file-alignment-for-fake-and-built.patch | 12 +- ...ebuild-Add-syscall-thunks-for-64-bit.patch | 38 +++--- ...all-NtOpenFile-through-syscall-thunk.patch | 28 ++-- 12 files changed, 178 insertions(+), 184 deletions(-) diff --git a/patches/ntdll-Syscall_Emulation/0001-ntdll-Support-x86_64-syscall-emulation.patch b/patches/ntdll-Syscall_Emulation/0001-ntdll-Support-x86_64-syscall-emulation.patch index dbb40f85..e5318f29 100644 --- a/patches/ntdll-Syscall_Emulation/0001-ntdll-Support-x86_64-syscall-emulation.patch +++ b/patches/ntdll-Syscall_Emulation/0001-ntdll-Support-x86_64-syscall-emulation.patch @@ -1,4 +1,4 @@ -From e193e84b7fb97f6f734b19d5bf2feb403d832abe Mon Sep 17 00:00:00 2001 +From e285d01056bb6df332fa2c22569efbf44ee97399 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Mon, 30 Dec 2019 13:27:53 +0300 Subject: [PATCH] ntdll: Support x86_64 syscall emulation. @@ -10,12 +10,12 @@ get the number from syscall thunks). Linux specific Seccomp is used for trapping syscalls. --- configure.ac | 1 + - dlls/ntdll/signal_x86_64.c | 109 +++++++++++++++++++++++++++++++++++++ - tools/winebuild/spec32.c | 9 ++- - 3 files changed, 117 insertions(+), 2 deletions(-) + dlls/ntdll/signal_x86_64.c | 105 +++++++++++++++++++++++++++++++++++++ + tools/winebuild/spec32.c | 9 +++- + 3 files changed, 113 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac -index e6245d8163f..485219e23b3 100644 +index b32bc818741..c681379e736 100644 --- a/configure.ac +++ b/configure.ac @@ -474,6 +474,7 @@ AC_CHECK_HEADERS(\ @@ -27,7 +27,7 @@ index e6245d8163f..485219e23b3 100644 linux/types.h \ linux/ucdrom.h \ diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c -index 26d688c3abe..87c5a99a65e 100644 +index 3a2f959c5e0..5205f8045c9 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -24,6 +24,7 @@ @@ -52,7 +52,7 @@ index 26d688c3abe..87c5a99a65e 100644 #define NONAMELESSUNION #define NONAMELESSSTRUCT #include "ntstatus.h" -@@ -3096,6 +3104,38 @@ static void usr1_handler( int signal, siginfo_t *siginfo, void *ucontext ) +@@ -3118,6 +3126,34 @@ static void usr1_handler( int signal, siginfo_t *siginfo, void *ucontext ) restore_context( &context, ucontext ); } @@ -78,11 +78,7 @@ index 26d688c3abe..87c5a99a65e 100644 + rsp = (void ***)&ctx->uc_mcontext.gregs[REG_RSP]; + *rsp -= 1; + -+#ifdef __APPLE__ -+ thunk_ret_offset = 0xb; -+#else -+ thunk_ret_offset = 0xc; -+#endif ++ thunk_ret_offset = 0x14; + + **rsp = (void *)(ctx->uc_mcontext.gregs[REG_RIP] + thunk_ret_offset); + ctx->uc_mcontext.gregs[REG_RIP] = (ULONG64)__wine_syscall_dispatcher; @@ -91,7 +87,7 @@ index 26d688c3abe..87c5a99a65e 100644 /*********************************************************************** * __wine_set_signal_handler (NTDLL.@) -@@ -3266,6 +3306,72 @@ void signal_init_thread( TEB *teb ) +@@ -3271,6 +3307,72 @@ void signal_init_thread( TEB *teb ) #endif } @@ -164,7 +160,7 @@ index 26d688c3abe..87c5a99a65e 100644 /********************************************************************** * signal_init_process */ -@@ -3298,6 +3404,9 @@ void signal_init_process(void) +@@ -3303,6 +3405,9 @@ void signal_init_process(void) sig_act.sa_sigaction = trap_handler; if (sigaction( SIGTRAP, &sig_act, NULL ) == -1) goto error; #endif @@ -175,7 +171,7 @@ index 26d688c3abe..87c5a99a65e 100644 error: diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c -index 9cc4698d0d7..c572fe49923 100644 +index 753108f61e4..ab6bde3b10d 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -531,7 +531,7 @@ static void output_syscall_thunks_x64( DLLSPEC *spec ) @@ -187,7 +183,7 @@ index 9cc4698d0d7..c572fe49923 100644 output( "\t.byte 0xf6,0x04,0x25,0x08,0x03,0xfe,0x7f,0x01\n" ); /* test byte ptr [0x7ffe0308], 1 */ output( "\t.byte 0x75,0x03\n" ); /* jne (over syscall) */ output( "\t.byte 0x0f,0x05\n" ); /* syscall */ -@@ -576,6 +576,9 @@ static void output_syscall_thunks_x64( DLLSPEC *spec ) +@@ -568,6 +568,9 @@ static void output_syscall_thunks_x64( DLLSPEC *spec ) output( "\t.byte %d\n", max(get_args_size(odp), 32) - 32 ); } @@ -197,16 +193,16 @@ index 9cc4698d0d7..c572fe49923 100644 output( "\n/* syscall dispatcher */\n\n" ); output( "\t.text\n" ); output( "\t.align %d\n", get_alignment(16) ); -@@ -601,6 +604,8 @@ static void output_syscall_thunks_x64( DLLSPEC *spec ) - else - output( "\tsubq $0xc,0x8(%%rbp)\n" ); +@@ -590,6 +593,8 @@ static void output_syscall_thunks_x64( DLLSPEC *spec ) + * depends on us returning to it. Adjust the return address accordingly. */ + output( "\tsubq $0x14,0x8(%%rbp)\n" ); + output( "\tsub $0xf000,%%rax\n" ); + /* copy over any arguments on the stack */ output( "\tleaq 0x38(%%rbp),%%rsi\n" ); if (UsePIC) -@@ -1192,7 +1197,7 @@ static void create_stub_exports_text_x64( DLLSPEC *spec ) +@@ -1181,7 +1186,7 @@ static void create_stub_exports_text_x64( DLLSPEC *spec ) align_output_rva( 16, 16 ); put_label( odp->link_name ); put_byte( 0x4c ); put_byte( 0x8b ); put_byte( 0xd1 ); /* mov r10, rcx */ @@ -216,5 +212,5 @@ index 9cc4698d0d7..c572fe49923 100644 put_byte( 0x08 ); put_byte( 0x03 ); put_byte( 0xfe ); put_byte( 0x7f ); put_byte( 0x01 ); -- -2.25.3 +2.26.2 diff --git a/patches/winebuild-Fake_Dlls/0001-kernel32-tests-Add-basic-tests-for-fake-dlls.patch b/patches/winebuild-Fake_Dlls/0001-kernel32-tests-Add-basic-tests-for-fake-dlls.patch index faeef5ee..facb88bb 100644 --- a/patches/winebuild-Fake_Dlls/0001-kernel32-tests-Add-basic-tests-for-fake-dlls.patch +++ b/patches/winebuild-Fake_Dlls/0001-kernel32-tests-Add-basic-tests-for-fake-dlls.patch @@ -1,17 +1,17 @@ -From 1d5ed7be366c36c9ca16a8783e4fb7dfc7e9bc73 Mon Sep 17 00:00:00 2001 +From df9a52ad2d92cbdd53101072cc188c2473cb6688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 25 May 2017 07:02:46 +0200 Subject: [PATCH] kernel32/tests: Add basic tests for fake dlls. --- - dlls/kernel32/tests/loader.c | 91 ++++++++++++++++++++++++++++++++++++++++++++ + dlls/kernel32/tests/loader.c | 91 ++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c -index 1e3b00e..cb5b8ed 100644 +index 5474d543248..4e7a15970cb 100644 --- a/dlls/kernel32/tests/loader.c +++ b/dlls/kernel32/tests/loader.c -@@ -1564,6 +1564,96 @@ static void test_filenames(void) +@@ -1535,6 +1535,96 @@ static void test_filenames(void) DeleteFileA( long_path ); } @@ -108,7 +108,7 @@ index 1e3b00e..cb5b8ed 100644 /* Verify linking style of import descriptors */ static void test_ImportDescriptors(void) { -@@ -3978,6 +4068,7 @@ START_TEST(loader) +@@ -3997,6 +4087,7 @@ START_TEST(loader) return; } @@ -117,5 +117,5 @@ index 1e3b00e..cb5b8ed 100644 test_ResolveDelayLoadedAPI(); test_ImportDescriptors(); -- -1.9.1 +2.26.2 diff --git a/patches/winebuild-Fake_Dlls/0002-krnl386.exe16-Do-not-abuse-WOW32Reserved-field-for-1.patch b/patches/winebuild-Fake_Dlls/0002-krnl386.exe16-Do-not-abuse-WOW32Reserved-field-for-1.patch index 7e149c62..11d7bdfb 100644 --- a/patches/winebuild-Fake_Dlls/0002-krnl386.exe16-Do-not-abuse-WOW32Reserved-field-for-1.patch +++ b/patches/winebuild-Fake_Dlls/0002-krnl386.exe16-Do-not-abuse-WOW32Reserved-field-for-1.patch @@ -1,4 +1,4 @@ -From 7d097bf5d20c03203d455501bb04151c3faf3dcb Mon Sep 17 00:00:00 2001 +From bbd53428eeb36e95e73c79d37bc8f846f42f3bd6 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Tue, 16 May 2017 04:37:52 +0200 Subject: [PATCH] krnl386.exe16: Do not abuse WOW32Reserved field for 16-bit @@ -24,7 +24,7 @@ Subject: [PATCH] krnl386.exe16: Do not abuse WOW32Reserved field for 16-bit 16 files changed, 78 insertions(+), 77 deletions(-) diff --git a/dlls/dbghelp/cpu_i386.c b/dlls/dbghelp/cpu_i386.c -index 9704cfda538..7a3e08a999e 100644 +index fd808a0d324..7d6723977a2 100644 --- a/dlls/dbghelp/cpu_i386.c +++ b/dlls/dbghelp/cpu_i386.c @@ -213,16 +213,16 @@ static BOOL i386_stack_walk(struct cpu_stack_walk *csw, STACKFRAME64 *frame, @@ -48,10 +48,10 @@ index 9704cfda538..7a3e08a999e 100644 } next_switch = p; diff --git a/dlls/krnl386.exe16/kernel.c b/dlls/krnl386.exe16/kernel.c -index 0a66d1e611a..17b0c156c07 100644 +index 07a57d0d937..89ea5c042e7 100644 --- a/dlls/krnl386.exe16/kernel.c +++ b/dlls/krnl386.exe16/kernel.c -@@ -45,8 +45,8 @@ static void thread_attach(void) +@@ -47,8 +47,8 @@ static void thread_attach(void) /* allocate the 16-bit stack (FIXME: should be done lazily) */ HGLOBAL16 hstack = WOWGlobalAlloc16( GMEM_FIXED, 0x10000 ); kernel_get_thread_data()->stack_sel = GlobalHandleToSel16( hstack ); @@ -62,7 +62,7 @@ index 0a66d1e611a..17b0c156c07 100644 memset( (char *)GlobalLock16(hstack) + 0x10000 - sizeof(STACK16FRAME), 0, sizeof(STACK16FRAME) ); } -@@ -58,7 +58,7 @@ static void thread_detach(void) +@@ -60,7 +60,7 @@ static void thread_detach(void) { /* free the 16-bit stack */ WOWGlobalFree16( kernel_get_thread_data()->stack_sel ); @@ -72,10 +72,10 @@ index 0a66d1e611a..17b0c156c07 100644 } diff --git a/dlls/krnl386.exe16/kernel16_private.h b/dlls/krnl386.exe16/kernel16_private.h -index 284b063741b..2f5b006e5ad 100644 +index f15934daa0e..9f939a9d5ba 100644 --- a/dlls/krnl386.exe16/kernel16_private.h +++ b/dlls/krnl386.exe16/kernel16_private.h -@@ -170,7 +170,7 @@ extern THHOOK *pThhook DECLSPEC_HIDDEN; +@@ -169,7 +169,7 @@ extern THHOOK *pThhook DECLSPEC_HIDDEN; (((offset)+(size) <= pModule->mapping_size) ? \ (memcpy( buffer, (const char *)pModule->mapping + (offset), (size) ), TRUE) : FALSE) @@ -84,7 +84,7 @@ index 284b063741b..2f5b006e5ad 100644 #define CURRENT_DS (CURRENT_STACK16->ds) /* push bytes on the 16-bit stack of a thread; return a segptr to the first pushed byte */ -@@ -178,8 +178,8 @@ static inline SEGPTR stack16_push( int size ) +@@ -177,8 +177,8 @@ static inline SEGPTR stack16_push( int size ) { STACK16FRAME *frame = CURRENT_STACK16; memmove( (char*)frame - size, frame, sizeof(*frame) ); @@ -95,7 +95,7 @@ index 284b063741b..2f5b006e5ad 100644 } /* pop bytes from the 16-bit stack of a thread */ -@@ -187,7 +187,7 @@ static inline void stack16_pop( int size ) +@@ -186,7 +186,7 @@ static inline void stack16_pop( int size ) { STACK16FRAME *frame = CURRENT_STACK16; memmove( (char*)frame + size, frame, sizeof(*frame) ); @@ -104,7 +104,7 @@ index 284b063741b..2f5b006e5ad 100644 } /* dosmem.c */ -@@ -273,11 +273,12 @@ struct tagSYSLEVEL; +@@ -300,11 +300,12 @@ struct tagSYSLEVEL; struct kernel_thread_data { @@ -119,10 +119,10 @@ index 284b063741b..2f5b006e5ad 100644 static inline struct kernel_thread_data *kernel_get_thread_data(void) diff --git a/dlls/krnl386.exe16/ne_module.c b/dlls/krnl386.exe16/ne_module.c -index 357a0e98d4a..4b0b6a0b114 100644 +index f1e1a14dd67..c951a18f869 100644 --- a/dlls/krnl386.exe16/ne_module.c +++ b/dlls/krnl386.exe16/ne_module.c -@@ -1217,7 +1217,7 @@ DWORD NE_StartTask(void) +@@ -1208,7 +1208,7 @@ DWORD NE_StartTask(void) sp = pSegTable[SELECTOROF(pModule->ne_sssp)-1].minsize + pModule->ne_stack; sp &= ~1; sp -= sizeof(STACK16FRAME); @@ -131,7 +131,7 @@ index 357a0e98d4a..4b0b6a0b114 100644 /* Registers at initialization must be: * ax zero -@@ -1245,8 +1245,8 @@ DWORD NE_StartTask(void) +@@ -1236,8 +1236,8 @@ DWORD NE_StartTask(void) TRACE("Starting main program: cs:ip=%04x:%04x ds=%04x ss:sp=%04x:%04x\n", context.SegCs, context.Eip, context.SegDs, @@ -143,10 +143,10 @@ index 357a0e98d4a..4b0b6a0b114 100644 WOWCallback16Ex( 0, WCB16_REGS, 0, NULL, (DWORD *)&context ); ExitThread( LOWORD(context.Eax) ); diff --git a/dlls/krnl386.exe16/ne_segment.c b/dlls/krnl386.exe16/ne_segment.c -index 000c5760f84..30ace05e57e 100644 +index aa886148029..70eb3360914 100644 --- a/dlls/krnl386.exe16/ne_segment.c +++ b/dlls/krnl386.exe16/ne_segment.c -@@ -378,9 +378,9 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum ) +@@ -370,9 +370,9 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum ) DWORD ret; selfloadheader = MapSL( MAKESEGPTR(SEL(pSegTable->hSeg),0) ); @@ -159,7 +159,7 @@ index 000c5760f84..30ace05e57e 100644 hFile16 = NE_OpenFile( pModule ); TRACE_(dll)("Call LoadAppSegProc(hmodule=0x%04x,hf=%x,segnum=%d)\n", -@@ -392,7 +392,7 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum ) +@@ -384,7 +384,7 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum ) pSeg->hSeg = LOWORD(ret); TRACE_(dll)("Ret LoadAppSegProc: hSeg=0x%04x\n", pSeg->hSeg); _lclose16( hFile16 ); @@ -168,7 +168,7 @@ index 000c5760f84..30ace05e57e 100644 pSeg->flags |= NE_SEGFLAGS_LOADED; return TRUE; -@@ -484,9 +484,9 @@ BOOL NE_LoadAllSegments( NE_MODULE *pModule ) +@@ -476,9 +476,9 @@ BOOL NE_LoadAllSegments( NE_MODULE *pModule ) sel = GlobalAlloc16( GMEM_ZEROINIT, 0xFF00 ); pModule->self_loading_sel = SEL(sel); FarSetOwner16( sel, pModule->self ); @@ -181,7 +181,7 @@ index 000c5760f84..30ace05e57e 100644 hFile16 = NE_OpenFile(pModule); TRACE_(dll)("CallBootAppProc(hModule=0x%04x,hf=0x%04x)\n", -@@ -496,7 +496,7 @@ BOOL NE_LoadAllSegments( NE_MODULE *pModule ) +@@ -488,7 +488,7 @@ BOOL NE_LoadAllSegments( NE_MODULE *pModule ) WOWCallback16Ex( (DWORD)selfloadheader->BootApp, WCB16_PASCAL, sizeof(args), args, NULL ); TRACE_(dll)("Return from CallBootAppProc\n"); _lclose16(hFile16); @@ -190,7 +190,7 @@ index 000c5760f84..30ace05e57e 100644 for (i = 2; i <= pModule->ne_cseg; i++) if (!NE_LoadSegment( pModule, i )) return FALSE; -@@ -691,7 +691,7 @@ static BOOL NE_InitDLL( NE_MODULE *pModule ) +@@ -680,7 +680,7 @@ static BOOL NE_InitDLL( NE_MODULE *pModule ) context.SegEs = ds; /* who knows ... */ context.SegCs = SEL(pSegTable[SELECTOROF(pModule->ne_csip)-1].hSeg); context.Eip = OFFSETOF(pModule->ne_csip); @@ -199,7 +199,7 @@ index 000c5760f84..30ace05e57e 100644 pModule->ne_csip = 0; /* Don't initialize it twice */ TRACE_(dll)("Calling LibMain for %.*s, cs:ip=%04x:%04x ds=%04x di=%04x cx=%04x\n", -@@ -794,7 +794,7 @@ static void NE_CallDllEntryPoint( NE_MODULE *pModule, DWORD dwReason ) +@@ -782,7 +782,7 @@ static void NE_CallDllEntryPoint( NE_MODULE *pModule, DWORD dwReason ) context.SegEs = ds; /* who knows ... */ context.SegCs = HIWORD(entryPoint); context.Eip = LOWORD(entryPoint); @@ -209,10 +209,10 @@ index 000c5760f84..30ace05e57e 100644 args[7] = HIWORD(dwReason); args[6] = LOWORD(dwReason); diff --git a/dlls/krnl386.exe16/task.c b/dlls/krnl386.exe16/task.c -index 84d4bf33a4c..ff69b37cd86 100644 +index 39a60cb97a9..21de62c5a01 100644 --- a/dlls/krnl386.exe16/task.c +++ b/dlls/krnl386.exe16/task.c -@@ -630,7 +630,7 @@ void WINAPI InitTask16( CONTEXT *context ) +@@ -624,7 +624,7 @@ void WINAPI InitTask16( CONTEXT *context ) /* Initialize the INSTANCEDATA structure */ pinstance = MapSL( MAKESEGPTR(CURRENT_DS, 0) ); @@ -221,7 +221,7 @@ index 84d4bf33a4c..ff69b37cd86 100644 pinstance->stackbottom = pinstance->stackmin; /* yup, that's right. Confused me too. */ pinstance->stacktop = ( pinstance->stackmin > LOWORD(context->Ebx) ? pinstance->stackmin - LOWORD(context->Ebx) : 0 ) + 150; -@@ -1101,14 +1101,14 @@ void WINAPI SwitchStackTo16( WORD seg, WORD ptr, WORD top ) +@@ -1095,14 +1095,14 @@ void WINAPI SwitchStackTo16( WORD seg, WORD ptr, WORD top ) if (!(pData = GlobalLock16( seg ))) return; TRACE("old=%04x:%04x new=%04x:%04x\n", @@ -239,7 +239,7 @@ index 84d4bf33a4c..ff69b37cd86 100644 + 2 * sizeof(WORD); *(WORD *)MapSL(pData->old_ss_sp) = oldFrame->bp; pData->stacktop = top; -@@ -1122,7 +1122,7 @@ void WINAPI SwitchStackTo16( WORD seg, WORD ptr, WORD top ) +@@ -1116,7 +1116,7 @@ void WINAPI SwitchStackTo16( WORD seg, WORD ptr, WORD top ) */ copySize = oldFrame->bp - OFFSETOF(pData->old_ss_sp); copySize += 3 * sizeof(WORD) + sizeof(STACK16FRAME); @@ -248,7 +248,7 @@ index 84d4bf33a4c..ff69b37cd86 100644 newFrame = CURRENT_STACK16; /* Copy the stack frame and the local variables to the new stack */ -@@ -1141,7 +1141,7 @@ void WINAPI SwitchStackBack16( CONTEXT *context ) +@@ -1135,7 +1135,7 @@ void WINAPI SwitchStackBack16( CONTEXT *context ) STACK16FRAME *oldFrame, *newFrame; INSTANCEDATA *pData; @@ -257,7 +257,7 @@ index 84d4bf33a4c..ff69b37cd86 100644 return; if (!pData->old_ss_sp) { -@@ -1160,7 +1160,7 @@ void WINAPI SwitchStackBack16( CONTEXT *context ) +@@ -1154,7 +1154,7 @@ void WINAPI SwitchStackBack16( CONTEXT *context ) /* Switch back to the old stack */ @@ -267,10 +267,10 @@ index 84d4bf33a4c..ff69b37cd86 100644 context->Esp = OFFSETOF(pData->old_ss_sp) - sizeof(DWORD); /*ret addr*/ pData->old_ss_sp = 0; diff --git a/dlls/krnl386.exe16/thunk.c b/dlls/krnl386.exe16/thunk.c -index c8ad3824c0f..69f6f3b2e8c 100644 +index 78925f594ba..141acb8d5e6 100644 --- a/dlls/krnl386.exe16/thunk.c +++ b/dlls/krnl386.exe16/thunk.c -@@ -435,7 +435,7 @@ void WINAPI __regs_QT_Thunk( CONTEXT *context ) +@@ -428,7 +428,7 @@ void WINAPI __regs_QT_Thunk( CONTEXT *context ) context16.Eip = LOWORD(context->Edx); /* point EBP to the STACK16FRAME on the stack * for the call_to_16 to set up the register content on calling */ @@ -279,7 +279,7 @@ index c8ad3824c0f..69f6f3b2e8c 100644 /* * used to be (problematic): -@@ -457,7 +457,7 @@ void WINAPI __regs_QT_Thunk( CONTEXT *context ) +@@ -450,7 +450,7 @@ void WINAPI __regs_QT_Thunk( CONTEXT *context ) * the number of parameters that the Win16 function * accepted (that it popped from the corresponding Win16 stack) */ context->Esp += LOWORD(context16.Esp) - @@ -288,7 +288,7 @@ index c8ad3824c0f..69f6f3b2e8c 100644 } DEFINE_REGS_ENTRYPOINT( QT_Thunk ) -@@ -561,7 +561,7 @@ void WINAPI __regs_FT_Thunk( CONTEXT *context ) +@@ -554,7 +554,7 @@ void WINAPI __regs_FT_Thunk( CONTEXT *context ) context16.SegCs = HIWORD(callTarget); context16.Eip = LOWORD(callTarget); @@ -297,7 +297,7 @@ index c8ad3824c0f..69f6f3b2e8c 100644 argsize = context->Ebp-context->Esp-0x40; if (argsize > sizeof(newstack)) argsize = sizeof(newstack); -@@ -573,8 +573,8 @@ void WINAPI __regs_FT_Thunk( CONTEXT *context ) +@@ -566,8 +566,8 @@ void WINAPI __regs_FT_Thunk( CONTEXT *context ) if (mapESPrelative & (1 << i)) { SEGPTR *arg = (SEGPTR *)newstack[i]; @@ -308,7 +308,7 @@ index c8ad3824c0f..69f6f3b2e8c 100644 + (*(LPBYTE *)arg - oldstack)); } -@@ -584,7 +584,7 @@ void WINAPI __regs_FT_Thunk( CONTEXT *context ) +@@ -577,7 +577,7 @@ void WINAPI __regs_FT_Thunk( CONTEXT *context ) context->Ecx = context16.Ecx; context->Esp += LOWORD(context16.Esp) - @@ -317,7 +317,7 @@ index c8ad3824c0f..69f6f3b2e8c 100644 /* Copy modified buffers back to 32-bit stack */ memcpy( oldstack, newstack, argsize ); -@@ -719,7 +719,7 @@ void WINAPI __regs_Common32ThkLS( CONTEXT *context ) +@@ -712,7 +712,7 @@ void WINAPI __regs_Common32ThkLS( CONTEXT *context ) context16.Edi = LOWORD(context->Ecx); context16.SegCs = HIWORD(context->Eax); context16.Eip = LOWORD(context->Eax); @@ -326,7 +326,7 @@ index c8ad3824c0f..69f6f3b2e8c 100644 argsize = HIWORD(context->Edx) * 4; -@@ -775,7 +775,7 @@ void WINAPI __regs_OT_32ThkLSF( CONTEXT *context ) +@@ -768,7 +768,7 @@ void WINAPI __regs_OT_32ThkLSF( CONTEXT *context ) context16.SegCs = HIWORD(context->Edx); context16.Eip = LOWORD(context->Edx); @@ -335,7 +335,7 @@ index c8ad3824c0f..69f6f3b2e8c 100644 argsize = 2 * *(WORD *)context->Esp + 2; -@@ -788,7 +788,7 @@ void WINAPI __regs_OT_32ThkLSF( CONTEXT *context ) +@@ -781,7 +781,7 @@ void WINAPI __regs_OT_32ThkLSF( CONTEXT *context ) (LPBYTE)CURRENT_STACK16 - argsize, argsize ); context->Esp += LOWORD(context16.Esp) - @@ -344,7 +344,7 @@ index c8ad3824c0f..69f6f3b2e8c 100644 } DEFINE_REGS_ENTRYPOINT( OT_32ThkLSF ) -@@ -1240,26 +1240,26 @@ void WINAPI __regs_K32Thk1632Prolog( CONTEXT *context ) +@@ -1233,26 +1233,26 @@ void WINAPI __regs_K32Thk1632Prolog( CONTEXT *context ) DWORD argSize = context->Ebp - context->Esp; char *stack16 = (char *)context->Esp - 4; STACK16FRAME *frame16 = (STACK16FRAME *)stack16 - 1; @@ -375,7 +375,7 @@ index c8ad3824c0f..69f6f3b2e8c 100644 } /* entry_point is never used again once the entry point has -@@ -1282,7 +1282,7 @@ void WINAPI __regs_K32Thk1632Epilog( CONTEXT *context ) +@@ -1275,7 +1275,7 @@ void WINAPI __regs_K32Thk1632Epilog( CONTEXT *context ) if ( code[5] == 0xFF && code[6] == 0x55 && code[7] == 0xFC && code[13] == 0x66 && code[14] == 0xCB) { @@ -384,7 +384,7 @@ index c8ad3824c0f..69f6f3b2e8c 100644 char *stack16 = (char *)(frame16 + 1); DWORD argSize = frame16->ebp - (DWORD)stack16; char *stack32 = (char *)frame16->frame32 - argSize; -@@ -1290,15 +1290,15 @@ void WINAPI __regs_K32Thk1632Epilog( CONTEXT *context ) +@@ -1283,15 +1283,15 @@ void WINAPI __regs_K32Thk1632Epilog( CONTEXT *context ) DWORD nArgsPopped = context->Esp - (DWORD)stack32; TRACE("before SYSTHUNK hack: EBP: %08x ESP: %08x cur_stack: %p\n", @@ -403,7 +403,7 @@ index c8ad3824c0f..69f6f3b2e8c 100644 } } DEFINE_REGS_ENTRYPOINT( K32Thk1632Epilog ) -@@ -2313,7 +2313,7 @@ void WINAPI Throw16( LPCATCHBUF lpbuf, INT16 retval, CONTEXT *context ) +@@ -2302,7 +2302,7 @@ void WINAPI Throw16( LPCATCHBUF lpbuf, INT16 retval, CONTEXT *context ) frame32 = pFrame->frame32; while (frame32 && frame32->frame16) { @@ -413,10 +413,10 @@ index c8ad3824c0f..69f6f3b2e8c 100644 if (OFFSETOF(frame32->frame16) > lpbuf[2]) { diff --git a/dlls/krnl386.exe16/wowthunk.c b/dlls/krnl386.exe16/wowthunk.c -index da829950bed..cf9caad44b2 100644 +index 2dddbf93289..3a4b104a673 100644 --- a/dlls/krnl386.exe16/wowthunk.c +++ b/dlls/krnl386.exe16/wowthunk.c -@@ -135,7 +135,7 @@ static DWORD call16_handler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RE +@@ -127,7 +127,7 @@ static DWORD call16_handler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RE { /* unwinding: restore the stack pointer in the TEB, and leave the Win16 mutex */ STACK32FRAME *frame32 = CONTAINING_RECORD(frame, STACK32FRAME, frame); @@ -425,7 +425,7 @@ index da829950bed..cf9caad44b2 100644 _LeaveWin16Lock(); } else if (record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION || -@@ -420,8 +420,8 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, +@@ -412,8 +412,8 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, TRACE_(relay)( "\1CallTo16(func=%04x:%04x", context->SegCs, LOWORD(context->Eip) ); while (count) TRACE_(relay)( ",%04x", wstack[--count] ); TRACE_(relay)( ") ss:sp=%04x:%04x ax=%04x bx=%04x cx=%04x dx=%04x si=%04x di=%04x bp=%04x ds=%04x es=%04x\n", @@ -436,7 +436,7 @@ index da829950bed..cf9caad44b2 100644 (WORD)context->Eax, (WORD)context->Ebx, (WORD)context->Ecx, (WORD)context->Edx, (WORD)context->Esi, (WORD)context->Edi, (WORD)context->Ebp, (WORD)context->SegDs, (WORD)context->SegEs ); -@@ -453,8 +453,8 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, +@@ -443,8 +443,8 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, if (TRACE_ON(relay)) { TRACE_(relay)( "\1RetFrom16() ss:sp=%04x:%04x ax=%04x bx=%04x cx=%04x dx=%04x bp=%04x sp=%04x\n", @@ -447,7 +447,7 @@ index da829950bed..cf9caad44b2 100644 (WORD)context->Eax, (WORD)context->Ebx, (WORD)context->Ecx, (WORD)context->Edx, (WORD)context->Ebp, (WORD)context->Esp ); SYSLEVEL_CheckNotLevel( 2 ); -@@ -470,10 +470,10 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, +@@ -460,10 +460,10 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, WORD * wstack = (WORD *)stack; TRACE_(relay)( "\1CallTo16(func=%04x:%04x,ds=%04x", @@ -461,7 +461,7 @@ index da829950bed..cf9caad44b2 100644 SYSLEVEL_CheckNotLevel( 2 ); } -@@ -496,8 +496,8 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, +@@ -486,8 +486,8 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, if (TRACE_ON(relay)) { TRACE_(relay)( "\1RetFrom16() ss:sp=%04x:%04x retval=%08x\n", @@ -473,10 +473,10 @@ index da829950bed..cf9caad44b2 100644 } } diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c -index b4e88d125f1..7c6e1b50cd4 100644 +index e905ed0af17..8a976f7745d 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c -@@ -846,7 +846,7 @@ static inline void *init_handler( const ucontext_t *sigcontext, WORD *fs, WORD * +@@ -912,7 +912,7 @@ static inline void *init_handler( const ucontext_t *sigcontext, WORD *fs, WORD * * SS is still non-system segment. This is why both CS and SS * are checked. */ @@ -499,10 +499,10 @@ index b6fd51c05f0..695ad7b6003 100644 WOWCallback16Ex( 0, WCB16_REGS, 0, NULL, (DWORD *)&context ); diff --git a/dlls/toolhelp.dll16/toolhelp.c b/dlls/toolhelp.dll16/toolhelp.c -index 02e8d6a8d53..2bccaa63e27 100644 +index 578d1ae7fab..1077f0b0367 100644 --- a/dlls/toolhelp.dll16/toolhelp.c +++ b/dlls/toolhelp.dll16/toolhelp.c -@@ -460,8 +460,8 @@ BOOL16 WINAPI TaskNext16( TASKENTRY *lpte ) +@@ -491,8 +491,8 @@ BOOL16 WINAPI TaskNext16( TASKENTRY *lpte ) lpte->hTaskParent = pTask->hParent; lpte->hInst = pTask->hInstance; lpte->hModule = pTask->hModule; @@ -513,7 +513,7 @@ index 02e8d6a8d53..2bccaa63e27 100644 lpte->wStackTop = pInstData->stacktop; lpte->wStackMinimum = pInstData->stackmin; lpte->wStackBottom = pInstData->stackbottom; -@@ -687,7 +687,7 @@ BOOL16 WINAPI TimerCount16( TIMERINFO *pTimerInfo ) +@@ -718,7 +718,7 @@ BOOL16 WINAPI TimerCount16( TIMERINFO *pTimerInfo ) */ BOOL16 WINAPI SystemHeapInfo16( SYSHEAPINFO *pHeapInfo ) { @@ -523,10 +523,10 @@ index 02e8d6a8d53..2bccaa63e27 100644 WORD user = LoadLibrary16( "USER.EXE" ); WORD gdi = LoadLibrary16( "GDI.EXE" ); diff --git a/dlls/user.exe16/message.c b/dlls/user.exe16/message.c -index dd15707e9f4..37666e72c1c 100644 +index e3ca3fd779d..fa9388ceaa1 100644 --- a/dlls/user.exe16/message.c +++ b/dlls/user.exe16/message.c -@@ -242,11 +242,11 @@ static LRESULT call_window_proc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPA +@@ -240,11 +240,11 @@ static LRESULT call_window_proc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPA /* Window procedures want ax = hInstance, ds = es = ss */ memset(&context, 0, sizeof(context)); @@ -540,7 +540,7 @@ index dd15707e9f4..37666e72c1c 100644 if (lParam) { -@@ -269,7 +269,7 @@ static LRESULT call_window_proc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPA +@@ -267,7 +267,7 @@ static LRESULT call_window_proc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPA if (size) { memcpy( &args.u, MapSL(lParam), size ); @@ -549,7 +549,7 @@ index dd15707e9f4..37666e72c1c 100644 } } -@@ -2094,7 +2094,7 @@ static LRESULT combo_proc16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, +@@ -2092,7 +2092,7 @@ static LRESULT combo_proc16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, static void edit_lock_buffer( HWND hwnd ) { @@ -558,7 +558,7 @@ index dd15707e9f4..37666e72c1c 100644 HLOCAL16 hloc16 = GetWindowWord( hwnd, GWW_HANDLE16 ); HANDLE16 oldDS; HLOCAL hloc32; -@@ -2120,7 +2120,7 @@ static void edit_lock_buffer( HWND hwnd ) +@@ -2118,7 +2118,7 @@ static void edit_lock_buffer( HWND hwnd ) static void edit_unlock_buffer( HWND hwnd ) { @@ -567,7 +567,7 @@ index dd15707e9f4..37666e72c1c 100644 HLOCAL16 hloc16 = GetWindowWord( hwnd, GWW_HANDLE16 ); HANDLE16 oldDS; HLOCAL hloc32; -@@ -2157,7 +2157,7 @@ static HLOCAL16 edit_get_handle( HWND hwnd ) +@@ -2155,7 +2155,7 @@ static HLOCAL16 edit_get_handle( HWND hwnd ) if (!(hloc = (HLOCAL)wow_handlers32.edit_proc( hwnd, EM_GETHANDLE, 0, 0, FALSE ))) return 0; alloc_size = LocalSize( hloc ); @@ -576,7 +576,7 @@ index dd15707e9f4..37666e72c1c 100644 oldDS = stack16->ds; stack16->ds = GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); -@@ -2195,7 +2195,7 @@ done: +@@ -2193,7 +2193,7 @@ done: static void edit_set_handle( HWND hwnd, HLOCAL16 hloc16 ) { @@ -585,7 +585,7 @@ index dd15707e9f4..37666e72c1c 100644 HINSTANCE16 hInstance = GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); HANDLE16 oldDS = stack16->ds; HLOCAL hloc32; -@@ -2225,7 +2225,7 @@ static void edit_destroy_handle( HWND hwnd ) +@@ -2223,7 +2223,7 @@ static void edit_destroy_handle( HWND hwnd ) HLOCAL16 hloc16 = GetWindowWord( hwnd, GWW_HANDLE16 ); if (hloc16) { @@ -617,10 +617,10 @@ index 27b92793836..deec596f766 100644 int userPercent, gdiPercent; diff --git a/dlls/user.exe16/window.c b/dlls/user.exe16/window.c -index 10f1389f0a7..a15bf57e482 100644 +index bf86719325b..1f53bdc9540 100644 --- a/dlls/user.exe16/window.c +++ b/dlls/user.exe16/window.c -@@ -455,7 +455,7 @@ HWND16 WINAPI GetParent16( HWND16 hwnd ) +@@ -456,7 +456,7 @@ HWND16 WINAPI GetParent16( HWND16 hwnd ) */ BOOL16 WINAPI IsWindow16( HWND16 hwnd ) { @@ -630,10 +630,10 @@ index 10f1389f0a7..a15bf57e482 100644 /* don't use WIN_Handle32 here, we don't care about the full handle */ return IsWindow( HWND_32(hwnd) ); diff --git a/include/winternl.h b/include/winternl.h -index 2d777e0166c..e302f5678d3 100644 +index dd63300d915..0aa0ac311c3 100644 --- a/include/winternl.h +++ b/include/winternl.h -@@ -360,7 +360,7 @@ typedef struct _TEB +@@ -362,7 +362,7 @@ typedef struct _TEB PVOID WOW32Reserved; /* 0c0/0100 */ ULONG CurrentLocale; /* 0c4/0108 */ ULONG FpSoftwareStatusRegister; /* 0c8/010c */ @@ -643,7 +643,7 @@ index 2d777e0166c..e302f5678d3 100644 ACTIVATION_CONTEXT_STACK ActivationContextStack; /* 1a8/02c8 */ BYTE SpareBytes1[24]; /* 1bc/02e8 */ diff --git a/tools/winebuild/relay.c b/tools/winebuild/relay.c -index 3b1f4cd18e0..35cbc440ec3 100644 +index 29d0a74c833..01bb97e02b4 100644 --- a/tools/winebuild/relay.c +++ b/tools/winebuild/relay.c @@ -31,7 +31,7 @@ @@ -656,5 +656,5 @@ index 3b1f4cd18e0..35cbc440ec3 100644 /* fix this if the x86_thread_data structure is changed */ #define GS_OFFSET 0x1d8 /* FIELD_OFFSET(TEB,SystemReserved2) + FIELD_OFFSET(struct x86_thread_data,gs) */ -- -2.20.1 +2.26.2 diff --git a/patches/winebuild-Fake_Dlls/0003-winebuild-Generate-syscall-thunks-for-ntdll-exports.patch b/patches/winebuild-Fake_Dlls/0003-winebuild-Generate-syscall-thunks-for-ntdll-exports.patch index d9ab0906..7fb275b1 100644 --- a/patches/winebuild-Fake_Dlls/0003-winebuild-Generate-syscall-thunks-for-ntdll-exports.patch +++ b/patches/winebuild-Fake_Dlls/0003-winebuild-Generate-syscall-thunks-for-ntdll-exports.patch @@ -1,4 +1,4 @@ -From f6b994d65424d14e14efb0f486781b48a4e40be0 Mon Sep 17 00:00:00 2001 +From 70b608b933988ecedb3537fe3187057ee7862b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 11 May 2017 05:32:55 +0200 Subject: [PATCH] winebuild: Generate syscall thunks for ntdll exports. @@ -17,10 +17,10 @@ Based on a patch by Erich E. Hoover. 9 files changed, 207 insertions(+), 27 deletions(-) diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c -index c9ddb1fcc7b..243eded1b77 100644 +index 8a976f7745d..04fdaf564b3 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c -@@ -479,6 +479,9 @@ static ULONG first_ldt_entry = 32; +@@ -476,6 +476,9 @@ static ULONG first_ldt_entry = 32; static wine_signal_handler handlers[256]; @@ -30,7 +30,7 @@ index c9ddb1fcc7b..243eded1b77 100644 enum i386_trap_code { TRAP_x86_UNKNOWN = -1, /* Unknown fault (TRAP_sig not defined) */ -@@ -1517,7 +1520,7 @@ NTSTATUS CDECL DECLSPEC_HIDDEN __regs_NtGetContextThread( DWORD edi, DWORD esi, +@@ -1514,7 +1517,7 @@ NTSTATUS CDECL DECLSPEC_HIDDEN __regs_NtGetContextThread( DWORD edi, DWORD esi, { context->Ebp = ebp; context->Esp = (DWORD)&retaddr; @@ -39,7 +39,7 @@ index c9ddb1fcc7b..243eded1b77 100644 context->SegCs = get_cs(); context->SegSs = get_ds(); context->EFlags = eflags; -@@ -2582,6 +2585,8 @@ NTSTATUS signal_alloc_thread( TEB *teb ) +@@ -2561,6 +2564,8 @@ NTSTATUS signal_alloc_thread( TEB *teb ) } else thread_data->fs = gdt_fs_sel; @@ -62,7 +62,7 @@ index 72afb0a3764..fbd90661ee0 100644 ok( context.SegCs == LOWORD(expect.SegCs), "wrong SegCs %08x/%08x\n", context.SegCs, expect.SegCs ); ok( context.SegDs == LOWORD(expect.SegDs), "wrong SegDs %08x/%08x\n", context.SegDs, expect.SegDs ); diff --git a/include/winternl.h b/include/winternl.h -index 93dd30482da..becb53e1261 100644 +index 0aa0ac311c3..26ee5b601fb 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -359,7 +359,7 @@ typedef struct _TEB diff --git a/patches/winebuild-Fake_Dlls/0004-winebuild-Use-multipass-label-system-to-generate-fak.patch b/patches/winebuild-Fake_Dlls/0004-winebuild-Use-multipass-label-system-to-generate-fak.patch index 50e4c49f..aaa7fa3a 100644 --- a/patches/winebuild-Fake_Dlls/0004-winebuild-Use-multipass-label-system-to-generate-fak.patch +++ b/patches/winebuild-Fake_Dlls/0004-winebuild-Use-multipass-label-system-to-generate-fak.patch @@ -1,4 +1,4 @@ -From 24441c46a4496982ff9ce2f1243f2cd8b52616b6 Mon Sep 17 00:00:00 2001 +From 667601bc23962316cead7b117a4fe3eaca21ef7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Mon, 15 May 2017 02:05:49 +0200 Subject: [PATCH] winebuild: Use multipass label system to generate fake dlls. @@ -11,10 +11,10 @@ Subject: [PATCH] winebuild: Use multipass label system to generate fake dlls. 4 files changed, 181 insertions(+), 63 deletions(-) diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h -index c92a184749c..53d4ba192eb 100644 +index 6ee847f908c..210324406a9 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h -@@ -342,6 +342,7 @@ extern size_t input_buffer_pos; +@@ -343,6 +343,7 @@ extern size_t input_buffer_pos; extern size_t input_buffer_size; extern unsigned char *output_buffer; extern size_t output_buffer_pos; @@ -22,7 +22,7 @@ index c92a184749c..53d4ba192eb 100644 extern size_t output_buffer_size; extern void init_input_buffer( const char *file ); -@@ -357,6 +358,11 @@ extern void put_dword( unsigned int val ); +@@ -358,6 +359,11 @@ extern void put_dword( unsigned int val ); extern void put_qword( unsigned int val ); extern void put_pword( unsigned int val ); extern void align_output( unsigned int align ); @@ -47,10 +47,10 @@ index bd55bb2fa5c..d9329019f8a 100644 /* output the resource directories */ diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c -index fa7984e1a38..e67cb48cd08 100644 +index 22dd399cb2b..c38f1fe663c 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c -@@ -885,11 +885,11 @@ void output_spec32_file( DLLSPEC *spec ) +@@ -844,11 +844,11 @@ void output_spec32_file( DLLSPEC *spec ) /******************************************************************* @@ -65,7 +65,7 @@ index fa7984e1a38..e67cb48cd08 100644 { static const unsigned char dll_code_section[] = { 0x31, 0xc0, /* xor %eax,%eax */ 0xc2, 0x0c, 0x00 }; /* ret $12 */ -@@ -901,21 +901,8 @@ void output_fake_module( DLLSPEC *spec ) +@@ -860,21 +860,8 @@ void output_fake_module( DLLSPEC *spec ) const unsigned int section_align = page_size; const unsigned int file_align = 0x200; const unsigned int reloc_size = 8; @@ -88,7 +88,7 @@ index fa7984e1a38..e67cb48cd08 100644 put_word( 0x5a4d ); /* e_magic */ put_word( 0x40 ); /* e_cblp */ -@@ -943,6 +930,7 @@ void output_fake_module( DLLSPEC *spec ) +@@ -902,6 +889,7 @@ void output_fake_module( DLLSPEC *spec ) put_dword( lfanew ); put_data( fakedll_signature, sizeof(fakedll_signature) ); @@ -96,7 +96,7 @@ index fa7984e1a38..e67cb48cd08 100644 put_dword( 0x4550 ); /* Signature */ switch(target_cpu) -@@ -966,11 +954,11 @@ void output_fake_module( DLLSPEC *spec ) +@@ -925,11 +913,11 @@ void output_fake_module( DLLSPEC *spec ) IMAGE_NT_OPTIONAL_HDR32_MAGIC ); /* Magic */ put_byte( 7 ); /* MajorLinkerVersion */ put_byte( 10 ); /* MinorLinkerVersion */ @@ -111,7 +111,7 @@ index fa7984e1a38..e67cb48cd08 100644 if (get_ptr_size() == 4) put_dword( 0 ); /* BaseOfData */ put_pword( 0x10000000 ); /* ImageBase */ put_dword( section_align ); /* SectionAlignment */ -@@ -982,8 +970,8 @@ void output_fake_module( DLLSPEC *spec ) +@@ -941,8 +929,8 @@ void output_fake_module( DLLSPEC *spec ) put_word( spec->subsystem_major ); /* MajorSubsystemVersion */ put_word( spec->subsystem_minor ); /* MinorSubsystemVersion */ put_dword( 0 ); /* Win32VersionValue */ @@ -122,7 +122,7 @@ index fa7984e1a38..e67cb48cd08 100644 put_dword( 0 ); /* CheckSum */ put_word( spec->subsystem ); /* Subsystem */ put_word( spec->dll_characteristics ); /* DllCharacteristics */ -@@ -996,10 +984,10 @@ void output_fake_module( DLLSPEC *spec ) +@@ -955,10 +943,10 @@ void output_fake_module( DLLSPEC *spec ) put_dword( 0 ); put_dword( 0 ); /* DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT] */ put_dword( 0 ); put_dword( 0 ); /* DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT] */ @@ -136,7 +136,7 @@ index fa7984e1a38..e67cb48cd08 100644 } else { -@@ -1009,8 +997,8 @@ void output_fake_module( DLLSPEC *spec ) +@@ -968,8 +956,8 @@ void output_fake_module( DLLSPEC *spec ) put_dword( 0 ); put_dword( 0 ); /* DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION] */ put_dword( 0 ); put_dword( 0 ); /* DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY] */ @@ -147,7 +147,7 @@ index fa7984e1a38..e67cb48cd08 100644 put_dword( 0 ); put_dword( 0 ); /* DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG] */ put_dword( 0 ); put_dword( 0 ); /* DataDirectory[IMAGE_DIRECTORY_ENTRY_COPYRIGHT] */ put_dword( 0 ); put_dword( 0 ); /* DataDirectory[IMAGE_DIRECTORY_ENTRY_GLOBALPTR] */ -@@ -1023,62 +1011,95 @@ void output_fake_module( DLLSPEC *spec ) +@@ -982,62 +970,95 @@ void output_fake_module( DLLSPEC *spec ) put_dword( 0 ); put_dword( 0 ); /* DataDirectory[15] */ /* .text section */ @@ -279,7 +279,7 @@ index fa7984e1a38..e67cb48cd08 100644 } diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c -index 05063786928..f53e09227ca 100644 +index 7dc61a708db..64e1fa51455 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -34,6 +34,7 @@ @@ -290,7 +290,7 @@ index 05063786928..f53e09227ca 100644 #include "build.h" #if defined(_WIN32) && !defined(__CYGWIN__) -@@ -541,8 +542,86 @@ size_t input_buffer_pos; +@@ -542,8 +543,86 @@ size_t input_buffer_pos; size_t input_buffer_size; unsigned char *output_buffer; size_t output_buffer_pos; @@ -377,7 +377,7 @@ index 05063786928..f53e09227ca 100644 static void check_output_buffer_space( size_t size ) { if (output_buffer_pos + size >= output_buffer_size) -@@ -574,7 +653,9 @@ void init_output_buffer(void) +@@ -575,7 +654,9 @@ void init_output_buffer(void) { output_buffer_size = 1024; output_buffer_pos = 0; @@ -387,7 +387,7 @@ index 05063786928..f53e09227ca 100644 } void flush_output_buffer(void) -@@ -584,6 +665,7 @@ void flush_output_buffer(void) +@@ -585,6 +666,7 @@ void flush_output_buffer(void) fatal_error( "Error writing to %s\n", output_file_name ); close_output_file(); free( output_buffer ); @@ -395,7 +395,7 @@ index 05063786928..f53e09227ca 100644 } unsigned char get_byte(void) -@@ -623,12 +705,14 @@ void put_data( const void *data, size_t size ) +@@ -624,12 +706,14 @@ void put_data( const void *data, size_t size ) check_output_buffer_space( size ); memcpy( output_buffer + output_buffer_pos, data, size ); output_buffer_pos += size; @@ -410,7 +410,7 @@ index 05063786928..f53e09227ca 100644 } void put_word( unsigned short val ) -@@ -675,6 +759,14 @@ void align_output( unsigned int align ) +@@ -676,6 +760,14 @@ void align_output( unsigned int align ) output_buffer_pos += size; } @@ -426,5 +426,5 @@ index 05063786928..f53e09227ca 100644 void output_standard_file_header(void) { -- -2.17.1 +2.26.2 diff --git a/patches/winebuild-Fake_Dlls/0005-winebuild-Add-stub-functions-in-fake-dlls.patch b/patches/winebuild-Fake_Dlls/0005-winebuild-Add-stub-functions-in-fake-dlls.patch index a2152711..91da1698 100644 --- a/patches/winebuild-Fake_Dlls/0005-winebuild-Add-stub-functions-in-fake-dlls.patch +++ b/patches/winebuild-Fake_Dlls/0005-winebuild-Add-stub-functions-in-fake-dlls.patch @@ -1,4 +1,4 @@ -From 5b939ad020141bf9a33bb54d7eec7f0c730b9669 Mon Sep 17 00:00:00 2001 +From e7919b740980b9e7e1a9a7337fa8231c7aff8af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Mon, 15 May 2017 16:27:56 +0200 Subject: [PATCH] winebuild: Add stub functions in fake dlls. @@ -61,10 +61,10 @@ index 4e7a15970cb..ec173c94a8e 100644 CloseHandle(map); CloseHandle(file); diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c -index 243eded1b77..2cd672ad165 100644 +index 04fdaf564b3..1dcc54895dc 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c -@@ -482,6 +482,39 @@ static wine_signal_handler handlers[256]; +@@ -479,6 +479,39 @@ static wine_signal_handler handlers[256]; extern void DECLSPEC_NORETURN __wine_syscall_dispatcher( void ); extern NTSTATUS WINAPI __syscall_NtGetContextThread( HANDLE handle, CONTEXT *context ); @@ -104,7 +104,7 @@ index 243eded1b77..2cd672ad165 100644 enum i386_trap_code { TRAP_x86_UNKNOWN = -1, /* Unknown fault (TRAP_sig not defined) */ -@@ -2586,6 +2619,7 @@ NTSTATUS signal_alloc_thread( TEB *teb ) +@@ -2565,6 +2598,7 @@ NTSTATUS signal_alloc_thread( TEB *teb ) else thread_data->fs = gdt_fs_sel; teb->WOW32Reserved = __wine_syscall_dispatcher; @@ -113,7 +113,7 @@ index 243eded1b77..2cd672ad165 100644 return STATUS_SUCCESS; } diff --git a/include/winternl.h b/include/winternl.h -index becb53e1261..94ab0046b5f 100644 +index 26ee5b601fb..03f86dae253 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -398,7 +398,7 @@ typedef struct _TEB 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 21421fd3..0bacb81f 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,4 +1,4 @@ -From 4e2ff25e0e50d37975ec152bcc40fa130ff130b9 Mon Sep 17 00:00:00 2001 +From 80bca88fd2ab601ad0fa9c90438d43c2d6b78eca 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: [PATCH] winebuild: Add syscall thunks in fake dlls. @@ -9,10 +9,10 @@ Subject: [PATCH] winebuild: Add syscall thunks in fake dlls. 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c -index cf4920ec0..e05a81fac 100644 +index ec173c94a8e..a3bed8b310b 100644 --- a/dlls/kernel32/tests/loader.c +++ b/dlls/kernel32/tests/loader.c -@@ -1592,7 +1592,6 @@ static void test_FakeDLL(void) +@@ -1602,7 +1602,6 @@ static void test_FakeDLL(void) /* check function content */ map_func = RVAToAddr(map_rva, ptr); @@ -21,10 +21,10 @@ index cf4920ec0..e05a81fac 100644 if (!strcmp(func_name, "NtSetEvent")) diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c -index 3caadf78c..c1ace3d32 100644 +index bf82ca497c0..6968e41260f 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c -@@ -863,13 +863,36 @@ static void create_stub_exports_text( DLLSPEC *spec ) +@@ -860,13 +860,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; @@ -62,7 +62,7 @@ index 3caadf78c..c1ace3d32 100644 put_label( name ); put_byte( 0x8b ); put_byte( 0xff ); /* mov edi, edi */ put_byte( 0x55 ); /* push ebp */ -@@ -960,7 +983,7 @@ static void create_stub_exports_text( DLLSPEC *spec ) +@@ -957,7 +980,7 @@ static void create_stub_exports_text( DLLSPEC *spec ) ORDDEF *odp = spec->ordinals[i]; if (odp) { @@ -72,5 +72,5 @@ index 3caadf78c..c1ace3d32 100644 } else -- -2.21.0 +2.26.2 diff --git a/patches/winebuild-Fake_Dlls/0007-winebuild-Fix-size-of-relocation-information-in-fake.patch b/patches/winebuild-Fake_Dlls/0007-winebuild-Fix-size-of-relocation-information-in-fake.patch index a396648c..a7ff0968 100644 --- a/patches/winebuild-Fake_Dlls/0007-winebuild-Fix-size-of-relocation-information-in-fake.patch +++ b/patches/winebuild-Fake_Dlls/0007-winebuild-Fix-size-of-relocation-information-in-fake.patch @@ -1,17 +1,17 @@ -From 72e217f735af13a8a7026688fd46f353c24e93ab Mon Sep 17 00:00:00 2001 +From acaf86ab9bb880b49c7771d47b8ed0e7513aa86e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 25 May 2017 03:22:25 +0200 -Subject: winebuild: Fix size of relocation information in fake dlls. +Subject: [PATCH] winebuild: Fix size of relocation information in fake dlls. --- tools/winebuild/spec32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c -index 5a245b5ae81..4dda31c349b 100644 +index 6968e41260f..f95b45b9a0d 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c -@@ -1100,8 +1100,8 @@ static void output_fake_module_pass( DLLSPEC *spec ) +@@ -1238,8 +1238,8 @@ static void output_fake_module_pass( DLLSPEC *spec ) /* .reloc contents */ align_output_rva( file_align, section_align ); put_label( "reloc_start" ); @@ -23,5 +23,5 @@ index 5a245b5ae81..4dda31c349b 100644 /* .rsrc contents */ -- -2.12.2 +2.26.2 diff --git a/patches/winebuild-Fake_Dlls/0008-winebuild-Try-to-make-sure-RVA-matches-between-fake-.patch b/patches/winebuild-Fake_Dlls/0008-winebuild-Try-to-make-sure-RVA-matches-between-fake-.patch index e4bd1532..b9fe1b85 100644 --- a/patches/winebuild-Fake_Dlls/0008-winebuild-Try-to-make-sure-RVA-matches-between-fake-.patch +++ b/patches/winebuild-Fake_Dlls/0008-winebuild-Try-to-make-sure-RVA-matches-between-fake-.patch @@ -1,4 +1,4 @@ -From b9dbb8650b4b339de5e71cf5dab5c3ec321def58 Mon Sep 17 00:00:00 2001 +From c83164619486ebdfa6a8421ac210bbfbffc876a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 25 May 2017 21:46:27 +0200 Subject: [PATCH] winebuild: Try to make sure RVA matches between fake and @@ -11,10 +11,10 @@ Subject: [PATCH] winebuild: Try to make sure RVA matches between fake and 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c -index 96cd67ff4..3a441bf7b 100644 +index a3bed8b310b..8b5a345b086 100644 --- a/dlls/kernel32/tests/loader.c +++ b/dlls/kernel32/tests/loader.c -@@ -1579,7 +1579,6 @@ static void test_FakeDLL(void) +@@ -1589,7 +1589,6 @@ static void test_FakeDLL(void) /* check position in memory */ dll_rva = (DWORD_PTR)dll_func - (DWORD_PTR)module; map_rva = funcs[ordinals[i]]; @@ -23,10 +23,10 @@ index 96cd67ff4..3a441bf7b 100644 func_name, dll_rva, map_rva); diff --git a/libs/wine/loader.c b/libs/wine/loader.c -index 8f40ea049..163125c9e 100644 +index c3b59d90224..b6847ca77b3 100644 --- a/libs/wine/loader.c +++ b/libs/wine/loader.c -@@ -405,8 +405,12 @@ static void *map_dll( const IMAGE_NT_HEADERS *nt_descr ) +@@ -335,8 +335,12 @@ static void *map_dll( const IMAGE_NT_HEADERS *nt_descr ) assert( size <= page_size ); /* module address must be aligned on 64K boundary */ @@ -41,7 +41,7 @@ index 8f40ea049..163125c9e 100644 dos = (IMAGE_DOS_HEADER *)addr; nt = (IMAGE_NT_HEADERS *)(dos + 1); -@@ -453,6 +457,11 @@ static void *map_dll( const IMAGE_NT_HEADERS *nt_descr ) +@@ -383,6 +387,11 @@ static void *map_dll( const IMAGE_NT_HEADERS *nt_descr ) nt->OptionalHeader.SizeOfImage = data_end; nt->OptionalHeader.ImageBase = (ULONG_PTR)addr; @@ -54,10 +54,10 @@ index 8f40ea049..163125c9e 100644 memcpy( sec->Name, ".text", sizeof(".text") ); diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c -index 75b2474fa..d0b1367ef 100644 +index f95b45b9a0d..07d6eed05fc 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c -@@ -378,14 +378,25 @@ static void output_relay_debug( DLLSPEC *spec ) +@@ -381,14 +381,25 @@ static void output_relay_debug( DLLSPEC *spec ) */ static void output_syscall_thunks( DLLSPEC *spec ) { @@ -85,7 +85,7 @@ index 75b2474fa..d0b1367ef 100644 for (i = 0; i < spec->nb_syscalls; i++) { ORDDEF *odp = spec->syscalls[i]; -@@ -765,6 +776,8 @@ void output_module( DLLSPEC *spec ) +@@ -813,6 +824,8 @@ void output_module( DLLSPEC *spec ) data_dirs[1] = ".L__wine_spec_imports"; /* DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT] */ if (spec->nb_resources) data_dirs[2] = ".L__wine_spec_resources"; /* DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE] */ @@ -95,5 +95,5 @@ index 75b2474fa..d0b1367ef 100644 output_data_directories( data_dirs ); -- -2.20.1 +2.26.2 diff --git a/patches/winebuild-Fake_Dlls/0009-libs-wine-Use-same-file-alignment-for-fake-and-built.patch b/patches/winebuild-Fake_Dlls/0009-libs-wine-Use-same-file-alignment-for-fake-and-built.patch index f2715d15..0356abf4 100644 --- a/patches/winebuild-Fake_Dlls/0009-libs-wine-Use-same-file-alignment-for-fake-and-built.patch +++ b/patches/winebuild-Fake_Dlls/0009-libs-wine-Use-same-file-alignment-for-fake-and-built.patch @@ -1,4 +1,4 @@ -From 87cbe344d00e41b46df4c9e44419b8c14cd49620 Mon Sep 17 00:00:00 2001 +From 1130cceef139041823a4465481a09adf58467afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 25 May 2017 21:56:06 +0200 Subject: [PATCH] libs/wine: Use same file alignment for fake and builtin DLLs. @@ -9,10 +9,10 @@ Subject: [PATCH] libs/wine: Use same file alignment for fake and builtin DLLs. 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c -index ffc28fd..c9af524 100644 +index 8b5a345b086..5373dc4efe1 100644 --- a/dlls/kernel32/tests/loader.c +++ b/dlls/kernel32/tests/loader.c -@@ -1455,7 +1455,6 @@ static void test_FakeDLL(void) +@@ -1595,7 +1595,6 @@ static void test_FakeDLL(void) /* check position in file */ map_offset = (DWORD_PTR)RtlImageRvaToVa(RtlImageNtHeader(ptr), ptr, map_rva, NULL) - (DWORD_PTR)ptr; dll_offset = (DWORD_PTR)RtlImageRvaToVa(RtlImageNtHeader(module), module, dll_rva, NULL) - (DWORD_PTR)module; @@ -21,10 +21,10 @@ index ffc28fd..c9af524 100644 func_name, map_offset, dll_offset); diff --git a/libs/wine/loader.c b/libs/wine/loader.c -index 677e0fe..162c94d 100644 +index b6847ca77b3..4597a6cb324 100644 --- a/libs/wine/loader.c +++ b/libs/wine/loader.c -@@ -468,7 +468,7 @@ static void *map_dll( const IMAGE_NT_HEADERS *nt_descr ) +@@ -398,7 +398,7 @@ static void *map_dll( const IMAGE_NT_HEADERS *nt_descr ) sec->SizeOfRawData = code_end - code_start; sec->Misc.VirtualSize = sec->SizeOfRawData; sec->VirtualAddress = code_start; @@ -34,5 +34,5 @@ index 677e0fe..162c94d 100644 sec++; -- -1.9.1 +2.26.2 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 041e1aad..a93ff2c0 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 8035154879b5e15e71d76b57f827ee0c3f3dc808 Mon Sep 17 00:00:00 2001 +From 7d5bb8de2172799e98449480c44a04b878f103c8 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 | 6 + libs/wine/loader.c | 4 + tools/winebuild/parser.c | 2 +- - tools/winebuild/spec32.c | 270 ++++++++++++++++++++++++++++++++++- - 6 files changed, 283 insertions(+), 8 deletions(-) + tools/winebuild/spec32.c | 268 ++++++++++++++++++++++++++++++++++- + 6 files changed, 281 insertions(+), 8 deletions(-) diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c index 5373dc4efe1..67d04876bd6 100644 @@ -60,7 +60,7 @@ index 31af1e98d3f..324a92b41a9 100644 } diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c -index f4da99db760..03229a98bb8 100644 +index a054164ee70..584076361e4 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -59,6 +59,8 @@ struct _KUSER_SHARED_DATA *user_shared_data = NULL; @@ -113,7 +113,7 @@ index 74216f8bb6e..820516329a4 100644 if (odp->flags & (FLAG_FORWARD | FLAG_REGISTER)) return 0; diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c -index 07d6eed05fc..36645aef417 100644 +index 07d6eed05fc..b5a8c190e1f 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -375,11 +375,11 @@ static void output_relay_debug( DLLSPEC *spec ) @@ -130,7 +130,7 @@ index 07d6eed05fc..36645aef417 100644 { const unsigned int page_size = get_page_size(); int i; -@@ -488,6 +488,149 @@ static void output_syscall_thunks( DLLSPEC *spec ) +@@ -488,6 +488,146 @@ static void output_syscall_thunks( DLLSPEC *spec ) output_function_size( "__wine_syscall_dispatcher" ); } @@ -184,8 +184,8 @@ index 07d6eed05fc..36645aef417 100644 + output( "\t.byte 0xc3\n" ); /* ret */ + output( "\t.byte 0xeb,0x01\n" ); /* jmp over ret */ + output( "\t.byte 0xc3\n" ); /* ret */ -+ output( "\t.byte 0x65,0x48,0x8b,0x04,0x25,0x30,0x00,0x00,0x00\n" ); /* mov rax, gs:[0x30] */ -+ output( "\t.byte 0xff,0x90,0x00,0x01,0x00,0x00\n" ); /* call qword ptr [rax+0x100] */ ++ output( "\t.byte 0x65,0x4c,0x8b,0x1c,0x25,0x30,0x00,0x00,0x00\n" ); /* mov r11, gs:[0x30] */ ++ output( "\t.byte 0x41,0xff,0x93,0x00,0x01,0x00,0x00\n" ); /* call qword ptr [r11+0x100] */ + /* This RET is never reached, but Legends of Runeterra demands that it + * exist anyway. */ + output( "\t.byte 0xc3\n" ); /* ret */ @@ -234,10 +234,7 @@ index 07d6eed05fc..36645aef417 100644 + + /* Legends of Runeterra hooks the first system call return instruction, and + * depends on us returning to it. Adjust the return address accordingly. */ -+ if (target_platform == PLATFORM_APPLE) -+ output( "\tsubq $0xb,0x8(%%rbp)\n" ); -+ else -+ output( "\tsubq $0xc,0x8(%%rbp)\n" ); ++ output( "\tsubq $0x14,0x8(%%rbp)\n" ); + + /* copy over any arguments on the stack */ + output( "\tleaq 0x38(%%rbp),%%rsi\n" ); @@ -280,7 +277,7 @@ index 07d6eed05fc..36645aef417 100644 /******************************************************************* * output_exports * -@@ -845,7 +988,10 @@ void output_spec32_file( DLLSPEC *spec ) +@@ -845,7 +985,10 @@ void output_spec32_file( DLLSPEC *spec ) open_output_file(); output_standard_file_header(); output_module( spec ); @@ -292,7 +289,7 @@ index 07d6eed05fc..36645aef417 100644 output_stubs( spec ); output_exports( spec ); output_imports( spec ); -@@ -858,7 +1004,7 @@ void output_spec32_file( DLLSPEC *spec ) +@@ -858,7 +1001,7 @@ void output_spec32_file( DLLSPEC *spec ) static int needs_stub_exports( DLLSPEC *spec ) { @@ -301,7 +298,7 @@ index 07d6eed05fc..36645aef417 100644 return 0; if (!(spec->characteristics & IMAGE_FILE_DLL)) return 0; -@@ -868,7 +1014,7 @@ static int needs_stub_exports( DLLSPEC *spec ) +@@ -868,7 +1011,7 @@ static int needs_stub_exports( DLLSPEC *spec ) } @@ -310,7 +307,7 @@ index 07d6eed05fc..36645aef417 100644 { int i, nr_exports = spec->base <= spec->limit ? spec->limit - spec->base + 1 : 0; size_t rva, thunk; -@@ -1026,6 +1172,115 @@ static void create_stub_exports_text( DLLSPEC *spec ) +@@ -1026,6 +1169,116 @@ static void create_stub_exports_text( DLLSPEC *spec ) } @@ -335,10 +332,11 @@ index 07d6eed05fc..36645aef417 100644 + put_byte( 0xc3 ); /* ret */ + put_byte( 0xeb ); put_byte( 0x01 ); /* jmp */ + put_byte( 0xc3 ); /* ret */ -+ put_byte( 0x65 ); put_byte( 0x48 ); put_byte( 0x8b ); /* mov rax, gs:[0x30] */ -+ put_byte( 0x04 ); put_byte( 0x25 ); ++ put_byte( 0x65 ); put_byte( 0x4c ); put_byte( 0x8b ); /* mov r11, gs:[0x30] */ ++ put_byte( 0x1c ); put_byte( 0x25 ); + put_dword( 0x30 ); -+ put_byte( 0xff ); put_byte( 0x90 ); put_dword( 0x100 ); /* call qword ptr [rax+0x100] */ ++ /* call qword ptr [r11+0x100] */ ++ put_byte( 0x41 ); put_byte( 0xff ); put_byte( 0x93 ); put_dword( 0x100 ); + put_byte( 0xc3 ); /* ret */ + } + @@ -426,7 +424,7 @@ index 07d6eed05fc..36645aef417 100644 static void create_stub_exports_data( DLLSPEC *spec ) { int i; -@@ -1225,7 +1480,10 @@ static void output_fake_module_pass( DLLSPEC *spec ) +@@ -1225,7 +1478,10 @@ static void output_fake_module_pass( DLLSPEC *spec ) if (needs_stub_exports( spec )) { put_label( "text_start" ); diff --git a/patches/winebuild-Fake_Dlls/0011-ntdll-Call-NtOpenFile-through-syscall-thunk.patch b/patches/winebuild-Fake_Dlls/0011-ntdll-Call-NtOpenFile-through-syscall-thunk.patch index ea3940f4..6a467db0 100644 --- a/patches/winebuild-Fake_Dlls/0011-ntdll-Call-NtOpenFile-through-syscall-thunk.patch +++ b/patches/winebuild-Fake_Dlls/0011-ntdll-Call-NtOpenFile-through-syscall-thunk.patch @@ -1,4 +1,4 @@ -From cba87bb5a4aea10f9f4c2044db8290479a83f17e Mon Sep 17 00:00:00 2001 +From 05e0803fffd023cbbb4e7c069bb81ae7154db5db Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Fri, 3 Jan 2020 17:39:08 +0300 Subject: [PATCH] ntdll: Call NtOpenFile through syscall thunk. @@ -15,7 +15,7 @@ Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48410 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c -index 1ca14827a79..6f3bc369f82 100644 +index 1ca794ae3e5..b3c13042adc 100644 --- a/dlls/ntdll/actctx.c +++ b/dlls/ntdll/actctx.c @@ -2892,7 +2892,7 @@ static NTSTATUS open_nt_file( HANDLE *handle, UNICODE_STRING *name ) @@ -37,10 +37,10 @@ index 1ca14827a79..6f3bc369f82 100644 { sxs_ai = *ai; diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c -index f02feb8c442..1dcc3d42db7 100644 +index d18df38f626..69607a4fed9 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c -@@ -3010,7 +3010,7 @@ NTSTATUS DIR_get_unix_cwd( char **cwd ) +@@ -2943,7 +2943,7 @@ NTSTATUS DIR_get_unix_cwd( char **cwd ) attr.SecurityDescriptor = NULL; attr.SecurityQualityOfService = NULL; @@ -50,10 +50,10 @@ index f02feb8c442..1dcc3d42db7 100644 RtlFreeUnicodeString( &dirW ); if (status != STATUS_SUCCESS) goto done; diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c -index 8a525c36a74..d964c296243 100644 +index 0b8c28a0651..e48cd84cffd 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c -@@ -2565,7 +2565,7 @@ static NTSTATUS open_dll_file( UNICODE_STRING *nt_name, WINE_MODREF **pwm, +@@ -2469,7 +2469,7 @@ static NTSTATUS open_dll_file( UNICODE_STRING *nt_name, WINE_MODREF **pwm, attr.ObjectName = nt_name; attr.SecurityDescriptor = NULL; attr.SecurityQualityOfService = NULL; @@ -63,10 +63,10 @@ index 8a525c36a74..d964c296243 100644 FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE ))) { diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c -index a28f5d0f580..deab31be66f 100644 +index 0d0c1194d23..a1bf219ed0a 100644 --- a/dlls/ntdll/locale.c +++ b/dlls/ntdll/locale.c -@@ -662,7 +662,7 @@ static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file ) +@@ -661,7 +661,7 @@ static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file ) return STATUS_NO_MEMORY; valueW.Length = NTDLL_swprintf( valueW.Buffer, pathfmtW, dir, name ) * sizeof(WCHAR); InitializeObjectAttributes( &attr, &valueW, 0, 0, NULL ); @@ -75,7 +75,7 @@ index a28f5d0f580..deab31be66f 100644 if (!status) TRACE( "found %s\n", debugstr_w( valueW.Buffer )); RtlFreeUnicodeString( &valueW ); if (status != STATUS_OBJECT_NAME_NOT_FOUND && status != STATUS_OBJECT_PATH_NOT_FOUND) return status; -@@ -686,7 +686,7 @@ static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file ) +@@ -685,7 +685,7 @@ static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file ) wcscat( valueW.Buffer, name ); valueW.Length = wcslen(valueW.Buffer) * sizeof(WCHAR); InitializeObjectAttributes( &attr, &valueW, 0, 0, NULL ); @@ -85,10 +85,10 @@ index a28f5d0f580..deab31be66f 100644 } RtlFreeUnicodeString( &valueW ); diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index 6bb50f8ddd6..75060f6d8e9 100644 +index 2e791b92f73..f8170793185 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h -@@ -348,4 +348,12 @@ static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len ) +@@ -350,4 +350,12 @@ static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len ) while (len--) *dst++ = (unsigned char)*src++; } @@ -115,10 +115,10 @@ index 32e1f951af5..71ae44dd498 100644 if (nts != STATUS_SUCCESS) goto out; diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c -index 1beb4b9341d..55ff4a7da1b 100644 +index 60ee39765bf..70dfe6f768a 100644 --- a/dlls/ntdll/process.c +++ b/dlls/ntdll/process.c -@@ -1395,7 +1395,7 @@ static NTSTATUS get_pe_file_info( UNICODE_STRING *path, ULONG attributes, +@@ -1281,7 +1281,7 @@ static NTSTATUS get_pe_file_info( UNICODE_STRING *path, ULONG attributes, memset( info, 0, sizeof(*info) ); InitializeObjectAttributes( &attr, path, attributes, 0, 0 ); @@ -128,5 +128,5 @@ index 1beb4b9341d..55ff4a7da1b 100644 { BOOL is_64bit; -- -2.26.1 +2.26.2