Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
d876893f
Commit
d876893f
authored
May 14, 2005
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store the 16-bit stack pointer in the WOW32Reserved TEB field.
parent
110c8dc5
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
77 additions
and
80 deletions
+77
-80
stack.c
dlls/dbghelp/stack.c
+1
-1
kernel_main.c
dlls/kernel/kernel_main.c
+3
-3
ne_module.c
dlls/kernel/ne_module.c
+3
-3
ne_segment.c
dlls/kernel/ne_segment.c
+13
-14
system.c
dlls/kernel/system.c
+1
-2
task.c
dlls/kernel/task.c
+9
-9
thunk.c
dlls/kernel/thunk.c
+23
-27
wowthunk.c
dlls/kernel/wowthunk.c
+8
-8
signal_i386.c
dlls/ntdll/signal_i386.c
+1
-1
winproc.c
dlls/user/winproc.c
+2
-4
stackframe.h
include/stackframe.h
+10
-5
thread.h
include/thread.h
+2
-2
build.h
tools/winebuild/build.h
+1
-1
No files found.
dlls/dbghelp/stack.c
View file @
d876893f
...
...
@@ -130,7 +130,7 @@ BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread,
if
(
NtQueryInformationThread
(
hThread
,
ThreadBasicInformation
,
&
info
,
sizeof
(
info
),
NULL
)
!=
STATUS_SUCCESS
)
goto
done_err
;
curr_switch
=
(
unsigned
long
)
info
.
TebBaseAddress
+
FIELD_OFFSET
(
TEB
,
cur_stack
);
curr_switch
=
(
unsigned
long
)
info
.
TebBaseAddress
+
FIELD_OFFSET
(
TEB
,
WOW32Reserved
);
if
(
!
f_read_mem
(
hProcess
,
(
void
*
)
curr_switch
,
&
next_switch
,
sizeof
(
next_switch
),
NULL
))
{
...
...
dlls/kernel/kernel_main.c
View file @
d876893f
...
...
@@ -86,8 +86,8 @@ static void thread_attach(void)
/* allocate the 16-bit stack (FIXME: should be done lazily) */
HGLOBAL16
hstack
=
K32WOWGlobalAlloc16
(
GMEM_FIXED
,
0x10000
);
NtCurrentTeb
()
->
stack_sel
=
GlobalHandleToSel16
(
hstack
);
NtCurrentTeb
()
->
cur_stack
=
MAKESEGPTR
(
NtCurrentTeb
()
->
stack_sel
,
0x10000
-
sizeof
(
STACK16FRAME
)
);
NtCurrentTeb
()
->
WOW32Reserved
=
(
void
*
)
MAKESEGPTR
(
NtCurrentTeb
()
->
stack_sel
,
0x10000
-
sizeof
(
STACK16FRAME
)
);
}
...
...
@@ -98,7 +98,7 @@ static void thread_detach(void)
{
/* free the 16-bit stack */
K32WOWGlobalFree16
(
NtCurrentTeb
()
->
stack_sel
);
NtCurrentTeb
()
->
cur_stack
=
0
;
NtCurrentTeb
()
->
WOW32Reserved
=
0
;
if
(
NtCurrentTeb
()
->
Tib
.
SubSystemTib
)
TASK_ExitTask
();
}
...
...
dlls/kernel/ne_module.c
View file @
d876893f
...
...
@@ -1401,7 +1401,7 @@ DWORD NE_StartTask(void)
sp
=
pSegTable
[
pModule
->
ss
-
1
].
minsize
+
pModule
->
stack_size
;
sp
&=
~
1
;
sp
-=
sizeof
(
STACK16FRAME
);
NtCurrentTeb
()
->
cur_stack
=
MAKESEGPTR
(
GlobalHandleToSel16
(
hInstance
),
sp
);
NtCurrentTeb
()
->
WOW32Reserved
=
(
void
*
)
MAKESEGPTR
(
GlobalHandleToSel16
(
hInstance
),
sp
);
/* Registers at initialization must be:
* ax zero
...
...
@@ -1431,8 +1431,8 @@ DWORD NE_StartTask(void)
TRACE
(
"Starting main program: cs:ip=%04lx:%04lx ds=%04lx ss:sp=%04x:%04x
\n
"
,
context
.
SegCs
,
context
.
Eip
,
context
.
SegDs
,
SELECTOROF
(
NtCurrentTeb
()
->
cur_stack
),
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
);
SELECTOROF
(
NtCurrentTeb
()
->
WOW32Reserved
),
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
);
WOWCallback16Ex
(
0
,
WCB16_REGS
,
0
,
NULL
,
(
DWORD
*
)
&
context
);
ExitThread
(
LOWORD
(
context
.
Eax
)
);
...
...
dlls/kernel/ne_segment.c
View file @
d876893f
...
...
@@ -167,16 +167,16 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
{
/* Implement self-loading segments */
SELFLOADHEADER
*
selfloadheader
;
DWORD
oldstack
;
void
*
oldstack
;
HANDLE
hFile32
;
HFILE16
hFile16
;
WORD
args
[
3
];
DWORD
ret
;
selfloadheader
=
MapSL
(
MAKESEGPTR
(
SEL
(
pSegTable
->
hSeg
),
0
)
);
oldstack
=
NtCurrentTeb
()
->
cur_stack
;
NtCurrentTeb
()
->
cur_stack
=
MAKESEGPTR
(
pModule
->
self_loading_sel
,
0xff00
-
sizeof
(
STACK16FRAME
));
oldstack
=
NtCurrentTeb
()
->
WOW32Reserved
;
NtCurrentTeb
()
->
WOW32Reserved
=
(
void
*
)
MAKESEGPTR
(
pModule
->
self_loading_sel
,
0xff00
-
sizeof
(
STACK16FRAME
));
TRACE_
(
dll
)(
"CallLoadAppSegProc(hmodule=0x%04x,hf=%p,segnum=%d
\n
"
,
pModule
->
self
,
hf
,
segnum
);
...
...
@@ -190,7 +190,7 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
pSeg
->
hSeg
=
LOWORD
(
ret
);
TRACE_
(
dll
)(
"Ret CallLoadAppSegProc: hSeg = 0x%04x
\n
"
,
pSeg
->
hSeg
);
_lclose16
(
hFile16
);
NtCurrentTeb
()
->
cur_stack
=
oldstack
;
NtCurrentTeb
()
->
WOW32Reserved
=
oldstack
;
}
else
if
(
!
(
pSeg
->
flags
&
NE_SEGFLAGS_ITERATED
))
ReadFile
(
hf
,
mem
,
size
,
&
res
,
NULL
);
...
...
@@ -468,7 +468,7 @@ BOOL NE_LoadAllSegments( NE_MODULE *pModule )
/* Handle self-loading modules */
SELFLOADHEADER
*
selfloadheader
;
HMODULE16
mod
=
GetModuleHandle16
(
"KERNEL"
);
DWORD
oldstack
;
void
*
oldstack
;
WORD
args
[
2
];
TRACE_
(
module
)(
"%.*s is a self-loading module!
\n
"
,
...
...
@@ -482,9 +482,9 @@ BOOL NE_LoadAllSegments( NE_MODULE *pModule )
sel
=
GlobalAlloc16
(
GMEM_ZEROINIT
,
0xFF00
);
pModule
->
self_loading_sel
=
SEL
(
sel
);
FarSetOwner16
(
sel
,
pModule
->
self
);
oldstack
=
NtCurrentTeb
()
->
cur_stack
;
NtCurrentTeb
()
->
cur_stack
=
MAKESEGPTR
(
pModule
->
self_loading_sel
,
0xff00
-
sizeof
(
STACK16FRAME
)
);
oldstack
=
NtCurrentTeb
()
->
WOW32Reserved
;
NtCurrentTeb
()
->
WOW32Reserved
=
(
void
*
)
MAKESEGPTR
(
pModule
->
self_loading_sel
,
0xff00
-
sizeof
(
STACK16FRAME
)
);
hf
=
NE_OpenFile
(
pModule
);
hFile16
=
Win32HandleToDosFileHandle
(
hf
);
...
...
@@ -495,7 +495,7 @@ BOOL NE_LoadAllSegments( NE_MODULE *pModule )
WOWCallback16Ex
(
(
DWORD
)
selfloadheader
->
BootApp
,
WCB16_PASCAL
,
sizeof
(
args
),
args
,
NULL
);
TRACE_
(
dll
)(
"Return from CallBootAppProc
\n
"
);
_lclose16
(
hFile16
);
NtCurrentTeb
()
->
cur_stack
=
oldstack
;
NtCurrentTeb
()
->
WOW32Reserved
=
oldstack
;
for
(
i
=
2
;
i
<=
pModule
->
seg_count
;
i
++
)
if
(
!
NE_LoadSegment
(
pModule
,
i
))
return
FALSE
;
...
...
@@ -693,7 +693,7 @@ static BOOL NE_InitDLL( NE_MODULE *pModule )
context
.
SegGs
=
wine_get_gs
();
context
.
SegCs
=
SEL
(
pSegTable
[
pModule
->
cs
-
1
].
hSeg
);
context
.
Eip
=
pModule
->
ip
;
context
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
context
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
pModule
->
cs
=
0
;
/* Don't initialize it twice */
TRACE_
(
dll
)(
"Calling LibMain for %.*s, cs:ip=%04lx:%04lx ds=%04lx di=%04x cx=%04x
\n
"
,
...
...
@@ -797,9 +797,8 @@ static void NE_CallDllEntryPoint( NE_MODULE *pModule, DWORD dwReason )
context
.
SegFs
=
wine_get_fs
();
context
.
SegGs
=
wine_get_gs
();
context
.
SegCs
=
HIWORD
(
entryPoint
);
context
.
Eip
=
LOWORD
(
entryPoint
);
context
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
context
.
Eip
=
LOWORD
(
entryPoint
);
context
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
args
[
7
]
=
HIWORD
(
dwReason
);
args
[
6
]
=
LOWORD
(
dwReason
);
...
...
dlls/kernel/system.c
View file @
d876893f
...
...
@@ -175,8 +175,7 @@ static void call_timer_proc16( WORD timer )
context
.
SegGs
=
wine_get_gs
();
context
.
SegCs
=
SELECTOROF
(
proc
);
context
.
Eip
=
OFFSETOF
(
proc
);
context
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
context
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
context
.
Eax
=
timer
;
WOWCallback16Ex
(
0
,
WCB16_REGS
,
0
,
NULL
,
(
DWORD
*
)
&
context
);
...
...
dlls/kernel/task.c
View file @
d876893f
...
...
@@ -611,7 +611,7 @@ void WINAPI InitTask16( CONTEXT86 *context )
/* Initialize the INSTANCEDATA structure */
pinstance
=
MapSL
(
MAKESEGPTR
(
CURRENT_DS
,
0
)
);
pinstance
->
stackmin
=
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
+
sizeof
(
STACK16FRAME
);
pinstance
->
stackmin
=
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
+
sizeof
(
STACK16FRAME
);
pinstance
->
stackbottom
=
pinstance
->
stackmin
;
/* yup, that's right. Confused me too. */
pinstance
->
stacktop
=
(
pinstance
->
stackmin
>
LOWORD
(
context
->
Ebx
)
?
pinstance
->
stackmin
-
LOWORD
(
context
->
Ebx
)
:
0
)
+
150
;
...
...
@@ -1081,14 +1081,14 @@ void WINAPI SwitchStackTo16( WORD seg, WORD ptr, WORD top )
if
(
!
(
pData
=
(
INSTANCEDATA
*
)
GlobalLock16
(
seg
)))
return
;
TRACE
(
"old=%04x:%04x new=%04x:%04x
\n
"
,
SELECTOROF
(
NtCurrentTeb
()
->
cur_stack
),
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
),
seg
,
ptr
);
SELECTOROF
(
NtCurrentTeb
()
->
WOW32Reserved
),
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
),
seg
,
ptr
);
/* Save the old stack */
oldFrame
=
CURRENT_STACK16
;
/* pop frame + args and push bp */
pData
->
old_ss_sp
=
NtCurrentTeb
()
->
cur_stack
+
sizeof
(
STACK16FRAME
)
pData
->
old_ss_sp
=
(
SEGPTR
)
NtCurrentTeb
()
->
WOW32Reserved
+
sizeof
(
STACK16FRAME
)
+
2
*
sizeof
(
WORD
);
*
(
WORD
*
)
MapSL
(
pData
->
old_ss_sp
)
=
oldFrame
->
bp
;
pData
->
stacktop
=
top
;
...
...
@@ -1102,7 +1102,7 @@ void WINAPI SwitchStackTo16( WORD seg, WORD ptr, WORD top )
*/
copySize
=
oldFrame
->
bp
-
OFFSETOF
(
pData
->
old_ss_sp
);
copySize
+=
3
*
sizeof
(
WORD
)
+
sizeof
(
STACK16FRAME
);
NtCurrentTeb
()
->
cur_stack
=
MAKESEGPTR
(
seg
,
ptr
-
copySize
);
NtCurrentTeb
()
->
WOW32Reserved
=
(
void
*
)
MAKESEGPTR
(
seg
,
ptr
-
copySize
);
newFrame
=
CURRENT_STACK16
;
/* Copy the stack frame and the local variables to the new stack */
...
...
@@ -1121,7 +1121,7 @@ void WINAPI SwitchStackBack16( CONTEXT86 *context )
STACK16FRAME
*
oldFrame
,
*
newFrame
;
INSTANCEDATA
*
pData
;
if
(
!
(
pData
=
(
INSTANCEDATA
*
)
GlobalLock16
(
SELECTOROF
(
NtCurrentTeb
()
->
cur_stack
))))
if
(
!
(
pData
=
(
INSTANCEDATA
*
)
GlobalLock16
(
SELECTOROF
(
NtCurrentTeb
()
->
WOW32Reserved
))))
return
;
if
(
!
pData
->
old_ss_sp
)
{
...
...
@@ -1140,7 +1140,7 @@ void WINAPI SwitchStackBack16( CONTEXT86 *context )
/* Switch back to the old stack */
NtCurrentTeb
()
->
cur_stack
=
pData
->
old_ss_sp
-
sizeof
(
STACK16FRAME
);
NtCurrentTeb
()
->
WOW32Reserved
=
(
void
*
)(
pData
->
old_ss_sp
-
sizeof
(
STACK16FRAME
)
);
context
->
SegSs
=
SELECTOROF
(
pData
->
old_ss_sp
);
context
->
Esp
=
OFFSETOF
(
pData
->
old_ss_sp
)
-
sizeof
(
DWORD
);
/*ret addr*/
pData
->
old_ss_sp
=
0
;
...
...
@@ -1473,8 +1473,8 @@ BOOL16 WINAPI TaskNext16( TASKENTRY *lpte )
lpte
->
hTaskParent
=
pTask
->
hParent
;
lpte
->
hInst
=
pTask
->
hInstance
;
lpte
->
hModule
=
pTask
->
hModule
;
lpte
->
wSS
=
SELECTOROF
(
pTask
->
teb
->
cur_stack
);
lpte
->
wSP
=
OFFSETOF
(
pTask
->
teb
->
cur_stack
);
lpte
->
wSS
=
SELECTOROF
(
pTask
->
teb
->
WOW32Reserved
);
lpte
->
wSP
=
OFFSETOF
(
pTask
->
teb
->
WOW32Reserved
);
lpte
->
wStackTop
=
pInstData
->
stacktop
;
lpte
->
wStackMinimum
=
pInstData
->
stackmin
;
lpte
->
wStackBottom
=
pInstData
->
stackbottom
;
...
...
dlls/kernel/thunk.c
View file @
d876893f
...
...
@@ -461,8 +461,7 @@ void WINAPI __regs_QT_Thunk( CONTEXT86 *context )
context16
.
Eip
=
LOWORD
(
context
->
Edx
);
/* point EBP to the STACK16FRAME on the stack
* for the call_to_16 to set up the register content on calling */
context16
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
context16
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
/*
* used to be (problematic):
...
...
@@ -484,7 +483,7 @@ void WINAPI __regs_QT_Thunk( CONTEXT86 *context )
* the number of parameters that the Win16 function
* accepted (that it popped from the corresponding Win16 stack) */
context
->
Esp
+=
LOWORD
(
context16
.
Esp
)
-
(
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
-
argsize
);
(
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
-
argsize
);
}
#ifdef DEFINE_REGS_ENTRYPOINT
DEFINE_REGS_ENTRYPOINT
(
QT_Thunk
,
0
,
0
);
...
...
@@ -594,8 +593,7 @@ void WINAPI __regs_FT_Thunk( CONTEXT86 *context )
context16
.
SegGs
=
wine_get_gs
();
context16
.
SegCs
=
HIWORD
(
callTarget
);
context16
.
Eip
=
LOWORD
(
callTarget
);
context16
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
context16
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
argsize
=
context
->
Ebp
-
context
->
Esp
-
0x40
;
if
(
argsize
>
sizeof
(
newstack
))
argsize
=
sizeof
(
newstack
);
...
...
@@ -607,8 +605,8 @@ void WINAPI __regs_FT_Thunk( CONTEXT86 *context )
if
(
mapESPrelative
&
(
1
<<
i
))
{
SEGPTR
*
arg
=
(
SEGPTR
*
)
newstack
[
i
];
*
arg
=
MAKESEGPTR
(
SELECTOROF
(
NtCurrentTeb
()
->
cur_stack
),
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
-
argsize
*
arg
=
MAKESEGPTR
(
SELECTOROF
(
NtCurrentTeb
()
->
WOW32Reserved
),
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
-
argsize
+
(
*
(
LPBYTE
*
)
arg
-
oldstack
));
}
...
...
@@ -618,7 +616,7 @@ void WINAPI __regs_FT_Thunk( CONTEXT86 *context )
context
->
Ecx
=
context16
.
Ecx
;
context
->
Esp
+=
LOWORD
(
context16
.
Esp
)
-
(
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
-
argsize
);
(
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
-
argsize
);
/* Copy modified buffers back to 32-bit stack */
memcpy
(
oldstack
,
newstack
,
argsize
);
...
...
@@ -777,8 +775,7 @@ void WINAPI __regs_Common32ThkLS( CONTEXT86 *context )
context16
.
Edi
=
LOWORD
(
context
->
Ecx
);
context16
.
SegCs
=
HIWORD
(
context
->
Eax
);
context16
.
Eip
=
LOWORD
(
context
->
Eax
);
context16
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
context16
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
argsize
=
HIWORD
(
context
->
Edx
)
*
4
;
...
...
@@ -838,8 +835,7 @@ void WINAPI __regs_OT_32ThkLSF( CONTEXT86 *context )
context16
.
SegGs
=
wine_get_gs
();
context16
.
SegCs
=
HIWORD
(
context
->
Edx
);
context16
.
Eip
=
LOWORD
(
context
->
Edx
);
context16
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
context16
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
argsize
=
2
*
*
(
WORD
*
)
context
->
Esp
+
2
;
...
...
@@ -852,7 +848,7 @@ void WINAPI __regs_OT_32ThkLSF( CONTEXT86 *context )
(
LPBYTE
)
CURRENT_STACK16
-
argsize
,
argsize
);
context
->
Esp
+=
LOWORD
(
context16
.
Esp
)
-
(
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
-
argsize
);
(
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
-
argsize
);
}
#ifdef DEFINE_REGS_ENTRYPOINT
DEFINE_REGS_ENTRYPOINT
(
OT_32ThkLSF
,
0
,
0
);
...
...
@@ -1274,24 +1270,24 @@ void WINAPI __regs_K32Thk1632Prolog( CONTEXT86 *context )
DWORD
argSize
=
context
->
Ebp
-
context
->
Esp
;
char
*
stack16
=
(
char
*
)
context
->
Esp
-
4
;
char
*
stack32
=
(
char
*
)
NtCurrentTeb
()
->
cur_stack
-
argSize
;
char
*
stack32
=
(
char
*
)
NtCurrentTeb
()
->
WOW32Reserved
-
argSize
;
STACK16FRAME
*
frame16
=
(
STACK16FRAME
*
)
stack16
-
1
;
TRACE
(
"before SYSTHUNK hack: EBP: %08lx ESP: %08lx cur_stack: %
08lx
\n
"
,
context
->
Ebp
,
context
->
Esp
,
NtCurrentTeb
()
->
cur_stack
);
TRACE
(
"before SYSTHUNK hack: EBP: %08lx ESP: %08lx cur_stack: %
p
\n
"
,
context
->
Ebp
,
context
->
Esp
,
NtCurrentTeb
()
->
WOW32Reserved
);
memset
(
frame16
,
'\0'
,
sizeof
(
STACK16FRAME
));
frame16
->
frame32
=
(
STACK32FRAME
*
)
NtCurrentTeb
()
->
cur_stack
;
frame16
->
frame32
=
NtCurrentTeb
()
->
WOW32Reserved
;
frame16
->
ebp
=
context
->
Ebp
;
memcpy
(
stack32
,
stack16
,
argSize
);
NtCurrentTeb
()
->
cur_stack
=
MAKESEGPTR
(
stackSel
,
(
DWORD
)
frame16
-
stackBase
);
NtCurrentTeb
()
->
WOW32Reserved
=
(
void
*
)
MAKESEGPTR
(
stackSel
,
(
DWORD
)
frame16
-
stackBase
);
context
->
Esp
=
(
DWORD
)
stack32
+
4
;
context
->
Ebp
=
context
->
Esp
+
argSize
;
TRACE
(
"after SYSTHUNK hack: EBP: %08lx ESP: %08lx cur_stack: %
08lx
\n
"
,
context
->
Ebp
,
context
->
Esp
,
NtCurrentTeb
()
->
cur_stack
);
TRACE
(
"after SYSTHUNK hack: EBP: %08lx ESP: %08lx cur_stack: %
p
\n
"
,
context
->
Ebp
,
context
->
Esp
,
NtCurrentTeb
()
->
WOW32Reserved
);
}
/* entry_point is never used again once the entry point has
...
...
@@ -1316,23 +1312,23 @@ void WINAPI __regs_K32Thk1632Epilog( CONTEXT86 *context )
if
(
code
[
5
]
==
0xFF
&&
code
[
6
]
==
0x55
&&
code
[
7
]
==
0xFC
&&
code
[
13
]
==
0x66
&&
code
[
14
]
==
0xCB
)
{
STACK16FRAME
*
frame16
=
MapSL
(
NtCurrentTeb
()
->
cur_stack
);
STACK16FRAME
*
frame16
=
MapSL
(
(
SEGPTR
)
NtCurrentTeb
()
->
WOW32Reserved
);
char
*
stack16
=
(
char
*
)(
frame16
+
1
);
DWORD
argSize
=
frame16
->
ebp
-
(
DWORD
)
stack16
;
char
*
stack32
=
(
char
*
)
frame16
->
frame32
-
argSize
;
DWORD
nArgsPopped
=
context
->
Esp
-
(
DWORD
)
stack32
;
TRACE
(
"before SYSTHUNK hack: EBP: %08lx ESP: %08lx cur_stack: %
08lx
\n
"
,
context
->
Ebp
,
context
->
Esp
,
NtCurrentTeb
()
->
cur_stack
);
TRACE
(
"before SYSTHUNK hack: EBP: %08lx ESP: %08lx cur_stack: %
p
\n
"
,
context
->
Ebp
,
context
->
Esp
,
NtCurrentTeb
()
->
WOW32Reserved
);
NtCurrentTeb
()
->
cur_stack
=
(
DWORD
)
frame16
->
frame32
;
NtCurrentTeb
()
->
WOW32Reserved
=
frame16
->
frame32
;
context
->
Esp
=
(
DWORD
)
stack16
+
nArgsPopped
;
context
->
Ebp
=
frame16
->
ebp
;
TRACE
(
"after SYSTHUNK hack: EBP: %08lx ESP: %08lx cur_stack: %
08lx
\n
"
,
context
->
Ebp
,
context
->
Esp
,
NtCurrentTeb
()
->
cur_stack
);
TRACE
(
"after SYSTHUNK hack: EBP: %08lx ESP: %08lx cur_stack: %
p
\n
"
,
context
->
Ebp
,
context
->
Esp
,
NtCurrentTeb
()
->
WOW32Reserved
);
}
}
#ifdef DEFINE_REGS_ENTRYPOINT
...
...
@@ -2214,7 +2210,7 @@ void WINAPI Throw16( LPCATCHBUF lpbuf, INT16 retval, CONTEXT86 *context )
frame32
=
pFrame
->
frame32
;
while
(
frame32
&&
frame32
->
frame16
)
{
if
(
OFFSETOF
(
frame32
->
frame16
)
<
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
))
if
(
OFFSETOF
(
frame32
->
frame16
)
<
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
))
break
;
/* Something strange is going on */
if
(
OFFSETOF
(
frame32
->
frame16
)
>
lpbuf
[
2
])
{
...
...
dlls/kernel/wowthunk.c
View file @
d876893f
...
...
@@ -265,7 +265,7 @@ static DWORD call16_handler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RE
{
/* unwinding: restore the stack pointer in the TEB, and leave the Win16 mutex */
STACK32FRAME
*
frame32
=
(
STACK32FRAME
*
)((
char
*
)
frame
-
offsetof
(
STACK32FRAME
,
frame
));
NtCurrentTeb
()
->
cur_stack
=
frame32
->
frame16
;
NtCurrentTeb
()
->
WOW32Reserved
=
(
void
*
)
frame32
->
frame16
;
_LeaveWin16Lock
();
}
else
if
(
record
->
ExceptionCode
==
EXCEPTION_ACCESS_VIOLATION
||
...
...
@@ -619,7 +619,7 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags,
context
->
SegCs
,
LOWORD
(
context
->
Eip
),
context
->
SegDs
);
while
(
count
)
DPRINTF
(
",%04x"
,
wstack
[
--
count
]
);
DPRINTF
(
") ss:sp=%04x:%04x"
,
SELECTOROF
(
NtCurrentTeb
()
->
cur_stack
),
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
);
SELECTOROF
(
NtCurrentTeb
()
->
WOW32Reserved
),
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
);
DPRINTF
(
" ax=%04x bx=%04x cx=%04x dx=%04x si=%04x di=%04x bp=%04x es=%04x fs=%04x
\n
"
,
(
WORD
)
context
->
Eax
,
(
WORD
)
context
->
Ebx
,
(
WORD
)
context
->
Ecx
,
(
WORD
)
context
->
Edx
,
(
WORD
)
context
->
Esi
,
(
WORD
)
context
->
Edi
,
...
...
@@ -674,8 +674,8 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags,
if
(
TRACE_ON
(
relay
))
{
DPRINTF
(
"%04lx:RetFrom16() ss:sp=%04x:%04x "
,
GetCurrentThreadId
(),
SELECTOROF
(
NtCurrentTeb
()
->
cur_stack
),
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
));
GetCurrentThreadId
(),
SELECTOROF
(
NtCurrentTeb
()
->
WOW32Reserved
),
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
));
DPRINTF
(
" ax=%04x bx=%04x cx=%04x dx=%04x bp=%04x sp=%04x
\n
"
,
(
WORD
)
context
->
Eax
,
(
WORD
)
context
->
Ebx
,
(
WORD
)
context
->
Ecx
,
(
WORD
)
context
->
Edx
,
(
WORD
)
context
->
Ebp
,
(
WORD
)
context
->
Esp
);
...
...
@@ -693,10 +693,10 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags,
DPRINTF
(
"%04lx:CallTo16(func=%04x:%04x,ds=%04x"
,
GetCurrentThreadId
(),
HIWORD
(
vpfn16
),
LOWORD
(
vpfn16
),
SELECTOROF
(
NtCurrentTeb
()
->
cur_stack
)
);
SELECTOROF
(
NtCurrentTeb
()
->
WOW32Reserved
)
);
while
(
count
)
DPRINTF
(
",%04x"
,
wstack
[
--
count
]
);
DPRINTF
(
") ss:sp=%04x:%04x
\n
"
,
SELECTOROF
(
NtCurrentTeb
()
->
cur_stack
),
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
)
);
SELECTOROF
(
NtCurrentTeb
()
->
WOW32Reserved
),
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
);
SYSLEVEL_CheckNotLevel
(
2
);
}
...
...
@@ -719,8 +719,8 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags,
if
(
TRACE_ON
(
relay
))
{
DPRINTF
(
"%04lx:RetFrom16() ss:sp=%04x:%04x retval=%08lx
\n
"
,
GetCurrentThreadId
(),
SELECTOROF
(
NtCurrentTeb
()
->
cur_stack
),
OFFSETOF
(
NtCurrentTeb
()
->
cur_stack
),
ret
);
GetCurrentThreadId
(),
SELECTOROF
(
NtCurrentTeb
()
->
WOW32Reserved
),
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
),
ret
);
SYSLEVEL_CheckNotLevel
(
2
);
}
}
...
...
dlls/ntdll/signal_i386.c
View file @
d876893f
...
...
@@ -661,7 +661,7 @@ static void *init_handler( const SIGCONTEXT *sigcontext )
* are checked.
*/
wine_set_gs
(
teb
->
gs_sel
);
stack
=
(
void
*
)
teb
->
cur_stack
;
stack
=
teb
->
WOW32Reserved
;
}
#ifdef __HAVE_VM86
else
if
((
void
*
)
EIP_sig
(
sigcontext
)
==
vm86_return
)
/* vm86 mode */
...
...
dlls/user/winproc.c
View file @
d876893f
...
...
@@ -435,21 +435,19 @@ static LRESULT WINAPI WINPROC_CallWndProc16( WNDPROC16 proc, HWND16 hwnd,
LRESULT
ret
;
WORD
args
[
5
];
DWORD
offset
=
0
;
TEB
*
teb
=
NtCurrentTeb
();
USER_CheckNotLock
();
/* Window procedures want ax = hInstance, ds = es = ss */
memset
(
&
context
,
0
,
sizeof
(
context
));
context
.
SegDs
=
context
.
SegEs
=
SELECTOROF
(
teb
->
cur_stack
);
context
.
SegDs
=
context
.
SegEs
=
SELECTOROF
(
NtCurrentTeb
()
->
WOW32Reserved
);
context
.
SegFs
=
wine_get_fs
();
context
.
SegGs
=
wine_get_gs
();
if
(
!
(
context
.
Eax
=
GetWindowWord
(
HWND_32
(
hwnd
),
GWLP_HINSTANCE
)))
context
.
Eax
=
context
.
SegDs
;
context
.
SegCs
=
SELECTOROF
(
proc
);
context
.
Eip
=
OFFSETOF
(
proc
);
context
.
Ebp
=
OFFSETOF
(
teb
->
cur_stack
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
context
.
Ebp
=
OFFSETOF
(
NtCurrentTeb
()
->
WOW32Reserved
)
+
(
WORD
)
&
((
STACK16FRAME
*
)
0
)
->
bp
;
if
(
lParam
)
{
...
...
include/stackframe.h
View file @
d876893f
...
...
@@ -22,9 +22,14 @@
#define __WINE_STACKFRAME_H
#include <string.h>
#include <stdarg.h>
#include <thread.h>
#include <windef.h>
#include <winbase.h>
#include <winnt.h>
#include <winreg.h>
#include <winternl.h>
#include <thread.h>
#include <wine/winbase16.h>
#include <pshpack1.h>
...
...
@@ -68,7 +73,7 @@ typedef struct _STACK16FRAME
#include <poppack.h>
#define CURRENT_STACK16 ((STACK16FRAME*)MapSL(
NtCurrentTeb()->cur_stack
))
#define CURRENT_STACK16 ((STACK16FRAME*)MapSL(
(SEGPTR)NtCurrentTeb()->WOW32Reserved
))
#define CURRENT_DS (CURRENT_STACK16->ds)
/* Push bytes on the 16-bit stack of a thread;
...
...
@@ -78,8 +83,8 @@ static inline SEGPTR stack16_push( int size )
{
STACK16FRAME
*
frame
=
CURRENT_STACK16
;
memmove
(
(
char
*
)
frame
-
size
,
frame
,
sizeof
(
*
frame
)
);
NtCurrentTeb
()
->
cur_stack
-=
size
;
return
(
SEGPTR
)(
NtCurrentTeb
()
->
cur_stack
+
sizeof
(
*
frame
));
NtCurrentTeb
()
->
WOW32Reserved
=
(
char
*
)
NtCurrentTeb
()
->
WOW32Reserved
-
size
;
return
(
SEGPTR
)(
(
char
*
)
NtCurrentTeb
()
->
WOW32Reserved
+
sizeof
(
*
frame
));
}
/* Pop bytes from the 16-bit stack of a thread */
...
...
@@ -87,7 +92,7 @@ static inline void stack16_pop( int size )
{
STACK16FRAME
*
frame
=
CURRENT_STACK16
;
memmove
(
(
char
*
)
frame
+
size
,
frame
,
sizeof
(
*
frame
)
);
NtCurrentTeb
()
->
cur_stack
+=
size
;
NtCurrentTeb
()
->
WOW32Reserved
=
(
char
*
)
NtCurrentTeb
()
->
WOW32Reserved
+
size
;
}
#endif
/* __WINE_STACKFRAME_H */
include/thread.h
View file @
d876893f
...
...
@@ -84,8 +84,8 @@ typedef struct _TEB
DWORD
unknown6
[
5
];
/* --n 1e8 Unknown */
/* The following are Wine-specific fields (NT: GDI stuff) */
UINT
code_page
;
/* --3 1fc Thread code page
*/
DWORD
cur_stack
;
/* --3 200 Current stack
*/
DWORD
unused_1fc
;
/* --3 1fc
*/
UINT
code_page
;
/* --3 200 Thread code page
*/
DWORD
teb_sel
;
/* --3 204 Selector to TEB */
DWORD
gs_sel
;
/* --3 208 %gs selector for this thread */
int
request_fd
;
/* --3 20c fd for sending server requests */
...
...
tools/winebuild/build.h
View file @
d876893f
...
...
@@ -133,7 +133,7 @@ typedef struct
#define STACK32OFFSET(reg) STRUCTOFFSET(STACK32FRAME,reg)
/* Offset of the stack pointer relative to %fs:(0) */
#define STACKOFFSET (STRUCTOFFSET(TEB,
cur_stack
))
#define STACKOFFSET (STRUCTOFFSET(TEB,
WOW32Reserved
))
#define MAX_ORDINALS 65535
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment