00045 :
00046
00047 This function
is called to initialize
the context
for a user mode APC.
00048
00049 Arguments:
00050
00051 ExceptionFrame - Supplies a pointer to an exception frame.
00052
00053 TrapFrame - Supplies a pointer to a trap frame.
00054
00055 NormalRoutine - Supplies a pointer to
the user mode APC routine.
00056
00057 NormalContext - Supplies a pointer to
the user context
for the APC
00058 routine.
00059
00060 SystemArgument1 - Supplies
the first system supplied value.
00061
00062 SystemArgument2 - Supplies
the second system supplied value.
00063
00064 Return Value:
00065
00066 None.
00067
00068 --*/
00069
00070 {
00071
00072 CONTEXT ContextRecord;
00073 EXCEPTION_RECORD ExceptionRecord;
00074 LONG Length;
00075 ULONG UserStack;
00076 PULONG PUserStack;
00077
00078
00079
00080
00081
00082
00083 ContextRecord.ContextFlags =
CONTEXT_FULL;
00084
KeContextFromKframes(TrapFrame, ExceptionFrame, &ContextRecord);
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
try {
00121
00122
00123
00124
00125
00126
00127
00128 PULONG FnDesc = (PULONG)
KeUserApcDispatcher;
00129
00130
00131
00132
00133
00134 Length = (
STK_MIN_FRAME + CONTEXT_LENGTH + KTRAP_FRAME_LENGTH +
00135
sizeof(ULONG) + STK_SLACK_SPACE + 7) & (-8);
00136 UserStack = (ContextRecord.Gpr1 & (~7)) - Length;
00137
00138
00139
00140
00141
00142
00143
ProbeForWrite((PCHAR)UserStack, Length,
sizeof(QUAD));
00144 RtlCopyMemory((PULONG)(UserStack + STK_MIN_FRAME), &ContextRecord,
sizeof(CONTEXT));
00145
00146
00147
00148
00149
00150
00151
00152 PUserStack = (PULONG) UserStack;
00153 PUserStack[0] = ContextRecord.Gpr1;
00154 PUserStack[(
STK_MIN_FRAME + CONTEXT_LENGTH +
00155 KTRAP_FRAME_LENGTH) /
sizeof(ULONG)] = FnDesc[1];
00156
00157
00158
00159
00160
00161
00162
00163
00164 TrapFrame->Gpr1 = UserStack;
00165 TrapFrame->Gpr2 = FnDesc[1];
00166 TrapFrame->Gpr3 = (ULONG)NormalContext;
00167 TrapFrame->Gpr4 = (ULONG)SystemArgument1;
00168 TrapFrame->Gpr5 = (ULONG)SystemArgument2;
00169 TrapFrame->Gpr6 = (ULONG)NormalRoutine;
00170 TrapFrame->Iar = FnDesc[0];
00171
00172
00173
00174
00175
00176
00177 } except (
KiCopyInformation(&ExceptionRecord,
00178 (GetExceptionInformation())->ExceptionRecord)) {
00179
00180
00181
00182
00183
00184
00185 ExceptionRecord.ExceptionAddress = (PVOID)(TrapFrame->Iar);
00186
KiDispatchException(&ExceptionRecord,
00187 ExceptionFrame,
00188 TrapFrame,
00189 UserMode,
00190 TRUE);
00191 }
00192
00193
return;
00194 }
}