From 916f975624ba4b69ea988397cdee5811939a6518 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 26 Feb 2000 16:51:13 +0000 Subject: [PATCH] Improved the selector get/set functions. Support ANSI-compatible inline asm (with the help of Patrik Stridvall). --- controls/edit.c | 1 + controls/listbox.c | 1 + debugger/registers.c | 4 +-- dlls/ntdll/signal_i386.c | 13 +++++----- if1632/snoop.c | 4 +-- if1632/thunk.c | 9 +++---- include/selectors.h | 37 ++++++++++++++------------- include/thread.h | 1 - include/winnt.h | 55 ++++++++++++++++++++++------------------ loader/main.c | 8 +++--- memory/selector.c | 33 +++++++++++++----------- misc/w32scomb.c | 3 +-- msdos/dpmi.c | 2 +- relay32/relay386.c | 6 ++--- scheduler/sysdeps.c | 22 ++++++++-------- scheduler/syslevel.c | 3 ++- tools/build.c | 15 ++++++++--- win32/kernel32.c | 2 +- windows/message.c | 1 + windows/winproc.c | 2 +- 20 files changed, 121 insertions(+), 101 deletions(-) diff --git a/controls/edit.c b/controls/edit.c index 557192ea243..25ea9d4c070 100644 --- a/controls/edit.c +++ b/controls/edit.c @@ -19,6 +19,7 @@ #include "wine/winbase16.h" #include "combo.h" #include "local.h" +#include "selectors.h" #include "debugtools.h" #include "callback.h" #include "tweak.h" diff --git a/controls/listbox.c b/controls/listbox.c index 3a1ea7b1469..863b2565ef9 100644 --- a/controls/listbox.c +++ b/controls/listbox.c @@ -16,6 +16,7 @@ #include "drive.h" #include "heap.h" #include "spy.h" +#include "selectors.h" #include "win.h" #include "combo.h" #include "debugtools.h" diff --git a/debugger/registers.c b/debugger/registers.c index 4ec7b28fd36..65f953af331 100644 --- a/debugger/registers.c +++ b/debugger/registers.c @@ -257,8 +257,8 @@ BOOL DEBUG_ValidateRegisters(void) return FALSE; \ } - GET_CS(cs); - GET_DS(ds); + cs = __get_cs(); + ds = __get_ds(); if (CS_reg(&DEBUG_context) != cs) CHECK_SEG(CS_reg(&DEBUG_context), "CS"); if (SS_reg(&DEBUG_context) != ds) CHECK_SEG(SS_reg(&DEBUG_context), "SS"); if (DS_reg(&DEBUG_context) != ds) CHECK_SEG(DS_reg(&DEBUG_context), "DS"); diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index 8454fec9ae5..5cceeba6f52 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -25,6 +25,8 @@ # endif #endif +#include "selectors.h" + /*********************************************************************** * signal context platform-specific definitions */ @@ -309,13 +311,13 @@ static inline void handler_init( CONTEXT *context, const SIGCONTEXT *sigcontext #ifdef FS_sig fs = FS_sig(sigcontext); #else - GET_FS(fs); + fs = __get_fs(); #endif context->SegFs = fs; /* now restore a proper %fs for the fault handler */ if (!IS_SELECTOR_SYSTEM(CS_sig(sigcontext))) fs = SYSLEVEL_Win16CurrentTeb; if (!fs) fs = SYSLEVEL_EmergencyTeb; - SET_FS(fs); + __set_fs(fs); } /*********************************************************************** @@ -357,8 +359,7 @@ static void save_context( CONTEXT *context, const SIGCONTEXT *sigcontext ) #ifdef GS_sig context->SegGs = LOWORD(GS_sig(sigcontext)); #else - GET_GS( context->SegGs ); - context->SegGs &= 0xffff; + context->SegGs = __get_gs(); #endif if (ISV86(context)) V86BASE(context) = (DWORD)DOSMEM_MemoryBase(0); } @@ -388,12 +389,12 @@ static void restore_context( const CONTEXT *context, SIGCONTEXT *sigcontext ) #ifdef FS_sig FS_sig(sigcontext) = context->SegFs; #else - SET_FS( context->SegFs ); + __set_fs( context->SegFs ); #endif #ifdef GS_sig GS_sig(sigcontext) = context->SegGs; #else - SET_GS( context->SegGs ); + __set_gs( context->SegGs ); #endif } diff --git a/if1632/snoop.c b/if1632/snoop.c index c49667aac42..0558b511105 100644 --- a/if1632/snoop.c +++ b/if1632/snoop.c @@ -100,7 +100,7 @@ SNOOP16_RegisterDLL(NE_MODULE *pModule,LPCSTR name) { snr[0].realfun = (DWORD)SNOOP16_Entry; snr[0].lcall = 0x9a; snr[0].callfromregs = (DWORD)CallFrom16Register; - GET_CS(snr[0].seg); + snr[0].seg = __get_cs(); snr[0].lret = 0xcb66; snr[1].pushbp = 0x5566; @@ -110,7 +110,7 @@ SNOOP16_RegisterDLL(NE_MODULE *pModule,LPCSTR name) { snr[1].realfun = (DWORD)SNOOP16_Return; snr[1].lcall = 0x9a; snr[1].callfromregs = (DWORD)CallFrom16Register; - GET_CS(snr[1].seg); + snr[1].seg = __get_cs(); snr[1].lret = 0xcb66; } while (*dll) { diff --git a/if1632/thunk.c b/if1632/thunk.c index 60da112f972..c4004ae8d93 100644 --- a/if1632/thunk.c +++ b/if1632/thunk.c @@ -19,6 +19,7 @@ #include "win.h" #include "flatthunk.h" #include "mouse.h" +#include "selectors.h" #include "keyboard.h" #include "debugtools.h" @@ -498,9 +499,8 @@ UINT WINAPI ThunkConnect16( void WINAPI C16ThkSL(CONTEXT86 *context) { LPBYTE stub = PTR_SEG_TO_LIN(EAX_reg(context)), x = stub; - WORD cs, ds; - GET_CS(cs); - GET_DS(ds); + WORD cs = __get_cs(); + WORD ds = __get_ds(); /* We produce the following code: * @@ -551,8 +551,7 @@ void WINAPI C16ThkSL01(CONTEXT86 *context) struct ThunkDataSL *td = SL16->fpData; DWORD procAddress = (DWORD)GetProcAddress16(GetModuleHandle16("KERNEL"), 631); - WORD cs; - GET_CS(cs); + WORD cs = __get_cs(); if (!td) { diff --git a/include/selectors.h b/include/selectors.h index dcc0132a7dd..fa2fb1d2311 100644 --- a/include/selectors.h +++ b/include/selectors.h @@ -18,25 +18,28 @@ extern void SELECTOR_MoveBlock( WORD sel, const void *new_base ); extern void SELECTOR_FreeBlock( WORD sel, WORD count ); #ifdef __i386__ -# define __GET_SEG(seg,res) __asm__( "movw %%" seg ",%w0" : "=r" (res) ) -# define __SET_SEG(seg,val) __asm__( "movw %w0,%%" seg : : "r" (val) ) +# ifdef __GNUC__ +# define __DEFINE_GET_SEG(seg) \ + extern inline unsigned short __get_##seg(void) \ + { unsigned short res; __asm__("movw %%" #seg ",%w0" : "=r"(res)); return res; } +# define __DEFINE_SET_SEG(seg) \ + extern inline void __set_##seg(int val) { __asm__("movl %0,%%" #seg : : "r" (val)); } +# else /* __GNUC__ */ +# define __DEFINE_GET_SEG(seg) extern unsigned short __get_##seg(void); +# define __DEFINE_SET_SEG(seg) extern void __set_##seg(unsigned int); +# endif /* __GNUC__ */ #else /* __i386__ */ -# define __GET_SEG(seg,res) ((res) = 0) -# define __SET_SEG(seg,val) /* nothing */ +# define __DEFINE_GET_SEG(seg) static inline unsigned short __get_##seg(void) { return 0; } +# define __DEFINE_SET_SEG(seg) /* nothing */ #endif /* __i386__ */ -#define GET_CS(cs) __GET_SEG("cs",cs) -#define GET_DS(ds) __GET_SEG("ds",ds) -#define GET_ES(es) __GET_SEG("es",es) -#define GET_FS(fs) __GET_SEG("fs",fs) -#define GET_GS(gs) __GET_SEG("gs",gs) -#define GET_SS(ss) __GET_SEG("ss",ss) - -#define SET_CS(cs) __SET_SEG("cs",cs) -#define SET_DS(ds) __SET_SEG("ds",ds) -#define SET_ES(es) __SET_SEG("es",es) -#define SET_FS(fs) __SET_SEG("fs",fs) -#define SET_GS(gs) __SET_SEG("gs",gs) -#define SET_SS(ss) __SET_SEG("ss",ss) +__DEFINE_GET_SEG(cs) +__DEFINE_GET_SEG(ds) +__DEFINE_GET_SEG(es) +__DEFINE_GET_SEG(fs) +__DEFINE_GET_SEG(gs) +__DEFINE_GET_SEG(ss) +__DEFINE_SET_SEG(fs) +__DEFINE_SET_SEG(gs) #endif /* __WINE_SELECTORS_H */ diff --git a/include/thread.h b/include/thread.h index 70c82c42898..6dd0c25737b 100644 --- a/include/thread.h +++ b/include/thread.h @@ -10,7 +10,6 @@ #include "config.h" #include "winbase.h" #include "syslevel.h" -#include "selectors.h" /* for SET_FS */ #include "ntdef.h" /* UNICODE_STRING */ struct _PDB; diff --git a/include/winnt.h b/include/winnt.h index 305cc0f7a11..f22e81b2cb3 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -671,15 +671,36 @@ typedef HANDLE *PHANDLE; /* Macros to retrieve the current context */ #ifdef __i386__ -#define _DEFINE_REGS_ENTRYPOINT( name, fn, args ) \ - __asm__(".align 4\n\t" \ - ".globl " #name "\n\t" \ - ".type " #name ",@function\n\t" \ - #name ":\n\t" \ - "call CALL32_Regs\n\t" \ - ".long " #fn "\n\t" \ - ".byte " #args ", " #args "\n\t"); +#ifdef NEED_UNDERSCORE_PREFIX +# define __ASM_NAME(name) "_" name +#else +# define __ASM_NAME(name) name +#endif + +#ifdef __GNUC__ +# define __ASM_GLOBAL_FUNC(name,code) \ + __asm__( ".align 4\n\t" \ + ".globl " __ASM_NAME(#name) "\n\t" \ + ".type " __ASM_NAME(#name) ",@function\n" \ + __ASM_NAME(#name) ":\n\t" \ + code ); +#else /* __GNUC__ */ +# define __ASM_GLOBAL_FUNC(name,code) \ + void __asm_dummy_##name(void) { \ + asm( ".align 4\n\t" \ + ".globl " __ASM_NAME(#name) "\n\t" \ + ".type " __ASM_NAME(#name) ",@function\n" \ + __ASM_NAME(#name) ":\n\t" \ + code ); \ + } +#endif /* __GNUC__ */ + +#define _DEFINE_REGS_ENTRYPOINT( name, fn, args ) \ + __ASM_GLOBAL_FUNC( name, \ + "call " __ASM_NAME("CALL32_Regs") "\n\t" \ + ".long " __ASM_NAME(#fn) "\n\t" \ + ".byte " #args ", " #args ) #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \ _DEFINE_REGS_ENTRYPOINT( name, fn, 0 ) #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \ @@ -1046,28 +1067,14 @@ typedef struct _NT_TIB struct _TEB; -#ifdef __WINE__ - -#if defined(__i386__) -static inline struct _TEB * WINE_UNUSED __get_teb(void) +#if defined(__i386__) && defined(__GNUC__) +extern inline struct _TEB * WINAPI NtCurrentTeb(void) { struct _TEB *teb; __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb)); return teb; } -#elif defined(HAVE__LWP_CREATE) -extern void *_lwp_getprivate(void); -static inline struct _TEB * WINE_UNUSED __get_teb(void) -{ - return (struct _TEB *)_lwp_getprivate(); -} #else -#error NtCurrentTeb() not defined for this architecture! -#endif - -#define NtCurrentTeb() __get_teb() - -#else /* __WINE__ */ extern struct _TEB * WINAPI NtCurrentTeb(void); #endif diff --git a/loader/main.c b/loader/main.c index b2457f3a632..8439b3f8566 100644 --- a/loader/main.c +++ b/loader/main.c @@ -45,6 +45,7 @@ #include "syslevel.h" #include "services.h" #include "winsock.h" +#include "selectors.h" #include "thread.h" #include "task.h" #include "debugtools.h" @@ -129,15 +130,12 @@ BOOL WINAPI MAIN_KernelInit(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReser hModule = GetModuleHandle16( "KERNEL" ); if ( hModule ) { - WORD cs, ds; - /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */ NE_SetEntryPoint( hModule, 178, GetWinFlags16() ); /* Initialize KERNEL.454/455 (__FLATCS/__FLATDS) */ - GET_CS(cs); GET_DS(ds); - NE_SetEntryPoint( hModule, 454, cs ); - NE_SetEntryPoint( hModule, 455, ds ); + NE_SetEntryPoint( hModule, 454, __get_cs() ); + NE_SetEntryPoint( hModule, 455, __get_ds() ); /* Initialize KERNEL.THHOOK */ TASK_InstallTHHook((THHOOK *)PTR_SEG_TO_LIN( diff --git a/memory/selector.c b/memory/selector.c index e52c3980d33..5c5816654a8 100644 --- a/memory/selector.c +++ b/memory/selector.c @@ -176,16 +176,12 @@ void SELECTOR_FreeBlock( WORD sel, WORD count ) #ifdef __i386__ { /* Check if we are freeing current %fs or %gs selector */ - - WORD fs, gs; - GET_FS(fs); - if ((fs >= sel) && (fs < nextsel)) + if ((__get_fs() >= sel) && (__get_fs() < nextsel)) { - WARN("Freeing %%fs selector (%04x), not good.\n", fs ); - SET_FS( 0 ); + WARN("Freeing %%fs selector (%04x), not good.\n", __get_fs() ); + __set_fs( 0 ); } - GET_GS(gs); - if ((gs >= sel) && (gs < nextsel)) SET_GS( 0 ); + if ((__get_gs() >= sel) && (__get_gs() < nextsel)) __set_gs( 0 ); } #endif /* __i386__ */ @@ -614,7 +610,6 @@ BOOL WINAPI GetThreadSelectorEntry( HANDLE hthread, DWORD sel, LPLDT_ENTRY ldten if (!(sel & 4)) /* GDT selector */ { - WORD seg; sel &= ~3; /* ignore RPL */ if (!sel) /* null selector */ { @@ -633,12 +628,9 @@ BOOL WINAPI GetThreadSelectorEntry( HANDLE hthread, DWORD sel, LPLDT_ENTRY ldten ldtent->HighWord.Bits.Default_Big = 1; ldtent->HighWord.Bits.Type = 0x12; /* it has to be one of the system GDT selectors */ - GET_DS(seg); - if (sel == (seg & ~3)) return TRUE; - GET_SS(seg); - if (sel == (seg & ~3)) return TRUE; - GET_CS(seg); - if (sel == (seg & ~3)) + if (sel == (__get_ds() & ~3)) return TRUE; + if (sel == (__get_ss() & ~3)) return TRUE; + if (sel == (__get_cs() & ~3)) { ldtent->HighWord.Bits.Type |= 8; /* code segment */ return TRUE; @@ -826,3 +818,14 @@ SEGPTR WINAPI UTLinearToSelectorOffset16(LPVOID lptr) { return (SEGPTR)lptr; } + +#ifdef __i386__ +__ASM_GLOBAL_FUNC( __get_cs, "movl %cs,%eax\n\tret" ); +__ASM_GLOBAL_FUNC( __get_ds, "movl %ds,%eax\n\tret" ); +__ASM_GLOBAL_FUNC( __get_es, "movl %es,%eax\n\tret" ); +__ASM_GLOBAL_FUNC( __get_fs, "movl %fs,%eax\n\tret" ); +__ASM_GLOBAL_FUNC( __get_gs, "movl %gs,%eax\n\tret" ); +__ASM_GLOBAL_FUNC( __get_ss, "movl %ss,%eax\n\tret" ); +__ASM_GLOBAL_FUNC( __set_fs, "movl 4(%esp),%eax\n\tmovl %eax,%fs\n\tret" ); +__ASM_GLOBAL_FUNC( __set_gs, "movl 4(%esp),%eax\n\tmovl %eax,%gs\n\tret" ); +#endif diff --git a/misc/w32scomb.c b/misc/w32scomb.c index a98ebd579b8..5ceb14595f9 100644 --- a/misc/w32scomb.c +++ b/misc/w32scomb.c @@ -28,7 +28,6 @@ SEGPTR WINAPI Get16DLLAddress(HMODULE handle, LPSTR func_name) { LPVOID tmpheap = HeapAlloc(ThunkHeap, 0, 32); SEGPTR thunk = HEAP_GetSegptr(ThunkHeap, 0, tmpheap); DWORD proc_16; - WORD cs; if (!handle) handle=GetModuleHandle16("WIN32S16"); proc_16 = (DWORD)WIN32_GetProcAddress16(handle, func_name); @@ -36,6 +35,6 @@ SEGPTR WINAPI Get16DLLAddress(HMODULE handle, LPSTR func_name) { x=PTR_SEG_TO_LIN(thunk); *x++=0xba; *(DWORD*)x=proc_16;x+=4; /* movl proc_16, $edx */ *x++=0xea; *(DWORD*)x=(DWORD)GetProcAddress(GetModuleHandleA("KERNEL32"),"QT_Thunk");x+=4; /* jmpl QT_Thunk */ - GET_CS(cs); *(WORD*)x=(WORD)cs; + *(WORD*)x=__get_cs(); return thunk; } diff --git a/msdos/dpmi.c b/msdos/dpmi.c index cd7819b8e67..f64fd933c47 100644 --- a/msdos/dpmi.c +++ b/msdos/dpmi.c @@ -495,7 +495,7 @@ static RMCB *DPMI_AllocRMCB( void ) *p++ = 0x9a; /* lcall */ *(FARPROC16 *)p = (FARPROC16)RMCallbackProc; /* FIXME: register relay */ p+=4; - GET_CS(*(WORD *)p); + *(WORD *)p = __get_cs(); p+=2; *p++=0xc3; /* lret (FIXME?) */ #endif diff --git a/relay32/relay386.c b/relay32/relay386.c index 8248699ae49..53ccb383b30 100644 --- a/relay32/relay386.c +++ b/relay32/relay386.c @@ -100,7 +100,6 @@ int RELAY_CallFrom32( int ret_addr, ... ) char buffer[80]; unsigned int typemask; FARPROC func; - WORD fs; int *args = &ret_addr + 1; /* Relay addr is the return address for this function */ @@ -111,8 +110,7 @@ int RELAY_CallFrom32( int ret_addr, ... ) func = (FARPROC)BUILTIN32_GetEntryPoint( buffer, relay_addr - 5, &typemask ); DPRINTF( "Call %s(", buffer ); RELAY_PrintArgs( args, nb_args, typemask ); - GET_FS( fs ); - DPRINTF( ") ret=%08x fs=%04x\n", ret_addr, fs ); + DPRINTF( ") ret=%08x fs=%04x\n", ret_addr, __get_fs() ); SYSLEVEL_CheckNotLevel( 2 ); @@ -202,7 +200,7 @@ int RELAY_CallFrom32( int ret_addr, ... ) } } DPRINTF( "Ret %s() retval=%08x ret=%08x fs=%04x\n", - buffer, ret, ret_addr, fs ); + buffer, ret, ret_addr, __get_fs() ); SYSLEVEL_CheckNotLevel( 2 ); diff --git a/scheduler/sysdeps.c b/scheduler/sysdeps.c index ab3f6d97a52..684357b0f03 100644 --- a/scheduler/sysdeps.c +++ b/scheduler/sysdeps.c @@ -27,6 +27,7 @@ static int *ph_errno = &h_errno; #endif #include "wine/port.h" #include "thread.h" +#include "selectors.h" #include "server.h" #include "winbase.h" #include "wine/exception.h" @@ -108,7 +109,7 @@ void SYSDEPS_SetCurThread( TEB *teb ) { #if defined(__i386__) /* On the i386, the current thread is in the %fs register */ - SET_FS( teb->teb_sel ); + __set_fs( teb->teb_sel ); #elif defined(HAVE__LWP_CREATE) /* On non-i386 Solaris, we use the LWP private pointer */ _lwp_setprivate( teb ); @@ -206,10 +207,9 @@ int SYSDEPS_SpawnThread( TEB *teb ) */ void SYSDEPS_ExitThread(void) { -#ifdef HAVE__LWP_CREATE +#if !defined(__i386__) && defined(HAVE__LWP_CREATE) _lwp_exit(); #endif - _exit( 0 ); } @@ -219,14 +219,14 @@ void SYSDEPS_ExitThread(void) * * This will crash and burn if called before threading is initialized */ - -/* if it was defined as a macro, we need to do some magic */ -#ifdef NtCurrentTeb -#undef NtCurrentTeb -#endif - +#ifdef __i386__ +__ASM_GLOBAL_FUNC( NtCurrentTeb, ".byte 0x64\n\tmovl 0x18,%eax\n\tret" ); +#elif defined(HAVE__LWP_CREATE) struct _TEB * WINAPI NtCurrentTeb(void) { - return __get_teb(); + extern void *_lwp_getprivate(void); + return (struct _TEB *)_lwp_getprivate(); } - +#else +# error NtCurrentTeb not defined for this architecture +#endif /* __i386__ */ diff --git a/scheduler/syslevel.c b/scheduler/syslevel.c index aeb3692c734..ea677bc0c59 100644 --- a/scheduler/syslevel.c +++ b/scheduler/syslevel.c @@ -8,6 +8,7 @@ #include #include "syslevel.h" #include "heap.h" +#include "selectors.h" #include "stackframe.h" #include "debugtools.h" @@ -94,7 +95,7 @@ VOID WINAPI _EnterSysLevel(SYSLEVEL *lock) teb->sys_count[lock->level] ); if (lock == &Win16Mutex) - GET_FS( SYSLEVEL_Win16CurrentTeb ); + SYSLEVEL_Win16CurrentTeb = __get_fs(); } /************************************************************************ diff --git a/tools/build.c b/tools/build.c index 835ad88224c..6228a423113 100644 --- a/tools/build.c +++ b/tools/build.c @@ -20,7 +20,6 @@ #include "winnt.h" #include "module.h" #include "neexe.h" -#include "selectors.h" #include "stackframe.h" #include "builtin16.h" #include "thread.h" @@ -43,6 +42,16 @@ # undef USE_STABS #endif +#ifdef __i386__ +extern WORD __get_cs(void); +extern WORD __get_ds(void); +__ASM_GLOBAL_FUNC( __get_cs, "movl %cs,%eax\n\tret" ); +__ASM_GLOBAL_FUNC( __get_ds, "movl %ds,%eax\n\tret" ); +#else +static inline WORD __get_cs(void) { return 0; } +static inline WORD __get_ds(void) { return 0; } +#endif + typedef enum { TYPE_BYTE, /* byte variable (Win16) */ @@ -3182,8 +3191,8 @@ int main(int argc, char **argv) * the asm files on the platform that will also run them. Probably * a safe assumption to make. */ - GET_CS( Code_Selector ); - GET_DS( Data_Selector ); + Code_Selector = __get_cs(); + Data_Selector = __get_ds(); if (!strcmp( argv[1], "-spec" )) BuildSpecFile( outfile, open_input( argv[2] ) ); else if (!strcmp( argv[1], "-glue" )) BuildGlue( outfile, open_input( argv[2] ) ); diff --git a/win32/kernel32.c b/win32/kernel32.c index 654bfd13438..c8e8fbe277f 100644 --- a/win32/kernel32.c +++ b/win32/kernel32.c @@ -968,7 +968,7 @@ FreeSLCallback( */ void WINAPI GetTEBSelectorFS16(void) { - GET_FS( CURRENT_STACK16->fs ); + CURRENT_STACK16->fs = __get_fs(); } /********************************************************************** diff --git a/windows/message.c b/windows/message.c index 2337bca8224..10500752031 100644 --- a/windows/message.c +++ b/windows/message.c @@ -24,6 +24,7 @@ #include "winproc.h" #include "task.h" #include "process.h" +#include "selectors.h" #include "thread.h" #include "options.h" #include "struct32.h" diff --git a/windows/winproc.c b/windows/winproc.c index 354ee62433a..861e8eb1eab 100644 --- a/windows/winproc.c +++ b/windows/winproc.c @@ -301,7 +301,7 @@ static WINDOWPROC *WINPROC_AllocWinProc( WNDPROC16 func, WINDOWPROCTYPE type, (void(*)())WINPROC_Thunk16To32W; proc->thunk.t_from16.lcall = 0x9a; /* lcall cs:glue */ proc->thunk.t_from16.glue = (void*)CallFrom16Long; - GET_CS(proc->thunk.t_from16.cs); + proc->thunk.t_from16.cs = __get_cs(); proc->thunk.t_from16.lret = 0xca66; proc->thunk.t_from16.nArgs = 10; proc->jmp.jmp = 0xe9;