File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3190,10 +3190,20 @@ 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- if (!(p[0 ] == 0x4C && p[1 ] == 0x8B && p[2 ] == 0xD1 )) return true ;
3194- if (!(p[3 ] == 0xB8 )) return true ;
3195- if (!(p[8 ] == 0x0F && p[9 ] == 0x05 )) return true ;
3196- if (!(p[10 ] == 0xC3 )) return true ;
3193+ // Allow optional ENDBR64 and padding bytes to reduce false positives on CET/hotpatch builds.
3194+ const uint8_t * q = p;
3195+ // Skip ENDBR64 (f3 0f 1e fa)
3196+ if (q[0 ] == 0xF3 && q[1 ] == 0x0F && q[2 ] == 0x1E && q[3 ] == 0xFA ) {
3197+ q += 4 ;
3198+ }
3199+ // Skip common padding (int3/nop)
3200+ for (int i = 0 ; i < 8 && (*q == 0xCC || *q == 0x90 ); ++i) {
3201+ q++;
3202+ }
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
31973207#endif
31983208 return false ;
31993209}
You can’t perform that action at this time.
0 commit comments