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
c244fe3d
Commit
c244fe3d
authored
Mar 07, 2023
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wow64: Keep track of APC stack frames, similarly to user callback frames.
And use the appropriate frame to restore the context in NtContinue.
parent
96841d03
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
9 deletions
+23
-9
syscall.c
dlls/wow64/syscall.c
+22
-9
winternl.h
include/winternl.h
+1
-0
No files found.
dlls/wow64/syscall.c
View file @
c244fe3d
...
...
@@ -84,6 +84,13 @@ struct user_callback_frame
__wine_jmp_buf
jmpbuf
;
};
/* stack frame for user APCs */
struct
user_apc_frame
{
struct
user_apc_frame
*
prev_frame
;
CONTEXT
*
context
;
void
*
wow_context
;
};
SYSTEM_DLL_INIT_BLOCK
*
pLdrSystemDllInitBlock
=
NULL
;
...
...
@@ -416,8 +423,14 @@ NTSTATUS WINAPI wow64_NtContinue( UINT *args )
BOOLEAN
alertable
=
get_ulong
(
&
args
);
NTSTATUS
status
=
get_context_return_value
(
context
);
struct
user_apc_frame
*
frame
=
NtCurrentTeb
()
->
TlsSlots
[
WOW64_TLS_APCLIST
];
pBTCpuSetContext
(
GetCurrentThread
(),
GetCurrentProcess
(),
NULL
,
context
);
while
(
frame
&&
frame
->
wow_context
!=
context
)
frame
=
frame
->
prev_frame
;
NtCurrentTeb
()
->
TlsSlots
[
WOW64_TLS_APCLIST
]
=
frame
?
frame
->
prev_frame
:
NULL
;
if
(
frame
)
NtContinue
(
frame
->
context
,
alertable
);
if
(
alertable
)
NtTestAlert
();
return
status
;
}
...
...
@@ -981,13 +994,11 @@ void * WINAPI Wow64AllocateTemp( SIZE_T size )
*/
void
WINAPI
Wow64ApcRoutine
(
ULONG_PTR
arg1
,
ULONG_PTR
arg2
,
ULONG_PTR
arg3
,
CONTEXT
*
context
)
{
NTSTATUS
retval
;
struct
user_apc_frame
frame
;
#ifdef __x86_64__
retval
=
context
->
Rax
;
#elif defined(__aarch64__)
retval
=
context
->
X0
;
#endif
frame
.
prev_frame
=
NtCurrentTeb
()
->
TlsSlots
[
WOW64_TLS_APCLIST
];
frame
.
context
=
context
;
NtCurrentTeb
()
->
TlsSlots
[
WOW64_TLS_APCLIST
]
=
&
frame
;
/* cf. 32-bit call_user_apc_dispatcher */
switch
(
current_machine
)
...
...
@@ -1014,10 +1025,11 @@ void WINAPI Wow64ApcRoutine( ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3, CON
stack
->
arg2
=
arg2
;
stack
->
arg3
=
arg3
;
stack
->
context
=
ctx
;
stack
->
context
.
Eax
=
retval
;
ctx
.
Esp
=
PtrToUlong
(
stack
);
ctx
.
Eip
=
pLdrSystemDllInitBlock
->
pKiUserApcDispatcher
;
frame
.
wow_context
=
&
stack
->
context
;
pBTCpuSetContext
(
GetCurrentThread
(),
GetCurrentProcess
(),
NULL
,
&
ctx
);
cpu_simulate
();
}
break
;
...
...
@@ -1035,14 +1047,15 @@ void WINAPI Wow64ApcRoutine( ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3, CON
stack
=
(
struct
apc_stack_layout
*
)
ULongToPtr
(
ctx
.
Sp
&
~
15
)
-
1
;
stack
->
func
=
arg1
>>
32
;
stack
->
context
=
ctx
;
stack
->
context
.
R0
=
retval
;
ctx
.
Sp
=
PtrToUlong
(
stack
);
ctx
.
Pc
=
pLdrSystemDllInitBlock
->
pKiUserApcDispatcher
;
ctx
.
R0
=
PtrToUlong
(
&
stack
->
context
);
ctx
.
R1
=
arg1
;
ctx
.
R2
=
arg2
;
ctx
.
R3
=
arg3
;
frame
.
wow_context
=
&
stack
->
context
;
pBTCpuSetContext
(
GetCurrentThread
(),
GetCurrentProcess
(),
NULL
,
&
ctx
);
cpu_simulate
();
}
break
;
}
...
...
@@ -1112,7 +1125,7 @@ NTSTATUS WINAPI Wow64KiUserCallbackDispatcher( ULONG id, void *args, ULONG len,
memcpy
(
args_data
,
args
,
len
);
ctx
.
R0
=
id
;
ctx
.
R1
=
PtrToUlong
(
args
);
ctx
.
R1
=
PtrToUlong
(
args
_data
);
ctx
.
R2
=
len
;
ctx
.
Sp
=
PtrToUlong
(
args_data
);
ctx
.
Pc
=
pLdrSystemDllInitBlock
->
pKiUserCallbackDispatcher
;
...
...
include/winternl.h
View file @
c244fe3d
...
...
@@ -1083,6 +1083,7 @@ typedef struct _TEB64
#define WOW64_TLS_CPURESERVED 1
#define WOW64_TLS_TEMPLIST 3
#define WOW64_TLS_USERCALLBACKDATA 5
#define WOW64_TLS_APCLIST 7
#define WOW64_TLS_FILESYSREDIR 8
#define WOW64_TLS_MAX_NUMBER 19
...
...
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