File alternative_patch_by_using_a_fake_cs_segment.patch of Package wine

--- a/dlls/ntdll/signal_i386.c
+++ a/dlls/ntdll/signal_i386.c
@@ -449,6 +449,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;
+
 /* convert from straight ASCII to Unicode without depending on the current codepage */
 static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len )
 {
@@ -893,7 +895,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 */
     {
         /*
@@ -1587,7 +1589,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])
@@ -1654,7 +1656,7 @@ static inline BOOL check_invalid_gs( ucontext_t *sigcontext, 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 FALSE;
     /* only handle faults in system libraries */
     if (virtual_is_valid_code_address( instr, 1 )) return FALSE;
 
@@ -1937,7 +1939,7 @@ static void setup_raise_exception( ucontext_t *sigcontext, struct stack_layout *
     EIP_sig(sigcontext) = (DWORD)raise_generic_exception;
     /* 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();
@@ -2358,6 +2360,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
@@ -2397,6 +2414,9 @@ NTSTATUS signal_alloc_thread( TEB **teb )
             status = STATUS_TOO_MANY_THREADS;
         }
     }
+
+    signal_init_cs();
+
     return status;
 }
 
--- a/include/wine/library.h
+++ a/include/wine/library.h
@@ -196,6 +196,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__ */
 
--- a/libs/wine/ldt.c
+++ a/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" )
 
--- a/libs/wine/wine.map
+++ a/libs/wine/wine.map
@@ -114,6 +114,7 @@ WINE_1.0
     wine_mmap_remove_reserved_area;
     wine_pthread_get_functions;
     wine_pthread_set_functions;
+    wine_set_cs;
     wine_set_fs;
     wine_set_gs;
     wine_switch_to_stack;