diff options
| author | Xavi Del Campo <xavi.dcr@tutanota.com> | 2020-01-31 10:32:23 +0100 |
|---|---|---|
| committer | Xavi Del Campo <xavi.dcr@tutanota.com> | 2020-01-31 10:32:23 +0100 |
| commit | 7c24e9a9b02b04dcaf9507acb94091ea70a2c02d (patch) | |
| tree | c28d0748652ad4b4222309e46e6cfc82c0906220 /tools/lictool.c | |
| parent | a2b7b6bb1cc2f4a3258b7b2dbc92399d151f864d (diff) | |
| download | psxsdk-7c24e9a9b02b04dcaf9507acb94091ea70a2c02d.tar.gz | |
Imported pristine psxsdk-20190410 from official repo
Diffstat (limited to 'tools/lictool.c')
| -rw-r--r-- | tools/lictool.c | 100 |
1 files changed, 100 insertions, 0 deletions
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 <stdio.h>
+#include <string.h>
+
+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 <input> <output> <options>\n"
+ "\n"
+ "Options:\n"
+ " -tmd=<file> 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;
+}
|
