Validating Wii U address range?

Discussion in 'Wii U - Hacking & Backup Loaders' started by BullyWiiPlaza, Nov 18, 2016.

  1. BullyWiiPlaza
    OP

    BullyWiiPlaza Nintendo Hacking <3

    Member
    1,729
    1,409
    Aug 2, 2014
    Germany
    For reading/writing it would be useful to ask the Wii U whether the memory area chosen for the respective operation is "safe" to use or not. I wrote the following piece of code:
    Code:
    int validateAddressRange(int starting_address, int ending_address) {
        for (int current_address = starting_address; current_address <= ending_address; current_address++) {
            int is_current_address_valid = OSIsAddressValid((void *) current_address);
    
            if (!is_current_address_valid) {
                return 0;
            }
        }
    
        return 1;
    }
    What does it do? It checks the memory range from start to end and in byte steps with the OSIsAddressValid() library function since we need to assure that every single address in-between is readable.

    Is there a range version since I assume my implementation could be slightly slow for checking big ranges?

    OSIsAddressRangeDCValid()
    is for the CPU data cache only. Alternatively I found syscall_get_map_virtual_address_range(), __OSValidateAddressSpaceRange() in coreinit.rpl.
     
    CosmoCortney likes this.