Skip to content

Commit

Permalink
Bump Zydis to 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HoShiMin committed Feb 23, 2023
1 parent c0c80a1 commit e232c02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions HookLib/HookLib/HookLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@

#include <ntstatus.h>

#define ZYDIS_STATIC_DEFINE
#pragma warning(push)
#pragma warning(disable: 4201) // Anonymous unions
#define ZYDIS_STATIC_BUILD
#include <Zydis/Zydis.h>
#pragma warning(pop)

#if !defined offsetof
#define offsetof(s, m) ((size_t)&(((s*)0)->m))
Expand Down Expand Up @@ -1686,18 +1689,18 @@ static unsigned char relocateBeginning(Arch arch, const void* from, void* to, un
ZydisDecoder decoder;
if (arch == x64)
{
ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_ADDRESS_WIDTH_64);
ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_STACK_WIDTH_64);
}
else
{
ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LEGACY_32, ZYDIS_ADDRESS_WIDTH_32);
ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LEGACY_32, ZYDIS_STACK_WIDTH_32);
}

unsigned char relocatedBytes = 0;

const unsigned char* srcInstr = (const unsigned char*)from;
ZydisDecodedInstruction instr;
while (ZYAN_SUCCESS(ZydisDecoderDecodeBuffer(&decoder, srcInstr, 16, &instr)))
while (ZYAN_SUCCESS(ZydisDecoderDecodeInstruction(&decoder, ZYAN_NULL, srcInstr, 16, &instr)))
{
unsigned char* const destInstr = (unsigned char*)to + (srcInstr - (const unsigned char*)from);
memcpy(destInstr, srcInstr, instr.length);
Expand Down
2 changes: 1 addition & 1 deletion HookLib/Zydis
Submodule Zydis updated 362 files

0 comments on commit e232c02

Please sign in to comment.