-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.c
66 lines (49 loc) · 1.63 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
#include <vitasdk.h>
#include <taihen.h>
#include <libk/stdio.h>
#include <libk/string.h>
#define DEBUG_FILE "MLCL00001"
static char titleid[10];
int launchAppByTitleid(const char *titleid) {
char uri[32];
sprintf(uri, "psgm:play?titleid=%s", titleid);
while (sceAppMgrLaunchAppByUri(0xFFFFF, uri) != 0)
sceKernelDelayThread(100000);
return 0;
}
int autoboot_thread(SceSize args, void *argp) {
// NPXS10079 is launched alongside livearea so we can check for it for autobooting any app
SceInt32 appId = 0;
char appName[10];
SceUID pid = 0;
do {
sceAppMgrGetRunningAppIdListForShell(&appId, 1);
if (appId != 0) {
pid = sceAppMgrGetProcessIdByAppIdForShell(appId);
if(pid > 0) {
sceAppMgrGetNameById(pid, appName);
if (strcmp(appName, "NPXS10079") == 0)
break;
}
}
sceKernelDelayThread(100000);
} while(1);
SceUID fd = sceIoOpen("ux0:/data/AutoBoot/boot.cfg", SCE_O_RDONLY, 0777);
if (fd >= 0) {
sceIoRead(fd, titleid, 9);
sceIoClose(fd);
titleid[9] = 0;
launchAppByTitleid(titleid);
}
return 0;
}
void _start() __attribute__ ((weak, alias ("module_start")));
int module_start(SceSize argc, const void *args) {
// Starting secondary thread to delay boot until enso is setup
SceUID thid = sceKernelCreateThread("autoboot_thread", autoboot_thread, 0x40, 0x100000, 0, 0, NULL);
if (thid >= 0) sceKernelStartThread(thid, 0, NULL);
return SCE_KERNEL_START_SUCCESS;
}
int module_stop(SceSize argc, const void *args) {
return SCE_KERNEL_STOP_SUCCESS;
}