FileSystemAccess:
- DirectSdmc
- CtrNandRw
+ - CategoryFileSystemTool # For FSLDR_GetNandCID
SystemControlInfo:
SaveDataSize: 0KB # It doesn't use any save data.
return cmdbuf[1];
}
+
+Result
+FSLDR_GetNandCid(u8* out, u32 length)
+{
+ u32 *cmdbuf = getThreadCommandBuffer();
+
+ cmdbuf[0] = IPC_MakeHeader(0x81A, 1, 2); // 0x81A0042
+ cmdbuf[1] = length;
+ cmdbuf[2] = IPC_Desc_Buffer(length, IPC_BUFFER_W);
+ cmdbuf[3] = (u32) out;
+
+ Result ret = 0;
+ if(R_FAILED(ret = svcSendSyncRequest(fsldrHandle)))
+ return ret;
+
+ return cmdbuf[1];
+}
Result FSLDR_InitializeWithSdkVersion(Handle session, u32 version);
Result FSLDR_SetPriority(u32 priority);
Result FSLDR_OpenFileDirectly(Handle *out, FS_ArchiveID archiveId, FS_Path archivePath, FS_Path filePath, u32 openFlags, u32 attributes);
+Result FSLDR_GetNandCid(u8* out, u32 length);
#endif
{
static Handle file;
static u32 total;
+ static u32 cid[4];
+ static char config_file_path[] = SYSCONFDIR "/config-00000000";
+
+ if (!R_SUCCEEDED(FSLDR_GetNandCid((u8*)cid, 0x10))) {
+ return;
+ }
+
+ char* cfg = config_file_path;
+ while(cfg[1] != 0) cfg++;
+
+ // Get path of actual config.
+ while (cid[0]) {
+ cfg[0] = hexDigits[(uint32_t)(cid[0] & 0xF)];
+ cfg--;
+ cid[0] >>= 4;
+ }
// Open file.
- if (!R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, PATH_CONFIG, FS_OPEN_READ))) {
+ if (!R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, config_file_path, FS_OPEN_READ))) {
// Failed to open.
return;
}