00044 :
00045
00046 This function
is called to initialize
the context
for a user mode APC.
00047
00048 Arguments:
00049
00050 ExceptionFrame - Supplies a pointer to an exception frame.
00051
00052 TrapFrame - Supplies a pointer to a trap frame.
00053
00054 NormalRoutine - Supplies a pointer to
the user mode APC routine.
00055
00056 NormalContext - Supplies a pointer to
the user context
for the APC
00057 routine.
00058
00059 SystemArgument1 - Supplies
the first system supplied value.
00060
00061 SystemArgument2 - Supplies
the second system supplied value.
00062
00063 Return Value:
00064
00065 None.
00066
00067 --*/
00068
00069 {
00070
00071 CONTEXT ContextRecord;
00072 EXCEPTION_RECORD ExceptionRecord;
00073 LONG_PTR Length;
00074 ULONG_PTR UserStack;
00075
00076
00077
00078
00079
00080
00081 ContextRecord.ContextFlags =
CONTEXT_FULL;
00082
KeContextFromKframes(TrapFrame, ExceptionFrame, &ContextRecord);
00083
00084
00085
00086
00087
00088
00089
00090
try {
00091
00092
00093
00094
00095
00096 Length = (
sizeof(CONTEXT) + 15) & (~15);
00097 UserStack = ((ULONG_PTR)ContextRecord.IntSp & (~15)) - Length;
00098
00099
00100
00101
00102
00103
00104
ProbeForWrite((PVOID)UserStack, (ULONG)Length,
sizeof(QUAD));
00105 RtlMoveMemory((PVOID)UserStack, &ContextRecord,
sizeof(CONTEXT));
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 TrapFrame->IntSp = (ULONGLONG)(LONG_PTR)UserStack;
00119 TrapFrame->IntFp = (ULONGLONG)(LONG_PTR)UserStack;
00120 TrapFrame->IntA0 = (ULONGLONG)(LONG_PTR)NormalContext;
00121 TrapFrame->IntA1 = (ULONGLONG)(LONG_PTR)SystemArgument1;
00122 TrapFrame->IntA2 = (ULONGLONG)(LONG_PTR)SystemArgument2;
00123 TrapFrame->IntA3 = (ULONGLONG)(LONG_PTR)NormalRoutine;
00124 TrapFrame->Fir = (ULONGLONG)(LONG_PTR)
KeUserApcDispatcher;
00125
00126
00127
00128
00129
00130
00131 } except (
KiCopyInformation(&ExceptionRecord,
00132 (GetExceptionInformation())->ExceptionRecord)) {
00133
00134
00135
00136
00137
00138
00139 ExceptionRecord.ExceptionAddress = (PVOID)(TrapFrame->Fir);
00140
KiDispatchException(&ExceptionRecord,
00141 ExceptionFrame,
00142 TrapFrame,
00143 UserMode,
00144 TRUE);
00145 }
00146
00147
return;
00148 }
}