libwiiu FS extensions (extracted from Loadiine)

Discussion in 'Wii U - Hacking & Backup Loaders' started by erana, Mar 26, 2016.

  1. erana
    OP

    erana Newbie

    Newcomer
    5
    4
    Mar 25, 2016
    Belgium
    Hello,

    if I am correct there are file open and reading functions in the Loadiine source code which can be put inside libwiiu.
    I got these magic numbers from the Loadiine code :

    #define FSOpenFile ((void (*) (FSClient *pClient, FSCmdBlock *pCmd, const char *path, const char *mode, int *handle, FSRetFlag error))0x106ef7c)
    #define FSReadFile ((int (*) (void *pClient, void *pCmd, void *buffer, int size, int count, int fd, int flag, int error)0x106f108)


    AFAIK you can do :

    uint32_t coreinit_handle;
    OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
    void (*FSOpenFile)(void *pClient, void *pCmd, const char *path, const char *mode, int *handle, uint error);
    int (*FSReadFile)(void *pClient, void *pCmd, void *buffer, int size, int count, int fd, int flag, int error);
    OSDynLoad_FindExport(coreinit_handle, 0, "FSOpenFile", &FSOpenFile);
    OSDynLoad_FindExport(coreinit_handle, 0, "FSReadFile", &FSReadFile);


    There are about 10 more functions like this inside the Loadiine code.

    I do not know if you have to acquire these functions as there's hex numbers encoded with the PROVIDE macro in Loadiine. The fact is that these FS functions might be set by Cafe OS onto these latch pointers.
    If so, you can have access to the (e.g. sd card) filesystem by using the macros above.

    The question remains however how Cafe OS and newlib are going to implement the fopen functions of libc with the above fd. Cafe OS has a similar path system as Linux/UNIX but I do not know if the file descriptor needs to be hacked somehow.

    I cannot test this however.
     
    Last edited by erana, Mar 26, 2016