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

jumps.c File Reference

#include "ntrtlp.h"
#include "setjmp.h"

Go to the source code of this file.

Functions

VOID longjmp (IN jmp_buf JumpBuffer, IN int ReturnValue)
int setjmp (IN jmp_buf JumpBuffer)


Function Documentation

VOID longjmp IN jmp_buf  JumpBuffer,
IN int  ReturnValue
 

Definition at line 33 of file jumps.c.

References NULL, and RtlUnwind().

Referenced by dojump(), and main().

00040 : 00041 00042 This function executes a long jump operation by virtually unwinding to 00043 the caller of the corresponding call to set jump and then calling unwind 00044 to transfer control to the jump target. 00045 00046 Arguments: 00047 00048 00049 JumpBuffer - Supplies the address of a jump buffer that contains the 00050 virtual frame pointer and target address. 00051 00052 N.B. This is an array of double to force quadword alignment. 00053 00054 ReturnValue - Supplies the value that is to be returned to the caller 00055 of set jump. 00056 00057 Return Value: 00058 00059 None. 00060 00061 --*/ 00062 00063 { 00064 00065 PULONG JumpArray; 00066 00067 // 00068 // If the specified return value is zero, then set it to one. 00069 // 00070 00071 if (ReturnValue == 0) { 00072 ReturnValue = 1; 00073 } 00074 00075 // 00076 // Unwind to the caller of set jump and return the specified value. 00077 // There is no return from unwind. 00078 // 00079 00080 JumpArray = (PULONG)&JumpBuffer[0]; 00081 RtlUnwind((PVOID)JumpArray[0], 00082 (PVOID)JumpArray[1], 00083 NULL, 00084 (PVOID)ReturnValue); 00085 }

int setjmp IN jmp_buf  JumpBuffer  ) 
 

Definition at line 88 of file jumps.c.

References NULL, RtlLookupFunctionEntry(), and RtlVirtualUnwind().

Referenced by main().

00094 : 00095 00096 This function performs a set jump operation by capturing the current 00097 context, virtualy unwinding to the caller of set jump, and returns zero 00098 to the caller. 00099 00100 Arguments: 00101 00102 JumpBuffer - Supplies the address of a jump buffer to store the virtual 00103 frame pointer and target address of the caller. 00104 00105 N.B. This is an array of double to force quadword alignment. 00106 00107 Return Value: 00108 00109 A value of zero is returned. 00110 00111 --*/ 00112 00113 { 00114 00115 CONTEXT ContextRecord; 00116 ULONG EstablisherFrame; 00117 PRUNTIME_FUNCTION FunctionEntry; 00118 BOOLEAN InFunction; 00119 PULONG JumpArray; 00120 ULONG NextPc; 00121 00122 // 00123 // Capture the current context, virtually unwind to the caller of set 00124 // jump, and return zero to the caller. 00125 // 00126 00127 JumpArray = (PULONG)&JumpBuffer[0]; 00128 RtlCaptureContext(&ContextRecord); 00129 NextPc = ContextRecord.Lr - 4; 00130 FunctionEntry = RtlLookupFunctionEntry(NextPc); 00131 NextPc = RtlVirtualUnwind(NextPc, 00132 FunctionEntry, 00133 &ContextRecord, 00134 &InFunction, 00135 &EstablisherFrame, 00136 NULL, 00137 0, 00138 0xffffffff); 00139 00140 JumpArray[1] = NextPc + 4; 00141 FunctionEntry = RtlLookupFunctionEntry(NextPc); 00142 NextPc = RtlVirtualUnwind(NextPc, 00143 FunctionEntry, 00144 &ContextRecord, 00145 &InFunction, 00146 &EstablisherFrame, 00147 NULL, 00148 0, 00149 0xffffffff); 00150 00151 JumpArray[0] = EstablisherFrame; 00152 return 0; 00153 } }


Generated on Sat May 15 19:44:24 2004 for test by doxygen 1.3.7