00068                    :
00069 
00070     This function scans 
the scope tables associated with 
the specified
00071     
procedure and calls exception and termination handlers as necessary.
00072 
00073 Arguments:
00074 
00075     ExceptionRecord - Supplies a pointer to an exception record.
00076 
00077     MemoryStackFp - Supplies a pointer to memory stack frame of 
the 
00078         establisher function.
00079 
00080     BackingStoreFp - Supplies a pointer to RSE stack frame of 
the 
00081         establisher function.
00082 
00083     ContextRecord - Supplies a pointer to a context record.
00084 
00085     DispatcherContext - Supplies a pointer to 
the exception dispatcher or
00086         unwind dispatcher context.
00087 
00088 Return Value:
00089 
00090     If 
the exception 
is handled by one of 
the exception filter 
routines, then
00091     there 
is no 
return from 
this routine and 
RtlUnwind is called. Otherwise,
00092     an exception disposition value of 
continue execution or 
continue search 
is
00093     returned.
00094 
00095 --*/
00096 
00097 {
00098     ULONGLONG ImageBase;
00099     ULONGLONG ControlPc;
00100     ULONGLONG TargetPc;
00101     ULONGLONG Handler;
00102     EXCEPTION_POINTERS ExceptionPointers;
00103     PRUNTIME_FUNCTION FunctionEntry;
00104     ULONG 
Index;
00105     ULONG 
Size;
00106     PSCOPE_TABLE ScopeTable;
00107     LONG Value;
00108 
00109     
00110     
00111     
00112     
00113     
00114 
00115     FunctionEntry = DispatcherContext->FunctionEntry;
00116     ImageBase = DispatcherContext->ImageBase;
00117     ScopeTable = (PSCOPE_TABLE) (ImageBase + *(PULONG) 
00118                      GetLanguageSpecificData(FunctionEntry, ImageBase));
00119 
00120     ControlPc = DispatcherContext->ControlPc - ImageBase;
00121 
00122     
00123     
00124     
00125     
00126     
00127     
00128     
00129 
00130     
if (IS_DISPATCHING(ExceptionRecord->ExceptionFlags)) {
00131 
00132         
00133         
00134         
00135         
00136 
00137         ExceptionPointers.ExceptionRecord = ExceptionRecord;
00138         ExceptionPointers.ContextRecord = ContextRecord;
00139         
for (
Index = 0; 
Index < ScopeTable->Count; 
Index += 1) {
00140             
if ((ControlPc >= ScopeTable->ScopeRecord[
Index].BeginAddress) &&
00141                 (ControlPc < ScopeTable->ScopeRecord[
Index].EndAddress) &&
00142                 (ScopeTable->ScopeRecord[
Index].JumpTarget != 0)) {
00143 
00144                 
00145                 
00146                 
00147 
00148                 ULONG 
Offset = ScopeTable->ScopeRecord[
Index].HandlerAddress;
00149 
00150                 
switch (
Offset & 0x7) {
00151 
00152                 
case 7:
00153                     Value = 
EXCEPTION_EXECUTE_HANDLER;
00154                     
break;
00155 
00156                 
case 5:
00157                     Value = 
EXCEPTION_CONTINUE_SEARCH;
00158                     
break;
00159 
00160                 
case 3:
00161                     Value = 
EXCEPTION_CONTINUE_EXECUTION;
00162                     
break;
00163 
00164                 
default:
00165                     Value = 
__C_ExecuteExceptionFilter(
00166                                 MemoryStackFp,
00167                                 BackingStoreFp,
00168                                 ExceptionRecord->ExceptionCode,
00169                                 &ExceptionPointers,
00170                                 (ImageBase + Offset),
00171                                 GlobalPointer);
00172                     
break;
00173                 }
00174 
00175                 
00176                 
00177                 
00178                 
00179                 
00180                 
00181 
00182                 
if (Value < 0) {
00183                     
return ExceptionContinueExecution;
00184 
00185                 } 
else if (Value > 0) {
00186 
00187                     FRAME_POINTERS EstablisherFrame = {MemoryStackFp,
00188                                                        BackingStoreFp};
00189 
00190                     
RtlUnwind2(EstablisherFrame,
00191                                (PVOID)(ImageBase + ScopeTable->ScopeRecord[Index].JumpTarget),
00192                                ExceptionRecord,
00193                                (PVOID)(ULONGLONG)ExceptionRecord->ExceptionCode,
00194                                ContextRecord);
00195                 }
00196             }
00197         }
00198 
00199     } 
else {
00200 
00201         
00202         
00203         
00204         
00205 
00206         TargetPc = ContextRecord->StIIP - ImageBase;
00207         
for (
Index = 0; 
Index < ScopeTable->Count; 
Index += 1) {
00208             
if ((ControlPc >= ScopeTable->ScopeRecord[
Index].BeginAddress) &&
00209                 (ControlPc < ScopeTable->ScopeRecord[
Index].EndAddress)) {
00210 
00211                 
00212                 
00213                 
00214                 
00215                 
00216                 
00217                 
00218                 
00219                 
00220 
00221 
00222                 
if ((TargetPc >= ScopeTable->ScopeRecord[
Index].BeginAddress) &&
00223                    (TargetPc < ScopeTable->ScopeRecord[
Index].EndAddress)) {
00224                     
break;
00225 
00226                 } 
else {
00227 
00228                     
00229                     
00230                     
00231                     
00232                     
00233                     
00234                     
00235                     
00236                     
00237 
00238                     
if (ScopeTable->ScopeRecord[
Index].JumpTarget != 0) {
00239                         
if (TargetPc == ScopeTable->ScopeRecord[
Index].JumpTarget) {
00240                             
break;
00241                         }
00242 
00243                     } 
else {
00244 
00245                         DispatcherContext->ControlPc = ImageBase +
00246                                 ScopeTable->ScopeRecord[
Index].EndAddress;
00247 
00248                         Handler = ImageBase + ScopeTable->ScopeRecord[
Index].HandlerAddress;
00249                         
__C_ExecuteTerminationHandler(
00250                             MemoryStackFp,
00251                             BackingStoreFp,
00252                             TRUE,
00253                             Handler,
00254                             GlobalPointer);
00255                     }
00256                 }
00257             }
00258         }
00259     }
00260 
00261     
00262     
00263     
00264 
00265     
return ExceptionContinueSearch;
00266 }
}