From 7c24e9a9b02b04dcaf9507acb94091ea70a2c02d Mon Sep 17 00:00:00 2001 From: Xavi Del Campo Date: Fri, 31 Jan 2020 10:32:23 +0100 Subject: Imported pristine psxsdk-20190410 from official repo --- tools/lictool.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 tools/lictool.c (limited to 'tools/lictool.c') diff --git a/tools/lictool.c b/tools/lictool.c new file mode 100644 index 0000000..4fcf493 --- /dev/null +++ b/tools/lictool.c @@ -0,0 +1,100 @@ +/* + * lictool + * + * Tool for manipulating PS1 license files + */ + +#include +#include + +unsigned char lic_buffer[37632]; // 16 CD sectors.. + +//0x2E08 + +void display_usage(); + +void display_usage() +{ + printf("" + "lictool - PS1 license file manipulation tool\n" + "usage: lictool \n" + "\n" + "Options:\n" + " -tmd= TMD file for boot logo\n" + " -removelogo Remove logo from license file\n"); +} + +int main(int argc, char *argv[]) +{ + int x,y,z,sz; + FILE *f; + + if(argc < 3) + { + display_usage(); + return 0; + } + + f = fopen(argv[1], "rb"); + + if(f == NULL) + { + printf("Could not open input license file! Aborting.\n"); + return -1; + } + + fread(lic_buffer, sizeof(char), 37632, f); + fclose(f); + + for(x = 3; x < argc; x++) + { + if(strncmp(argv[x], "-tmd=", 5) == 0) + { + f = fopen(argv[x] + 5, "rb"); + + if(f == NULL) + printf("Could not open TMD file %s. Ignoring option.\n", argv[x] + 5); + else + { + fseek(f, 0, SEEK_END); + sz = ftell(f); + fseek(f, 0, SEEK_SET); + z = 0x2E08; + + for(y = 0; y < sz; y++) + { + if((z - ((z / 2352)*2352)) == 2072) + z+=304; + + fread(&lic_buffer[z], sizeof(char), 1, f); + + z++; + } + + fclose(f); + } + } + else if(strncmp(argv[x], "-removelogo", 11) == 0) + { + z = 0x2E08; + + for(y = 0; y < 12; y++) + lic_buffer[z+y] = 0; + + lic_buffer[z] = 0x41; + } + } + + f = fopen(argv[2], "wb"); + + if(f == NULL) + { + printf("Could not open output file path for writing! Aborting.\n"); + return -1; + } + + fwrite(lic_buffer, sizeof(char), 37632, f); + fclose(f); + + return 0; +} -- cgit v1.2.3