Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- My 3 comments below explain the issue, particularly the last comment. How can we write to the protected segment on HEN? We can on DEX with the debug syscall.
- void PatchInJump(int Address, int Destination){
- int FuncBytes[4];
- Destination = *(int*)Destination;
- FuncBytes[0] = 0x3D600000 + ((Destination >> 16) & 0xFFFF);
- if(Destination & 0x8000) FuncBytes[0] += 1;
- FuncBytes[1] = 0x396B0000 + (Destination & 0xFFFF);
- FuncBytes[2] = 0x7D6903A6;
- FuncBytes[3] = 0x4E800420;
- Memcpy((void*)Address, FuncBytes, 4*4);//This will work, writing to an address within the eboot due to cobra enabling write on the code segment. Also syscall 8 write works.
- }
- void hookFunctionStart(int Address, int saveStub, int Destination){ //Works on every game
- saveStub = *(int*)saveStub;
- int BranchtoAddress = Address + (4*4);
- int StubData[8];
- StubData[0] = 0x3D600000 + ((BranchtoAddress >> 16) & 0xFFFF);
- if(BranchtoAddress & 0x8000) StubData[0] += 1;
- StubData[1] = 0x396B0000 + (BranchtoAddress & 0xFFFF);
- StubData[2] = 0x7D6903A6;
- Memcpy(&StubData[3], (void*)Address, 4*4);//This will work with normal write or syscall 8 because StubData is in a writeable segment of the sprx
- StubData[7] = 0x4E800420;
- Memcpy((void*)saveStub, StubData, 8*4);//This will fail. saveStub is in the code segment of the sprx, and cobra does not enable write on it. Syscall 8 will also not work. The only way to do this is with dex debug write. Is there any way to fix this to work on HEN/CEX?
- PatchInJump(Address, Destination);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement