[Question] Modifying Exefs

Discussion in '3DS - ROM Hacking, Translations and Utilities' started by thane98, Aug 15, 2016.

  1. thane98
    OP

    thane98 GBAtemp Advanced Fan

    Member
    564
    267
    Apr 23, 2016
    United States
    I'm aware of the processes for creating and running modifications to a game's romfs, but I haven't done anything with the exefs. I haven't been able to find answers to some questions I have about modifying it, so I thought that I'd go ahead and ask here.

    Is is possible to run exefs modifications through an NTR plugin? I know that HANS offers a method for running code.bin changes, but I'd like to avoid dealing with HANS if possible. If nothing can be done using NTR, is there an alternative for running exefs (or at the least, code.bin) changes?

    I also have some questions about the file structure of the code.bin in exefs if anyone has experience working with that kind of file. Obviously, code will vary greatly from game to game, but I'm wondering if there's any sort of defined structure to the compiled code. Knowing about that before trying to make changes could save a lot of headaches. Also, if I wanted to add bytes to the file, what steps would I need to take in order to have the code still load correctly? Do I need to make changes elsewhere if I expand the file size?

    Apologies for all of the questions. Any information on making edits to an exefs would be very helpful.
     
  2. Ningyoplug

    Ningyoplug GBAtemp Regular

    Member
    201
    53
    Mar 10, 2016
    Italy
    Gayland
    Seconding all your questions. I'd like to know more (especially about the code.bin structure) as well, but no one ever seems to talk about it...
    It would be nice if someone could shed some light on the exefs.

    PS: I'd like to add one more question: does anyone know where the info on S supports being locked to 1 person only is situated in the code.bin? It would help me greatly.
     
  3. shinyquagsire23

    shinyquagsire23 SALT/Sm4sh Leak Guy

    Member
    1,964
    3,238
    Nov 18, 2012
    United States
    Las Vegas
    SaltySD just uses Luma3DS's code override. Just modify the code.bin and stick it at /luma/code_sections/<TID>.bin. I usually end up testing by shipping all my patches as a bunch of w32s over RPC anyhow though.
     
    thane98 likes this.
  4. thane98
    OP

    thane98 GBAtemp Advanced Fan

    Member
    564
    267
    Apr 23, 2016
    United States
    Thank you, that sounds like exactly what I was looking for. I didn't know that Luma offered that sort of functionality. Do you know if that method allows for expanded code.bin files? That'd be my only other concern.
     
  5. shinyquagsire23

    shinyquagsire23 SALT/Sm4sh Leak Guy

    Member
    1,964
    3,238
    Nov 18, 2012
    United States
    Las Vegas
    Don't think so, but I also don't think that would work anyhow since code.bin is the .text, .rodata and .data lumped into one blob, and that's how they are in memory. Best bet is finding unused code tbh. Sm4sh has an entire libpng library imported which is never used.
     
  6. thane98
    OP

    thane98 GBAtemp Advanced Fan

    Member
    564
    267
    Apr 23, 2016
    United States
    Yeah, that might be a better option - I guess that I might as well jump in and see what can be done. Thank you for your help!
     
  7. thane98
    OP

    thane98 GBAtemp Advanced Fan

    Member
    564
    267
    Apr 23, 2016
    United States
    Sorry to bug you again - I'm having some trouble getting my modified code.bin to load. I took a decompressed code.bin, modified it, renamed it to use the Fates Special Edition TID (0004000000179800), and left it on my SD card using the path sd:/luma/code_sections/0004000000179800.bin. However, I'm noticing no changes in game - it looks like Luma's not loading the modified code at all. I went ahead and updated luma to the latest hourly build to make sure that wasn't the issue, though that didn't fix things. Is there some step that I'm missing here?
     
  8. shinyquagsire23

    shinyquagsire23 SALT/Sm4sh Leak Guy

    Member
    1,964
    3,238
    Nov 18, 2012
    United States
    Las Vegas
    It could possibly be using the update TID, if there's a game update installed.

    EDIT: Actually it doesn't seem that's the case, not sure what it could be then.
     
    Last edited by shinyquagsire23, Aug 15, 2016
  9. thane98
    OP

    thane98 GBAtemp Advanced Fan

    Member
    564
    267
    Apr 23, 2016
    United States
    Turns out I'm an idiot - I forgot to turn on external .code usage in Luma's settings.