-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<10.4 FIRMs can't insert loader sysmodule (it grew by 0x200 bytes) #5
Comments
I'd suggest waiting on the patches for now; I'm working on a decidedly less crap assembler for them. Current ones are still useful to understand the bytecode format, but the syntax will likely change. Patches pre-assemble are located in (expectedly) the If you want any help with the patches, feel free to PM or mail me. |
This is odd, both dumping and loading worked perfectly for me. |
Hm. Actually, @Wolfvak is correct, it doesn't trigger here now that I actually copy the commit and test it. What version of devkitPro are you using? More specifically, the following:
|
ctrulib version (latest commit as of 2016-06-09):
|
I have absolutely no clue, since your output matches mine. The only thing I can think of is that your version of GCC is miscompiling code for some unknown reason. Can you upload the arm9loaderhax.bin somewhere? I'm going to compare the output of your compiler. EDIT: Also, the entire build directory would be helpful, as well. It should only fail once it grows past 12800 - right now, we're the same size as nintendo's loader, and the CXI still has about 101 bytes of padding at the end. (f0 0f f0 0f ...) |
I guess I figured something out: I am still running 10.7 on my N3DS (don't ask me why). I dumped the loader.ncch from the decrypted firmware (10.2 NATIVE_FIRM that is, I believe). Then I used
Well, do the same thing for the custom
Now, I downloaded the 11.0 firmware, let corbenik decrypt it and extracted the loader:
See a pattern? The 11.0 loader is one unit larger than on 10.7 (10.2) NATIVE_FIRM. Nintendo actually provided us with 0x200b more to work with when they shipped 11.0. TIL. So a possible solution would be for me to finally upgrade and for you to state that with <11.0, the custom loader won't work. PS: I really should've been doing homework instead of fiddling with bytes. Back to Algebra. |
Well, he does recommend using FIRM 0x52/0x21, and that's what I've been testing with. There's currently no reason not to use it (except NTR maybe) So, moving the loader NCCH around the FIRM section 0 might be the solution. |
I'll leave it open and change the title. I need to fix the expansion anyways, so until then I'll leave it open. It'll also work well as a notice to anyone running into this. |
Do you perhaps have any ressources where one can find out about how things should be loaded into memory? If I know what makes expansion more difficult than contraction I might be able to come up with fix for it. |
It's not all that hard to fix, IMO, but because we do things cakes style we need to do it in-place. It isn't something I had run into yet, so I just didn't bother. Every offset/every size after the sysmodule section has to be changed to account for the number of mediaunits it was grown, and also adjust headers, etc. This also involves memmove to actually make space to inject. We need to keep the firmware contiguous in memory, unlike Luma (it reloads and repatches on reboot, we do not.) As an aside, once this is fixed, it should probably also be submitted to Cakes in source/patch.c, since that's where the sysmodule injection code originates from. |
Assigning myself, since I'm fixing this now. Better to just get it done. |
It looks like older NATIVE_FIRM has been removed from the CDN, by the way. |
Interestingly, when I tried to download 0000001F a minute ago, it failed. I must have typo'd. Anyways, I have a few things to squash first (master definitely doesn't work right at this moment.) |
It looks like the size of loader was actually updated in 10.4, so I'm changing the title. 1F is fine. It's actually anything older. |
I've pushed a test (which works during regular boot) but I have no clue whether it remains valid during a firmlaunch. Native firmlaunch should only happen on o3ds, anyways, so care to test this @Wolfvak ? You'll want to use 10.2 FIRM. ctrtool finds the cache firmware (cache/p_native) valid, so I assume all is well, but it needs testing. |
I've tested using the cache firmware as native (with patches off) and it seems to work, so for now I'll be closing this issue unless anyone finds anything severely wrong with the expansion code. |
I compiled corbenik from source an noticed that everytime I enabled the custom loader, the CFW would get stuck in a loop warning me that the
loader.cxi
is to big (L41 here) and that it would need to grow 1 unit.It probably hangs because the following
continue;
just jumps back to thewhile
-condition, which hasn't changed, and thus executes the same code again ad infinitum. I don't know if that's intended this way.Too find out why it complained that it'd need to grow, I did a
git bisect
. Starting with 19cc0eb the issue appeared for me the first time and also did the size ofloader.cxi
change from previously 12288 bytes to 12800 bytes after.I understand that the 'shift all the modules'-code is not implemented right now, but can you confirm that the custom loader indeed exceeds the size of the original?
Anyway, cool project! If I could get any ressources on how develop patches/what patches are needed, I'd be on board writing some!
The text was updated successfully, but these errors were encountered: