mirror of https://github.com/x64dbg/zydis
Merge branch 'develop' of https://github.com/zyantific/zyan-disassembler-engine into develop
This commit is contained in:
commit
d7775dcfaa
|
@ -39,6 +39,7 @@
|
||||||
# include <mach/mach_time.h>
|
# include <mach/mach_time.h>
|
||||||
#elif defined(ZYDIS_LINUX)
|
#elif defined(ZYDIS_LINUX)
|
||||||
# include <sys/time.h>
|
# include <sys/time.h>
|
||||||
|
# inlcude <pthread.h>
|
||||||
#else
|
#else
|
||||||
# error "Unsupported platform detected"
|
# error "Unsupported platform detected"
|
||||||
#endif
|
#endif
|
||||||
|
@ -47,6 +48,10 @@
|
||||||
/* Helper functions */
|
/* Helper functions */
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
/* Time measurement */
|
||||||
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#if defined(ZYDIS_WINDOWS)
|
#if defined(ZYDIS_WINDOWS)
|
||||||
double CounterFreq = 0.0;
|
double CounterFreq = 0.0;
|
||||||
uint64_t CounterStart = 0;
|
uint64_t CounterStart = 0;
|
||||||
|
@ -93,6 +98,42 @@ double GetCounter()
|
||||||
// TODO:
|
// TODO:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
/* Process & Thread Priority */
|
||||||
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void adjustProcessAndThreadPriority()
|
||||||
|
{
|
||||||
|
#ifdef ZYDIS_WINDOWS
|
||||||
|
SYSTEM_INFO info;
|
||||||
|
GetSystemInfo(&info);
|
||||||
|
if (info.dwNumberOfProcessors > 1)
|
||||||
|
{
|
||||||
|
if (!SetThreadAffinityMask(GetCurrentThread(), (DWORD_PTR)1))
|
||||||
|
{
|
||||||
|
fputs("Warning: Could not set thread affinity mask.", stderr);
|
||||||
|
}
|
||||||
|
if (!SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS))
|
||||||
|
{
|
||||||
|
fputs("Warning: Could not set process priority class.", stderr);
|
||||||
|
}
|
||||||
|
if (!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL))
|
||||||
|
{
|
||||||
|
fputs("Warning: Could not set thread priority class.", stderr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef ZYDIS_LINUX
|
||||||
|
pthread_t thread = pthread_self();
|
||||||
|
cpu_set_t cpus;
|
||||||
|
CPU_ZERO(&cpus);
|
||||||
|
CPU_SET(cpu, &cpus);
|
||||||
|
pthread_setaffinity_np(thread, sizeof(cpus), &cpus);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
/* Internal functions */
|
/* Internal functions */
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
@ -150,6 +191,10 @@ uint64_t processBuffer(const char* buffer, size_t length, ZydisDecodeGranularity
|
||||||
void testPerformance(const char* buffer, size_t length, ZydisDecodeGranularity granularity,
|
void testPerformance(const char* buffer, size_t length, ZydisDecodeGranularity granularity,
|
||||||
ZydisBool format)
|
ZydisBool format)
|
||||||
{
|
{
|
||||||
|
// Cache warmup
|
||||||
|
processBuffer(buffer, length, granularity, format);
|
||||||
|
|
||||||
|
// Testing
|
||||||
uint64_t count = 0;
|
uint64_t count = 0;
|
||||||
StartCounter();
|
StartCounter();
|
||||||
for (uint8_t j = 0; j < 100; ++j)
|
for (uint8_t j = 0; j < 100; ++j)
|
||||||
|
@ -289,6 +334,8 @@ int main(int argc, char** argv)
|
||||||
srand((unsigned)time(&t));
|
srand((unsigned)time(&t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
adjustProcessAndThreadPriority();
|
||||||
|
|
||||||
for (uint8_t i = 0; i < ZYDIS_ARRAY_SIZE(tests); ++i)
|
for (uint8_t i = 0; i < ZYDIS_ARRAY_SIZE(tests); ++i)
|
||||||
{
|
{
|
||||||
FILE* file;
|
FILE* file;
|
||||||
|
|
|
@ -3176,6 +3176,7 @@ static ZydisStatus ZydisDecodeOptionalInstructionParts(ZydisDecoderContext* cont
|
||||||
default:
|
default:
|
||||||
ZYDIS_UNREACHABLE;
|
ZYDIS_UNREACHABLE;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
case 64:
|
case 64:
|
||||||
hasSIB =
|
hasSIB =
|
||||||
|
|
Loading…
Reference in New Issue