Created
October 21, 2015 08:09
-
-
Save hanjianwei/14e9a21c64fe286107d1 to your computer and use it in GitHub Desktop.
Check if a Windows exe built with Unity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int check_unity(const char *filename) | |
{ | |
FILE *f = fopen(filename, "rb"); | |
const char *s = "UnityPlayer"; | |
char buf[20]; | |
int len = strlen(s); | |
int is_unity = 0; | |
if (!f) | |
return 0; | |
fseek(f, 8545324, SEEK_SET); | |
fscanf(f, "%15s", buf); | |
if (strncmp(s, buf, len) == 0) | |
is_unity = 1; | |
fclose(f); | |
return is_unity; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
if (argc < 2) { | |
printf("Usage: %s <filename>\n", argv[0]); | |
return 1; | |
} | |
if (check_unity(argv[1])) | |
printf("Unity!\n"); | |
else | |
printf("Not Unity\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment