@@ -3721,9 +3721,14 @@ HRESULT CordbUnmanagedThread::SetupFirstChanceHijackForSync()
3721
3721
LOG ((LF_CORDB, LL_INFO10000, " CUT::SFCHFS: hijackCtx started as:\n " ));
3722
3722
LogContext (GetHijackCtx ());
3723
3723
3724
- // Save the thread's full context.
3724
+ // Save the thread's full context + DT_CONTEXT_EXTENDED_REGISTERS
3725
+ // to avoid getting incomplete information and corrupt the thread context
3725
3726
DT_CONTEXT context;
3727
+ #if defined(DT_CONTEXT_EXTENDED_REGISTERS)
3728
+ context.ContextFlags = DT_CONTEXT_FULL | DT_CONTEXT_EXTENDED_REGISTERS;
3729
+ #else
3726
3730
context.ContextFlags = DT_CONTEXT_FULL;
3731
+ #endif
3727
3732
BOOL succ = DbiGetThreadContext (m_handle, &context);
3728
3733
_ASSERTE (succ);
3729
3734
// for debugging when GetThreadContext fails
@@ -3732,8 +3737,11 @@ HRESULT CordbUnmanagedThread::SetupFirstChanceHijackForSync()
3732
3737
DWORD error = GetLastError ();
3733
3738
LOG ((LF_CORDB, LL_ERROR, " CUT::SFCHFS: DbiGetThreadContext error=0x%x\n " , error));
3734
3739
}
3735
-
3740
+ #if defined(DT_CONTEXT_EXTENDED_REGISTERS)
3741
+ GetHijackCtx ()->ContextFlags = DT_CONTEXT_FULL | DT_CONTEXT_EXTENDED_REGISTERS;
3742
+ #else
3736
3743
GetHijackCtx ()->ContextFlags = DT_CONTEXT_FULL;
3744
+ #endif
3737
3745
CORDbgCopyThreadContext (GetHijackCtx (), &context);
3738
3746
LOG ((LF_CORDB, LL_INFO10000, " CUT::SFCHFS: thread=0x%x Hijacking for sync. Original context is:\n " , this ));
3739
3747
LogContext (GetHijackCtx ());
0 commit comments