ReactOS 0.4.15-dev-7958-gcd0bb1a
psctx.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/ps/amd64/psctx.c
5 * PURPOSE: Process Manager: Set/Get Context for i386
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 * Timo Kreuzer (timo.kreuzer@reactos.org)
8 */
9
10/* INCLUDES *******************************************************************/
11
12#include <ntoskrnl.h>
13#define NDEBUG
14#include <debug.h>
15
16/* FUNCTIONS ******************************************************************/
17
18
20VOID
23 _In_ PKAPC Apc,
24 _Inout_ PKNORMAL_ROUTINE* NormalRoutine,
25 _Inout_ PVOID* NormalContext,
28{
29 PGET_SET_CTX_CONTEXT GetSetContext;
31 PKTRAP_FRAME TrapFrame = NULL;
32
33 PAGED_CODE();
34
35 /* Get the Context Structure */
36 GetSetContext = CONTAINING_RECORD(Apc, GET_SET_CTX_CONTEXT, Apc);
37 Thread = Apc->SystemArgument2;
39
40 /* If this is a kernel-mode request, grab the saved trap frame */
41 if (GetSetContext->Mode == KernelMode)
42 {
43 TrapFrame = Thread->TrapFrame;
44 }
45
46 /* If we don't have one, grab it from the stack */
47 if (TrapFrame == NULL)
48 {
49 /* Get the thread's base trap frame */
51 }
52
53 /* Check if it's a set or get */
54 if (Apc->SystemArgument1 != 0)
55 {
56 /* Set the nonvolatiles on the stack, target frame is the trap frame */
57 KiSetTrapContext(TrapFrame, &GetSetContext->Context, GetSetContext->Mode);
58 }
59 else
60 {
61 /* Convert the trap frame to a context */
62 KeTrapFrameToContext(TrapFrame,
63 NULL,
64 &GetSetContext->Context);
65 }
66
67 /* Notify the Native API that we are done */
68 KeSetEvent(&GetSetContext->Event, IO_NO_INCREMENT, FALSE);
69}
70
71/* EOF */
#define PAGED_CODE()
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define _IRQL_requires_(irql)
Definition: driverspecs.h:229
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define KeGetCurrentThread
Definition: hal.h:55
#define _Inout_
Definition: ms_sal.h:378
#define _In_
Definition: ms_sal.h:308
#define KernelMode
Definition: asm.h:34
VOID(NTAPI * PKNORMAL_ROUTINE)(IN PVOID NormalContext OPTIONAL, IN PVOID SystemArgument1 OPTIONAL, IN PVOID SystemArgument2 OPTIONAL)
Definition: ketypes.h:744
VOID KiSetTrapContext(_Out_ PKTRAP_FRAME TrapFrame, _In_ PCONTEXT Context, _In_ KPROCESSOR_MODE RequestorMode)
#define KeGetTrapFrame(Thread)
Definition: ke.h:208
VOID NTAPI KeTrapFrameToContext(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, IN OUT PCONTEXT Context)
Definition: context.c:169
VOID NTAPI PspGetOrSetContextKernelRoutine(IN PKAPC Apc, IN OUT PKNORMAL_ROUTINE *NormalRoutine, IN OUT PVOID *NormalContext, IN OUT PVOID *SystemArgument1, IN OUT PVOID *SystemArgument2)
Definition: psctx.c:38
CONTEXT Context
Definition: ps.h:87
KEVENT Event
Definition: ps.h:85
KPROCESSOR_MODE Mode
Definition: ps.h:86
Definition: ketypes.h:547
#define NTAPI
Definition: typedefs.h:36
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define IO_NO_INCREMENT
Definition: iotypes.h:598
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:688
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:689
#define NT_ASSERT
Definition: rtlfuncs.h:3310