00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
#include "ntrtlp.h"
00030
#include "setjmp.h"
00031
00032
VOID
00033 longjmp (
00034 IN jmp_buf JumpBuffer,
00035 IN
int ReturnValue
00036 )
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 {
00064
00065 PULONG JumpArray;
00066
00067
00068
00069
00070
00071
if (ReturnValue == 0) {
00072 ReturnValue = 1;
00073 }
00074
00075
00076
00077
00078
00079
00080 JumpArray = (PULONG)&JumpBuffer[0];
00081
RtlUnwind((PVOID)JumpArray[0],
00082 (PVOID)JumpArray[1],
00083
NULL,
00084 (PVOID)ReturnValue);
00085 }
00086
00087
int
00088 setjmp (
00089 IN jmp_buf JumpBuffer
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 CONTEXT ContextRecord;
00116 ULONG EstablisherFrame;
00117 PRUNTIME_FUNCTION FunctionEntry;
00118 BOOLEAN InFunction;
00119 PULONG JumpArray;
00120 ULONG NextPc;
00121
00122
00123
00124
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 }