#ifndef TARGET_UNIX
#ifdef TARGET_X86
+
//****************************************************************************************
// This will check who caused the exception. If it was caused by the the redirect function,
// the reason is to resume the thread back at the point it was redirected in the first
pFrame->Pop();
// Copy the saved context record into the EH context;
- ReplaceExceptionContextRecord(pExcepPtrs->ContextRecord, pCtx);
+ // NB: cannot use ReplaceExceptionContextRecord here.
+ // these contexts may contain extended registers and may have different format
+ // for reasons such as alignment or context compaction
+ CONTEXT* pTarget = pExcepPtrs->ContextRecord;
+ if (!CopyContext(pTarget, pTarget->ContextFlags, pCtx))
+ {
+ STRESS_LOG1(LF_SYNC, LL_ERROR, "ERROR: Could not set context record, lastError = 0x%x\n", GetLastError());
+ EEPOLICY_HANDLE_FATAL_ERROR(COR_E_EXECUTIONENGINE);
+ }
DWORD espValue = pCtx->Esp;