/
main.c
68 lines (66 loc) · 2.27 KB
/
main.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
#include "ps4.h"
#include "patch.h"
#include "ApplicationCache.h"
void writeCacheDB()
{
size_t len;
unsigned char* fbuf = base64_decode(ApcStr, sizeof(ApcStr), &len);
int fid = open("/user/system/webkit/webbrowser/appcache/ApplicationCache.db", O_WRONLY | O_CREAT | O_TRUNC, 0777);
write(fid, fbuf, len);
close(fid);
}
int _main(struct thread *td) {
initKernel();
initLibc();
syscall(11,patcher,td);
initSysUtil();
if (!dir_exists("/user/system/webkit/webbrowser/appcache"))
{
mkdir ("/user/system/webkit/webbrowser/appcache", 0777);
}
int usbdir = open("/mnt/usb0/.dirtest", O_WRONLY | O_CREAT | O_TRUNC, 0777);
if (usbdir == -1)
{
usbdir = open("/mnt/usb1/.dirtest", O_WRONLY | O_CREAT | O_TRUNC, 0777);
if (usbdir == -1)
{
systemMessage("No usb found\nUsing Internal Cache");
writeCacheDB();
systemMessage("Cache install Complete.\n\nBookmark:\nhttp://cache/index.html");
return 0;
}
else
{
close(usbdir);
if (file_exists("/mnt/usb1/ApplicationCache.db"))
{
systemMessage("Cache file found on USB1");
copy_File("/mnt/usb1/ApplicationCache.db","/user/system/webkit/webbrowser/appcache/ApplicationCache.db");
systemMessage("Cache restore Complete.");
}
else
{
systemMessage("No cache file found on USB1\nUsing Internal Cache");
writeCacheDB();
systemMessage("Cache install Complete.\n\nBookmark:\nhttp://cache/index.html");
}
}
}
else
{
close(usbdir);
if (file_exists("/mnt/usb0/ApplicationCache.db"))
{
systemMessage("Cache file found on USB0");
copy_File("/mnt/usb0/ApplicationCache.db","/user/system/webkit/webbrowser/appcache/ApplicationCache.db");
systemMessage("Cache restore Complete.");
}
else
{
systemMessage("No cache file found on USB0\nUsing Internal Cache");
writeCacheDB();
systemMessage("Cache install Complete.\n\nBookmark:\nhttp://cache/index.html");
}
}
return 0;
}