throw std::move(ex);
}
-#ifdef _AMD64_
+#if defined(_TARGET_AMD64_) || defined(_TARGET_X86_)
/*++
Function :
--*/
VOID* GetRegisterAddressByIndex(PCONTEXT pContext, UINT index)
{
+#if defined(_TARGET_AMD64_)
_ASSERTE(index < 16);
return &((&pContext->Rax)[index]);
+#elif defined(_TARGET_X86_)
+ _ASSERTE(index < 8);
+
+ static const SIZE_T OFFSET_OF_REGISTERS[] =
+ {
+ offsetof(CONTEXT, Eax),
+ offsetof(CONTEXT, Ecx),
+ offsetof(CONTEXT, Edx),
+ offsetof(CONTEXT, Ebx),
+ offsetof(CONTEXT, Esp),
+ offsetof(CONTEXT, Ebp),
+ offsetof(CONTEXT, Esi),
+ offsetof(CONTEXT, Edi),
+ };
+
+ return (VOID*)(PBYTE(pContext) + OFFSET_OF_REGISTERS[index]);
+#else
+ PORTABILITY_ASSERT("GetRegisterAddressByIndex");
+ return NULL;
+#endif
}
/*++
--*/
bool IsDivByZeroAnIntegerOverflow(PCONTEXT pContext)
{
- BYTE * ip = (BYTE*)pContext->Rip;
+ BYTE * ip = (BYTE *)GetIP(pContext);
BYTE rex = 0;
bool hasOpSizePrefix = false;
// must have been an overflow.
return divisor != 0;
}
-#endif //_AMD64_
+#endif // _TARGET_AMD64_ || _TARGET_X86_
BOOL IsSafeToCallExecutionManager()
{
return TRUE;
}
-#ifdef _AMD64_
+#if defined(_TARGET_AMD64_) || defined(_TARGET_X86_)
// It is possible that an overflow was mapped to a divide-by-zero exception.
// This happens when we try to divide the maximum negative value of a
// signed integer with -1.
// The exception was an integer overflow, so augment the exception code.
ex->GetExceptionRecord()->ExceptionCode = EXCEPTION_INT_OVERFLOW;
}
-#endif //_AMD64_
+#endif // _TARGET_AMD64_ || _TARGET_X86_
// Create frame necessary for the exception handling
FrameWithCookie<FaultingExceptionFrame> fef;