mirror of
https://github.com/switchbrew/switch-tools.git
synced 2025-06-23 14:22:40 +02:00
generate correct save_data_owner_ids
This commit is contained in:
parent
87f4744e62
commit
6fd5ae6e48
@ -466,18 +466,33 @@ int CreateNpdm(const char *json, void **dst, u32 *dst_size) {
|
|||||||
sdois = cJSON_GetObjectItemCaseSensitive(fsaccess, "save_data_owner_ids");
|
sdois = cJSON_GetObjectItemCaseSensitive(fsaccess, "save_data_owner_ids");
|
||||||
if (cJSON_IsArray(sdois)) {
|
if (cJSON_IsArray(sdois)) {
|
||||||
u32 *count = (u32 *)((u8 *)fah + fah->SdoiOffset);
|
u32 *count = (u32 *)((u8 *)fah + fah->SdoiOffset);
|
||||||
u64 *id = (u64 *)((u8 *)count + sizeof(u32));
|
|
||||||
cJSON_ArrayForEach(sdoi, sdois) {
|
cJSON_ArrayForEach(sdoi, sdois) {
|
||||||
if (!cJSON_GetU64FromObjectValue(sdoi, id)) {
|
if (!cJSON_IsObject(sdoi)) {
|
||||||
status = 0;
|
status = 0;
|
||||||
goto NPDM_BUILD_END;
|
goto NPDM_BUILD_END;
|
||||||
}
|
}
|
||||||
++id;
|
|
||||||
++(*count);
|
++(*count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8 *accessibility = (u8 *)count + sizeof(u32);
|
||||||
|
u64 *id = (u64 *)(accessibility + (((*count) + 3ULL) & ~3ULL));
|
||||||
|
|
||||||
|
cJSON_ArrayForEach(sdoi, sdois) {
|
||||||
|
if (!cJSON_GetU8(sdoi, "accessibility", accessibility)) {
|
||||||
|
status = 0;
|
||||||
|
goto NPDM_BUILD_END;
|
||||||
|
}
|
||||||
|
if (!cJSON_GetU64(sdoi, "id", id)) {
|
||||||
|
status = 0;
|
||||||
|
goto NPDM_BUILD_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
++accessibility;
|
||||||
|
++id;
|
||||||
|
}
|
||||||
|
|
||||||
if (*count > 0) {
|
if (*count > 0) {
|
||||||
fah->SdoiSize = sizeof(u32) + sizeof(u64) * (*count);
|
fah->SdoiSize = sizeof(u32) + sizeof(u8) * ((((*count) + 3ULL) & ~3ULL)) + sizeof(u64) * (*count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user