@@ -7870,7 +7870,7 @@ BOOL IsIPInEE(void *ip)
7870
7870
}
7871
7871
}
7872
7872
7873
- #if defined(_TARGET_AMD64_ ) && defined(FEATURE_HIJACK )
7873
+ #if defined(FEATURE_HIJACK ) && (! defined(_TARGET_X86_) || defined(FEATURE_PAL) )
7874
7874
7875
7875
// This function is used to check if the specified IP is in the prolog or not.
7876
7876
bool IsIPInProlog (EECodeInfo *pCodeInfo)
@@ -7887,6 +7887,9 @@ bool IsIPInProlog(EECodeInfo *pCodeInfo)
7887
7887
7888
7888
_ASSERTE (pCodeInfo->IsValid ());
7889
7889
7890
+ #ifdef _TARGET_AMD64_
7891
+
7892
+ // Optimized version for AMD64 that doesn't need to go through the GC info decoding
7890
7893
PTR_RUNTIME_FUNCTION funcEntry = pCodeInfo->GetFunctionEntry ();
7891
7894
7892
7895
// We should always get a function entry for a managed method
@@ -7896,8 +7899,31 @@ bool IsIPInProlog(EECodeInfo *pCodeInfo)
7896
7899
PUNWIND_INFO pUnwindInfo = (PUNWIND_INFO)(pCodeInfo->GetModuleBase () + funcEntry->UnwindData );
7897
7900
7898
7901
// Check if the specified IP is beyond the prolog or not.
7899
- DWORD dwPrologLen = pUnwindInfo->SizeOfProlog ;
7900
- if (pCodeInfo->GetRelOffset () >= dwPrologLen)
7902
+ DWORD prologLen = pUnwindInfo->SizeOfProlog ;
7903
+
7904
+ #else // _TARGET_AMD64_
7905
+
7906
+ GCInfoToken gcInfoToken = pCodeInfo->GetGCInfoToken ();
7907
+
7908
+ #ifdef USE_GC_INFO_DECODER
7909
+
7910
+ GcInfoDecoder gcInfoDecoder (
7911
+ gcInfoToken,
7912
+ DECODE_PROLOG_LENGTH
7913
+ );
7914
+
7915
+ DWORD prologLen = gcInfoDecoder.GetPrologSize ();
7916
+
7917
+ #else // USE_GC_INFO_DECODER
7918
+
7919
+ size_t prologLen;
7920
+ pCodeInfo->GetCodeManager ()->IsInPrologOrEpilog (0 , gcInfoToken, &prologLen);
7921
+
7922
+ #endif // USE_GC_INFO_DECODER
7923
+
7924
+ #endif // _TARGET_AMD64_
7925
+
7926
+ if (pCodeInfo->GetRelOffset () >= prologLen)
7901
7927
{
7902
7928
fInsideProlog = false ;
7903
7929
}
@@ -7920,11 +7946,11 @@ bool IsIPInEpilog(PTR_CONTEXT pContextToCheck, EECodeInfo *pCodeInfo, BOOL *pSaf
7920
7946
CONTRACTL_END;
7921
7947
7922
7948
TADDR ipToCheck = GetIP (pContextToCheck);
7923
-
7949
+
7924
7950
_ASSERTE (pCodeInfo->IsValid ());
7925
-
7951
+
7926
7952
// The Codeinfo should correspond to the IP we are interested in.
7927
- _ASSERTE (ipToCheck == pCodeInfo->GetCodeAddress ());
7953
+ _ASSERTE (PCODEToPINSTR ( ipToCheck) == pCodeInfo->GetCodeAddress ());
7928
7954
7929
7955
// By default, assume its safe to inject the abort.
7930
7956
*pSafeToInjectThreadAbort = TRUE ;
@@ -7951,11 +7977,10 @@ bool IsIPInEpilog(PTR_CONTEXT pContextToCheck, EECodeInfo *pCodeInfo, BOOL *pSaf
7951
7977
// RtlVirtualUnwind against "ipToCheck" results in a NULL personality routine, it implies that we are inside
7952
7978
// the epilog.
7953
7979
7954
- DWORD64 imageBase = 0 ;
7955
- PUNWIND_INFO pUnwindInfo = NULL ;
7980
+ DWORD_PTR imageBase = 0 ;
7956
7981
CONTEXT tempContext;
7957
7982
PVOID HandlerData;
7958
- DWORD64 establisherFrame = 0 ;
7983
+ DWORD_PTR establisherFrame = 0 ;
7959
7984
PEXCEPTION_ROUTINE personalityRoutine = NULL ;
7960
7985
7961
7986
// Lookup the function entry for the IP
@@ -7965,7 +7990,6 @@ bool IsIPInEpilog(PTR_CONTEXT pContextToCheck, EECodeInfo *pCodeInfo, BOOL *pSaf
7965
7990
_ASSERTE (funcEntry != NULL );
7966
7991
7967
7992
imageBase = pCodeInfo->GetModuleBase ();
7968
- pUnwindInfo = (PUNWIND_INFO)(imageBase+ funcEntry->UnwindData );
7969
7993
7970
7994
ZeroMemory (&tempContext, sizeof (CONTEXT));
7971
7995
CopyOSContext (&tempContext, pContextToCheck);
@@ -7988,13 +8012,15 @@ bool IsIPInEpilog(PTR_CONTEXT pContextToCheck, EECodeInfo *pCodeInfo, BOOL *pSaf
7988
8012
// We are in epilog.
7989
8013
fIsInEpilog = true ;
7990
8014
8015
+ #ifdef _TARGET_AMD64_
7991
8016
// Check if context pointers has returned the address of the stack location in the hijacked function
7992
8017
// from where RBP was restored. If the address is NULL, then it implies that RBP has been popped off.
7993
8018
// Since JIT64 ensures that pop of RBP is the last instruction before ret/jmp, it implies its not safe
7994
8019
// to inject an abort @ this point as EstablisherFrame (which will be based
7995
8020
// of RBP for managed code since that is the FramePointer register, as indicated in the UnwindInfo)
7996
8021
// will be off and can result in bad managed exception dispatch.
7997
- if (ctxPtrs.Rbp == NULL )
8022
+ if (ctxPtrs.Rbp == NULL )
8023
+ #endif
7998
8024
{
7999
8025
*pSafeToInjectThreadAbort = FALSE ;
8000
8026
}
@@ -8003,7 +8029,7 @@ bool IsIPInEpilog(PTR_CONTEXT pContextToCheck, EECodeInfo *pCodeInfo, BOOL *pSaf
8003
8029
return fIsInEpilog ;
8004
8030
}
8005
8031
8006
- #endif // defined(_TARGET_AMD64_) && defined(FEATURE_HIJACK )
8032
+ #endif // FEATURE_HIJACK && (!_TARGET_X86_ || FEATURE_PAL )
8007
8033
8008
8034
#define EXCEPTION_VISUALCPP_DEBUGGER ((DWORD) (1 <<30 | 0x6D <<16 | 5000 ))
8009
8035
0 commit comments