Official libiosuhax - PPC IPC library for communication to /dev/iosuhax

Discussion in 'Wii U - Homebrew' started by dimok, Nov 17, 2016.

  1. dimok
    OP

    dimok GBAtemp Advanced Fan

    Member
    728
    2,174
    Jan 11, 2009
    United States

    PPC IPC Library

    If you are an end user just skip to next (FT2SD) section :P. Otherwise here is some explanation on what this is:

    I was working on something for developers on the PPC side to allow them easier interaction with iosuhax. I created a new /dev/iosuhax node which can be accessed from the PPC side and which can receive many different commands. It has at least the power of the wupclient.py but is quite a bit faster as it uses the native PPC <-> ARM interprocess communication queue of the system.

    Now I wrote up some IOCTL commands to allow easy FSA access and to allow SVC syscalls, memcpy in and out, IOS kernel read and other usefull stuff from the PPC side. This is still in development and can be extended with more usefull commands. You can see all the changes on my iosuhax fork here:
    https://github.com/dimok789/iosuhax

    You can build that fork for sysNAND or redNAND depending on what make target you use (either "make redNAND" or "make cfw").

    Furthermore I prepared a (hopefully) easy to use library for PPC developers to link against. I called it libiosuhax. You can find the library here:
    https://github.com/dimok789/libiosuhax

    The library includes the necessary IOS_Ioctl wrappers to do the work for several functions and a quite usefull multi-functional devoptab which can be used to map different path within IOSU FS to a path accessible from the PPC. The devoptab lib can also mount different devices to a virtual path and map those for the PPC to access.

    A little insight on a possible usage.
    Code:
      // initialize IOSUHAX
      int res = IOSUHAX_Open();
      if(res < 0)
      {
      // handle error
      }
      // initialize FSA fd
      int fsaFd = IOSUHAX_FSA_Open();
      if(fsaFd < 0)
      {
      // handle error
      }
      // mount "/dev/odd03" to "/vol/storage_virt_odd" and bind it to our virt PPC path "odd:/"
      // if 3rd parameter is NULL it only binds the /vol path (e.g. /vol/system)  to our virt PPC path
      res = mount_fs("odd", fsaFd, "/dev/odd03", "/vol/storage_virt_odd");
      if(res < 0)
      {
      // handle error
      }
    
      FILE *pFile = fopen("odd:/code/some.rpx", "rb");
      // do some read/write I/O
      ...
    
    This all shall help make user friendly IOSU applications on the PPC side. With this developers could actually access the IOSUHAX and do all kind of stuff in there directly from a (in best case) good looking GX2 PPC application.

    FT2SD

    So this above was all only usefull to developers. Now let's get to the part that is interessting for end users. I prepared something for you guys to play with. A tool which utilizes the new library and shows it in action and how to use it.

    I created a new application called FT2SD (File Tree 2 SD). This application is a file tree dumper to SD. It can dump several (currently) predefined paths directly to your SD card, like for example game disc content, updates, tickets, slc content, vWii content, mlc...Think of this tool as a very pimped ddd alternative. It might even miss some interessting paths but those can be added quite easy.
    The application is currently only a console application but I think i will improve it later with a GX2 GUI and make a nice explorer tool out of it where the user can change paths and copy stuff back and forth.

    This is how it looks in action:
    [​IMG][​IMG]

    Here is a HBL ELF for that application which you have to run once you have a /dev/iosuhax node (a.k.a. run the custom fw.img). You can use it on both sysNAND or redNAND. It doesn't matter as long as you have the /dev/iosuhax node in your fw.img or some other launch method.

    http://www2.zippyshare.com/v/VR6842HO/file.html

    Have fun dumping stuff.

    FTPiiu everywhere

    Now this tool is only for advanced users ONLY. This is an extension to the existing ftpiiu tool. It mounts all the paths listed in the FT2SD tool and offers them on the FTP. This includes SLC and MLC! You can also add files or remove files on the FTP which makes it quite dangerous if you do this on sysNAND. So therefore here is a fair warning:

    DO NOT TOUCH THIS TOOL IF YOU DON'T KNOW WHAT YOU DO. IF YOU MODIFY FILES ON sysNAND YOU MIGHT BE SCREWED!!!

    If you brick your WiiU because you modified some files on sysNAND with this, then it is your own fault.

    If you are aware of the risk and want to only explore the files on your WiiU here is the application:

    http://www45.zippyshare.com/v/QHVbAby9/file.html

    [​IMG][​IMG]

    The same rules apply to this application as to the above

    Sources

    cfw redNAND and sysNAND fw.img:
    https://github.com/dimok789/iosuhax

    PPC IPC library for /dev/iosuhax:
    https://github.com/dimok789/libiosuhax

    FT2SD and FTPiiu everywhere:
    https://github.com/dimok789/ft2sd
    https://github.com/dimok789/ftpiiu/tree/ftpiiu_everywhere

    How to compile

    cfw redNAND and sysNAND fw.img:
    There is a nice thread somewhere around made by FIX94 that explains it.

    PPC IPC library for /dev/iosuhax:
    Just use "make" and "make install". Then link the library with -liosuhax in your makefile and use it. There is a already build library in the releases section.
     
    Last edited by dimok, Nov 18, 2016
  2. Afraidium

    Afraidium Advanced Member

    Newcomer
    50
    9
    Nov 8, 2016
    United States
    Beautiful post! Good things coming at a steady pace for the U!
     
  3. the_randomizer

    the_randomizer The Temp's official fox whisperer

    Member
    22,417
    10,761
    Apr 29, 2011
    United States
    Dr. Wahwee's castle
    Pretty cool stuff :D
     
  4. KiiWii

    KiiWii GBAtemp Psycho!

    Member
    3,876
    1,396
    Nov 17, 2008
    United Kingdom
    Wow, incredible! Thanks @dimok!

    Definitely looking forward to a GX2 version. Could this be built into loadiine or should it be kept separate?
     
    Last edited by KiiWii, Nov 17, 2016
  5. Maschell

    Maschell GBAtemp Advanced Fan

    Member
    912
    1,331
    Jun 14, 2008
    Gambia, The
    Amazing =)
     
  6. Cyan

    Cyan GBATemp's lurking knight

    Global Moderator
    18,572
    8,921
    Oct 27, 2002
    France
    Engine room, learning
    Thank you for all your work and making things always easier for everyone.
    I still haven't try any CFW, I might try it with ftpiiu_everywhere just by curiosity.
     
    NintendU_the_great likes this.
  7. DeslotlCL

    DeslotlCL GBAtemp's official dragon look-alike axolotl

    Member
    1,942
    2,143
    Oct 28, 2015
    Chile
    under your bed
    Question, what exactly should i do to dump one of my discs? Select the dump disc content odd03 or odd04? What will be the disc format output? Loadiine ready or an instalable wud?
     
  8. Conn0r

    Conn0r GBAtemp Fan

    Member
    327
    187
    Jan 10, 2016
    United States
    Is dumping with FT2SD just as slow as wupserver or is it fast and speedy?
     
  9. pwsincd

    pwsincd Garage Flower

    Member
    GBAtemp Patron
    pwsincd is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    3,367
    1,740
    Dec 4, 2011
    Manchester UK
  10. dimok
    OP

    dimok GBAtemp Advanced Fan

    Member
    728
    2,174
    Jan 11, 2009
    United States
    Usually odd03 has the content. Some games have content on odd04. The data you get from there is /code /content /meta, as required by loadiine. You dont get the wud image.

    As described above its a direct copy and therefore quite faster.
     
    KiiWii, Conn0r and DeslotlCL like this.
  11. DeslotlCL

    DeslotlCL GBAtemp's official dragon look-alike axolotl

    Member
    1,942
    2,143
    Oct 28, 2015
    Chile
    under your bed
    Ah I see, that's alright. Thanks :)
     
  12. Conn0r

    Conn0r GBAtemp Fan

    Member
    327
    187
    Jan 10, 2016
    United States
    Aren't we still trying to get these hooks on 3ds.
     
  13. smealum

    smealum growing up sucks.

    Member
    635
    2,030
    May 1, 2006
    United States
    SF
    neato burrito
     
  14. subcon959

    subcon959 teh retro

    Member
    810
    499
    Dec 24, 2008
    Trying to use ftpiiu everywhere but I keep getting a List Error. I can only seem to browse the SD, everything else gives that error. I'm using FlashFXP.
     
  15. Cyan

    Cyan GBATemp's lurking knight

    Global Moderator
    18,572
    8,921
    Oct 27, 2002
    France
    Engine room, learning
    I had issue with flashFXP in the past (broke my SD card inserted in Wii with ftpii, it couldn't be detected, even the HBC bubble never popped out when inserting/removing it. the card works on PSP and PC... not on wii), but it was an old version so maybe it's fixed now.
    I don't know if it was ftpii or flashfxp issue, but I'm now using filezilla instead.
     
  16. subcon959

    subcon959 teh retro

    Member
    810
    499
    Dec 24, 2008
    In case it was flashfxp, I just tried pasting the ftp address straight into explorer and same thing happened. I can browse SD fine, but anywhere else and it throws up an error as if I don't have permissions. I'm launching dimok's iosuhax beforehand so that shouldn't be an issue.
     
  17. shinyquagsire23

    shinyquagsire23 SALT/Sm4sh Leak Guy

    Member
    1,966
    3,249
    Nov 18, 2012
    United States
    Las Vegas
    I personally feel like forcing permissions in IOS is the proper solution for this, to be honest. You can access the entire MLC partition like this as long as permissions are stripped away. You can test this by just chmod'ing a file with perms 0x777 and any application will be able to access it. Having a separate devoptab and extra hooks just to communicate with IOS kinda feels like a mess of a way to go about doing things, and I can't really think of any reasons for PPC to be poking IOS memory when wupserver is OK at that already. At the very least it's at least kinda neat? I just can't think of any real uses for it, personally.
     
  18. Cyan

    Cyan GBATemp's lurking knight

    Global Moderator
    18,572
    8,921
    Oct 27, 2002
    France
    Engine room, learning
    subcon, you are using his new fw.img ? not an old one you had, right?
    He added "IOSU Node" on his new IOSUHax yesterday, you need these nodes (API) to "attach" ftpii to it.
     
  19. dimok
    OP

    dimok GBAtemp Advanced Fan

    Member
    728
    2,174
    Jan 11, 2009
    United States
    I updated the lib and added FSA raw open/read/write/close functions as ioctl commands now.
    @aliaspider @FIX94 now we can try and see if we can use libfat from PPC ;). Screw that Nintendo FS library with zero caching.

    You are very likely not using a new build of the iosuhax. I uploaded the sources yesterday and you have to re-build it.

    Actually this is how the system is intended to access FSA and hardware in generell in the first place, through IPC.
    Changing permissions of files on the systems is usually a very bad idea as that is quite permanent. From my point of view this is actually not the way to go. At least not for normal users. What wupserver can do is quite awesome but accessing wupserver from PPC through a local TCP socket seems kind of weird when there is something on the system that is faster and is already designed exactly for that interprocess communication. This whole thing's purpose is for creating nice PPC applications.

    Besides you still have to mount some devices as they are not always mounted so you have to have some communication to the ARM side.
     
    Last edited by dimok, Nov 18, 2016
  20. AboodXD

    AboodXD I hack NSMB games, and other shiz.

    Member
    2,697
    1,417
    Oct 11, 2014
    United Arab Emirates
    Not under a rock.
    Can somebody tell me what FTP program is @dimok using?
    FileZilla only succeeds to mount the SD...

    It says Directory listing failed for everything except SD.
    I'm using redNAND BTW.

    Edit: oh, I have to rebuild iosuhax...
     
    Last edited by AboodXD, Nov 18, 2016
    efen3001 likes this.