Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

apcuser.c File Reference

#include "ki.h"

Go to the source code of this file.

Functions

VOID KiInitializeUserApc (IN PKEXCEPTION_FRAME ExceptionFrame, IN PKTRAP_FRAME TrapFrame, IN PKNORMAL_ROUTINE NormalRoutine, IN PVOID NormalContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)


Function Documentation

VOID KiInitializeUserApc IN PKEXCEPTION_FRAME  ExceptionFrame,
IN PKTRAP_FRAME  TrapFrame,
IN PKNORMAL_ROUTINE  NormalRoutine,
IN PVOID  NormalContext,
IN PVOID  SystemArgument1,
IN PVOID  SystemArgument2
 

Definition at line 33 of file alpha/apcuser.c.

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 // Move the user mode state from the trap and exception frames to the 00078 // context frame. 00079 // 00080 00081 ContextRecord.ContextFlags = CONTEXT_FULL; 00082 KeContextFromKframes(TrapFrame, ExceptionFrame, &ContextRecord); 00083 00084 // 00085 // Transfer the context information to the user stack, initialize the 00086 // APC routine parameters, and modify the trap frame so execution will 00087 // continue in user mode at the user mode APC dispatch routine. 00088 // 00089 00090 try { 00091 00092 // 00093 // Compute length of context record and new aligned user stack pointer. 00094 // 00095 00096 Length = (sizeof(CONTEXT) + 15) & (~15); 00097 UserStack = ((ULONG_PTR)ContextRecord.IntSp & (~15)) - Length; 00098 00099 // 00100 // Probe user stack area for writeability and then transfer the 00101 // context record to the user stack. 00102 // 00103 00104 ProbeForWrite((PVOID)UserStack, (ULONG)Length, sizeof(QUAD)); 00105 RtlMoveMemory((PVOID)UserStack, &ContextRecord, sizeof(CONTEXT)); 00106 00107 // 00108 // Set the address of the user APC routine, the APC parameters, the 00109 // new frame pointer, and the new stack pointer in the current trap 00110 // frame. Set the continuation address so control will be transferred 00111 // to the user APC dispatcher. 00112 // 00113 // N.B. It is not possible to pass 64 bit arguments to the routine. 00114 // N.B. ULONG becomes canonical longword with (ULONGLONG)(LONG) cast. 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 // If an exception occurs, then copy the exception information to an 00128 // exception record and handle the exception. 00129 // 00130 00131 } except (KiCopyInformation(&ExceptionRecord, 00132 (GetExceptionInformation())->ExceptionRecord)) { 00133 00134 // 00135 // Set the address of the exception to the current program address 00136 // and raise the exception by calling the exception dispatcher. 00137 // 00138 00139 ExceptionRecord.ExceptionAddress = (PVOID)(TrapFrame->Fir); 00140 KiDispatchException(&ExceptionRecord, 00141 ExceptionFrame, 00142 TrapFrame, 00143 UserMode, 00144 TRUE); 00145 } 00146 00147 return; 00148 } }


Generated on Sat May 15 19:42:52 2004 for test by doxygen 1.3.7