Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenzo Ferrillo
wine
Commits
71659970
Commit
71659970
authored
3 years ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
wow64: Add support for user callbacks.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
be6ccdf5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
dlls/wow64/syscall.c
+112
-0
112 additions, 0 deletions
dlls/wow64/syscall.c
dlls/wow64/syscall.h
+1
-0
1 addition, 0 deletions
dlls/wow64/syscall.h
dlls/wow64/wow64.spec
+1
-1
1 addition, 1 deletion
dlls/wow64/wow64.spec
include/winternl.h
+4
-3
4 additions, 3 deletions
include/winternl.h
with
118 additions
and
4 deletions
dlls/wow64/syscall.c
+
112
−
0
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
*/
...
...
@@ -793,6 +825,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.@)
*/
...
...
This diff is collapsed.
Click to expand it.
dlls/wow64/syscall.h
+
1
−
0
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 ) \
...
...
This diff is collapsed.
Click to expand it.
dlls/wow64/wow64.spec
+
1
−
1
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
...
...
This diff is collapsed.
Click to expand it.
include/winternl.h
+
4
−
3
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
/***********************************************************************
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment