NTSTATUS
PsGetContextThread(
__in PETHREAD Thread,
__inout PCONTEXT ThreadContext,
__in KPROCESSOR_MODE Mode
)
/*++
Routine Description:
This function returns the usermode context of the specified thread. This
function will fail if the specified thread is a system thread. It will
return the wrong answer if the thread is a non-system thread that does
not execute in user-mode.
Arguments:
Thread - Supplies a pointer to the thread object from
which to retrieve context information.
ThreadContext - Supplies the address of a buffer that will receive
the context of the specified thread.
Mode - Mode to use for validation checks.
Return Value:
None.
--*/
看楼主的参数,想调用的应该是这个函数吧:
NTSTATUS
NtGetContextThread(
__in HANDLE ThreadHandle,
__inout PCONTEXT ThreadContext
)
/*++
Routine Description:
This function returns the usermode context of the specified thread. This
function will fail if the specified thread is a system thread. It will
return the wrong answer if the thread is a non-system thread that does
not execute in user-mode.
Arguments:
ThreadHandle - Supplies an open handle to the thread object from
which to retrieve context information. The handle
must allow THREAD_GET_CONTEXT access to the thread.
ThreadContext - Supplies the address of a buffer that will receive
the context of the specified thread.
Return Value:
None.
--*/
NTSTATUS
NtGetContextThread(
__in HANDLE ThreadHandle,
__inout PCONTEXT ThreadContext
)
/*++
Routine Description:
This function returns the usermode context of the specified thread. This
function will fail if the specified thread is a system thread. It will
return the wrong answer if the thread is a non-system thread that does
not execute in user-mode.
Arguments:
ThreadHandle - Supplies an open handle to the thread object from
which to retrieve context information. The handle
must allow THREAD_GET_CONTEXT access to the thread.
ThreadContext - Supplies the address of a buffer that will receive
the context of the specified thread.
Return Value:
None.
--*/
{
KPROCESSOR_MODE Mode;
NTSTATUS Status;
PETHREAD Thread;
PETHREAD CurrentThread;
PAGED_CODE();
//
// Get previous mode and reference specified thread.
//
CurrentThread = PsGetCurrentThread ();
Mode = KeGetPreviousModeByThread (&CurrentThread->Tcb);
Status = ObReferenceObjectByHandle (ThreadHandle,
THREAD_GET_CONTEXT,
PsThreadType,
Mode,
&Thread,
NULL);
//
// If the reference was successful, the check if the specified thread
// is a system thread.
//
if (NT_SUCCESS (Status)) {
//
// If the thread is not a system thread, then attempt to get the
// context of the thread.
//
if (IS_SYSTEM_THREAD (Thread) == FALSE) {
Status = PsGetContextThread (Thread, ThreadContext, Mode);
} else {
Status = STATUS_INVALID_HANDLE;
}
ObDereferenceObject (Thread);
}
return Status;
}