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