mirror of https://github.com/x64dbg/TitanEngine
hopefully fixed a crash with getting/setting the AVX context on unsupported systems
This commit is contained in:
parent
60c7a748b4
commit
e3107e6dd3
|
|
@ -82,7 +82,7 @@ __declspec(dllexport) bool TITCALL _SetFullContextDataEx(HANDLE hActiveThread, T
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGContext.EFlags = titcontext->eflags;
|
DBGContext.EFlags = (DWORD)titcontext->eflags;
|
||||||
DBGContext.Dr0 = titcontext->dr0;
|
DBGContext.Dr0 = titcontext->dr0;
|
||||||
DBGContext.Dr1 = titcontext->dr1;
|
DBGContext.Dr1 = titcontext->dr1;
|
||||||
DBGContext.Dr2 = titcontext->dr2;
|
DBGContext.Dr2 = titcontext->dr2;
|
||||||
|
|
@ -1244,8 +1244,8 @@ __declspec(dllexport) bool TITCALL SetAVXContext(HANDLE hActiveThread, TITAN_ENG
|
||||||
goto Cleanup;
|
goto Cleanup;
|
||||||
|
|
||||||
Xmm = (PM128A)pfnLocateXStateFeature(Context, XSTATE_LEGACY_SSE, &FeatureLength);
|
Xmm = (PM128A)pfnLocateXStateFeature(Context, XSTATE_LEGACY_SSE, &FeatureLength);
|
||||||
Ymm = (PM128A)pfnLocateXStateFeature(Context, XSTATE_AVX, NULL);
|
if(Xmm != NULL) //If the feature is unsupported by the processor it will return NULL
|
||||||
|
{
|
||||||
for(Index = 0; Index < FeatureLength / sizeof(* Ymm); Index += 1)
|
for(Index = 0; Index < FeatureLength / sizeof(* Ymm); Index += 1)
|
||||||
{
|
{
|
||||||
memcpy
|
memcpy
|
||||||
|
|
@ -1254,7 +1254,13 @@ __declspec(dllexport) bool TITCALL SetAVXContext(HANDLE hActiveThread, TITAN_ENG
|
||||||
((char*) & (titcontext->YmmRegisters[32 * Index])),
|
((char*) & (titcontext->YmmRegisters[32 * Index])),
|
||||||
sizeof(Xmm[Index])
|
sizeof(Xmm[Index])
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ymm = (PM128A)pfnLocateXStateFeature(Context, XSTATE_AVX, NULL);
|
||||||
|
if(Ymm != NULL) //If the feature is unsupported by the processor it will return NULL
|
||||||
|
{
|
||||||
|
for(Index = 0; Index < FeatureLength / sizeof(* Ymm); Index += 1)
|
||||||
|
{
|
||||||
memcpy
|
memcpy
|
||||||
(
|
(
|
||||||
Ymm++,
|
Ymm++,
|
||||||
|
|
@ -1262,6 +1268,7 @@ __declspec(dllexport) bool TITCALL SetAVXContext(HANDLE hActiveThread, TITAN_ENG
|
||||||
sizeof(Ymm[Index])
|
sizeof(Ymm[Index])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Success = SetThreadContext(hActiveThread, Context);
|
Success = SetThreadContext(hActiveThread, Context);
|
||||||
if(Success == FALSE)
|
if(Success == FALSE)
|
||||||
|
|
@ -1330,9 +1337,9 @@ __declspec(dllexport) bool TITCALL GetAVXContext(HANDLE hActiveThread, TITAN_ENG
|
||||||
if(Success == FALSE)
|
if(Success == FALSE)
|
||||||
goto Cleanup;
|
goto Cleanup;
|
||||||
|
|
||||||
Ymm = (PM128A)pfnLocateXStateFeature(Context, XSTATE_AVX, &FeatureLength);
|
|
||||||
Xmm = (PM128A)pfnLocateXStateFeature(Context, XSTATE_LEGACY_SSE, &FeatureLength);
|
Xmm = (PM128A)pfnLocateXStateFeature(Context, XSTATE_LEGACY_SSE, &FeatureLength);
|
||||||
|
if(Xmm != NULL) //If the feature is unsupported by the processor it will return NULL
|
||||||
|
{
|
||||||
for(Index = 0; Index < FeatureLength / sizeof(* Ymm); Index += 1)
|
for(Index = 0; Index < FeatureLength / sizeof(* Ymm); Index += 1)
|
||||||
{
|
{
|
||||||
memcpy
|
memcpy
|
||||||
|
|
@ -1341,6 +1348,14 @@ __declspec(dllexport) bool TITCALL GetAVXContext(HANDLE hActiveThread, TITAN_ENG
|
||||||
Xmm++,
|
Xmm++,
|
||||||
sizeof(Xmm[Index])
|
sizeof(Xmm[Index])
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ymm = (PM128A)pfnLocateXStateFeature(Context, XSTATE_AVX, &FeatureLength);
|
||||||
|
if(Ymm != NULL) //If the feature is unsupported by the processor it will return NULL
|
||||||
|
{
|
||||||
|
for(Index = 0; Index < FeatureLength / sizeof(* Ymm); Index += 1)
|
||||||
|
{
|
||||||
memcpy
|
memcpy
|
||||||
(
|
(
|
||||||
((char*) & (titcontext->YmmRegisters[32 * Index])) + sizeof(titcontext->XmmRegisters[Index]),
|
((char*) & (titcontext->YmmRegisters[32 * Index])) + sizeof(titcontext->XmmRegisters[Index]),
|
||||||
|
|
@ -1348,6 +1363,7 @@ __declspec(dllexport) bool TITCALL GetAVXContext(HANDLE hActiveThread, TITAN_ENG
|
||||||
sizeof(Ymm[Index])
|
sizeof(Ymm[Index])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
returnf = true;
|
returnf = true;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue