Skip to content

Commit 0b97050

Browse files
committed
Add support for IAT hooking on ARM64
1 parent 1b703ae commit 0b97050

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Src/Lib/IatHookHelper.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,17 @@ IatHookData *SetIatHook( IMAGE_DOS_HEADER *dosHeader, DWORD iatOffset, DWORD int
7070
{
7171
IatHookData *hook=g_IatHooks+g_IatHookCount;
7272
g_IatHookCount++;
73+
#if defined(_M_AMD64) || defined(_M_IX86)
7374
hook->jump[0]=hook->jump[1]=0x90; // NOP
7475
hook->jump[2]=0xFF; hook->jump[3]=0x25; // JUMP
75-
#ifdef _WIN64
76+
#if defined(_M_AMD64)
7677
hook->jumpOffs=0;
7778
#else
7879
hook->jumpOffs=(DWORD)(hook)+8;
80+
#endif
81+
#elif defined(_M_ARM64)
82+
hook->jump[0]=0x48; hook->jump[1]=0x00; hook->jump[2]=0x00; hook->jump[3]=0x58; // LDR X8, newProc
83+
hook->jump[4]=0x00; hook->jump[5]=0x01; hook->jump[6]=0x1F; hook->jump[7]=0xD6; // BR X8
7984
#endif
8085
hook->newProc=newProc;
8186
hook->oldProc=(void*)thunk->u1.Function;

Src/Lib/IatHookHelper.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66

77
struct IatHookData
88
{
9+
#if defined(_M_AMD64) || defined(_M_IX86)
910
unsigned char jump[4]; // jump instruction 0x90, 0x90, 0xFF, 0x25
1011
DWORD jumpOffs; // jump instruction offset
12+
#elif defined(_M_ARM64)
13+
unsigned char jump[8]; // LDR <address>, BR
14+
#endif
1115
void *newProc; // the address of the new proc
1216
void *oldProc; // the address of the old proc
1317
IMAGE_THUNK_DATA *thunk; // the IAT thunk

0 commit comments

Comments
 (0)