Homebrew Channel Freezes w/o Internet December 06, 2011 10:33PM | Registered: 12 years ago Posts: 15 |
Re: Homebrew Channel Freezes w/o Internet December 06, 2011 10:49PM | Moderator Registered: 15 years ago Posts: 5,075 |
#define HAVE_AHBPROT ((*(vu32*)0xcd800064 == 0xFFFFFFFF) ? 1 : 0) #define MEM_REG_BASE 0xd8b4000 #define MEM_PROT (MEM_REG_BASE + 0x20a) static void disable_memory_protection() { write32(MEM_PROT, read32(MEM_PROT) & 0x0000FFFF); } static u32 apply_patch(char *name, const u8 *pattern, u32 pattern_size, const u8 *patch, u32 patch_size, u32 patch_offset) { u8 *ptr_start = (u8*)*((u32*)0x80003134), *ptr_end = (u8*)0x94000000; u32 found = 0; u8 *location = NULL; while (ptr_start < (ptr_end - patch_size)) { if (!memcmp(ptr_start, pattern, pattern_size)) { found++; location = ptr_start + patch_offset; u8 *start = location; u32 i; for (i = 0; i < patch_size; i++) { *location++ = patch; } DCFlushRange((u8 *)(((u32)start) >> 5 << 5), (patch_size >> 5 << 5) + 64); ICInvalidateRange((u8 *)(((u32)start) >> 5 << 5), (patch_size >> 5 << 5) + 64); } ptr_start++; } return found; } const u8 es_set_ahbprot_pattern[] = { 0x68, 0x5B, 0x22, 0xEC, 0x00, 0x52, 0x18, 0x9B, 0x68, 0x1B, 0x46, 0x98, 0x07, 0xDB }; const u8 es_set_ahbprot_patch[] = { 0x01 }; u32 IOSPATCH_AHBPROT() { if (HAVE_AHBPROT) { disable_memory_protection(); return apply_patch("es_set_ahbprot", es_set_ahbprot_pattern, sizeof(es_set_ahbprot_pattern), es_set_ahbprot_patch, sizeof(es_set_ahbprot_patch), 25); } return 0; } int main(int argc, char* argv[]) { int ret; /* Enable AHBPROT on title launch */ ret = IOSPATCH_AHBPROT(); if (ret) { /* Reload current IOS, typically IOS58 */ IOS_ReloadIOS(IOS_GetVersion()); } else { /* * Fatal error!!! * Unable to patch the running IOS. * The application has been likely launched without AHBPROT access rights. */ } /* * Put your code here */ }
Re: Homebrew Channel Freezes w/o Internet December 06, 2011 11:45PM | Registered: 15 years ago Posts: 276 |
Re: Homebrew Channel Freezes w/o Internet December 06, 2011 11:56PM | Moderator Registered: 15 years ago Posts: 5,075 |
Re: Homebrew Channel Freezes w/o Internet December 07, 2011 12:20AM | Registered: 15 years ago Posts: 276 |
Re: Homebrew Channel Freezes w/o Internet December 08, 2011 12:02AM | Registered: 15 years ago Posts: 686 |
Re: Homebrew Channel Freezes w/o Internet December 08, 2011 01:23AM | Registered: 12 years ago Posts: 15 |
Re: Homebrew Channel Freezes w/o Internet December 08, 2011 05:51PM | Moderator Registered: 15 years ago Posts: 5,075 |
Re: Homebrew Channel Freezes w/o Internet December 08, 2011 09:20PM | Registered: 15 years ago Posts: 276 |
Re: Homebrew Channel Freezes w/o Internet December 08, 2011 09:44PM | Registered: 15 years ago Posts: 686 |
It's the end of the IOS heap area. IOS sets that value when it is loaded and since it hasn't been reloaded before the app starts, there's no way of knowing if it has been modified. It would be safer (or at the very least, more consistent) to hardcode it like the end value.Quote
ekeeke
@tuedj: start address is nowhere near MEM1, it is actually the address of IOS area start, which is stored at $80000134 according to wiibrew.
Nope, libogc doesn't have a handler for alignment exceptions. Some PowerPC CPUs do support unaligned integer loads/stores without raising an exception by breaking the data into smaller chunks, obviously this should be avoided because it's slower and in this case it's especially dumb because the register we want to change is only 16 bits (hence the masking).Quote
As for read32/write32, i think libogc actually "realigns" things properly so no exceptions.
Re: Homebrew Channel Freezes w/o Internet December 08, 2011 10:32PM | Registered: 15 years ago Posts: 276 |
Re: Homebrew Channel Freezes w/o Internet December 08, 2011 10:50PM | Registered: 12 years ago Posts: 15 |
Awesome. Thanks. Thank you, too, SifJar. When SifJar said it would lose some functionality, I didn't know it would only be DVD support and I didn't want to screw things up for my friend. We can do without the DVD support for now, though, so thank you guys again.Quote
ekeeke
@Qufa: the easiest temporary solution is as said earlier to remove the no_ios_reload in meta xml files. You lose ability to load games from a DVD but it's no big loss if you don't use that feature.
Re: Homebrew Channel Freezes w/o Internet December 08, 2011 11:54PM | Moderator Registered: 15 years ago Posts: 5,075 |
Re: Homebrew Channel Freezes w/o Internet December 09, 2011 01:46AM | Registered: 12 years ago Posts: 15 |
It's all good, man. I appreciate that you only said what you know instead of pretending to know things that you're not sure about.Quote
SifJar
I wasn't sure if there was anything else that the emulators used HW_AHBPROT for or not, or I would have specified. Apologies for making you think you'd lose more than you actually would.