diff options
Diffstat (limited to 'src/tools')
| -rwxr-xr-x | src/tools/fileutils.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tools/fileutils.c b/src/tools/fileutils.c index 18b8dc4d..fa57cd69 100755 --- a/src/tools/fileutils.c +++ b/src/tools/fileutils.c @@ -15,6 +15,7 @@ #include "debug.h" #include "fileutils.h" +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"; int FileExist(const char* filename, int flags) @@ -77,6 +78,23 @@ int FileIsX64ELF(const char* filename) return 0; } +int FileIsX86ELF(const char* filename) +{ + FILE *f = fopen(filename, "rb"); + if(!f) + return 0; + char head[sizeof(*x86sign)] = {0}; + int sz = fread(head, sizeof(*x86sign), 1, f); + if(sz!=1) { + fclose(f); + return 0; + } + fclose(f); + if(memcmp(head, x86sign, sizeof(*x86sign))==0) + return 1; + return 0; +} + #if defined(RPI) || defined(RK3399) || defined(RK3326) void sanitize_mojosetup_gtk_background() { |