PKGBUILDS/wine-tkg-git/wine-tkg-git/wine-tkg-patches/game-specific/leagueoflolfix/legacy/leagueoflolfix-b8f0e32.patch

121 lines
4.3 KiB
Diff

diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index abdc0efc51..411abb86d8 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -437,6 +437,8 @@ static wine_signal_handler handlers[256];
extern void DECLSPEC_NORETURN __wine_syscall_dispatcher( void );
extern NTSTATUS WINAPI __syscall_NtGetContextThread( HANDLE handle, CONTEXT *context );
+static int wine_cs;
+
static void* WINAPI __wine_fakedll_dispatcher( const char *module, ULONG ord )
{
UNICODE_STRING name;
@@ -885,7 +887,7 @@ static inline void * SIGNALFUNC init_handler( const ucontext_t *sigcontext, WORD
}
#endif
- if (!wine_ldt_is_system(CS_sig(sigcontext)) ||
+ if ((CS_sig(sigcontext) != wine_cs && !wine_ldt_is_system(CS_sig(sigcontext))) ||
!wine_ldt_is_system(SS_sig(sigcontext))) /* 16-bit mode */
{
/*
@@ -1576,7 +1578,7 @@ static inline DWORD is_privileged_instr( CONTEXT *context )
BYTE instr[16];
unsigned int i, len, prefix_count = 0;
- if (!wine_ldt_is_system( context->SegCs )) return 0;
+ if (context->SegCs != wine_cs && !wine_ldt_is_system( context->SegCs )) return 0;
len = virtual_uninterrupted_read_memory( (BYTE *)context->Eip, instr, sizeof(instr) );
for (i = 0; i < len; i++) switch (instr[i])
@@ -1674,7 +1676,7 @@ static inline BOOL check_invalid_gs( CONTEXT *context )
WORD system_gs = x86_thread_data()->gs;
if (context->SegGs == system_gs) return FALSE;
- if (!wine_ldt_is_system( context->SegCs )) return FALSE;
+ if (context->SegCs != wine_cs && !wine_ldt_is_system( context->SegCs )) return 0;
/* only handle faults in system libraries */
if (virtual_is_valid_code_address( instr, 1 )) return FALSE;
@@ -1916,7 +1918,7 @@ static EXCEPTION_RECORD *setup_exception_record( ucontext_t *sigcontext, void *s
EIP_sig(sigcontext) = (DWORD)func;
/* clear single-step, direction, and align check flag */
EFL_sig(sigcontext) &= ~(0x100|0x400|0x40000);
- CS_sig(sigcontext) = wine_get_cs();
+ CS_sig(sigcontext) = wine_cs;
DS_sig(sigcontext) = wine_get_ds();
ES_sig(sigcontext) = wine_get_es();
FS_sig(sigcontext) = wine_get_fs();
@@ -2394,6 +2396,21 @@ static void ldt_unlock(void)
else RtlLeaveCriticalSection( &ldt_section );
}
+void signal_init_cs(void)
+{
+ LDT_ENTRY entry;
+
+ if (!wine_cs)
+ wine_cs = wine_ldt_alloc_entries( 1 );
+
+ wine_ldt_set_base( &entry, 0 );
+ wine_ldt_set_limit( &entry, (UINT_PTR)-1 );
+ wine_ldt_set_flags( &entry, WINE_LDT_FLAGS_CODE|WINE_LDT_FLAGS_32BIT );
+ wine_ldt_set_entry( wine_cs, &entry );
+
+ wine_set_cs( wine_cs );
+}
+
/**********************************************************************
* signal_alloc_thread
@@ -2433,6 +2450,9 @@ NTSTATUS signal_alloc_thread( TEB **teb )
status = STATUS_TOO_MANY_THREADS;
}
}
+
+ signal_init_cs();
+
return status;
}
diff --git a/include/wine/library.h b/include/wine/library.h
index 7395a117c7..56e749033e 100644
--- a/include/wine/library.h
+++ b/include/wine/library.h
@@ -192,6 +192,7 @@ __DEFINE_SET_SEG(fs)
__DEFINE_SET_SEG(gs)
#undef __DEFINE_GET_SEG
#undef __DEFINE_SET_SEG
+extern void wine_set_cs(unsigned int);
#endif /* __i386__ */
diff --git a/libs/wine/ldt.c b/libs/wine/ldt.c
index b9371814ba..21e9f0528b 100644
--- a/libs/wine/ldt.c
+++ b/libs/wine/ldt.c
@@ -461,6 +461,10 @@ __ASM_GLOBAL_FUNC( wine_get_es, "movw %es,%ax\n\tret" )
__ASM_GLOBAL_FUNC( wine_get_fs, "movw %fs,%ax\n\tret" )
__ASM_GLOBAL_FUNC( wine_get_gs, "movw %gs,%ax\n\tret" )
__ASM_GLOBAL_FUNC( wine_get_ss, "movw %ss,%ax\n\tret" )
+__ASM_GLOBAL_FUNC( wine_set_cs, "movl 4(%esp),%eax\n\t"
+ "xchg 0(%esp),%eax\n\t"
+ "push %eax\n\t"
+ "retf" )
__ASM_GLOBAL_FUNC( wine_set_fs, "movl 4(%esp),%eax\n\tmovw %ax,%fs\n\tret" )
__ASM_GLOBAL_FUNC( wine_set_gs, "movl 4(%esp),%eax\n\tmovw %ax,%gs\n\tret" )
diff --git a/libs/wine/wine.map b/libs/wine/wine.map
index 72ffed80c0..c41f567fb6 100644
--- a/libs/wine/wine.map
+++ b/libs/wine/wine.map
@@ -114,6 +114,7 @@ WINE_1.0
wine_mmap_enum_free_areas;
wine_mmap_is_in_free_area;
wine_mmap_remove_free_area;
+ wine_set_cs;
wine_set_fs;
wine_set_gs;
wine_utf8_mbstowcs;