aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReiko Asakura2021-02-24 00:16:13 -0500
committerReiko Asakura2021-02-24 00:16:13 -0500
commit3c74277e4d175d4f846de077a95afe0a7cf8faf5 (patch)
tree8a034e2234288372f5d143b751d2e40df35eb299
parentWait for controller input only when using Enso (diff)
downloadtaihen-3c74277e4d175d4f846de077a95afe0a7cf8faf5.tar.gz
Fix USB mount failure when boot is delayedrelease/0.12.2
-rw-r--r--taihen.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/taihen.c b/taihen.c
index fa2df58..1e170b7 100644
--- a/taihen.c
+++ b/taihen.c
@@ -26,6 +26,23 @@
/** For ordering log entries */
unsigned char log_ctr = 0;
+/** Hook reference to `is_safe_mode` */
+static tai_hook_ref_t g_is_safe_mode_hook;
+
+/** References to the hooks */
+static SceUID g_hooks[1];
+
+/**
+ * @brief Patch to allow USB drive mounting when boot is delayed
+ * when waiting for controller input
+ *
+ * @return Always returns 1
+ */
+static int is_safe_mode_patched(void) {
+ TAI_NEXT(is_safe_mode_patched, g_is_safe_mode_hook);
+ return 1;
+}
+
/**
* @brief Add a hook given an absolute address
*
@@ -352,6 +369,7 @@ int module_start(SceSize argc, const void *args) {
if (sceSblAimgrIsGenuineDolce() && sceKernelSysrootGetShellPid() < 0) {
kbl_param = sceKernelGetSysrootBuffer();
if (*(uint32_t*)(kbl_param + 0xC4) == 0xFF1C && *(uint32_t*)(kbl_param + 0xD8) == 0x8) {
+ g_hooks[0] = taiHookFunctionImportForKernel(KERNEL_PID, &g_is_safe_mode_hook, "SceUsbServ", 0x2ED7F97A, 0x834439A7, is_safe_mode_patched);
sceSysconCtrlDolceLED(1);
for (int i = 0; i <= 10000000; i += 50000) {
memset(&ctrl, 0, sizeof(ctrl));
@@ -365,6 +383,9 @@ int module_start(SceSize argc, const void *args) {
sceKernelDelayThread(50000);
}
sceSysconCtrlDolceLED(0);
+ if (g_hooks[0] >= 0) {
+ taiHookReleaseForKernel(g_hooks[0], g_is_safe_mode_hook);
+ }
}
}
sceCtrlPeekBufferPositive(0, &ctrl, 1);