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
7a71f986
Commit
7a71f986
authored
Aug 06, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Use KiUserApcDispatcher() to call user APCs.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
2a08e0e2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
121 additions
and
42 deletions
+121
-42
loader.c
dlls/ntdll/unix/loader.c
+2
-0
server.c
dlls/ntdll/unix/server.c
+22
-29
signal_arm.c
dlls/ntdll/unix/signal_arm.c
+23
-0
signal_arm64.c
dlls/ntdll/unix/signal_arm64.c
+23
-0
signal_i386.c
dlls/ntdll/unix/signal_i386.c
+24
-1
signal_x86_64.c
dlls/ntdll/unix/signal_x86_64.c
+24
-0
thread.c
dlls/ntdll/unix/thread.c
+0
-12
unix_private.h
dlls/ntdll/unix/unix_private.h
+3
-0
No files found.
dlls/ntdll/unix/loader.c
View file @
7a71f986
...
...
@@ -96,6 +96,7 @@ extern IMAGE_NT_HEADERS __wine_spec_nt_header;
void
(
WINAPI
*
pDbgUiRemoteBreakin
)(
void
*
arg
)
=
NULL
;
void
(
WINAPI
*
pKiRaiseUserExceptionDispatcher
)(
void
)
=
NULL
;
void
(
WINAPI
*
pKiUserApcDispatcher
)(
CONTEXT
*
,
ULONG_PTR
,
ULONG_PTR
,
ULONG_PTR
,
PNTAPCFUNC
)
=
NULL
;
NTSTATUS
(
WINAPI
*
pKiUserExceptionDispatcher
)(
EXCEPTION_RECORD
*
,
CONTEXT
*
)
=
NULL
;
void
(
WINAPI
*
pLdrInitializeThunk
)(
CONTEXT
*
,
void
**
,
ULONG_PTR
,
ULONG_PTR
)
=
NULL
;
void
(
WINAPI
*
pRtlUserThreadStart
)(
PRTL_THREAD_START_ROUTINE
entry
,
void
*
arg
)
=
NULL
;
...
...
@@ -841,6 +842,7 @@ static void fixup_ntdll_imports( const IMAGE_NT_HEADERS *nt )
GET_FUNC
(
DbgUiRemoteBreakin
);
GET_FUNC
(
KiRaiseUserExceptionDispatcher
);
GET_FUNC
(
KiUserExceptionDispatcher
);
GET_FUNC
(
KiUserApcDispatcher
);
GET_FUNC
(
LdrInitializeThunk
);
GET_FUNC
(
RtlUserThreadStart
);
GET_FUNC
(
__wine_set_unix_funcs
);
...
...
dlls/ntdll/unix/server.c
View file @
7a71f986
...
...
@@ -349,23 +349,19 @@ static int wait_select_reply( void *cookie )
}
static
void
invoke_apc
(
const
user_apc_t
*
apc
)
static
void
invoke_apc
(
CONTEXT
*
context
,
const
user_apc_t
*
apc
)
{
switch
(
apc
->
type
)
{
case
APC_USER
:
{
void
(
WINAPI
*
func
)(
ULONG_PTR
,
ULONG_PTR
,
ULONG_PTR
)
=
wine_server_get_ptr
(
apc
->
user
.
func
);
func
(
apc
->
user
.
args
[
0
],
apc
->
user
.
args
[
1
],
apc
->
user
.
args
[
2
]
);
call_user_apc
(
context
,
apc
->
user
.
args
[
0
],
apc
->
user
.
args
[
1
],
apc
->
user
.
args
[
2
],
wine_server_get_ptr
(
apc
->
user
.
func
));
break
;
}
case
APC_TIMER
:
{
void
(
WINAPI
*
func
)(
void
*
,
unsigned
int
,
unsigned
int
)
=
wine_server_get_ptr
(
apc
->
user
.
func
);
func
(
wine_server_get_ptr
(
apc
->
user
.
args
[
1
]
),
(
DWORD
)
apc
->
timer
.
time
,
(
DWORD
)(
apc
->
timer
.
time
>>
32
)
);
call_user_apc
(
context
,
(
ULONG_PTR
)
wine_server_get_ptr
(
apc
->
user
.
args
[
1
]
),
(
DWORD
)
apc
->
timer
.
time
,
(
DWORD
)(
apc
->
timer
.
time
>>
32
),
wine_server_get_ptr
(
apc
->
user
.
func
));
break
;
}
default:
server_protocol_error
(
"get_apc_request: bad type %d
\n
"
,
apc
->
type
);
break
;
...
...
@@ -672,7 +668,6 @@ unsigned int server_wait( const select_op_t *select_op, data_size_t size, UINT f
const
LARGE_INTEGER
*
timeout
)
{
timeout_t
abs_timeout
=
timeout
?
timeout
->
QuadPart
:
TIMEOUT_INFINITE
;
BOOL
user_apc
=
FALSE
;
unsigned
int
ret
;
user_apc_t
apc
;
...
...
@@ -684,34 +679,32 @@ unsigned int server_wait( const select_op_t *select_op, data_size_t size, UINT f
abs_timeout
-=
now
.
QuadPart
;
}
for
(;;)
{
ret
=
server_select
(
select_op
,
size
,
flags
,
abs_timeout
,
NULL
,
NULL
,
&
apc
);
if
(
ret
!=
STATUS_USER_APC
)
break
;
invoke_apc
(
&
apc
);
/* if we ran a user apc we have to check once more if additional apcs are queued,
* but we don't want to wait */
abs_timeout
=
0
;
user_apc
=
TRUE
;
size
=
0
;
/* don't signal multiple times */
if
(
size
>=
sizeof
(
select_op
->
signal_and_wait
)
&&
select_op
->
op
==
SELECT_SIGNAL_AND_WAIT
)
size
=
offsetof
(
select_op_t
,
signal_and_wait
.
signal
);
}
if
(
ret
==
STATUS_TIMEOUT
&&
user_apc
)
ret
=
STATUS_USER_APC
;
ret
=
server_select
(
select_op
,
size
,
flags
,
abs_timeout
,
NULL
,
NULL
,
&
apc
);
if
(
ret
==
STATUS_USER_APC
)
invoke_apc
(
NULL
,
&
apc
);
/* A test on Windows 2000 shows that Windows always yields during
a wait, but a wait that is hit by an event gets a priority
boost as well. This seems to model that behavior the closest. */
if
(
ret
==
STATUS_TIMEOUT
)
NtYieldExecution
();
return
ret
;
}
/***********************************************************************
* NtContinue (NTDLL.@)
*/
NTSTATUS
WINAPI
NtContinue
(
CONTEXT
*
context
,
BOOLEAN
alertable
)
{
user_apc_t
apc
;
NTSTATUS
status
;
status
=
server_select
(
NULL
,
0
,
SELECT_INTERRUPTIBLE
|
SELECT_ALERTABLE
,
0
,
NULL
,
NULL
,
&
apc
);
if
(
status
==
STATUS_USER_APC
)
invoke_apc
(
context
,
&
apc
);
return
NtSetContextThread
(
GetCurrentThread
(),
context
);
}
/***********************************************************************
* server_queue_process_apc
*/
unsigned
int
server_queue_process_apc
(
HANDLE
process
,
const
apc_call_t
*
call
,
apc_result_t
*
result
)
...
...
dlls/ntdll/unix/signal_arm.c
View file @
7a71f986
...
...
@@ -575,6 +575,29 @@ static void setup_exception( ucontext_t *sigcontext, EXCEPTION_RECORD *rec )
REGn_sig
(
2
,
sigcontext
)
=
(
DWORD
)
pKiUserExceptionDispatcher
;
}
/***********************************************************************
* call_user_apc
*/
void
WINAPI
call_user_apc
(
CONTEXT
*
context_ptr
,
ULONG_PTR
ctx
,
ULONG_PTR
arg1
,
ULONG_PTR
arg2
,
PNTAPCFUNC
func
)
{
CONTEXT
context
;
if
(
!
context_ptr
)
{
context
.
ContextFlags
=
CONTEXT_FULL
;
NtGetContextThread
(
GetCurrentThread
(),
&
context
);
context
.
R0
=
STATUS_USER_APC
;
context_ptr
=
&
context
;
}
pKiUserApcDispatcher
(
context_ptr
,
ctx
,
arg1
,
arg2
,
func
);
}
/***********************************************************************
* call_user_exception_dispatcher
*/
void
WINAPI
call_user_exception_dispatcher
(
EXCEPTION_RECORD
*
rec
,
CONTEXT
*
context
,
NTSTATUS
(
WINAPI
*
dispatcher
)(
EXCEPTION_RECORD
*
,
CONTEXT
*
)
)
{
...
...
dlls/ntdll/unix/signal_arm64.c
View file @
7a71f986
...
...
@@ -579,6 +579,29 @@ static void setup_exception( ucontext_t *sigcontext, EXCEPTION_RECORD *rec )
REGn_sig
(
18
,
sigcontext
)
=
(
ULONG_PTR
)
NtCurrentTeb
();
}
/***********************************************************************
* call_user_apc
*/
void
WINAPI
call_user_apc
(
CONTEXT
*
context_ptr
,
ULONG_PTR
ctx
,
ULONG_PTR
arg1
,
ULONG_PTR
arg2
,
PNTAPCFUNC
func
)
{
CONTEXT
context
;
if
(
!
context_ptr
)
{
context
.
ContextFlags
=
CONTEXT_FULL
;
NtGetContextThread
(
GetCurrentThread
(),
&
context
);
context
.
u
.
s
.
X0
=
STATUS_USER_APC
;
context_ptr
=
&
context
;
}
pKiUserApcDispatcher
(
context_ptr
,
ctx
,
arg1
,
arg2
,
func
);
}
/***********************************************************************
* call_user_exception_dispatcher
*/
void
WINAPI
call_user_exception_dispatcher
(
EXCEPTION_RECORD
*
rec
,
CONTEXT
*
context
,
NTSTATUS
(
WINAPI
*
dispatcher
)(
EXCEPTION_RECORD
*
,
CONTEXT
*
)
)
{
...
...
dlls/ntdll/unix/signal_i386.c
View file @
7a71f986
...
...
@@ -1181,7 +1181,7 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
}
if
(
needed_flags
&
CONTEXT_CONTROL
)
{
context
->
Esp
=
(
DWORD
)
&
frame
->
thunk
_addr
;
context
->
Esp
=
(
DWORD
)
&
frame
->
ret
_addr
;
context
->
Ebp
=
frame
->
ebp
;
context
->
Eip
=
frame
->
thunk_addr
;
context
->
EFlags
=
0x202
;
...
...
@@ -1535,6 +1535,29 @@ static void setup_exception( ucontext_t *sigcontext, EXCEPTION_RECORD *rec )
setup_raise_exception
(
sigcontext
,
stack
,
rec
,
&
context
);
}
/***********************************************************************
* call_user_apc
*/
void
WINAPI
call_user_apc
(
CONTEXT
*
context_ptr
,
ULONG_PTR
ctx
,
ULONG_PTR
arg1
,
ULONG_PTR
arg2
,
PNTAPCFUNC
func
)
{
CONTEXT
context
;
if
(
!
context_ptr
)
{
context
.
ContextFlags
=
CONTEXT_FULL
;
NtGetContextThread
(
GetCurrentThread
(),
&
context
);
context
.
Eax
=
STATUS_USER_APC
;
context_ptr
=
&
context
;
}
pKiUserApcDispatcher
(
context_ptr
,
ctx
,
arg1
,
arg2
,
func
);
}
/***********************************************************************
* call_user_exception_dispatcher
*/
__ASM_GLOBAL_FUNC
(
call_user_exception_dispatcher
,
"add $4,%esp
\n\t
"
"movl (%esp),%eax
\n\t
"
/* rec */
...
...
dlls/ntdll/unix/signal_x86_64.c
View file @
7a71f986
...
...
@@ -1887,6 +1887,30 @@ static void setup_exception( ucontext_t *sigcontext, EXCEPTION_RECORD *rec )
setup_raise_exception
(
sigcontext
,
rec
,
&
context
);
}
/***********************************************************************
* call_user_apc
*/
void
WINAPI
call_user_apc
(
CONTEXT
*
context_ptr
,
ULONG_PTR
ctx
,
ULONG_PTR
arg1
,
ULONG_PTR
arg2
,
PNTAPCFUNC
func
)
{
CONTEXT
context
;
if
(
!
context_ptr
)
{
context
.
ContextFlags
=
CONTEXT_FULL
;
NtGetContextThread
(
GetCurrentThread
(),
&
context
);
context
.
Rax
=
STATUS_USER_APC
;
context_ptr
=
&
context
;
}
pKiUserApcDispatcher
(
context_ptr
,
ctx
,
arg1
,
arg2
,
func
);
}
/***********************************************************************
* call_user_exception_dispatcher
*/
extern
void
WINAPI
user_exception_dispatcher_trampoline
(
struct
stack_layout
*
stack
,
void
*
pKiUserExceptionDispatcher
);
...
...
dlls/ntdll/unix/thread.c
View file @
7a71f986
...
...
@@ -519,18 +519,6 @@ NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
}
/***********************************************************************
* NtContinue (NTDLL.@)
*/
NTSTATUS
WINAPI
NtContinue
(
CONTEXT
*
context
,
BOOLEAN
alertable
)
{
static
const
LARGE_INTEGER
zero_timeout
;
if
(
alertable
)
server_wait
(
NULL
,
0
,
SELECT_INTERRUPTIBLE
|
SELECT_ALERTABLE
,
&
zero_timeout
);
return
NtSetContextThread
(
GetCurrentThread
(),
context
);
}
/******************************************************************************
* NtQueueApcThread (NTDLL.@)
*/
...
...
dlls/ntdll/unix/unix_private.h
View file @
7a71f986
...
...
@@ -85,6 +85,7 @@ static const SIZE_T signal_stack_size = 0x10000 - 0x3000;
/* callbacks to PE ntdll from the Unix side */
extern
void
(
WINAPI
*
pDbgUiRemoteBreakin
)(
void
*
arg
)
DECLSPEC_HIDDEN
;
extern
void
(
WINAPI
*
pKiRaiseUserExceptionDispatcher
)(
void
)
DECLSPEC_HIDDEN
;
extern
void
(
WINAPI
*
pKiUserApcDispatcher
)(
CONTEXT
*
,
ULONG_PTR
,
ULONG_PTR
,
ULONG_PTR
,
PNTAPCFUNC
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
(
WINAPI
*
pKiUserExceptionDispatcher
)(
EXCEPTION_RECORD
*
,
CONTEXT
*
)
DECLSPEC_HIDDEN
;
extern
void
(
WINAPI
*
pLdrInitializeThunk
)(
CONTEXT
*
,
void
**
,
ULONG_PTR
,
ULONG_PTR
)
DECLSPEC_HIDDEN
;
extern
void
(
WINAPI
*
pRtlUserThreadStart
)(
PRTL_THREAD_START_ROUTINE
entry
,
void
*
arg
)
DECLSPEC_HIDDEN
;
...
...
@@ -257,6 +258,8 @@ extern void init_cpu_info(void) DECLSPEC_HIDDEN;
extern
void
dbg_init
(
void
)
DECLSPEC_HIDDEN
;
extern
void
WINAPI
call_user_apc
(
CONTEXT
*
context_ptr
,
ULONG_PTR
ctx
,
ULONG_PTR
arg1
,
ULONG_PTR
arg2
,
PNTAPCFUNC
func
)
DECLSPEC_HIDDEN
;
extern
void
WINAPI
call_user_exception_dispatcher
(
EXCEPTION_RECORD
*
rec
,
CONTEXT
*
context
,
NTSTATUS
(
WINAPI
*
dispatcher
)(
EXCEPTION_RECORD
*
,
CONTEXT
*
)
)
DECLSPEC_HIDDEN
;
...
...
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