krnl386: Move the 16-bit stack out of the WOW32Reserved field.
Based on a patch by Sebastian Lackner. Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f87262ea99
commit
b636f9816f
|
@ -213,16 +213,16 @@ static BOOL i386_stack_walk(struct cpu_stack_walk *csw, STACKFRAME64 *frame,
|
||||||
/* Init done */
|
/* Init done */
|
||||||
set_curr_mode((frame->AddrPC.Mode == AddrModeFlat) ? stm_32bit : stm_16bit);
|
set_curr_mode((frame->AddrPC.Mode == AddrModeFlat) ? stm_32bit : stm_16bit);
|
||||||
|
|
||||||
/* cur_switch holds address of WOW32Reserved field in TEB in debuggee
|
/* cur_switch holds address of SystemReserved1[0] field in TEB in debuggee
|
||||||
* address space
|
* address space
|
||||||
*/
|
*/
|
||||||
if (NtQueryInformationThread(csw->hThread, ThreadBasicInformation, &info,
|
if (NtQueryInformationThread(csw->hThread, ThreadBasicInformation, &info,
|
||||||
sizeof(info), NULL) == STATUS_SUCCESS)
|
sizeof(info), NULL) == STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
curr_switch = (DWORD_PTR)info.TebBaseAddress + FIELD_OFFSET(TEB, WOW32Reserved);
|
curr_switch = (DWORD_PTR)info.TebBaseAddress + FIELD_OFFSET(TEB, SystemReserved1);
|
||||||
if (!sw_read_mem(csw, curr_switch, &p, sizeof(p)))
|
if (!sw_read_mem(csw, curr_switch, &p, sizeof(p)))
|
||||||
{
|
{
|
||||||
WARN("Can't read TEB:WOW32Reserved\n");
|
WARN("Can't read TEB:SystemReserved1\n");
|
||||||
goto done_err;
|
goto done_err;
|
||||||
}
|
}
|
||||||
next_switch = p;
|
next_switch = p;
|
||||||
|
|
|
@ -298,6 +298,7 @@ struct tagSYSLEVEL;
|
||||||
|
|
||||||
struct kernel_thread_data
|
struct kernel_thread_data
|
||||||
{
|
{
|
||||||
|
SEGPTR stack; /* 16-bit stack pointer */
|
||||||
WORD stack_sel; /* 16-bit stack selector */
|
WORD stack_sel; /* 16-bit stack selector */
|
||||||
WORD htask16; /* Win16 task handle */
|
WORD htask16; /* Win16 task handle */
|
||||||
DWORD sys_count[4]; /* syslevel mutex entry counters */
|
DWORD sys_count[4]; /* syslevel mutex entry counters */
|
||||||
|
|
|
@ -1229,7 +1229,7 @@ void WINAPI __regs_K32Thk1632Prolog( CONTEXT *context )
|
||||||
DWORD argSize = context->Ebp - context->Esp;
|
DWORD argSize = context->Ebp - context->Esp;
|
||||||
char *stack16 = (char *)context->Esp - 4;
|
char *stack16 = (char *)context->Esp - 4;
|
||||||
STACK16FRAME *frame16 = (STACK16FRAME *)stack16 - 1;
|
STACK16FRAME *frame16 = (STACK16FRAME *)stack16 - 1;
|
||||||
STACK32FRAME *frame32 = NtCurrentTeb()->WOW32Reserved;
|
STACK32FRAME *frame32 = (STACK32FRAME *)kernel_get_thread_data()->stack;
|
||||||
char *stack32 = (char *)frame32 - argSize;
|
char *stack32 = (char *)frame32 - argSize;
|
||||||
WORD stackSel = SELECTOROF(frame32->frame16);
|
WORD stackSel = SELECTOROF(frame32->frame16);
|
||||||
DWORD stackBase = GetSelectorBase(stackSel);
|
DWORD stackBase = GetSelectorBase(stackSel);
|
||||||
|
@ -1282,7 +1282,7 @@ void WINAPI __regs_K32Thk1632Epilog( CONTEXT *context )
|
||||||
TRACE("before SYSTHUNK hack: EBP: %08x ESP: %08x cur_stack: %04x:%04x\n",
|
TRACE("before SYSTHUNK hack: EBP: %08x ESP: %08x cur_stack: %04x:%04x\n",
|
||||||
context->Ebp, context->Esp, CURRENT_SS, CURRENT_SP);
|
context->Ebp, context->Esp, CURRENT_SS, CURRENT_SP);
|
||||||
|
|
||||||
NtCurrentTeb()->WOW32Reserved = frame16->frame32;
|
kernel_get_thread_data()->stack = (SEGPTR)frame16->frame32;
|
||||||
|
|
||||||
context->Esp = (DWORD)stack16 + nArgsPopped;
|
context->Esp = (DWORD)stack16 + nArgsPopped;
|
||||||
context->Ebp = frame16->ebp;
|
context->Ebp = frame16->ebp;
|
||||||
|
|
|
@ -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 */
|
/* unwinding: restore the stack pointer in the TEB, and leave the Win16 mutex */
|
||||||
STACK32FRAME *frame32 = CONTAINING_RECORD(frame, STACK32FRAME, frame);
|
STACK32FRAME *frame32 = CONTAINING_RECORD(frame, STACK32FRAME, frame);
|
||||||
NtCurrentTeb()->WOW32Reserved = (void *)frame32->frame16;
|
kernel_get_thread_data()->stack = frame32->frame16;
|
||||||
_LeaveWin16Lock();
|
_LeaveWin16Lock();
|
||||||
}
|
}
|
||||||
else if (record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
|
else if (record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
|
||||||
|
|
|
@ -630,7 +630,7 @@ static inline void *init_handler( const ucontext_t *sigcontext )
|
||||||
* SS is still non-system segment. This is why both CS and SS
|
* SS is still non-system segment. This is why both CS and SS
|
||||||
* are checked.
|
* are checked.
|
||||||
*/
|
*/
|
||||||
return teb->WOW32Reserved;
|
return teb->SystemReserved1[0];
|
||||||
}
|
}
|
||||||
return (void *)(ESP_sig(sigcontext) & ~3);
|
return (void *)(ESP_sig(sigcontext) & ~3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -491,8 +491,8 @@ BOOL16 WINAPI TaskNext16( TASKENTRY *lpte )
|
||||||
lpte->hTaskParent = pTask->hParent;
|
lpte->hTaskParent = pTask->hParent;
|
||||||
lpte->hInst = pTask->hInstance;
|
lpte->hInst = pTask->hInstance;
|
||||||
lpte->hModule = pTask->hModule;
|
lpte->hModule = pTask->hModule;
|
||||||
lpte->wSS = SELECTOROF( pTask->teb->WOW32Reserved );
|
lpte->wSS = SELECTOROF( pTask->teb->SystemReserved1[0] );
|
||||||
lpte->wSP = OFFSETOF( pTask->teb->WOW32Reserved );
|
lpte->wSP = OFFSETOF( pTask->teb->SystemReserved1[0] );
|
||||||
lpte->wStackTop = pInstData->stacktop;
|
lpte->wStackTop = pInstData->stacktop;
|
||||||
lpte->wStackMinimum = pInstData->stackmin;
|
lpte->wStackMinimum = pInstData->stackmin;
|
||||||
lpte->wStackBottom = pInstData->stackbottom;
|
lpte->wStackBottom = pInstData->stackbottom;
|
||||||
|
|
|
@ -562,9 +562,9 @@ 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_STACK16 ((STACK16FRAME *)MapSL((SEGPTR)NtCurrentTeb()->SystemReserved1[0]))
|
||||||
#define CURRENT_DS (CURRENT_STACK16->ds)
|
#define CURRENT_DS (CURRENT_STACK16->ds)
|
||||||
#define CURRENT_SP (((WORD *)&NtCurrentTeb()->WOW32Reserved)[0])
|
#define CURRENT_SP (((WORD *)NtCurrentTeb()->SystemReserved1)[0])
|
||||||
#define CURRENT_SS (((WORD *)&NtCurrentTeb()->WOW32Reserved)[1])
|
#define CURRENT_SS (((WORD *)NtCurrentTeb()->SystemReserved1)[1])
|
||||||
|
|
||||||
#endif /* __WINE_WINE_WINBASE16_H */
|
#endif /* __WINE_WINE_WINBASE16_H */
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
|
|
||||||
/* offset of the stack pointer relative to %fs:(0) */
|
/* offset of the stack pointer relative to %fs:(0) */
|
||||||
#define STACKOFFSET 0xc0 /* FIELD_OFFSET(TEB,WOW32Reserved) */
|
#define STACKOFFSET 0x10c /* FIELD_OFFSET(TEB,SystemReserved1) */
|
||||||
|
|
||||||
/* fix this if the x86_thread_data structure is changed */
|
/* 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) */
|
#define GS_OFFSET 0x1d8 /* FIELD_OFFSET(TEB,SystemReserved2) + FIELD_OFFSET(struct x86_thread_data,gs) */
|
||||||
|
|
Loading…
Reference in New Issue