externals: Update zydis to 4.0.0

Merge commit '6fa8d51479'
This commit is contained in:
Alexandre Bouvier 2022-11-20 21:52:58 +01:00
commit cbeed6396f
394 changed files with 61415 additions and 39455 deletions

View file

@ -147,9 +147,9 @@ DriverEntry(
// Initialize Zydis decoder and formatter
ZydisDecoder decoder;
#ifdef _M_AMD64
if (!ZYAN_SUCCESS(ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_ADDRESS_WIDTH_64)))
if (!ZYAN_SUCCESS(ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_STACK_WIDTH_64)))
#else
if (!ZYAN_SUCCESS(ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LONG_COMPAT_32, ZYDIS_ADDRESS_WIDTH_32)))
if (!ZYAN_SUCCESS(ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LONG_COMPAT_32, ZYDIS_STACK_WIDTH_32)))
#endif
return STATUS_DRIVER_INTERNAL_ERROR;
@ -159,12 +159,14 @@ DriverEntry(
SIZE_T readOffset = 0;
ZydisDecodedInstruction instruction;
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT];
ZyanStatus status;
CHAR printBuffer[128];
// Start the decode loop
while ((status = ZydisDecoderDecodeBuffer(&decoder, (PVOID)(imageBase + entryPointRva + readOffset),
length - readOffset, &instruction)) != ZYDIS_STATUS_NO_MORE_DATA)
while ((status = ZydisDecoderDecodeFull(&decoder,
(PVOID)(imageBase + entryPointRva + readOffset), length - readOffset, &instruction,
operands)) != ZYDIS_STATUS_NO_MORE_DATA)
{
NT_ASSERT(ZYAN_SUCCESS(status));
if (!ZYAN_SUCCESS(status))
@ -176,7 +178,8 @@ DriverEntry(
// Format and print the instruction
const ZyanU64 instrAddress = (ZyanU64)(imageBase + entryPointRva + readOffset);
ZydisFormatterFormatInstruction(
&formatter, &instruction, printBuffer, sizeof(printBuffer), instrAddress);
&formatter, &instruction, operands, instruction.operand_count_visible, printBuffer,
sizeof(printBuffer), instrAddress, NULL);
Print("+%-4X 0x%-16llX\t\t%hs\n", (ULONG)readOffset, instrAddress, printBuffer);
readOffset += instruction.length;