diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2022-08-30 10:25:09 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2022-08-30 10:25:09 +0200 |
| commit | 742742fd486c1beb0d70aa734de4a0ecdbe9fca7 (patch) | |
| tree | b0af2ab135916a83496ccd3108b5a2ff2e049532 /src/tools/fileutils.c | |
| parent | 5f6104a9d30d3f295f7b05dee7d5aee89711f977 (diff) | |
| download | box64-742742fd486c1beb0d70aa734de4a0ecdbe9fca7.tar.gz box64-742742fd486c1beb0d70aa734de4a0ecdbe9fca7.zip | |
small improvment to x64/x86 signature detection
Diffstat (limited to 'src/tools/fileutils.c')
| -rwxr-xr-x | src/tools/fileutils.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/tools/fileutils.c b/src/tools/fileutils.c index 5631134b..a4b046f2 100755 --- a/src/tools/fileutils.c +++ b/src/tools/fileutils.c @@ -70,15 +70,12 @@ int FileIsX64ELF(const char* filename) return 0; char head[20] = {0}; int sz = fread(head, 20, 1, f); + fclose(f); if(sz!=1) { - fclose(f); return 0; } - fclose(f); - if(memcmp(head, x64sign, 20)==0) - return 1; head[7] = x64lib[7]; // this one changes - if(memcmp(head, x64lib, 20)==0) + if(!memcmp(head, x64lib, 20)) return 1; return 0; } @@ -90,15 +87,12 @@ int FileIsX86ELF(const char* filename) return 0; char head[20] = {0}; int sz = fread(head, 20, 1, f); + fclose(f); if(sz!=1) { - fclose(f); return 0; } - fclose(f); - if(memcmp(head, x86sign, 20)==0) - return 1; head[7] = x64lib[7]; - if(memcmp(head, x86lib, 20)==0) + if(!memcmp(head, x86lib, 20)) return 1; return 0; } |