Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
60067579
Commit
60067579
authored
Aug 13, 2002
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setup exception frame around 16-bit calls to unwind stack properly.
parent
1166dc73
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
34 deletions
+70
-34
thunk.c
dlls/kernel/thunk.c
+2
-0
exception.c
dlls/ntdll/exception.c
+22
-3
stackframe.h
include/stackframe.h
+13
-12
relay.c
tools/winebuild/relay.c
+33
-19
No files found.
dlls/kernel/thunk.c
View file @
60067579
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "windef.h"
#include "windef.h"
#include "winbase.h"
#include "winbase.h"
#include "winerror.h"
#include "winerror.h"
#include "ntddk.h"
#include "wine/winbase16.h"
#include "wine/winbase16.h"
#include "wine/debug.h"
#include "wine/debug.h"
...
@@ -2091,6 +2092,7 @@ void WINAPI Throw16( LPCATCHBUF lpbuf, INT16 retval, CONTEXT86 *context )
...
@@ -2091,6 +2092,7 @@ void WINAPI Throw16( LPCATCHBUF lpbuf, INT16 retval, CONTEXT86 *context )
}
}
frame32
=
((
STACK16FRAME
*
)
MapSL
(
frame32
->
frame16
))
->
frame32
;
frame32
=
((
STACK16FRAME
*
)
MapSL
(
frame32
->
frame16
))
->
frame32
;
}
}
RtlUnwind
(
&
pFrame
->
frame32
->
frame
,
NULL
,
NULL
,
0
);
context
->
Eip
=
lpbuf
[
0
];
context
->
Eip
=
lpbuf
[
0
];
context
->
SegCs
=
lpbuf
[
1
];
context
->
SegCs
=
lpbuf
[
1
];
...
...
dlls/ntdll/exception.c
View file @
60067579
...
@@ -403,10 +403,29 @@ DWORD __wine_exception_handler( EXCEPTION_RECORD *record, EXCEPTION_FRAME *frame
...
@@ -403,10 +403,29 @@ DWORD __wine_exception_handler( EXCEPTION_RECORD *record, EXCEPTION_FRAME *frame
DWORD
__wine_finally_handler
(
EXCEPTION_RECORD
*
record
,
EXCEPTION_FRAME
*
frame
,
DWORD
__wine_finally_handler
(
EXCEPTION_RECORD
*
record
,
EXCEPTION_FRAME
*
frame
,
CONTEXT
*
context
,
LPVOID
pdispatcher
)
CONTEXT
*
context
,
LPVOID
pdispatcher
)
{
{
if
(
record
->
ExceptionFlags
&
(
EH_UNWINDING
|
EH_EXIT_UNWIND
))
{
__WINE_FRAME
*
wine_frame
=
(
__WINE_FRAME
*
)
frame
;
__WINE_FRAME
*
wine_frame
=
(
__WINE_FRAME
*
)
frame
;
if
(
!
(
record
->
ExceptionFlags
&
(
EH_UNWINDING
|
EH_EXIT_UNWIND
)))
return
ExceptionContinueSearch
;
wine_frame
->
u
.
finally_func
(
FALSE
);
wine_frame
->
u
.
finally_func
(
FALSE
);
}
return
ExceptionContinueSearch
;
}
/*************************************************************
* __wine_callto16_handler
*
* Handler for exceptions occuring in 16-bit code.
*/
DWORD
__wine_callto16_handler
(
EXCEPTION_RECORD
*
record
,
EXCEPTION_FRAME
*
frame
,
CONTEXT
*
context
,
LPVOID
pdispatcher
)
{
if
(
record
->
ExceptionFlags
&
(
EH_UNWINDING
|
EH_EXIT_UNWIND
))
{
/* 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
;
_LeaveWin16Lock
();
}
return
ExceptionContinueSearch
;
return
ExceptionContinueSearch
;
}
}
include/stackframe.h
View file @
60067579
...
@@ -32,18 +32,19 @@
...
@@ -32,18 +32,19 @@
/* 32-bit stack layout after CallTo16() */
/* 32-bit stack layout after CallTo16() */
typedef
struct
_STACK32FRAME
typedef
struct
_STACK32FRAME
{
{
SEGPTR
frame16
;
/* 00 16-bit frame from last CallFrom16() */
DWORD
restore_addr
;
/* 00 return address for restoring code selector */
DWORD
restore_addr
;
/* 04 return address for restoring code selector */
DWORD
codeselector
;
/* 04 code selector to restore */
DWORD
codeselector
;
/* 08 code selector to restore */
EXCEPTION_FRAME
frame
;
/* 08 Exception frame */
DWORD
edi
;
/* 0c saved registers */
SEGPTR
frame16
;
/* 10 16-bit frame from last CallFrom16() */
DWORD
esi
;
/* 10 */
DWORD
edi
;
/* 14 saved registers */
DWORD
edx
;
/* 14 */
DWORD
esi
;
/* 18 */
DWORD
ecx
;
/* 18 */
DWORD
edx
;
/* 1c */
DWORD
ebx
;
/* 1c */
DWORD
ecx
;
/* 20 */
DWORD
ebp
;
/* 20 saved 32-bit frame pointer */
DWORD
ebx
;
/* 24 */
DWORD
retaddr
;
/* 24 return address */
DWORD
ebp
;
/* 28 saved 32-bit frame pointer */
DWORD
target
;
/* 28 target address / CONTEXT86 pointer */
DWORD
retaddr
;
/* 2c return address */
DWORD
nb_args
;
/* 2c number of 16-bit argument bytes */
DWORD
target
;
/* 30 target address / CONTEXT86 pointer */
DWORD
nb_args
;
/* 34 number of 16-bit argument bytes */
}
STACK32FRAME
;
}
STACK32FRAME
;
/* 16-bit stack layout after CallFrom16() */
/* 16-bit stack layout after CallFrom16() */
...
...
tools/winebuild/relay.c
View file @
60067579
...
@@ -501,12 +501,6 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
...
@@ -501,12 +501,6 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
fprintf
(
outfile
,
"
\t
addl $_GLOBAL_OFFSET_TABLE_+[.-.Lwine_call_to_16_%s.getgot1], %%ebx
\n
"
,
name
);
fprintf
(
outfile
,
"
\t
addl $_GLOBAL_OFFSET_TABLE_+[.-.Lwine_call_to_16_%s.getgot1], %%ebx
\n
"
,
name
);
}
}
/* Enter Win16 Mutex */
if
(
UsePIC
)
fprintf
(
outfile
,
"
\t
call "
__ASM_NAME
(
"_EnterWin16Lock@PLT"
)
"
\n
"
);
else
fprintf
(
outfile
,
"
\t
call "
__ASM_NAME
(
"_EnterWin16Lock"
)
"
\n
"
);
/* Print debugging info */
/* Print debugging info */
if
(
debugging
)
if
(
debugging
)
{
{
...
@@ -523,6 +517,21 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
...
@@ -523,6 +517,21 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
fprintf
(
outfile
,
"
\t
addl $12, %%esp
\n
"
);
fprintf
(
outfile
,
"
\t
addl $12, %%esp
\n
"
);
}
}
/* Enter Win16 Mutex */
if
(
UsePIC
)
fprintf
(
outfile
,
"
\t
call "
__ASM_NAME
(
"_EnterWin16Lock@PLT"
)
"
\n
"
);
else
fprintf
(
outfile
,
"
\t
call "
__ASM_NAME
(
"_EnterWin16Lock"
)
"
\n
"
);
/* Setup exception frame */
fprintf
(
outfile
,
"
\t
.byte 0x64
\n\t
pushl (%d)
\n
"
,
STACKOFFSET
);
if
(
UsePIC
)
fprintf
(
outfile
,
"
\t
pushl "
__ASM_NAME
(
"__wine_callto16_handler@GOT"
)
"(%%ebx)
\n
"
);
else
fprintf
(
outfile
,
"
\t
pushl $"
__ASM_NAME
(
"__wine_callto16_handler"
)
"
\n
"
);
fprintf
(
outfile
,
"
\t
.byte 0x64
\n\t
pushl (%d)
\n
"
,
STRUCTOFFSET
(
TEB
,
except
)
);
fprintf
(
outfile
,
"
\t
.byte 0x64
\n\t
movl %%esp,(%d)
\n
"
,
STRUCTOFFSET
(
TEB
,
except
)
);
/* Get return address */
/* Get return address */
if
(
UsePIC
)
if
(
UsePIC
)
{
{
...
@@ -534,7 +543,12 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
...
@@ -534,7 +543,12 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
/* Call the actual CallTo16 routine (simulate a lcall) */
/* Call the actual CallTo16 routine (simulate a lcall) */
fprintf
(
outfile
,
"
\t
pushl %%cs
\n
"
);
fprintf
(
outfile
,
"
\t
pushl %%cs
\n
"
);
fprintf
(
outfile
,
"
\t
call .Lwine_call_to_16_%s
\n
"
,
name
);
fprintf
(
outfile
,
"
\t
call .Lwine_call_to_16_%s
\n
"
,
reg_func
?
name
:
"long"
);
/* Remove exception frame */
fprintf
(
outfile
,
"
\t
.byte 0x64
\n\t
popl (%d)
\n
"
,
STRUCTOFFSET
(
TEB
,
except
)
);
fprintf
(
outfile
,
"
\t
addl $4, %%esp
\n
"
);
fprintf
(
outfile
,
"
\t
.byte 0x64
\n\t
popl (%d)
\n
"
,
STACKOFFSET
);
if
(
!
reg_func
)
if
(
!
reg_func
)
{
{
...
@@ -563,7 +577,9 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
...
@@ -563,7 +577,9 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
* at the cost of a somewhat less efficient return path.]
* at the cost of a somewhat less efficient return path.]
*/
*/
fprintf
(
outfile
,
"
\t
movl %d(%%esp), %%edi
\n
"
,
STACK32OFFSET
(
target
)
-
12
);
fprintf
(
outfile
,
"
\t
movl %d(%%esp), %%edi
\n
"
,
STACK32OFFSET
(
target
)
-
STACK32OFFSET
(
edi
));
/* everything above edi has been popped already */
fprintf
(
outfile
,
"
\t
movl %%eax, %d(%%edi)
\n
"
,
CONTEXTOFFSET
(
Eax
)
);
fprintf
(
outfile
,
"
\t
movl %%eax, %d(%%edi)
\n
"
,
CONTEXTOFFSET
(
Eax
)
);
fprintf
(
outfile
,
"
\t
movl %%ebx, %d(%%edi)
\n
"
,
CONTEXTOFFSET
(
Ebx
)
);
fprintf
(
outfile
,
"
\t
movl %%ebx, %d(%%edi)
\n
"
,
CONTEXTOFFSET
(
Ebx
)
);
fprintf
(
outfile
,
"
\t
movl %%ecx, %d(%%edi)
\n
"
,
CONTEXTOFFSET
(
Ecx
)
);
fprintf
(
outfile
,
"
\t
movl %%ecx, %d(%%edi)
\n
"
,
CONTEXTOFFSET
(
Ecx
)
);
...
@@ -584,6 +600,12 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
...
@@ -584,6 +600,12 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
fprintf
(
outfile
,
"
\t
addl $_GLOBAL_OFFSET_TABLE_+[.-.Lwine_call_to_16_%s.getgot2], %%ebx
\n
"
,
name
);
fprintf
(
outfile
,
"
\t
addl $_GLOBAL_OFFSET_TABLE_+[.-.Lwine_call_to_16_%s.getgot2], %%ebx
\n
"
,
name
);
}
}
/* Leave Win16 Mutex */
if
(
UsePIC
)
fprintf
(
outfile
,
"
\t
call "
__ASM_NAME
(
"_LeaveWin16Lock@PLT"
)
"
\n
"
);
else
fprintf
(
outfile
,
"
\t
call "
__ASM_NAME
(
"_LeaveWin16Lock"
)
"
\n
"
);
/* Print debugging info */
/* Print debugging info */
if
(
debugging
)
if
(
debugging
)
{
{
...
@@ -597,12 +619,6 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
...
@@ -597,12 +619,6 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
fprintf
(
outfile
,
"
\t
addl $4, %%esp
\n
"
);
fprintf
(
outfile
,
"
\t
addl $4, %%esp
\n
"
);
}
}
/* Leave Win16 Mutex */
if
(
UsePIC
)
fprintf
(
outfile
,
"
\t
call "
__ASM_NAME
(
"_LeaveWin16Lock@PLT"
)
"
\n
"
);
else
fprintf
(
outfile
,
"
\t
call "
__ASM_NAME
(
"_LeaveWin16Lock"
)
"
\n
"
);
/* Get return value */
/* Get return value */
fprintf
(
outfile
,
"
\t
popl %%eax
\n
"
);
fprintf
(
outfile
,
"
\t
popl %%eax
\n
"
);
...
@@ -620,13 +636,12 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
...
@@ -620,13 +636,12 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
/* Start of the actual CallTo16 routine */
/* Start of the actual CallTo16 routine */
fprintf
(
outfile
,
".Lwine_call_to_16_%s:
\n
"
,
name
);
if
(
!
reg_func
&&
short_ret
)
return
;
/* call_to_16_word uses call_to_16_long backend routine */
/* Complete STACK32FRAME */
fprintf
(
outfile
,
".Lwine_call_to_16_%s:
\n
"
,
name
);
fprintf
(
outfile
,
"
\t
.byte 0x64
\n\t
pushl (%d)
\n
"
,
STACKOFFSET
);
fprintf
(
outfile
,
"
\t
movl %%esp,%%edx
\n
"
);
/* Switch to the 16-bit stack */
/* Switch to the 16-bit stack */
fprintf
(
outfile
,
"
\t
movl %%esp,%%edx
\n
"
);
#ifdef __svr4__
#ifdef __svr4__
fprintf
(
outfile
,
"
\t
data16
\n
"
);
fprintf
(
outfile
,
"
\t
data16
\n
"
);
#endif
#endif
...
@@ -739,7 +754,6 @@ static void BuildRet16Func( FILE *outfile )
...
@@ -739,7 +754,6 @@ static void BuildRet16Func( FILE *outfile )
#endif
#endif
fprintf
(
outfile
,
"
\t
movw %%di,%%ss
\n
"
);
fprintf
(
outfile
,
"
\t
movw %%di,%%ss
\n
"
);
fprintf
(
outfile
,
"
\t
.byte 0x64
\n\t
movl (%d),%%esp
\n
"
,
STACKOFFSET
);
fprintf
(
outfile
,
"
\t
.byte 0x64
\n\t
movl (%d),%%esp
\n
"
,
STACKOFFSET
);
fprintf
(
outfile
,
"
\t
.byte 0x64
\n\t
popl (%d)
\n
"
,
STACKOFFSET
);
/* Return to caller */
/* Return to caller */
...
...
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