From b185afa29f8a6b8d368a161dea9de7186f3f314c Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Wed, 31 Aug 2022 08:48:54 +0200 Subject: Fixed x86/x86_64 binary detection (for #399) --- src/tools/fileutils.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tools/fileutils.c b/src/tools/fileutils.c index a4b046f2..80a0ec60 100755 --- a/src/tools/fileutils.c +++ b/src/tools/fileutils.c @@ -17,8 +17,8 @@ static const char* x86sign = "\x7f" "ELF" "\x01" "\x01" "\x01" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x02" "\x00" "\x03" "\x00"; static const char* x64sign = "\x7f" "ELF" "\x02" "\x01" "\x01" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x02" "\x00" "\x3e" "\x00"; -static const char* x86lib = "\x7f" "ELF" "\x01" "\x01" "\x01" "\x03" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x03" "\x00" "\x03" "\x00"; -static const char* x64lib = "\x7f" "ELF" "\x02" "\x01" "\x01" "\x03" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x03" "\x00" "\x3e" "\x00"; +static const char* x86lib = "\x7f" "ELF" "\x01" "\x01" "\x01" "\x03" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x02" "\x00" "\x03" "\x00"; +static const char* x64lib = "\x7f" "ELF" "\x02" "\x01" "\x01" "\x03" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x02" "\x00" "\x3e" "\x00"; int FileExist(const char* filename, int flags) { @@ -75,6 +75,7 @@ int FileIsX64ELF(const char* filename) return 0; } head[7] = x64lib[7]; // this one changes + head[16]&=0xfe; if(!memcmp(head, x64lib, 20)) return 1; return 0; @@ -92,6 +93,7 @@ int FileIsX86ELF(const char* filename) return 0; } head[7] = x64lib[7]; + head[16]&=0xfe; if(!memcmp(head, x86lib, 20)) return 1; return 0; -- cgit 1.4.1