mirror of
https://github.com/rvtr/unlaunch-installer_dev.git
synced 2026-01-26 13:43:08 -05:00
Properly map to "sd" deviceList path, even if it says "nand"
Hiya passes the appname as nand:/, but the nand device is set as being external storage, so is actually mapped to the sd, account for that
This commit is contained in:
parent
9c01c0c464
commit
101269a3a8
@ -4,19 +4,49 @@
|
||||
#define DEVICE_LIST_SENTINEL *(vu32*)0x02300020
|
||||
#define DEVICE_LIST_ADDR (vu8*)0x02300024
|
||||
|
||||
size_t getDeviceNameLenFromAppName(const char (appname)[0x40])
|
||||
{
|
||||
for(int i = 0; i < 0x40; ++i)
|
||||
{
|
||||
if(appname[i] == ':')
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
DeviceList* getDeviceList(void)
|
||||
{
|
||||
static bool gotDeviceList = false;
|
||||
if(!gotDeviceList) {
|
||||
while(!DEVICE_LIST_SENTINEL);
|
||||
DeviceList* list = (DeviceList*)DEVICE_LIST_ADDR;
|
||||
bool isSd = strncmp(list->appname, "sdmc", 4) == 0;
|
||||
if(!isSd && strncmp(list->appname, "nand", 4) != 0)
|
||||
|
||||
size_t deviceNameLen = getDeviceNameLenFromAppName(list->appname);
|
||||
|
||||
if(deviceNameLen == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
bool isSd = false;
|
||||
|
||||
for(int i = 0; i < 11; ++i)
|
||||
{
|
||||
Device* device = &list->devices[i];
|
||||
if(device->deviceName[deviceNameLen] == '\0' && strncmp(device->deviceName, list->appname, deviceNameLen) == 0)
|
||||
{
|
||||
isSd = device->phisicalDrive == 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(isSd)
|
||||
{
|
||||
//transform sdmc:/ to sd:/
|
||||
memmove(list->appname + 2, list->appname + 4, sizeof(list->appname) - 4);
|
||||
//transform the root path to sd:/ (can be sdmc:/, nand:/, nand2:/, etc)
|
||||
memmove(list->appname + (deviceNameLen - 2), list->appname + deviceNameLen, sizeof(list->appname) - deviceNameLen);
|
||||
list->appname[0] = 's';
|
||||
list->appname[1] = 'd';
|
||||
list->appname[sizeof(list->appname) - 1] = '\0';
|
||||
list->appname[sizeof(list->appname) - 2] = '\0';
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user