Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

103 lines
2.9 KiB

//
// Created by GautamB 06/01/01
// Based on IA64 ehstate.h
//
extern "C" {
#include "windows.h"
}
#include "ehassert.h"
#include "ehdata.h" // Declarations of all types used for EH
#include "ehstate.h"
#include "eh.h"
#include "ehhooks.h"
#include "trnsctrl.h"
#pragma hdrstop
__ehstate_t __StateFromIp(
FuncInfo *pFuncInfo,
DispatcherContext *pDC,
__int64 Ip
) {
unsigned int index; // loop control variable
unsigned int nIPMapEntry; // # of IpMapEntry; must be > 0
DASSERT(pFuncInfo != NULL);
nIPMapEntry = FUNC_NIPMAPENT(*pFuncInfo);
DASSERT(FUNC_IPMAP(*pFuncInfo, pDC->ImageBase) != NULL);
for (index = 0; index < nIPMapEntry; index++) {
IptoStateMapEntry *pIPtoStateMap = FUNC_PIPTOSTATE(*pFuncInfo, index, pDC->ImageBase);
if( Ip < (pDC->ImageBase + pIPtoStateMap->Ip) ) {
break;
}
}
if (index == 0) {
// We are at the first entry, could be an error
return EH_EMPTY_STATE;
}
// We over-shot one iteration; return state from the previous slot
return FUNC_IPTOSTATE(*pFuncInfo, index - 1, pDC->ImageBase).State;
}
__ehstate_t __StateFromControlPc(
FuncInfo *pFuncInfo,
DispatcherContext *pDC
) {
return __StateFromIp(pFuncInfo, pDC, pDC->ControlPc);
}
//
// This routine is a replacement for the corresponding macro in 'ehdata.h'
//
__ehstate_t __GetCurrentState(
EHRegistrationNode *pFrame,
DispatcherContext *pDC,
FuncInfo *pFuncInfo
) {
if( UNWINDSTATE(*pFrame, FUNC_DISPUNWINDHELP(*pFuncInfo)) == -2 ) {
return __StateFromControlPc(pFuncInfo, pDC);
}
else {
return UNWINDSTATE(*pFrame, FUNC_DISPUNWINDHELP(*pFuncInfo));
}
}
VOID __SetState(
EHRegistrationNode *pRN,
DispatcherContext *pDC,
FuncInfo *pFuncInfo,
__ehstate_t newState
){
UNWINDSTATE(*pRN, FUNC_DISPUNWINDHELP(*pFuncInfo)) = (int)newState;
}
VOID __SetUnwindTryBlock(
EHRegistrationNode *pRN,
DispatcherContext *pDC,
FuncInfo *pFuncInfo,
INT curState
){
EHRegistrationNode EstablisherFramePointers;
EstablisherFramePointers = *_GetEstablisherFrame(pRN, pDC, pFuncInfo, &EstablisherFramePointers);
if( curState > UNWINDTRYBLOCK(EstablisherFramePointers, FUNC_DISPUNWINDHELP(*pFuncInfo)) ) {
UNWINDTRYBLOCK(EstablisherFramePointers, FUNC_DISPUNWINDHELP(*pFuncInfo)) = (int)curState;
}
}
INT __GetUnwindTryBlock(
EHRegistrationNode *pRN,
DispatcherContext *pDC,
FuncInfo *pFuncInfo
){
EHRegistrationNode EstablisherFramePointers;
EstablisherFramePointers = *_GetEstablisherFrame(pRN, pDC, pFuncInfo, &EstablisherFramePointers);
return UNWINDTRYBLOCK(EstablisherFramePointers, FUNC_DISPUNWINDHELP(*pFuncInfo));
}