mirror of https://github.com/x64dbg/TitanEngine
Fixed AVX YMM registers
This commit is contained in:
parent
ee9fc93b96
commit
d572dd2bfc
|
|
@ -594,6 +594,12 @@ typedef struct
|
|||
DWORD OriginalCOMTableSize;
|
||||
} FILE_FIX_INFO, *PFILE_FIX_INFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
M128A Low; //XMM/SSE part
|
||||
M128A High; //AVX part
|
||||
} YmmRegister_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BYTE data[10];
|
||||
|
|
@ -652,10 +658,10 @@ typedef struct
|
|||
DWORD MxCsr;
|
||||
#ifdef _WIN64
|
||||
M128A XmmRegisters[16];
|
||||
BYTE YmmRegisters[32 * 16];
|
||||
YmmRegister_t YmmRegisters[16];
|
||||
#else // x86
|
||||
M128A XmmRegisters[8];
|
||||
BYTE YmmRegisters[32 * 8];
|
||||
YmmRegister_t YmmRegisters[8];
|
||||
#endif
|
||||
} TITAN_ENGINE_CONTEXT_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -962,32 +962,20 @@ __declspec(dllexport) bool TITCALL SetAVXContext(HANDLE hActiveThread, TITAN_ENG
|
|||
return false;
|
||||
|
||||
DWORD FeatureLength;
|
||||
PM128A Xmm = (PM128A)_LocateXStateFeature(Context, XSTATE_LEGACY_SSE, &FeatureLength);
|
||||
if(Xmm != NULL) //If the feature is unsupported by the processor it will return NULL
|
||||
PM128A Sse = (PM128A)_LocateXStateFeature(Context, XSTATE_LEGACY_SSE, &FeatureLength);
|
||||
PM128A Avx = (PM128A)_LocateXStateFeature(Context, XSTATE_AVX, NULL);
|
||||
int NumberOfRegisters = FeatureLength / sizeof(Sse[0]);
|
||||
|
||||
if(Sse != NULL) //If the feature is unsupported by the processor it will return NULL
|
||||
{
|
||||
for(DWORD Index = 0; Index < FeatureLength / sizeof(* Xmm); Index += 1)
|
||||
{
|
||||
memcpy
|
||||
(
|
||||
Xmm++,
|
||||
((char*) & (titcontext->YmmRegisters[32 * Index])),
|
||||
sizeof(Xmm[Index])
|
||||
);
|
||||
}
|
||||
for(int i = 0; i < NumberOfRegisters; i++)
|
||||
Sse[i] = titcontext->YmmRegisters[i].Low;
|
||||
}
|
||||
|
||||
PM128A Ymm = (PM128A)_LocateXStateFeature(Context, XSTATE_AVX, NULL);
|
||||
if(Ymm != NULL) //If the feature is unsupported by the processor it will return NULL
|
||||
if(Avx != NULL) //If the feature is unsupported by the processor it will return NULL
|
||||
{
|
||||
for(DWORD Index = 0; Index < FeatureLength / sizeof(* Ymm); Index += 1)
|
||||
{
|
||||
memcpy
|
||||
(
|
||||
Ymm++,
|
||||
((char*) & (titcontext->YmmRegisters[32 * Index])) + sizeof(titcontext->XmmRegisters[Index]),
|
||||
sizeof(Ymm[Index])
|
||||
);
|
||||
}
|
||||
for(int i = 0; i < NumberOfRegisters; i++)
|
||||
Avx[i] = titcontext->YmmRegisters[i].High;
|
||||
}
|
||||
|
||||
return (SetThreadContext(hActiveThread, Context) == TRUE);
|
||||
|
|
@ -1034,32 +1022,20 @@ __declspec(dllexport) bool TITCALL GetAVXContext(HANDLE hActiveThread, TITAN_ENG
|
|||
return false;
|
||||
|
||||
DWORD FeatureLength;
|
||||
PM128A Xmm = (PM128A)_LocateXStateFeature(Context, XSTATE_LEGACY_SSE, &FeatureLength);
|
||||
if(Xmm != NULL) //If the feature is unsupported by the processor it will return NULL
|
||||
PM128A Sse = (PM128A)_LocateXStateFeature(Context, XSTATE_LEGACY_SSE, &FeatureLength);
|
||||
PM128A Avx = (PM128A)_LocateXStateFeature(Context, XSTATE_AVX, NULL);
|
||||
int NumberOfRegisters = FeatureLength / sizeof(Sse[0]);
|
||||
|
||||
if(Sse != NULL) //If the feature is unsupported by the processor it will return NULL
|
||||
{
|
||||
for(DWORD Index = 0; Index < FeatureLength / sizeof(*Xmm); Index++)
|
||||
{
|
||||
memcpy
|
||||
(
|
||||
(char*) & (titcontext->YmmRegisters[32 * Index]),
|
||||
Xmm++,
|
||||
sizeof(Xmm[Index])
|
||||
);
|
||||
}
|
||||
for(int i = 0; i < NumberOfRegisters; i++)
|
||||
titcontext->YmmRegisters[i].Low = Sse[i];
|
||||
}
|
||||
|
||||
PM128A Ymm = (PM128A)_LocateXStateFeature(Context, XSTATE_AVX, &FeatureLength);
|
||||
if(Ymm != NULL) //If the feature is unsupported by the processor it will return NULL
|
||||
if(Avx != NULL) //If the feature is unsupported by the processor it will return NULL
|
||||
{
|
||||
for(DWORD Index = 0; Index < FeatureLength / sizeof(*Ymm); Index++)
|
||||
{
|
||||
memcpy
|
||||
(
|
||||
((char*) & (titcontext->YmmRegisters[32 * Index])) + sizeof(titcontext->XmmRegisters[Index]),
|
||||
Ymm++,
|
||||
sizeof(Ymm[Index])
|
||||
);
|
||||
}
|
||||
for(int i = 0; i < NumberOfRegisters; i++)
|
||||
titcontext->YmmRegisters[i].High = Avx[i];
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -93,6 +93,12 @@
|
|||
#define CONTEXT_EXTENDED_REGISTERS 0
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
M128A Low; //XMM/SSE part
|
||||
M128A High; //AVX part
|
||||
} YmmRegister_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BYTE data[10];
|
||||
|
|
@ -151,10 +157,10 @@ typedef struct
|
|||
DWORD MxCsr;
|
||||
#ifdef _WIN64
|
||||
M128A XmmRegisters[16];
|
||||
BYTE YmmRegisters[32 * 16];
|
||||
YmmRegister_t YmmRegisters[16];
|
||||
#else // x86
|
||||
M128A XmmRegisters[8];
|
||||
BYTE YmmRegisters[32 * 8];
|
||||
YmmRegister_t YmmRegisters[8];
|
||||
#endif
|
||||
} TITAN_ENGINE_CONTEXT_t;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue