| 80 | send("[hook] hook scene condition -> 1101"); |
| 81 | miniappScenePtr.writeInt(1101); |
| 82 | |
| 83 | // TODO: customize debugging endpoint |
| 84 | // const websocketServerStringPtr = passArgs.add(8).readPointer().add(520); |
| 85 | // VERBOSE && console.log("[hook] hook websocket server, original: ", websocketServerStringPtr.readUtf8String()); |
| 86 | // websocketServerStringPtr.writeUtf8String("ws://127.0.0.1:8189/"); |
| 87 | }; |
| 88 | |
| 89 | const patchOnLoadStart = (base, config) => { |
| 90 | // xref: AppletIndexContainer::OnLoadStart |
| 91 | Interceptor.attach(base.add(config.LoadStartHookOffset), { |
| 92 | onEnter(args) { |
| 93 | send( |
| 94 | `[inteceptor] AppletIndexContainer::OnLoadStart onEnter, ` + |
| 95 | `indexContainer.this: ${args[0]}`, |
| 96 | ); |
| 97 | // write debug_flag to 0x1 |
| 98 | if (args[1].and(0xff).toInt32() !== 1) { |
| 99 | args[1] = args[1].and(ptr("0xffffffffffffff00")).or(1); |
| 100 | } |
| 101 | // handle onLoad scene |
| 102 | hookOnLoadScene(args[0], config.SceneOffsets); |
| 103 | }, |
| 104 | onLeave(retval) { |