Commit 6e1c296e authored by Alexandre Julliard's avatar Alexandre Julliard

include: Make the CURRENT_STACK16 and CURRENT_DS macros available globally.

parent 97825b9c
...@@ -169,9 +169,6 @@ extern THHOOK *pThhook DECLSPEC_HIDDEN; ...@@ -169,9 +169,6 @@ extern THHOOK *pThhook DECLSPEC_HIDDEN;
(((offset)+(size) <= pModule->mapping_size) ? \ (((offset)+(size) <= pModule->mapping_size) ? \
(memcpy( buffer, (const char *)pModule->mapping + (offset), (size) ), TRUE) : FALSE) (memcpy( buffer, (const char *)pModule->mapping + (offset), (size) ), TRUE) : FALSE)
#define CURRENT_STACK16 ((STACK16FRAME*)MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved)))
#define CURRENT_DS (CURRENT_STACK16->ds)
/* push bytes on the 16-bit stack of a thread; return a segptr to the first pushed byte */ /* push bytes on the 16-bit stack of a thread; return a segptr to the first pushed byte */
static inline SEGPTR stack16_push( int size ) static inline SEGPTR stack16_push( int size )
{ {
......
...@@ -1276,7 +1276,7 @@ void WINAPI __regs_K32Thk1632Epilog( CONTEXT *context ) ...@@ -1276,7 +1276,7 @@ void WINAPI __regs_K32Thk1632Epilog( CONTEXT *context )
if ( code[5] == 0xFF && code[6] == 0x55 && code[7] == 0xFC if ( code[5] == 0xFF && code[6] == 0x55 && code[7] == 0xFC
&& code[13] == 0x66 && code[14] == 0xCB) && code[13] == 0x66 && code[14] == 0xCB)
{ {
STACK16FRAME *frame16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved); STACK16FRAME *frame16 = CURRENT_STACK16;
char *stack16 = (char *)(frame16 + 1); char *stack16 = (char *)(frame16 + 1);
DWORD argSize = frame16->ebp - (DWORD)stack16; DWORD argSize = frame16->ebp - (DWORD)stack16;
char *stack32 = (char *)frame16->frame32 - argSize; char *stack32 = (char *)frame16->frame32 - argSize;
......
...@@ -718,15 +718,15 @@ BOOL16 WINAPI TimerCount16( TIMERINFO *pTimerInfo ) ...@@ -718,15 +718,15 @@ BOOL16 WINAPI TimerCount16( TIMERINFO *pTimerInfo )
*/ */
BOOL16 WINAPI SystemHeapInfo16( SYSHEAPINFO *pHeapInfo ) BOOL16 WINAPI SystemHeapInfo16( SYSHEAPINFO *pHeapInfo )
{ {
STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved); HANDLE16 oldDS = CURRENT_DS;
HANDLE16 oldDS = stack16->ds;
WORD user = LoadLibrary16( "USER.EXE" ); WORD user = LoadLibrary16( "USER.EXE" );
WORD gdi = LoadLibrary16( "GDI.EXE" ); WORD gdi = LoadLibrary16( "GDI.EXE" );
stack16->ds = user;
CURRENT_DS = user;
pHeapInfo->wUserFreePercent = (int)LocalCountFree16() * 100 / LocalHeapSize16(); pHeapInfo->wUserFreePercent = (int)LocalCountFree16() * 100 / LocalHeapSize16();
stack16->ds = gdi; CURRENT_DS = gdi;
pHeapInfo->wGDIFreePercent = (int)LocalCountFree16() * 100 / LocalHeapSize16(); pHeapInfo->wGDIFreePercent = (int)LocalCountFree16() * 100 / LocalHeapSize16();
stack16->ds = oldDS; CURRENT_DS = oldDS;
pHeapInfo->hUserSegment = user; pHeapInfo->hUserSegment = user;
pHeapInfo->hGDISegment = gdi; pHeapInfo->hGDISegment = gdi;
FreeLibrary16( user ); FreeLibrary16( user );
......
...@@ -2092,7 +2092,6 @@ static LRESULT combo_proc16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, ...@@ -2092,7 +2092,6 @@ static LRESULT combo_proc16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
static void edit_lock_buffer( HWND hwnd ) static void edit_lock_buffer( HWND hwnd )
{ {
STACK16FRAME* stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
HLOCAL16 hloc16 = GetWindowWord( hwnd, GWW_HANDLE16 ); HLOCAL16 hloc16 = GetWindowWord( hwnd, GWW_HANDLE16 );
HANDLE16 oldDS; HANDLE16 oldDS;
HLOCAL hloc32; HLOCAL hloc32;
...@@ -2101,8 +2100,8 @@ static void edit_lock_buffer( HWND hwnd ) ...@@ -2101,8 +2100,8 @@ static void edit_lock_buffer( HWND hwnd )
if (!hloc16) return; if (!hloc16) return;
if (!(hloc32 = (HLOCAL)wow_handlers32.edit_proc( hwnd, EM_GETHANDLE, 0, 0, FALSE ))) return; if (!(hloc32 = (HLOCAL)wow_handlers32.edit_proc( hwnd, EM_GETHANDLE, 0, 0, FALSE ))) return;
oldDS = stack16->ds; oldDS = CURRENT_DS;
stack16->ds = GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); CURRENT_DS = GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
size = LocalSize16(hloc16); size = LocalSize16(hloc16);
if (LocalReAlloc( hloc32, size, LMEM_MOVEABLE )) if (LocalReAlloc( hloc32, size, LMEM_MOVEABLE ))
{ {
...@@ -2112,13 +2111,11 @@ static void edit_lock_buffer( HWND hwnd ) ...@@ -2112,13 +2111,11 @@ static void edit_lock_buffer( HWND hwnd )
LocalUnlock( hloc32 ); LocalUnlock( hloc32 );
LocalUnlock16( hloc16 ); LocalUnlock16( hloc16 );
} }
stack16->ds = oldDS; CURRENT_DS = oldDS;
} }
static void edit_unlock_buffer( HWND hwnd ) static void edit_unlock_buffer( HWND hwnd )
{ {
STACK16FRAME* stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
HLOCAL16 hloc16 = GetWindowWord( hwnd, GWW_HANDLE16 ); HLOCAL16 hloc16 = GetWindowWord( hwnd, GWW_HANDLE16 );
HANDLE16 oldDS; HANDLE16 oldDS;
HLOCAL hloc32; HLOCAL hloc32;
...@@ -2128,8 +2125,8 @@ static void edit_unlock_buffer( HWND hwnd ) ...@@ -2128,8 +2125,8 @@ static void edit_unlock_buffer( HWND hwnd )
if (!(hloc32 = (HLOCAL)wow_handlers32.edit_proc( hwnd, EM_GETHANDLE, 0, 0, FALSE ))) return; if (!(hloc32 = (HLOCAL)wow_handlers32.edit_proc( hwnd, EM_GETHANDLE, 0, 0, FALSE ))) return;
size = LocalSize( hloc32 ); size = LocalSize( hloc32 );
oldDS = stack16->ds; oldDS = CURRENT_DS;
stack16->ds = GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); CURRENT_DS = GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
if (LocalReAlloc16( hloc16, size, LMEM_MOVEABLE )) if (LocalReAlloc16( hloc16, size, LMEM_MOVEABLE ))
{ {
char *text = LocalLock( hloc32 ); char *text = LocalLock( hloc32 );
...@@ -2138,7 +2135,7 @@ static void edit_unlock_buffer( HWND hwnd ) ...@@ -2138,7 +2135,7 @@ static void edit_unlock_buffer( HWND hwnd )
LocalUnlock( hloc32 ); LocalUnlock( hloc32 );
LocalUnlock16( hloc16 ); LocalUnlock16( hloc16 );
} }
stack16->ds = oldDS; CURRENT_DS = oldDS;
} }
static HLOCAL16 edit_get_handle( HWND hwnd ) static HLOCAL16 edit_get_handle( HWND hwnd )
...@@ -2146,7 +2143,6 @@ static HLOCAL16 edit_get_handle( HWND hwnd ) ...@@ -2146,7 +2143,6 @@ static HLOCAL16 edit_get_handle( HWND hwnd )
CHAR *textA; CHAR *textA;
UINT alloc_size; UINT alloc_size;
HLOCAL hloc; HLOCAL hloc;
STACK16FRAME* stack16;
HANDLE16 oldDS; HANDLE16 oldDS;
HLOCAL16 hloc16 = GetWindowWord( hwnd, GWW_HANDLE16 ); HLOCAL16 hloc16 = GetWindowWord( hwnd, GWW_HANDLE16 );
...@@ -2155,13 +2151,12 @@ static HLOCAL16 edit_get_handle( HWND hwnd ) ...@@ -2155,13 +2151,12 @@ static HLOCAL16 edit_get_handle( HWND hwnd )
if (!(hloc = (HLOCAL)wow_handlers32.edit_proc( hwnd, EM_GETHANDLE, 0, 0, FALSE ))) return 0; if (!(hloc = (HLOCAL)wow_handlers32.edit_proc( hwnd, EM_GETHANDLE, 0, 0, FALSE ))) return 0;
alloc_size = LocalSize( hloc ); alloc_size = LocalSize( hloc );
stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved)); oldDS = CURRENT_DS;
oldDS = stack16->ds; CURRENT_DS = GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
stack16->ds = GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
if (!LocalHeapSize16()) if (!LocalHeapSize16())
{ {
if (!LocalInit16(stack16->ds, 0, GlobalSize16(stack16->ds))) if (!LocalInit16(CURRENT_DS, 0, GlobalSize16(CURRENT_DS)))
{ {
ERR("could not initialize local heap\n"); ERR("could not initialize local heap\n");
goto done; goto done;
...@@ -2187,15 +2182,14 @@ static HLOCAL16 edit_get_handle( HWND hwnd ) ...@@ -2187,15 +2182,14 @@ static HLOCAL16 edit_get_handle( HWND hwnd )
SetWindowWord( hwnd, GWW_HANDLE16, hloc16 ); SetWindowWord( hwnd, GWW_HANDLE16, hloc16 );
done: done:
stack16->ds = oldDS; CURRENT_DS = oldDS;
return hloc16; return hloc16;
} }
static void edit_set_handle( HWND hwnd, HLOCAL16 hloc16 ) static void edit_set_handle( HWND hwnd, HLOCAL16 hloc16 )
{ {
STACK16FRAME* stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
HINSTANCE16 hInstance = GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); HINSTANCE16 hInstance = GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
HANDLE16 oldDS = stack16->ds; HANDLE16 oldDS = CURRENT_DS;
HLOCAL hloc32; HLOCAL hloc32;
INT count; INT count;
CHAR *text; CHAR *text;
...@@ -2203,7 +2197,7 @@ static void edit_set_handle( HWND hwnd, HLOCAL16 hloc16 ) ...@@ -2203,7 +2197,7 @@ static void edit_set_handle( HWND hwnd, HLOCAL16 hloc16 )
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & ES_MULTILINE)) return; if (!(GetWindowLongW( hwnd, GWL_STYLE ) & ES_MULTILINE)) return;
if (!hloc16) return; if (!hloc16) return;
stack16->ds = hInstance; CURRENT_DS = hInstance;
count = LocalSize16(hloc16); count = LocalSize16(hloc16);
text = MapSL(LocalLock16(hloc16)); text = MapSL(LocalLock16(hloc16));
if ((hloc32 = LocalAlloc(LMEM_MOVEABLE, count))) if ((hloc32 = LocalAlloc(LMEM_MOVEABLE, count)))
...@@ -2213,8 +2207,7 @@ static void edit_set_handle( HWND hwnd, HLOCAL16 hloc16 ) ...@@ -2213,8 +2207,7 @@ static void edit_set_handle( HWND hwnd, HLOCAL16 hloc16 )
LocalUnlock16(hloc16); LocalUnlock16(hloc16);
SetWindowWord( hwnd, GWW_HANDLE16, hloc16 ); SetWindowWord( hwnd, GWW_HANDLE16, hloc16 );
} }
stack16->ds = oldDS; CURRENT_DS = oldDS;
if (hloc32) wow_handlers32.edit_proc( hwnd, EM_SETHANDLE, (WPARAM)hloc32, 0, FALSE ); if (hloc32) wow_handlers32.edit_proc( hwnd, EM_SETHANDLE, (WPARAM)hloc32, 0, FALSE );
} }
...@@ -2223,13 +2216,12 @@ static void edit_destroy_handle( HWND hwnd ) ...@@ -2223,13 +2216,12 @@ static void edit_destroy_handle( HWND hwnd )
HLOCAL16 hloc16 = GetWindowWord( hwnd, GWW_HANDLE16 ); HLOCAL16 hloc16 = GetWindowWord( hwnd, GWW_HANDLE16 );
if (hloc16) if (hloc16)
{ {
STACK16FRAME* stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved)); HANDLE16 oldDS = CURRENT_DS;
HANDLE16 oldDS = stack16->ds;
stack16->ds = GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); CURRENT_DS = GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
while (LocalUnlock16(hloc16)) ; while (LocalUnlock16(hloc16)) ;
LocalFree16(hloc16); LocalFree16(hloc16);
stack16->ds = oldDS; CURRENT_DS = oldDS;
SetWindowWord( hwnd, GWW_HANDLE16, 0 ); SetWindowWord( hwnd, GWW_HANDLE16, 0 );
} }
} }
......
...@@ -1394,11 +1394,10 @@ DWORD WINAPI GetTabbedTextExtent16( HDC16 hdc, LPCSTR lpstr, INT16 count, ...@@ -1394,11 +1394,10 @@ DWORD WINAPI GetTabbedTextExtent16( HDC16 hdc, LPCSTR lpstr, INT16 count,
*/ */
DWORD WINAPI UserSeeUserDo16(WORD wReqType, WORD wParam1, WORD wParam2, WORD wParam3) DWORD WINAPI UserSeeUserDo16(WORD wReqType, WORD wParam1, WORD wParam2, WORD wParam3)
{ {
STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved); HANDLE16 oldDS = CURRENT_DS;
HANDLE16 oldDS = stack16->ds;
DWORD ret = (DWORD)-1; DWORD ret = (DWORD)-1;
stack16->ds = USER_HeapSel; CURRENT_DS = USER_HeapSel;
switch (wReqType) switch (wReqType)
{ {
case USUD_LOCALALLOC: case USUD_LOCALALLOC:
...@@ -1419,7 +1418,7 @@ DWORD WINAPI UserSeeUserDo16(WORD wReqType, WORD wParam1, WORD wParam2, WORD wPa ...@@ -1419,7 +1418,7 @@ DWORD WINAPI UserSeeUserDo16(WORD wReqType, WORD wParam1, WORD wParam2, WORD wPa
default: default:
WARN("wReqType %04x (unknown)\n", wReqType); WARN("wReqType %04x (unknown)\n", wReqType);
} }
stack16->ds = oldDS; CURRENT_DS = oldDS;
return ret; return ret;
} }
...@@ -1787,32 +1786,31 @@ UINT16 WINAPI RealizePalette16( HDC16 hdc ) ...@@ -1787,32 +1786,31 @@ UINT16 WINAPI RealizePalette16( HDC16 hdc )
*/ */
WORD WINAPI GetFreeSystemResources16( WORD resType ) WORD WINAPI GetFreeSystemResources16( WORD resType )
{ {
STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved); HANDLE16 oldDS = CURRENT_DS;
HANDLE16 oldDS = stack16->ds;
int userPercent, gdiPercent; int userPercent, gdiPercent;
switch(resType) switch(resType)
{ {
case GFSR_USERRESOURCES: case GFSR_USERRESOURCES:
stack16->ds = USER_HeapSel; CURRENT_DS = USER_HeapSel;
userPercent = (int)LocalCountFree16() * 100 / LocalHeapSize16(); userPercent = (int)LocalCountFree16() * 100 / LocalHeapSize16();
gdiPercent = 100; gdiPercent = 100;
stack16->ds = oldDS; CURRENT_DS = oldDS;
break; break;
case GFSR_GDIRESOURCES: case GFSR_GDIRESOURCES:
stack16->ds = gdi_inst; CURRENT_DS = gdi_inst;
gdiPercent = (int)LocalCountFree16() * 100 / LocalHeapSize16(); gdiPercent = (int)LocalCountFree16() * 100 / LocalHeapSize16();
userPercent = 100; userPercent = 100;
stack16->ds = oldDS; CURRENT_DS = oldDS;
break; break;
case GFSR_SYSTEMRESOURCES: case GFSR_SYSTEMRESOURCES:
stack16->ds = USER_HeapSel; CURRENT_DS = USER_HeapSel;
userPercent = (int)LocalCountFree16() * 100 / LocalHeapSize16(); userPercent = (int)LocalCountFree16() * 100 / LocalHeapSize16();
stack16->ds = gdi_inst; CURRENT_DS = gdi_inst;
gdiPercent = (int)LocalCountFree16() * 100 / LocalHeapSize16(); gdiPercent = (int)LocalCountFree16() * 100 / LocalHeapSize16();
stack16->ds = oldDS; CURRENT_DS = oldDS;
break; break;
default: default:
......
...@@ -456,8 +456,7 @@ HWND16 WINAPI GetParent16( HWND16 hwnd ) ...@@ -456,8 +456,7 @@ HWND16 WINAPI GetParent16( HWND16 hwnd )
*/ */
BOOL16 WINAPI IsWindow16( HWND16 hwnd ) BOOL16 WINAPI IsWindow16( HWND16 hwnd )
{ {
STACK16FRAME *frame = MapSL( (SEGPTR)NtCurrentTeb()->WOW32Reserved ); CURRENT_STACK16->es = USER_HeapSel;
frame->es = USER_HeapSel;
/* don't use WIN_Handle32 here, we don't care about the full handle */ /* don't use WIN_Handle32 here, we don't care about the full handle */
return IsWindow( HWND_32(hwnd) ); return IsWindow( HWND_32(hwnd) );
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <windef.h> #include <windef.h>
#include <winbase.h> #include <winbase.h>
#include <winnls.h> #include <winnls.h>
#include <winternl.h>
#include <wine/windef16.h> #include <wine/windef16.h>
#include <pshpack1.h> #include <pshpack1.h>
...@@ -561,4 +562,7 @@ BOOL16 WINAPI WritePrivateProfileSection16(LPCSTR,LPCSTR,LPCSTR); ...@@ -561,4 +562,7 @@ BOOL16 WINAPI WritePrivateProfileSection16(LPCSTR,LPCSTR,LPCSTR);
BOOL16 WINAPI WritePrivateProfileStruct16(LPCSTR,LPCSTR,LPVOID,UINT16,LPCSTR); BOOL16 WINAPI WritePrivateProfileStruct16(LPCSTR,LPCSTR,LPVOID,UINT16,LPCSTR);
BOOL16 WINAPI WriteProfileSection16(LPCSTR,LPCSTR); BOOL16 WINAPI WriteProfileSection16(LPCSTR,LPCSTR);
#define CURRENT_STACK16 ((STACK16FRAME *)MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved))
#define CURRENT_DS (CURRENT_STACK16->ds)
#endif /* __WINE_WINE_WINBASE16_H */ #endif /* __WINE_WINE_WINBASE16_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment