ReactOS 0.4.15-dev-8064-gdaf8068
psctx.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for psctx.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI PspGetContext (IN PKTRAP_FRAME TrapFrame, IN PVOID NonVolatileContext, IN OUT PCONTEXT Context)
 
VOID NTAPI PspSetContext (OUT PKTRAP_FRAME TrapFrame, OUT PVOID NonVolatileContext, IN PCONTEXT Context, IN KPROCESSOR_MODE Mode)
 
VOID NTAPI PspGetOrSetContextKernelRoutine (IN PKAPC Apc, IN OUT PKNORMAL_ROUTINE *NormalRoutine, IN OUT PVOID *NormalContext, IN OUT PVOID *SystemArgument1, IN OUT PVOID *SystemArgument2)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file psctx.c.

Function Documentation

◆ PspGetContext()

VOID NTAPI PspGetContext ( IN PKTRAP_FRAME  TrapFrame,
IN PVOID  NonVolatileContext,
IN OUT PCONTEXT  Context 
)

Definition at line 19 of file psctx.c.

22{
23 PAGED_CODE();
24
25 /* Convert the trap frame to a context */
27}
#define PAGED_CODE()
#define NULL
Definition: types.h:112
VOID NTAPI KeTrapFrameToContext(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, IN OUT PCONTEXT Context)
Definition: context.c:169

◆ PspGetOrSetContextKernelRoutine()

VOID NTAPI PspGetOrSetContextKernelRoutine ( IN PKAPC  Apc,
IN OUT PKNORMAL_ROUTINE NormalRoutine,
IN OUT PVOID NormalContext,
IN OUT PVOID SystemArgument1,
IN OUT PVOID SystemArgument2 
)

Definition at line 44 of file psctx.c.

49{
50 PGET_SET_CTX_CONTEXT GetSetContext;
55 PKTRAP_FRAME TrapFrame = NULL;
56 PAGED_CODE();
57
58 /* Get the Context Structure */
59 GetSetContext = CONTAINING_RECORD(Apc, GET_SET_CTX_CONTEXT, Apc);
60 Context = &GetSetContext->Context;
61 Event = &GetSetContext->Event;
62 Mode = GetSetContext->Mode;
63 Thread = Apc->SystemArgument2;
64
65 /* If this is a kernel-mode request, grab the saved trap frame */
66 if (Mode == KernelMode) TrapFrame = Thread->Tcb.TrapFrame;
67
68 /* If we don't have one, grab it from the stack */
69 if (!TrapFrame)
70 {
71 /* Trap frame is right under our initial stack */
72 TrapFrame = KeGetTrapFrame(&Thread->Tcb);
73 }
74
75 /* Check if it's a set or get */
76 if (Apc->SystemArgument1)
77 {
78 /* Set the Context */
79 PspSetContext(TrapFrame, NULL, Context, Mode);
80 }
81 else
82 {
83 /* Get the Context */
84 PspGetContext(TrapFrame, NULL, Context);
85 }
86
87 /* Notify the Native API that we are done */
89}
#define FALSE
Definition: types.h:117
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
_In_ ULONG Mode
Definition: hubbusif.h:303
VOID NTAPI PspGetContext(IN PKTRAP_FRAME TrapFrame, IN PVOID NonVolatileContext, IN OUT PCONTEXT Context)
Definition: psctx.c:19
VOID NTAPI PspSetContext(OUT PKTRAP_FRAME TrapFrame, OUT PVOID NonVolatileContext, IN PCONTEXT Context, IN KPROCESSOR_MODE Mode)
Definition: psctx.c:31
#define KernelMode
Definition: asm.h:34
#define KeGetTrapFrame(Thread)
Definition: ke.h:208
KTHREAD Tcb
Definition: pstypes.h:1103
CONTEXT Context
Definition: ps.h:87
KEVENT Event
Definition: ps.h:85
KPROCESSOR_MODE Mode
Definition: ps.h:86
PKTRAP_FRAME TrapFrame
Definition: ketypes.h:1774
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define IO_NO_INCREMENT
Definition: iotypes.h:598
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7

Referenced by PsGetContextThread(), and PsSetContextThread().

◆ PspSetContext()

VOID NTAPI PspSetContext ( OUT PKTRAP_FRAME  TrapFrame,
OUT PVOID  NonVolatileContext,
IN PCONTEXT  Context,
IN KPROCESSOR_MODE  Mode 
)

Definition at line 31 of file psctx.c.

35{
36 PAGED_CODE();
37
38 /* Convert the context to a trap frame structure */
39 KeContextToTrapFrame(Context, NULL, TrapFrame, Context->ContextFlags, Mode);
40}
VOID NTAPI KeContextToTrapFrame(PCONTEXT Context, PKEXCEPTION_FRAME ExeptionFrame, PKTRAP_FRAME TrapFrame, ULONG ContextFlags, KPROCESSOR_MODE PreviousMode)