[Project] Injecting any app into Health and Safety?

Discussion in '3DS - Homebrew Development and Emulators' started by d0k3, Nov 1, 2015.

  1. d0k3
    OP

    d0k3 3DS Homebrew Legend

    Member
    2,668
    2,675
    Dec 3, 2004
    Gambia, The
    NEWS: If you want to try this now, check out this post! Keep in mind that you have to compile my Decrypt9 version yourselves to try it. We're still working on streamlining this, and there might even be a GUI later on.

    ----------------------------------------------------------------------------------------------------

    Well, a lot of people know that problem - you just setup a brand new EmuNAND, just to notice, moments later, that you forgot about installing a CIA manager. Now you're out of luck, and the only choice you've got left is setting up your SysNAND (via PastaCFW / ReiNAND Sys / rxTools dev) with a CIA manager and formatting your EmuNAND anew.

    One solution for that problem is injecting FBI into the H&S app. There's the FBI inject generator by Riku, and rxTools FBI injector uses the exact same files generated by that. Riku's tool uses the TMD to identify the H&S version and selects from a range of "precompiled" FBI inject files. Two problems with that: [1] you can't inject a recent version of FBI and [2] this is not available for N3DS. Add to that [3], it might make sense to inject apps other than FBI over H&S now or in the future.

    So, what if we could create valid inject files for any app?

    I started this over at 4DSdev.org, and, basically, with a lot of help from @Syphurith, we have already figured out what to do. Check out my post here. The thread is pretty short, so you can also read it completely.

    Now, the problem left is - how to streamline the process? Asking GBAtemp members here. it is not simple to do, and the known tools (Makerom/CTRtool/3DStool) won't do the trick - at least not on their own. Any help is appreciated! If you don't know how to do all that stuff, even if you know how to streamline it in part will help.
     
    Last edited by d0k3, Nov 4, 2015
    chronoss, The9thBit, MelonGx and 3 others like this.
  2. d0k3
    OP

    d0k3 3DS Homebrew Legend

    Member
    2,668
    2,675
    Dec 3, 2004
    Gambia, The
    I might add to that, what I see as the main sources of trouble right now, is creating the new ExeFS / RomFS, and making sure all those hashes are correct while still modifying the original H&S NCCH header and TMD as little as possible. Just building a new app with Makerom won't do the trick. Best way would be to just inject the new ExeFS and new RomFS (the tool doing this would have to take care of the hashes/sizes/offsets in the NCCH header as well), the remaing adaptions are pretty easy. We also need to make sure that the resulting .CXI has the same size as the original H&S app.

    Plus, it would be best if we could find a way to streamline the process so that a single .BAT file could manage all of it.
     
    Last edited by d0k3, Nov 1, 2015
  3. MsMidnight

    MsMidnight part time fe modder

    Member
    1,753
    1,308
    Oct 12, 2015
    kys
    Will this be 9.2 and below ?
     
  4. d0k3
    OP

    d0k3 3DS Homebrew Legend

    Member
    2,668
    2,675
    Dec 3, 2004
    Gambia, The
    You need a CFW to run unsigned code, so yup, you're out of luck above 9.2.
     
    Subtle Demise likes this.
  5. Shadowtrance

    Shadowtrance GBAtemp Addict

    Member
    2,488
    1,517
    May 9, 2014
    Hervey Bay, Queensland
    Should be interesting if this actually happens. :)
    Not that i can be of much help haha I can probably eliminate the need for a batch file though and replace it with a nice GUI in C# (winforms). I'm getting pretty good at that. :)

    Pity riku seems totally against sharing source for ANYTHING he creates/shares though :(

    @d0k3 don't know if you're still having issues getting the tmdfixer to compile or not but i fixed it by creating a folder called build in the same folder and it worked. :)
    After that it doesn't complain about any files for me (originally complained about msys-20.dll).
     
    Last edited by Shadowtrance, Nov 1, 2015
    Syphurith likes this.
  6. 101239

    101239 GBATemp Irregular

    Banned
    312
    158
    Oct 25, 2015
    United States
    Maybe Somewhere near you? ( ͡° ͜ʖ ͡°)
    E
    X
    c
    I
    T
    E
    M
    E
    N
    Expectations---_-__---__- T --_--__---___--
    !
     
  7. d0k3
    OP

    d0k3 3DS Homebrew Legend

    Member
    2,668
    2,675
    Dec 3, 2004
    Gambia, The
    Thanks a ton! You wouldn't believe, but I was just about to ask you exactly this :D. Anyways, I'm already pretty far. I think by tomorrow we'll have something that hopefully works and is ready to test.
     
    Last edited by d0k3, Nov 1, 2015
  8. Syphurith

    Syphurith Beginner

    Member
    641
    222
    Mar 8, 2013
    Switzerland
    Xi'an, Shaanxi Province
    Sorry for an incomplete build script. Now I've uploaded a new version including source there, it accepts arguments, so you don't need to always use fbi_inject.* as the name.
    Eh.. about the exheader, have you already made any tool for it? If so at least you can have a batch/shell script version to try first.
     
    Last edited by Syphurith, Nov 2, 2015
    d0k3 likes this.
  9. Syphurith

    Syphurith Beginner

    Member
    641
    222
    Mar 8, 2013
    Switzerland
    Xi'an, Shaanxi Province
    @d0k3 Now, as I've made the exheader merge tool, you can get it there.
    http://4dsdev.org/thread.php?pid=648#648 Source code and usage explanation included.
    I've tested with the 1.3.8 fbi exheader, and old h&s one, version 2050. Merged result as expected.
    Now i would like to check the ver.1024. Hope you can take usage of this.
     
    d0k3 likes this.
  10. d0k3
    OP

    d0k3 3DS Homebrew Legend

    Member
    2,668
    2,675
    Dec 3, 2004
    Gambia, The
    Alright, big progress here, thanks to @Syphurith. I've put together a batch file to handle the full process, get it from here:
    http://wikisend.com/download/350650/UniversalInjectGen_v0.1.zip

    Howto:
    • Put H&S app & tmd into apptmd_hs/ folder (names do not matter) / H&S app needs to be decrypted
    • Put CIA of app to inject into cia_inject/ folder (name does not matter
    • Run go.bat
    The only thing missing from this is encryption, but I'm sure we can handle this. Not for noobs atm because of that specific reason, though. Also: experimental! So keep backups of your NAND and be sure to be safe.
     
    Last edited by d0k3, Nov 2, 2015
    Shadowtrance likes this.
  11. Shadowtrance

    Shadowtrance GBAtemp Addict

    Member
    2,488
    1,517
    May 9, 2014
    Hervey Bay, Queensland
    Eww bat file! :P haha
    I'll have to do something about that at some point, although it'll be windows only as i don't know how to make cross platform winforms. :(
     
  12. d0k3
    OP

    d0k3 3DS Homebrew Legend

    Member
    2,668
    2,675
    Dec 3, 2004
    Gambia, The
    A .BAT file is not cross plattform either :P.
     
  13. Shadowtrance

    Shadowtrance GBAtemp Addict

    Member
    2,488
    1,517
    May 9, 2014
    Hervey Bay, Queensland
    This is true. haha
    Is there even linux/mac versions of the programs needed anyway?
     
  14. The Real Jdbye

    The Real Jdbye Always Remember 30/07/08

    Member
    GBAtemp Patron
    The Real Jdbye is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    12,516
    5,474
    Mar 17, 2010
    Norway
    Alola
    Technically, C# is cross platform (with Mono) ;)
     
  15. Shadowtrance

    Shadowtrance GBAtemp Addict

    Member
    2,488
    1,517
    May 9, 2014
    Hervey Bay, Queensland
    True, but I've no idea how to make the gui's created with winforms work on other platforms. (i is still a noob with all this haha).
    Doesn't really help if there isn't non windows versions of the underlying programs though.
     
  16. The Real Jdbye

    The Real Jdbye Always Remember 30/07/08

    Member
    GBAtemp Patron
    The Real Jdbye is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    12,516
    5,474
    Mar 17, 2010
    Norway
    Alola
    It should work out of the box: http://www.mono-project.com/docs/gui/winforms/
     
  17. d0k3
    OP

    d0k3 3DS Homebrew Legend

    Member
    2,668
    2,675
    Dec 3, 2004
    Gambia, The
    The tools used in this are Windows only, so just making a portable GUI wouldn't be enough.
    Well, ask the OS X / Linux users ;). While I understand them completely, I do not need OS X or Linux compatible versions.
     
  18. Shadowtrance

    Shadowtrance GBAtemp Addict

    Member
    2,488
    1,517
    May 9, 2014
    Hervey Bay, Queensland
    Yeah neither do i, was just thinking out aloud really. :)
     
  19. DiegitusXD

    DiegitusXD GBAtemp Fan

    Member
    405
    115
    May 6, 2015
    So this is for users below 9.2,no?
     
  20. d0k3
    OP

    d0k3 3DS Homebrew Legend

    Member
    2,668
    2,675
    Dec 3, 2004
    Gambia, The
    Well...
    if you're willing to test (asking the pros / people with hardmods here), here's a new version:
    http://wikisend.com/download/715352/UniversalInjectGen_v0.2.zip

    This should fix:
    * the wildcard issue for CTRtools
    * the size issue (output size should be correct now)
    * processing the logo.bin for .apps that have it

    From what I see this will generate an app identical to Riku's inject files, save for the RomFS. The difference in RomFS is only due to us using a different content for the dummy file, so no problem.

    Also, keep in mind that the resulting .app/.tmd is unencrypted. Might work, or it might not. I'm unsure atm. Encryption wouldn't be too difficult to add, though.