-
Notifications
You must be signed in to change notification settings - Fork 6
/
genidx.c
104 lines (90 loc) · 2.6 KB
/
genidx.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* CrazyVoid Generate PS4 IDX File
* - 07/24/2017
*/
#include <sys/types.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <zlib.h>
#include <dirent.h>
#include <assert.h>
#include <stdint.h>
#ifdef WIN32
#include "mingw_mmap.h"
#include <windows.h>
#else
#include <sys/mman.h>
#endif
#include "tools.h"
u8 magicPreset[0x9] = { 0x72, 0x69, 0x64, 0x78, 0x01, 0x00, 0x00, 0x00, 0x01 };
u8 padding1Preset[0x4] = { 0x00, 0x00, 0x00, 0x00 };
u8 unknownPreset[0x16] = { 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
u8 padding2Preset[0x16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
u8 outputFile[0x50];
int generateIDX(char *CONTENT_ID, char *ENTITLEMENT_LABEL)
{
int ret;
if(strlen(CONTENT_ID) == 19)
{
if(strlen(ENTITLEMENT_LABEL) == 16)
{
char outputFilename[30] = "fake";
strcat(outputFilename, CONTENT_ID);
strcat(outputFilename, ".idx");
printf("Output : %s\n\n", outputFilename);
memcpy(outputFile, magicPreset, 9);
memcpy(outputFile+9, CONTENT_ID, 19);
memcpy(outputFile+28, padding1Preset, 4);
memcpy(outputFile+32, ENTITLEMENT_LABEL, 16);
memcpy(outputFile+48, unknownPreset, 16);
memcpy(outputFile+64, padding2Preset, 16);
FILE *fp;
fp = fopen(outputFilename, "w+");
fwrite(outputFile, sizeof(outputFile), 1, fp);
fclose(fp);
ret = 0;
}
else
{
printf("[ERROR] Invalid length of ENTITLEMENT LABLE\nFailed to create IDX\n\n");
ret = 1;
}
}
else
{
printf("[ERROR] Invalid length of CONTENT ID\nFailed to create IDX\n\n");
ret = 2;
}
return ret;
}
void help_Output()
{
printf("====PS4 IDX Generator - CrazyVoid======\n");
#ifdef WIN32
printf("genidx.exe CONTENT_ID ENTITLEMENT_LABEL\n\n");
#else
printf("./genidx CONTENT_ID ENTITLEMENT_LABEL\n\n");
#endif
printf("[ERROR] INCORRECT AMOUNT OF ARGUMENTS\n\n");
}
int main(int argc, char *argv[])
{
int ret;
if (argc != 3)
{
help_Output();
ret = 3;
}
else
{
// Dont change this line, stealing others work is not nice :)
// If you add code, feel free to add your name.
printf("[CrazyVoid] IDX Generator v0.1\n");
ret = generateIDX(argv[1], argv[2]);
}
return ret;
}