Skip to content

Commit 79d0b9c

Browse files
committed
relax ntdll stub check
1 parent 57b7c77 commit 79d0b9c

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

auth.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3190,8 +3190,11 @@ static bool ntdll_syscall_stub_tampered(const char* name)
31903190

31913191
const uint8_t* p = reinterpret_cast<const uint8_t*>(fn);
31923192
#ifdef _WIN64
3193-
// Allow optional ENDBR64 and padding bytes to reduce false positives on CET/hotpatch builds.
3193+
// Reduce false positives: only flag obvious hooks/trampolines or missing syscall.
31943194
const uint8_t* q = p;
3195+
if (q[0] == 0xE9 || (q[0] == 0xFF && q[1] == 0x25)) {
3196+
return true; // direct jmp / jmp [rip+imm32]
3197+
}
31953198
// Skip ENDBR64 (f3 0f 1e fa)
31963199
if (q[0] == 0xF3 && q[1] == 0x0F && q[2] == 0x1E && q[3] == 0xFA) {
31973200
q += 4;
@@ -3200,10 +3203,17 @@ static bool ntdll_syscall_stub_tampered(const char* name)
32003203
for (int i = 0; i < 8 && (*q == 0xCC || *q == 0x90); ++i) {
32013204
q++;
32023205
}
3203-
if (!(q[0] == 0x4C && q[1] == 0x8B && q[2] == 0xD1)) return true; // mov r10, rcx
3204-
if (!(q[3] == 0xB8)) return true; // mov eax, imm32
3205-
if (!(q[8] == 0x0F && q[9] == 0x05)) return true; // syscall
3206-
if (!(q[10] == 0xC3)) return true; // ret
3206+
// Scan first 32 bytes for syscall; if absent, suspect hook.
3207+
bool has_syscall = false;
3208+
for (int i = 0; i < 32; ++i) {
3209+
if (q[i] == 0x0F && q[i + 1] == 0x05) {
3210+
has_syscall = true;
3211+
break;
3212+
}
3213+
}
3214+
if (!has_syscall) {
3215+
return true;
3216+
}
32073217
#endif
32083218
return false;
32093219
}

0 commit comments

Comments
 (0)