diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-07-12 13:43:00 -0500 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-07-12 13:43:00 -0500 |
| commit | a66bb7453b335975ae0f55a96e3f9665139d8024 (patch) | |
| tree | 55d579ac559eb10542e20e514fc7660d461d8df6 /src/tools/fileutils.c | |
| parent | 5406a040fbf51bec372612a147aea1f80acf97be (diff) | |
| download | box64-a66bb7453b335975ae0f55a96e3f9665139d8024.tar.gz box64-a66bb7453b335975ae0f55a96e3f9665139d8024.zip | |
Use box86 to launch x86 binary (if box86 is present in same folder as box64)
Diffstat (limited to 'src/tools/fileutils.c')
| -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() { |