Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Static copy approach. Copies to a statically allocated region of memory which should certainly be permissible.
- Assumes a size of 1 << 12, but can be modified to be larger as necessary. Fail in the event that size is not correct.
- This may actually be considerably better to do in general, but the lack of runtime size corrections may be a bit dissuading.
- Not to mention that the copying could be optimized a bit too :)
- */
- #define SIZE (1 << 12)
- uint32_t func[SIZE];
- MAKE_HOOK_OFFSETLESS(LateUpdate, void, void *self) {
- reinterpret_cast<void (*)(void*)>(func)(self);
- }
- extern "C" void load() {
- auto lateUpdateInfo = il2cpp_utils::FindMethodUnsafe("", "BeatmapObjectCallbackController", "LateUpdate", 0);
- auto nextMethodInfo = il2cpp_utils::FindMethodUnsafe("", "BeatmapObjectCallbackController", "AddBeatmapObjectCallback", 2);
- uint32_t *startAddr = (uint32_t *) lateUpdateInfo->methodPointer;
- uint32_t *endAddr = (uint32_t *) nextMethodInfo->methodPointer;
- std::vector<uint32_t> instructions(startAddr, endAddr);
- if (endAddr - startAddr > SIZE) {
- // Fail
- }
- int dstIdx = 0;
- for (int i = 0; i < instructions.size(); i++) {
- uint32_t ins = instructions[i];
- func[dstIdx] = ins;
- ++dstIdx;
- if (ins == 0x1e293901) { // 0x0139291e fsub s1,s8,s9
- // Append instructions here, increase dstIdx
- // This assumes you want to KEEP the fsub instruction (you can ofc move that stuff below)
- func[dstIdx] = 0x0;
- ++dstIdx;
- }
- }
- if (mprotect(reinterpret_cast<void*>(func), SIZE, PROT_EXEC) == 0) {
- // Success
- }
- INSTALL_HOOK_OFFSETLESS(LateUpdate, il2cpp_utils::FindMethodUnsafe("", "BeatmapObjectCallbackController", "LateUpdate", 0));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement