mirror of
https://github.com/rvtr/unlaunch-installer_dev.git
synced 2026-01-26 13:43:08 -05:00
Properly detect case where deviceList was populated with garbage data
Assume the device list is valid if it has a valid device that matches the path of the app
This commit is contained in:
parent
593141e702
commit
bfdd89218d
@ -4,6 +4,8 @@
|
||||
#define DEVICE_LIST_SENTINEL *(vu32*)0x02300020
|
||||
#define DEVICE_LIST_ADDR (vu8*)0x02300024
|
||||
|
||||
static u8 gotDeviceList = 0;
|
||||
|
||||
size_t getDeviceNameLenFromAppName(const char (appname)[0x40])
|
||||
{
|
||||
for(int i = 0; i < 0x40; ++i)
|
||||
@ -18,8 +20,8 @@ size_t getDeviceNameLenFromAppName(const char (appname)[0x40])
|
||||
|
||||
DeviceList* getDeviceList(void)
|
||||
{
|
||||
static bool gotDeviceList = false;
|
||||
if(!gotDeviceList) {
|
||||
gotDeviceList = 1;
|
||||
while(!DEVICE_LIST_SENTINEL);
|
||||
DeviceList* list = (DeviceList*)DEVICE_LIST_ADDR;
|
||||
|
||||
@ -29,18 +31,14 @@ DeviceList* getDeviceList(void)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
gotDeviceList = 2;
|
||||
bool isSd = device->phisicalDrive == 0;
|
||||
if(isSd)
|
||||
{
|
||||
//transform the root path to sd:/ (can be sdmc:/, nand:/, nand2:/, etc)
|
||||
@ -49,8 +47,13 @@ DeviceList* getDeviceList(void)
|
||||
list->appname[1] = 'd';
|
||||
memset(list->appname + (sizeof(list->appname) - deviceNameLen + 2), 0, deviceNameLen - 2);
|
||||
}
|
||||
gotDeviceList = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(gotDeviceList == 1)
|
||||
return 0;
|
||||
|
||||
return (DeviceList*)DEVICE_LIST_ADDR;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user