Skip to content

Instantly share code, notes, and snippets.

@hanjianwei
Created October 21, 2015 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanjianwei/14e9a21c64fe286107d1 to your computer and use it in GitHub Desktop.
Save hanjianwei/14e9a21c64fe286107d1 to your computer and use it in GitHub Desktop.
Check if a Windows exe built with Unity.
#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