Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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