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

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

  1. shinyquagsire23

    shinyquagsire23 SALT/Sm4sh Leak Guy

    Member
    1,966
    3,249
    Nov 18, 2012
    United States
    Las Vegas
    They have to be defined? As far as browser stuff goes, you have to import and define everything manually. WUT and HBC samples have things which do this but for browser it's a little more tricky.
     
  2. BullyWiiPlaza

    BullyWiiPlaza Nintendo Hacking <3

    Member
    1,791
    1,462
    Aug 2, 2014
    Germany
    This is for the Homebrew Launcher. It builds an ELF. It's not for the browser (anymore).
     
    Last edited by BullyWiiPlaza, Mar 31, 2017
  3. shinyquagsire23

    shinyquagsire23 SALT/Sm4sh Leak Guy

    Member
    1,966
    3,249
    Nov 18, 2012
    United States
    Las Vegas
    BullyWiiPlaza likes this.
  4. BullyWiiPlaza

    BullyWiiPlaza Nintendo Hacking <3

    Member
    1,791
    1,462
    Aug 2, 2014
    Germany
  5. Nerdtendo

    Nerdtendo GBAtemp Regular

    Member
    168
    87
    Sep 29, 2016
    United States
    So I was directed to this forum because I am considering developing. I'm still just learning programming (I've made 1 basic game using Python and am working on a more complex one) and I'm also pretty young (I would rather not specify my age) so who here can give me a noob rundown of homebrew development and how it works?
     
  6. BullyWiiPlaza

    BullyWiiPlaza Nintendo Hacking <3

    Member
    1,791
    1,462
    Aug 2, 2014
    Germany
    You learn C programming and then install devkitPro/with libraries potentially to get started with compiling projects. You better use some existing project and modify it to do what you want instead of starting from scratch.
     
  7. Nerdtendo

    Nerdtendo GBAtemp Regular

    Member
    168
    87
    Sep 29, 2016
    United States
    Alright, that she all i need to know. I'll probably tinker with Python a bit more beforehand moving on to C but I'll look into this.
     
  8. QuarkTheAwesome

    QuarkTheAwesome Working for Hugs

    Member
    838
    2,076
    Apr 19, 2015
    Australia
    Stuck in the PowerPC
    When do you think about this again, a useful getting-started overview is here.
     
    CreeperMario likes this.
  9. Maschell

    Maschell GBAtemp Advanced Fan

    Member
    914
    1,331
    Jun 14, 2008
    Gambia, The
    There is also a dynamics_libs common repo that everyone can use and include into their projects as a submodule (but nobody is doing except me...)
     
    BullyWiiPlaza likes this.
  10. BullyWiiPlaza

    BullyWiiPlaza Nintendo Hacking <3

    Member
    1,791
    1,462
    Aug 2, 2014
    Germany
    Well, I used this library now but the console crashes on the very first call to IOSUHAX_Open(). Here is the code:
    Code:
    case COMMAND_IOSUHAX_READ_FILE: {
        log_print("COMMAND_IOSUHAX_READ_FILE");
    
        // TODO Crashes console on this call
        int returnValue = IOSUHAX_Open(NULL);
        log_print("IOSUHAX_Open Done");
        log_printf("IOSUHAX_Open: %i", returnValue);
    
        if (returnValue < 0) {
            goto IOSUHAX_OPEN_FAILED;
        }
    
        int fileSystemFileDescriptor = IOSUHAX_FSA_Open();
        log_printf("IOSUHAX_FSA_Open: %i", fileSystemFileDescriptor);
    
        if (fileSystemFileDescriptor < 0) {
            goto IOSUHAX_FSA_OPEN_FAILED;
        }
    
        int fileDescriptor;
        const char *filePath = "/vol/storage_usb/usr/title/0005000e/1010ed00/content/audio/stream/pBGM_GBA_CHEESELAND_F.bfstm";
        returnValue = IOSUHAX_FSA_OpenFile(fileSystemFileDescriptor, filePath, "rb", &fileDescriptor);
        log_printf("IOSUHAX_FSA_OpenFile: %i", returnValue);
    
        if (returnValue < 0) {
            goto IOSUHAX_OPEN_FILE_FAILED;
        }
    
        fileStat_s fileStat;
        returnValue = IOSUHAX_FSA_StatFile(fileSystemFileDescriptor, fileDescriptor, &fileStat);
        log_printf("IOSUHAX_FSA_StatFile: %i", returnValue);
    
        if (returnValue < 0) {
            goto IOSUHAX_READ_FILE_FAILED_CLOSE;
        }
    
        void *fileBuffer = MEMBucket_alloc(fileStat.size, 4);
        log_printf("File Buffer: %p", fileBuffer);
    
        if (!fileBuffer) {
            goto IOSUHAX_READ_FILE_FAILED_CLOSE;
        }
    
        size_t totalBytesRead = 0;
        while (totalBytesRead < fileStat.size) {
            size_t remainingBytes = fileStat.size - totalBytesRead;
            int bytesRead = IOSUHAX_FSA_ReadFile(fileSystemFileDescriptor,
                                                 fileBuffer + totalBytesRead,
                                                 0x01,
                                                 remainingBytes,
                                                 fileDescriptor,
                                                 0);
            log_printf("IOSUHAX_FSA_ReadFile: %i", bytesRead);
    
            if (bytesRead <= 0) {
                goto IOSUHAX_READ_FILE_FAILED_CLOSE;
            } else {
                totalBytesRead += bytesRead;
            }
        }
    
        log_printf("Bytes read: %i", totalBytesRead);
    
        IOSUHAX_READ_FILE_FAILED_CLOSE:
    
        returnValue = IOSUHAX_FSA_CloseFile(fileSystemFileDescriptor, fileDescriptor);
        log_printf("IOSUHAX_FSA_CloseFile: %i", returnValue);
    
        IOSUHAX_OPEN_FILE_FAILED:
    
        returnValue = IOSUHAX_FSA_Close(fileSystemFileDescriptor);
        log_printf("IOSUHAX_FSA_Close: %i", returnValue);
    
        IOSUHAX_FSA_OPEN_FAILED:
    
        returnValue = IOSUHAX_Close();
        log_printf("IOSUHAX_Close: %i", returnValue);
    
        IOSUHAX_OPEN_FAILED:
    
        break;
    }
    I intend to read a file from Mario Kart 8 from the USB and hard-coded the path for testing. In case there is something wrong with it, thanks for any indications.

    Only the first log is printed so it is obvious that it crashed exactly at the first call:
    [​IMG]
    I tried in the Wii U menu and in some Wii U game but same result. Why does it crash? Since the code compiled to begin with, the function is not undefined or anything so it should execute correctly. I didn't modify the libiosuhax at all. I only used CBHC booting the system menu with patches however, no Mocha. With Mocha, it freezes after the TCP Gecko Installer when the Wii U menu loads :/
     
    Last edited by BullyWiiPlaza, Apr 20, 2017
  11. Maschell

    Maschell GBAtemp Advanced Fan

    Member
    914
    1,331
    Jun 14, 2008
    Gambia, The
    Check the logs of the console with ftpiiu everywhere

    Edit: ONLY Mocha supports libiosuhax on dev/iosuhax, so I guess thats the problem. It shouldn't crash though.
    (CBHC needs some workarround I personally don't really like)
    Probabaly the fact that the TCP Installer is crashing after using Mocha is the problem
     
    Last edited by Maschell, Apr 20, 2017
  12. BullyWiiPlaza

    BullyWiiPlaza Nintendo Hacking <3

    Member
    1,791
    1,462
    Aug 2, 2014
    Germany
    What's the file path to check the logs?
    So CBHC should use Mocha to avoid having more problems and the TCP Gecko Installer should be fixed so it doesn't crash in certain circumstances? It seems like it because I also don't like how some dimok tools don't work with CBHC's system menu patches. There is just no reason for that :D
     
  13. Maschell

    Maschell GBAtemp Advanced Fan

    Member
    914
    1,331
    Jun 14, 2008
    Gambia, The
    The otherway round. CBHC doesn't support libiosuhax, because it's "just" patching some function and is no real CFW.
    I personally would just use Mocha and no CBHC at all ;)

    The logs are in "storage_slc/logs"
     
    BullyWiiPlaza likes this.
  14. brienj

    brienj Trying to avoid getting cancer

    Member
    1,232
    1,707
    Jan 3, 2016
    United States
    I'm glad to learn I'm not the only one ...

    I have a few homebrew projects I haven't bothered releasing, cause I didn't feel like making it work with the MCP hooks in Haxchi/CBHC.
     
    Maschell likes this.