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
00030
#include "ntrtlp.h"
00031
00032
00033
00034
00035
00036
00037
00038 #define RAISE_EXCEPTION(Status, ExceptionRecordt) { \
00039
EXCEPTION_RECORD ExceptionRecordn; \
00040
\
00041
ExceptionRecordn.ExceptionCode = Status; \
00042
ExceptionRecordn.ExceptionFlags = EXCEPTION_NONCONTINUABLE; \
00043
ExceptionRecordn.ExceptionRecord = ExceptionRecordt; \
00044
ExceptionRecordn.NumberParameters = 0; \
00045
RtlRaiseException(&ExceptionRecordn); \
00046
}
00047
00048
00049
00050
00051
00052 #define IS_HANDLER_DEFINED(FunctionEntry) \
00053
(RF_EXCEPTION_HANDLER(FunctionEntry) != 0)
00054
00055
#if DBG
00056
00057
00058
00059
00060
00061
#define PC_HISTORY_DEPTH 4
00062
00063
00064
00065
00066
00067
00068 ULONG RtlDebugFlags;
00069
00070
#endif
00071
00072 #define Virtual VirtualFramePointer
00073 #define Real RealFramePointer
00074
00075
VOID
00076 RtlUnwindRfp (
00077 IN PVOID TargetRealFrame OPTIONAL,
00078 IN PVOID TargetIp OPTIONAL,
00079 IN PEXCEPTION_RECORD ExceptionRecord OPTIONAL,
00080 IN PVOID ReturnValue
00081 )
00082
00083
00084
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
00121
00122
00123
00124 {
00125
00126 CONTEXT ContextRecord1;
00127 CONTEXT ContextRecord2;
00128 ULONG_PTR ControlPc;
00129
#if DBG
00130
ULONG_PTR ControlPcHistory[PC_HISTORY_DEPTH];
00131 ULONG ControlPcHistoryIndex = 0;
00132
#endif
00133
DISPATCHER_CONTEXT DispatcherContext;
00134 EXCEPTION_DISPOSITION Disposition;
00135 FRAME_POINTERS EstablisherFrame;
00136 ULONG ExceptionFlags;
00137 EXCEPTION_RECORD ExceptionRecord1;
00138
#if DBG
00139
LONG FrameDepth = 0;
00140
#endif
00141
PRUNTIME_FUNCTION FunctionEntry;
00142 ULONG_PTR HighLimit;
00143 BOOLEAN InFunction;
00144 ULONG_PTR LastPc;
00145 ULONG_PTR LowLimit;
00146
00147
#if DBG
00148
if (RtlDebugFlags & RTL_DBG_UNWIND) {
00149
DbgPrint(
"\nRtlUnwindRfp(TargetRealFrame = %p, TargetIp = %p,, ReturnValue = %lx)\n",
00150 TargetRealFrame, TargetIp, ReturnValue);
00151 }
00152
#endif
00153
00154
00155
00156
00157
00158
00159
00160
RtlpGetStackLimits(&LowLimit, &HighLimit);
00161 RtlCaptureContext(&ContextRecord1);
00162 ControlPc = (ULONG_PTR)ContextRecord1.IntRa;
00163 FunctionEntry =
RtlLookupFunctionEntry(ControlPc);
00164 LastPc =
RtlVirtualUnwind(ControlPc,
00165 FunctionEntry,
00166 &ContextRecord1,
00167 &InFunction,
00168 &EstablisherFrame,
00169
NULL);
00170
00171 ControlPc = LastPc;
00172 ContextRecord1.Fir = (ULONGLONG)(LONG_PTR)TargetIp;
00173
00174
00175
00176
00177
00178
00179
if (ARGUMENT_PRESENT(ExceptionRecord) ==
FALSE) {
00180 ExceptionRecord = &ExceptionRecord1;
00181 ExceptionRecord1.ExceptionCode = STATUS_UNWIND;
00182 ExceptionRecord1.ExceptionRecord =
NULL;
00183 ExceptionRecord1.ExceptionAddress = (PVOID)ControlPc;
00184 ExceptionRecord1.NumberParameters = 0;
00185 }
00186
00187
00188
00189
00190
00191
00192 ExceptionFlags =
EXCEPTION_UNWINDING;
00193
if (ARGUMENT_PRESENT(TargetRealFrame) ==
FALSE) {
00194 ExceptionRecord->ExceptionFlags |=
EXCEPTION_EXIT_UNWIND;
00195 }
00196
00197
00198
00199
00200
00201
00202
do {
00203
00204
#if DBG
00205
if (RtlDebugFlags & RTL_DBG_UNWIND_DETAIL) {
00206
DbgPrint(
"RtlUnwindRfp: Loop: FrameDepth = %d, Rfp = %p, sp = %p, ControlPc = %p\n",
00207 FrameDepth, EstablisherFrame.Real, (ULONG_PTR)ContextRecord1.IntSp, ControlPc);
00208 FrameDepth -= 1;
00209 }
00210
#endif
00211
00212
00213
00214
00215
00216
00217 FunctionEntry =
RtlLookupFunctionEntry(ControlPc);
00218
00219
00220
00221
00222
00223
00224
00225
00226
if (FunctionEntry !=
NULL) {
00227 RtlMoveMemory(&ContextRecord2, &ContextRecord1,
sizeof(CONTEXT));
00228 LastPc =
RtlVirtualUnwind(ControlPc,
00229 FunctionEntry,
00230 &ContextRecord1,
00231 &InFunction,
00232 &EstablisherFrame,
00233
NULL);
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
if ((EstablisherFrame.Real < LowLimit) ||
00245 (EstablisherFrame.Virtual > HighLimit) ||
00246 (EstablisherFrame.Real > EstablisherFrame.Virtual) ||
00247 ((ARGUMENT_PRESENT(TargetRealFrame) !=
FALSE) &&
00248 ((ULONG_PTR)TargetRealFrame < EstablisherFrame.Real)) ||
00249 ((EstablisherFrame.Virtual & 0xF) != 0) ||
00250 ((EstablisherFrame.Real & 0xF) != 0)) {
00251
00252
#if DBG
00253
DbgPrint(
"\n****** Warning - bad stack or target frame (unwind).\n");
00254
DbgPrint(
" EstablisherFrame Virtual = %p, Real = %p\n",
00255 EstablisherFrame.Virtual, EstablisherFrame.Real);
00256
DbgPrint(
" TargetRealFrame = %p\n", TargetRealFrame);
00257
if ((ARGUMENT_PRESENT(TargetRealFrame) !=
FALSE) &&
00258 ((ULONG_PTR)TargetRealFrame < EstablisherFrame.Real)) {
00259
DbgPrint(
" TargetRealFrame is below EstablisherFrame.Real!\n");
00260 }
00261
DbgPrint(
" Previous EstablisherFrame (sp) = %p\n",
00262 (ULONG_PTR)ContextRecord2.IntSp);
00263
DbgPrint(
" LowLimit = %p, HighLimit = %p\n",
00264 LowLimit, HighLimit);
00265
DbgPrint(
" LastPc = %p, ControlPc = %p\n",
00266 LastPc, ControlPc);
00267
DbgPrint(
" Now raising STATUS_BAD_STACK exception.\n");
00268
#endif
00269
00270
RAISE_EXCEPTION(STATUS_BAD_STACK, ExceptionRecord);
00271
00272 }
else if (
IS_HANDLER_DEFINED(FunctionEntry) && InFunction) {
00273
00274
#if DBG
00275
if (RtlDebugFlags & RTL_DBG_DISPATCH_EXCEPTION_DETAIL) {
00276
DbgPrint(
"RtlUnwindRfp: ExceptionHandler = %p, HandlerData = %p\n",
00277 FunctionEntry->ExceptionHandler, FunctionEntry->HandlerData);
00278 }
00279
#endif
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297 DispatcherContext.ControlPc = ControlPc;
00298 DispatcherContext.FunctionEntry = FunctionEntry;
00299 DispatcherContext.EstablisherFrame = EstablisherFrame.Virtual;
00300 DispatcherContext.ContextRecord = &ContextRecord2;
00301
00302
00303
00304
00305
00306
do {
00307
00308
00309
00310
00311
00312
00313
if ((ULONG_PTR)TargetRealFrame == EstablisherFrame.Real) {
00314 ExceptionFlags |=
EXCEPTION_TARGET_UNWIND;
00315 }
00316
00317 ExceptionRecord->ExceptionFlags = ExceptionFlags;
00318
00319
00320
00321
00322
00323
00324 ContextRecord2.IntV0 = (ULONGLONG)(LONG_PTR)ReturnValue;
00325
00326
#if DBG
00327
if (RtlDebugFlags & RTL_DBG_UNWIND_DETAIL) {
00328
DbgPrint(
"RtlUnwindRfp: calling RtlpExecuteHandlerForUnwind, ControlPc = %p\n", ControlPc);
00329 }
00330
#endif
00331
00332 Disposition =
00333
RtlpExecuteHandlerForUnwind(ExceptionRecord,
00334 EstablisherFrame.Virtual,
00335 &ContextRecord2,
00336 &DispatcherContext,
00337 RF_EXCEPTION_HANDLER(FunctionEntry));
00338
00339
#if DBG
00340
if (RtlDebugFlags & RTL_DBG_UNWIND_DETAIL) {
00341
DbgPrint(
"RtlUnwindRfp: RtlpExecuteHandlerForUnwind returned Disposition = %lx\n", Disposition);
00342 }
00343
#endif
00344
00345
00346
00347
00348
00349 ExceptionFlags &= ~(
EXCEPTION_COLLIDED_UNWIND |
00350
EXCEPTION_TARGET_UNWIND);
00351
00352
00353
00354
00355
00356
switch (Disposition) {
00357
00358
00359
00360
00361
00362
00363
00364
00365
case ExceptionContinueSearch :
00366
break;
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
case ExceptionCollidedUnwind :
00379 ControlPc = DispatcherContext.ControlPc;
00380 FunctionEntry = DispatcherContext.FunctionEntry;
00381 RtlMoveMemory(&ContextRecord1,
00382 DispatcherContext.ContextRecord,
00383
sizeof(CONTEXT));
00384
00385 ContextRecord1.Fir = (ULONGLONG)(LONG_PTR)TargetIp;
00386 RtlMoveMemory(&ContextRecord2,
00387 &ContextRecord1,
00388
sizeof(CONTEXT));
00389
00390 ExceptionFlags |=
EXCEPTION_COLLIDED_UNWIND;
00391 LastPc =
RtlVirtualUnwind(ControlPc,
00392 FunctionEntry,
00393 &ContextRecord1,
00394 &InFunction,
00395 &EstablisherFrame,
00396
NULL);
00397
break;
00398
00399
00400
00401
00402
00403
00404
00405
default :
00406
RAISE_EXCEPTION(STATUS_INVALID_DISPOSITION, ExceptionRecord);
00407 }
00408
00409 }
while ((ExceptionFlags &
EXCEPTION_COLLIDED_UNWIND) != 0);
00410 }
00411
00412 }
else {
00413
00414
00415
00416
00417
00418 LastPc = (ULONG_PTR)ContextRecord1.IntRa - 4;
00419
00420
00421
00422
00423
00424
00425
if (LastPc == ControlPc) {
00426
00427
#if DBG
00428
ULONG
Count;
00429
DbgPrint(
"\n****** Warning - malformed function table (unwind).\n");
00430
DbgPrint(
"ControlPc = %p, %p", LastPc, ControlPc);
00431
for (
Count = 0;
Count < PC_HISTORY_DEPTH;
Count += 1) {
00432
if (ControlPcHistoryIndex > 0) {
00433 ControlPcHistoryIndex -= 1;
00434 ControlPc = ControlPcHistory[ControlPcHistoryIndex % PC_HISTORY_DEPTH];
00435
DbgPrint(
", %p", ControlPc);
00436 }
00437 }
00438
DbgPrint(ControlPcHistoryIndex == 0 ?
".\n" :
", ...\n");
00439
DbgPrint(
" Now raising STATUS_BAD_FUNCTION_TABLE exception.\n");
00440
#endif
00441
00442
RtlRaiseStatus(STATUS_BAD_FUNCTION_TABLE);
00443 }
00444 }
00445
00446
00447
00448
00449
00450
#if DBG
00451
ControlPcHistory[ControlPcHistoryIndex % PC_HISTORY_DEPTH] = ControlPc;
00452 ControlPcHistoryIndex += 1;
00453
#endif
00454
00455 ControlPc = LastPc;
00456
00457 }
while ((EstablisherFrame.Real < HighLimit) &&
00458 (EstablisherFrame.Real != (ULONG_PTR)TargetRealFrame));
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
if (EstablisherFrame.Real == (ULONG_PTR)TargetRealFrame) {
00469 ContextRecord2.IntV0 = (ULONGLONG)(LONG_PTR)ReturnValue;
00470
00471
#if DBG
00472
if (RtlDebugFlags & RTL_DBG_UNWIND) {
00473
DbgPrint(
"RtlUnwindRfp: finished unwinding, and calling RtlpRestoreContext\n");
00474 }
00475
#endif
00476
00477
RtlpRestoreContext(&ContextRecord2);
00478
00479 }
else {
00480
00481
#if DBG
00482
if (RtlDebugFlags & RTL_DBG_UNWIND) {
00483
DbgPrint(
"RtlUnwindRfp: finished unwinding, but calling ZwRaiseException\n");
00484 }
00485
#endif
00486
00487 ZwRaiseException(ExceptionRecord, &ContextRecord1,
FALSE);
00488 }
00489 }
00490
00491
VOID
00492 RtlUnwindReturn (
00493 IN PVOID TargetFrame,
00494 IN PEXCEPTION_RECORD ExceptionRecord OPTIONAL,
00495 IN PVOID ReturnValue
00496 )
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534 {
00535
00536 CONTEXT ContextRecord1;
00537 CONTEXT ContextRecord2;
00538 ULONG_PTR ControlPc;
00539
#if DBG
00540
ULONG_PTR ControlPcHistory[PC_HISTORY_DEPTH];
00541 ULONG ControlPcHistoryIndex = 0;
00542
#endif
00543
DISPATCHER_CONTEXT DispatcherContext;
00544 EXCEPTION_DISPOSITION Disposition;
00545 FRAME_POINTERS EstablisherFrame;
00546 ULONG ExceptionFlags;
00547 EXCEPTION_RECORD ExceptionRecord1;
00548
#if DBG
00549
LONG FrameDepth = 0;
00550
#endif
00551
PRUNTIME_FUNCTION FunctionEntry;
00552 ULONG_PTR HighLimit;
00553 BOOLEAN InFunction;
00554 ULONG_PTR LastPc;
00555 ULONG_PTR LowLimit;
00556
00557
#if DBG
00558
if (RtlDebugFlags & RTL_DBG_UNWIND) {
00559
DbgPrint(
"\nRtlUnwindReturn(TargetFrame = %p,, ReturnValue = %lx)\n",
00560 TargetFrame, ReturnValue);
00561 }
00562
#endif
00563
00564
00565
00566
00567
00568
00569
00570
RtlpGetStackLimits(&LowLimit, &HighLimit);
00571 RtlCaptureContext(&ContextRecord1);
00572 ControlPc = (ULONG_PTR)ContextRecord1.IntRa;
00573 FunctionEntry =
RtlLookupFunctionEntry(ControlPc);
00574 LastPc =
RtlVirtualUnwind(ControlPc,
00575 FunctionEntry,
00576 &ContextRecord1,
00577 &InFunction,
00578 &EstablisherFrame,
00579
NULL);
00580
00581 ControlPc = LastPc;
00582 ContextRecord1.Fir = 0;
00583
00584
00585
00586
00587
00588
00589
if (ARGUMENT_PRESENT(ExceptionRecord) ==
FALSE) {
00590 ExceptionRecord = &ExceptionRecord1;
00591 ExceptionRecord1.ExceptionCode = STATUS_UNWIND;
00592 ExceptionRecord1.ExceptionRecord =
NULL;
00593 ExceptionRecord1.ExceptionAddress = (PVOID)ControlPc;
00594 ExceptionRecord1.NumberParameters = 0;
00595 }
00596
00597
00598
00599
00600
00601
00602 ExceptionFlags =
EXCEPTION_UNWINDING;
00603
00604
00605
00606
00607
00608
00609
do {
00610
00611
#if DBG
00612
if (RtlDebugFlags & RTL_DBG_UNWIND_DETAIL) {
00613
DbgPrint(
"RtlUnwindReturn: Loop: FrameDepth = %d, sp = %p, ControlPc = %p\n",
00614 FrameDepth, (ULONG_PTR)ContextRecord1.IntSp, ControlPc);
00615 FrameDepth -= 1;
00616 }
00617
#endif
00618
00619
00620
00621
00622
00623
00624 FunctionEntry =
RtlLookupFunctionEntry(ControlPc);
00625
00626
00627
00628
00629
00630
00631
00632
00633
if (FunctionEntry !=
NULL) {
00634 RtlMoveMemory(&ContextRecord2, &ContextRecord1,
sizeof(CONTEXT));
00635 LastPc =
RtlVirtualUnwind(ControlPc,
00636 FunctionEntry,
00637 &ContextRecord1,
00638 &InFunction,
00639 &EstablisherFrame,
00640
NULL);
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
if ((EstablisherFrame.Virtual < LowLimit) ||
00652 (EstablisherFrame.Virtual > HighLimit) ||
00653 ((ULONG_PTR)TargetFrame < EstablisherFrame.Virtual) ||
00654 ((EstablisherFrame.Virtual & 0xF) != 0)) {
00655
00656
#if DBG
00657
DbgPrint(
"\n****** Warning - bad stack or target frame (unwind).\n");
00658
DbgPrint(
" EstablisherFrame Virtual = %p, Real = %p\n",
00659 EstablisherFrame.Virtual, EstablisherFrame.Real);
00660
DbgPrint(
" TargetFrame = %p\n", TargetFrame);
00661
if ((ARGUMENT_PRESENT(TargetFrame) !=
FALSE) &&
00662 ((ULONG_PTR)TargetFrame < EstablisherFrame.Virtual)) {
00663
DbgPrint(
" TargetFrame is below EstablisherFrame!\n");
00664 }
00665
DbgPrint(
" Previous EstablisherFrame (sp) = %p\n",
00666 (ULONG_PTR)ContextRecord2.IntSp);
00667
DbgPrint(
" LowLimit = %p, HighLimit = %p\n",
00668 LowLimit, HighLimit);
00669
DbgPrint(
" LastPc = %p, ControlPc = %p\n",
00670 LastPc, ControlPc);
00671
DbgPrint(
" Now raising STATUS_BAD_STACK exception.\n");
00672
#endif
00673
00674
RAISE_EXCEPTION(STATUS_BAD_STACK, ExceptionRecord);
00675
00676 }
else if (
IS_HANDLER_DEFINED(FunctionEntry) && InFunction) {
00677
00678
#if DBG
00679
if (RtlDebugFlags & RTL_DBG_DISPATCH_EXCEPTION_DETAIL) {
00680
DbgPrint(
"RtlUnwindReturn: ExceptionHandler = %p, HandlerData = %p\n",
00681 FunctionEntry->ExceptionHandler, FunctionEntry->HandlerData);
00682 }
00683
#endif
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701 DispatcherContext.ControlPc = ControlPc;
00702 DispatcherContext.FunctionEntry = FunctionEntry;
00703 DispatcherContext.EstablisherFrame = EstablisherFrame.Virtual;
00704 DispatcherContext.ContextRecord = &ContextRecord2;
00705
00706
00707
00708
00709
00710
do {
00711
00712
00713
00714
00715
00716
00717
if ((ULONG_PTR)TargetFrame == EstablisherFrame.Virtual) {
00718 ExceptionFlags |=
EXCEPTION_TARGET_UNWIND;
00719 }
00720
00721 ExceptionRecord->ExceptionFlags = ExceptionFlags;
00722
00723
00724
00725
00726
00727
00728 ContextRecord2.IntV0 = (ULONGLONG)(LONG_PTR)ReturnValue;
00729
00730
#if DBG
00731
if (RtlDebugFlags & RTL_DBG_UNWIND_DETAIL) {
00732
DbgPrint(
"RtlUnwindReturn: calling RtlpExecuteHandlerForUnwind, ControlPc = %p\n", ControlPc);
00733 }
00734
#endif
00735
00736 Disposition =
00737
RtlpExecuteHandlerForUnwind(ExceptionRecord,
00738 EstablisherFrame.Virtual,
00739 &ContextRecord2,
00740 &DispatcherContext,
00741 RF_EXCEPTION_HANDLER(FunctionEntry));
00742
00743
#if DBG
00744
if (RtlDebugFlags & RTL_DBG_UNWIND_DETAIL) {
00745
DbgPrint(
"RtlUnwindReturn: RtlpExecuteHandlerForUnwind returned Disposition = %lx\n", Disposition);
00746 }
00747
#endif
00748
00749
00750
00751
00752
00753 ExceptionFlags &= ~(
EXCEPTION_COLLIDED_UNWIND |
00754
EXCEPTION_TARGET_UNWIND);
00755
00756
00757
00758
00759
00760
switch (Disposition) {
00761
00762
00763
00764
00765
00766
00767
00768
00769
case ExceptionContinueSearch :
00770
break;
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
case ExceptionCollidedUnwind :
00783 ControlPc = DispatcherContext.ControlPc;
00784 FunctionEntry = DispatcherContext.FunctionEntry;
00785 RtlMoveMemory(&ContextRecord1,
00786 DispatcherContext.ContextRecord,
00787
sizeof(CONTEXT));
00788
00789 ContextRecord1.Fir = 0;
00790 RtlMoveMemory(&ContextRecord2,
00791 &ContextRecord1,
00792
sizeof(CONTEXT));
00793
00794 ExceptionFlags |=
EXCEPTION_COLLIDED_UNWIND;
00795 LastPc =
RtlVirtualUnwind(ControlPc,
00796 FunctionEntry,
00797 &ContextRecord1,
00798 &InFunction,
00799 &EstablisherFrame,
00800
NULL);
00801
break;
00802
00803
00804
00805
00806
00807
00808
00809
default :
00810
RAISE_EXCEPTION(STATUS_INVALID_DISPOSITION, ExceptionRecord);
00811 }
00812
00813 }
while ((ExceptionFlags &
EXCEPTION_COLLIDED_UNWIND) != 0);
00814 }
00815
00816 }
else {
00817
00818
00819
00820
00821
00822 LastPc = (ULONG_PTR)ContextRecord1.IntRa - 4;
00823
00824
00825
00826
00827
00828
00829
if (LastPc == ControlPc) {
00830
#if DBG
00831
ULONG
Count;
00832
DbgPrint(
"\n****** Warning - malformed function table (unwind).\n");
00833
DbgPrint(
"ControlPc = %p, %p", LastPc, ControlPc);
00834
for (
Count = 0;
Count < PC_HISTORY_DEPTH;
Count += 1) {
00835
if (ControlPcHistoryIndex > 0) {
00836 ControlPcHistoryIndex -= 1;
00837 ControlPc = ControlPcHistory[ControlPcHistoryIndex % PC_HISTORY_DEPTH];
00838
DbgPrint(
", %p", ControlPc);
00839 }
00840 }
00841
DbgPrint(ControlPcHistoryIndex == 0 ?
".\n" :
", ...\n");
00842
DbgPrint(
" Now raising STATUS_BAD_FUNCTION_TABLE exception.\n");
00843
#endif
00844
00845
RtlRaiseStatus(STATUS_BAD_FUNCTION_TABLE);
00846 }
00847 }
00848
00849
00850
00851
00852
00853
#if DBG
00854
ControlPcHistory[ControlPcHistoryIndex % PC_HISTORY_DEPTH] = ControlPc;
00855 ControlPcHistoryIndex += 1;
00856
#endif
00857
00858 ControlPc = LastPc;
00859
00860 }
while ((EstablisherFrame.Virtual < HighLimit) &&
00861 (EstablisherFrame.Virtual != (ULONG_PTR)TargetFrame));
00862
00863
00864
00865
00866
00867
00868
00869
00870
if ((ULONG_PTR)ContextRecord1.IntSp == (ULONG_PTR)TargetFrame) {
00871 ContextRecord1.IntV0 = (ULONGLONG)(LONG_PTR)ReturnValue;
00872
00873
00874
00875
00876
00877
00878 ContextRecord1.Fir = (ULONGLONG)(LONG_PTR)LastPc + 4;
00879
00880
#if DBG
00881
if (RtlDebugFlags & RTL_DBG_UNWIND) {
00882
DbgPrint(
"RtlUnwindReturn: finished unwinding, and calling RtlpRestoreContext\n");
00883 }
00884
#endif
00885
00886
RtlpRestoreContext(&ContextRecord1);
00887
00888 }
else {
00889
00890
#if DBG
00891
if (RtlDebugFlags & RTL_DBG_UNWIND) {
00892
DbgPrint(
"RtlUnwindReturn: finished unwinding, but calling ZwRaiseException\n");
00893 }
00894
#endif
00895
00896 ZwRaiseException(ExceptionRecord, &ContextRecord1,
FALSE);
00897 }
00898 }