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
71659970
Commit
71659970
authored
Dec 02, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wow64: Add support for user callbacks.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
be6ccdf5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
4 deletions
+118
-4
syscall.c
dlls/wow64/syscall.c
+112
-0
syscall.h
dlls/wow64/syscall.h
+1
-0
wow64.spec
dlls/wow64/wow64.spec
+1
-1
winternl.h
include/winternl.h
+4
-3
No files found.
dlls/wow64/syscall.c
View file @
71659970
...
...
@@ -70,6 +70,18 @@ struct mem_header
BYTE
data
[
1
];
};
/* stack frame for user callbacks */
struct
user_callback_frame
{
struct
user_callback_frame
*
prev_frame
;
struct
mem_header
*
temp_list
;
void
**
ret_ptr
;
ULONG
*
ret_len
;
NTSTATUS
status
;
__wine_jmp_buf
jmpbuf
;
};
SYSTEM_DLL_INIT_BLOCK
*
pLdrSystemDllInitBlock
=
NULL
;
/* wow64win syscall table */
...
...
@@ -143,6 +155,26 @@ NTSTATUS WINAPI wow64_NtAllocateUuids( UINT *args )
}
/***********************************************************************
* wow64_NtCallbackReturn
*/
NTSTATUS
WINAPI
wow64_NtCallbackReturn
(
UINT
*
args
)
{
void
*
ret_ptr
=
get_ptr
(
&
args
);
ULONG
ret_len
=
get_ulong
(
&
args
);
NTSTATUS
status
=
get_ulong
(
&
args
);
struct
user_callback_frame
*
frame
=
NtCurrentTeb
()
->
TlsSlots
[
WOW64_TLS_USERCALLBACKDATA
];
if
(
!
frame
)
return
STATUS_NO_CALLBACK_ACTIVE
;
*
frame
->
ret_ptr
=
ret_ptr
;
*
frame
->
ret_len
=
ret_len
;
frame
->
status
=
status
;
__wine_longjmp
(
&
frame
->
jmpbuf
,
1
);
}
/**********************************************************************
* wow64_NtClose
*/
...
...
@@ -794,6 +826,86 @@ void WINAPI Wow64ApcRoutine( ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3, CON
/**********************************************************************
* Wow64KiUserCallbackDispatcher (wow64.@)
*/
NTSTATUS
WINAPI
Wow64KiUserCallbackDispatcher
(
ULONG
id
,
void
*
args
,
ULONG
len
,
void
**
ret_ptr
,
ULONG
*
ret_len
)
{
struct
user_callback_frame
frame
;
frame
.
prev_frame
=
NtCurrentTeb
()
->
TlsSlots
[
WOW64_TLS_USERCALLBACKDATA
];
frame
.
temp_list
=
NtCurrentTeb
()
->
TlsSlots
[
WOW64_TLS_TEMPLIST
];
frame
.
ret_ptr
=
ret_ptr
;
frame
.
ret_len
=
ret_len
;
NtCurrentTeb
()
->
TlsSlots
[
WOW64_TLS_USERCALLBACKDATA
]
=
&
frame
;
NtCurrentTeb
()
->
TlsSlots
[
WOW64_TLS_TEMPLIST
]
=
NULL
;
/* cf. 32-bit KeUserModeCallback */
switch
(
current_machine
)
{
case
IMAGE_FILE_MACHINE_I386
:
{
I386_CONTEXT
orig_ctx
,
ctx
=
{
CONTEXT_I386_FULL
};
void
*
args_data
;
ULONG
*
stack
;
NtQueryInformationThread
(
GetCurrentThread
(),
ThreadWow64Context
,
&
ctx
,
sizeof
(
ctx
),
NULL
);
stack
=
args_data
=
ULongToPtr
(
(
ctx
.
Esp
-
len
)
&
~
15
);
memcpy
(
args_data
,
args
,
len
);
*
(
--
stack
)
=
0
;
*
(
--
stack
)
=
len
;
*
(
--
stack
)
=
PtrToUlong
(
args_data
);
*
(
--
stack
)
=
id
;
*
(
--
stack
)
=
0xdeadbabe
;
orig_ctx
=
ctx
;
ctx
.
Esp
=
PtrToUlong
(
stack
);
ctx
.
Eip
=
pLdrSystemDllInitBlock
->
pKiUserCallbackDispatcher
;
NtSetInformationThread
(
GetCurrentThread
(),
ThreadWow64Context
,
&
ctx
,
sizeof
(
ctx
)
);
if
(
!
__wine_setjmpex
(
&
frame
.
jmpbuf
,
NULL
))
cpu_simulate
();
else
NtSetInformationThread
(
GetCurrentThread
(),
ThreadWow64Context
,
&
orig_ctx
,
sizeof
(
orig_ctx
)
);
}
break
;
case
IMAGE_FILE_MACHINE_ARMNT
:
{
ARM_CONTEXT
orig_ctx
,
ctx
=
{
CONTEXT_ARM_FULL
};
void
*
args_data
;
NtQueryInformationThread
(
GetCurrentThread
(),
ThreadWow64Context
,
&
ctx
,
sizeof
(
ctx
),
NULL
);
args_data
=
ULongToPtr
(
(
ctx
.
Sp
-
len
)
&
~
15
);
memcpy
(
args_data
,
args
,
len
);
ctx
.
R0
=
id
;
ctx
.
R1
=
PtrToUlong
(
args
);
ctx
.
R2
=
len
;
ctx
.
Sp
=
PtrToUlong
(
args_data
);
ctx
.
Pc
=
pLdrSystemDllInitBlock
->
pKiUserCallbackDispatcher
;
NtSetInformationThread
(
GetCurrentThread
(),
ThreadWow64Context
,
&
ctx
,
sizeof
(
ctx
)
);
if
(
!
__wine_setjmpex
(
&
frame
.
jmpbuf
,
NULL
))
cpu_simulate
();
else
NtSetInformationThread
(
GetCurrentThread
(),
ThreadWow64Context
,
&
orig_ctx
,
sizeof
(
orig_ctx
)
);
}
break
;
}
NtCurrentTeb
()
->
TlsSlots
[
WOW64_TLS_USERCALLBACKDATA
]
=
frame
.
prev_frame
;
NtCurrentTeb
()
->
TlsSlots
[
WOW64_TLS_TEMPLIST
]
=
frame
.
temp_list
;
return
frame
.
status
;
}
/**********************************************************************
* Wow64LdrpInitialize (wow64.@)
*/
void
WINAPI
Wow64LdrpInitialize
(
CONTEXT
*
context
)
...
...
dlls/wow64/syscall.h
View file @
71659970
...
...
@@ -37,6 +37,7 @@
SYSCALL_ENTRY( NtAllocateVirtualMemoryEx ) \
SYSCALL_ENTRY( NtAreMappedFilesTheSame ) \
SYSCALL_ENTRY( NtAssignProcessToJobObject ) \
SYSCALL_ENTRY( NtCallbackReturn ) \
SYSCALL_ENTRY( NtCancelIoFile ) \
SYSCALL_ENTRY( NtCancelIoFileEx ) \
SYSCALL_ENTRY( NtCancelTimer ) \
...
...
dlls/wow64/wow64.spec
View file @
71659970
...
...
@@ -9,7 +9,7 @@
@ stub Wow64GetWow64ImageOption
@ stub Wow64IsControlFlowGuardEnforced
@ stub Wow64IsStackExtentsCheckEnforced
@ st
ub Wow64KiUserCallbackDispatcher
@ st
dcall Wow64KiUserCallbackDispatcher(long ptr long ptr ptr)
@ stdcall Wow64LdrpInitialize(ptr)
@ stub Wow64LogPrint
@ stub Wow64NotifyUnsimulateComplete
...
...
include/winternl.h
View file @
71659970
...
...
@@ -1080,9 +1080,10 @@ typedef struct _TEB64
}
TEB64
;
/* reserved TEB64 TLS slots for Wow64 */
#define WOW64_TLS_CPURESERVED 1
#define WOW64_TLS_TEMPLIST 3
#define WOW64_TLS_FILESYSREDIR 8
#define WOW64_TLS_CPURESERVED 1
#define WOW64_TLS_TEMPLIST 3
#define WOW64_TLS_USERCALLBACKDATA 5
#define WOW64_TLS_FILESYSREDIR 8
/***********************************************************************
...
...
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