mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2025-01-09 11:07:23 -03:00
Use verbosity-level-based log macros everywhere.
Also, Result codes are now just printed using %X.
This commit is contained in:
parent
9cb2a0440e
commit
5cc83491c1
34 changed files with 999 additions and 1022 deletions
|
@ -48,15 +48,6 @@ extern "C" {
|
|||
#define LOG_MSG_BUF_GENERIC(dst, dst_size, level, fmt, ...) logWriteFormattedStringToBuffer(dst, dst_size, level, __FILENAME__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define LOG_DATA_GENERIC(data, data_size, level, fmt, ...) logWriteBinaryDataToLogFile(data, data_size, level, __FILENAME__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
|
||||
|
||||
|
||||
/* TODO: delete these macros after migrating all log calls to the new verbosity-level-based system. */
|
||||
#define LOG_MSG(fmt, ...) LOG_MSG_GENERIC(LOG_LEVEL, fmt, ##__VA_ARGS__)
|
||||
#define LOG_MSG_BUF(dst, dst_size, fmt, ...) LOG_MSG_BUF_GENERIC(dst, dst_size, LOG_LEVEL, fmt, ##__VA_ARGS__)
|
||||
#define LOG_DATA(data, data_size, fmt, ...) LOG_DATA_GENERIC(data, data_size, LOG_LEVEL, fmt, ##__VA_ARGS__)
|
||||
|
||||
|
||||
|
||||
#if LOG_LEVEL == LOG_LEVEL_DEBUG
|
||||
#define LOG_MSG_DEBUG(fmt, ...) LOG_MSG_GENERIC(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
|
||||
#define LOG_MSG_BUF_DEBUG(dst, dst_size, fmt, ...) LOG_MSG_BUF_GENERIC(dst, dst_size, LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
|
||||
|
@ -130,15 +121,6 @@ void logControlMutex(bool lock);
|
|||
|
||||
/// Helper macros.
|
||||
|
||||
|
||||
|
||||
/* TODO: delete these macros after migrating all log calls to the new verbosity-level-based system. */
|
||||
#define LOG_MSG(fmt, ...) do {} while(0)
|
||||
#define LOG_MSG_BUF(dst, dst_size, fmt, ...) do {} while(0)
|
||||
#define LOG_DATA(data, data_size, fmt, ...) do {} while(0)
|
||||
|
||||
|
||||
|
||||
#define LOG_MSG_GENERIC(level, fmt, ...) do {} while(0)
|
||||
#define LOG_MSG_BUF_GENERIC(dst, dst_size, level, fmt, ...) do {} while(0)
|
||||
#define LOG_DATA_GENERIC(data, data_size, level, fmt, ...) do {} while(0)
|
||||
|
|
|
@ -25,7 +25,7 @@ size_t aes128XtsNintendoCrypt(Aes128XtsContext *ctx, void *dst, const void *src,
|
|||
{
|
||||
if (!ctx || !dst || !src || !size || !sector_size || (size % sector_size) != 0)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ bool bfttfInitialize(void)
|
|||
nca_ctx = calloc(1, sizeof(NcaContext));
|
||||
if (!nca_ctx)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for temporary NCA context!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for temporary NCA context!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ bool bfttfInitialize(void)
|
|||
/* Get title info. */
|
||||
if (!(title_info = titleGetInfoFromStorageByTitleId(NcmStorageId_BuiltInSystem, font_info->title_id)))
|
||||
{
|
||||
LOG_MSG("Failed to get title info for %016lX!", font_info->title_id);
|
||||
LOG_MSG_ERROR("Failed to get title info for %016lX!", font_info->title_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ bool bfttfInitialize(void)
|
|||
/* Check if NCA context initialization succeeded. */
|
||||
if (!nca_ctx_init)
|
||||
{
|
||||
LOG_MSG("Failed to initialize Data NCA context for %016lX!", font_info->title_id);
|
||||
LOG_MSG_ERROR("Failed to initialize Data NCA context for %016lX!", font_info->title_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ bool bfttfInitialize(void)
|
|||
/* This will also free a previous RomFS context, if available. */
|
||||
if (!romfsInitializeContext(&romfs_ctx, &(nca_ctx->fs_ctx[0]), NULL))
|
||||
{
|
||||
LOG_MSG("Failed to initialize RomFS context for Data NCA from %016lX!", font_info->title_id);
|
||||
LOG_MSG_ERROR("Failed to initialize RomFS context for Data NCA from %016lX!", font_info->title_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -126,28 +126,28 @@ bool bfttfInitialize(void)
|
|||
/* Get RomFS file entry. */
|
||||
if (!(romfs_file_entry = romfsGetFileEntryByPath(&romfs_ctx, font_info->path)))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve RomFS file entry in %016lX!", font_info->title_id);
|
||||
LOG_MSG_ERROR("Failed to retrieve RomFS file entry in %016lX!", font_info->title_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check file size. */
|
||||
if (!romfs_file_entry->size)
|
||||
{
|
||||
LOG_MSG("File size for \"%s\" in %016lX is zero!", font_info->path, font_info->title_id);
|
||||
LOG_MSG_ERROR("File size for \"%s\" in %016lX is zero!", font_info->path, font_info->title_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Allocate memory for BFTTF data. */
|
||||
if (!(font_info->data = malloc(romfs_file_entry->size)))
|
||||
{
|
||||
LOG_MSG("Failed to allocate 0x%lX bytes for \"%s\" in %016lX!", romfs_file_entry->size, font_info->path, font_info->title_id);
|
||||
LOG_MSG_ERROR("Failed to allocate 0x%lX bytes for \"%s\" in %016lX!", romfs_file_entry->size, font_info->path, font_info->title_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Read BFTFF data. */
|
||||
if (!romfsReadFileEntryData(&romfs_ctx, romfs_file_entry, font_info->data, romfs_file_entry->size, 0))
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%lX bytes long \"%s\" in %016lX!", romfs_file_entry->size, font_info->path, font_info->title_id);
|
||||
LOG_MSG_ERROR("Failed to read 0x%lX bytes long \"%s\" in %016lX!", romfs_file_entry->size, font_info->path, font_info->title_id);
|
||||
free(font_info->data);
|
||||
font_info->data = NULL;
|
||||
continue;
|
||||
|
@ -159,7 +159,7 @@ bool bfttfInitialize(void)
|
|||
/* Decode BFTTF data. */
|
||||
if (!bfttfDecodeFont(font_info))
|
||||
{
|
||||
LOG_MSG("Failed to decode 0x%lX bytes long \"%s\" in %016lX!", romfs_file_entry->size, font_info->path, font_info->title_id);
|
||||
LOG_MSG_ERROR("Failed to decode 0x%lX bytes long \"%s\" in %016lX!", romfs_file_entry->size, font_info->path, font_info->title_id);
|
||||
free(font_info->data);
|
||||
font_info->data = NULL;
|
||||
font_info->size = 0;
|
||||
|
@ -172,7 +172,7 @@ bool bfttfInitialize(void)
|
|||
|
||||
/* Update flags. */
|
||||
ret = g_bfttfInterfaceInit = (count > 0);
|
||||
if (!ret) LOG_MSG("No BFTTF fonts retrieved!");
|
||||
if (!ret) LOG_MSG_ERROR("No BFTTF fonts retrieved!");
|
||||
}
|
||||
|
||||
romfsFreeContext(&romfs_ctx);
|
||||
|
@ -208,7 +208,7 @@ bool bfttfGetFontByType(BfttfFontData *font_data, u8 font_type)
|
|||
{
|
||||
if (!font_data || font_type >= BfttfFontType_Total)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ bool bfttfGetFontByType(BfttfFontData *font_data, u8 font_type)
|
|||
BfttfFontInfo *font_info = &(g_fontInfo[font_type]);
|
||||
if (font_info->size <= 8 || !font_info->data)
|
||||
{
|
||||
LOG_MSG("BFTTF font data unavailable for type 0x%02X!", font_type);
|
||||
LOG_MSG_ERROR("BFTTF font data unavailable for type 0x%02X!", font_type);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ static bool bfttfDecodeFont(BfttfFontInfo *font_info)
|
|||
{
|
||||
if (!font_info || font_info->size <= 8 || !IS_ALIGNED(font_info->size, 4) || !font_info->data)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ bool bktrInitializeContext(BucketTreeContext *out, NcaFsSectionContext *nca_fs_c
|
|||
if (!out || !nca_fs_ctx || !nca_fs_ctx->enabled || nca_fs_ctx->section_type >= NcaFsSectionType_Invalid || !(nca_ctx = (NcaContext*)nca_fs_ctx->nca_ctx) || \
|
||||
(nca_ctx->rights_id_available && !nca_ctx->titlekey_retrieved) || storage_type == BucketTreeStorageType_Compressed || storage_type >= BucketTreeStorageType_Count)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ bool bktrInitializeCompressedStorageContext(BucketTreeContext *out, BucketTreeSu
|
|||
substorage->type == BucketTreeSubStorageType_AesCtrEx || substorage->type == BucketTreeSubStorageType_Compressed || substorage->type >= BucketTreeSubStorageType_Count || \
|
||||
(substorage->type == BucketTreeSubStorageType_Regular && substorage->bktr_ctx) || (substorage->type != BucketTreeSubStorageType_Regular && !substorage->bktr_ctx))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ bool bktrInitializeCompressedStorageContext(BucketTreeContext *out, BucketTreeSu
|
|||
/* Verify bucket info. */
|
||||
if (!bktrVerifyBucketInfo(compressed_bucket, BKTR_NODE_SIZE, BKTR_COMPRESSED_ENTRY_SIZE, &node_storage_size, &entry_storage_size))
|
||||
{
|
||||
LOG_MSG("Compressed Storage BucketInfo verification failed!");
|
||||
LOG_MSG_ERROR("Compressed Storage BucketInfo verification failed!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ bool bktrInitializeCompressedStorageContext(BucketTreeContext *out, BucketTreeSu
|
|||
compressed_table = calloc(1, compressed_bucket->size);
|
||||
if (!compressed_table)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for the Compressed Storage Table!");
|
||||
LOG_MSG_ERROR("Unable to allocate memory for the Compressed Storage Table!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ bool bktrInitializeCompressedStorageContext(BucketTreeContext *out, BucketTreeSu
|
|||
|
||||
if (!bktrReadSubStorage(substorage, ¶ms))
|
||||
{
|
||||
LOG_MSG("Failed to read Compressed Storage Table data!");
|
||||
LOG_MSG_ERROR("Failed to read Compressed Storage Table data!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ bool bktrInitializeCompressedStorageContext(BucketTreeContext *out, BucketTreeSu
|
|||
u64 start_offset = 0, end_offset = 0;
|
||||
if (!bktrValidateTableOffsetNode(compressed_table, BKTR_NODE_SIZE, BKTR_COMPRESSED_ENTRY_SIZE, compressed_bucket->header.entry_count, &start_offset, &end_offset))
|
||||
{
|
||||
LOG_MSG("Compressed Storage Table Offset Node validation failed!");
|
||||
LOG_MSG_ERROR("Compressed Storage Table Offset Node validation failed!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,7 @@ bool bktrSetRegularSubStorage(BucketTreeContext *ctx, NcaFsSectionContext *nca_f
|
|||
(ctx->storage_type == BucketTreeStorageType_Indirect && ctx->nca_fs_ctx == nca_fs_ctx) || \
|
||||
((ctx->storage_type == BucketTreeStorageType_AesCtrEx || ctx->storage_type == BucketTreeStorageType_Sparse) && ctx->nca_fs_ctx != nca_fs_ctx))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -285,7 +285,7 @@ bool bktrSetBucketTreeSubStorage(BucketTreeContext *parent_ctx, BucketTreeContex
|
|||
parent_ctx->nca_fs_ctx != child_ctx->nca_fs_ctx)) || ((child_ctx->storage_type == BucketTreeStorageType_Compressed || \
|
||||
child_ctx->storage_type == BucketTreeStorageType_Sparse) && (substorage_index != 0 || parent_ctx->nca_fs_ctx == child_ctx->nca_fs_ctx)))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ bool bktrReadStorage(BucketTreeContext *ctx, void *out, u64 read_size, u64 offse
|
|||
{
|
||||
if (!bktrIsBlockWithinStorageRange(ctx, read_size, offset) || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ bool bktrIsBlockWithinIndirectStorageRange(BucketTreeContext *ctx, u64 offset, u
|
|||
if (!bktrIsBlockWithinStorageRange(ctx, size, offset) || (ctx->storage_type != BucketTreeStorageType_Indirect && ctx->storage_type != BucketTreeStorageType_Compressed) || \
|
||||
(ctx->storage_type == BucketTreeStorageType_Compressed && ctx->substorages[0].type != BucketTreeSubStorageType_Indirect) || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ bool bktrIsBlockWithinIndirectStorageRange(BucketTreeContext *ctx, u64 offset, u
|
|||
start_entry = end_entry = (BucketTreeCompressedStorageEntry*)visitor.entry;
|
||||
if (!bktrIsOffsetWithinStorageRange(ctx, (u64)start_entry->virtual_offset) || (u64)start_entry->virtual_offset > offset)
|
||||
{
|
||||
LOG_MSG("Invalid Compressed Storage entry! (0x%lX) (#1).", start_entry->virtual_offset);
|
||||
LOG_MSG_ERROR("Invalid Compressed Storage entry! (0x%lX) (#1).", start_entry->virtual_offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ bool bktrIsBlockWithinIndirectStorageRange(BucketTreeContext *ctx, u64 offset, u
|
|||
/* Retrieve next entry node. */
|
||||
if (!bktrVisitorMoveNext(&visitor))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve next Compressed Storage entry!");
|
||||
LOG_MSG_ERROR("Failed to retrieve next Compressed Storage entry!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,7 @@ bool bktrIsBlockWithinIndirectStorageRange(BucketTreeContext *ctx, u64 offset, u
|
|||
end_entry = (BucketTreeCompressedStorageEntry*)visitor.entry;
|
||||
if (!bktrIsOffsetWithinStorageRange(ctx, (u64)end_entry->virtual_offset) || (u64)end_entry->virtual_offset <= (u64)tmp->virtual_offset)
|
||||
{
|
||||
LOG_MSG("Invalid Indirect Storage entry! (0x%lX) (#2).", (u64)end_entry->virtual_offset);
|
||||
LOG_MSG_ERROR("Invalid Indirect Storage entry! (0x%lX) (#2).", (u64)end_entry->virtual_offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -435,7 +435,7 @@ bool bktrIsBlockWithinIndirectStorageRange(BucketTreeContext *ctx, u64 offset, u
|
|||
/* Check if the current Compressed Storage entry node points to one or more Indirect Storage entry nodes with Patch storage index. */
|
||||
if (!bktrIsBlockWithinIndirectStorageRange(indirect_storage, indirect_block_offset, indirect_block_size, &updated))
|
||||
{
|
||||
LOG_MSG("Failed to determine if 0x%lX-byte long Compressed storage block at offset 0x%lX is within Indirect Storage!", indirect_block_offset, indirect_block_size);
|
||||
LOG_MSG_ERROR("Failed to determine if 0x%lX-byte long Compressed storage block at offset 0x%lX is within Indirect Storage!", indirect_block_offset, indirect_block_size);
|
||||
goto end;
|
||||
}
|
||||
} while(!updated && end_entry && (u64)end_entry->virtual_offset < (offset + size));
|
||||
|
@ -454,7 +454,7 @@ bool bktrIsBlockWithinIndirectStorageRange(BucketTreeContext *ctx, u64 offset, u
|
|||
start_entry = end_entry = (BucketTreeIndirectStorageEntry*)visitor.entry;
|
||||
if (!bktrIsOffsetWithinStorageRange(ctx, start_entry->virtual_offset) || start_entry->virtual_offset > offset)
|
||||
{
|
||||
LOG_MSG("Invalid Indirect Storage entry! (0x%lX) (#1).", start_entry->virtual_offset);
|
||||
LOG_MSG_ERROR("Invalid Indirect Storage entry! (0x%lX) (#1).", start_entry->virtual_offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -473,7 +473,7 @@ bool bktrIsBlockWithinIndirectStorageRange(BucketTreeContext *ctx, u64 offset, u
|
|||
/* Retrieve the next entry node. */
|
||||
if (!bktrVisitorMoveNext(&visitor))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve next Indirect Storage entry!");
|
||||
LOG_MSG_ERROR("Failed to retrieve next Indirect Storage entry!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -481,7 +481,7 @@ bool bktrIsBlockWithinIndirectStorageRange(BucketTreeContext *ctx, u64 offset, u
|
|||
end_entry = (BucketTreeIndirectStorageEntry*)visitor.entry;
|
||||
if (!bktrIsOffsetWithinStorageRange(ctx, end_entry->virtual_offset) || end_entry->virtual_offset <= start_entry->virtual_offset)
|
||||
{
|
||||
LOG_MSG("Invalid Indirect Storage entry! (0x%lX) (#2).", end_entry->virtual_offset);
|
||||
LOG_MSG_ERROR("Invalid Indirect Storage entry! (0x%lX) (#2).", end_entry->virtual_offset);
|
||||
goto end;
|
||||
}
|
||||
} while(end_entry->virtual_offset < (offset + size));
|
||||
|
@ -505,7 +505,7 @@ static bool bktrInitializeIndirectStorageContext(BucketTreeContext *out, NcaFsSe
|
|||
{
|
||||
if ((!is_sparse && nca_fs_ctx->section_type != NcaFsSectionType_PatchRomFs) || (is_sparse && !nca_fs_ctx->has_sparse_layer))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -518,7 +518,7 @@ static bool bktrInitializeIndirectStorageContext(BucketTreeContext *out, NcaFsSe
|
|||
/* Verify bucket info. */
|
||||
if (!bktrVerifyBucketInfo(indirect_bucket, BKTR_NODE_SIZE, BKTR_INDIRECT_ENTRY_SIZE, &node_storage_size, &entry_storage_size))
|
||||
{
|
||||
LOG_MSG("Indirect Storage BucketInfo verification failed! (%s).", is_sparse ? "sparse" : "patch");
|
||||
LOG_MSG_ERROR("Indirect Storage BucketInfo verification failed! (%s).", is_sparse ? "sparse" : "patch");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -526,7 +526,7 @@ static bool bktrInitializeIndirectStorageContext(BucketTreeContext *out, NcaFsSe
|
|||
indirect_table = calloc(1, indirect_bucket->size);
|
||||
if (!indirect_table)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for the Indirect Storage Table! (%s).", is_sparse ? "sparse" : "patch");
|
||||
LOG_MSG_ERROR("Unable to allocate memory for the Indirect Storage Table! (%s).", is_sparse ? "sparse" : "patch");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -534,7 +534,7 @@ static bool bktrInitializeIndirectStorageContext(BucketTreeContext *out, NcaFsSe
|
|||
if ((!is_sparse && !ncaReadFsSection(nca_fs_ctx, indirect_table, indirect_bucket->size, indirect_bucket->offset)) || \
|
||||
(is_sparse && !ncaReadContentFile((NcaContext*)nca_fs_ctx->nca_ctx, indirect_table, indirect_bucket->size, nca_fs_ctx->sparse_table_offset)))
|
||||
{
|
||||
LOG_MSG("Failed to read Indirect Storage Table data! (%s).", is_sparse ? "sparse" : "patch");
|
||||
LOG_MSG_ERROR("Failed to read Indirect Storage Table data! (%s).", is_sparse ? "sparse" : "patch");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -565,7 +565,7 @@ static bool bktrInitializeIndirectStorageContext(BucketTreeContext *out, NcaFsSe
|
|||
u64 start_offset = 0, end_offset = 0;
|
||||
if (!bktrValidateTableOffsetNode(indirect_table, BKTR_NODE_SIZE, BKTR_INDIRECT_ENTRY_SIZE, indirect_bucket->header.entry_count, &start_offset, &end_offset))
|
||||
{
|
||||
LOG_MSG("Indirect Storage Table Offset Node validation failed! (%s).", is_sparse ? "sparse" : "patch");
|
||||
LOG_MSG_ERROR("Indirect Storage Table Offset Node validation failed! (%s).", is_sparse ? "sparse" : "patch");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -602,7 +602,7 @@ static bool bktrReadIndirectStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
(!missing_original_storage && (ctx->substorages[0].type == BucketTreeSubStorageType_Indirect || ctx->substorages[0].type == BucketTreeSubStorageType_AesCtrEx || \
|
||||
ctx->substorages[0].type >= BucketTreeSubStorageType_Count)))) || (offset + read_size) > ctx->end_offset)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -612,7 +612,7 @@ static bool bktrReadIndirectStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
|
||||
if (!bktrIsOffsetWithinStorageRange(ctx, cur_entry.virtual_offset) || cur_entry.virtual_offset > offset || cur_entry.storage_index > BucketTreeIndirectStorageIndex_Patch)
|
||||
{
|
||||
LOG_MSG("Invalid Indirect Storage entry! (0x%lX) (#1).", cur_entry.virtual_offset);
|
||||
LOG_MSG_ERROR("Invalid Indirect Storage entry! (0x%lX) (#1).", cur_entry.virtual_offset);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -625,7 +625,7 @@ static bool bktrReadIndirectStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
/* Retrieve the next entry. */
|
||||
if (!bktrVisitorMoveNext(visitor))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve next Indirect Storage entry!");
|
||||
LOG_MSG_ERROR("Failed to retrieve next Indirect Storage entry!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -633,7 +633,7 @@ static bool bktrReadIndirectStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
BucketTreeIndirectStorageEntry *next_entry = (BucketTreeIndirectStorageEntry*)visitor->entry;
|
||||
if (!bktrIsOffsetWithinStorageRange(ctx, next_entry->virtual_offset) || next_entry->storage_index > BucketTreeIndirectStorageIndex_Patch)
|
||||
{
|
||||
LOG_MSG("Invalid Indirect Storage entry! (0x%lX) (#2).", next_entry->virtual_offset);
|
||||
LOG_MSG_ERROR("Invalid Indirect Storage entry! (0x%lX) (#2).", next_entry->virtual_offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -650,7 +650,7 @@ static bool bktrReadIndirectStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
/* Verify next entry offset. */
|
||||
if (next_entry_offset <= cur_entry_offset || offset >= next_entry_offset)
|
||||
{
|
||||
LOG_MSG("Invalid virtual offset for the Indirect Storage's next entry! (0x%lX).", next_entry_offset);
|
||||
LOG_MSG_ERROR("Invalid virtual offset for the Indirect Storage's next entry! (0x%lX).", next_entry_offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -669,9 +669,9 @@ static bool bktrReadIndirectStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
/* Retrieve data from the original data storage. */
|
||||
/* This may either be a Regular/Sparse/Compressed storage from the base NCA (Indirect) or a Regular storage from this very same NCA (Sparse). */
|
||||
success = bktrReadSubStorage(&(ctx->substorages[0]), ¶ms);
|
||||
if (!success) LOG_MSG("Failed to read 0x%lX-byte long chunk from offset 0x%lX in original data storage!", read_size, data_offset);
|
||||
if (!success) LOG_MSG_ERROR("Failed to read 0x%lX-byte long chunk from offset 0x%lX in original data storage!", read_size, data_offset);
|
||||
} else {
|
||||
LOG_MSG("Error: attempting to read 0x%lX-byte long chunk from missing original data storage at offset 0x%lX!", read_size, data_offset);
|
||||
LOG_MSG_ERROR("Error: attempting to read 0x%lX-byte long chunk from missing original data storage at offset 0x%lX!", read_size, data_offset);
|
||||
}
|
||||
} else {
|
||||
if (!is_sparse)
|
||||
|
@ -679,7 +679,7 @@ static bool bktrReadIndirectStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
/* Retrieve data from the indirect data storage. */
|
||||
/* This must always be the AesCtrEx storage within this very same NCA (Indirect). */
|
||||
success = bktrReadSubStorage(&(ctx->substorages[1]), ¶ms);
|
||||
if (!success) LOG_MSG("Failed to read 0x%lX-byte long chunk from offset 0x%lX in AesCtrEx storage!", read_size, data_offset);
|
||||
if (!success) LOG_MSG_ERROR("Failed to read 0x%lX-byte long chunk from offset 0x%lX in AesCtrEx storage!", read_size, data_offset);
|
||||
} else {
|
||||
/* Fill output buffer with zeroes (SparseStorage's ZeroStorage). */
|
||||
memset(out, 0, read_size);
|
||||
|
@ -695,7 +695,7 @@ static bool bktrReadIndirectStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
success = (bktrReadIndirectStorage(visitor, out, indirect_block_size, offset) && \
|
||||
bktrReadIndirectStorage(visitor, (u8*)out + indirect_block_size, read_size - indirect_block_size, offset + indirect_block_size));
|
||||
|
||||
if (!success) LOG_MSG("Failed to read 0x%lX bytes block from multiple Indirect Storage entries at offset 0x%lX!", read_size, offset);
|
||||
if (!success) LOG_MSG_ERROR("Failed to read 0x%lX bytes block from multiple Indirect Storage entries at offset 0x%lX!", read_size, offset);
|
||||
}
|
||||
|
||||
end:
|
||||
|
@ -706,7 +706,7 @@ static bool bktrInitializeAesCtrExStorageContext(BucketTreeContext *out, NcaFsSe
|
|||
{
|
||||
if (nca_fs_ctx->section_type != NcaFsSectionType_PatchRomFs || !nca_fs_ctx->header.patch_info.aes_ctr_ex_bucket.size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -718,7 +718,7 @@ static bool bktrInitializeAesCtrExStorageContext(BucketTreeContext *out, NcaFsSe
|
|||
/* Verify bucket info. */
|
||||
if (!bktrVerifyBucketInfo(aes_ctr_ex_bucket, BKTR_NODE_SIZE, BKTR_AES_CTR_EX_ENTRY_SIZE, &node_storage_size, &entry_storage_size))
|
||||
{
|
||||
LOG_MSG("AesCtrEx Storage BucketInfo verification failed!");
|
||||
LOG_MSG_ERROR("AesCtrEx Storage BucketInfo verification failed!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -726,14 +726,14 @@ static bool bktrInitializeAesCtrExStorageContext(BucketTreeContext *out, NcaFsSe
|
|||
aes_ctr_ex_table = calloc(1, aes_ctr_ex_bucket->size);
|
||||
if (!aes_ctr_ex_table)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for the AesCtrEx Storage Table!");
|
||||
LOG_MSG_ERROR("Unable to allocate memory for the AesCtrEx Storage Table!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Read AesCtrEx storage table data. */
|
||||
if (!ncaReadFsSection(nca_fs_ctx, aes_ctr_ex_table, aes_ctr_ex_bucket->size, aes_ctr_ex_bucket->offset))
|
||||
{
|
||||
LOG_MSG("Failed to read AesCtrEx Storage Table data!");
|
||||
LOG_MSG_ERROR("Failed to read AesCtrEx Storage Table data!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -741,7 +741,7 @@ static bool bktrInitializeAesCtrExStorageContext(BucketTreeContext *out, NcaFsSe
|
|||
u64 start_offset = 0, end_offset = 0;
|
||||
if (!bktrValidateTableOffsetNode(aes_ctr_ex_table, BKTR_NODE_SIZE, BKTR_AES_CTR_EX_ENTRY_SIZE, aes_ctr_ex_bucket->header.entry_count, &start_offset, &end_offset))
|
||||
{
|
||||
LOG_MSG("AesCtrEx Storage Table Offset Node validation failed!");
|
||||
LOG_MSG_ERROR("AesCtrEx Storage Table Offset Node validation failed!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -773,7 +773,7 @@ static bool bktrReadAesCtrExStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
|
||||
if (!out || !bktrIsValidSubstorage(&(ctx->substorages[0])) || ctx->substorages[0].type != BucketTreeSubStorageType_Regular || (offset + read_size) > ctx->end_offset)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -783,7 +783,7 @@ static bool bktrReadAesCtrExStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
|
||||
if (!bktrIsOffsetWithinStorageRange(ctx, cur_entry.offset) || cur_entry.offset > offset || !IS_ALIGNED(cur_entry.offset, AES_BLOCK_SIZE))
|
||||
{
|
||||
LOG_MSG("Invalid AesCtrEx Storage entry! (0x%lX) (#1).", cur_entry.offset);
|
||||
LOG_MSG_ERROR("Invalid AesCtrEx Storage entry! (0x%lX) (#1).", cur_entry.offset);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -796,7 +796,7 @@ static bool bktrReadAesCtrExStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
/* Retrieve the next entry. */
|
||||
if (!bktrVisitorMoveNext(visitor))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve next AesCtrEx Storage entry!");
|
||||
LOG_MSG_ERROR("Failed to retrieve next AesCtrEx Storage entry!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -804,7 +804,7 @@ static bool bktrReadAesCtrExStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
BucketTreeAesCtrExStorageEntry *next_entry = (BucketTreeAesCtrExStorageEntry*)visitor->entry;
|
||||
if (!bktrIsOffsetWithinStorageRange(ctx, next_entry->offset))
|
||||
{
|
||||
LOG_MSG("Invalid AesCtrEx Storage entry! (0x%lX) (#2).", next_entry->offset);
|
||||
LOG_MSG_ERROR("Invalid AesCtrEx Storage entry! (0x%lX) (#2).", next_entry->offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -821,7 +821,7 @@ static bool bktrReadAesCtrExStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
/* Verify next entry offset. */
|
||||
if (!IS_ALIGNED(next_entry_offset, AES_BLOCK_SIZE) || next_entry_offset <= cur_entry_offset || offset >= next_entry_offset)
|
||||
{
|
||||
LOG_MSG("Invalid offset for the AesCtrEx Storage's next entry! (0x%lX).", next_entry_offset);
|
||||
LOG_MSG_ERROR("Invalid offset for the AesCtrEx Storage's next entry! (0x%lX).", next_entry_offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -833,7 +833,7 @@ static bool bktrReadAesCtrExStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
bktrBucketInitializeSubStorageReadParams(¶ms, out, offset, read_size, 0, cur_entry.generation, cur_entry.encryption == BucketTreeAesCtrExStorageEncryption_Enabled, ctx->storage_type);
|
||||
|
||||
success = bktrReadSubStorage(&(ctx->substorages[0]), ¶ms);
|
||||
if (!success) LOG_MSG("Failed to read 0x%lX-byte long chunk at offset 0x%lX from AesCtrEx storage!", read_size, offset);
|
||||
if (!success) LOG_MSG_ERROR("Failed to read 0x%lX-byte long chunk at offset 0x%lX from AesCtrEx storage!", read_size, offset);
|
||||
} else {
|
||||
/* Handle reads that span multiple AesCtrEx storage entries. */
|
||||
if (moved) bktrVisitorMovePrevious(visitor);
|
||||
|
@ -843,7 +843,7 @@ static bool bktrReadAesCtrExStorage(BucketTreeVisitor *visitor, void *out, u64 r
|
|||
success = (bktrReadAesCtrExStorage(visitor, out, aes_ctr_ex_block_size, offset) && \
|
||||
bktrReadAesCtrExStorage(visitor, (u8*)out + aes_ctr_ex_block_size, read_size - aes_ctr_ex_block_size, offset + aes_ctr_ex_block_size));
|
||||
|
||||
if (!success) LOG_MSG("Failed to read 0x%lX bytes block from multiple AesCtrEx Storage entries at offset 0x%lX!", read_size, offset);
|
||||
if (!success) LOG_MSG_ERROR("Failed to read 0x%lX bytes block from multiple AesCtrEx Storage entries at offset 0x%lX!", read_size, offset);
|
||||
}
|
||||
|
||||
end:
|
||||
|
@ -858,7 +858,7 @@ static bool bktrReadCompressedStorage(BucketTreeVisitor *visitor, void *out, u64
|
|||
|
||||
if (!out || !bktrIsValidSubstorage(&(ctx->substorages[0])) || ctx->substorages[0].type >= BucketTreeSubStorageType_AesCtrEx || (offset + read_size) > ctx->end_offset)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -873,7 +873,7 @@ static bool bktrReadCompressedStorage(BucketTreeVisitor *visitor, void *out, u64
|
|||
(cur_entry.compression_type == BucketTreeCompressedStorageCompressionType_LZ4 && (cur_entry.compression_level < BKTR_COMPRESSION_LEVEL_MIN || \
|
||||
cur_entry.compression_level > BKTR_COMPRESSION_LEVEL_MAX || !IS_ALIGNED(cur_entry.physical_offset, BKTR_COMPRESSION_PHYS_ALIGNMENT))))
|
||||
{
|
||||
LOG_DATA(&cur_entry, sizeof(BucketTreeCompressedStorageEntry), "Invalid Compressed Storage entry! (#1). Entry dump:");
|
||||
LOG_DATA_ERROR(&cur_entry, sizeof(BucketTreeCompressedStorageEntry), "Invalid Compressed Storage entry! (#1). Entry dump:");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -886,7 +886,7 @@ static bool bktrReadCompressedStorage(BucketTreeVisitor *visitor, void *out, u64
|
|||
/* Retrieve the next entry. */
|
||||
if (!bktrVisitorMoveNext(visitor))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve next Compressed Storage entry!");
|
||||
LOG_MSG_ERROR("Failed to retrieve next Compressed Storage entry!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -900,7 +900,7 @@ static bool bktrReadCompressedStorage(BucketTreeVisitor *visitor, void *out, u64
|
|||
(next_entry->compression_type == BucketTreeCompressedStorageCompressionType_LZ4 && (next_entry->compression_level < BKTR_COMPRESSION_LEVEL_MIN || \
|
||||
next_entry->compression_level > BKTR_COMPRESSION_LEVEL_MAX || !IS_ALIGNED(next_entry->physical_offset, BKTR_COMPRESSION_PHYS_ALIGNMENT))))
|
||||
{
|
||||
LOG_DATA(next_entry, sizeof(BucketTreeCompressedStorageEntry), "Invalid Compressed Storage entry! (#2). Entry dump:");
|
||||
LOG_DATA_ERROR(next_entry, sizeof(BucketTreeCompressedStorageEntry), "Invalid Compressed Storage entry! (#2). Entry dump:");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -917,7 +917,7 @@ static bool bktrReadCompressedStorage(BucketTreeVisitor *visitor, void *out, u64
|
|||
/* Verify next entry offset. */
|
||||
if (next_entry_offset <= cur_entry_offset || offset >= next_entry_offset)
|
||||
{
|
||||
LOG_MSG("Invalid virtual offset for the Compressed Storage's next entry! (0x%lX).", next_entry_offset);
|
||||
LOG_MSG_ERROR("Invalid virtual offset for the Compressed Storage's next entry! (0x%lX).", next_entry_offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -937,7 +937,7 @@ static bool bktrReadCompressedStorage(BucketTreeVisitor *visitor, void *out, u64
|
|||
bktrBucketInitializeSubStorageReadParams(¶ms, out, data_offset, read_size, 0, 0, false, ctx->storage_type);
|
||||
|
||||
success = bktrReadSubStorage(&(ctx->substorages[0]), ¶ms);
|
||||
if (!success) LOG_MSG("Failed to read 0x%lX-byte long chunk from offset 0x%lX in non-compressed entry!", read_size, data_offset);
|
||||
if (!success) LOG_MSG_ERROR("Failed to read 0x%lX-byte long chunk from offset 0x%lX in non-compressed entry!", read_size, data_offset);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -961,7 +961,7 @@ static bool bktrReadCompressedStorage(BucketTreeVisitor *visitor, void *out, u64
|
|||
buffer = calloc(1, buffer_size);
|
||||
if (!buffer)
|
||||
{
|
||||
LOG_MSG("Failed to allocate 0x%lX-byte long buffer for data decompression! (0x%lX).", buffer_size, decompressed_data_size);
|
||||
LOG_MSG_ERROR("Failed to allocate 0x%lX-byte long buffer for data decompression! (0x%lX).", buffer_size, decompressed_data_size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -972,7 +972,7 @@ static bool bktrReadCompressedStorage(BucketTreeVisitor *visitor, void *out, u64
|
|||
/* Read compressed LZ4 block. */
|
||||
if (!bktrReadSubStorage(&(ctx->substorages[0]), ¶ms))
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%lX-byte long compressed block from offset 0x%lX!", compressed_data_size, data_offset);
|
||||
LOG_MSG_ERROR("Failed to read 0x%lX-byte long compressed block from offset 0x%lX!", compressed_data_size, data_offset);
|
||||
free(buffer);
|
||||
break;
|
||||
}
|
||||
|
@ -981,7 +981,7 @@ static bool bktrReadCompressedStorage(BucketTreeVisitor *visitor, void *out, u64
|
|||
int lz4_res = 0;
|
||||
if ((lz4_res = LZ4_decompress_safe((char*)read_ptr, (char*)buffer, (int)compressed_data_size, (int)buffer_size)) != (int)decompressed_data_size)
|
||||
{
|
||||
LOG_MSG("Failed to decompress 0x%lX-byte long compressed block! (%d).", compressed_data_size, lz4_res);
|
||||
LOG_MSG_ERROR("Failed to decompress 0x%lX-byte long compressed block! (%d).", compressed_data_size, lz4_res);
|
||||
free(buffer);
|
||||
break;
|
||||
}
|
||||
|
@ -1007,7 +1007,7 @@ static bool bktrReadCompressedStorage(BucketTreeVisitor *visitor, void *out, u64
|
|||
success = (bktrReadCompressedStorage(visitor, out, compressed_block_size, offset) && \
|
||||
bktrReadCompressedStorage(visitor, (u8*)out + compressed_block_size, read_size - compressed_block_size, offset + compressed_block_size));
|
||||
|
||||
if (!success) LOG_MSG("Failed to read 0x%lX bytes block from multiple Compressed Storage entries at offset 0x%lX!", read_size, offset);
|
||||
if (!success) LOG_MSG_ERROR("Failed to read 0x%lX bytes block from multiple Compressed Storage entries at offset 0x%lX!", read_size, offset);
|
||||
}
|
||||
|
||||
end:
|
||||
|
@ -1018,7 +1018,7 @@ static bool bktrReadSubStorage(BucketTreeSubStorage *substorage, BucketTreeSubSt
|
|||
{
|
||||
if (!bktrIsValidSubstorage(substorage) || !params || !params->buffer || !params->size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1045,7 +1045,7 @@ static bool bktrReadSubStorage(BucketTreeSubStorage *substorage, BucketTreeSubSt
|
|||
success = bktrReadStorage(ctx, params->buffer, params->size, params->offset);
|
||||
}
|
||||
|
||||
if (!success) LOG_MSG("Failed to read 0x%lX-byte long chunk from offset 0x%lX!", params->size, params->offset);
|
||||
if (!success) LOG_MSG_ERROR("Failed to read 0x%lX-byte long chunk from offset 0x%lX!", params->size, params->offset);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -1077,7 +1077,7 @@ static bool bktrVerifyBucketInfo(NcaBucketInfo *bucket, u64 node_size, u64 entry
|
|||
if (out_node_storage_size) *out_node_storage_size = node_storage_size;
|
||||
if (out_entry_storage_size) *out_entry_storage_size = entry_storage_size;
|
||||
} else {
|
||||
LOG_MSG("Calculated table size exceeds the provided bucket's table size! (0x%lX > 0x%lX).", calc_table_size, bucket->size);
|
||||
LOG_MSG_ERROR("Calculated table size exceeds the provided bucket's table size! (0x%lX > 0x%lX).", calc_table_size, bucket->size);
|
||||
}
|
||||
|
||||
return success;
|
||||
|
@ -1091,7 +1091,7 @@ static bool bktrValidateTableOffsetNode(const BucketTreeTable *table, u64 node_s
|
|||
/* Verify offset node header. */
|
||||
if (!bktrVerifyNodeHeader(node_header, 0, node_size, sizeof(u64)))
|
||||
{
|
||||
LOG_MSG("Bucket Tree Offset Node header verification failed!");
|
||||
LOG_MSG_ERROR("Bucket Tree Offset Node header verification failed!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1104,7 +1104,7 @@ static bool bktrValidateTableOffsetNode(const BucketTreeTable *table, u64 node_s
|
|||
|
||||
if (start_offset > *bktrGetOffsetNodeBegin(offset_node) || start_offset >= end_offset || node_header->count != entry_set_count)
|
||||
{
|
||||
LOG_MSG("Invalid Bucket Tree Offset Node!");
|
||||
LOG_MSG_ERROR("Invalid Bucket Tree Offset Node!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1190,7 +1190,7 @@ static bool bktrFindStorageEntry(BucketTreeContext *ctx, u64 virtual_offset, Buc
|
|||
{
|
||||
if (!ctx || virtual_offset >= ctx->storage_table->offset_node.header.offset || !out_visitor)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1209,7 +1209,7 @@ static bool bktrFindStorageEntry(BucketTreeContext *ctx, u64 virtual_offset, Buc
|
|||
|
||||
if (!bktrGetTreeNodeEntryIndex(start_ptr, end_ptr, virtual_offset, &entry_set_index))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve Bucket Tree Node entry index for virtual offset 0x%lX! (#1).", virtual_offset);
|
||||
LOG_MSG_ERROR("Failed to retrieve Bucket Tree Node entry index for virtual offset 0x%lX! (#1).", virtual_offset);
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
|
@ -1218,7 +1218,7 @@ static bool bktrFindStorageEntry(BucketTreeContext *ctx, u64 virtual_offset, Buc
|
|||
|
||||
if (!bktrGetTreeNodeEntryIndex(start_ptr, end_ptr, virtual_offset, &entry_set_index))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve Bucket Tree Node entry index for virtual offset 0x%lX! (#2).", virtual_offset);
|
||||
LOG_MSG_ERROR("Failed to retrieve Bucket Tree Node entry index for virtual offset 0x%lX! (#2).", virtual_offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1227,7 +1227,7 @@ static bool bktrFindStorageEntry(BucketTreeContext *ctx, u64 virtual_offset, Buc
|
|||
u32 node_index = entry_set_index;
|
||||
if (node_index >= ctx->offset_count || !bktrFindEntrySet(ctx, &entry_set_index, virtual_offset, node_index))
|
||||
{
|
||||
LOG_MSG("Invalid L2 Bucket Tree Node index!");
|
||||
LOG_MSG_ERROR("Invalid L2 Bucket Tree Node index!");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1236,13 +1236,13 @@ static bool bktrFindStorageEntry(BucketTreeContext *ctx, u64 virtual_offset, Buc
|
|||
/* Validate the entry set index. */
|
||||
if (entry_set_index >= ctx->entry_set_count)
|
||||
{
|
||||
LOG_MSG("Invalid Bucket Tree Node offset!");
|
||||
LOG_MSG_ERROR("Invalid Bucket Tree Node offset!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Find the entry. */
|
||||
success = bktrFindEntry(ctx, out_visitor, virtual_offset, entry_set_index);
|
||||
if (!success) LOG_MSG("Failed to retrieve storage entry!");
|
||||
if (!success) LOG_MSG_ERROR("Failed to retrieve storage entry!");
|
||||
|
||||
end:
|
||||
return success;
|
||||
|
@ -1252,7 +1252,7 @@ static bool bktrGetTreeNodeEntryIndex(const u64 *start_ptr, const u64 *end_ptr,
|
|||
{
|
||||
if (!start_ptr || !end_ptr || start_ptr >= end_ptr || !out_index)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1284,7 +1284,7 @@ static bool bktrGetEntryNodeEntryIndex(const BucketTreeNodeHeader *node_header,
|
|||
{
|
||||
if (!node_header || !out_index)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1296,7 +1296,7 @@ static bool bktrGetEntryNodeEntryIndex(const BucketTreeNodeHeader *node_header,
|
|||
/* Validate index. */
|
||||
if (storage_node.index == UINT32_MAX)
|
||||
{
|
||||
LOG_MSG("Unable to find index for virtual offset 0x%lX!", virtual_offset);
|
||||
LOG_MSG_ERROR("Unable to find index for virtual offset 0x%lX!", virtual_offset);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1312,7 +1312,7 @@ static bool bktrFindEntrySet(BucketTreeContext *ctx, u32 *out_index, u64 virtual
|
|||
const BucketTreeNodeHeader *node_header = bktrGetTreeNodeHeader(ctx, node_index);
|
||||
if (!node_header)
|
||||
{
|
||||
LOG_MSG("Failed to retrieve offset node header at index 0x%X!", node_index);
|
||||
LOG_MSG_ERROR("Failed to retrieve offset node header at index 0x%X!", node_index);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1320,7 +1320,7 @@ static bool bktrFindEntrySet(BucketTreeContext *ctx, u32 *out_index, u64 virtual
|
|||
u32 offset_index = 0;
|
||||
if (!bktrGetEntryNodeEntryIndex(node_header, sizeof(u64), virtual_offset, &offset_index))
|
||||
{
|
||||
LOG_MSG("Failed to get offset node entry index!");
|
||||
LOG_MSG_ERROR("Failed to get offset node entry index!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1338,7 +1338,7 @@ static const BucketTreeNodeHeader *bktrGetTreeNodeHeader(BucketTreeContext *ctx,
|
|||
|
||||
if ((node_offset + BKTR_NODE_HEADER_SIZE) > ctx->node_storage_size)
|
||||
{
|
||||
LOG_MSG("Invalid Bucket Tree Offset Node offset!");
|
||||
LOG_MSG_ERROR("Invalid Bucket Tree Offset Node offset!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1348,7 +1348,7 @@ static const BucketTreeNodeHeader *bktrGetTreeNodeHeader(BucketTreeContext *ctx,
|
|||
/* Validate offset node header. */
|
||||
if (!bktrVerifyNodeHeader(node_header, node_index, node_size, sizeof(u64)))
|
||||
{
|
||||
LOG_MSG("Bucket Tree Offset Node header verification failed!");
|
||||
LOG_MSG_ERROR("Bucket Tree Offset Node header verification failed!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1366,7 +1366,7 @@ static bool bktrFindEntry(BucketTreeContext *ctx, BucketTreeVisitor *out_visitor
|
|||
const BucketTreeNodeHeader *entry_set_header = bktrGetEntryNodeHeader(ctx, entry_set_index);
|
||||
if (!entry_set_header)
|
||||
{
|
||||
LOG_MSG("Failed to retrieve entry node header at index 0x%X!", entry_set_index);
|
||||
LOG_MSG_ERROR("Failed to retrieve entry node header at index 0x%X!", entry_set_index);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1379,7 +1379,7 @@ static bool bktrFindEntry(BucketTreeContext *ctx, BucketTreeVisitor *out_visitor
|
|||
u32 entry_index = 0;
|
||||
if (!bktrGetEntryNodeEntryIndex(entry_set_header, entry_size, virtual_offset, &entry_index))
|
||||
{
|
||||
LOG_MSG("Failed to get entry node entry index!");
|
||||
LOG_MSG_ERROR("Failed to get entry node entry index!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1387,7 +1387,7 @@ static bool bktrFindEntry(BucketTreeContext *ctx, BucketTreeVisitor *out_visitor
|
|||
u64 entry_offset = bktrGetEntryNodeEntryOffset(entry_set_offset, entry_size, entry_index);
|
||||
if ((entry_offset + entry_size) > (ctx->node_storage_size + ctx->entry_storage_size))
|
||||
{
|
||||
LOG_MSG("Invalid Bucket Tree Entry Node entry offset!");
|
||||
LOG_MSG_ERROR("Invalid Bucket Tree Entry Node entry offset!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1411,7 +1411,7 @@ static const BucketTreeNodeHeader *bktrGetEntryNodeHeader(BucketTreeContext *ctx
|
|||
|
||||
if ((entry_set_offset + BKTR_NODE_HEADER_SIZE) > (ctx->node_storage_size + ctx->entry_storage_size))
|
||||
{
|
||||
LOG_MSG("Invalid Bucket Tree Entry Node offset!");
|
||||
LOG_MSG_ERROR("Invalid Bucket Tree Entry Node offset!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1421,7 +1421,7 @@ static const BucketTreeNodeHeader *bktrGetEntryNodeHeader(BucketTreeContext *ctx
|
|||
/* Validate entry node header. */
|
||||
if (!bktrVerifyNodeHeader(entry_set_header, entry_set_index, entry_set_size, entry_size))
|
||||
{
|
||||
LOG_MSG("Bucket Tree Entry Node header verification failed!");
|
||||
LOG_MSG_ERROR("Bucket Tree Entry Node header verification failed!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1525,7 +1525,7 @@ static bool bktrVisitorMoveNext(BucketTreeVisitor *visitor)
|
|||
{
|
||||
if (!bktrVisitorIsValid(visitor))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1543,7 +1543,7 @@ static bool bktrVisitorMoveNext(BucketTreeVisitor *visitor)
|
|||
const u32 entry_set_index = (entry_set->header.index + 1);
|
||||
if (entry_set_index >= ctx->entry_set_count)
|
||||
{
|
||||
LOG_MSG("Error: attempting to move visitor into non-existing Bucket Tree Entry Node!");
|
||||
LOG_MSG_ERROR("Error: attempting to move visitor into non-existing Bucket Tree Entry Node!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1554,7 +1554,7 @@ static bool bktrVisitorMoveNext(BucketTreeVisitor *visitor)
|
|||
|
||||
if ((entry_set_offset + sizeof(BucketTreeEntrySetHeader)) > (ctx->node_storage_size + ctx->entry_storage_size))
|
||||
{
|
||||
LOG_MSG("Invalid Bucket Tree Entry Node offset!");
|
||||
LOG_MSG_ERROR("Invalid Bucket Tree Entry Node offset!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1564,7 +1564,7 @@ static bool bktrVisitorMoveNext(BucketTreeVisitor *visitor)
|
|||
if (!bktrVerifyNodeHeader(&(entry_set->header), entry_set_index, entry_set_size, ctx->entry_size) || entry_set->start != end_offset || \
|
||||
entry_set->start >= entry_set->header.offset)
|
||||
{
|
||||
LOG_MSG("Bucket Tree Entry Node header verification failed!");
|
||||
LOG_MSG_ERROR("Bucket Tree Entry Node header verification failed!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1578,7 +1578,7 @@ static bool bktrVisitorMoveNext(BucketTreeVisitor *visitor)
|
|||
|
||||
if ((entry_offset + entry_size) > (ctx->node_storage_size + ctx->entry_storage_size))
|
||||
{
|
||||
LOG_MSG("Invalid Bucket Tree Entry Node entry offset!");
|
||||
LOG_MSG_ERROR("Invalid Bucket Tree Entry Node entry offset!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1597,7 +1597,7 @@ static bool bktrVisitorMovePrevious(BucketTreeVisitor *visitor)
|
|||
{
|
||||
if (!bktrVisitorIsValid(visitor))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1614,7 +1614,7 @@ static bool bktrVisitorMovePrevious(BucketTreeVisitor *visitor)
|
|||
/* We have reached the start of this entry node. Let's try to retrieve the last entry from the previous one. */
|
||||
if (!entry_set->header.index)
|
||||
{
|
||||
LOG_MSG("Error: attempting to move visitor into non-existing Bucket Tree Entry Node!");
|
||||
LOG_MSG_ERROR("Error: attempting to move visitor into non-existing Bucket Tree Entry Node!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1626,7 +1626,7 @@ static bool bktrVisitorMovePrevious(BucketTreeVisitor *visitor)
|
|||
|
||||
if ((entry_set_offset + sizeof(BucketTreeEntrySetHeader)) > (ctx->node_storage_size + ctx->entry_storage_size))
|
||||
{
|
||||
LOG_MSG("Invalid Bucket Tree Entry Node offset!");
|
||||
LOG_MSG_ERROR("Invalid Bucket Tree Entry Node offset!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1636,7 +1636,7 @@ static bool bktrVisitorMovePrevious(BucketTreeVisitor *visitor)
|
|||
if (!bktrVerifyNodeHeader(&(entry_set->header), entry_set_index, entry_set_size, ctx->entry_size) || entry_set->header.offset != start_offset || \
|
||||
entry_set->start >= entry_set->header.offset)
|
||||
{
|
||||
LOG_MSG("Bucket Tree Entry Node header verification failed!");
|
||||
LOG_MSG_ERROR("Bucket Tree Entry Node header verification failed!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1652,7 +1652,7 @@ static bool bktrVisitorMovePrevious(BucketTreeVisitor *visitor)
|
|||
|
||||
if ((entry_offset + entry_size) > (ctx->node_storage_size + ctx->entry_storage_size))
|
||||
{
|
||||
LOG_MSG("Invalid Bucket Tree Entry Node entry offset!");
|
||||
LOG_MSG_ERROR("Invalid Bucket Tree Entry Node entry offset!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ bool certRetrieveCertificateByName(Certificate *dst, const char *name)
|
|||
{
|
||||
if (!dst || !name || !*name)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ bool certRetrieveCertificateChainBySignatureIssuer(CertificateChain *dst, const
|
|||
{
|
||||
if (!dst || !issuer || strncmp(issuer, "Root-", 5) != 0)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ u8 *certGenerateRawCertificateChainBySignatureIssuer(const char *issuer, u64 *ou
|
|||
{
|
||||
if (!issuer || !*issuer || !out_size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ u8 *certGenerateRawCertificateChainBySignatureIssuer(const char *issuer, u64 *ou
|
|||
|
||||
if (!certRetrieveCertificateChainBySignatureIssuer(&chain, issuer))
|
||||
{
|
||||
LOG_MSG("Error retrieving certificate chain for \"%s\"!", issuer);
|
||||
LOG_MSG_ERROR("Error retrieving certificate chain for \"%s\"!", issuer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ u8 *certGenerateRawCertificateChainBySignatureIssuer(const char *issuer, u64 *ou
|
|||
raw_chain = malloc(raw_chain_size);
|
||||
if (!raw_chain)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for raw \"%s\" certificate chain! (0x%lX).", issuer, raw_chain_size);
|
||||
LOG_MSG_ERROR("Unable to allocate memory for raw \"%s\" certificate chain! (0x%lX).", issuer, raw_chain_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ u8 *certRetrieveRawCertificateChainFromGameCardByRightsId(const FsRightsId *id,
|
|||
{
|
||||
if (!id || !out_size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -143,26 +143,26 @@ u8 *certRetrieveRawCertificateChainFromGameCardByRightsId(const FsRightsId *id,
|
|||
|
||||
if (!gamecardGetHashFileSystemEntryInfoByName(GameCardHashFileSystemPartitionType_Secure, raw_chain_filename, &raw_chain_offset, &raw_chain_size))
|
||||
{
|
||||
LOG_MSG("Error retrieving offset and size for \"%s\" entry in secure hash FS partition!", raw_chain_filename);
|
||||
LOG_MSG_ERROR("Error retrieving offset and size for \"%s\" entry in secure hash FS partition!", raw_chain_filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (raw_chain_size < SIGNED_CERT_MIN_SIZE)
|
||||
{
|
||||
LOG_MSG("Invalid size for \"%s\"! (0x%lX).", raw_chain_filename, raw_chain_size);
|
||||
LOG_MSG_ERROR("Invalid size for \"%s\"! (0x%lX).", raw_chain_filename, raw_chain_size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
raw_chain = malloc(raw_chain_size);
|
||||
if (!raw_chain)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for raw \"%s\" certificate chain! (0x%lX).", raw_chain_filename, raw_chain_size);
|
||||
LOG_MSG_ERROR("Unable to allocate memory for raw \"%s\" certificate chain! (0x%lX).", raw_chain_filename, raw_chain_size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!gamecardReadStorage(raw_chain, raw_chain_size, raw_chain_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read \"%s\" data from the inserted gamecard!", raw_chain_filename);
|
||||
LOG_MSG_ERROR("Failed to read \"%s\" data from the inserted gamecard!", raw_chain_filename);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ static bool certOpenEsCertSaveFile(void)
|
|||
g_esCertSaveCtx = save_open_savefile(CERT_SAVEFILE_PATH, 0);
|
||||
if (!g_esCertSaveCtx)
|
||||
{
|
||||
LOG_MSG("Failed to open ES certificate system savefile!");
|
||||
LOG_MSG_ERROR("Failed to open ES certificate system savefile!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ static bool _certRetrieveCertificateByName(Certificate *dst, const char *name)
|
|||
{
|
||||
if (!g_esCertSaveCtx)
|
||||
{
|
||||
LOG_MSG("ES certificate savefile not opened!");
|
||||
LOG_MSG_ERROR("ES certificate savefile not opened!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -216,13 +216,13 @@ static bool _certRetrieveCertificateByName(Certificate *dst, const char *name)
|
|||
|
||||
if (!save_get_fat_storage_from_file_entry_by_path(g_esCertSaveCtx, cert_path, &fat_storage, &cert_size))
|
||||
{
|
||||
LOG_MSG("Failed to locate certificate \"%s\" in ES certificate system save!", name);
|
||||
LOG_MSG_ERROR("Failed to locate certificate \"%s\" in ES certificate system save!", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cert_size < SIGNED_CERT_MIN_SIZE || cert_size > SIGNED_CERT_MAX_SIZE)
|
||||
{
|
||||
LOG_MSG("Invalid size for certificate \"%s\"! (0x%lX).", name, cert_size);
|
||||
LOG_MSG_ERROR("Invalid size for certificate \"%s\"! (0x%lX).", name, cert_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -231,14 +231,14 @@ static bool _certRetrieveCertificateByName(Certificate *dst, const char *name)
|
|||
u64 br = save_allocation_table_storage_read(&fat_storage, dst->data, 0, dst->size);
|
||||
if (br != dst->size)
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%lX bytes from certificate \"%s\"! Read 0x%lX bytes.", dst->size, name, br);
|
||||
LOG_MSG_ERROR("Failed to read 0x%lX bytes from certificate \"%s\"! Read 0x%lX bytes.", dst->size, name, br);
|
||||
return false;
|
||||
}
|
||||
|
||||
dst->type = certGetCertificateType(dst->data, dst->size);
|
||||
if (dst->type == CertType_None)
|
||||
{
|
||||
LOG_MSG("Invalid certificate type for \"%s\"!", name);
|
||||
LOG_MSG_ERROR("Invalid certificate type for \"%s\"!", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -254,13 +254,13 @@ static u8 certGetCertificateType(void *data, u64 data_size)
|
|||
|
||||
if (!data || data_size < SIGNED_CERT_MIN_SIZE || data_size > SIGNED_CERT_MAX_SIZE)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return type;
|
||||
}
|
||||
|
||||
if (!(cert_common_block = certGetCommonBlock(data)) || !(signed_cert_size = certGetSignedCertificateSize(data)) || signed_cert_size > data_size)
|
||||
{
|
||||
LOG_MSG("Input buffer doesn't hold a valid signed certificate!");
|
||||
LOG_MSG_ERROR("Input buffer doesn't hold a valid signed certificate!");
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ static bool _certRetrieveCertificateChainBySignatureIssuer(CertificateChain *dst
|
|||
{
|
||||
if (!g_esCertSaveCtx)
|
||||
{
|
||||
LOG_MSG("ES certificate savefile not opened!");
|
||||
LOG_MSG_ERROR("ES certificate savefile not opened!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -306,14 +306,14 @@ static bool _certRetrieveCertificateChainBySignatureIssuer(CertificateChain *dst
|
|||
dst->count = certGetCertificateCountInSignatureIssuer(issuer);
|
||||
if (!dst->count)
|
||||
{
|
||||
LOG_MSG("Invalid signature issuer string!");
|
||||
LOG_MSG_ERROR("Invalid signature issuer string!");
|
||||
return false;
|
||||
}
|
||||
|
||||
dst->certs = calloc(dst->count, sizeof(Certificate));
|
||||
if (!dst->certs)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for the certificate chain! (0x%lX).", dst->count * sizeof(Certificate));
|
||||
LOG_MSG_ERROR("Unable to allocate memory for the certificate chain! (0x%lX).", dst->count * sizeof(Certificate));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ static bool _certRetrieveCertificateChainBySignatureIssuer(CertificateChain *dst
|
|||
{
|
||||
if (!_certRetrieveCertificateByName(&(dst->certs[i]), pch))
|
||||
{
|
||||
LOG_MSG("Unable to retrieve certificate \"%s\"!", pch);
|
||||
LOG_MSG_ERROR("Unable to retrieve certificate \"%s\"!", pch);
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ bool cnmtInitializeContext(ContentMetaContext *out, NcaContext *nca_ctx)
|
|||
(nca_ctx->storage_id != NcmStorageId_GameCard && !nca_ctx->ncm_storage) || (nca_ctx->storage_id == NcmStorageId_GameCard && !nca_ctx->gamecard_offset) || \
|
||||
nca_ctx->header.content_type != NcaContentType_Meta || nca_ctx->content_type_ctx || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -67,14 +67,14 @@ bool cnmtInitializeContext(ContentMetaContext *out, NcaContext *nca_ctx)
|
|||
/* Initialize Partition FS context. */
|
||||
if (!pfsInitializeContext(&(out->pfs_ctx), &(nca_ctx->fs_ctx[0])))
|
||||
{
|
||||
LOG_MSG("Failed to initialize Partition FS context!");
|
||||
LOG_MSG_ERROR("Failed to initialize Partition FS context!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Get Partition FS entry count. Edge case, we should never trigger this. */
|
||||
if (!(pfs_entry_count = pfsGetEntryCount(&(out->pfs_ctx))))
|
||||
{
|
||||
LOG_MSG("Partition FS has no file entries!");
|
||||
LOG_MSG_ERROR("Partition FS has no file entries!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -87,11 +87,11 @@ bool cnmtInitializeContext(ContentMetaContext *out, NcaContext *nca_ctx)
|
|||
|
||||
if (i >= pfs_entry_count)
|
||||
{
|
||||
LOG_MSG("'.cnmt' entry unavailable in Partition FS!");
|
||||
LOG_MSG_ERROR("'.cnmt' entry unavailable in Partition FS!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
//LOG_MSG("Found '.cnmt' entry \"%s\" in Meta NCA \"%s\".", out->cnmt_filename, nca_ctx->content_id_str);
|
||||
LOG_MSG_INFO("Found '.cnmt' entry \"%s\" in Meta NCA \"%s\".", out->cnmt_filename, nca_ctx->content_id_str);
|
||||
|
||||
/* Retrieve content meta type and title ID from the '.cnmt' filename. */
|
||||
if (!cnmtGetContentMetaTypeAndTitleIdFromFileName(out->cnmt_filename, cnmt_filename_len, &content_meta_type, &title_id)) goto end;
|
||||
|
@ -99,14 +99,14 @@ bool cnmtInitializeContext(ContentMetaContext *out, NcaContext *nca_ctx)
|
|||
/* Get '.cnmt' file entry. */
|
||||
if (!(out->pfs_entry = pfsGetEntryByIndex(&(out->pfs_ctx), i)))
|
||||
{
|
||||
LOG_MSG("Failed to get '.cnmt' entry from Partition FS!");
|
||||
LOG_MSG_ERROR("Failed to get '.cnmt' entry from Partition FS!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Check raw CNMT size. */
|
||||
if (!out->pfs_entry->size)
|
||||
{
|
||||
LOG_DATA(out->pfs_entry, sizeof(PartitionFileSystemEntry), "Invalid raw CNMT size! Partition FS entry dump:");
|
||||
LOG_DATA_ERROR(out->pfs_entry, sizeof(PartitionFileSystemEntry), "Invalid raw CNMT size! Partition FS entry dump:");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -114,14 +114,14 @@ bool cnmtInitializeContext(ContentMetaContext *out, NcaContext *nca_ctx)
|
|||
out->raw_data_size = out->pfs_entry->size;
|
||||
if (!(out->raw_data = malloc(out->raw_data_size)))
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for the raw CNMT data!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for the raw CNMT data!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Read raw CNMT data into memory buffer. */
|
||||
if (!pfsReadEntryData(&(out->pfs_ctx), out->pfs_entry, out->raw_data, out->raw_data_size, 0))
|
||||
{
|
||||
LOG_MSG("Failed to read raw CNMT data!");
|
||||
LOG_MSG_ERROR("Failed to read raw CNMT data!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -134,21 +134,21 @@ bool cnmtInitializeContext(ContentMetaContext *out, NcaContext *nca_ctx)
|
|||
|
||||
if (out->packaged_header->title_id != title_id)
|
||||
{
|
||||
LOG_MSG("CNMT title ID mismatch! (%016lX != %016lX).", out->packaged_header->title_id, title_id);
|
||||
LOG_MSG_ERROR("CNMT title ID mismatch! (%016lX != %016lX).", out->packaged_header->title_id, title_id);
|
||||
dump_packaged_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out->packaged_header->content_meta_type != content_meta_type)
|
||||
{
|
||||
LOG_MSG("CNMT content meta type mismatch! (0x%02X != 0x%02X).", out->packaged_header->content_meta_type, content_meta_type);
|
||||
LOG_MSG_ERROR("CNMT content meta type mismatch! (0x%02X != 0x%02X).", out->packaged_header->content_meta_type, content_meta_type);
|
||||
dump_packaged_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!out->packaged_header->content_count && out->packaged_header->content_meta_type != NcmContentMetaType_SystemUpdate)
|
||||
{
|
||||
LOG_MSG("Invalid content count!");
|
||||
LOG_MSG_ERROR("Invalid content count!");
|
||||
dump_packaged_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ bool cnmtInitializeContext(ContentMetaContext *out, NcaContext *nca_ctx)
|
|||
if ((out->packaged_header->content_meta_type == NcmContentMetaType_SystemUpdate && !out->packaged_header->content_meta_count) || \
|
||||
(out->packaged_header->content_meta_type != NcmContentMetaType_SystemUpdate && out->packaged_header->content_meta_count))
|
||||
{
|
||||
LOG_MSG("Invalid content meta count!");
|
||||
LOG_MSG_ERROR("Invalid content meta count!");
|
||||
dump_packaged_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -197,14 +197,14 @@ bool cnmtInitializeContext(ContentMetaContext *out, NcaContext *nca_ctx)
|
|||
|
||||
if (invalid_ext_header_size)
|
||||
{
|
||||
LOG_MSG("Invalid extended header size!");
|
||||
LOG_MSG_ERROR("Invalid extended header size!");
|
||||
dump_packaged_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (invalid_ext_data_size)
|
||||
{
|
||||
LOG_DATA(out->extended_header, out->packaged_header->extended_header_size, "Invalid extended data size! CNMT Extended Header dump:");
|
||||
LOG_DATA_ERROR(out->extended_header, out->packaged_header->extended_header_size, "Invalid extended data size! CNMT Extended Header dump:");
|
||||
dump_packaged_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ bool cnmtInitializeContext(ContentMetaContext *out, NcaContext *nca_ctx)
|
|||
/* Safety check: verify raw CNMT size. */
|
||||
if (cur_offset != out->raw_data_size)
|
||||
{
|
||||
LOG_MSG("Raw CNMT size mismatch! (0x%lX != 0x%lX).", cur_offset, out->raw_data_size);
|
||||
LOG_MSG_ERROR("Raw CNMT size mismatch! (0x%lX != 0x%lX).", cur_offset, out->raw_data_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -254,8 +254,7 @@ bool cnmtInitializeContext(ContentMetaContext *out, NcaContext *nca_ctx)
|
|||
end:
|
||||
if (!success)
|
||||
{
|
||||
if (dump_packaged_header) LOG_DATA(out->packaged_header, sizeof(ContentMetaPackagedContentMetaHeader), "CNMT Packaged Header dump:");
|
||||
|
||||
if (dump_packaged_header) LOG_DATA_DEBUG(out->packaged_header, sizeof(ContentMetaPackagedContentMetaHeader), "CNMT Packaged Header dump:");
|
||||
cnmtFreeContext(out);
|
||||
}
|
||||
|
||||
|
@ -266,7 +265,7 @@ bool cnmtUpdateContentInfo(ContentMetaContext *cnmt_ctx, NcaContext *nca_ctx)
|
|||
{
|
||||
if (!cnmtIsValidContext(cnmt_ctx) || !nca_ctx || !*(nca_ctx->content_id_str) || !*(nca_ctx->hash_str) || nca_ctx->content_type > NcmContentType_DeltaFragment || !nca_ctx->content_size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -288,14 +287,14 @@ bool cnmtUpdateContentInfo(ContentMetaContext *cnmt_ctx, NcaContext *nca_ctx)
|
|||
/* Jackpot. Copy content ID and hash to our raw CNMT. */
|
||||
memcpy(packaged_content_info->hash, nca_ctx->hash, sizeof(nca_ctx->hash));
|
||||
memcpy(&(content_info->content_id), &(nca_ctx->content_id), sizeof(NcmContentId));
|
||||
LOG_MSG("Updated CNMT content record #%u (title ID %016lX, size 0x%lX, type 0x%02X, ID offset 0x%02X).", i, cnmt_ctx->packaged_header->title_id, content_size, content_info->content_type, \
|
||||
content_info->id_offset);
|
||||
LOG_MSG_INFO("Updated CNMT content record #%u (title ID %016lX, size 0x%lX, type 0x%02X, ID offset 0x%02X).", i, cnmt_ctx->packaged_header->title_id, content_size, content_info->content_type, \
|
||||
content_info->id_offset);
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) LOG_MSG("Unable to find CNMT content info entry for \"%s\" NCA! (Title ID %016lX, size 0x%lX, type 0x%02X, ID offset 0x%02X).", nca_ctx->content_id_str, \
|
||||
if (!success) LOG_MSG_ERROR("Unable to find CNMT content info entry for \"%s\" NCA! (Title ID %016lX, size 0x%lX, type 0x%02X, ID offset 0x%02X).", nca_ctx->content_id_str, \
|
||||
cnmt_ctx->packaged_header->title_id, nca_ctx->content_size, nca_ctx->content_type, nca_ctx->id_offset);
|
||||
|
||||
return success;
|
||||
|
@ -305,7 +304,7 @@ bool cnmtGenerateNcaPatch(ContentMetaContext *cnmt_ctx)
|
|||
{
|
||||
if (!cnmtIsValidContext(cnmt_ctx))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -314,14 +313,14 @@ bool cnmtGenerateNcaPatch(ContentMetaContext *cnmt_ctx)
|
|||
sha256CalculateHash(cnmt_hash, cnmt_ctx->raw_data, cnmt_ctx->raw_data_size);
|
||||
if (!memcmp(cnmt_hash, cnmt_ctx->raw_data_hash, sizeof(cnmt_hash)))
|
||||
{
|
||||
LOG_MSG("Skipping CNMT patching - no content records have been changed.");
|
||||
LOG_MSG_INFO("Skipping CNMT patching - no content records have been changed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Generate Partition FS entry patch. */
|
||||
if (!pfsGenerateEntryPatch(&(cnmt_ctx->pfs_ctx), cnmt_ctx->pfs_entry, cnmt_ctx->raw_data, cnmt_ctx->raw_data_size, 0, &(cnmt_ctx->nca_patch)))
|
||||
{
|
||||
LOG_MSG("Failed to generate Partition FS entry patch!");
|
||||
LOG_MSG_ERROR("Failed to generate Partition FS entry patch!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -346,7 +345,7 @@ void cnmtWriteNcaPatch(ContentMetaContext *cnmt_ctx, void *buf, u64 buf_size, u6
|
|||
if (nca_patch->written)
|
||||
{
|
||||
nca_ctx->content_type_ctx_patch = false;
|
||||
LOG_MSG("CNMT Partition FS entry patch successfully written to NCA \"%s\"!", nca_ctx->content_id_str);
|
||||
LOG_MSG_INFO("CNMT Partition FS entry patch successfully written to NCA \"%s\"!", nca_ctx->content_id_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -354,7 +353,7 @@ bool cnmtGenerateAuthoringToolXml(ContentMetaContext *cnmt_ctx, NcaContext *nca_
|
|||
{
|
||||
if (!cnmtIsValidContext(cnmt_ctx) || !nca_ctx || !nca_ctx_count || nca_ctx_count > ((u32)cnmt_ctx->packaged_header->content_count + 1))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -418,7 +417,7 @@ bool cnmtGenerateAuthoringToolXml(ContentMetaContext *cnmt_ctx, NcaContext *nca_
|
|||
|
||||
if (invalid_nca)
|
||||
{
|
||||
LOG_MSG("NCA \"%s\" isn't referenced by this CNMT!", cur_nca_ctx->content_id_str);
|
||||
LOG_MSG_ERROR("NCA \"%s\" isn't referenced by this CNMT!", cur_nca_ctx->content_id_str);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -483,7 +482,7 @@ end:
|
|||
if (!success)
|
||||
{
|
||||
if (xml_buf) free(xml_buf);
|
||||
LOG_MSG("Failed to generate CNMT AuthoringTool XML!");
|
||||
LOG_MSG_ERROR("Failed to generate CNMT AuthoringTool XML!");
|
||||
}
|
||||
|
||||
return success;
|
||||
|
@ -493,7 +492,7 @@ static bool cnmtGetContentMetaTypeAndTitleIdFromFileName(const char *cnmt_filena
|
|||
{
|
||||
if (!cnmt_filename || cnmt_filename_len < CNMT_MINIMUM_FILENAME_LENGTH || !out_content_meta_type || !out_title_id)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -506,7 +505,7 @@ static bool cnmtGetContentMetaTypeAndTitleIdFromFileName(const char *cnmt_filena
|
|||
|
||||
if (!pch1 || !(content_meta_type_str_len = (pch1 - cnmt_filename)) || (pch2 - ++pch1) != 16)
|
||||
{
|
||||
LOG_MSG("Invalid '.cnmt' filename in Partition FS! (\"%s\").", cnmt_filename);
|
||||
LOG_MSG_ERROR("Invalid '.cnmt' filename in Partition FS! (\"%s\").", cnmt_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -528,13 +527,13 @@ static bool cnmtGetContentMetaTypeAndTitleIdFromFileName(const char *cnmt_filena
|
|||
|
||||
if (i > NcmContentMetaType_Delta)
|
||||
{
|
||||
LOG_MSG("Invalid content meta type \"%.*s\" in '.cnmt' filename! (\"%s\").", (int)content_meta_type_str_len, cnmt_filename, cnmt_filename);
|
||||
LOG_MSG_ERROR("Invalid content meta type \"%.*s\" in '.cnmt' filename! (\"%s\").", (int)content_meta_type_str_len, cnmt_filename, cnmt_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(*out_title_id = strtoull(pch1, NULL, 16)))
|
||||
{
|
||||
LOG_MSG("Invalid title ID in '.cnmt' filename! (\"%s\").", cnmt_filename);
|
||||
LOG_MSG_ERROR("Invalid title ID in '.cnmt' filename! (\"%s\").", cnmt_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ bool configInitialize(void)
|
|||
/* Parse JSON config. */
|
||||
if (!configParseConfigJson())
|
||||
{
|
||||
LOG_MSG("Failed to parse JSON configuration!");
|
||||
LOG_MSG_ERROR("Failed to parse JSON configuration!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -122,20 +122,18 @@ static bool configParseConfigJson(void)
|
|||
|
||||
/* Read config JSON. */
|
||||
g_configJson = json_object_from_file(CONFIG_PATH);
|
||||
if (!g_configJson)
|
||||
if (g_configJson)
|
||||
{
|
||||
/* Validate configuration. */
|
||||
ret = configValidateJsonRootObject(g_configJson);
|
||||
use_default_config = !ret;
|
||||
} else {
|
||||
jsonLogLastError();
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Validate configuration. */
|
||||
ret = configValidateJsonRootObject(g_configJson);
|
||||
use_default_config = !ret;
|
||||
|
||||
end:
|
||||
if (use_default_config)
|
||||
{
|
||||
LOG_MSG("Loading default configuration.");
|
||||
LOG_MSG_INFO("Loading default configuration.");
|
||||
|
||||
/* Free config JSON. */
|
||||
configFreeConfigJson();
|
||||
|
@ -151,6 +149,8 @@ end:
|
|||
}
|
||||
}
|
||||
|
||||
if (!ret) LOG_MSG_ERROR("Failed to parse both current and default JSON configuration files!");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ bool gamecardInitialize(void)
|
|||
g_gameCardReadBuf = malloc(GAMECARD_READ_BUFFER_SIZE);
|
||||
if (!g_gameCardReadBuf)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for the gamecard read buffer!");
|
||||
LOG_MSG_ERROR("Unable to allocate memory for the gamecard read buffer!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ bool gamecardInitialize(void)
|
|||
rc = fsOpenDeviceOperator(&g_deviceOperator);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("fsOpenDeviceOperator failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("fsOpenDeviceOperator failed! (0x%X).", rc);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ bool gamecardInitialize(void)
|
|||
rc = fsOpenGameCardDetectionEventNotifier(&g_gameCardEventNotifier);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("fsOpenGameCardDetectionEventNotifier failed! (0x%08X)", rc);
|
||||
LOG_MSG_ERROR("fsOpenGameCardDetectionEventNotifier failed! (0x%X)", rc);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ bool gamecardInitialize(void)
|
|||
rc = fsEventNotifierGetEventHandle(&g_gameCardEventNotifier, &g_gameCardKernelEvent, true);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("fsEventNotifierGetEventHandle failed! (0x%08X)", rc);
|
||||
LOG_MSG_ERROR("fsEventNotifierGetEventHandle failed! (0x%X)", rc);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ bool gamecardGetIdSet(FsGameCardIdSet *out)
|
|||
if (!g_gameCardInterfaceInit || g_gameCardStatus != GameCardStatus_InsertedAndInfoLoaded || !out) break;
|
||||
|
||||
Result rc = fsDeviceOperatorGetGameCardIdSet(&g_deviceOperator, out);
|
||||
if (R_FAILED(rc)) LOG_MSG("fsDeviceOperatorGetGameCardIdSet failed! (0x%08X)", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("fsDeviceOperatorGetGameCardIdSet failed! (0x%X)", rc);
|
||||
|
||||
ret = R_SUCCEEDED(rc);
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ bool gamecardGetCertificate(FsGameCardCertificate *out)
|
|||
|
||||
/* Read the gamecard certificate using the official IPC call. */
|
||||
Result rc = fsDeviceOperatorGetGameCardDeviceCertificate(&g_deviceOperator, &g_gameCardHandle, out);
|
||||
if (R_FAILED(rc)) LOG_MSG("fsDeviceOperatorGetGameCardDeviceCertificate failed! (0x%08X)", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("fsDeviceOperatorGetGameCardDeviceCertificate failed! (0x%X)", rc);
|
||||
|
||||
ret = R_SUCCEEDED(rc);
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ bool gamecardGetBundledFirmwareUpdateVersion(Version *out)
|
|||
u32 update_version = 0;
|
||||
|
||||
Result rc = fsDeviceOperatorUpdatePartitionInfo(&g_deviceOperator, &g_gameCardHandle, &update_version, &update_id);
|
||||
if (R_FAILED(rc)) LOG_MSG("fsDeviceOperatorUpdatePartitionInfo failed! (0x%08X)", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("fsDeviceOperatorUpdatePartitionInfo failed! (0x%X)", rc);
|
||||
|
||||
ret = (R_SUCCEEDED(rc) && update_id == GAMECARD_UPDATE_TID);
|
||||
if (ret) out->value = update_version;
|
||||
|
@ -459,7 +459,7 @@ bool gamecardGetHashFileSystemContext(u8 hfs_partition_type, HashFileSystemConte
|
|||
{
|
||||
if (!hfs_partition_type || hfs_partition_type >= GameCardHashFileSystemPartitionType_Count || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -478,7 +478,7 @@ bool gamecardGetHashFileSystemContext(u8 hfs_partition_type, HashFileSystemConte
|
|||
out->name = strdup(fs_ctx->name);
|
||||
if (!out->name)
|
||||
{
|
||||
LOG_MSG("Failed to duplicate Hash FS partition name! (%s).", fs_ctx->name);
|
||||
LOG_MSG_ERROR("Failed to duplicate Hash FS partition name! (%s).", fs_ctx->name);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -490,7 +490,7 @@ bool gamecardGetHashFileSystemContext(u8 hfs_partition_type, HashFileSystemConte
|
|||
out->header = calloc(fs_ctx->header_size, sizeof(u8));
|
||||
if (!out->header)
|
||||
{
|
||||
LOG_MSG("Failed to duplicate Hash FS partition header! (%s).", fs_ctx->name);
|
||||
LOG_MSG_ERROR("Failed to duplicate Hash FS partition header! (%s).", fs_ctx->name);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -509,7 +509,7 @@ bool gamecardGetHashFileSystemEntryInfoByName(u8 hfs_partition_type, const char
|
|||
{
|
||||
if (!hfs_partition_type || hfs_partition_type >= GameCardHashFileSystemPartitionType_Count || !entry_name || !*entry_name || (!out_offset && !out_size))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -585,7 +585,7 @@ static bool gamecardReadLotusAsicFirmwareBlob(void)
|
|||
g_lafwBlob = calloc(1, sizeof(LotusAsicFirmwareBlob));
|
||||
if (!g_lafwBlob)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for LAFW blob!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for LAFW blob!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -600,7 +600,7 @@ static bool gamecardReadLotusAsicFirmwareBlob(void)
|
|||
|
||||
if (!ret)
|
||||
{
|
||||
LOG_MSG("Failed to retrieve FS .data segment dump!");
|
||||
LOG_MSG_ERROR("Failed to retrieve FS .data segment dump!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -624,7 +624,7 @@ static bool gamecardReadLotusAsicFirmwareBlob(void)
|
|||
|
||||
if (!found)
|
||||
{
|
||||
LOG_MSG("Unable to locate Lotus %s blob in FS .data segment!", dev_unit ? "ReadDevFw" : "ReadFw");
|
||||
LOG_MSG_ERROR("Unable to locate Lotus %s blob in FS .data segment!", dev_unit ? "ReadDevFw" : "ReadFw");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -637,7 +637,7 @@ static bool gamecardReadLotusAsicFirmwareBlob(void)
|
|||
fw_version >>= 1;
|
||||
}
|
||||
|
||||
LOG_MSG("LAFW version: %lu.", g_lafwVersion);
|
||||
LOG_MSG_INFO("LAFW version: %lu.", g_lafwVersion);
|
||||
|
||||
/* Update flag. */
|
||||
ret = true;
|
||||
|
@ -652,7 +652,7 @@ static bool gamecardCreateDetectionThread(void)
|
|||
{
|
||||
if (!utilsCreateThread(&g_gameCardDetectionThread, gamecardDetectionThreadFunc, NULL, 1))
|
||||
{
|
||||
LOG_MSG("Failed to create gamecard detection thread!");
|
||||
LOG_MSG_ERROR("Failed to create gamecard detection thread!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -726,7 +726,7 @@ NX_INLINE bool gamecardIsInserted(void)
|
|||
{
|
||||
bool inserted = false;
|
||||
Result rc = fsDeviceOperatorIsGameCardInserted(&g_deviceOperator, &inserted);
|
||||
if (R_FAILED(rc)) LOG_MSG("fsDeviceOperatorIsGameCardInserted failed! (0x%08X)", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("fsDeviceOperatorIsGameCardInserted failed! (0x%X)", rc);
|
||||
return (R_SUCCEEDED(rc) && inserted);
|
||||
}
|
||||
|
||||
|
@ -752,7 +752,7 @@ static void gamecardLoadInfo(void)
|
|||
/* Check if we meet the Lotus ASIC firmware (LAFW) version requirement. */
|
||||
if (g_lafwVersion < g_gameCardInfoArea.fw_version)
|
||||
{
|
||||
LOG_MSG("LAFW version doesn't meet gamecard requirement! (%lu < %lu).", g_lafwVersion, g_gameCardInfoArea.fw_version);
|
||||
LOG_MSG_ERROR("LAFW version doesn't meet gamecard requirement! (%lu < %lu).", g_lafwVersion, g_gameCardInfoArea.fw_version);
|
||||
g_gameCardStatus = GameCardStatus_LotusAsicFirmwareUpdateRequired;
|
||||
goto end;
|
||||
}
|
||||
|
@ -761,7 +761,7 @@ static void gamecardLoadInfo(void)
|
|||
/* gamecardReadStorageArea() actually checks if the storage area sizes are greater than zero, so we must perform this step. */
|
||||
if (!gamecardGetStorageAreasSizes())
|
||||
{
|
||||
LOG_MSG("Failed to retrieve gamecard storage area sizes!");
|
||||
LOG_MSG_ERROR("Failed to retrieve gamecard storage area sizes!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -769,7 +769,7 @@ static void gamecardLoadInfo(void)
|
|||
g_gameCardCapacity = gamecardGetCapacityFromRomSizeValue(g_gameCardHeader.rom_size);
|
||||
if (!g_gameCardCapacity)
|
||||
{
|
||||
LOG_MSG("Invalid gamecard capacity value! (0x%02X).", g_gameCardHeader.rom_size);
|
||||
LOG_MSG_ERROR("Invalid gamecard capacity value! (0x%02X).", g_gameCardHeader.rom_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -792,7 +792,7 @@ static void gamecardLoadInfo(void)
|
|||
g_gameCardHfsCtx = calloc(g_gameCardHfsCount, sizeof(HashFileSystemContext*));
|
||||
if (!g_gameCardHfsCtx)
|
||||
{
|
||||
LOG_MSG("Unable to allocate Hash FS context pointer array! (%u).", g_gameCardHfsCount);
|
||||
LOG_MSG_ERROR("Unable to allocate Hash FS context pointer array! (%u).", g_gameCardHfsCount);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -812,7 +812,7 @@ static void gamecardLoadInfo(void)
|
|||
|
||||
if (fs_entry->name_offset >= root_fs_name_table_size || !*fs_entry_name)
|
||||
{
|
||||
LOG_MSG("Invalid name for root Hash FS partition entry #%u!", i);
|
||||
LOG_MSG_ERROR("Invalid name for root Hash FS partition entry #%u!", i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -874,7 +874,7 @@ static bool gamecardReadHeader(void)
|
|||
/* Open normal storage area. */
|
||||
if (!gamecardOpenStorageArea(GameCardStorageArea_Normal))
|
||||
{
|
||||
LOG_MSG("Failed to open normal storage area!");
|
||||
LOG_MSG_ERROR("Failed to open normal storage area!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -883,16 +883,16 @@ static bool gamecardReadHeader(void)
|
|||
Result rc = fsStorageRead(&g_gameCardStorage, 0, &g_gameCardHeader, sizeof(GameCardHeader));
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("fsStorageRead failed to read gamecard header! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("fsStorageRead failed to read gamecard header! (0x%X).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
//LOG_DATA(&g_gameCardHeader, sizeof(GameCardHeader), "Gamecard header dump:");
|
||||
LOG_DATA_DEBUG(&g_gameCardHeader, sizeof(GameCardHeader), "Gamecard header dump:");
|
||||
|
||||
/* Check magic word from gamecard header. */
|
||||
if (__builtin_bswap32(g_gameCardHeader.magic) != GAMECARD_HEAD_MAGIC)
|
||||
{
|
||||
LOG_MSG("Invalid gamecard header magic word! (0x%08X).", __builtin_bswap32(g_gameCardHeader.magic));
|
||||
LOG_MSG_ERROR("Invalid gamecard header magic word! (0x%08X).", __builtin_bswap32(g_gameCardHeader.magic));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -909,7 +909,7 @@ static bool _gamecardGetDecryptedCardInfoArea(void)
|
|||
card_info_key = keysGetGameCardInfoKey();
|
||||
if (!card_info_key)
|
||||
{
|
||||
LOG_MSG("Failed to retrieve CardInfo area key!");
|
||||
LOG_MSG_ERROR("Failed to retrieve CardInfo area key!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -922,7 +922,7 @@ static bool _gamecardGetDecryptedCardInfoArea(void)
|
|||
/* Decrypt CardInfo area. */
|
||||
aes128CbcDecrypt(&aes_ctx, &g_gameCardInfoArea, &(g_gameCardHeader.card_info), sizeof(GameCardInfo));
|
||||
|
||||
//LOG_DATA(&g_gameCardInfoArea, sizeof(GameCardInfo), "Gamecard CardInfo area dump:");
|
||||
LOG_DATA_DEBUG(&g_gameCardInfoArea, sizeof(GameCardInfo), "Gamecard CardInfo area dump:");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -931,7 +931,7 @@ static bool gamecardReadSecurityInformation(GameCardSecurityInformation *out)
|
|||
{
|
||||
if (!g_gameCardInterfaceInit || g_gameCardStatus != GameCardStatus_InsertedAndInfoLoaded || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -941,7 +941,7 @@ static bool gamecardReadSecurityInformation(GameCardSecurityInformation *out)
|
|||
/* Open secure storage area. */
|
||||
if (!gamecardOpenStorageArea(GameCardStorageArea_Secure))
|
||||
{
|
||||
LOG_MSG("Failed to open secure storage area!");
|
||||
LOG_MSG_ERROR("Failed to open secure storage area!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -951,7 +951,7 @@ static bool gamecardReadSecurityInformation(GameCardSecurityInformation *out)
|
|||
/* Retrieve full FS program memory dump. */
|
||||
if (!memRetrieveFullProgramMemory(&g_fsProgramMemory))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve full FS program memory dump!");
|
||||
LOG_MSG_ERROR("Failed to retrieve full FS program memory dump!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -987,7 +987,7 @@ static bool gamecardGetHandleAndStorage(u32 partition)
|
|||
{
|
||||
if (g_gameCardStatus < GameCardStatus_InsertedAndInfoNotLoaded || partition > 1)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1004,7 +1004,7 @@ static bool gamecardGetHandleAndStorage(u32 partition)
|
|||
rc = fsDeviceOperatorGetGameCardHandle(&g_deviceOperator, &g_gameCardHandle);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
//LOG_MSG("fsDeviceOperatorGetGameCardHandle failed on try #%u! (0x%08X).", i + 1, rc);
|
||||
LOG_MSG_DEBUG("fsDeviceOperatorGetGameCardHandle failed on try #%u! (0x%X).", i + 1, rc);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1013,7 +1013,7 @@ static bool gamecardGetHandleAndStorage(u32 partition)
|
|||
if (R_FAILED(rc))
|
||||
{
|
||||
gamecardCloseHandle(); /* Close invalid gamecard handle. */
|
||||
//LOG_MSG("fsOpenGameCardStorage failed to open %s storage area on try #%u! (0x%08X).", GAMECARD_STORAGE_AREA_NAME(partition + 1), i + 1, rc);
|
||||
LOG_MSG_DEBUG("fsOpenGameCardStorage failed to open %s storage area on try #%u! (0x%X).", GAMECARD_STORAGE_AREA_NAME(partition + 1), i + 1, rc);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1023,7 +1023,7 @@ static bool gamecardGetHandleAndStorage(u32 partition)
|
|||
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("fsDeviceOperatorGetGameCardHandle / fsOpenGameCardStorage failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("fsDeviceOperatorGetGameCardHandle / fsOpenGameCardStorage failed! (0x%X).", rc);
|
||||
if (g_gameCardStatus == GameCardStatus_InsertedAndInfoNotLoaded && partition == 0) g_gameCardStatus = GameCardStatus_NoGameCardPatchEnabled;
|
||||
}
|
||||
|
||||
|
@ -1039,7 +1039,7 @@ static bool gamecardOpenStorageArea(u8 area)
|
|||
{
|
||||
if (g_gameCardStatus < GameCardStatus_InsertedAndInfoNotLoaded || (area != GameCardStorageArea_Normal && area != GameCardStorageArea_Secure))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1052,7 +1052,7 @@ static bool gamecardOpenStorageArea(u8 area)
|
|||
/* Retrieve both a new gamecard handle and a storage area handle. */
|
||||
if (!gamecardGetHandleAndStorage(area - 1)) /* Zero-based index. */
|
||||
{
|
||||
LOG_MSG("Failed to retrieve gamecard handle and storage area handle! (%s).", GAMECARD_STORAGE_AREA_NAME(area));
|
||||
LOG_MSG_ERROR("Failed to retrieve gamecard handle and storage area handle! (%s).", GAMECARD_STORAGE_AREA_NAME(area));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1066,7 +1066,7 @@ static bool gamecardReadStorageArea(void *out, u64 read_size, u64 offset)
|
|||
{
|
||||
if (g_gameCardStatus < GameCardStatus_InsertedAndInfoNotLoaded || !g_gameCardNormalAreaSize || !g_gameCardSecureAreaSize || !out || !read_size || (offset + read_size) > g_gameCardTotalSize)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1095,7 +1095,7 @@ static bool gamecardReadStorageArea(void *out, u64 read_size, u64 offset)
|
|||
/* If the right storage area has already been opened, this will return true. */
|
||||
if (!gamecardOpenStorageArea(area))
|
||||
{
|
||||
LOG_MSG("Failed to open %s storage area!", GAMECARD_STORAGE_AREA_NAME(area));
|
||||
LOG_MSG_ERROR("Failed to open %s storage area!", GAMECARD_STORAGE_AREA_NAME(area));
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1108,7 +1108,7 @@ static bool gamecardReadStorageArea(void *out, u64 read_size, u64 offset)
|
|||
rc = fsStorageRead(&g_gameCardStorage, base_offset, out_u8, read_size);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("fsStorageRead failed to read 0x%lX bytes at offset 0x%lX from %s storage area! (0x%08X) (aligned).", read_size, base_offset, GAMECARD_STORAGE_AREA_NAME(area), rc);
|
||||
LOG_MSG_ERROR("fsStorageRead failed to read 0x%lX bytes at offset 0x%lX from %s storage area! (0x%X) (aligned).", read_size, base_offset, GAMECARD_STORAGE_AREA_NAME(area), rc);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1126,7 +1126,7 @@ static bool gamecardReadStorageArea(void *out, u64 read_size, u64 offset)
|
|||
rc = fsStorageRead(&g_gameCardStorage, block_start_offset, g_gameCardReadBuf, chunk_size);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("fsStorageRead failed to read 0x%lX bytes at offset 0x%lX from %s storage area! (0x%08X) (unaligned).", chunk_size, block_start_offset, GAMECARD_STORAGE_AREA_NAME(area), rc);
|
||||
LOG_MSG_ERROR("fsStorageRead failed to read 0x%lX bytes at offset 0x%lX from %s storage area! (0x%X) (unaligned).", chunk_size, block_start_offset, GAMECARD_STORAGE_AREA_NAME(area), rc);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1164,7 +1164,7 @@ static bool gamecardGetStorageAreasSizes(void)
|
|||
|
||||
if (!gamecardOpenStorageArea(area))
|
||||
{
|
||||
LOG_MSG("Failed to open %s storage area!", GAMECARD_STORAGE_AREA_NAME(area));
|
||||
LOG_MSG_ERROR("Failed to open %s storage area!", GAMECARD_STORAGE_AREA_NAME(area));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1174,7 +1174,7 @@ static bool gamecardGetStorageAreasSizes(void)
|
|||
|
||||
if (R_FAILED(rc) || !area_size)
|
||||
{
|
||||
LOG_MSG("fsStorageGetSize failed to retrieve %s storage area size! (0x%08X).", GAMECARD_STORAGE_AREA_NAME(area), rc);
|
||||
LOG_MSG_ERROR("fsStorageGetSize failed to retrieve %s storage area size! (0x%X).", GAMECARD_STORAGE_AREA_NAME(area), rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1234,7 +1234,7 @@ static HashFileSystemContext *gamecardInitializeHashFileSystemContext(const char
|
|||
if ((name && !*name) || offset < (GAMECARD_CERTIFICATE_OFFSET + sizeof(FsGameCardCertificate)) || !IS_ALIGNED(offset, GAMECARD_PAGE_SIZE) || \
|
||||
(size && (!IS_ALIGNED(size, GAMECARD_PAGE_SIZE) || (offset + size) > g_gameCardTotalSize)))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1242,7 +1242,7 @@ static HashFileSystemContext *gamecardInitializeHashFileSystemContext(const char
|
|||
fs_ctx = calloc(1, sizeof(HashFileSystemContext));
|
||||
if (!fs_ctx)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for Hash FS context! (offset 0x%lX).", offset);
|
||||
LOG_MSG_ERROR("Unable to allocate memory for Hash FS context! (offset 0x%lX).", offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1250,7 +1250,7 @@ static HashFileSystemContext *gamecardInitializeHashFileSystemContext(const char
|
|||
fs_ctx->name = (name ? strdup(name) : strdup(g_gameCardHfsPartitionNames[GAMECARD_HFS_PARTITION_NAME_INDEX(GameCardHashFileSystemPartitionType_Root)]));
|
||||
if (!fs_ctx->name)
|
||||
{
|
||||
LOG_MSG("Failed to duplicate Hash FS partition name! (offset 0x%lX).", offset);
|
||||
LOG_MSG_ERROR("Failed to duplicate Hash FS partition name! (offset 0x%lX).", offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1262,7 +1262,7 @@ static HashFileSystemContext *gamecardInitializeHashFileSystemContext(const char
|
|||
|
||||
if (i >= GameCardHashFileSystemPartitionType_Count)
|
||||
{
|
||||
LOG_MSG("Failed to find a matching Hash FS partition type for \"%s\"! (offset 0x%lX).", fs_ctx->name, offset);
|
||||
LOG_MSG_ERROR("Failed to find a matching Hash FS partition type for \"%s\"! (offset 0x%lX).", fs_ctx->name, offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1271,14 +1271,14 @@ static HashFileSystemContext *gamecardInitializeHashFileSystemContext(const char
|
|||
/* Read partial Hash FS header. */
|
||||
if (!gamecardReadStorageArea(&fs_header, sizeof(HashFileSystemHeader), offset))
|
||||
{
|
||||
LOG_MSG("Failed to read partial Hash FS header! (\"%s\", offset 0x%lX).", fs_ctx->name, offset);
|
||||
LOG_MSG_ERROR("Failed to read partial Hash FS header! (\"%s\", offset 0x%lX).", fs_ctx->name, offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
magic = __builtin_bswap32(fs_header.magic);
|
||||
if (magic != HFS0_MAGIC)
|
||||
{
|
||||
LOG_MSG("Invalid Hash FS magic word! (0x%08X) (\"%s\", offset 0x%lX).", magic, fs_ctx->name, offset);
|
||||
LOG_MSG_ERROR("Invalid Hash FS magic word! (0x%08X) (\"%s\", offset 0x%lX).", magic, fs_ctx->name, offset);
|
||||
dump_fs_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1287,7 +1287,7 @@ static HashFileSystemContext *gamecardInitializeHashFileSystemContext(const char
|
|||
/* Only allow a zero entry count if we're not dealing with the root partition. Never allow a zero-sized name table. */
|
||||
if ((!name && !fs_header.entry_count) || !fs_header.name_table_size)
|
||||
{
|
||||
LOG_MSG("Invalid Hash FS entry count / name table size! (\"%s\", offset 0x%lX).", fs_ctx->name, offset);
|
||||
LOG_MSG_ERROR("Invalid Hash FS entry count / name table size! (\"%s\", offset 0x%lX).", fs_ctx->name, offset);
|
||||
dump_fs_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1300,14 +1300,14 @@ static HashFileSystemContext *gamecardInitializeHashFileSystemContext(const char
|
|||
fs_ctx->header = calloc(fs_ctx->header_size, sizeof(u8));
|
||||
if (!fs_ctx->header)
|
||||
{
|
||||
LOG_MSG("Unable to allocate 0x%lX bytes buffer for the full Hash FS header! (\"%s\", offset 0x%lX).", fs_ctx->header_size, fs_ctx->name, offset);
|
||||
LOG_MSG_ERROR("Unable to allocate 0x%lX bytes buffer for the full Hash FS header! (\"%s\", offset 0x%lX).", fs_ctx->header_size, fs_ctx->name, offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Read full Hash FS header. */
|
||||
if (!gamecardReadStorageArea(fs_ctx->header, fs_ctx->header_size, offset))
|
||||
{
|
||||
LOG_MSG("Failed to read full Hash FS header! (\"%s\", offset 0x%lX).", fs_ctx->name, offset);
|
||||
LOG_MSG_ERROR("Failed to read full Hash FS header! (\"%s\", offset 0x%lX).", fs_ctx->name, offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1317,7 +1317,7 @@ static HashFileSystemContext *gamecardInitializeHashFileSystemContext(const char
|
|||
sha256CalculateHash(fs_header_hash, fs_ctx->header + hash_target_offset, hash_target_size);
|
||||
if (memcmp(fs_header_hash, hash, SHA256_HASH_SIZE) != 0)
|
||||
{
|
||||
LOG_MSG("Hash FS header doesn't match expected SHA-256 hash! (\"%s\", offset 0x%lX).", fs_ctx->name, offset);
|
||||
LOG_MSG_ERROR("Hash FS header doesn't match expected SHA-256 hash! (\"%s\", offset 0x%lX).", fs_ctx->name, offset);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1341,7 +1341,7 @@ static HashFileSystemContext *gamecardInitializeHashFileSystemContext(const char
|
|||
end:
|
||||
if (!success && fs_ctx)
|
||||
{
|
||||
if (dump_fs_header) LOG_DATA(&fs_header, sizeof(HashFileSystemHeader), "Partial Hash FS header dump (\"%s\", offset 0x%lX):", fs_ctx->name, offset);
|
||||
if (dump_fs_header) LOG_DATA_DEBUG(&fs_header, sizeof(HashFileSystemHeader), "Partial Hash FS header dump (\"%s\", offset 0x%lX):", fs_ctx->name, offset);
|
||||
|
||||
if (fs_ctx->header) free(fs_ctx->header);
|
||||
|
||||
|
@ -1361,7 +1361,7 @@ static HashFileSystemContext *_gamecardGetHashFileSystemContext(u8 hfs_partition
|
|||
if (!g_gameCardInterfaceInit || g_gameCardStatus != GameCardStatus_InsertedAndInfoLoaded || !g_gameCardHfsCount || !g_gameCardHfsCtx || !hfs_partition_type || \
|
||||
hfs_partition_type >= GameCardHashFileSystemPartitionType_Count)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1380,7 +1380,7 @@ static HashFileSystemContext *_gamecardGetHashFileSystemContext(u8 hfs_partition
|
|||
fs_ctx = NULL;
|
||||
}
|
||||
|
||||
if (!fs_ctx) LOG_MSG("Failed to locate Hash FS partition with type %u!", hfs_partition_type);
|
||||
if (!fs_ctx) LOG_MSG_ERROR("Failed to locate Hash FS partition with type %u!", hfs_partition_type);
|
||||
|
||||
end:
|
||||
return fs_ctx;
|
||||
|
|
|
@ -26,14 +26,14 @@ bool hfsReadPartitionData(HashFileSystemContext *ctx, void *out, u64 read_size,
|
|||
{
|
||||
if (!ctx || !ctx->size || !out || !read_size || (offset + read_size) > ctx->size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Read partition data. */
|
||||
if (!gamecardReadStorage(out, read_size, ctx->offset + offset))
|
||||
{
|
||||
LOG_MSG("Failed to read Hash FS partition data!");
|
||||
LOG_MSG_ERROR("Failed to read Hash FS partition data!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -44,14 +44,14 @@ bool hfsReadEntryData(HashFileSystemContext *ctx, HashFileSystemEntry *fs_entry,
|
|||
{
|
||||
if (!ctx || !fs_entry || !fs_entry->size || (fs_entry->offset + fs_entry->size) > ctx->size || !out || !read_size || (offset + read_size) > fs_entry->size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Read entry data. */
|
||||
if (!hfsReadPartitionData(ctx, out, read_size, ctx->header_size + fs_entry->offset + offset))
|
||||
{
|
||||
LOG_MSG("Failed to read Partition FS entry data!");
|
||||
LOG_MSG_ERROR("Failed to read Partition FS entry data!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ bool hfsGetTotalDataSize(HashFileSystemContext *ctx, u64 *out_size)
|
|||
|
||||
if (!entry_count || !out_size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ bool hfsGetTotalDataSize(HashFileSystemContext *ctx, u64 *out_size)
|
|||
{
|
||||
if (!(fs_entry = hfsGetEntryByIndex(ctx, i)))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve Hash FS entry #%u!", i);
|
||||
LOG_MSG_ERROR("Failed to retrieve Hash FS entry #%u!", i);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ bool hfsGetEntryIndexByName(HashFileSystemContext *ctx, const char *name, u32 *o
|
|||
|
||||
if (!entry_count || !name_table || !name || !*name || !out_idx)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -104,13 +104,13 @@ bool hfsGetEntryIndexByName(HashFileSystemContext *ctx, const char *name, u32 *o
|
|||
{
|
||||
if (!(fs_entry = hfsGetEntryByIndex(ctx, i)))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve Hash FS entry #%u!", i);
|
||||
LOG_MSG_ERROR("Failed to retrieve Hash FS entry #%u!", i);
|
||||
break;
|
||||
}
|
||||
|
||||
if (fs_entry->name_offset >= name_table_size)
|
||||
{
|
||||
LOG_MSG("Name offset from Hash FS entry #%u exceeds name table size!", i);
|
||||
LOG_MSG_ERROR("Name offset from Hash FS entry #%u exceeds name table size!", i);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ bool httpInitialize(void)
|
|||
CURLcode res = curl_global_init(CURL_GLOBAL_ALL);
|
||||
if (res != CURLE_OK)
|
||||
{
|
||||
LOG_MSG("%s", curl_easy_strerror(res));
|
||||
LOG_MSG_ERROR("%s", curl_easy_strerror(res));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ bool httpPerformGetRequest(const char *url, bool force_https, size_t *outsize, H
|
|||
{
|
||||
if (!g_httpInterfaceInit || !url || !*url)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ bool httpPerformGetRequest(const char *url, bool force_https, size_t *outsize, H
|
|||
curl = curl_easy_init();
|
||||
if (!curl)
|
||||
{
|
||||
LOG_MSG("Failed to start CURL session for \"%s\"!", url);
|
||||
LOG_MSG_ERROR("Failed to start CURL session for \"%s\"!", url);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ bool httpPerformGetRequest(const char *url, bool force_https, size_t *outsize, H
|
|||
/* Update output size. */
|
||||
if (outsize) *outsize = (size_t)download_size;
|
||||
} else {
|
||||
LOG_MSG("curl_easy_perform failed for \"%s\"! (res %d, HTTP code %ld, download %ld, length %ld).", url, res, http_code, download_size, content_length);
|
||||
LOG_MSG_ERROR("curl_easy_perform failed for \"%s\"! (res %d, HTTP code %ld, download %ld, length %ld).", url, res, http_code, download_size, content_length);
|
||||
if (res != CURLE_OK)
|
||||
{
|
||||
/* Log CURL error info. */
|
||||
|
@ -175,7 +175,7 @@ bool httpPerformGetRequest(const char *url, bool force_https, size_t *outsize, H
|
|||
error_str = curl_easy_strerror(res);
|
||||
}
|
||||
|
||||
if (error_str) LOG_MSG("CURL error info: \"%s\".", error_str);
|
||||
if (error_str) LOG_MSG_INFO("CURL error info: \"%s\".", error_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ bool httpDownloadFile(const char *path, const char *url, bool force_https, HttpP
|
|||
{
|
||||
if (!path || !*path)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ bool httpDownloadFile(const char *path, const char *url, bool force_https, HttpP
|
|||
fd = fopen(path, "wb");
|
||||
if (!fd)
|
||||
{
|
||||
LOG_MSG("Failed to open \"%s\" for writing!", path);
|
||||
LOG_MSG_ERROR("Failed to open \"%s\" for writing!", path);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ char *httpDownloadData(size_t *outsize, const char *url, bool force_https, HttpP
|
|||
{
|
||||
if (!outsize)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -263,28 +263,28 @@ bool keysLoadKeyset(void)
|
|||
/* Retrieve FS .rodata keys. */
|
||||
if (!keysRetrieveKeysFromProgramMemory(&g_fsRodataMemoryInfo))
|
||||
{
|
||||
LOG_MSG("Unable to retrieve keys from FS .rodata segment!");
|
||||
LOG_MSG_ERROR("Unable to retrieve keys from FS .rodata segment!");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Retrieve FS .data keys. */
|
||||
if (!keysRetrieveKeysFromProgramMemory(&g_fsDataMemoryInfo))
|
||||
{
|
||||
LOG_MSG("Unable to retrieve keys from FS .data segment!");
|
||||
LOG_MSG_ERROR("Unable to retrieve keys from FS .data segment!");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Derive NCA header key. */
|
||||
if (!keysDeriveNcaHeaderKey())
|
||||
{
|
||||
LOG_MSG("Unable to derive NCA header key!");
|
||||
LOG_MSG_ERROR("Unable to derive NCA header key!");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Derive sealed NCA KAEKs. */
|
||||
if (!keysDeriveSealedNcaKeyAreaEncryptionKeys())
|
||||
{
|
||||
LOG_MSG("Unable to derive sealed NCA KAEKs!");
|
||||
LOG_MSG_ERROR("Unable to derive sealed NCA KAEKs!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -301,12 +301,14 @@ bool keysLoadKeyset(void)
|
|||
ret = g_keysetLoaded = true;
|
||||
}
|
||||
|
||||
/*if (ret)
|
||||
#if LOG_LEVEL == LOG_LEVEL_DEBUG
|
||||
if (ret)
|
||||
{
|
||||
LOG_DATA(&g_ncaKeyset, sizeof(KeysNcaKeyset), "NCA keyset dump:");
|
||||
LOG_DATA(&g_eTicketRsaDeviceKey, sizeof(SetCalRsa2048DeviceKey), "eTicket RSA device key dump:");
|
||||
LOG_DATA(&g_gameCardKeyset, sizeof(KeysGameCardKeyset), "Gamecard keyset dump:");
|
||||
}*/
|
||||
LOG_DATA_DEBUG(&g_ncaKeyset, sizeof(KeysNcaKeyset), "NCA keyset dump:");
|
||||
LOG_DATA_DEBUG(&g_eTicketRsaDeviceKey, sizeof(SetCalRsa2048DeviceKey), "eTicket RSA device key dump:");
|
||||
LOG_DATA_DEBUG(&g_gameCardKeyset, sizeof(KeysGameCardKeyset), "Gamecard keyset dump:");
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -327,7 +329,7 @@ const u8 *keysGetNcaMainSignatureModulus(u8 key_generation)
|
|||
{
|
||||
if (key_generation > NcaSignatureKeyGeneration_Current)
|
||||
{
|
||||
LOG_MSG("Unsupported key generation value! (0x%02X).", key_generation);
|
||||
LOG_MSG_ERROR("Unsupported key generation value! (0x%02X).", key_generation);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -342,7 +344,7 @@ const u8 *keysGetNcaMainSignatureModulus(u8 key_generation)
|
|||
|
||||
if (!memcmp(ret, null_modulus, RSA2048_PUBKEY_SIZE))
|
||||
{
|
||||
LOG_MSG("%s NCA header main signature modulus 0x%02X unavailable.", dev_unit ? "Development" : "Retail", key_generation);
|
||||
LOG_MSG_ERROR("%s NCA header main signature modulus 0x%02X unavailable.", dev_unit ? "Development" : "Retail", key_generation);
|
||||
ret = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -357,19 +359,19 @@ bool keysDecryptNcaKeyAreaEntry(u8 kaek_index, u8 key_generation, void *dst, con
|
|||
|
||||
if (kaek_index >= NcaKeyAreaEncryptionKeyIndex_Count)
|
||||
{
|
||||
LOG_MSG("Invalid KAEK index! (0x%02X).", kaek_index);
|
||||
LOG_MSG_ERROR("Invalid KAEK index! (0x%02X).", kaek_index);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (key_gen_val >= NcaKeyGeneration_Max)
|
||||
{
|
||||
LOG_MSG("Invalid key generation value! (0x%02X).", key_gen_val);
|
||||
LOG_MSG_ERROR("Invalid key generation value! (0x%02X).", key_gen_val);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!dst || !src)
|
||||
{
|
||||
LOG_MSG("Invalid destination/source pointer.");
|
||||
LOG_MSG_ERROR("Invalid destination/source pointer.");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -377,7 +379,7 @@ bool keysDecryptNcaKeyAreaEntry(u8 kaek_index, u8 key_generation, void *dst, con
|
|||
{
|
||||
if (!g_keysetLoaded) break;
|
||||
Result rc = splCryptoGenerateAesKey(g_ncaKeyset.nca_kaek_sealed[kaek_index][key_gen_val], src, dst);
|
||||
if (!(ret = R_SUCCEEDED(rc))) LOG_MSG("splCryptoGenerateAesKey failed! (0x%08X).", rc);
|
||||
if (!(ret = R_SUCCEEDED(rc))) LOG_MSG_ERROR("splCryptoGenerateAesKey failed! (0x%X).", rc);
|
||||
}
|
||||
|
||||
end:
|
||||
|
@ -391,13 +393,13 @@ const u8 *keysGetNcaKeyAreaEncryptionKey(u8 kaek_index, u8 key_generation)
|
|||
|
||||
if (kaek_index >= NcaKeyAreaEncryptionKeyIndex_Count)
|
||||
{
|
||||
LOG_MSG("Invalid KAEK index! (0x%02X).", kaek_index);
|
||||
LOG_MSG_ERROR("Invalid KAEK index! (0x%02X).", kaek_index);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (key_gen_val >= NcaKeyGeneration_Max)
|
||||
{
|
||||
LOG_MSG("Invalid key generation value! (0x%02X).", key_gen_val);
|
||||
LOG_MSG_ERROR("Invalid key generation value! (0x%02X).", key_gen_val);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -414,7 +416,7 @@ bool keysDecryptRsaOaepWrappedTitleKey(const void *rsa_wrapped_titlekey, void *o
|
|||
{
|
||||
if (!rsa_wrapped_titlekey || !out_titlekey)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -439,7 +441,7 @@ bool keysDecryptRsaOaepWrappedTitleKey(const void *rsa_wrapped_titlekey, void *o
|
|||
/* Copy RSA-OAEP unwrapped titlekey. */
|
||||
memcpy(out_titlekey, out_keydata, AES_128_KEY_SIZE);
|
||||
} else {
|
||||
LOG_MSG("RSA-OAEP titlekey decryption failed!");
|
||||
LOG_MSG_ERROR("RSA-OAEP titlekey decryption failed!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,7 +455,7 @@ const u8 *keysGetTicketCommonKey(u8 key_generation)
|
|||
|
||||
if (key_gen_val >= NcaKeyGeneration_Max)
|
||||
{
|
||||
LOG_MSG("Invalid key generation value! (0x%02X).", key_gen_val);
|
||||
LOG_MSG_ERROR("Invalid key generation value! (0x%02X).", key_gen_val);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -502,7 +504,7 @@ static bool keysRetrieveKeysFromProgramMemory(KeysMemoryInfo *info)
|
|||
{
|
||||
if (!info || !info->key_count)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -522,7 +524,7 @@ static bool keysRetrieveKeysFromProgramMemory(KeysMemoryInfo *info)
|
|||
/* Check destination pointer. */
|
||||
if (!key->dst)
|
||||
{
|
||||
LOG_MSG("Invalid destination pointer for key \"%s\" in program %016lX!", key->name, info->location.program_id);
|
||||
LOG_MSG_ERROR("Invalid destination pointer for key \"%s\" in program %016lX!", key->name, info->location.program_id);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -543,7 +545,7 @@ static bool keysRetrieveKeysFromProgramMemory(KeysMemoryInfo *info)
|
|||
|
||||
if (!found)
|
||||
{
|
||||
LOG_MSG("Unable to locate key \"%s\" in process memory from program %016lX!", key->name, info->location.program_id);
|
||||
LOG_MSG_ERROR("Unable to locate key \"%s\" in process memory from program %016lX!", key->name, info->location.program_id);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -564,7 +566,7 @@ static bool keysDeriveNcaHeaderKey(void)
|
|||
rc = splCryptoGenerateAesKek(g_ncaKeyset.nca_header_kek_source, 0, 0, g_ncaKeyset.nca_header_kek_sealed);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("splCryptoGenerateAesKek failed! (0x%08X) (nca_header_kek_sealed).", rc);
|
||||
LOG_MSG_ERROR("splCryptoGenerateAesKek failed! (0x%X) (nca_header_kek_sealed).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -572,14 +574,14 @@ static bool keysDeriveNcaHeaderKey(void)
|
|||
rc = splCryptoGenerateAesKey(g_ncaKeyset.nca_header_kek_sealed, g_ncaKeyset.nca_header_key_source, g_ncaKeyset.nca_header_key);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("splCryptoGenerateAesKey failed! (0x%08X) (nca_header_key) (#1).", rc);
|
||||
LOG_MSG_ERROR("splCryptoGenerateAesKey failed! (0x%X) (nca_header_key) (#1).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = splCryptoGenerateAesKey(g_ncaKeyset.nca_header_kek_sealed, g_ncaKeyset.nca_header_key_source + AES_128_KEY_SIZE, g_ncaKeyset.nca_header_key + AES_128_KEY_SIZE);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("splCryptoGenerateAesKey failed! (0x%08X) (nca_header_key) (#2).", rc);
|
||||
LOG_MSG_ERROR("splCryptoGenerateAesKey failed! (0x%X) (nca_header_key) (#2).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -608,7 +610,7 @@ static bool keysDeriveSealedNcaKeyAreaEncryptionKeys(void)
|
|||
rc = splCryptoGenerateAesKek(nca_kaek_source, j, 0, nca_kaek_sealed);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
//LOG_MSG("splCryptoGenerateAesKek failed for KAEK index %u and key generation %u! (0x%08X).", i, (j <= 1 ? 0 : j), rc);
|
||||
LOG_MSG_DEBUG("splCryptoGenerateAesKek failed for KAEK index %u and key generation %u! (0x%X).", i, (j <= 1 ? 0 : j), rc);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -619,7 +621,7 @@ static bool keysDeriveSealedNcaKeyAreaEncryptionKeys(void)
|
|||
}
|
||||
|
||||
success = (key_cnt > 0);
|
||||
if (success) LOG_MSG("Derived %u sealed NCA KAEK(s) (%u key generation[s]).", key_cnt, highest_key_gen + 1);
|
||||
if (success) LOG_MSG_INFO("Derived %u sealed NCA KAEK(s) (%u key generation[s]).", key_cnt, highest_key_gen + 1);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -663,7 +665,7 @@ static int keysGetKeyAndValueFromFile(FILE *f, char **line, char **key, char **v
|
|||
{
|
||||
if (!f || !line || !key || !value)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
@ -682,7 +684,7 @@ static int keysGetKeyAndValueFromFile(FILE *f, char **line, char **key, char **v
|
|||
if (errno != 0 || read <= 0)
|
||||
{
|
||||
ret = ((errno == 0 && (read == 0 || feof(f))) ? 1 : -2);
|
||||
if (ret != 1) LOG_MSG("__getline failed! (0x%lX, %ld, %d, %d).", ftell(f), read, errno, ret);
|
||||
if (ret != 1) LOG_MSG_ERROR("__getline failed! (0x%lX, %ld, %d, %d).", ftell(f), read, errno, ret);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -692,7 +694,7 @@ static int keysGetKeyAndValueFromFile(FILE *f, char **line, char **key, char **v
|
|||
l = *line;
|
||||
if (*l == '\n' || *l == '\r' || *l == '\0')
|
||||
{
|
||||
LOG_MSG("Empty line detected! (0x%lX, 0x%lX).", n, read);
|
||||
LOG_MSG_WARNING("Empty line detected! (0x%lX, 0x%lX).", n, read);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -722,7 +724,7 @@ static int keysGetKeyAndValueFromFile(FILE *f, char **line, char **key, char **v
|
|||
/* Bail out if we reached the end of string. */
|
||||
if (*p == '\0')
|
||||
{
|
||||
LOG_MSG("End of string reached while validating key name string! (#1) (0x%lX, 0x%lX, 0x%lX).", n, read, (size_t)(p - l));
|
||||
LOG_MSG_ERROR("End of string reached while validating key name string! (#1) (0x%lX, 0x%lX, 0x%lX).", n, read, (size_t)(p - l));
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -736,7 +738,7 @@ static int keysGetKeyAndValueFromFile(FILE *f, char **line, char **key, char **v
|
|||
/* Handle unsupported characters. */
|
||||
if (*p != '_' && (*p < '0' || *p > '9') && (*p < 'a' || *p > 'z'))
|
||||
{
|
||||
LOG_MSG("Unsupported character detected in key name string! (0x%lX, 0x%lX, 0x%lX, 0x%02X).", n, read, (size_t)(p - l), *p);
|
||||
LOG_MSG_ERROR("Unsupported character detected in key name string! (0x%lX, 0x%lX, 0x%lX, 0x%02X).", n, read, (size_t)(p - l), *p);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -744,7 +746,7 @@ static int keysGetKeyAndValueFromFile(FILE *f, char **line, char **key, char **v
|
|||
/* Bail if the final ++p put us at the end of string. */
|
||||
if (*p == '\0')
|
||||
{
|
||||
LOG_MSG("End of string reached while validating key name string! (#2) (0x%lX, 0x%lX, 0x%lX).", n, read, (size_t)(p - l));
|
||||
LOG_MSG_ERROR("End of string reached while validating key name string! (#2) (0x%lX, 0x%lX, 0x%lX).", n, read, (size_t)(p - l));
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -759,7 +761,7 @@ static int keysGetKeyAndValueFromFile(FILE *f, char **line, char **key, char **v
|
|||
|
||||
if (*p != '=' && *p != ',')
|
||||
{
|
||||
LOG_MSG("Unable to find expected [,=]! (0x%lX, 0x%lX, 0x%lX).", n, read, (size_t)(p - l));
|
||||
LOG_MSG_ERROR("Unable to find expected [,=]! (0x%lX, 0x%lX, 0x%lX).", n, read, (size_t)(p - l));
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -769,7 +771,7 @@ static int keysGetKeyAndValueFromFile(FILE *f, char **line, char **key, char **v
|
|||
/* Empty key name string is an error. */
|
||||
if (*k == '\0')
|
||||
{
|
||||
LOG_MSG("Key name string empty! (0x%lX, 0x%lX).", n, read);
|
||||
LOG_MSG_ERROR("Key name string empty! (0x%lX, 0x%lX).", n, read);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -785,7 +787,7 @@ static int keysGetKeyAndValueFromFile(FILE *f, char **line, char **key, char **v
|
|||
/* Bail out if we reached the end of string. */
|
||||
if (*p == '\0')
|
||||
{
|
||||
LOG_MSG("End of string reached while validating value string! (0x%lX, 0x%lX, 0x%lX, %s).", n, read, (size_t)(p - l), k);
|
||||
LOG_MSG_ERROR("End of string reached while validating value string! (0x%lX, 0x%lX, 0x%lX, %s).", n, read, (size_t)(p - l), k);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -799,7 +801,7 @@ static int keysGetKeyAndValueFromFile(FILE *f, char **line, char **key, char **v
|
|||
/* Handle unsupported characters. */
|
||||
if ((*p < '0' || *p > '9') && (*p < 'a' || *p > 'f'))
|
||||
{
|
||||
LOG_MSG("Unsupported character detected in value string! (0x%lX, 0x%lX, 0x%lX, 0x%02X, %s).", n, read, (size_t)(p - l), *p, k);
|
||||
LOG_MSG_ERROR("Unsupported character detected in value string! (0x%lX, 0x%lX, 0x%lX, 0x%02X, %s).", n, read, (size_t)(p - l), *p, k);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -815,7 +817,7 @@ static int keysGetKeyAndValueFromFile(FILE *f, char **line, char **key, char **v
|
|||
|
||||
if (p < e)
|
||||
{
|
||||
LOG_MSG("Additional data detected after value string and before line end! (0x%lX, 0x%lX, 0x%lX, %s).", n, read, (size_t)(p - *line), k);
|
||||
LOG_MSG_ERROR("Additional data detected after value string and before line end! (0x%lX, 0x%lX, 0x%lX, %s).", n, read, (size_t)(p - *line), k);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -823,7 +825,7 @@ static int keysGetKeyAndValueFromFile(FILE *f, char **line, char **key, char **v
|
|||
/* Empty value string and value string length not being a multiple of 2 are both errors. */
|
||||
if (*v == '\0' || ((l - v) % 2) != 0)
|
||||
{
|
||||
LOG_MSG("Invalid value string length! (0x%lX, 0x%lX, 0x%lX, %s).", n, read, (size_t)(l - v), k);
|
||||
LOG_MSG_ERROR("Invalid value string length! (0x%lX, 0x%lX, 0x%lX, %s).", n, read, (size_t)(l - v), k);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -859,13 +861,13 @@ static bool keysParseHexKey(u8 *out, const char *key, const char *value, u32 siz
|
|||
|
||||
if (!out || !key || !*key || !value || !(value_len = strlen(value)) || !size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value_len != hex_str_len)
|
||||
{
|
||||
LOG_MSG("Key \"%s\" must be %u hex digits long!", key, hex_str_len);
|
||||
LOG_MSG_ERROR("Key \"%s\" must be %u hex digits long!", key, hex_str_len);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -876,7 +878,7 @@ static bool keysParseHexKey(u8 *out, const char *key, const char *value, u32 siz
|
|||
char val = keysConvertHexDigitToBinary(value[i]);
|
||||
if (val == 'z')
|
||||
{
|
||||
LOG_MSG("Invalid hex character in key \"%s\" at position %u!", key, i);
|
||||
LOG_MSG_ERROR("Invalid hex character in key \"%s\" at position %u!", key, i);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -900,7 +902,7 @@ static bool keysReadKeysFromFile(void)
|
|||
keys_file = fopen(keys_file_path, "rb");
|
||||
if (!keys_file)
|
||||
{
|
||||
LOG_MSG("Unable to open \"%s\" to retrieve keys!", keys_file_path);
|
||||
LOG_MSG_ERROR("Unable to open \"%s\" to retrieve keys!", keys_file_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -951,15 +953,15 @@ static bool keysReadKeysFromFile(void)
|
|||
|
||||
if (key_count)
|
||||
{
|
||||
LOG_MSG("Loaded %u key(s) from \"%s\".", key_count, keys_file_path);
|
||||
LOG_MSG_INFO("Loaded %u key(s) from \"%s\".", key_count, keys_file_path);
|
||||
} else {
|
||||
LOG_MSG("Unable to parse keys from \"%s\"! (keys file empty?).", keys_file_path);
|
||||
LOG_MSG_ERROR("Unable to parse keys from \"%s\"! (keys file empty?).", keys_file_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!eticket_rsa_kek_available)
|
||||
{
|
||||
LOG_MSG("\"eticket_rsa_kek\" unavailable in \"%s\"!", keys_file_path);
|
||||
LOG_MSG_ERROR("\"eticket_rsa_kek\" unavailable in \"%s\"!", keys_file_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -978,7 +980,7 @@ static bool keysGetDecryptedEticketRsaDeviceKey(void)
|
|||
rc = setcalGetEticketDeviceKey(&g_eTicketRsaDeviceKey);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("setcalGetEticketDeviceKey failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("setcalGetEticketDeviceKey failed! (0x%X).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -995,14 +997,14 @@ static bool keysGetDecryptedEticketRsaDeviceKey(void)
|
|||
public_exponent = __builtin_bswap32(eticket_rsa_key->public_exponent);
|
||||
if (public_exponent != ETICKET_RSA_DEVICE_KEY_PUBLIC_EXPONENT)
|
||||
{
|
||||
LOG_MSG("Invalid public exponent for decrypted eTicket RSA device key! Wrong keys? (0x%08X).", public_exponent);
|
||||
LOG_MSG_ERROR("Invalid public exponent for decrypted eTicket RSA device key! Wrong keys? (0x%X).", public_exponent);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Test RSA key pair. */
|
||||
if (!keysTestEticketRsaDeviceKey(&(eticket_rsa_key->public_exponent), eticket_rsa_key->private_exponent, eticket_rsa_key->modulus))
|
||||
{
|
||||
LOG_MSG("eTicket RSA device key test failed! Wrong keys?");
|
||||
LOG_MSG_ERROR("eTicket RSA device key test failed! Wrong keys?");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1013,7 +1015,7 @@ static bool keysTestEticketRsaDeviceKey(const void *e, const void *d, const void
|
|||
{
|
||||
if (!e || !d || !n)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1029,20 +1031,20 @@ static bool keysTestEticketRsaDeviceKey(const void *e, const void *d, const void
|
|||
rc = splUserExpMod(x, n, d, RSA2048_BYTES, y);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("splUserExpMod failed! (#1) (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("splUserExpMod failed! (#1) (0x%X).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = splUserExpMod(y, n, e, 4, z);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("splUserExpMod failed! (#2) (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("splUserExpMod failed! (#2) (0x%X).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (memcmp(x, z, RSA2048_BYTES) != 0)
|
||||
{
|
||||
LOG_MSG("Invalid RSA key pair!");
|
||||
LOG_MSG_ERROR("Invalid RSA key pair!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1057,7 +1059,7 @@ static bool keysDeriveGameCardKeys(void)
|
|||
rc = splCryptoGenerateAesKek(g_gameCardKeyset.gc_cardinfo_kek_source, 0, 0, g_gameCardKeyset.gc_cardinfo_kek_sealed);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("splCryptoGenerateAesKek failed! (0x%08X) (gc_cardinfo_kek_sealed).", rc);
|
||||
LOG_MSG_ERROR("splCryptoGenerateAesKek failed! (0x%X) (gc_cardinfo_kek_sealed).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1065,7 +1067,7 @@ static bool keysDeriveGameCardKeys(void)
|
|||
rc = splCryptoGenerateAesKey(g_gameCardKeyset.gc_cardinfo_kek_sealed, g_gameCardKeyset.gc_cardinfo_key_prod_source, g_gameCardKeyset.gc_cardinfo_key_prod);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("splCryptoGenerateAesKey failed! (0x%08X) (gc_cardinfo_key_prod).", rc);
|
||||
LOG_MSG_ERROR("splCryptoGenerateAesKey failed! (0x%X) (gc_cardinfo_key_prod).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1073,7 +1075,7 @@ static bool keysDeriveGameCardKeys(void)
|
|||
rc = splCryptoGenerateAesKey(g_gameCardKeyset.gc_cardinfo_kek_sealed, g_gameCardKeyset.gc_cardinfo_key_dev_source, g_gameCardKeyset.gc_cardinfo_key_dev);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("splCryptoGenerateAesKey failed! (0x%08X) (gc_cardinfo_key_dev).", rc);
|
||||
LOG_MSG_ERROR("splCryptoGenerateAesKey failed! (0x%X) (gc_cardinfo_key_dev).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ bool legalInfoInitializeContext(LegalInfoContext *out, NcaContext *nca_ctx)
|
|||
(nca_ctx->storage_id != NcmStorageId_GameCard && !nca_ctx->ncm_storage) || (nca_ctx->storage_id == NcmStorageId_GameCard && !nca_ctx->gamecard_offset) || \
|
||||
nca_ctx->header.content_type != NcaContentType_Manual || nca_ctx->content_type_ctx || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -43,23 +43,23 @@ bool legalInfoInitializeContext(LegalInfoContext *out, NcaContext *nca_ctx)
|
|||
/* Initialize RomFS context. */
|
||||
if (!romfsInitializeContext(&romfs_ctx, &(nca_ctx->fs_ctx[0]), NULL))
|
||||
{
|
||||
LOG_MSG("Failed to initialize RomFS context!");
|
||||
LOG_MSG_ERROR("Failed to initialize RomFS context!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Retrieve RomFS file entry for 'legalinfo.xml'. */
|
||||
if (!(xml_entry = romfsGetFileEntryByPath(&romfs_ctx, "/legalinfo.xml")))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve file entry for \"legalinfo.xml\" from RomFS!");
|
||||
LOG_MSG_ERROR("Failed to retrieve file entry for \"legalinfo.xml\" from RomFS!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
//LOG_MSG("Found 'legalinfo.xml' entry in LegalInformation NCA \"%s\".", nca_ctx->content_id_str);
|
||||
LOG_MSG_INFO("Found 'legalinfo.xml' entry in LegalInformation NCA \"%s\".", nca_ctx->content_id_str);
|
||||
|
||||
/* Verify XML size. */
|
||||
if (!xml_entry->size)
|
||||
{
|
||||
LOG_MSG("Invalid XML size!");
|
||||
LOG_MSG_ERROR("Invalid XML size!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -67,14 +67,14 @@ bool legalInfoInitializeContext(LegalInfoContext *out, NcaContext *nca_ctx)
|
|||
out->authoring_tool_xml_size = xml_entry->size;
|
||||
if (!(out->authoring_tool_xml = malloc(out->authoring_tool_xml_size)))
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for the XML!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for the XML!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Read NACP data into memory buffer. */
|
||||
if (!romfsReadFileEntryData(&romfs_ctx, xml_entry, out->authoring_tool_xml, out->authoring_tool_xml_size, 0))
|
||||
{
|
||||
LOG_MSG("Failed to read XML!");
|
||||
LOG_MSG_ERROR("Failed to read XML!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ static bool memRetrieveProgramMemory(MemoryLocation *location, bool is_segment)
|
|||
envIsSyscallHinted(0x69) && /* svcQueryDebugProcessMemory. */
|
||||
envIsSyscallHinted(0x6A))) /* svcReadDebugProcessMemory. */
|
||||
{
|
||||
LOG_MSG("Debug SVC permissions not available!");
|
||||
LOG_MSG_ERROR("Debug SVC permissions not available!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ static bool memRetrieveProgramMemory(MemoryLocation *location, bool is_segment)
|
|||
rc = svcQueryDebugProcessMemory(&mem_info, &page_info, debug_handle, addr);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
MEMLOG_ERROR("svcQueryDebugProcessMemory failed for program %016lX! (0x%08X).", location->program_id, rc);
|
||||
MEMLOG_ERROR("svcQueryDebugProcessMemory failed for program %016lX! (0x%X).", location->program_id, rc);
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ static bool memRetrieveProgramMemory(MemoryLocation *location, bool is_segment)
|
|||
rc = svcReadDebugProcessMemory(location->data + location->data_size, debug_handle, mem_info.addr, mem_info.size);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
MEMLOG_ERROR("svcReadDebugProcessMemory failed for program %016lX! (0x%08X).", location->program_id, rc);
|
||||
MEMLOG_ERROR("svcReadDebugProcessMemory failed for program %016lX! (0x%X).", location->program_id, rc);
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ static bool memRetrieveDebugHandleFromProgramById(Handle *out, u64 program_id)
|
|||
rc = pmdmntGetProcessId(&pid, program_id);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
MEMLOG_ERROR("pmdmntGetProcessId failed for program %016lX! (0x%08X).", program_id, rc);
|
||||
MEMLOG_ERROR("pmdmntGetProcessId failed for program %016lX! (0x%X).", program_id, rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ static bool memRetrieveDebugHandleFromProgramById(Handle *out, u64 program_id)
|
|||
rc = svcDebugActiveProcess(&debug_handle, pid);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
MEMLOG_ERROR("svcDebugActiveProcess failed for program %016lX! (0x%08X).", program_id, rc);
|
||||
MEMLOG_ERROR("svcDebugActiveProcess failed for program %016lX! (0x%X).", program_id, rc);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
@ -276,7 +276,7 @@ static bool memRetrieveDebugHandleFromProgramById(Handle *out, u64 program_id)
|
|||
rc = svcGetProcessList((s32*)&num_processes, pids, 300);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
MEMLOG_ERROR("svcGetProcessList failed! (0x%08X).", rc);
|
||||
MEMLOG_ERROR("svcGetProcessList failed! (0x%X).", rc);
|
||||
free(pids);
|
||||
return false;
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ static bool memRetrieveDebugHandleFromProgramById(Handle *out, u64 program_id)
|
|||
|
||||
if (i == num_processes)
|
||||
{
|
||||
MEMLOG_ERROR("Unable to find program %016lX in kernel process list! (0x%08X).", program_id, rc);
|
||||
MEMLOG_ERROR("Unable to find program %016lX in kernel process list! (0x%X).", program_id, rc);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ bool nacpInitializeContext(NacpContext *out, NcaContext *nca_ctx)
|
|||
(nca_ctx->storage_id != NcmStorageId_GameCard && !nca_ctx->ncm_storage) || (nca_ctx->storage_id == NcmStorageId_GameCard && !nca_ctx->gamecard_offset) || \
|
||||
nca_ctx->header.content_type != NcaContentType_Control || nca_ctx->content_type_ctx || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -250,37 +250,37 @@ bool nacpInitializeContext(NacpContext *out, NcaContext *nca_ctx)
|
|||
/* Initialize RomFS context. */
|
||||
if (!romfsInitializeContext(&(out->romfs_ctx), &(nca_ctx->fs_ctx[0]), NULL))
|
||||
{
|
||||
LOG_MSG("Failed to initialize RomFS context!");
|
||||
LOG_MSG_ERROR("Failed to initialize RomFS context!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Retrieve RomFS file entry for 'control.nacp'. */
|
||||
if (!(out->romfs_file_entry = romfsGetFileEntryByPath(&(out->romfs_ctx), "/control.nacp")))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve file entry for \"control.nacp\" from RomFS!");
|
||||
LOG_MSG_ERROR("Failed to retrieve file entry for \"control.nacp\" from RomFS!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
//LOG_MSG("Found 'control.nacp' entry in Control NCA \"%s\".", nca_ctx->content_id_str);
|
||||
LOG_MSG_INFO("Found 'control.nacp' entry in Control NCA \"%s\".", nca_ctx->content_id_str);
|
||||
|
||||
/* Verify NACP size. */
|
||||
if (out->romfs_file_entry->size != sizeof(_NacpStruct))
|
||||
{
|
||||
LOG_MSG("Invalid NACP size!");
|
||||
LOG_MSG_ERROR("Invalid NACP size!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Allocate memory for the NACP data. */
|
||||
if (!(out->data = malloc(sizeof(_NacpStruct))))
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for the NACP data!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for the NACP data!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Read NACP data into memory buffer. */
|
||||
if (!romfsReadFileEntryData(&(out->romfs_ctx), out->romfs_file_entry, out->data, sizeof(_NacpStruct), 0))
|
||||
{
|
||||
LOG_MSG("Failed to read NACP data!");
|
||||
LOG_MSG_ERROR("Failed to read NACP data!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,7 @@ bool nacpInitializeContext(NacpContext *out, NcaContext *nca_ctx)
|
|||
/* Check if the current language is supported. */
|
||||
if (!nacpCheckBitflagField(&(out->data->supported_language), sizeof(out->data->supported_language) * 8, i))
|
||||
{
|
||||
//LOG_MSG("\"%s\" language not supported (flag 0x%08X, index %u).", language_str, out->data->supported_language, i);
|
||||
LOG_MSG_DEBUG("\"%s\" language not supported (flag 0x%08X, index %u).", language_str, out->data->supported_language, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -308,21 +308,21 @@ bool nacpInitializeContext(NacpContext *out, NcaContext *nca_ctx)
|
|||
/* Retrieve RomFS file entry for this icon. */
|
||||
if (!(icon_entry = romfsGetFileEntryByPath(&(out->romfs_ctx), icon_path)))
|
||||
{
|
||||
//LOG_MSG("\"%s\" file entry not found (flag 0x%08X, index %u).", icon_path, out->data->supported_language, i);
|
||||
LOG_MSG_DEBUG("\"%s\" file entry not found (flag 0x%08X, index %u).", icon_path, out->data->supported_language, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check icon size. */
|
||||
if (!icon_entry->size || icon_entry->size > NACP_MAX_ICON_SIZE)
|
||||
{
|
||||
LOG_MSG("Invalid NACP icon size!");
|
||||
LOG_MSG_ERROR("Invalid NACP icon size!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Reallocate icon context buffer. */
|
||||
if (!(tmp_icon_ctx = realloc(out->icon_ctx, (out->icon_count + 1) * sizeof(NacpIconContext))))
|
||||
{
|
||||
LOG_MSG("Failed to reallocate NACP icon context buffer!");
|
||||
LOG_MSG_ERROR("Failed to reallocate NACP icon context buffer!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -335,14 +335,14 @@ bool nacpInitializeContext(NacpContext *out, NcaContext *nca_ctx)
|
|||
/* Allocate memory for this icon data. */
|
||||
if (!(icon_ctx->icon_data = malloc(icon_entry->size)))
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for NACP icon data!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for NACP icon data!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Read icon data. */
|
||||
if (!romfsReadFileEntryData(&(out->romfs_ctx), icon_entry, icon_ctx->icon_data, icon_entry->size, 0))
|
||||
{
|
||||
LOG_MSG("Failed to read NACP icon data!");
|
||||
LOG_MSG_ERROR("Failed to read NACP icon data!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -373,7 +373,7 @@ bool nacpGenerateNcaPatch(NacpContext *nacp_ctx, bool patch_sua, bool patch_scre
|
|||
{
|
||||
if (!nacpIsValidContext(nacp_ctx))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -404,14 +404,14 @@ bool nacpGenerateNcaPatch(NacpContext *nacp_ctx, bool patch_sua, bool patch_scre
|
|||
sha256CalculateHash(nacp_hash, data, sizeof(_NacpStruct));
|
||||
if (!memcmp(nacp_hash, nacp_ctx->data_hash, sizeof(nacp_hash)))
|
||||
{
|
||||
LOG_MSG("Skipping NACP patching - no flags have changed.");
|
||||
LOG_MSG_INFO("Skipping NACP patching - no flags have changed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Generate RomFS file entry patch. */
|
||||
if (!romfsGenerateFileEntryPatch(&(nacp_ctx->romfs_ctx), nacp_ctx->romfs_file_entry, data, sizeof(_NacpStruct), 0, &(nacp_ctx->nca_patch)))
|
||||
{
|
||||
LOG_MSG("Failed to generate RomFS file entry patch!");
|
||||
LOG_MSG_ERROR("Failed to generate RomFS file entry patch!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,7 @@ void nacpWriteNcaPatch(NacpContext *nacp_ctx, void *buf, u64 buf_size, u64 buf_o
|
|||
if (nca_patch->written)
|
||||
{
|
||||
nca_ctx->content_type_ctx_patch = false;
|
||||
LOG_MSG("NACP RomFS file entry patch successfully written to NCA \"%s\"!", nca_ctx->content_id_str);
|
||||
LOG_MSG_INFO("NACP RomFS file entry patch successfully written to NCA \"%s\"!", nca_ctx->content_id_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -444,7 +444,7 @@ bool nacpGenerateAuthoringToolXml(NacpContext *nacp_ctx, u32 version, u32 requir
|
|||
{
|
||||
if (!nacpIsValidContext(nacp_ctx))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -867,7 +867,7 @@ end:
|
|||
if (!success)
|
||||
{
|
||||
if (xml_buf) free(xml_buf);
|
||||
LOG_MSG("Failed to generate NACP AuthoringTool XML!");
|
||||
LOG_MSG_ERROR("Failed to generate NACP AuthoringTool XML!");
|
||||
}
|
||||
|
||||
return success;
|
||||
|
@ -1023,7 +1023,7 @@ static bool nacpAddStringFieldToAuthoringToolXml(char **xml_buf, u64 *xml_buf_si
|
|||
{
|
||||
if (!xml_buf || !xml_buf_size || !tag_name || !*tag_name || !value)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1034,7 +1034,7 @@ static bool nacpAddEnumFieldToAuthoringToolXml(char **xml_buf, u64 *xml_buf_size
|
|||
{
|
||||
if (!xml_buf || !xml_buf_size || !tag_name || !*tag_name || !str_func)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1050,7 +1050,7 @@ static bool nacpAddBitflagFieldToAuthoringToolXml(char **xml_buf, u64 *xml_buf_s
|
|||
if (!xml_buf || !xml_buf_size || !tag_name || !*tag_name || !flag || !flag_width || (flag_width > 1 && !IS_POWER_OF_TWO(flag_width)) || flag_width > 0x10 || \
|
||||
(flag_bitcount = (flag_width * 8)) < max_flag_idx || !str_func)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1088,7 +1088,7 @@ static bool nacpAddU16FieldToAuthoringToolXml(char **xml_buf, u64 *xml_buf_size,
|
|||
{
|
||||
if (!xml_buf || !xml_buf_size || !tag_name || !*tag_name)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1101,7 +1101,7 @@ static bool nacpAddU32FieldToAuthoringToolXml(char **xml_buf, u64 *xml_buf_size,
|
|||
{
|
||||
if (!xml_buf || !xml_buf_size || !tag_name || !*tag_name)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1114,7 +1114,7 @@ static bool nacpAddU64FieldToAuthoringToolXml(char **xml_buf, u64 *xml_buf_size,
|
|||
{
|
||||
if (!xml_buf || !xml_buf_size || !tag_name || !*tag_name)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ bool ncaInitializeContext(NcaContext *out, u8 storage_id, u8 hfs_partition_type,
|
|||
(storage_id == NcmStorageId_GameCard && (!hfs_partition_type || hfs_partition_type >= GameCardHashFileSystemPartitionType_Count)) || !content_info || \
|
||||
content_info->content_type >= NcmContentType_DeltaFragment)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ bool ncaInitializeContext(NcaContext *out, u8 storage_id, u8 hfs_partition_type,
|
|||
titleConvertNcmContentSizeToU64(content_info->size, &(out->content_size));
|
||||
if (out->content_size < NCA_FULL_HEADER_LENGTH)
|
||||
{
|
||||
LOG_MSG("Invalid size for NCA \"%s\"!", out->content_id_str);
|
||||
LOG_MSG_ERROR("Invalid size for NCA \"%s\"!", out->content_id_str);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ bool ncaInitializeContext(NcaContext *out, u8 storage_id, u8 hfs_partition_type,
|
|||
/* Retrieve gamecard NCA offset. */
|
||||
if (!gamecardGetHashFileSystemEntryInfoByName(hfs_partition_type, nca_filename, &(out->gamecard_offset), NULL))
|
||||
{
|
||||
LOG_MSG("Error retrieving offset for \"%s\" entry in secure hash FS partition!", nca_filename);
|
||||
LOG_MSG_ERROR("Error retrieving offset for \"%s\" entry in secure hash FS partition!", nca_filename);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ bool ncaInitializeContext(NcaContext *out, u8 storage_id, u8 hfs_partition_type,
|
|||
/* Read decrypted NCA header and NCA FS section headers. */
|
||||
if (!ncaReadDecryptedHeader(out))
|
||||
{
|
||||
LOG_MSG("Failed to read decrypted NCA \"%s\" header!", out->content_id_str);
|
||||
LOG_MSG_ERROR("Failed to read decrypted NCA \"%s\" header!", out->content_id_str);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ bool ncaInitializeContext(NcaContext *out, u8 storage_id, u8 hfs_partition_type,
|
|||
memcpy(out->titlekey, usable_tik->dec_titlekey, 0x10);
|
||||
out->titlekey_retrieved = true;
|
||||
} else {
|
||||
LOG_MSG("Error retrieving ticket for NCA \"%s\"!", out->content_id_str);
|
||||
LOG_MSG_ERROR("Error retrieving ticket for NCA \"%s\"!", out->content_id_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ bool ncaInitializeContext(NcaContext *out, u8 storage_id, u8 hfs_partition_type,
|
|||
if (ncaInitializeFsSectionContext(out, i)) valid_fs_section_cnt++;
|
||||
}
|
||||
|
||||
if (!valid_fs_section_cnt) LOG_MSG("Unable to identify any valid FS sections in NCA \"%s\"!", out->content_id_str);
|
||||
if (!valid_fs_section_cnt) LOG_MSG_ERROR("Unable to identify any valid FS sections in NCA \"%s\"!", out->content_id_str);
|
||||
|
||||
return (valid_fs_section_cnt > 0);
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ bool ncaReadContentFile(NcaContext *ctx, void *out, u64 read_size, u64 offset)
|
|||
if (!ctx || !*(ctx->content_id_str) || (ctx->storage_id != NcmStorageId_GameCard && !ctx->ncm_storage) || (ctx->storage_id == NcmStorageId_GameCard && !ctx->gamecard_offset) || !out || \
|
||||
!read_size || (offset + read_size) > ctx->content_size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -198,12 +198,12 @@ bool ncaReadContentFile(NcaContext *ctx, void *out, u64 read_size, u64 offset)
|
|||
/* This strips NAX0 crypto from SD card NCAs (not used on eMMC NCAs). */
|
||||
rc = ncmContentStorageReadContentIdFile(ctx->ncm_storage, out, read_size, &(ctx->content_id), offset);
|
||||
ret = R_SUCCEEDED(rc);
|
||||
if (!ret) LOG_MSG("Failed to read 0x%lX bytes block at offset 0x%lX from NCA \"%s\"! (0x%08X) (ncm).", read_size, offset, ctx->content_id_str, rc);
|
||||
if (!ret) LOG_MSG_ERROR("Failed to read 0x%lX bytes block at offset 0x%lX from NCA \"%s\"! (0x%X) (ncm).", read_size, offset, ctx->content_id_str, rc);
|
||||
} else {
|
||||
/* Retrieve NCA data using raw gamecard reads. */
|
||||
/* Fixes NCA read issues with gamecards under HOS < 4.0.0 when using ncmContentStorageReadContentIdFile(). */
|
||||
ret = gamecardReadStorage(out, read_size, ctx->gamecard_offset + offset);
|
||||
if (!ret) LOG_MSG("Failed to read 0x%lX bytes block at offset 0x%lX from NCA \"%s\"! (gamecard).", read_size, offset, ctx->content_id_str);
|
||||
if (!ret) LOG_MSG_ERROR("Failed to read 0x%lX bytes block at offset 0x%lX from NCA \"%s\"! (gamecard).", read_size, offset, ctx->content_id_str);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -213,7 +213,7 @@ bool ncaGetFsSectionHashTargetExtents(NcaFsSectionContext *ctx, u64 *out_offset,
|
|||
{
|
||||
if (!ctx || (!out_offset && !out_size))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -317,14 +317,14 @@ void ncaSetDownloadDistributionType(NcaContext *ctx)
|
|||
if (!ctx || ctx->content_size < NCA_FULL_HEADER_LENGTH || !*(ctx->content_id_str) || ctx->content_type > NcmContentType_DeltaFragment || \
|
||||
ctx->header.distribution_type == NcaDistributionType_Download) return;
|
||||
ctx->header.distribution_type = NcaDistributionType_Download;
|
||||
LOG_MSG("Set download distribution type to %s NCA \"%s\".", titleGetNcmContentTypeName(ctx->content_type), ctx->content_id_str);
|
||||
LOG_MSG_INFO("Set download distribution type to %s NCA \"%s\".", titleGetNcmContentTypeName(ctx->content_type), ctx->content_id_str);
|
||||
}
|
||||
|
||||
bool ncaRemoveTitleKeyCrypto(NcaContext *ctx)
|
||||
{
|
||||
if (!ctx || ctx->content_size < NCA_FULL_HEADER_LENGTH || !*(ctx->content_id_str) || ctx->content_type > NcmContentType_DeltaFragment)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ bool ncaRemoveTitleKeyCrypto(NcaContext *ctx)
|
|||
/* Encrypt NCA key area. */
|
||||
if (!ncaEncryptKeyArea(ctx))
|
||||
{
|
||||
LOG_MSG("Error encrypting %s NCA \"%s\" key area!", titleGetNcmContentTypeName(ctx->content_type), ctx->content_id_str);
|
||||
LOG_MSG_ERROR("Error encrypting %s NCA \"%s\" key area!", titleGetNcmContentTypeName(ctx->content_type), ctx->content_id_str);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ bool ncaRemoveTitleKeyCrypto(NcaContext *ctx)
|
|||
/* Update context flags. */
|
||||
ctx->rights_id_available = false;
|
||||
|
||||
LOG_MSG("Removed titlekey crypto from %s NCA \"%s\".", titleGetNcmContentTypeName(ctx->content_type), ctx->content_id_str);
|
||||
LOG_MSG_INFO("Removed titlekey crypto from %s NCA \"%s\".", titleGetNcmContentTypeName(ctx->content_type), ctx->content_id_str);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ bool ncaEncryptHeader(NcaContext *ctx)
|
|||
{
|
||||
if (!ctx || !*(ctx->content_id_str) || ctx->content_size < NCA_FULL_HEADER_LENGTH)
|
||||
{
|
||||
LOG_MSG("Invalid NCA context!");
|
||||
LOG_MSG_ERROR("Invalid NCA context!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -371,7 +371,7 @@ bool ncaEncryptHeader(NcaContext *ctx)
|
|||
|
||||
if (!header_key)
|
||||
{
|
||||
LOG_MSG("Failed to retrieve NCA header key!");
|
||||
LOG_MSG_ERROR("Failed to retrieve NCA header key!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -383,7 +383,7 @@ bool ncaEncryptHeader(NcaContext *ctx)
|
|||
crypt_res = aes128XtsNintendoCrypt(&hdr_aes_ctx, &(ctx->encrypted_header), &(ctx->header), sizeof(NcaHeader), 0, NCA_AES_XTS_SECTOR_SIZE, true);
|
||||
if (crypt_res != sizeof(NcaHeader))
|
||||
{
|
||||
LOG_MSG("Error encrypting NCA \"%s\" header!", ctx->content_id_str);
|
||||
LOG_MSG_ERROR("Error encrypting NCA \"%s\" header!", ctx->content_id_str);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -407,7 +407,7 @@ bool ncaEncryptHeader(NcaContext *ctx)
|
|||
crypt_res = aes128XtsNintendoCrypt(aes_xts_ctx, &(fs_ctx->encrypted_header), &(fs_ctx->header), sizeof(NcaFsHeader), sector, NCA_AES_XTS_SECTOR_SIZE, true);
|
||||
if (crypt_res != sizeof(NcaFsHeader))
|
||||
{
|
||||
LOG_MSG("Error encrypting NCA%u \"%s\" FS section header #%u!", ctx->format_version, ctx->content_id_str, i);
|
||||
LOG_MSG_ERROR("Error encrypting NCA%u \"%s\" FS section header #%u!", ctx->format_version, ctx->content_id_str, i);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -498,7 +498,7 @@ static bool ncaReadDecryptedHeader(NcaContext *ctx)
|
|||
{
|
||||
if (!ctx || !*(ctx->content_id_str) || ctx->content_size < NCA_FULL_HEADER_LENGTH)
|
||||
{
|
||||
LOG_MSG("Invalid NCA context!");
|
||||
LOG_MSG_ERROR("Invalid NCA context!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -509,14 +509,14 @@ static bool ncaReadDecryptedHeader(NcaContext *ctx)
|
|||
|
||||
if (!header_key)
|
||||
{
|
||||
LOG_MSG("Failed to retrieve NCA header key!");
|
||||
LOG_MSG_ERROR("Failed to retrieve NCA header key!");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Read NCA header. */
|
||||
if (!ncaReadContentFile(ctx, &(ctx->encrypted_header), sizeof(NcaHeader), 0))
|
||||
{
|
||||
LOG_MSG("Failed to read NCA \"%s\" header!", ctx->content_id_str);
|
||||
LOG_MSG_ERROR("Failed to read NCA \"%s\" header!", ctx->content_id_str);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -529,7 +529,7 @@ static bool ncaReadDecryptedHeader(NcaContext *ctx)
|
|||
|
||||
if (crypt_res != sizeof(NcaHeader) || (magic != NCA_NCA3_MAGIC && magic != NCA_NCA2_MAGIC && magic != NCA_NCA0_MAGIC) || ctx->header.content_size != ctx->content_size)
|
||||
{
|
||||
LOG_MSG("Error decrypting NCA \"%s\" header!", ctx->content_id_str);
|
||||
LOG_MSG_ERROR("Error decrypting NCA \"%s\" header!", ctx->content_id_str);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -543,7 +543,7 @@ static bool ncaReadDecryptedHeader(NcaContext *ctx)
|
|||
/* Decrypt NCA key area (if needed). */
|
||||
if (!ctx->rights_id_available && !ncaDecryptKeyArea(ctx))
|
||||
{
|
||||
LOG_MSG("Error decrypting NCA \"%s\" key area!", ctx->content_id_str);
|
||||
LOG_MSG_ERROR("Error decrypting NCA \"%s\" key area!", ctx->content_id_str);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -564,7 +564,7 @@ static bool ncaReadDecryptedHeader(NcaContext *ctx)
|
|||
u64 fs_header_offset = (ctx->format_version != NcaVersion_Nca0 ? (sizeof(NcaHeader) + (i * sizeof(NcaFsHeader))) : NCA_FS_SECTOR_OFFSET(fs_info->start_sector));
|
||||
if (!ncaReadContentFile(ctx, &(fs_ctx->encrypted_header), sizeof(NcaFsHeader), fs_header_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read NCA%u \"%s\" FS section header #%u at offset 0x%lX!", ctx->format_version, ctx->content_id_str, i, fs_header_offset);
|
||||
LOG_MSG_ERROR("Failed to read NCA%u \"%s\" FS section header #%u at offset 0x%lX!", ctx->format_version, ctx->content_id_str, i, fs_header_offset);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -578,7 +578,7 @@ static bool ncaReadDecryptedHeader(NcaContext *ctx)
|
|||
crypt_res = aes128XtsNintendoCrypt(aes_xts_ctx, &(fs_ctx->header), &(fs_ctx->encrypted_header), sizeof(NcaFsHeader), sector, NCA_AES_XTS_SECTOR_SIZE, false);
|
||||
if (crypt_res != sizeof(NcaFsHeader))
|
||||
{
|
||||
LOG_MSG("Error decrypting NCA%u \"%s\" FS section header #%u!", ctx->format_version, ctx->content_id_str, i);
|
||||
LOG_MSG_ERROR("Error decrypting NCA%u \"%s\" FS section header #%u!", ctx->format_version, ctx->content_id_str, i);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -590,7 +590,7 @@ static bool ncaDecryptKeyArea(NcaContext *ctx)
|
|||
{
|
||||
if (!ctx)
|
||||
{
|
||||
LOG_MSG("Invalid NCA context!");
|
||||
LOG_MSG_ERROR("Invalid NCA context!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -621,7 +621,7 @@ static bool ncaDecryptKeyArea(NcaContext *ctx)
|
|||
/* Decrypt current key area entry. */
|
||||
if (!keysDecryptNcaKeyAreaEntry(ctx->header.kaek_index, ctx->key_generation, dst_key, src_key))
|
||||
{
|
||||
LOG_MSG("Failed to decrypt NCA key area entry #%u!", i);
|
||||
LOG_MSG_ERROR("Failed to decrypt NCA key area entry #%u!", i);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -633,7 +633,7 @@ static bool ncaEncryptKeyArea(NcaContext *ctx)
|
|||
{
|
||||
if (!ctx)
|
||||
{
|
||||
LOG_MSG("Invalid NCA context!");
|
||||
LOG_MSG_ERROR("Invalid NCA context!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -654,7 +654,7 @@ static bool ncaEncryptKeyArea(NcaContext *ctx)
|
|||
kaek = keysGetNcaKeyAreaEncryptionKey(ctx->header.kaek_index, ctx->key_generation);
|
||||
if (!kaek)
|
||||
{
|
||||
LOG_MSG("Unable to retrieve KAEK for KAEK index 0x%02X and key generation 0x%02X!", ctx->header.kaek_index, ctx->key_generation);
|
||||
LOG_MSG_ERROR("Unable to retrieve KAEK for KAEK index 0x%02X and key generation 0x%02X!", ctx->header.kaek_index, ctx->key_generation);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -684,7 +684,7 @@ static bool ncaVerifyMainSignature(NcaContext *ctx)
|
|||
{
|
||||
if (!ctx)
|
||||
{
|
||||
LOG_MSG("Invalid NCA context!");
|
||||
LOG_MSG_ERROR("Invalid NCA context!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -693,8 +693,12 @@ static bool ncaVerifyMainSignature(NcaContext *ctx)
|
|||
if (!modulus) return false;
|
||||
|
||||
/* Verify NCA signature. */
|
||||
return rsa2048VerifySha256BasedPssSignature(&(ctx->header.magic), NCA_SIGNATURE_AREA_SIZE, ctx->header.main_signature, modulus, g_ncaHeaderMainSignaturePublicExponent, \
|
||||
sizeof(g_ncaHeaderMainSignaturePublicExponent));
|
||||
bool ret = rsa2048VerifySha256BasedPssSignature(&(ctx->header.magic), NCA_SIGNATURE_AREA_SIZE, ctx->header.main_signature, modulus, g_ncaHeaderMainSignaturePublicExponent, \
|
||||
sizeof(g_ncaHeaderMainSignaturePublicExponent));
|
||||
|
||||
LOG_MSG_INFO("Header signature for %s NCA \"%s\" is %s.", titleGetNcmContentTypeName(ctx->content_type), ctx->content_id_str, ret ? "valid" : "invalid");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
NX_INLINE bool ncaIsVersion0KeyAreaEncrypted(NcaContext *ctx)
|
||||
|
@ -728,7 +732,7 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx)
|
|||
{
|
||||
if (!nca_ctx || section_idx >= NCA_FS_HEADER_COUNT)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -759,7 +763,7 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx)
|
|||
/* Don't proceed if this NCA FS section isn't populated. */
|
||||
if (!ncaIsFsInfoEntryValid(fs_info))
|
||||
{
|
||||
//LOG_MSG("Invalid FsInfo entry for section #%u in \"%s\". Skipping FS section.", section_idx, nca_ctx->content_id_str);
|
||||
LOG_MSG_INFO("Invalid FsInfo entry for section #%u in \"%s\". Skipping FS section.", section_idx, nca_ctx->content_id_str);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -767,7 +771,7 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx)
|
|||
sha256CalculateHash(fs_header_hash_calc, &(fs_ctx->header), sizeof(NcaFsHeader));
|
||||
if (memcmp(fs_header_hash_calc, fs_header_hash, SHA256_HASH_SIZE) != 0)
|
||||
{
|
||||
LOG_MSG("Checksum mismatch for FS section header #%u in \"%s\". Skipping FS section.", section_idx, nca_ctx->content_id_str);
|
||||
LOG_MSG_ERROR("Checksum mismatch for FS section header #%u in \"%s\". Skipping FS section.", section_idx, nca_ctx->content_id_str);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -778,7 +782,7 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx)
|
|||
/* Check if we're dealing with an invalid start offset or an empty size. */
|
||||
if (fs_ctx->section_offset < sizeof(NcaHeader) || !fs_ctx->section_size)
|
||||
{
|
||||
LOG_MSG("Invalid offset/size for FS section #%u in \"%s\" (0x%lX, 0x%lX). Skipping FS section.", section_idx, nca_ctx->content_id_str, fs_ctx->section_offset, \
|
||||
LOG_MSG_ERROR("Invalid offset/size for FS section #%u in \"%s\" (0x%lX, 0x%lX). Skipping FS section.", section_idx, nca_ctx->content_id_str, fs_ctx->section_offset, \
|
||||
fs_ctx->section_size);
|
||||
goto end;
|
||||
}
|
||||
|
@ -803,7 +807,7 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx)
|
|||
|
||||
if (fs_ctx->hash_type == NcaHashType_Auto || fs_ctx->hash_type == NcaHashType_AutoSha3 || fs_ctx->hash_type > NcaHashType_HierarchicalIntegritySha3)
|
||||
{
|
||||
LOG_MSG("Invalid hash type for FS section #%u in \"%s\" (0x%02X). Skipping FS section.", section_idx, nca_ctx->content_id_str, fs_ctx->hash_type);
|
||||
LOG_MSG_ERROR("Invalid hash type for FS section #%u in \"%s\" (0x%02X). Skipping FS section.", section_idx, nca_ctx->content_id_str, fs_ctx->hash_type);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -827,7 +831,7 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx)
|
|||
|
||||
if (fs_ctx->encryption_type == NcaEncryptionType_Auto || fs_ctx->encryption_type > NcaEncryptionType_AesCtrExSkipLayerHash)
|
||||
{
|
||||
LOG_MSG("Invalid encryption type for FS section #%u in \"%s\" (0x%02X). Skipping FS section.", section_idx, nca_ctx->content_id_str, fs_ctx->encryption_type);
|
||||
LOG_MSG_ERROR("Invalid encryption type for FS section #%u in \"%s\" (0x%02X). Skipping FS section.", section_idx, nca_ctx->content_id_str, fs_ctx->encryption_type);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -840,15 +844,15 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx)
|
|||
|
||||
if (!ncaVerifyBucketInfo(sparse_bucket) || raw_storage_offset < sizeof(NcaHeader) || (raw_storage_offset + raw_storage_size) > nca_ctx->content_size)
|
||||
{
|
||||
LOG_DATA(sparse_info, sizeof(NcaSparseInfo), "Invalid SparseInfo data for FS section #%u in \"%s\" (0x%lX). Skipping FS section. SparseInfo dump:", section_idx, \
|
||||
nca_ctx->content_id_str, nca_ctx->content_size);
|
||||
LOG_DATA_ERROR(sparse_info, sizeof(NcaSparseInfo), "Invalid SparseInfo data for FS section #%u in \"%s\" (0x%lX). Skipping FS section. SparseInfo dump:", section_idx, \
|
||||
nca_ctx->content_id_str, nca_ctx->content_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!raw_storage_size || !sparse_bucket->header.entry_count)
|
||||
{
|
||||
/* Return true but don't set this FS section as enabled, since we can't really use it. */
|
||||
LOG_MSG("Empty SparseInfo data detected for FS section #%u in \"%s\". Skipping FS section.", section_idx, nca_ctx->content_id_str);
|
||||
LOG_MSG_ERROR("Empty SparseInfo data detected for FS section #%u in \"%s\". Skipping FS section.", section_idx, nca_ctx->content_id_str);
|
||||
success = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -861,7 +865,7 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx)
|
|||
/* Check if we're within boundaries. */
|
||||
if ((fs_ctx->section_offset + fs_ctx->section_size) > nca_ctx->content_size)
|
||||
{
|
||||
LOG_MSG("FS section #%u in \"%s\" is out of NCA boundaries. Skipping FS section.", section_idx, nca_ctx->content_id_str);
|
||||
LOG_MSG_ERROR("FS section #%u in \"%s\" is out of NCA boundaries. Skipping FS section.", section_idx, nca_ctx->content_id_str);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -909,8 +913,8 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx)
|
|||
|
||||
if (fs_ctx->section_type >= NcaFsSectionType_Invalid)
|
||||
{
|
||||
LOG_DATA(&(fs_ctx->header), sizeof(NcaFsHeader), "Unable to determine section type for FS section #%u in \"%s\" (0x%02X, 0x%02X). Skipping FS section. FS header dump:", \
|
||||
section_idx, nca_ctx->content_id_str, fs_ctx->hash_type, fs_ctx->encryption_type);
|
||||
LOG_DATA_ERROR(&(fs_ctx->header), sizeof(NcaFsHeader), "Unable to determine section type for FS section #%u in \"%s\" (0x%02X, 0x%02X). Skipping FS section. FS header dump:", \
|
||||
section_idx, nca_ctx->content_id_str, fs_ctx->hash_type, fs_ctx->encryption_type);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -921,14 +925,14 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx)
|
|||
fs_ctx->hash_region.offset = 0;
|
||||
if (!ncaGetFsSectionHashTargetExtents(fs_ctx, &(fs_ctx->hash_region.size), NULL))
|
||||
{
|
||||
LOG_MSG("Invalid hash type for FS section #%u in \"%s\" (0x%02X). Skipping FS section.", fs_ctx->section_idx, nca_ctx->content_id_str, fs_ctx->hash_type);
|
||||
LOG_MSG_ERROR("Invalid hash type for FS section #%u in \"%s\" (0x%02X). Skipping FS section.", fs_ctx->section_idx, nca_ctx->content_id_str, fs_ctx->hash_type);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Check if we're within boundaries. */
|
||||
if (fs_ctx->hash_region.size > fs_ctx->section_size || (fs_ctx->section_offset + fs_ctx->hash_region.size) > nca_ctx->content_size)
|
||||
{
|
||||
LOG_MSG("Hash layer region for FS section #%u in \"%s\" is out of NCA boundaries. Skipping FS section.", section_idx, nca_ctx->content_id_str);
|
||||
LOG_MSG_ERROR("Hash layer region for FS section #%u in \"%s\" is out of NCA boundaries. Skipping FS section.", section_idx, nca_ctx->content_id_str);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -936,7 +940,7 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx)
|
|||
fs_ctx->skip_hash_layer_crypto = (fs_ctx->encryption_type == NcaEncryptionType_AesCtrSkipLayerHash || fs_ctx->encryption_type == NcaEncryptionType_AesCtrExSkipLayerHash);
|
||||
if (fs_ctx->skip_hash_layer_crypto && fs_ctx->hash_type == NcaHashType_None)
|
||||
{
|
||||
LOG_MSG("NcaHashType_None used with SkipLayerHash crypto for FS section #%u in \"%s\". Skipping FS section.", section_idx, nca_ctx->content_id_str);
|
||||
LOG_MSG_ERROR("NcaHashType_None used with SkipLayerHash crypto for FS section #%u in \"%s\". Skipping FS section.", section_idx, nca_ctx->content_id_str);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -951,7 +955,7 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx)
|
|||
/* Get target hash layer offset. */
|
||||
if (!ncaGetFsSectionHashTargetExtents(fs_ctx, &raw_storage_offset, NULL))
|
||||
{
|
||||
LOG_MSG("Invalid hash type for FS section #%u in \"%s\" (0x%02X). Skipping FS section.", fs_ctx->section_idx, nca_ctx->content_id_str, fs_ctx->hash_type);
|
||||
LOG_MSG_ERROR("Invalid hash type for FS section #%u in \"%s\" (0x%02X). Skipping FS section.", fs_ctx->section_idx, nca_ctx->content_id_str, fs_ctx->hash_type);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -963,8 +967,8 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx)
|
|||
if (!ncaVerifyBucketInfo(compression_bucket) || !compression_bucket->header.entry_count || (raw_storage_offset && (raw_storage_offset < sizeof(NcaHeader) || \
|
||||
(raw_storage_offset + raw_storage_size) > fs_ctx->section_size || (fs_ctx->section_offset + raw_storage_offset + raw_storage_size) > nca_ctx->content_size)))
|
||||
{
|
||||
LOG_DATA(compression_bucket, sizeof(NcaBucketInfo), "Invalid CompressionInfo data for FS section #%u in \"%s\" (0x%lX). Skipping FS section. CompressionInfo dump:", \
|
||||
section_idx, nca_ctx->content_id_str, nca_ctx->content_size);
|
||||
LOG_DATA_ERROR(compression_bucket, sizeof(NcaBucketInfo), "Invalid CompressionInfo data for FS section #%u in \"%s\" (0x%lX). Skipping FS section. CompressionInfo dump:", \
|
||||
section_idx, nca_ctx->content_id_str, nca_ctx->content_size);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1095,7 +1099,7 @@ static bool _ncaReadFsSection(NcaFsSectionContext *ctx, void *out, u64 read_size
|
|||
ctx->section_type >= NcaFsSectionType_Invalid || ctx->encryption_type == NcaEncryptionType_Auto || ctx->encryption_type > NcaEncryptionType_AesCtrExSkipLayerHash || \
|
||||
!out || !read_size || (offset + read_size) > ctx->section_size)
|
||||
{
|
||||
LOG_MSG("Invalid NCA FS section header parameters!");
|
||||
LOG_MSG_ERROR("Invalid NCA FS section header parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1118,7 +1122,7 @@ static bool _ncaReadFsSection(NcaFsSectionContext *ctx, void *out, u64 read_size
|
|||
(nca_ctx->format_version != NcaVersion_Nca0 && nca_ctx->format_version != NcaVersion_Nca2 && nca_ctx->format_version != NcaVersion_Nca3) || \
|
||||
(content_offset + read_size) > nca_ctx->content_size)
|
||||
{
|
||||
LOG_MSG("Invalid NCA header parameters!");
|
||||
LOG_MSG_ERROR("Invalid NCA header parameters!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1128,7 +1132,7 @@ static bool _ncaReadFsSection(NcaFsSectionContext *ctx, void *out, u64 read_size
|
|||
/* Read plaintext area. Use NCA-relative offset. */
|
||||
if (!ncaReadContentFile(nca_ctx, out, block_size, content_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (plaintext hash region) (#1).", block_size, content_offset, \
|
||||
LOG_MSG_ERROR("Failed to read 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (plaintext hash region) (#1).", block_size, content_offset, \
|
||||
nca_ctx->content_id_str, ctx->section_idx);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1149,7 +1153,7 @@ static bool _ncaReadFsSection(NcaFsSectionContext *ctx, void *out, u64 read_size
|
|||
|
||||
/* Read remaining plaintext data. Use NCA-relative offset. */
|
||||
ret = ncaReadContentFile(nca_ctx, (u8*)out + block_size, read_size, content_offset);
|
||||
if (!ret) LOG_MSG("Failed to read 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (plaintext hash region) (#2).", read_size, content_offset, \
|
||||
if (!ret) LOG_MSG_ERROR("Failed to read 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (plaintext hash region) (#2).", read_size, content_offset, \
|
||||
nca_ctx->content_id_str, ctx->section_idx);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1162,7 +1166,7 @@ static bool _ncaReadFsSection(NcaFsSectionContext *ctx, void *out, u64 read_size
|
|||
/* Read data. */
|
||||
if (!ncaReadContentFile(nca_ctx, out, read_size, content_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (aligned).", read_size, content_offset, nca_ctx->content_id_str, ctx->section_idx);
|
||||
LOG_MSG_ERROR("Failed to read 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (aligned).", read_size, content_offset, nca_ctx->content_id_str, ctx->section_idx);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1181,7 +1185,7 @@ static bool _ncaReadFsSection(NcaFsSectionContext *ctx, void *out, u64 read_size
|
|||
crypt_res = aes128XtsNintendoCrypt(&(ctx->xts_decrypt_ctx), out, out, read_size, sector_num, NCA_AES_XTS_SECTOR_SIZE, false);
|
||||
if (crypt_res != read_size)
|
||||
{
|
||||
LOG_MSG("Failed to AES-XTS decrypt 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (aligned).", read_size, content_offset, nca_ctx->content_id_str, \
|
||||
LOG_MSG_ERROR("Failed to AES-XTS decrypt 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (aligned).", read_size, content_offset, nca_ctx->content_id_str, \
|
||||
ctx->section_idx);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1209,7 +1213,7 @@ static bool _ncaReadFsSection(NcaFsSectionContext *ctx, void *out, u64 read_size
|
|||
/* Read data. */
|
||||
if (!ncaReadContentFile(nca_ctx, g_ncaCryptoBuffer, chunk_size, block_start_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%lX bytes encrypted data block at offset 0x%lX from NCA \"%s\" FS section #%u! (unaligned).", chunk_size, block_start_offset, nca_ctx->content_id_str, \
|
||||
LOG_MSG_ERROR("Failed to read 0x%lX bytes encrypted data block at offset 0x%lX from NCA \"%s\" FS section #%u! (unaligned).", chunk_size, block_start_offset, nca_ctx->content_id_str, \
|
||||
ctx->section_idx);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1222,7 +1226,7 @@ static bool _ncaReadFsSection(NcaFsSectionContext *ctx, void *out, u64 read_size
|
|||
crypt_res = aes128XtsNintendoCrypt(&(ctx->xts_decrypt_ctx), g_ncaCryptoBuffer, g_ncaCryptoBuffer, chunk_size, sector_num, NCA_AES_XTS_SECTOR_SIZE, false);
|
||||
if (crypt_res != chunk_size)
|
||||
{
|
||||
LOG_MSG("Failed to AES-XTS decrypt 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (unaligned).", chunk_size, block_start_offset, nca_ctx->content_id_str, \
|
||||
LOG_MSG_ERROR("Failed to AES-XTS decrypt 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (unaligned).", chunk_size, block_start_offset, nca_ctx->content_id_str, \
|
||||
ctx->section_idx);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1282,7 +1286,7 @@ static bool _ncaReadAesCtrExStorage(NcaFsSectionContext *ctx, void *out, u64 rea
|
|||
ctx->section_type != NcaFsSectionType_PatchRomFs || (ctx->encryption_type != NcaEncryptionType_None && ctx->encryption_type != NcaEncryptionType_AesCtrEx && \
|
||||
ctx->encryption_type != NcaEncryptionType_AesCtrExSkipLayerHash) || !out || !read_size || (offset + read_size) > ctx->section_size)
|
||||
{
|
||||
LOG_MSG("Invalid NCA FS section header parameters!");
|
||||
LOG_MSG_ERROR("Invalid NCA FS section header parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1297,7 +1301,7 @@ static bool _ncaReadAesCtrExStorage(NcaFsSectionContext *ctx, void *out, u64 rea
|
|||
if (!*(nca_ctx->content_id_str) || (nca_ctx->storage_id != NcmStorageId_GameCard && !nca_ctx->ncm_storage) || (nca_ctx->storage_id == NcmStorageId_GameCard && !nca_ctx->gamecard_offset) || \
|
||||
(content_offset + read_size) > nca_ctx->content_size)
|
||||
{
|
||||
LOG_MSG("Invalid NCA header parameters!");
|
||||
LOG_MSG_ERROR("Invalid NCA header parameters!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1307,7 +1311,7 @@ static bool _ncaReadAesCtrExStorage(NcaFsSectionContext *ctx, void *out, u64 rea
|
|||
/* Read data. */
|
||||
if (!ncaReadContentFile(nca_ctx, out, read_size, content_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (aligned).", read_size, content_offset, nca_ctx->content_id_str, ctx->section_idx);
|
||||
LOG_MSG_ERROR("Failed to read 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (aligned).", read_size, content_offset, nca_ctx->content_id_str, ctx->section_idx);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1335,7 +1339,7 @@ static bool _ncaReadAesCtrExStorage(NcaFsSectionContext *ctx, void *out, u64 rea
|
|||
/* Read data. */
|
||||
if (!ncaReadContentFile(nca_ctx, g_ncaCryptoBuffer, chunk_size, block_start_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%lX bytes encrypted data block at offset 0x%lX from NCA \"%s\" FS section #%u! (unaligned).", chunk_size, block_start_offset, nca_ctx->content_id_str, \
|
||||
LOG_MSG_ERROR("Failed to read 0x%lX bytes encrypted data block at offset 0x%lX from NCA \"%s\" FS section #%u! (unaligned).", chunk_size, block_start_offset, nca_ctx->content_id_str, \
|
||||
ctx->section_idx);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1391,7 +1395,7 @@ static bool ncaGenerateHashDataPatch(NcaFsSectionContext *ctx, const void *data,
|
|||
(data_offset + data_size) > last_layer_size || !out || ctx->encryption_type == NcaEncryptionType_Auto || ctx->encryption_type == NcaEncryptionType_AesCtrEx || \
|
||||
ctx->encryption_type >= NcaEncryptionType_AesCtrExSkipLayerHash)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1444,7 +1448,7 @@ static bool ncaGenerateHashDataPatch(NcaFsSectionContext *ctx, const void *data,
|
|||
if (hash_block_size <= 1 || !cur_layer_size || (cur_layer_offset + cur_layer_size) > ctx->section_size || (i > 1 && (!parent_layer_size || \
|
||||
(parent_layer_offset + parent_layer_size) > ctx->section_size)))
|
||||
{
|
||||
LOG_MSG("Invalid hierarchical parent/child layer!");
|
||||
LOG_MSG_ERROR("Invalid hierarchical parent/child layer! (%u).", i - 1);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1475,7 +1479,7 @@ static bool ncaGenerateHashDataPatch(NcaFsSectionContext *ctx, const void *data,
|
|||
cur_layer_block = calloc(cur_layer_read_size, sizeof(u8));
|
||||
if (!cur_layer_block)
|
||||
{
|
||||
LOG_MSG("Unable to allocate 0x%lX bytes for hierarchical layer #%u data block! (current).", cur_layer_read_size, i - 1);
|
||||
LOG_MSG_ERROR("Unable to allocate 0x%lX bytes for hierarchical layer #%u data block! (current).", cur_layer_read_size, i - 1);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1489,7 +1493,7 @@ static bool ncaGenerateHashDataPatch(NcaFsSectionContext *ctx, const void *data,
|
|||
/* Read current layer block. */
|
||||
if (!_ncaReadFsSection(ctx, cur_layer_block, cur_layer_read_size, cur_layer_read_start_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%lX bytes long hierarchical layer #%u data block from offset 0x%lX! (current).", cur_layer_read_size, i - 1, cur_layer_read_start_offset);
|
||||
LOG_MSG_ERROR("Failed to read 0x%lX bytes long hierarchical layer #%u data block from offset 0x%lX! (current).", cur_layer_read_size, i - 1, cur_layer_read_start_offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1503,14 +1507,14 @@ static bool ncaGenerateHashDataPatch(NcaFsSectionContext *ctx, const void *data,
|
|||
parent_layer_block = calloc(parent_layer_read_size, sizeof(u8));
|
||||
if (!parent_layer_block)
|
||||
{
|
||||
LOG_MSG("Unable to allocate 0x%lX bytes for hierarchical layer #%u data block! (parent).", parent_layer_read_size, i - 2);
|
||||
LOG_MSG_ERROR("Unable to allocate 0x%lX bytes for hierarchical layer #%u data block! (parent).", parent_layer_read_size, i - 2);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Read parent layer block. */
|
||||
if (!_ncaReadFsSection(ctx, parent_layer_block, parent_layer_read_size, parent_layer_offset + parent_layer_read_start_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%lX bytes long hierarchical layer #%u data block from offset 0x%lX! (parent).", parent_layer_read_size, i - 2, parent_layer_read_start_offset);
|
||||
LOG_MSG_ERROR("Failed to read 0x%lX bytes long hierarchical layer #%u data block from offset 0x%lX! (parent).", parent_layer_read_size, i - 2, parent_layer_read_start_offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1535,7 +1539,7 @@ static bool ncaGenerateHashDataPatch(NcaFsSectionContext *ctx, const void *data,
|
|||
&(cur_layer_patch->size), &(cur_layer_patch->offset));
|
||||
if (!cur_layer_patch->data)
|
||||
{
|
||||
LOG_MSG("Failed to generate encrypted 0x%lX bytes long hierarchical layer #%u data block!", cur_data_size, i - 1);
|
||||
LOG_MSG_ERROR("Failed to generate encrypted 0x%lX bytes long hierarchical layer #%u data block!", cur_data_size, i - 1);
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
|
@ -1543,7 +1547,7 @@ static bool ncaGenerateHashDataPatch(NcaFsSectionContext *ctx, const void *data,
|
|||
cur_layer_patch->data = malloc(cur_data_size);
|
||||
if (!cur_layer_patch->data)
|
||||
{
|
||||
LOG_MSG("Failed to allocate 0x%lX bytes long buffer for hierarchical layer #%u data block!", cur_data_size, i - 1);
|
||||
LOG_MSG_ERROR("Failed to allocate 0x%lX bytes long buffer for hierarchical layer #%u data block!", cur_data_size, i - 1);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1615,8 +1619,8 @@ static bool ncaWritePatchToMemoryBuffer(NcaContext *ctx, const void *patch, u64
|
|||
|
||||
memcpy((u8*)buf + buf_block_offset, (const u8*)patch + patch_block_offset, buf_block_size);
|
||||
|
||||
LOG_MSG("Overwrote 0x%lX bytes block at offset 0x%lX from raw %s NCA \"%s\" buffer (size 0x%lX, NCA offset 0x%lX).", buf_block_size, buf_block_offset, titleGetNcmContentTypeName(ctx->content_type), \
|
||||
ctx->content_id_str, buf_size, buf_offset);
|
||||
LOG_MSG_INFO("Overwrote 0x%lX bytes block at offset 0x%lX from raw %s NCA \"%s\" buffer (size 0x%lX, NCA offset 0x%lX).", buf_block_size, buf_block_offset, titleGetNcmContentTypeName(ctx->content_type), \
|
||||
ctx->content_id_str, buf_size, buf_offset);
|
||||
|
||||
return ((patch_block_offset + buf_block_size) == patch_size);
|
||||
}
|
||||
|
@ -1636,7 +1640,7 @@ static void *ncaGenerateEncryptedFsSectionBlock(NcaFsSectionContext *ctx, const
|
|||
ctx->encryption_type == NcaEncryptionType_Auto || ctx->encryption_type == NcaEncryptionType_AesCtrEx || ctx->encryption_type >= NcaEncryptionType_AesCtrExSkipLayerHash || \
|
||||
ctx->section_type >= NcaFsSectionType_Invalid || !data || !data_size || (data_offset + data_size) > ctx->section_size || !out_block_size || !out_block_offset)
|
||||
{
|
||||
LOG_MSG("Invalid NCA FS section header parameters!");
|
||||
LOG_MSG_ERROR("Invalid NCA FS section header parameters!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1652,7 +1656,7 @@ static void *ncaGenerateEncryptedFsSectionBlock(NcaFsSectionContext *ctx, const
|
|||
if (!*(nca_ctx->content_id_str) || (nca_ctx->storage_id != NcmStorageId_GameCard && !nca_ctx->ncm_storage) || (nca_ctx->storage_id == NcmStorageId_GameCard && !nca_ctx->gamecard_offset) || \
|
||||
(nca_ctx->format_version != NcaVersion_Nca0 && nca_ctx->format_version != NcaVersion_Nca2 && nca_ctx->format_version != NcaVersion_Nca3) || (content_offset + data_size) > nca_ctx->content_size)
|
||||
{
|
||||
LOG_MSG("Invalid NCA header parameters!");
|
||||
LOG_MSG_ERROR("Invalid NCA header parameters!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1665,7 +1669,7 @@ static void *ncaGenerateEncryptedFsSectionBlock(NcaFsSectionContext *ctx, const
|
|||
out = malloc(data_size);
|
||||
if (!out)
|
||||
{
|
||||
LOG_MSG("Unable to allocate 0x%lX bytes buffer! (aligned).", data_size);
|
||||
LOG_MSG_ERROR("Unable to allocate 0x%lX bytes buffer! (aligned).", data_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1680,7 +1684,7 @@ static void *ncaGenerateEncryptedFsSectionBlock(NcaFsSectionContext *ctx, const
|
|||
crypt_res = aes128XtsNintendoCrypt(&(ctx->xts_encrypt_ctx), out, out, data_size, sector_num, NCA_AES_XTS_SECTOR_SIZE, true);
|
||||
if (crypt_res != data_size)
|
||||
{
|
||||
LOG_MSG("Failed to AES-XTS encrypt 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (aligned).", data_size, content_offset, nca_ctx->content_id_str, ctx->section_idx);
|
||||
LOG_MSG_ERROR("Failed to AES-XTS encrypt 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (aligned).", data_size, content_offset, nca_ctx->content_id_str, ctx->section_idx);
|
||||
goto end;
|
||||
}
|
||||
} else
|
||||
|
@ -1710,14 +1714,14 @@ static void *ncaGenerateEncryptedFsSectionBlock(NcaFsSectionContext *ctx, const
|
|||
out = malloc(block_size);
|
||||
if (!out)
|
||||
{
|
||||
LOG_MSG("Unable to allocate 0x%lX bytes buffer! (unaligned).", block_size);
|
||||
LOG_MSG_ERROR("Unable to allocate 0x%lX bytes buffer! (unaligned).", block_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Read decrypted data using aligned offset and size. */
|
||||
if (!_ncaReadFsSection(ctx, out, block_size, block_start_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read decrypted NCA \"%s\" FS section #%u data block!", nca_ctx->content_id_str, ctx->section_idx);
|
||||
LOG_MSG_ERROR("Failed to read decrypted NCA \"%s\" FS section #%u data block!", nca_ctx->content_id_str, ctx->section_idx);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1732,7 +1736,7 @@ static void *ncaGenerateEncryptedFsSectionBlock(NcaFsSectionContext *ctx, const
|
|||
crypt_res = aes128XtsNintendoCrypt(&(ctx->xts_encrypt_ctx), out, out, block_size, sector_num, NCA_AES_XTS_SECTOR_SIZE, true);
|
||||
if (crypt_res != block_size)
|
||||
{
|
||||
LOG_MSG("Failed to AES-XTS encrypt 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (aligned).", block_size, content_offset, nca_ctx->content_id_str, ctx->section_idx);
|
||||
LOG_MSG_ERROR("Failed to AES-XTS encrypt 0x%lX bytes data block at offset 0x%lX from NCA \"%s\" FS section #%u! (aligned).", block_size, content_offset, nca_ctx->content_id_str, ctx->section_idx);
|
||||
goto end;
|
||||
}
|
||||
} else
|
||||
|
|
|
@ -32,7 +32,7 @@ bool ncaStorageInitializeContext(NcaStorageContext *out, NcaFsSectionContext *nc
|
|||
if (!out || !nca_fs_ctx || !nca_fs_ctx->enabled || (nca_fs_ctx->section_type == NcaFsSectionType_PatchRomFs && \
|
||||
(!nca_fs_ctx->has_patch_indirect_layer || !nca_fs_ctx->has_patch_aes_ctr_ex_layer || nca_fs_ctx->has_sparse_layer)))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ bool ncaStorageSetPatchOriginalSubStorage(NcaStorageContext *patch_ctx, NcaStora
|
|||
(patch_ctx->base_storage_type != NcaStorageBaseStorageType_Indirect && patch_ctx->base_storage_type != NcaStorageBaseStorageType_Compressed) || \
|
||||
!patch_ctx->indirect_storage || !patch_ctx->aes_ctr_ex_storage)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ bool ncaStorageSetPatchOriginalSubStorage(NcaStorageContext *patch_ctx, NcaStora
|
|||
break;
|
||||
}
|
||||
|
||||
if (!success) LOG_MSG("Failed to set base storage to patch storage!");
|
||||
if (!success) LOG_MSG_ERROR("Failed to set base storage to patch storage!");
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ bool ncaStorageGetHashTargetExtents(NcaStorageContext *ctx, u64 *out_offset, u64
|
|||
{
|
||||
if (!ncaStorageIsValidContext(ctx) || (!out_offset && !out_size))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ bool ncaStorageGetHashTargetExtents(NcaStorageContext *ctx, u64 *out_offset, u64
|
|||
/* Get hash target extents from the NCA FS section. */
|
||||
if (!ncaGetFsSectionHashTargetExtents(ctx->nca_fs_ctx, &hash_target_offset, &hash_target_size))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve NCA FS section's hash target extents!");
|
||||
LOG_MSG_ERROR("Failed to retrieve NCA FS section's hash target extents!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ bool ncaStorageRead(NcaStorageContext *ctx, void *out, u64 read_size, u64 offset
|
|||
{
|
||||
if (!ncaStorageIsValidContext(ctx) || !out || !read_size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ bool ncaStorageRead(NcaStorageContext *ctx, void *out, u64 read_size, u64 offset
|
|||
break;
|
||||
}
|
||||
|
||||
if (!success) LOG_MSG("Failed to read 0x%lX-byte long block from offset 0x%lX in base storage! (type: %u).", read_size, offset, ctx->base_storage_type);
|
||||
if (!success) LOG_MSG_ERROR("Failed to read 0x%lX-byte long block from offset 0x%lX in base storage! (type: %u).", read_size, offset, ctx->base_storage_type);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ bool ncaStorageIsBlockWithinPatchStorageRange(NcaStorageContext *ctx, u64 offset
|
|||
ctx->base_storage_type != NcaStorageBaseStorageType_Compressed) || (ctx->base_storage_type == NcaStorageBaseStorageType_Indirect && !ctx->indirect_storage) || \
|
||||
(ctx->base_storage_type == NcaStorageBaseStorageType_Compressed && !ctx->compressed_storage))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ bool ncaStorageIsBlockWithinPatchStorageRange(NcaStorageContext *ctx, u64 offset
|
|||
|
||||
/* Check if the provided block extents are within the Indirect Storage's range. */
|
||||
bool success = bktrIsBlockWithinIndirectStorageRange(bktr_ctx, offset, size, out);
|
||||
if (!success) LOG_MSG("Failed to determine if block extents are within the Indirect Storage's range!");
|
||||
if (!success) LOG_MSG_ERROR("Failed to determine if block extents are within the Indirect Storage's range!");
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ static bool ncaStorageInitializeBucketTreeContext(BucketTreeContext **out, NcaFs
|
|||
{
|
||||
if (!out || !nca_fs_ctx || storage_type >= BucketTreeStorageType_Count)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ static bool ncaStorageInitializeBucketTreeContext(BucketTreeContext **out, NcaFs
|
|||
bktr_ctx = calloc(1, sizeof(BucketTreeContext));
|
||||
if (!bktr_ctx)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for Bucket Tree context! (%u).", storage_type);
|
||||
LOG_MSG_ERROR("Unable to allocate memory for Bucket Tree context! (%u).", storage_type);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ static bool ncaStorageInitializeBucketTreeContext(BucketTreeContext **out, NcaFs
|
|||
success = bktrInitializeContext(bktr_ctx, nca_fs_ctx, storage_type);
|
||||
if (!success)
|
||||
{
|
||||
LOG_MSG("Failed to initialize Bucket Tree context! (%u).", storage_type);
|
||||
LOG_MSG_ERROR("Failed to initialize Bucket Tree context! (%u).", storage_type);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ static bool ncaStorageInitializeCompressedStorageBucketTreeContext(NcaStorageCon
|
|||
!nca_fs_ctx->has_compression_layer || (out->base_storage_type == NcaStorageBaseStorageType_Sparse && !out->sparse_storage) || \
|
||||
(out->base_storage_type == NcaStorageBaseStorageType_Indirect && !out->indirect_storage))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -327,7 +327,7 @@ static bool ncaStorageInitializeCompressedStorageBucketTreeContext(NcaStorageCon
|
|||
bktr_ctx = calloc(1, sizeof(BucketTreeContext));
|
||||
if (!bktr_ctx)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for Bucket Tree context!");
|
||||
LOG_MSG_ERROR("Unable to allocate memory for Bucket Tree context!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ static bool ncaStorageInitializeCompressedStorageBucketTreeContext(NcaStorageCon
|
|||
success = bktrInitializeCompressedStorageContext(bktr_ctx, &bktr_substorage);
|
||||
if (!success)
|
||||
{
|
||||
LOG_MSG("Failed to initialize Bucket Tree context!");
|
||||
LOG_MSG_ERROR("Failed to initialize Bucket Tree context!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
nca_ctx->content_type != NcmContentType_Program || !pfs_ctx->offset || !pfs_ctx->size || !pfs_ctx->is_exefs || \
|
||||
pfs_ctx->header_size <= sizeof(PartitionFileSystemHeader) || !pfs_ctx->header)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -44,16 +44,16 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
/* Get 'main.npdm' file entry. */
|
||||
if (!(pfs_entry = pfsGetEntryByName(pfs_ctx, "main.npdm")))
|
||||
{
|
||||
LOG_MSG("'main.npdm' entry unavailable in ExeFS!");
|
||||
LOG_MSG_ERROR("'main.npdm' entry unavailable in ExeFS!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
//LOG_MSG("Found 'main.npdm' entry in Program NCA \"%s\".", nca_ctx->content_id_str);
|
||||
LOG_MSG_INFO("Found 'main.npdm' entry in Program NCA \"%s\".", nca_ctx->content_id_str);
|
||||
|
||||
/* Check raw NPDM size. */
|
||||
if (!pfs_entry->size)
|
||||
{
|
||||
LOG_MSG("Invalid raw NPDM size!");
|
||||
LOG_MSG_ERROR("Invalid raw NPDM size!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -61,14 +61,14 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
out->raw_data_size = pfs_entry->size;
|
||||
if (!(out->raw_data = malloc(out->raw_data_size)))
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for the raw NPDM data!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for the raw NPDM data!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Read raw NPDM data into memory buffer. */
|
||||
if (!pfsReadEntryData(pfs_ctx, pfs_entry, out->raw_data, out->raw_data_size, 0))
|
||||
{
|
||||
LOG_MSG("Failed to read raw NPDM data!");
|
||||
LOG_MSG_ERROR("Failed to read raw NPDM data!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
|
||||
if (__builtin_bswap32(out->meta_header->magic) != NPDM_META_MAGIC)
|
||||
{
|
||||
LOG_MSG("Invalid meta header magic word! (0x%08X != 0x%08X).", __builtin_bswap32(out->meta_header->magic), __builtin_bswap32(NPDM_META_MAGIC));
|
||||
LOG_MSG_ERROR("Invalid meta header magic word! (0x%08X != 0x%08X).", __builtin_bswap32(out->meta_header->magic), __builtin_bswap32(NPDM_META_MAGIC));
|
||||
dump_meta_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -86,49 +86,49 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
if (!out->meta_header->flags.is_64bit_instruction && (out->meta_header->flags.process_address_space == NpdmProcessAddressSpace_AddressSpace64BitOld || \
|
||||
out->meta_header->flags.process_address_space == NpdmProcessAddressSpace_AddressSpace64Bit))
|
||||
{
|
||||
LOG_MSG("Invalid meta header flags! (0x%02X).", *((u8*)&(out->meta_header->flags)));
|
||||
LOG_MSG_ERROR("Invalid meta header flags! (0x%02X).", *((u8*)&(out->meta_header->flags)));
|
||||
dump_meta_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out->meta_header->main_thread_priority > NPDM_MAIN_THREAD_MAX_PRIORITY)
|
||||
{
|
||||
LOG_MSG("Invalid main thread priority! (0x%02X).", out->meta_header->main_thread_priority);
|
||||
LOG_MSG_ERROR("Invalid main thread priority! (0x%02X).", out->meta_header->main_thread_priority);
|
||||
dump_meta_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out->meta_header->main_thread_core_number > NPDM_MAIN_THREAD_MAX_CORE_NUMBER)
|
||||
{
|
||||
LOG_MSG("Invalid main thread core number! (%u).", out->meta_header->main_thread_core_number);
|
||||
LOG_MSG_ERROR("Invalid main thread core number! (%u).", out->meta_header->main_thread_core_number);
|
||||
dump_meta_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out->meta_header->system_resource_size > NPDM_SYSTEM_RESOURCE_MAX_SIZE)
|
||||
{
|
||||
LOG_MSG("Invalid system resource size! (0x%08X).", out->meta_header->system_resource_size);
|
||||
LOG_MSG_ERROR("Invalid system resource size! (0x%X).", out->meta_header->system_resource_size);
|
||||
dump_meta_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!IS_ALIGNED(out->meta_header->main_thread_stack_size, NPDM_MAIN_THREAD_STACK_SIZE_ALIGNMENT))
|
||||
{
|
||||
LOG_MSG("Invalid main thread stack size! (0x%08X).", out->meta_header->main_thread_stack_size);
|
||||
LOG_MSG_ERROR("Invalid main thread stack size! (0x%X).", out->meta_header->main_thread_stack_size);
|
||||
dump_meta_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out->meta_header->aci_offset < sizeof(NpdmMetaHeader) || out->meta_header->aci_size < sizeof(NpdmAciHeader) || (out->meta_header->aci_offset + out->meta_header->aci_size) > out->raw_data_size)
|
||||
{
|
||||
LOG_MSG("Invalid ACI0 offset/size! (0x%08X, 0x%08X).", out->meta_header->aci_offset, out->meta_header->aci_size);
|
||||
LOG_MSG_ERROR("Invalid ACI0 offset/size! (0x%X, 0x%X).", out->meta_header->aci_offset, out->meta_header->aci_size);
|
||||
dump_meta_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out->meta_header->acid_offset < sizeof(NpdmMetaHeader) || out->meta_header->acid_size < sizeof(NpdmAcidHeader) || (out->meta_header->acid_offset + out->meta_header->acid_size) > out->raw_data_size)
|
||||
{
|
||||
LOG_MSG("Invalid ACID offset/size! (0x%08X, 0x%08X).", out->meta_header->acid_offset, out->meta_header->acid_size);
|
||||
LOG_MSG_ERROR("Invalid ACID offset/size! (0x%X, 0x%X).", out->meta_header->acid_offset, out->meta_header->acid_size);
|
||||
dump_meta_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
(out->meta_header->aci_offset > out->meta_header->acid_offset && out->meta_header->aci_offset < (out->meta_header->acid_offset + out->meta_header->acid_size)) || \
|
||||
(out->meta_header->acid_offset > out->meta_header->aci_offset && out->meta_header->acid_offset < (out->meta_header->aci_offset + out->meta_header->aci_size)))
|
||||
{
|
||||
LOG_MSG("ACI0/ACID sections overlap! (0x%08X, 0x%08X | 0x%08X, 0x%08X).", out->meta_header->aci_offset, out->meta_header->aci_size, out->meta_header->acid_offset, out->meta_header->acid_size);
|
||||
LOG_MSG_ERROR("ACI0/ACID sections overlap! (0x%X, 0x%X | 0x%X, 0x%X).", out->meta_header->aci_offset, out->meta_header->aci_size, out->meta_header->acid_offset, out->meta_header->acid_size);
|
||||
dump_meta_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -148,21 +148,21 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
|
||||
if (__builtin_bswap32(out->acid_header->magic) != NPDM_ACID_MAGIC)
|
||||
{
|
||||
LOG_MSG("Invalid ACID header magic word! (0x%08X != 0x%08X).", __builtin_bswap32(out->acid_header->magic), __builtin_bswap32(NPDM_ACID_MAGIC));
|
||||
LOG_MSG_ERROR("Invalid ACID header magic word! (0x%08X != 0x%08X).", __builtin_bswap32(out->acid_header->magic), __builtin_bswap32(NPDM_ACID_MAGIC));
|
||||
dump_meta_header = dump_acid_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out->acid_header->size != (out->meta_header->acid_size - sizeof(out->acid_header->signature)))
|
||||
{
|
||||
LOG_MSG("Invalid ACID header size! (0x%08X).", out->acid_header->size);
|
||||
LOG_MSG_ERROR("Invalid ACID header size! (0x%X).", out->acid_header->size);
|
||||
dump_meta_header = dump_acid_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out->acid_header->program_id_min > out->acid_header->program_id_max)
|
||||
{
|
||||
LOG_MSG("Invalid ACID program ID range! (%016lX - %016lX).", out->acid_header->program_id_min, out->acid_header->program_id_max);
|
||||
LOG_MSG_ERROR("Invalid ACID program ID range! (%016lX - %016lX).", out->acid_header->program_id_min, out->acid_header->program_id_max);
|
||||
dump_meta_header = dump_acid_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
if (out->acid_header->fs_access_control_offset < sizeof(NpdmAcidHeader) || out->acid_header->fs_access_control_size < sizeof(NpdmFsAccessControlDescriptor) || \
|
||||
(out->acid_header->fs_access_control_offset + out->acid_header->fs_access_control_size) > out->meta_header->acid_size)
|
||||
{
|
||||
LOG_MSG("Invalid ACID FsAccessControl offset/size! (0x%08X, 0x%08X).", out->acid_header->fs_access_control_offset, out->acid_header->fs_access_control_size);
|
||||
LOG_MSG_ERROR("Invalid ACID FsAccessControl offset/size! (0x%X, 0x%X).", out->acid_header->fs_access_control_offset, out->acid_header->fs_access_control_size);
|
||||
dump_meta_header = dump_acid_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
if (out->acid_header->srv_access_control_offset < sizeof(NpdmAcidHeader) || \
|
||||
(out->acid_header->srv_access_control_offset + out->acid_header->srv_access_control_size) > out->meta_header->acid_size)
|
||||
{
|
||||
LOG_MSG("Invalid ACID SrvAccessControl offset/size! (0x%08X, 0x%08X).", out->acid_header->srv_access_control_offset, out->acid_header->srv_access_control_size);
|
||||
LOG_MSG_ERROR("Invalid ACID SrvAccessControl offset/size! (0x%X, 0x%X).", out->acid_header->srv_access_control_offset, out->acid_header->srv_access_control_size);
|
||||
dump_meta_header = dump_acid_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
out->acid_header->kernel_capability_offset < sizeof(NpdmAcidHeader) || \
|
||||
(out->acid_header->kernel_capability_offset + out->acid_header->kernel_capability_size) > out->meta_header->acid_size)
|
||||
{
|
||||
LOG_MSG("Invalid ACID KernelCapability offset/size! (0x%08X, 0x%08X).", out->acid_header->kernel_capability_offset, out->acid_header->kernel_capability_size);
|
||||
LOG_MSG_ERROR("Invalid ACID KernelCapability offset/size! (0x%X, 0x%X).", out->acid_header->kernel_capability_offset, out->acid_header->kernel_capability_size);
|
||||
dump_meta_header = dump_acid_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -210,21 +210,21 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
|
||||
if (__builtin_bswap32(out->aci_header->magic) != NPDM_ACI0_MAGIC)
|
||||
{
|
||||
LOG_MSG("Invalid ACI0 header magic word! (0x%08X != 0x%08X).", __builtin_bswap32(out->aci_header->magic), __builtin_bswap32(NPDM_ACI0_MAGIC));
|
||||
LOG_MSG_ERROR("Invalid ACI0 header magic word! (0x%08X != 0x%08X).", __builtin_bswap32(out->aci_header->magic), __builtin_bswap32(NPDM_ACI0_MAGIC));
|
||||
dump_meta_header = dump_acid_header = dump_aci_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out->aci_header->program_id != nca_ctx->header.program_id)
|
||||
{
|
||||
LOG_MSG("ACI0 program ID mismatch! (%016lX != %016lX).", out->aci_header->program_id, nca_ctx->header.program_id);
|
||||
LOG_MSG_ERROR("ACI0 program ID mismatch! (%016lX != %016lX).", out->aci_header->program_id, nca_ctx->header.program_id);
|
||||
dump_meta_header = dump_acid_header = dump_aci_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out->aci_header->program_id < out->acid_header->program_id_min || out->aci_header->program_id > out->acid_header->program_id_max)
|
||||
{
|
||||
LOG_MSG("ACI0 program ID out of ACID program ID range! (%016lX, %016lX - %016lX).", out->aci_header->program_id, out->acid_header->program_id_min, out->acid_header->program_id_max);
|
||||
LOG_MSG_ERROR("ACI0 program ID out of ACID program ID range! (%016lX, %016lX - %016lX).", out->aci_header->program_id, out->acid_header->program_id_min, out->acid_header->program_id_max);
|
||||
dump_meta_header = dump_acid_header = dump_aci_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
if (out->aci_header->fs_access_control_offset < sizeof(NpdmAciHeader) || out->aci_header->fs_access_control_size < sizeof(NpdmFsAccessControlData) || \
|
||||
(out->aci_header->fs_access_control_offset + out->aci_header->fs_access_control_size) > out->meta_header->aci_size)
|
||||
{
|
||||
LOG_MSG("Invalid ACI0 FsAccessControl offset/size! (0x%08X, 0x%08X).", out->aci_header->fs_access_control_offset, out->aci_header->fs_access_control_size);
|
||||
LOG_MSG_ERROR("Invalid ACI0 FsAccessControl offset/size! (0x%X, 0x%X).", out->aci_header->fs_access_control_offset, out->aci_header->fs_access_control_size);
|
||||
dump_meta_header = dump_acid_header = dump_aci_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
if (out->aci_header->srv_access_control_offset < sizeof(NpdmAciHeader) || \
|
||||
(out->aci_header->srv_access_control_offset + out->aci_header->srv_access_control_size) > out->meta_header->aci_size)
|
||||
{
|
||||
LOG_MSG("Invalid ACI0 SrvAccessControl offset/size! (0x%08X, 0x%08X).", out->aci_header->srv_access_control_offset, out->aci_header->srv_access_control_size);
|
||||
LOG_MSG_ERROR("Invalid ACI0 SrvAccessControl offset/size! (0x%X, 0x%X).", out->aci_header->srv_access_control_offset, out->aci_header->srv_access_control_size);
|
||||
dump_meta_header = dump_acid_header = dump_aci_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
out->aci_header->kernel_capability_offset < sizeof(NpdmAciHeader) || \
|
||||
(out->aci_header->kernel_capability_offset + out->aci_header->kernel_capability_size) > out->meta_header->aci_size)
|
||||
{
|
||||
LOG_MSG("Invalid ACI0 KernelCapability offset/size! (0x%08X, 0x%08X).", out->aci_header->kernel_capability_offset, out->aci_header->kernel_capability_size);
|
||||
LOG_MSG_ERROR("Invalid ACI0 KernelCapability offset/size! (0x%X, 0x%X).", out->aci_header->kernel_capability_offset, out->aci_header->kernel_capability_size);
|
||||
dump_meta_header = dump_acid_header = dump_aci_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
/* Safety check: verify raw NPDM size. */
|
||||
if (out->raw_data_size < cur_offset)
|
||||
{
|
||||
LOG_MSG("Invalid raw NPDM size! (0x%lX < 0x%lX).", out->raw_data_size, cur_offset);
|
||||
LOG_MSG_ERROR("Invalid raw NPDM size! (0x%lX < 0x%lX).", out->raw_data_size, cur_offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -278,9 +278,9 @@ bool npdmInitializeContext(NpdmContext *out, PartitionFileSystemContext *pfs_ctx
|
|||
end:
|
||||
if (!success)
|
||||
{
|
||||
if (dump_aci_header) LOG_DATA(out->aci_header, sizeof(NpdmAciHeader), "NPDM ACI0 Header dump:");
|
||||
if (dump_acid_header) LOG_DATA(out->acid_header, sizeof(NpdmAcidHeader), "NPDM ACID Header dump:");
|
||||
if (dump_meta_header) LOG_DATA(out->meta_header, sizeof(NpdmMetaHeader), "NPDM Meta Header dump:");
|
||||
if (dump_aci_header) LOG_DATA_DEBUG(out->aci_header, sizeof(NpdmAciHeader), "NPDM ACI0 Header dump:");
|
||||
if (dump_acid_header) LOG_DATA_DEBUG(out->acid_header, sizeof(NpdmAcidHeader), "NPDM ACID Header dump:");
|
||||
if (dump_meta_header) LOG_DATA_DEBUG(out->meta_header, sizeof(NpdmMetaHeader), "NPDM Meta Header dump:");
|
||||
|
||||
npdmFreeContext(out);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ bool nsoInitializeContext(NsoContext *out, PartitionFileSystemContext *pfs_ctx,
|
|||
nca_ctx->content_type != NcmContentType_Program || !pfs_ctx->offset || !pfs_ctx->size || !pfs_ctx->is_exefs || \
|
||||
pfs_ctx->header_size <= sizeof(PartitionFileSystemHeader) || !pfs_ctx->header || !pfs_entry)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -53,21 +53,21 @@ bool nsoInitializeContext(NsoContext *out, PartitionFileSystemContext *pfs_ctx,
|
|||
/* Get entry filename. */
|
||||
if (!(out->nso_filename = pfsGetEntryName(pfs_ctx, pfs_entry)) || !*(out->nso_filename))
|
||||
{
|
||||
LOG_MSG("Invalid Partition FS entry filename!");
|
||||
LOG_MSG_ERROR("Invalid Partition FS entry filename!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Read NSO header. */
|
||||
if (!pfsReadEntryData(pfs_ctx, pfs_entry, &(out->nso_header), sizeof(NsoHeader), 0))
|
||||
{
|
||||
LOG_MSG("Failed to read NSO \"%s\" header!", out->nso_filename);;
|
||||
LOG_MSG_ERROR("Failed to read NSO \"%s\" header!", out->nso_filename);;
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Verify NSO header. */
|
||||
if (__builtin_bswap32(out->nso_header.magic) != NSO_HEADER_MAGIC)
|
||||
{
|
||||
LOG_MSG("Invalid NSO \"%s\" header magic word! (0x%08X != 0x%08X).", out->nso_filename, __builtin_bswap32(out->nso_header.magic), __builtin_bswap32(NSO_HEADER_MAGIC));
|
||||
LOG_MSG_ERROR("Invalid NSO \"%s\" header magic word! (0x%08X != 0x%08X).", out->nso_filename, __builtin_bswap32(out->nso_header.magic), __builtin_bswap32(NSO_HEADER_MAGIC));
|
||||
dump_nso_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -77,8 +77,8 @@ bool nsoInitializeContext(NsoContext *out, PartitionFileSystemContext *pfs_ctx,
|
|||
(!(out->nso_header.flags & NsoFlags_TextCompress) && out->nso_header.text_file_size != out->nso_header.text_segment_info.size) || \
|
||||
(out->nso_header.text_segment_info.file_offset + out->nso_header.text_file_size) > pfs_entry->size)
|
||||
{
|
||||
LOG_MSG("Invalid .text segment offset/size for NSO \"%s\"! (0x%08X, 0x%08X, 0x%08X).", out->nso_filename, out->nso_header.text_segment_info.file_offset, out->nso_header.text_file_size, \
|
||||
out->nso_header.text_segment_info.size);
|
||||
LOG_MSG_ERROR("Invalid .text segment offset/size for NSO \"%s\"! (0x%X, 0x%X, 0x%X).", out->nso_filename, out->nso_header.text_segment_info.file_offset, \
|
||||
out->nso_header.text_file_size, out->nso_header.text_segment_info.size);
|
||||
dump_nso_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -88,8 +88,8 @@ bool nsoInitializeContext(NsoContext *out, PartitionFileSystemContext *pfs_ctx,
|
|||
(!(out->nso_header.flags & NsoFlags_RoCompress) && out->nso_header.rodata_file_size != out->nso_header.rodata_segment_info.size) || \
|
||||
(out->nso_header.rodata_segment_info.file_offset + out->nso_header.rodata_file_size) > pfs_entry->size)
|
||||
{
|
||||
LOG_MSG("Invalid .rodata segment offset/size for NSO \"%s\"! (0x%08X, 0x%08X, 0x%08X).", out->nso_filename, out->nso_header.rodata_segment_info.file_offset, out->nso_header.rodata_file_size, \
|
||||
out->nso_header.rodata_segment_info.size);
|
||||
LOG_MSG_ERROR("Invalid .rodata segment offset/size for NSO \"%s\"! (0x%X, 0x%X, 0x%X).", out->nso_filename, out->nso_header.rodata_segment_info.file_offset, \
|
||||
out->nso_header.rodata_file_size, out->nso_header.rodata_segment_info.size);
|
||||
dump_nso_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -99,36 +99,36 @@ bool nsoInitializeContext(NsoContext *out, PartitionFileSystemContext *pfs_ctx,
|
|||
(!(out->nso_header.flags & NsoFlags_DataCompress) && out->nso_header.data_file_size != out->nso_header.data_segment_info.size) || \
|
||||
(out->nso_header.data_segment_info.file_offset + out->nso_header.data_file_size) > pfs_entry->size)
|
||||
{
|
||||
LOG_MSG("Invalid .data segment offset/size for NSO \"%s\"! (0x%08X, 0x%08X, 0x%08X).", out->nso_filename, out->nso_header.data_segment_info.file_offset, out->nso_header.data_file_size, \
|
||||
out->nso_header.data_segment_info.size);
|
||||
LOG_MSG_ERROR("Invalid .data segment offset/size for NSO \"%s\"! (0x%X, 0x%X, 0x%X).", out->nso_filename, out->nso_header.data_segment_info.file_offset, \
|
||||
out->nso_header.data_file_size, out->nso_header.data_segment_info.size);
|
||||
dump_nso_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out->nso_header.module_name_size > 1 && (out->nso_header.module_name_offset < sizeof(NsoHeader) || (out->nso_header.module_name_offset + out->nso_header.module_name_size) > pfs_entry->size))
|
||||
{
|
||||
LOG_MSG("Invalid module name offset/size for NSO \"%s\"! (0x%08X, 0x%08X).", out->nso_filename, out->nso_header.module_name_offset, out->nso_header.module_name_size);
|
||||
LOG_MSG_ERROR("Invalid module name offset/size for NSO \"%s\"! (0x%X, 0x%X).", out->nso_filename, out->nso_header.module_name_offset, out->nso_header.module_name_size);
|
||||
dump_nso_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out->nso_header.api_info_section_info.size && (out->nso_header.api_info_section_info.offset + out->nso_header.api_info_section_info.size) > out->nso_header.rodata_segment_info.size)
|
||||
{
|
||||
LOG_MSG("Invalid .api_info section offset/size for NSO \"%s\"! (0x%08X, 0x%08X).", out->nso_filename, out->nso_header.api_info_section_info.offset, out->nso_header.api_info_section_info.size);
|
||||
LOG_MSG_ERROR("Invalid .api_info section offset/size for NSO \"%s\"! (0x%X, 0x%X).", out->nso_filename, out->nso_header.api_info_section_info.offset, out->nso_header.api_info_section_info.size);
|
||||
dump_nso_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out->nso_header.dynstr_section_info.size && (out->nso_header.dynstr_section_info.offset + out->nso_header.dynstr_section_info.size) > out->nso_header.rodata_segment_info.size)
|
||||
{
|
||||
LOG_MSG("Invalid .dynstr section offset/size for NSO \"%s\"! (0x%08X, 0x%08X).", out->nso_filename, out->nso_header.dynstr_section_info.offset, out->nso_header.dynstr_section_info.size);
|
||||
LOG_MSG_ERROR("Invalid .dynstr section offset/size for NSO \"%s\"! (0x%X, 0x%X).", out->nso_filename, out->nso_header.dynstr_section_info.offset, out->nso_header.dynstr_section_info.size);
|
||||
dump_nso_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out->nso_header.dynsym_section_info.size && (out->nso_header.dynsym_section_info.offset + out->nso_header.dynsym_section_info.size) > out->nso_header.rodata_segment_info.size)
|
||||
{
|
||||
LOG_MSG("Invalid .dynsym section offset/size for NSO \"%s\"! (0x%08X, 0x%08X).", out->nso_filename, out->nso_header.dynsym_section_info.offset, out->nso_header.dynsym_section_info.size);
|
||||
LOG_MSG_ERROR("Invalid .dynsym section offset/size for NSO \"%s\"! (0x%X, 0x%X).", out->nso_filename, out->nso_header.dynsym_section_info.offset, out->nso_header.dynsym_section_info.size);
|
||||
dump_nso_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ end:
|
|||
|
||||
if (!success)
|
||||
{
|
||||
if (dump_nso_header) LOG_DATA(&(out->nso_header), sizeof(NsoHeader), "NSO header dump:");
|
||||
if (dump_nso_header) LOG_DATA_DEBUG(&(out->nso_header), sizeof(NsoHeader), "NSO header dump:");
|
||||
|
||||
nsoFreeContext(out);
|
||||
}
|
||||
|
@ -178,14 +178,14 @@ static bool nsoGetModuleName(NsoContext *nso_ctx)
|
|||
/* Get module name. */
|
||||
if (!pfsReadEntryData(nso_ctx->pfs_ctx, nso_ctx->pfs_entry, &module_name, sizeof(NsoModuleName), nso_ctx->nso_header.module_name_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read NSO \"%s\" module name length!", nso_ctx->nso_filename);
|
||||
LOG_MSG_ERROR("Failed to read NSO \"%s\" module name length!", nso_ctx->nso_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Verify module name length. */
|
||||
if (module_name.name_length != ((u8)nso_ctx->nso_header.module_name_size - 1))
|
||||
{
|
||||
LOG_MSG("NSO \"%s\" module name length mismatch! (0x%02X != 0x%02X).", nso_ctx->nso_filename, module_name.name_length, (u8)nso_ctx->nso_header.module_name_size - 1);
|
||||
LOG_MSG_ERROR("NSO \"%s\" module name length mismatch! (0x%02X != 0x%02X).", nso_ctx->nso_filename, module_name.name_length, (u8)nso_ctx->nso_header.module_name_size - 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -193,14 +193,14 @@ static bool nsoGetModuleName(NsoContext *nso_ctx)
|
|||
nso_ctx->module_name = calloc(nso_ctx->nso_header.module_name_size, sizeof(char));
|
||||
if (!nso_ctx->module_name)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for NSO \"%s\" module name!", nso_ctx->nso_filename);
|
||||
LOG_MSG_ERROR("Failed to allocate memory for NSO \"%s\" module name!", nso_ctx->nso_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Read module name string. */
|
||||
if (!pfsReadEntryData(nso_ctx->pfs_ctx, nso_ctx->pfs_entry, nso_ctx->module_name, module_name.name_length, nso_ctx->nso_header.module_name_offset + 1))
|
||||
{
|
||||
LOG_MSG("Failed to read NSO \"%s\" module name string!", nso_ctx->nso_filename);
|
||||
LOG_MSG_ERROR("Failed to read NSO \"%s\" module name string!", nso_ctx->nso_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ static u8 *nsoGetRodataSegment(NsoContext *nso_ctx)
|
|||
/* Allocate memory for the .rodata buffer. */
|
||||
if (!(rodata_buf = calloc(rodata_buf_size, sizeof(u8))))
|
||||
{
|
||||
LOG_MSG("Failed to allocate 0x%lX bytes for the .rodata segment in NSO \"%s\"!", rodata_buf_size, nso_ctx->nso_filename);
|
||||
LOG_MSG_ERROR("Failed to allocate 0x%lX bytes for the .rodata segment in NSO \"%s\"!", rodata_buf_size, nso_ctx->nso_filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ static u8 *nsoGetRodataSegment(NsoContext *nso_ctx)
|
|||
/* Read .rodata segment data. */
|
||||
if (!pfsReadEntryData(nso_ctx->pfs_ctx, nso_ctx->pfs_entry, rodata_read_ptr, rodata_read_size, nso_ctx->nso_header.rodata_segment_info.file_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read .rodata segment in NRO \"%s\"!", nso_ctx->nso_filename);
|
||||
LOG_MSG_ERROR("Failed to read .rodata segment in NRO \"%s\"!", nso_ctx->nso_filename);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ static u8 *nsoGetRodataSegment(NsoContext *nso_ctx)
|
|||
if ((lz4_res = LZ4_decompress_safe((char*)rodata_read_ptr, (char*)rodata_buf, (int)nso_ctx->nso_header.rodata_file_size, (int)rodata_buf_size)) != \
|
||||
(int)nso_ctx->nso_header.rodata_segment_info.size)
|
||||
{
|
||||
LOG_MSG("LZ4 decompression failed for NRO \"%s\"! (%d).", nso_ctx->nso_filename, lz4_res);
|
||||
LOG_MSG_ERROR("LZ4 decompression failed for NRO \"%s\"! (%d).", nso_ctx->nso_filename, lz4_res);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ static u8 *nsoGetRodataSegment(NsoContext *nso_ctx)
|
|||
sha256CalculateHash(rodata_hash, rodata_buf, nso_ctx->nso_header.rodata_segment_info.size);
|
||||
if (memcmp(rodata_hash, nso_ctx->nso_header.rodata_segment_hash, SHA256_HASH_SIZE) != 0)
|
||||
{
|
||||
LOG_MSG(".rodata segment checksum mismatch for NRO \"%s\"!", nso_ctx->nso_filename);
|
||||
LOG_MSG_ERROR(".rodata segment checksum mismatch for NRO \"%s\"!", nso_ctx->nso_filename);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ static bool nsoGetModuleInfoName(NsoContext *nso_ctx, u8 *rodata_buf)
|
|||
nso_ctx->module_info_name = calloc(module_info->name_length + 1, sizeof(char));
|
||||
if (!nso_ctx->module_info_name)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for NSO \"%s\" module info name!", nso_ctx->nso_filename);
|
||||
LOG_MSG_ERROR("Failed to allocate memory for NSO \"%s\" module info name!", nso_ctx->nso_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,7 @@ static bool nsoGetSectionFromRodataSegment(NsoContext *nso_ctx, u8 *rodata_buf,
|
|||
/* Allocate memory for the desired .rodata section. */
|
||||
if (!(*section_ptr = malloc(section_size)))
|
||||
{
|
||||
LOG_MSG("Failed to allocate 0x%lX bytes for section at .rodata offset 0x%lX in NSO \"%s\"!", section_size, section_offset, nso_ctx->nso_filename);
|
||||
LOG_MSG_ERROR("Failed to allocate 0x%lX bytes for section at .rodata offset 0x%lX in NSO \"%s\"!", section_size, section_offset, nso_ctx->nso_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ bool bfsarInitialize(void)
|
|||
/* Create BFSAR file in the SD card root directory. */
|
||||
if (use_root) sprintf(g_bfsarPath, "/" BFSAR_FILENAME);
|
||||
|
||||
LOG_MSG("BFSAR path: \"%s\".", g_bfsarPath);
|
||||
LOG_MSG_DEBUG("BFSAR path: \"%s\".", g_bfsarPath);
|
||||
|
||||
/* Check if the BFSAR file is already available and not empty. */
|
||||
bfsar_file = fopen(g_bfsarPath, "rb");
|
||||
|
@ -93,7 +93,7 @@ bool bfsarInitialize(void)
|
|||
/* Get title info. */
|
||||
if (!(title_info = titleGetInfoFromStorageByTitleId(NcmStorageId_BuiltInSystem, QLAUNCH_TID)))
|
||||
{
|
||||
LOG_MSG("Failed to get title info for qlaunch!");
|
||||
LOG_MSG_ERROR("Failed to get title info for qlaunch!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -101,28 +101,28 @@ bool bfsarInitialize(void)
|
|||
nca_ctx = calloc(1, sizeof(NcaContext));
|
||||
if (!nca_ctx)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for temporary NCA context!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for temporary NCA context!");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Initialize NCA context. */
|
||||
if (!ncaInitializeContext(nca_ctx, NcmStorageId_BuiltInSystem, 0, titleGetContentInfoByTypeAndIdOffset(title_info, NcmContentType_Program, 0), title_info->version.value, NULL))
|
||||
{
|
||||
LOG_MSG("Failed to initialize qlaunch Program NCA context!");
|
||||
LOG_MSG_ERROR("Failed to initialize qlaunch Program NCA context!");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Initialize RomFS context. */
|
||||
if (!romfsInitializeContext(&romfs_ctx, &(nca_ctx->fs_ctx[1]), NULL))
|
||||
{
|
||||
LOG_MSG("Failed to initialize RomFS context for qlaunch Program NCA!");
|
||||
LOG_MSG_ERROR("Failed to initialize RomFS context for qlaunch Program NCA!");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Get RomFS file entry. */
|
||||
if (!(romfs_file_entry = romfsGetFileEntryByPath(&romfs_ctx, BFSAR_ROMFS_PATH)))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve RomFS file entry for \"" BFSAR_ROMFS_PATH "\"!");
|
||||
LOG_MSG_ERROR("Failed to retrieve RomFS file entry for \"" BFSAR_ROMFS_PATH "\"!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -130,21 +130,21 @@ bool bfsarInitialize(void)
|
|||
bfsar_size = romfs_file_entry->size;
|
||||
if (!bfsar_size)
|
||||
{
|
||||
LOG_MSG("File size for qlaunch's \"" BFSAR_ROMFS_PATH "\" is zero!");
|
||||
LOG_MSG_ERROR("File size for qlaunch's \"" BFSAR_ROMFS_PATH "\" is zero!");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Allocate memory for BFSAR data. */
|
||||
if (!(bfsar_data = malloc(bfsar_size)))
|
||||
{
|
||||
LOG_MSG("Failed to allocate 0x%lX bytes for qlaunch's \"" BFSAR_ROMFS_PATH "\"!", bfsar_size);
|
||||
LOG_MSG_ERROR("Failed to allocate 0x%lX bytes for qlaunch's \"" BFSAR_ROMFS_PATH "\"!", bfsar_size);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Read BFSAR data. */
|
||||
if (!romfsReadFileEntryData(&romfs_ctx, romfs_file_entry, bfsar_data, bfsar_size, 0))
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%lX bytes long \"" BFSAR_ROMFS_PATH "\" from qlaunch!", bfsar_size);
|
||||
LOG_MSG_ERROR("Failed to read 0x%lX bytes long \"" BFSAR_ROMFS_PATH "\" from qlaunch!", bfsar_size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ bool bfsarInitialize(void)
|
|||
bfsar_file = fopen(g_bfsarPath, "wb");
|
||||
if (!bfsar_file)
|
||||
{
|
||||
LOG_MSG("Failed to open \"%s\" for writing!", g_bfsarPath);
|
||||
LOG_MSG_ERROR("Failed to open \"%s\" for writing!", g_bfsarPath);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ bool bfsarInitialize(void)
|
|||
wr = fwrite(bfsar_data, 1, bfsar_size, bfsar_file);
|
||||
if (wr != bfsar_size)
|
||||
{
|
||||
LOG_MSG("Failed to write 0x%lX bytes block to \"%s\"!", bfsar_size, g_bfsarPath);
|
||||
LOG_MSG_ERROR("Failed to write 0x%lX bytes block to \"%s\"!", bfsar_size, g_bfsarPath);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ bool jsonSet##functype(const struct json_object *obj, const char *path, vartype
|
|||
struct json_object *child = jsonGetObjectByPath(obj, path, NULL); \
|
||||
if (child && jsonValidate##functype(child, ##__VA_ARGS__)) { \
|
||||
ret = (json_object_set_##jsontype(child, value) == 1); \
|
||||
if (!ret) LOG_MSG("Failed to update \"%s\"!", path); \
|
||||
if (!ret) LOG_MSG_ERROR("Failed to update \"%s\"!", path); \
|
||||
} \
|
||||
return ret; \
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ struct json_object *jsonParseFromString(const char *str, size_t size)
|
|||
{
|
||||
if (!str || !*str)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ struct json_object *jsonParseFromString(const char *str, size_t size)
|
|||
tok = json_tokener_new();
|
||||
if (!tok)
|
||||
{
|
||||
LOG_MSG("json_tokener_new failed!");
|
||||
LOG_MSG_ERROR("json_tokener_new failed!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ struct json_object *jsonParseFromString(const char *str, size_t size)
|
|||
obj = json_tokener_parse_ex(tok, str, (int)size);
|
||||
if ((jerr = json_tokener_get_error(tok)) != json_tokener_success)
|
||||
{
|
||||
LOG_MSG("json_tokener_parse_ex failed! Reason: \"%s\".", json_tokener_error_desc(jerr));
|
||||
LOG_MSG_ERROR("json_tokener_parse_ex failed! Reason: \"%s\".", json_tokener_error_desc(jerr));
|
||||
|
||||
if (obj)
|
||||
{
|
||||
|
@ -91,14 +91,14 @@ struct json_object *jsonGetObjectByPath(const struct json_object *obj, const cha
|
|||
|
||||
if (!jsonValidateObject(obj) || !path || !*path)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Duplicate path to avoid problems with strtok_r(). */
|
||||
if (!(path_dup = strdup(path)))
|
||||
{
|
||||
LOG_MSG("Unable to duplicate input path! (\"%s\").", path);
|
||||
LOG_MSG_ERROR("Unable to duplicate input path! (\"%s\").", path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ struct json_object *jsonGetObjectByPath(const struct json_object *obj, const cha
|
|||
pch = strtok_r(path_dup, "/", &state);
|
||||
if (!pch)
|
||||
{
|
||||
LOG_MSG("Failed to tokenize input path! (\"%s\").", path);
|
||||
LOG_MSG_ERROR("Failed to tokenize input path! (\"%s\").", path);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ struct json_object *jsonGetObjectByPath(const struct json_object *obj, const cha
|
|||
/* Retrieve JSON object using the current path element. */
|
||||
if (!json_object_object_get_ex(parent_obj, prev_pch, &child_obj))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve JSON object by key for \"%s\"! (\"%s\").", prev_pch, path);
|
||||
LOG_MSG_ERROR("Failed to retrieve JSON object by key for \"%s\"! (\"%s\").", prev_pch, path);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ struct json_object *jsonGetObjectByPath(const struct json_object *obj, const cha
|
|||
*out_last_element = strdup(prev_pch);
|
||||
if (!*out_last_element)
|
||||
{
|
||||
LOG_MSG("Failed to duplicate last path element \"%s\"! (\"%s\").", prev_pch, path);
|
||||
LOG_MSG_ERROR("Failed to duplicate last path element \"%s\"! (\"%s\").", prev_pch, path);
|
||||
child_obj = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ void jsonLogLastError(void)
|
|||
if (str[str_len - 1] == '\r') str[--str_len] = '\0';
|
||||
|
||||
/* Log error message. */
|
||||
LOG_MSG("%s", str);
|
||||
LOG_MSG_ERROR("%s", str);
|
||||
}
|
||||
|
||||
JSON_GETTER(Boolean, bool, boolean);
|
||||
|
@ -187,7 +187,7 @@ bool jsonSetArray(const struct json_object *obj, const char *path, struct json_o
|
|||
{
|
||||
if (!obj || !path || !*path || !jsonValidateArray(value))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -199,14 +199,14 @@ bool jsonSetArray(const struct json_object *obj, const char *path, struct json_o
|
|||
parent_obj = jsonGetObjectByPath(obj, path, &key);
|
||||
if (!parent_obj)
|
||||
{
|
||||
LOG_MSG("Failed to retrieve parent JSON object! (\"%s\").", path);
|
||||
LOG_MSG_ERROR("Failed to retrieve parent JSON object! (\"%s\").", path);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Set new JSON array. */
|
||||
if (json_object_object_add(parent_obj, key, value) != 0)
|
||||
{
|
||||
LOG_MSG("json_object_object_add failed! (\"%s\").", path);
|
||||
LOG_MSG_ERROR("json_object_object_add failed! (\"%s\").", path);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ bool utilsInitializeResources(const int program_argc, const char **program_argv)
|
|||
/* Retrieve pointer to the SD card FsFileSystem element. */
|
||||
if (!(g_sdCardFileSystem = fsdevGetDeviceFileSystem(DEVOPTAB_SDMC_DEVICE)))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve FsFileSystem object for the SD card!");
|
||||
LOG_MSG_ERROR("Failed to retrieve FsFileSystem object for the SD card!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -193,14 +193,14 @@ bool utilsInitializeResources(const int program_argc, const char **program_argv)
|
|||
/* Load keyset. */
|
||||
if (!keysLoadKeyset())
|
||||
{
|
||||
LOG_MSG("Failed to load keyset!\nUpdate your keys file with Lockpick_RCM:\n" LOCKPICK_RCM_URL);
|
||||
LOG_MSG_ERROR("Failed to load keyset!\nUpdate your keys file with Lockpick_RCM:\n" LOCKPICK_RCM_URL);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Allocate NCA crypto buffer. */
|
||||
if (!ncaAllocateCryptoBuffer())
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for NCA crypto buffer!");
|
||||
LOG_MSG_ERROR("Unable to allocate memory for NCA crypto buffer!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ bool utilsInitializeResources(const int program_argc, const char **program_argv)
|
|||
rc = romfsInit();
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("Failed to mount RomFS container!");
|
||||
LOG_MSG_ERROR("Failed to mount " APP_TITLE "'s RomFS container!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ bool utilsCreateThread(Thread *out_thread, ThreadFunc func, void *arg, int cpu_i
|
|||
/* -2 can be provided to use the default process core. */
|
||||
if (!out_thread || !func || (cpu_id < 0 && cpu_id != -2) || cpu_id > 2)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ bool utilsCreateThread(Thread *out_thread, ThreadFunc func, void *arg, int cpu_i
|
|||
rc = svcGetInfo(&core_mask, InfoType_CoreMask, CUR_PROCESS_HANDLE, 0);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("svcGetInfo failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("svcGetInfo failed! (0x%X).", rc);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ bool utilsCreateThread(Thread *out_thread, ThreadFunc func, void *arg, int cpu_i
|
|||
rc = threadCreate(out_thread, func, arg, NULL, stack_size, 0x3B, cpu_id);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("threadCreate failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("threadCreate failed! (0x%X).", rc);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,7 @@ bool utilsCreateThread(Thread *out_thread, ThreadFunc func, void *arg, int cpu_i
|
|||
rc = svcSetThreadCoreMask(out_thread->handle, cpu_id == -2 ? -1 : cpu_id, core_mask);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("svcSetThreadCoreMask failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("svcSetThreadCoreMask failed! (0x%X).", rc);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -450,7 +450,7 @@ bool utilsCreateThread(Thread *out_thread, ThreadFunc func, void *arg, int cpu_i
|
|||
rc = threadStart(out_thread);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("threadStart failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("threadStart failed! (0x%X).", rc);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -466,14 +466,14 @@ void utilsJoinThread(Thread *thread)
|
|||
{
|
||||
if (!thread || thread->handle == INVALID_HANDLE)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return;
|
||||
}
|
||||
|
||||
Result rc = threadWaitForExit(thread);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("threadWaitForExit failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("threadWaitForExit failed! (0x%X).", rc);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -486,7 +486,7 @@ __attribute__((format(printf, 3, 4))) bool utilsAppendFormattedStringToBuffer(ch
|
|||
{
|
||||
if (!dst || !dst_size || (!*dst && *dst_size) || (*dst && !*dst_size) || !fmt || !*fmt)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -502,7 +502,7 @@ __attribute__((format(printf, 3, 4))) bool utilsAppendFormattedStringToBuffer(ch
|
|||
|
||||
if (dst_cur_size && dst_str_len >= dst_cur_size)
|
||||
{
|
||||
LOG_MSG("String length is equal to or greater than the provided buffer size! (0x%lX >= 0x%lX).", dst_str_len, dst_cur_size);
|
||||
LOG_MSG_ERROR("String length is equal to or greater than the provided buffer size! (0x%lX >= 0x%lX).", dst_str_len, dst_cur_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -512,7 +512,7 @@ __attribute__((format(printf, 3, 4))) bool utilsAppendFormattedStringToBuffer(ch
|
|||
formatted_str_len = vsnprintf(NULL, 0, fmt, args);
|
||||
if (formatted_str_len <= 0)
|
||||
{
|
||||
LOG_MSG("Failed to retrieve formatted string length!");
|
||||
LOG_MSG_ERROR("Failed to retrieve formatted string length!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -527,7 +527,7 @@ __attribute__((format(printf, 3, 4))) bool utilsAppendFormattedStringToBuffer(ch
|
|||
tmp_str = realloc(dst_ptr, dst_cur_size);
|
||||
if (!tmp_str)
|
||||
{
|
||||
LOG_MSG("Failed to resize buffer to 0x%lX byte(s).", dst_cur_size);
|
||||
LOG_MSG_ERROR("Failed to resize buffer to 0x%lX byte(s).", dst_cur_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -647,7 +647,7 @@ bool utilsGetFileSystemStatsByPath(const char *path, u64 *out_total, u64 *out_fr
|
|||
|
||||
if (!path || !*path || !(name_end = strchr(path, ':')) || *(name_end + 1) != '/' || (!out_total && !out_free))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -656,7 +656,7 @@ bool utilsGetFileSystemStatsByPath(const char *path, u64 *out_total, u64 *out_fr
|
|||
|
||||
if ((ret = statvfs(stat_path, &info)) != 0)
|
||||
{
|
||||
LOG_MSG("statvfs failed for \"%s\"! (%d) (errno: %d).", stat_path, ret, errno);
|
||||
LOG_MSG_ERROR("statvfs failed for \"%s\"! (%d) (errno: %d).", stat_path, ret, errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -673,7 +673,7 @@ void utilsCreateOutputDirectories(const char *device)
|
|||
|
||||
if (device && (!(device_len = strlen(device)) || device[device_len - 1] != ':'))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -709,7 +709,7 @@ bool utilsCreateConcatenationFile(const char *path)
|
|||
{
|
||||
if (!path || !*path)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -719,7 +719,7 @@ bool utilsCreateConcatenationFile(const char *path)
|
|||
/* Create ConcatenationFile. */
|
||||
/* If the call succeeds, the caller function will be able to operate on this file using stdio calls. */
|
||||
Result rc = fsdevCreateFile(path, 0, FsCreateOption_BigFile);
|
||||
if (R_FAILED(rc)) LOG_MSG("fsdevCreateFile failed for \"%s\"! (0x%08X).", path, rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("fsdevCreateFile failed for \"%s\"! (0x%X).", path, rc);
|
||||
|
||||
return R_SUCCEEDED(rc);
|
||||
}
|
||||
|
@ -751,7 +751,7 @@ char *utilsGeneratePath(const char *prefix, const char *filename, const char *ex
|
|||
{
|
||||
if (!filename || !*filename)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -771,7 +771,7 @@ char *utilsGeneratePath(const char *prefix, const char *filename, const char *ex
|
|||
/* Allocate memory for the output path. */
|
||||
if (!(path = calloc(path_len + 1, sizeof(char))))
|
||||
{
|
||||
LOG_MSG("Failed to allocate 0x%lX bytes for output path!", path_len);
|
||||
LOG_MSG_ERROR("Failed to allocate 0x%lX bytes for output path!", path_len);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -823,7 +823,7 @@ char *utilsGeneratePath(const char *prefix, const char *filename, const char *ex
|
|||
/* Truncate last element. Make sure to preserve the provided file extension. */
|
||||
if (extension_len >= last_cp_pos)
|
||||
{
|
||||
LOG_MSG("File extension length is >= truncated filename length! (0x%lX >= 0x%lX).", extension_len, last_cp_pos);
|
||||
LOG_MSG_ERROR("File extension length is >= truncated filename length! (0x%lX >= 0x%lX).", extension_len, last_cp_pos);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -840,7 +840,7 @@ char *utilsGeneratePath(const char *prefix, const char *filename, const char *ex
|
|||
/* Check if the full length for the generated path is >= FS_MAX_PATH. */
|
||||
if (path_len >= FS_MAX_PATH)
|
||||
{
|
||||
LOG_MSG("Generated path length is >= FS_MAX_PATH! (0x%lX).", path_len);
|
||||
LOG_MSG_ERROR("Generated path length is >= FS_MAX_PATH! (0x%lX).", path_len);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -912,7 +912,7 @@ bool utilsParseGitHubReleaseJsonData(const char *json_buf, size_t json_buf_size,
|
|||
{
|
||||
if (!json_buf || !json_buf_size || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -927,7 +927,7 @@ bool utilsParseGitHubReleaseJsonData(const char *json_buf, size_t json_buf_size,
|
|||
out->obj = jsonParseFromString(json_buf, json_buf_size);
|
||||
if (!out->obj)
|
||||
{
|
||||
LOG_MSG("Failed to parse JSON object!");
|
||||
LOG_MSG_ERROR("Failed to parse JSON object!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -940,14 +940,14 @@ bool utilsParseGitHubReleaseJsonData(const char *json_buf, size_t json_buf_size,
|
|||
|
||||
if (!out->version || !out->commit_hash || !published_at || !out->changelog || !assets)
|
||||
{
|
||||
LOG_MSG("Failed to retrieve required elements from the provided JSON!");
|
||||
LOG_MSG_ERROR("Failed to retrieve required elements from the provided JSON!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Parse release date. */
|
||||
if (!strptime(published_at, "%Y-%m-%dT%H:%M:%SZ", &(out->date)))
|
||||
{
|
||||
LOG_MSG("Failed to parse release date \"%s\"!", published_at);
|
||||
LOG_MSG_ERROR("Failed to parse release date \"%s\"!", published_at);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -973,7 +973,7 @@ bool utilsParseGitHubReleaseJsonData(const char *json_buf, size_t json_buf_size,
|
|||
|
||||
if (!out->download_url)
|
||||
{
|
||||
LOG_MSG("Failed to retrieve required elements from the provided JSON!");
|
||||
LOG_MSG_ERROR("Failed to retrieve required elements from the provided JSON!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -990,7 +990,7 @@ bool utilsIsApplicationUpdatable(const char *version, const char *commit_hash)
|
|||
{
|
||||
if (!version || !*version || *version != 'v' || !commit_hash || !*commit_hash)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1060,7 +1060,7 @@ static bool _utilsIsDevelopmentUnit(void)
|
|||
{
|
||||
g_isDevUnit = tmp;
|
||||
} else {
|
||||
LOG_MSG("splIsDevelopment failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("splIsDevelopment failed! (0x%X).", rc);
|
||||
}
|
||||
|
||||
return R_SUCCEEDED(rc);
|
||||
|
@ -1079,21 +1079,21 @@ static bool utilsMountEmmcBisSystemPartitionStorage(void)
|
|||
rc = fsOpenBisStorage(&g_emmcBisSystemPartitionStorage, FsBisPartitionId_System);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("Failed to open eMMC BIS System partition storage! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("Failed to open eMMC BIS System partition storage! (0x%X).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
g_emmcBisSystemPartitionFatFsObj = calloc(1, sizeof(FATFS));
|
||||
if (!g_emmcBisSystemPartitionFatFsObj)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for FatFs element!");
|
||||
LOG_MSG_ERROR("Unable to allocate memory for FatFs element!");
|
||||
return false;
|
||||
}
|
||||
|
||||
fr = f_mount(g_emmcBisSystemPartitionFatFsObj, BIS_SYSTEM_PARTITION_MOUNT_NAME, 1);
|
||||
if (fr != FR_OK)
|
||||
{
|
||||
LOG_MSG("Failed to mount eMMC BIS System partition! (%u).", fr);
|
||||
LOG_MSG_ERROR("Failed to mount eMMC BIS System partition! (%u).", fr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ bool pfsInitializeContext(PartitionFileSystemContext *out, NcaFsSectionContext *
|
|||
(nca_fs_ctx->hash_type != NcaHashType_HierarchicalSha256 && nca_fs_ctx->hash_type != NcaHashType_HierarchicalSha3256) || !(nca_ctx = (NcaContext*)nca_fs_ctx->nca_ctx) || \
|
||||
(nca_ctx->rights_id_available && !nca_ctx->titlekey_retrieved))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ bool pfsInitializeContext(PartitionFileSystemContext *out, NcaFsSectionContext *
|
|||
NcaStorageContext *storage_ctx = &(out->storage_ctx);
|
||||
if (!ncaStorageInitializeContext(storage_ctx, nca_fs_ctx))
|
||||
{
|
||||
LOG_MSG("Failed to initialize NCA storage context!");
|
||||
LOG_MSG_ERROR("Failed to initialize NCA storage context!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -59,28 +59,28 @@ bool pfsInitializeContext(PartitionFileSystemContext *out, NcaFsSectionContext *
|
|||
/* Get Partition FS offset and size. */
|
||||
if (!ncaStorageGetHashTargetExtents(storage_ctx, &(out->offset), &(out->size)))
|
||||
{
|
||||
LOG_MSG("Failed to get target hash layer extents!");
|
||||
LOG_MSG_ERROR("Failed to get target hash layer extents!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Read partial Partition FS header. */
|
||||
if (!ncaStorageRead(storage_ctx, &pfs_header, sizeof(PartitionFileSystemHeader), out->offset))
|
||||
{
|
||||
LOG_MSG("Failed to read partial Partition FS header!");
|
||||
LOG_MSG_ERROR("Failed to read partial Partition FS header!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
magic = __builtin_bswap32(pfs_header.magic);
|
||||
if (magic != PFS0_MAGIC)
|
||||
{
|
||||
LOG_MSG("Invalid Partition FS magic word! (0x%08X).", magic);
|
||||
LOG_MSG_ERROR("Invalid Partition FS magic word! (0x%08X).", magic);
|
||||
dump_fs_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!pfs_header.entry_count || !pfs_header.name_table_size)
|
||||
{
|
||||
LOG_MSG("Invalid Partition FS entry count / name table size!");
|
||||
LOG_MSG_ERROR("Invalid Partition FS entry count / name table size!");
|
||||
dump_fs_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -92,14 +92,14 @@ bool pfsInitializeContext(PartitionFileSystemContext *out, NcaFsSectionContext *
|
|||
out->header = calloc(out->header_size, sizeof(u8));
|
||||
if (!out->header)
|
||||
{
|
||||
LOG_MSG("Unable to allocate 0x%lX bytes buffer for the full Partition FS header!", out->header_size);
|
||||
LOG_MSG_ERROR("Unable to allocate 0x%lX bytes buffer for the full Partition FS header!", out->header_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Read full Partition FS header. */
|
||||
if (!ncaStorageRead(storage_ctx, out->header, out->header_size, out->offset))
|
||||
{
|
||||
LOG_MSG("Failed to read full Partition FS header!");
|
||||
LOG_MSG_ERROR("Failed to read full Partition FS header!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ bool pfsInitializeContext(PartitionFileSystemContext *out, NcaFsSectionContext *
|
|||
end:
|
||||
if (!success)
|
||||
{
|
||||
if (dump_fs_header) LOG_DATA(&pfs_header, sizeof(PartitionFileSystemHeader), "Partition FS header dump:");
|
||||
if (dump_fs_header) LOG_DATA_DEBUG(&pfs_header, sizeof(PartitionFileSystemHeader), "Partition FS header dump:");
|
||||
|
||||
pfsFreeContext(out);
|
||||
}
|
||||
|
@ -125,14 +125,14 @@ bool pfsReadPartitionData(PartitionFileSystemContext *ctx, void *out, u64 read_s
|
|||
{
|
||||
if (!ctx || !ncaStorageIsValidContext(&(ctx->storage_ctx)) || !ctx->size || !out || !read_size || (offset + read_size) > ctx->size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Read partition data. */
|
||||
if (!ncaStorageRead(&(ctx->storage_ctx), out, read_size, ctx->offset + offset))
|
||||
{
|
||||
LOG_MSG("Failed to read Partition FS data!");
|
||||
LOG_MSG_ERROR("Failed to read Partition FS data!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -143,14 +143,14 @@ bool pfsReadEntryData(PartitionFileSystemContext *ctx, PartitionFileSystemEntry
|
|||
{
|
||||
if (!ctx || !fs_entry || !fs_entry->size || (fs_entry->offset + fs_entry->size) > ctx->size || !out || !read_size || (offset + read_size) > fs_entry->size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Read entry data. */
|
||||
if (!pfsReadPartitionData(ctx, out, read_size, ctx->header_size + fs_entry->offset + offset))
|
||||
{
|
||||
LOG_MSG("Failed to read Partition FS entry data!");
|
||||
LOG_MSG_ERROR("Failed to read Partition FS entry data!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ bool pfsGetEntryIndexByName(PartitionFileSystemContext *ctx, const char *name, u
|
|||
|
||||
if (!entry_count || !name_table || !name || !*name || !out_idx)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -175,13 +175,13 @@ bool pfsGetEntryIndexByName(PartitionFileSystemContext *ctx, const char *name, u
|
|||
{
|
||||
if (!(fs_entry = pfsGetEntryByIndex(ctx, i)))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve Partition FS entry #%u!", i);
|
||||
LOG_MSG_ERROR("Failed to retrieve Partition FS entry #%u!", i);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fs_entry->name_offset >= name_table_size)
|
||||
{
|
||||
LOG_MSG("Name offset from Partition FS entry #%u exceeds name table size!", i);
|
||||
LOG_MSG_ERROR("Name offset from Partition FS entry #%u exceeds name table size!", i);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -192,8 +192,7 @@ bool pfsGetEntryIndexByName(PartitionFileSystemContext *ctx, const char *name, u
|
|||
}
|
||||
}
|
||||
|
||||
/* Only log error if we're not dealing with a NPDM. */
|
||||
if (strcmp(name, "main.npdm") != 0) LOG_MSG("Unable to find Partition FS entry \"%s\"!", name);
|
||||
LOG_MSG_ERROR("Unable to find Partition FS entry \"%s\"!", name);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -206,7 +205,7 @@ bool pfsGetTotalDataSize(PartitionFileSystemContext *ctx, u64 *out_size)
|
|||
|
||||
if (!entry_count || !out_size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -214,7 +213,7 @@ bool pfsGetTotalDataSize(PartitionFileSystemContext *ctx, u64 *out_size)
|
|||
{
|
||||
if (!(fs_entry = pfsGetEntryByIndex(ctx, i)))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve Partition FS entry #%u!", i);
|
||||
LOG_MSG_ERROR("Failed to retrieve Partition FS entry #%u!", i);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -231,7 +230,7 @@ bool pfsGenerateEntryPatch(PartitionFileSystemContext *ctx, PartitionFileSystemE
|
|||
if (!ctx || !ncaStorageIsValidContext(&(ctx->storage_ctx)) || ctx->storage_ctx.base_storage_type != NcaStorageBaseStorageType_Regular || !ctx->header_size || !ctx->header || \
|
||||
!fs_entry || !fs_entry->size || (fs_entry->offset + fs_entry->size) > ctx->size || !data || !data_size || (data_offset + data_size) > fs_entry->size || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -239,7 +238,7 @@ bool pfsGenerateEntryPatch(PartitionFileSystemContext *ctx, PartitionFileSystemE
|
|||
|
||||
if (!ncaGenerateHierarchicalSha256Patch(ctx->nca_fs_ctx, data, data_size, partition_offset, out))
|
||||
{
|
||||
LOG_MSG("Failed to generate 0x%lX bytes HierarchicalSha256 patch at offset 0x%lX for Partition FS entry!", data_size, partition_offset);
|
||||
LOG_MSG_ERROR("Failed to generate 0x%lX bytes HierarchicalSha256 patch at offset 0x%lX for Partition FS entry!", data_size, partition_offset);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -250,7 +249,7 @@ bool pfsAddEntryInformationToFileContext(PartitionFileSystemFileContext *ctx, co
|
|||
{
|
||||
if (!ctx || !entry_name || !*entry_name)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -265,7 +264,7 @@ bool pfsAddEntryInformationToFileContext(PartitionFileSystemFileContext *ctx, co
|
|||
/* Reallocate Partition FS entries. */
|
||||
if (!(tmp_pfs_entries = realloc(ctx->entries, tmp_pfs_entries_size)))
|
||||
{
|
||||
LOG_MSG("Failed to reallocate Partition FS entries!");
|
||||
LOG_MSG_ERROR("Failed to reallocate Partition FS entries!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -285,7 +284,7 @@ bool pfsAddEntryInformationToFileContext(PartitionFileSystemFileContext *ctx, co
|
|||
/* Reallocate Partition FS name table. */
|
||||
if (!(tmp_name_table = realloc(ctx->name_table, tmp_name_table_size)))
|
||||
{
|
||||
LOG_MSG("Failed to reallocate Partition FS name table!");
|
||||
LOG_MSG_ERROR("Failed to reallocate Partition FS name table!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -310,7 +309,7 @@ bool pfsUpdateEntryNameFromFileContext(PartitionFileSystemFileContext *ctx, u32
|
|||
{
|
||||
if (!ctx || !ctx->header.entry_count || !ctx->header.name_table_size || !ctx->entries || !ctx->name_table || entry_idx >= ctx->header.entry_count || !new_entry_name || !*new_entry_name)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -322,7 +321,7 @@ bool pfsUpdateEntryNameFromFileContext(PartitionFileSystemFileContext *ctx, u32
|
|||
|
||||
if (new_entry_name_len > cur_entry_name_len)
|
||||
{
|
||||
LOG_MSG("New entry name length exceeds previous entry name length! (0x%lX > 0x%lX).", new_entry_name_len, cur_entry_name_len);
|
||||
LOG_MSG_ERROR("New entry name length exceeds previous entry name length! (0x%lX > 0x%lX).", new_entry_name_len, cur_entry_name_len);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -335,7 +334,7 @@ bool pfsWriteFileContextHeaderToMemoryBuffer(PartitionFileSystemFileContext *ctx
|
|||
{
|
||||
if (!ctx || !ctx->header.entry_count || !ctx->header.name_table_size || !ctx->entries || !ctx->name_table || !buf || !out_header_size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -354,7 +353,7 @@ bool pfsWriteFileContextHeaderToMemoryBuffer(PartitionFileSystemFileContext *ctx
|
|||
/* Check buffer size. */
|
||||
if (buf_size < full_header_size)
|
||||
{
|
||||
LOG_MSG("Not enough space available in input buffer to write full Partition FS header! (got 0x%lX, need 0x%lX).", buf_size, full_header_size);
|
||||
LOG_MSG_ERROR("Not enough space available in input buffer to write full Partition FS header! (got 0x%lX, need 0x%lX).", buf_size, full_header_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ bool programInfoInitializeContext(ProgramInfoContext *out, NcaContext *nca_ctx)
|
|||
(nca_ctx->storage_id != NcmStorageId_GameCard && !nca_ctx->ncm_storage) || (nca_ctx->storage_id == NcmStorageId_GameCard && !nca_ctx->gamecard_offset) || \
|
||||
nca_ctx->header.content_type != NcaContentType_Program || nca_ctx->content_type_ctx || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -79,28 +79,28 @@ bool programInfoInitializeContext(ProgramInfoContext *out, NcaContext *nca_ctx)
|
|||
/* Initialize Partition FS context. */
|
||||
if (!pfsInitializeContext(&(out->pfs_ctx), &(nca_ctx->fs_ctx[0])))
|
||||
{
|
||||
LOG_MSG("Failed to initialize Partition FS context!");
|
||||
LOG_MSG_ERROR("Failed to initialize Partition FS context!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Check if we're indeed dealing with an ExeFS. */
|
||||
if (!out->pfs_ctx.is_exefs)
|
||||
{
|
||||
LOG_MSG("Initialized Partition FS is not an ExeFS!");
|
||||
LOG_MSG_ERROR("Initialized Partition FS is not an ExeFS!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Get ExeFS entry count. Edge case, we should never trigger this. */
|
||||
if (!(pfs_entry_count = pfsGetEntryCount(&(out->pfs_ctx))))
|
||||
{
|
||||
LOG_MSG("ExeFS has no file entries!");
|
||||
LOG_MSG_ERROR("ExeFS has no file entries!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Initialize NPDM context. */
|
||||
if (!npdmInitializeContext(&(out->npdm_ctx), &(out->pfs_ctx)))
|
||||
{
|
||||
LOG_MSG("Failed to initialize NPDM context!");
|
||||
LOG_MSG_ERROR("Failed to initialize NPDM context!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ bool programInfoInitializeContext(ProgramInfoContext *out, NcaContext *nca_ctx)
|
|||
/* Reallocate NSO context buffer. */
|
||||
if (!(tmp_nso_ctx = realloc(out->nso_ctx, (out->nso_count + 1) * sizeof(NsoContext))))
|
||||
{
|
||||
LOG_MSG("Failed to reallocate NSO context buffer for NSO \"%s\"! (entry #%u).", pfs_entry_name, i);
|
||||
LOG_MSG_ERROR("Failed to reallocate NSO context buffer for NSO \"%s\"! (entry #%u).", pfs_entry_name, i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ bool programInfoInitializeContext(ProgramInfoContext *out, NcaContext *nca_ctx)
|
|||
/* Initialize NSO context. */
|
||||
if (!nsoInitializeContext(&(out->nso_ctx[out->nso_count]), &(out->pfs_ctx), pfs_entry))
|
||||
{
|
||||
LOG_MSG("Failed to initialize context for NSO \"%s\"! (entry #%u).", pfs_entry_name, i);
|
||||
LOG_MSG_ERROR("Failed to initialize context for NSO \"%s\"! (entry #%u).", pfs_entry_name, i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ bool programInfoInitializeContext(ProgramInfoContext *out, NcaContext *nca_ctx)
|
|||
/* Safety check. */
|
||||
if (!out->nso_count)
|
||||
{
|
||||
LOG_MSG("ExeFS has no NSOs!");
|
||||
LOG_MSG_ERROR("ExeFS has no NSOs!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ bool programInfoGenerateAuthoringToolXml(ProgramInfoContext *program_info_ctx)
|
|||
{
|
||||
if (!programInfoIsValidContext(program_info_ctx))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -187,21 +187,21 @@ bool programInfoGenerateAuthoringToolXml(ProgramInfoContext *program_info_ctx)
|
|||
mbedtls_base64_encode(NULL, 0, &npdm_acid_b64_size, npdm_acid, npdm_acid_size);
|
||||
if (npdm_acid_b64_size <= npdm_acid_size)
|
||||
{
|
||||
LOG_MSG("Invalid Base64 conversion length for the NPDM ACID section! (0x%lX, 0x%lX).", npdm_acid_b64_size, npdm_acid_size);
|
||||
LOG_MSG_ERROR("Invalid Base64 conversion length for the NPDM ACID section! (0x%lX, 0x%lX).", npdm_acid_b64_size, npdm_acid_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Allocate memory for the NPDM ACID Base64 string. */
|
||||
if (!(npdm_acid_b64 = calloc(npdm_acid_b64_size + 1, sizeof(char))))
|
||||
{
|
||||
LOG_MSG("Failed to allocate 0x%lX bytes for the NPDM ACID section Base64 string!", npdm_acid_b64_size);
|
||||
LOG_MSG_ERROR("Failed to allocate 0x%lX bytes for the NPDM ACID section Base64 string!", npdm_acid_b64_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Convert NPDM ACID section to a Base64 string. */
|
||||
if (mbedtls_base64_encode((u8*)npdm_acid_b64, npdm_acid_b64_size + 1, &npdm_acid_b64_size, npdm_acid, npdm_acid_size) != 0)
|
||||
{
|
||||
LOG_MSG("Base64 conversion failed for the NPDM ACID section!");
|
||||
LOG_MSG_ERROR("Base64 conversion failed for the NPDM ACID section!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ end:
|
|||
if (!success)
|
||||
{
|
||||
if (xml_buf) free(xml_buf);
|
||||
LOG_MSG("Failed to generate ProgramInfo AuthoringTool XML!");
|
||||
LOG_MSG_ERROR("Failed to generate ProgramInfo AuthoringTool XML!");
|
||||
}
|
||||
|
||||
return success;
|
||||
|
@ -286,7 +286,7 @@ static bool programInfoGetSdkVersionAndBuildTypeFromSdkNso(ProgramInfoContext *p
|
|||
{
|
||||
if (!program_info_ctx || !program_info_ctx->nso_count || !program_info_ctx->nso_ctx || !sdk_version || !build_type)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ static bool programInfoGetSdkVersionAndBuildTypeFromSdkNso(ProgramInfoContext *p
|
|||
/* Duplicate strings. */
|
||||
if (!(*sdk_version = strndup(sdk_entry_version, sdk_entry_version_len)) || !(*build_type = strdup(sdk_entry_build_type)))
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for output strings!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for output strings!");
|
||||
|
||||
if (*sdk_version)
|
||||
{
|
||||
|
@ -369,7 +369,7 @@ static bool programInfoAddNsoApiListToAuthoringToolXml(char **xml_buf, u64 *xml_
|
|||
if (!xml_buf || !xml_buf_size || !program_info_ctx || !program_info_ctx->nso_count || !program_info_ctx->nso_ctx || !api_list_tag || !*api_list_tag || !api_entry_prefix || \
|
||||
!*api_entry_prefix || !sdk_prefix || !(sdk_prefix_len = strlen(sdk_prefix)))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -462,7 +462,7 @@ static bool programInfoAddStringFieldToAuthoringToolXml(char **xml_buf, u64 *xml
|
|||
{
|
||||
if (!xml_buf || !xml_buf_size || !tag_name || !*tag_name)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -473,7 +473,7 @@ static bool programInfoAddNsoSymbolsToAuthoringToolXml(char **xml_buf, u64 *xml_
|
|||
{
|
||||
if (!xml_buf || !xml_buf_size || !program_info_ctx || !program_info_ctx->npdm_ctx.meta_header || !program_info_ctx->nso_count || !program_info_ctx->nso_ctx)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -570,7 +570,7 @@ static bool programInfoAddFsAccessControlDataToAuthoringToolXml(char **xml_buf,
|
|||
|
||||
if (!xml_buf || !xml_buf_size || !program_info_ctx || !(aci_fac_data = program_info_ctx->npdm_ctx.aci_fac_data))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ bool romfsInitializeContext(RomFileSystemContext *out, NcaFsSectionContext *base
|
|||
!(patch_nca_ctx = (NcaContext*)patch_nca_fs_ctx->nca_ctx) || (!missing_base_romfs && patch_nca_ctx->format_version != base_nca_ctx->format_version) || \
|
||||
patch_nca_fs_ctx->section_type != NcaFsSectionType_PatchRomFs || (patch_nca_ctx->rights_id_available && !patch_nca_ctx->titlekey_retrieved))))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ bool romfsInitializeContext(RomFileSystemContext *out, NcaFsSectionContext *base
|
|||
/* Initialize base NCA storage context. */
|
||||
if (!missing_base_romfs && !ncaStorageInitializeContext(base_storage_ctx, base_nca_fs_ctx))
|
||||
{
|
||||
LOG_MSG("Failed to initialize base NCA storage context!");
|
||||
LOG_MSG_ERROR("Failed to initialize base NCA storage context!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -68,14 +68,14 @@ bool romfsInitializeContext(RomFileSystemContext *out, NcaFsSectionContext *base
|
|||
/* Initialize base NCA storage context. */
|
||||
if (!ncaStorageInitializeContext(patch_storage_ctx, patch_nca_fs_ctx))
|
||||
{
|
||||
LOG_MSG("Failed to initialize patch NCA storage context!");
|
||||
LOG_MSG_ERROR("Failed to initialize patch NCA storage context!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Set patch NCA storage original substorage, if available. */
|
||||
if (!missing_base_romfs && !ncaStorageSetPatchOriginalSubStorage(patch_storage_ctx, base_storage_ctx))
|
||||
{
|
||||
LOG_MSG("Failed to set patch NCA storage context's original substorage!");
|
||||
LOG_MSG_ERROR("Failed to set patch NCA storage context's original substorage!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -91,20 +91,20 @@ bool romfsInitializeContext(RomFileSystemContext *out, NcaFsSectionContext *base
|
|||
/* Get RomFS offset and size. */
|
||||
if (!ncaStorageGetHashTargetExtents(out->default_storage_ctx, &(out->offset), &(out->size)))
|
||||
{
|
||||
LOG_MSG("Failed to get target hash layer extents!");
|
||||
LOG_MSG_ERROR("Failed to get target hash layer extents!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Read RomFS header. */
|
||||
if (!ncaStorageRead(out->default_storage_ctx, &(out->header), sizeof(RomFileSystemHeader), out->offset))
|
||||
{
|
||||
LOG_MSG("Failed to read RomFS header!");
|
||||
LOG_MSG_ERROR("Failed to read RomFS header!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((is_nca0_romfs && out->header.old_format.header_size != ROMFS_OLD_HEADER_SIZE) || (!is_nca0_romfs && out->header.cur_format.header_size != ROMFS_HEADER_SIZE))
|
||||
{
|
||||
LOG_MSG("Invalid RomFS header size!");
|
||||
LOG_MSG_ERROR("Invalid RomFS header size!");
|
||||
dump_fs_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ bool romfsInitializeContext(RomFileSystemContext *out, NcaFsSectionContext *base
|
|||
|
||||
if (!out->dir_table_size || (dir_table_offset + out->dir_table_size) > out->size)
|
||||
{
|
||||
LOG_MSG("Invalid RomFS directory entries table!");
|
||||
LOG_MSG_ERROR("Invalid RomFS directory entries table!");
|
||||
dump_fs_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -123,13 +123,13 @@ bool romfsInitializeContext(RomFileSystemContext *out, NcaFsSectionContext *base
|
|||
out->dir_table = malloc(out->dir_table_size);
|
||||
if (!out->dir_table)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for RomFS directory entries table!");
|
||||
LOG_MSG_ERROR("Unable to allocate memory for RomFS directory entries table!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!ncaStorageRead(out->default_storage_ctx, out->dir_table, out->dir_table_size, out->offset + dir_table_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read RomFS directory entries table!");
|
||||
LOG_MSG_ERROR("Failed to read RomFS directory entries table!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ bool romfsInitializeContext(RomFileSystemContext *out, NcaFsSectionContext *base
|
|||
|
||||
if (!out->file_table_size || (file_table_offset + out->file_table_size) > out->size)
|
||||
{
|
||||
LOG_MSG("Invalid RomFS file entries table!");
|
||||
LOG_MSG_ERROR("Invalid RomFS file entries table!");
|
||||
dump_fs_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -147,13 +147,13 @@ bool romfsInitializeContext(RomFileSystemContext *out, NcaFsSectionContext *base
|
|||
out->file_table = malloc(out->file_table_size);
|
||||
if (!out->file_table)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for RomFS file entries table!");
|
||||
LOG_MSG_ERROR("Unable to allocate memory for RomFS file entries table!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!ncaStorageRead(out->default_storage_ctx, out->file_table, out->file_table_size, out->offset + file_table_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read RomFS file entries table!");
|
||||
LOG_MSG_ERROR("Failed to read RomFS file entries table!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ bool romfsInitializeContext(RomFileSystemContext *out, NcaFsSectionContext *base
|
|||
out->body_offset = (is_nca0_romfs ? (u64)out->header.old_format.body_offset : out->header.cur_format.body_offset);
|
||||
if (out->body_offset >= out->size)
|
||||
{
|
||||
LOG_MSG("Invalid RomFS file data body!");
|
||||
LOG_MSG_ERROR("Invalid RomFS file data body!");
|
||||
dump_fs_header = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ bool romfsInitializeContext(RomFileSystemContext *out, NcaFsSectionContext *base
|
|||
end:
|
||||
if (!success)
|
||||
{
|
||||
if (dump_fs_header) LOG_DATA(&(out->header), sizeof(RomFileSystemHeader), "RomFS header dump:");
|
||||
if (dump_fs_header) LOG_DATA_DEBUG(&(out->header), sizeof(RomFileSystemHeader), "RomFS header dump:");
|
||||
|
||||
romfsFreeContext(out);
|
||||
}
|
||||
|
@ -184,14 +184,14 @@ bool romfsReadFileSystemData(RomFileSystemContext *ctx, void *out, u64 read_size
|
|||
{
|
||||
if (!romfsIsValidContext(ctx) || !out || !read_size || (offset + read_size) > ctx->size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Read filesystem data. */
|
||||
if (!ncaStorageRead(ctx->default_storage_ctx, out, read_size, ctx->offset + offset))
|
||||
{
|
||||
LOG_MSG("Failed to read RomFS data!");
|
||||
LOG_MSG_ERROR("Failed to read RomFS data!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -203,14 +203,14 @@ bool romfsReadFileEntryData(RomFileSystemContext *ctx, RomFileSystemFileEntry *f
|
|||
if (!romfsIsValidContext(ctx) || !file_entry || !file_entry->size || (file_entry->offset + file_entry->size) > ctx->size || !out || !read_size || \
|
||||
(offset + read_size) > file_entry->size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Read entry data. */
|
||||
if (!romfsReadFileSystemData(ctx, out, read_size, ctx->body_offset + file_entry->offset + offset))
|
||||
{
|
||||
LOG_MSG("Failed to read RomFS file entry data!");
|
||||
LOG_MSG_ERROR("Failed to read RomFS file entry data!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ bool romfsGetTotalDataSize(RomFileSystemContext *ctx, bool only_updated, u64 *ou
|
|||
{
|
||||
if (!romfsIsValidContext(ctx) || !out_size || (only_updated && (!ctx->is_patch || ctx->default_storage_ctx->nca_fs_ctx->section_type != NcaFsSectionType_PatchRomFs)))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -240,14 +240,14 @@ bool romfsGetTotalDataSize(RomFileSystemContext *ctx, bool only_updated, u64 *ou
|
|||
/* Get current file entry. */
|
||||
if (!(file_entry = romfsGetCurrentFileEntry(ctx)))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve current file entry! (0x%lX, 0x%lX).", ctx->cur_file_offset, ctx->file_table_size);
|
||||
LOG_MSG_ERROR("Failed to retrieve current file entry! (0x%lX, 0x%lX).", ctx->cur_file_offset, ctx->file_table_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Update total data size, taking into account the only_updated flag. */
|
||||
if (only_updated && !romfsIsFileEntryUpdated(ctx, file_entry, &updated))
|
||||
{
|
||||
LOG_MSG("Failed to determine if file entry is updated or not! (0x%lX, 0x%lX).", ctx->cur_file_offset, ctx->file_table_size);
|
||||
LOG_MSG_ERROR("Failed to determine if file entry is updated or not! (0x%lX, 0x%lX).", ctx->cur_file_offset, ctx->file_table_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ bool romfsGetTotalDataSize(RomFileSystemContext *ctx, bool only_updated, u64 *ou
|
|||
/* Move to the next file entry. */
|
||||
if (!romfsMoveToNextFileEntry(ctx))
|
||||
{
|
||||
LOG_MSG("Failed to move to the next file entry! (0x%lX, 0x%lX).", ctx->cur_file_offset, ctx->file_table_size);
|
||||
LOG_MSG_ERROR("Failed to move to the next file entry! (0x%lX, 0x%lX).", ctx->cur_file_offset, ctx->file_table_size);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ bool romfsGetDirectoryDataSize(RomFileSystemContext *ctx, RomFileSystemDirectory
|
|||
{
|
||||
if (!romfsIsValidContext(ctx) || !dir_entry || !out_size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ bool romfsGetDirectoryDataSize(RomFileSystemContext *ctx, RomFileSystemDirectory
|
|||
/* Get current file entry. */
|
||||
if (!(cur_file_entry = romfsGetFileEntryByOffset(ctx, cur_entry_offset)))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve file entry! (0x%lX, 0x%lX).", cur_entry_offset, ctx->file_table_size);
|
||||
LOG_MSG_ERROR("Failed to retrieve file entry! (0x%lX, 0x%lX).", cur_entry_offset, ctx->file_table_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -317,14 +317,14 @@ bool romfsGetDirectoryDataSize(RomFileSystemContext *ctx, RomFileSystemDirectory
|
|||
/* Get current directory entry. */
|
||||
if (!(cur_dir_entry = romfsGetDirectoryEntryByOffset(ctx, cur_entry_offset)))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve directory entry! (0x%lX, 0x%lX).", cur_entry_offset, ctx->dir_table_size);
|
||||
LOG_MSG_ERROR("Failed to retrieve directory entry! (0x%lX, 0x%lX).", cur_entry_offset, ctx->dir_table_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Calculate directory size. */
|
||||
if (!romfsGetDirectoryDataSize(ctx, cur_dir_entry, &child_dir_size))
|
||||
{
|
||||
LOG_MSG("Failed to get size for directory entry! (0x%lX, 0x%lX).", cur_entry_offset, ctx->dir_table_size);
|
||||
LOG_MSG_ERROR("Failed to get size for directory entry! (0x%lX, 0x%lX).", cur_entry_offset, ctx->dir_table_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ RomFileSystemDirectoryEntry *romfsGetDirectoryEntryByPath(RomFileSystemContext *
|
|||
|
||||
if (!romfsIsValidContext(ctx) || !path || *path != '/' || !(dir_entry = romfsGetDirectoryEntryByOffset(ctx, 0)))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -364,7 +364,7 @@ RomFileSystemDirectoryEntry *romfsGetDirectoryEntryByPath(RomFileSystemContext *
|
|||
/* Duplicate path to avoid problems with strtok_r(). */
|
||||
if (!(path_dup = strdup(path)))
|
||||
{
|
||||
LOG_MSG("Unable to duplicate input path! (\"%s\").", path);
|
||||
LOG_MSG_ERROR("Unable to duplicate input path! (\"%s\").", path);
|
||||
dir_entry = NULL;
|
||||
goto end;
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ RomFileSystemDirectoryEntry *romfsGetDirectoryEntryByPath(RomFileSystemContext *
|
|||
pch = strtok_r(path_dup, "/", &state);
|
||||
if (!pch)
|
||||
{
|
||||
LOG_MSG("Failed to tokenize input path! (\"%s\").", path);
|
||||
LOG_MSG_ERROR("Failed to tokenize input path! (\"%s\").", path);
|
||||
dir_entry = NULL;
|
||||
goto end;
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ RomFileSystemDirectoryEntry *romfsGetDirectoryEntryByPath(RomFileSystemContext *
|
|||
/* Get child directory entry using the current token. */
|
||||
if (!(dir_entry = romfsGetChildDirectoryEntryByName(ctx, dir_entry, pch)))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve directory entry by name for \"%s\"! (\"%s\").", pch, path);
|
||||
LOG_MSG_ERROR("Failed to retrieve directory entry by name for \"%s\"! (\"%s\").", pch, path);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -401,28 +401,23 @@ end:
|
|||
RomFileSystemFileEntry *romfsGetFileEntryByPath(RomFileSystemContext *ctx, const char *path)
|
||||
{
|
||||
size_t path_len = 0;
|
||||
u8 content_type = 0;
|
||||
char *path_dup = NULL, *filename = NULL;
|
||||
RomFileSystemFileEntry *file_entry = NULL;
|
||||
RomFileSystemDirectoryEntry *dir_entry = NULL;
|
||||
NcaContext *nca_ctx = NULL;
|
||||
|
||||
if (!romfsIsValidContext(ctx) || !(nca_ctx = (NcaContext*)ctx->default_storage_ctx->nca_fs_ctx->nca_ctx) || !path || *path != '/')
|
||||
if (!romfsIsValidContext(ctx) || !path || *path != '/')
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Retrieve path length. */
|
||||
path_len = strlen(path);
|
||||
|
||||
/* Retrieve NCA content type. */
|
||||
content_type = nca_ctx->content_type;
|
||||
|
||||
/* Duplicate path. */
|
||||
if (!(path_dup = strdup(path)))
|
||||
{
|
||||
LOG_MSG("Unable to duplicate input path! (\"%s\").", path);
|
||||
LOG_MSG_ERROR("Unable to duplicate input path! (\"%s\").", path);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -436,7 +431,7 @@ RomFileSystemFileEntry *romfsGetFileEntryByPath(RomFileSystemContext *ctx, const
|
|||
/* Safety check. */
|
||||
if (!path_len || !(filename = strrchr(path_dup, '/')))
|
||||
{
|
||||
LOG_MSG("Invalid input path! (\"%s\").", path);
|
||||
LOG_MSG_ERROR("Invalid input path! (\"%s\").", path);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -447,17 +442,12 @@ RomFileSystemFileEntry *romfsGetFileEntryByPath(RomFileSystemContext *ctx, const
|
|||
/* If the first character is NULL, then just retrieve the root directory entry. */
|
||||
if (!(dir_entry = (*path_dup ? romfsGetDirectoryEntryByPath(ctx, path_dup) : romfsGetDirectoryEntryByOffset(ctx, 0))))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve directory entry for \"%s\"! (\"%s\").", *path_dup ? path_dup : "/", path);
|
||||
LOG_MSG_ERROR("Failed to retrieve directory entry for \"%s\"! (\"%s\").", *path_dup ? path_dup : "/", path);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Retrieve file entry. */
|
||||
if (!(file_entry = romfsGetChildFileEntryByName(ctx, dir_entry, filename)))
|
||||
{
|
||||
/* Only log error if we're not dealing with NACP icons or a LegalInformation XML. */
|
||||
bool skip_log = ((!strncmp(path, "/icon_", 6) && content_type == NcmContentType_Control) || (!strcmp(path, "/legalinfo.xml") && content_type == NcmContentType_LegalInformation));
|
||||
if (!skip_log) LOG_MSG("Failed to retrieve file entry by name for \"%s\"! (\"%s\").", filename, path);
|
||||
}
|
||||
if (!(file_entry = romfsGetChildFileEntryByName(ctx, dir_entry, filename))) LOG_MSG_ERROR("Failed to retrieve file entry by name for \"%s\"! (\"%s\").", filename, path);
|
||||
|
||||
end:
|
||||
if (path_dup) free(path_dup);
|
||||
|
@ -476,7 +466,7 @@ bool romfsGeneratePathFromDirectoryEntry(RomFileSystemContext *ctx, RomFileSyste
|
|||
if (!romfsIsValidContext(ctx) || !dir_entry || (!dir_entry->name_length && dir_entry->parent_offset) || !out_path || out_path_size < 2 || \
|
||||
illegal_char_replace_type > RomFileSystemPathIllegalCharReplaceType_KeepAsciiCharsOnly)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -491,7 +481,7 @@ bool romfsGeneratePathFromDirectoryEntry(RomFileSystemContext *ctx, RomFileSyste
|
|||
dir_entries = calloc(1, sizeof(RomFileSystemDirectoryEntry*));
|
||||
if (!dir_entries)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for directory entries!");
|
||||
LOG_MSG_ERROR("Unable to allocate memory for directory entries!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -509,7 +499,7 @@ bool romfsGeneratePathFromDirectoryEntry(RomFileSystemContext *ctx, RomFileSyste
|
|||
/* Reallocate directory entries pointer array. */
|
||||
if (!(tmp_dir_entries = realloc(dir_entries, (dir_entries_count + 1) * sizeof(RomFileSystemDirectoryEntry*))))
|
||||
{
|
||||
LOG_MSG("Unable to reallocate directory entries buffer!");
|
||||
LOG_MSG_ERROR("Unable to reallocate directory entries buffer!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -520,7 +510,7 @@ bool romfsGeneratePathFromDirectoryEntry(RomFileSystemContext *ctx, RomFileSyste
|
|||
RomFileSystemDirectoryEntry **cur_dir_entry = &(dir_entries[dir_entries_count]);
|
||||
if (!(*cur_dir_entry = romfsGetDirectoryEntryByOffset(ctx, dir_offset)) || !(*cur_dir_entry)->name_length)
|
||||
{
|
||||
LOG_MSG("Failed to retrieve directory entry!");
|
||||
LOG_MSG_ERROR("Failed to retrieve directory entry!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -532,7 +522,7 @@ bool romfsGeneratePathFromDirectoryEntry(RomFileSystemContext *ctx, RomFileSyste
|
|||
/* Make sure the output buffer is big enough to hold the full path + NULL terminator. */
|
||||
if (path_len >= out_path_size)
|
||||
{
|
||||
LOG_MSG("Output path length exceeds output buffer size! (%lu >= %lu).", path_len, out_path_size);
|
||||
LOG_MSG_ERROR("Output path length exceeds output buffer size! (%lu >= %lu).", path_len, out_path_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -579,14 +569,14 @@ bool romfsGeneratePathFromFileEntry(RomFileSystemContext *ctx, RomFileSystemFile
|
|||
if (!romfsIsValidContext(ctx) || !file_entry || !file_entry->name_length || !out_path || out_path_size < 2 || \
|
||||
!(dir_entry = romfsGetDirectoryEntryByOffset(ctx, file_entry->parent_offset)) || illegal_char_replace_type > RomFileSystemPathIllegalCharReplaceType_KeepAsciiCharsOnly)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Retrieve full RomFS path up to the file entry name. */
|
||||
if (!romfsGeneratePathFromDirectoryEntry(ctx, dir_entry, out_path, out_path_size, illegal_char_replace_type))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve RomFS directory path!");
|
||||
LOG_MSG_ERROR("Failed to retrieve RomFS directory path!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -594,7 +584,7 @@ bool romfsGeneratePathFromFileEntry(RomFileSystemContext *ctx, RomFileSystemFile
|
|||
path_len = strlen(out_path);
|
||||
if ((path_len + 1 + file_entry->name_length) >= out_path_size)
|
||||
{
|
||||
LOG_MSG("Output path length exceeds output buffer size! (%lu >= %lu).", path_len + 1 + file_entry->name_length, out_path_size);
|
||||
LOG_MSG_ERROR("Output path length exceeds output buffer size! (%lu >= %lu).", path_len + 1 + file_entry->name_length, out_path_size);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -623,7 +613,7 @@ bool romfsIsFileEntryUpdated(RomFileSystemContext *ctx, RomFileSystemFileEntry *
|
|||
if (!romfsIsValidContext(ctx) || !ctx->is_patch || ctx->default_storage_ctx->nca_fs_ctx->section_type != NcaFsSectionType_PatchRomFs || \
|
||||
!file_entry || !file_entry->size || (file_entry->offset + file_entry->size) > ctx->size || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -640,7 +630,7 @@ bool romfsIsFileEntryUpdated(RomFileSystemContext *ctx, RomFileSystemFileEntry *
|
|||
/* Check if any sections from this block belong to the Patch storage. */
|
||||
if (!ncaStorageIsBlockWithinPatchStorageRange(ctx->default_storage_ctx, file_offset, file_entry->size, out))
|
||||
{
|
||||
LOG_MSG("Failed to determine if file entry is within Patch storage range!");
|
||||
LOG_MSG_ERROR("Failed to determine if file entry is within Patch storage range!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -657,7 +647,7 @@ bool romfsGenerateFileEntryPatch(RomFileSystemContext *ctx, RomFileSystemFileEnt
|
|||
(ctx->default_storage_ctx->nca_fs_ctx->section_type != NcaFsSectionType_Nca0RomFs && ctx->default_storage_ctx->nca_fs_ctx->section_type != NcaFsSectionType_RomFs) || \
|
||||
!file_entry || !file_entry->size || (file_entry->offset + file_entry->size) > ctx->size || !data || !data_size || (data_offset + data_size) > file_entry->size || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -676,8 +666,8 @@ bool romfsGenerateFileEntryPatch(RomFileSystemContext *ctx, RomFileSystemFileEnt
|
|||
|
||||
out->written = false;
|
||||
|
||||
if (!success) LOG_MSG("Failed to generate 0x%lX bytes Hierarchical%s patch at offset 0x%lX for RomFS file entry!", data_size, \
|
||||
nca_fs_ctx->section_type == NcaFsSectionType_Nca0RomFs ? "Sha256" : "Integrity", fs_offset);
|
||||
if (!success) LOG_MSG_ERROR("Failed to generate 0x%lX bytes Hierarchical%s patch at offset 0x%lX for RomFS file entry!", data_size, \
|
||||
nca_fs_ctx->section_type == NcaFsSectionType_Nca0RomFs ? "Sha256" : "Integrity", fs_offset);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -690,7 +680,7 @@ static RomFileSystemDirectoryEntry *romfsGetChildDirectoryEntryByName(RomFileSys
|
|||
|
||||
if (!dir_entry || (dir_offset = dir_entry->directory_offset) == ROMFS_VOID_ENTRY || !name || !(name_len = strlen(name)))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -700,7 +690,7 @@ static RomFileSystemDirectoryEntry *romfsGetChildDirectoryEntryByName(RomFileSys
|
|||
/* Get current directory entry. */
|
||||
if (!(child_dir_entry = romfsGetDirectoryEntryByOffset(ctx, dir_offset)))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve directory entry! (0x%lX, 0x%lX).", dir_offset, ctx->dir_table_size);
|
||||
LOG_MSG_ERROR("Failed to retrieve directory entry! (0x%lX, 0x%lX).", dir_offset, ctx->dir_table_size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -724,7 +714,7 @@ static RomFileSystemFileEntry *romfsGetChildFileEntryByName(RomFileSystemContext
|
|||
|
||||
if (!dir_entry || (file_offset = dir_entry->file_offset) == ROMFS_VOID_ENTRY || !name || !(name_len = strlen(name)))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -734,7 +724,7 @@ static RomFileSystemFileEntry *romfsGetChildFileEntryByName(RomFileSystemContext
|
|||
/* Get current file entry. */
|
||||
if (!(child_file_entry = romfsGetFileEntryByOffset(ctx, file_offset)))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve file entry! (0x%lX, 0x%lX).", file_offset, ctx->file_table_size);
|
||||
LOG_MSG_ERROR("Failed to retrieve file entry! (0x%lX, 0x%lX).", file_offset, ctx->file_table_size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ bool rsa2048VerifySha256BasedPssSignature(const void *data, size_t data_size, co
|
|||
{
|
||||
if (!data || !data_size || !signature || !modulus || !public_exponent || !public_exponent_size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ bool rsa2048VerifySha256BasedPssSignature(const void *data, size_t data_size, co
|
|||
mbedtls_ret = mbedtls_rsa_import_raw(&rsa, (const u8*)modulus, RSA2048_BYTES, NULL, 0, NULL, 0, NULL, 0, (const u8*)public_exponent, public_exponent_size);
|
||||
if (mbedtls_ret != 0)
|
||||
{
|
||||
LOG_MSG("mbedtls_rsa_import_raw failed! (%d).", mbedtls_ret);
|
||||
LOG_MSG_ERROR("mbedtls_rsa_import_raw failed! (%d).", mbedtls_ret);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ bool rsa2048VerifySha256BasedPssSignature(const void *data, size_t data_size, co
|
|||
mbedtls_ret = mbedtls_rsa_rsassa_pss_verify(&rsa, NULL, NULL, MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_SHA256, SHA256_HASH_SIZE, hash, (const u8*)signature);
|
||||
if (mbedtls_ret != 0)
|
||||
{
|
||||
LOG_MSG("mbedtls_rsa_rsassa_pss_verify failed! (%d).", mbedtls_ret);
|
||||
LOG_MSG_ERROR("mbedtls_rsa_rsassa_pss_verify failed! (%d).", mbedtls_ret);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ bool rsa2048OaepDecrypt(void *dst, size_t dst_size, const void *signature, const
|
|||
if (!dst || !dst_size || !signature || !modulus || !public_exponent || !public_exponent_size || !private_exponent || !private_exponent_size || (!label && label_size) || (label && !label_size) || \
|
||||
!out_size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ bool rsa2048OaepDecrypt(void *dst, size_t dst_size, const void *signature, const
|
|||
mbedtls_ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, (const u8*)pers, strlen(pers));
|
||||
if (mbedtls_ret != 0)
|
||||
{
|
||||
LOG_MSG("mbedtls_ctr_drbg_seed failed! (%d).", mbedtls_ret);
|
||||
LOG_MSG_ERROR("mbedtls_ctr_drbg_seed failed! (%d).", mbedtls_ret);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ bool rsa2048OaepDecrypt(void *dst, size_t dst_size, const void *signature, const
|
|||
mbedtls_ret = mbedtls_rsa_import_raw(&rsa, (const u8*)modulus, RSA2048_BYTES, NULL, 0, NULL, 0, (const u8*)private_exponent, private_exponent_size, (const u8*)public_exponent, public_exponent_size);
|
||||
if (mbedtls_ret != 0)
|
||||
{
|
||||
LOG_MSG("mbedtls_rsa_import_raw failed! (%d).", mbedtls_ret);
|
||||
LOG_MSG_ERROR("mbedtls_rsa_import_raw failed! (%d).", mbedtls_ret);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ bool rsa2048OaepDecrypt(void *dst, size_t dst_size, const void *signature, const
|
|||
mbedtls_ret = mbedtls_rsa_complete(&rsa);
|
||||
if (mbedtls_ret != 0)
|
||||
{
|
||||
LOG_MSG("mbedtls_rsa_complete failed! (%d).", mbedtls_ret);
|
||||
LOG_MSG_ERROR("mbedtls_rsa_complete failed! (%d).", mbedtls_ret);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ bool rsa2048OaepDecrypt(void *dst, size_t dst_size, const void *signature, const
|
|||
mbedtls_ret = mbedtls_rsa_rsaes_oaep_decrypt(&rsa, mbedtls_ctr_drbg_random, &ctr_drbg, MBEDTLS_RSA_PRIVATE, (const u8*)label, label_size, out_size, (const u8*)signature, (u8*)dst, dst_size);
|
||||
if (mbedtls_ret != 0)
|
||||
{
|
||||
LOG_MSG("mbedtls_rsa_rsaes_oaep_decrypt failed! (%d).", mbedtls_ret);
|
||||
LOG_MSG_ERROR("mbedtls_rsa_rsaes_oaep_decrypt failed! (%d).", mbedtls_ret);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -109,7 +109,7 @@ bool servicesInitialize(void)
|
|||
Result rc = service_info->init_func();
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("Failed to initialize \"%s\" service! (0x%08X).", service_info->name, rc);
|
||||
LOG_MSG_ERROR("Failed to initialize \"%s\" service! (0x%X).", service_info->name, rc);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
|
@ -157,12 +157,12 @@ bool servicesCheckRunningServiceByName(const char *name)
|
|||
{
|
||||
if (!name || !*name || !_servicesCheckInitializedServiceByName("spl:"))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
break;
|
||||
}
|
||||
|
||||
Result rc = servicesAtmosphereHasService(&ret, smEncodeName(name));
|
||||
if (R_FAILED(rc)) LOG_MSG("servicesAtmosphereHasService failed for \"%s\"! (0x%08X).", name, rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("servicesAtmosphereHasService failed for \"%s\"! (0x%X).", name, rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -174,7 +174,7 @@ void servicesChangeHardwareClockRates(u32 cpu_rate, u32 mem_rate)
|
|||
{
|
||||
if ((g_clkSvcUsePcv && !_servicesCheckInitializedServiceByName("pcv")) || (!g_clkSvcUsePcv && !_servicesCheckInitializedServiceByName("clkrst")))
|
||||
{
|
||||
LOG_MSG("Error: clock service uninitialized.");
|
||||
LOG_MSG_ERROR("Error: clock service uninitialized.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -189,8 +189,8 @@ void servicesChangeHardwareClockRates(u32 cpu_rate, u32 mem_rate)
|
|||
rc2 = clkrstSetClockRate(&g_clkrstMemSession, mem_rate);
|
||||
}
|
||||
|
||||
if (R_FAILED(rc1)) LOG_MSG("%sSetClockRate failed! (0x%08X) (CPU).", (g_clkSvcUsePcv ? "pcv" : "clkrst"), rc1);
|
||||
if (R_FAILED(rc2)) LOG_MSG("%sSetClockRate failed! (0x%08X) (MEM).", (g_clkSvcUsePcv ? "pcv" : "clkrst"), rc2);
|
||||
if (R_FAILED(rc1)) LOG_MSG_ERROR("%sSetClockRate failed! (0x%X) (CPU).", (g_clkSvcUsePcv ? "pcv" : "clkrst"), rc1);
|
||||
if (R_FAILED(rc2)) LOG_MSG_ERROR("%sSetClockRate failed! (0x%X) (MEM).", (g_clkSvcUsePcv ? "pcv" : "clkrst"), rc2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ static Result servicesAtmosphereHasService(bool *out, SmServiceName name)
|
|||
if (!g_atmosphereVersion)
|
||||
{
|
||||
rc = servicesGetExosphereApiVersion(&g_atmosphereVersion);
|
||||
if (R_FAILED(rc)) LOG_MSG("servicesGetExosphereApiVersion failed! (0x%08X).", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("servicesGetExosphereApiVersion failed! (0x%X).", rc);
|
||||
}
|
||||
|
||||
/* Check if service is running. */
|
||||
|
@ -256,7 +256,7 @@ static Result servicesGetExosphereApiVersion(u32 *out)
|
|||
if (R_SUCCEEDED(rc))
|
||||
{
|
||||
*out = version = (u32)((cfg >> 40) & 0xFFFFFF);
|
||||
LOG_MSG("Exosphère API version: %u.%u.%u.", HOSVER_MAJOR(version), HOSVER_MINOR(version), HOSVER_MICRO(version));
|
||||
LOG_MSG_INFO("Exosphère API version: %u.%u.%u.", HOSVER_MAJOR(version), HOSVER_MINOR(version), HOSVER_MICRO(version));
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
@ -275,7 +275,7 @@ static Result servicesClkrstInitialize(void)
|
|||
rc = clkrstInitialize();
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("clkrstInitialize failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("clkrstInitialize failed! (0x%X).", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ static Result servicesClkrstInitialize(void)
|
|||
rc = clkrstOpenSession(&g_clkrstCpuSession, PcvModuleId_CpuBus, 3);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("clkrstOpenSession failed! (0x%08X) (CPU).", rc);
|
||||
LOG_MSG_ERROR("clkrstOpenSession failed! (0x%X) (CPU).", rc);
|
||||
clkrstExit();
|
||||
return rc;
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ static Result servicesClkrstInitialize(void)
|
|||
rc = clkrstOpenSession(&g_clkrstMemSession, PcvModuleId_EMC, 3);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("clkrstOpenSession failed! (0x%08X) (MEM).", rc);
|
||||
LOG_MSG_ERROR("clkrstOpenSession failed! (0x%X) (MEM).", rc);
|
||||
clkrstCloseSession(&g_clkrstCpuSession);
|
||||
clkrstExit();
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ void sha3ContextUpdate(Sha3Context *ctx, const void *src, size_t size)
|
|||
{
|
||||
if (!ctx || !src || !size || ctx->finalized)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ void sha3ContextGetHash(Sha3Context *ctx, void *dst)
|
|||
{
|
||||
if (!ctx || !dst)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ static void sha3ContextCreate(Sha3Context *out, u32 hash_size)
|
|||
{
|
||||
if (!out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ bool tikRetrieveTicketByRightsId(Ticket *dst, const FsRightsId *id, bool use_gam
|
|||
{
|
||||
if (!dst || !id)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -127,14 +127,14 @@ bool tikRetrieveTicketByRightsId(Ticket *dst, const FsRightsId *id, bool use_gam
|
|||
bool tik_retrieved = (use_gamecard ? tikRetrieveTicketFromGameCardByRightsId(dst, id) : tikRetrieveTicketFromEsSaveDataByRightsId(dst, id));
|
||||
if (!tik_retrieved)
|
||||
{
|
||||
LOG_MSG("Unable to retrieve ticket data!");
|
||||
LOG_MSG_ERROR("Unable to retrieve ticket data!");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Get encrypted titlekey from ticket. */
|
||||
if (!tikGetEncryptedTitleKeyFromTicket(dst))
|
||||
{
|
||||
LOG_MSG("Unable to retrieve encrypted titlekey from ticket!");
|
||||
LOG_MSG_ERROR("Unable to retrieve encrypted titlekey from ticket!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ bool tikRetrieveTicketByRightsId(Ticket *dst, const FsRightsId *id, bool use_gam
|
|||
/* Get decrypted titlekey. */
|
||||
if (!tikGetDecryptedTitleKey(dst->dec_titlekey, dst->enc_titlekey, key_generation))
|
||||
{
|
||||
LOG_MSG("Unable to decrypt titlekey!");
|
||||
LOG_MSG_ERROR("Unable to decrypt titlekey!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ bool tikConvertPersonalizedTicketToCommonTicket(Ticket *tik, u8 **out_raw_cert_c
|
|||
if (!tik || tik->type == TikType_None || tik->type > TikType_SigHmac160 || tik->size < SIGNED_TIK_MIN_SIZE || tik->size > SIGNED_TIK_MAX_SIZE || \
|
||||
!(tik_common_block = tikGetCommonBlock(tik->data)) || tik_common_block->titlekey_type != TikTitleKeyType_Personalized || !out_raw_cert_chain || !out_raw_cert_chain_size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ bool tikConvertPersonalizedTicketToCommonTicket(Ticket *tik, u8 **out_raw_cert_c
|
|||
|
||||
if (!raw_cert_chain)
|
||||
{
|
||||
LOG_MSG("Failed to generate raw certificate chain for common ticket signature issuer!");
|
||||
LOG_MSG_ERROR("Failed to generate raw certificate chain for common ticket signature issuer!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ static bool tikRetrieveTicketFromGameCardByRightsId(Ticket *dst, const FsRightsI
|
|||
{
|
||||
if (!dst || !id)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -252,25 +252,25 @@ static bool tikRetrieveTicketFromGameCardByRightsId(Ticket *dst, const FsRightsI
|
|||
|
||||
if (!gamecardGetHashFileSystemEntryInfoByName(GameCardHashFileSystemPartitionType_Secure, tik_filename, &tik_offset, &tik_size))
|
||||
{
|
||||
LOG_MSG("Error retrieving offset and size for \"%s\" entry in secure hash FS partition!", tik_filename);
|
||||
LOG_MSG_ERROR("Error retrieving offset and size for \"%s\" entry in secure hash FS partition!", tik_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tik_size < SIGNED_TIK_MIN_SIZE || tik_size > SIGNED_TIK_MAX_SIZE)
|
||||
{
|
||||
LOG_MSG("Invalid size for \"%s\"! (0x%lX).", tik_filename, tik_size);
|
||||
LOG_MSG_ERROR("Invalid size for \"%s\"! (0x%lX).", tik_filename, tik_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!gamecardReadStorage(dst->data, tik_size, tik_offset))
|
||||
{
|
||||
LOG_MSG("Failed to read \"%s\" data from the inserted gamecard!", tik_filename);
|
||||
LOG_MSG_ERROR("Failed to read \"%s\" data from the inserted gamecard!", tik_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!tikGetTicketTypeAndSize(dst->data, tik_size, &(dst->type), &(dst->size)))
|
||||
{
|
||||
LOG_MSG("Unable to determine ticket type and size!");
|
||||
LOG_MSG_ERROR("Unable to determine ticket type and size!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ static bool tikRetrieveTicketFromEsSaveDataByRightsId(Ticket *dst, const FsRight
|
|||
{
|
||||
if (!dst || !id)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -298,42 +298,42 @@ static bool tikRetrieveTicketFromEsSaveDataByRightsId(Ticket *dst, const FsRight
|
|||
/* Allocate memory to retrieve the ticket. */
|
||||
if (!(buf = malloc(buf_size)))
|
||||
{
|
||||
LOG_MSG("Unable to allocate 0x%lX bytes block for temporary read buffer!", buf_size);
|
||||
LOG_MSG_ERROR("Unable to allocate 0x%lX bytes block for temporary read buffer!", buf_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Get titlekey type. */
|
||||
if (!tikGetTitleKeyTypeFromRightsId(id, &titlekey_type))
|
||||
{
|
||||
LOG_MSG("Unable to retrieve ticket titlekey type!");
|
||||
LOG_MSG_ERROR("Unable to retrieve ticket titlekey type!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Open ES common/personalized system savefile. */
|
||||
if (!(save_ctx = save_open_savefile(titlekey_type == TikTitleKeyType_Common ? TIK_COMMON_SAVEFILE_PATH : TIK_PERSONALIZED_SAVEFILE_PATH, 0)))
|
||||
{
|
||||
LOG_MSG("Failed to open ES %s ticket system savefile!", g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
LOG_MSG_ERROR("Failed to open ES %s ticket system savefile!", g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Get ticket entry offset from ticket_list.bin. */
|
||||
if (!tikGetTicketEntryOffsetFromTicketList(save_ctx, buf, buf_size, id, &ticket_offset, titlekey_type))
|
||||
{
|
||||
LOG_MSG("Unable to find an entry with a matching Rights ID in \"%s\" from ES %s ticket system save!", TIK_LIST_STORAGE_PATH, g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
LOG_MSG_ERROR("Unable to find an entry with a matching Rights ID in \"%s\" from ES %s ticket system save!", TIK_LIST_STORAGE_PATH, g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Get ticket entry from ticket.bin. */
|
||||
if (!tikRetrieveTicketEntryFromTicketBin(save_ctx, buf, buf_size, id, ticket_offset, titlekey_type))
|
||||
{
|
||||
LOG_MSG("Unable to find a matching %s ticket entry for the provided Rights ID!", g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
LOG_MSG_ERROR("Unable to find a matching %s ticket entry for the provided Rights ID!", g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Get ticket type and size. */
|
||||
if (!tikGetTicketTypeAndSize(buf, SIGNED_TIK_MAX_SIZE, &(dst->type), &(dst->size)))
|
||||
{
|
||||
LOG_MSG("Unable to determine ticket type and size!");
|
||||
LOG_MSG_ERROR("Unable to determine ticket type and size!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,7 @@ static bool tikGetEncryptedTitleKeyFromTicket(Ticket *tik)
|
|||
|
||||
if (!tik || !(tik_common_block = tikGetCommonBlock(tik->data)))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -371,7 +371,7 @@ static bool tikGetEncryptedTitleKeyFromTicket(Ticket *tik)
|
|||
if (!keysDecryptRsaOaepWrappedTitleKey(tik_common_block->titlekey_block, tik->enc_titlekey)) return false;
|
||||
break;
|
||||
default:
|
||||
LOG_MSG("Invalid titlekey type value! (0x%02X).", tik_common_block->titlekey_type);
|
||||
LOG_MSG_ERROR("Invalid titlekey type value! (0x%02X).", tik_common_block->titlekey_type);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ static bool tikGetDecryptedTitleKey(void *dst, const void *src, u8 key_generatio
|
|||
{
|
||||
if (!dst || !src)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ static bool tikGetDecryptedTitleKey(void *dst, const void *src, u8 key_generatio
|
|||
ticket_common_key = keysGetTicketCommonKey(key_generation);
|
||||
if (!ticket_common_key)
|
||||
{
|
||||
LOG_MSG("Unable to retrieve ticket common key for key generation 0x%02X!", key_generation);
|
||||
LOG_MSG_ERROR("Unable to retrieve ticket common key for key generation 0x%02X!", key_generation);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,7 @@ static bool tikGetTitleKeyTypeFromRightsId(const FsRightsId *id, u8 *out)
|
|||
{
|
||||
if (!id || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -421,7 +421,7 @@ static bool tikGetTitleKeyTypeFromRightsId(const FsRightsId *id, u8 *out)
|
|||
|
||||
if (!tikRetrieveRightsIdsByTitleKeyType(&rights_ids, &count, i == 1))
|
||||
{
|
||||
LOG_MSG("Unable to retrieve %s rights IDs!", g_tikTitleKeyTypeStrings[i]);
|
||||
LOG_MSG_ERROR("Unable to retrieve %s rights IDs!", g_tikTitleKeyTypeStrings[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -449,7 +449,7 @@ static bool tikRetrieveRightsIdsByTitleKeyType(FsRightsId **out, u32 *out_count,
|
|||
{
|
||||
if (!out || !out_count)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -467,27 +467,27 @@ static bool tikRetrieveRightsIdsByTitleKeyType(FsRightsId **out, u32 *out_count,
|
|||
rc = (personalized ? esCountPersonalizedTicket((s32*)&count) : esCountCommonTicket((s32*)&count));
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("esCount%c%sTicket failed! (0x%08X).", toupper(g_tikTitleKeyTypeStrings[str_idx][0]), g_tikTitleKeyTypeStrings[str_idx] + 1, rc);
|
||||
LOG_MSG_ERROR("esCount%c%sTicket failed! (0x%X).", toupper(g_tikTitleKeyTypeStrings[str_idx][0]), g_tikTitleKeyTypeStrings[str_idx] + 1, rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!count)
|
||||
{
|
||||
LOG_MSG("No %s tickets available!", g_tikTitleKeyTypeStrings[str_idx]);
|
||||
LOG_MSG_ERROR("No %s tickets available!", g_tikTitleKeyTypeStrings[str_idx]);
|
||||
return true;
|
||||
}
|
||||
|
||||
rights_ids = calloc(count, sizeof(FsRightsId));
|
||||
if (!rights_ids)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for %s rights IDs!", g_tikTitleKeyTypeStrings[str_idx]);
|
||||
LOG_MSG_ERROR("Unable to allocate memory for %s rights IDs!", g_tikTitleKeyTypeStrings[str_idx]);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = (personalized ? esListPersonalizedTicket((s32*)&ids_written, rights_ids, (s32)count) : esListCommonTicket((s32*)&ids_written, rights_ids, (s32)count));
|
||||
if (R_FAILED(rc) || !ids_written)
|
||||
{
|
||||
LOG_MSG("esList%c%sTicket failed! (0x%08X). Wrote %u entries, expected %u entries.", toupper(g_tikTitleKeyTypeStrings[str_idx][0]), g_tikTitleKeyTypeStrings[str_idx] + 1, rc, ids_written, count);
|
||||
LOG_MSG_ERROR("esList%c%sTicket failed! (0x%X). Wrote %u entries, expected %u entries.", toupper(g_tikTitleKeyTypeStrings[str_idx][0]), g_tikTitleKeyTypeStrings[str_idx] + 1, rc, ids_written, count);
|
||||
free(rights_ids);
|
||||
return false;
|
||||
}
|
||||
|
@ -502,7 +502,7 @@ static bool tikGetTicketEntryOffsetFromTicketList(save_ctx_t *save_ctx, u8 *buf,
|
|||
{
|
||||
if (!save_ctx || !buf || !buf_size || (buf_size % sizeof(TikListEntry)) != 0 || !id || !out_offset)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -517,14 +517,14 @@ static bool tikGetTicketEntryOffsetFromTicketList(save_ctx_t *save_ctx, u8 *buf,
|
|||
/* Get FAT storage info for the ticket_list.bin stored within the opened system savefile. */
|
||||
if (!save_get_fat_storage_from_file_entry_by_path(save_ctx, TIK_LIST_STORAGE_PATH, &fat_storage, &ticket_list_bin_size))
|
||||
{
|
||||
LOG_MSG("Failed to locate \"%s\" in ES %s ticket system save!", TIK_LIST_STORAGE_PATH, g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
LOG_MSG_ERROR("Failed to locate \"%s\" in ES %s ticket system save!", TIK_LIST_STORAGE_PATH, g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Check ticket_list.bin size. */
|
||||
if (ticket_list_bin_size < sizeof(TikListEntry) || (ticket_list_bin_size % sizeof(TikListEntry)) != 0)
|
||||
{
|
||||
LOG_MSG("Invalid size for \"%s\" in ES %s ticket system save! (0x%lX).", TIK_LIST_STORAGE_PATH, g_tikTitleKeyTypeStrings[titlekey_type], ticket_list_bin_size);
|
||||
LOG_MSG_ERROR("Invalid size for \"%s\" in ES %s ticket system save! (0x%lX).", TIK_LIST_STORAGE_PATH, g_tikTitleKeyTypeStrings[titlekey_type], ticket_list_bin_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -535,7 +535,7 @@ static bool tikGetTicketEntryOffsetFromTicketList(save_ctx_t *save_ctx, u8 *buf,
|
|||
|
||||
if ((br = save_allocation_table_storage_read(&fat_storage, buf, total_br, buf_size)) != buf_size)
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%lX bytes chunk at offset 0x%lX from \"%s\" in ES %s ticket system save!", buf_size, total_br, TIK_LIST_STORAGE_PATH, g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
LOG_MSG_ERROR("Failed to read 0x%lX bytes chunk at offset 0x%lX from \"%s\" in ES %s ticket system save!", buf_size, total_br, TIK_LIST_STORAGE_PATH, g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -575,7 +575,7 @@ static bool tikRetrieveTicketEntryFromTicketBin(save_ctx_t *save_ctx, u8 *buf, u
|
|||
{
|
||||
if (!save_ctx || !buf || buf_size < SIGNED_TIK_MAX_SIZE || !id || (ticket_offset % SIGNED_TIK_MAX_SIZE) != 0)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -592,21 +592,21 @@ static bool tikRetrieveTicketEntryFromTicketBin(save_ctx_t *save_ctx, u8 *buf, u
|
|||
/* Get FAT storage info for the ticket.bin stored within the opened system savefile. */
|
||||
if (!save_get_fat_storage_from_file_entry_by_path(save_ctx, TIK_DB_STORAGE_PATH, &fat_storage, &ticket_bin_size))
|
||||
{
|
||||
LOG_MSG("Failed to locate \"%s\" in ES %s ticket system save!", TIK_DB_STORAGE_PATH, g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
LOG_MSG_ERROR("Failed to locate \"%s\" in ES %s ticket system save!", TIK_DB_STORAGE_PATH, g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Check ticket.bin size. */
|
||||
if (ticket_bin_size < SIGNED_TIK_MIN_SIZE || (ticket_bin_size % SIGNED_TIK_MAX_SIZE) != 0 || ticket_bin_size < (ticket_offset + SIGNED_TIK_MAX_SIZE))
|
||||
{
|
||||
LOG_MSG("Invalid size for \"%s\" in ES %s ticket system save! (0x%lX).", TIK_DB_STORAGE_PATH, g_tikTitleKeyTypeStrings[titlekey_type], ticket_bin_size);
|
||||
LOG_MSG_ERROR("Invalid size for \"%s\" in ES %s ticket system save! (0x%lX).", TIK_DB_STORAGE_PATH, g_tikTitleKeyTypeStrings[titlekey_type], ticket_bin_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Read ticket data. */
|
||||
if ((br = save_allocation_table_storage_read(&fat_storage, buf, ticket_offset, SIGNED_TIK_MAX_SIZE)) != SIGNED_TIK_MAX_SIZE)
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%X-byte long ticket at offset 0x%lX from \"%s\" in ES %s ticket system save!", SIGNED_TIK_MAX_SIZE, ticket_offset, TIK_DB_STORAGE_PATH, \
|
||||
LOG_MSG_ERROR("Failed to read 0x%X-byte long ticket at offset 0x%lX from \"%s\" in ES %s ticket system save!", SIGNED_TIK_MAX_SIZE, ticket_offset, TIK_DB_STORAGE_PATH, \
|
||||
g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
return false;
|
||||
}
|
||||
|
@ -620,14 +620,14 @@ static bool tikRetrieveTicketEntryFromTicketBin(save_ctx_t *save_ctx, u8 *buf, u
|
|||
/* Don't proceed if HOS version isn't at least 9.0.0. */
|
||||
if (!hosversionAtLeast(9, 0, 0))
|
||||
{
|
||||
LOG_MSG("Unable to retrieve ES key entry for volatile tickets under HOS versions below 9.0.0!");
|
||||
LOG_MSG_ERROR("Unable to retrieve ES key entry for volatile tickets under HOS versions below 9.0.0!");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Retrieve ES program memory. */
|
||||
if (!memRetrieveFullProgramMemory(&g_esMemoryLocation))
|
||||
{
|
||||
LOG_MSG("Failed to retrieve ES program memory!");
|
||||
LOG_MSG_ERROR("Failed to retrieve ES program memory!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -664,13 +664,13 @@ static bool tikRetrieveTicketEntryFromTicketBin(save_ctx_t *save_ctx, u8 *buf, u
|
|||
/* Check if we were able to decrypt the ticket. */
|
||||
if (!tik_common_block)
|
||||
{
|
||||
LOG_MSG("Unable to decrypt volatile ticket at offset 0x%lX in \"%s\" from ES %s ticket system save!", ticket_offset, TIK_DB_STORAGE_PATH, g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
LOG_MSG_ERROR("Unable to decrypt volatile ticket at offset 0x%lX in \"%s\" from ES %s ticket system save!", ticket_offset, TIK_DB_STORAGE_PATH, g_tikTitleKeyTypeStrings[titlekey_type]);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the rights ID from the ticket common block matches the one we're looking for. */
|
||||
if (!(success = (memcmp(tik_common_block->rights_id.c, id->c, 0x10) == 0))) LOG_MSG("Retrieved ticket doesn't hold a matching Rights ID!");
|
||||
if (!(success = (memcmp(tik_common_block->rights_id.c, id->c, 0x10) == 0))) LOG_MSG_ERROR("Retrieved ticket doesn't hold a matching Rights ID!");
|
||||
|
||||
end:
|
||||
if (is_volatile) memFreeMemoryLocation(&g_esMemoryLocation);
|
||||
|
@ -686,13 +686,13 @@ static bool tikGetTicketTypeAndSize(void *data, u64 data_size, u8 *out_type, u64
|
|||
|
||||
if (!data || data_size < SIGNED_TIK_MIN_SIZE || data_size > SIGNED_TIK_MAX_SIZE || !out_type || !out_size)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(signed_ticket_size = tikGetSignedTicketSize(data)) || signed_ticket_size > data_size)
|
||||
{
|
||||
LOG_MSG("Input buffer doesn't hold a valid signed ticket!");
|
||||
LOG_MSG_ERROR("Input buffer doesn't hold a valid signed ticket!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -543,14 +543,14 @@ bool titleInitialize(void)
|
|||
g_nsAppControlData = calloc(1, sizeof(NsApplicationControlData));
|
||||
if (!g_nsAppControlData)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for the ns application control data!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for the ns application control data!");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Generate application metadata entries from hardcoded system titles, since we can't retrieve their names via ns. */
|
||||
if (!titleGenerateMetadataEntriesFromSystemTitles())
|
||||
{
|
||||
LOG_MSG("Failed to generate application metadata from hardcoded system titles!");
|
||||
LOG_MSG_ERROR("Failed to generate application metadata from hardcoded system titles!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -559,7 +559,7 @@ bool titleInitialize(void)
|
|||
/* However, if any new gamecard is inserted while the application is running, we *will* have to retrieve the metadata from its application(s). */
|
||||
if (!titleGenerateMetadataEntriesFromNsRecords())
|
||||
{
|
||||
LOG_MSG("Failed to generate application metadata from ns records!");
|
||||
LOG_MSG_ERROR("Failed to generate application metadata from ns records!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -567,7 +567,7 @@ bool titleInitialize(void)
|
|||
/* The background gamecard title thread will take care of initializing the gamecard title storage. */
|
||||
if (!titleInitializePersistentTitleStorages())
|
||||
{
|
||||
LOG_MSG("Failed to initialize persistent title storages!");
|
||||
LOG_MSG_ERROR("Failed to initialize persistent title storages!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -578,7 +578,7 @@ bool titleInitialize(void)
|
|||
g_titleGameCardStatusChangeUserEvent = gamecardGetStatusChangeUserEvent();
|
||||
if (!g_titleGameCardStatusChangeUserEvent)
|
||||
{
|
||||
LOG_MSG("Failed to retrieve gamecard status change user event!");
|
||||
LOG_MSG_ERROR("Failed to retrieve gamecard status change user event!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -644,7 +644,7 @@ TitleApplicationMetadata **titleGetApplicationMetadataEntries(bool is_system, u3
|
|||
{
|
||||
if (!g_titleInterfaceInit || (is_system && (!g_systemMetadata || !g_systemMetadataCount)) || (!is_system && (!g_userMetadata || !g_userMetadataCount)) || !out_count)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -665,7 +665,7 @@ TitleApplicationMetadata **titleGetApplicationMetadataEntries(bool is_system, u3
|
|||
tmp_app_metadata = realloc(app_metadata, (app_count + 1) * sizeof(TitleApplicationMetadata*));
|
||||
if (!tmp_app_metadata)
|
||||
{
|
||||
LOG_MSG("Failed to reallocate application metadata pointer array!");
|
||||
LOG_MSG_ERROR("Failed to reallocate application metadata pointer array!");
|
||||
if (app_metadata) free(app_metadata);
|
||||
app_metadata = NULL;
|
||||
error = true;
|
||||
|
@ -684,7 +684,7 @@ TitleApplicationMetadata **titleGetApplicationMetadataEntries(bool is_system, u3
|
|||
/* Update output counter. */
|
||||
*out_count = app_count;
|
||||
|
||||
if (!app_metadata || !app_count) LOG_MSG("No content data found for %s!", is_system ? "system titles" : "user applications");
|
||||
if (!app_metadata || !app_count) LOG_MSG_ERROR("No content data found for %s!", is_system ? "system titles" : "user applications");
|
||||
}
|
||||
|
||||
return app_metadata;
|
||||
|
@ -700,7 +700,7 @@ TitleInfo *titleGetInfoFromStorageByTitleId(u8 storage_id, u64 title_id)
|
|||
if (title_info)
|
||||
{
|
||||
ret = titleDuplicateTitleInfo(title_info, NULL, NULL, NULL);
|
||||
if (!ret) LOG_MSG("Failed to duplicate title info for %016lX!", title_id);
|
||||
if (!ret) LOG_MSG_ERROR("Failed to duplicate title info for %016lX!", title_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -750,7 +750,7 @@ bool titleGetUserApplicationData(u64 app_id, TitleUserApplicationData *out)
|
|||
{
|
||||
if (!g_titleInterfaceInit || !app_id || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -766,7 +766,7 @@ bool titleGetUserApplicationData(u64 app_id, TitleUserApplicationData *out)
|
|||
out->app_info = titleDuplicateTitleInfo(app_info, NULL, NULL, NULL);
|
||||
if (!out->app_info)
|
||||
{
|
||||
LOG_MSG("Failed to duplicate user application info for %016lX!", app_id);
|
||||
LOG_MSG_ERROR("Failed to duplicate user application info for %016lX!", app_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -778,7 +778,7 @@ bool titleGetUserApplicationData(u64 app_id, TitleUserApplicationData *out)
|
|||
out->patch_info = titleDuplicateTitleInfo(patch_info, out->app_info, NULL, NULL);
|
||||
if (!out->patch_info)
|
||||
{
|
||||
LOG_MSG("Failed to duplicate patch info for %016lX!", app_id);
|
||||
LOG_MSG_ERROR("Failed to duplicate patch info for %016lX!", app_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -809,14 +809,14 @@ bool titleGetUserApplicationData(u64 app_id, TitleUserApplicationData *out)
|
|||
out->aoc_info = titleDuplicateTitleInfo(aoc_info, out->app_info, NULL, NULL);
|
||||
if (!out->aoc_info)
|
||||
{
|
||||
LOG_MSG("Failed to duplicate add-on content info for %016lX!", app_id);
|
||||
LOG_MSG_ERROR("Failed to duplicate add-on content info for %016lX!", app_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check retrieved title info. */
|
||||
ret = (app_info || patch_info || aoc_info);
|
||||
if (!ret) LOG_MSG("Failed to retrieve user application data for ID \"%016lX\"!", app_id);
|
||||
if (!ret) LOG_MSG_ERROR("Failed to retrieve user application data for ID \"%016lX\"!", app_id);
|
||||
}
|
||||
|
||||
/* Clear output. */
|
||||
|
@ -872,7 +872,7 @@ TitleInfo **titleGetOrphanTitles(u32 *out_count)
|
|||
{
|
||||
if (!g_titleInterfaceInit || !g_orphanTitleInfo || !*g_orphanTitleInfo || !g_orphanTitleInfoCount || !out_count)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -880,7 +880,7 @@ TitleInfo **titleGetOrphanTitles(u32 *out_count)
|
|||
orphan_info = calloc(g_orphanTitleInfoCount + 1, sizeof(TitleInfo*));
|
||||
if (!orphan_info)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for orphan title info pointer array!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for orphan title info pointer array!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -890,7 +890,7 @@ TitleInfo **titleGetOrphanTitles(u32 *out_count)
|
|||
orphan_info[i] = titleDuplicateTitleInfo(g_orphanTitleInfo[i], NULL, NULL, NULL);
|
||||
if (!orphan_info[i])
|
||||
{
|
||||
LOG_MSG("Failed to duplicate info for orphan title %016lX!", g_orphanTitleInfo[i]->meta_key.id);
|
||||
LOG_MSG_ERROR("Failed to duplicate info for orphan title %016lX!", g_orphanTitleInfo[i]->meta_key.id);
|
||||
titleFreeOrphanTitles(&orphan_info);
|
||||
break;
|
||||
}
|
||||
|
@ -938,7 +938,7 @@ char *titleGenerateFileName(TitleInfo *title_info, u8 naming_convention, u8 ille
|
|||
if (!title_info || title_info->meta_key.type < NcmContentMetaType_Application || title_info->meta_key.type > NcmContentMetaType_Delta || naming_convention > TitleNamingConvention_IdAndVersionOnly || \
|
||||
(naming_convention == TitleNamingConvention_Full && illegal_char_replace_type > TitleFileNameIllegalCharReplaceType_KeepAsciiCharsOnly))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -972,7 +972,7 @@ char *titleGenerateFileName(TitleInfo *title_info, u8 naming_convention, u8 ille
|
|||
|
||||
/* Duplicate generated filename. */
|
||||
filename = strdup(title_name);
|
||||
if (!filename) LOG_MSG("Failed to duplicate generated filename!");
|
||||
if (!filename) LOG_MSG_ERROR("Failed to duplicate generated filename!");
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
@ -995,7 +995,7 @@ char *titleGenerateGameCardFileName(u8 naming_convention, u8 illegal_char_replac
|
|||
if (!g_titleInterfaceInit || !g_titleGameCardAvailable || naming_convention > TitleNamingConvention_IdAndVersionOnly || \
|
||||
(naming_convention == TitleNamingConvention_Full && illegal_char_replace_type > TitleFileNameIllegalCharReplaceType_KeepAsciiCharsOnly))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1061,7 +1061,7 @@ char *titleGenerateGameCardFileName(u8 naming_convention, u8 illegal_char_replac
|
|||
char *tmp_filename = realloc(filename, (cur_filename_len + app_name_len + 1) * sizeof(char));
|
||||
if (!tmp_filename)
|
||||
{
|
||||
LOG_MSG("Failed to reallocate filename buffer!");
|
||||
LOG_MSG_ERROR("Failed to reallocate filename buffer!");
|
||||
if (filename) free(filename);
|
||||
filename = NULL;
|
||||
error = true;
|
||||
|
@ -1080,7 +1080,7 @@ char *titleGenerateGameCardFileName(u8 naming_convention, u8 illegal_char_replac
|
|||
fallback:
|
||||
if (!filename && !error)
|
||||
{
|
||||
LOG_MSG("Error: the inserted gamecard doesn't hold any user applications!");
|
||||
LOG_MSG_ERROR("Error: the inserted gamecard doesn't hold any user applications!");
|
||||
|
||||
/* Fallback string if no applications can be found. */
|
||||
sprintf(app_name, "gamecard");
|
||||
|
@ -1093,7 +1093,7 @@ fallback:
|
|||
}
|
||||
|
||||
filename = strdup(app_name);
|
||||
if (!filename) LOG_MSG("Failed to duplicate fallback filename!");
|
||||
if (!filename) LOG_MSG_ERROR("Failed to duplicate fallback filename!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1154,7 +1154,7 @@ static bool titleReallocateApplicationMetadata(u32 extra_app_count, bool is_syst
|
|||
{
|
||||
if (!cached_app_metadata)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1184,7 +1184,7 @@ static bool titleReallocateApplicationMetadata(u32 extra_app_count, bool is_syst
|
|||
/* Clear new application metadata pointer array area (if needed). */
|
||||
if (!free_entries && extra_app_count) memset(cached_app_metadata + cached_app_metadata_count, 0, extra_app_count * sizeof(TitleApplicationMetadata*));
|
||||
} else {
|
||||
LOG_MSG("Failed to reallocate application metadata pointer array! (%u element[s]).", realloc_app_count);
|
||||
LOG_MSG_ERROR("Failed to reallocate application metadata pointer array! (%u element[s]).", realloc_app_count);
|
||||
goto end;
|
||||
}
|
||||
} else
|
||||
|
@ -1216,7 +1216,7 @@ NX_INLINE bool titleInitializePersistentTitleStorages(void)
|
|||
{
|
||||
if (!titleInitializeTitleStorage(i))
|
||||
{
|
||||
LOG_MSG("Failed to initialize title storage with ID %u!", i);
|
||||
LOG_MSG_ERROR("Failed to initialize title storage with ID %u!", i);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1233,7 +1233,7 @@ static bool titleInitializeTitleStorage(u8 storage_id)
|
|||
{
|
||||
if (storage_id < NcmStorageId_GameCard || storage_id > NcmStorageId_SdCard)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1256,7 +1256,7 @@ static bool titleInitializeTitleStorage(u8 storage_id)
|
|||
{
|
||||
/* If the SD card is mounted, but it isn't currently being used by HOS, 0x21005 will be returned, so we'll just filter this particular error and continue. */
|
||||
/* This can occur when using the "Nintendo" directory from a different console, or when the "sdmc:/Nintendo/Contents/private" file is corrupted. */
|
||||
LOG_MSG("ncmOpenContentMetaDatabase failed for storage ID %u! (0x%08X).", storage_id, rc);
|
||||
LOG_MSG_ERROR("ncmOpenContentMetaDatabase failed for %s! (0x%X).", titleGetNcmStorageIdName(storage_id), rc);
|
||||
if (storage_id == NcmStorageId_SdCard && rc == 0x21005) success = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1267,7 +1267,7 @@ static bool titleInitializeTitleStorage(u8 storage_id)
|
|||
{
|
||||
/* If the SD card is mounted, but it isn't currently being used by HOS, 0x21005 will be returned, so we'll just filter this particular error and continue. */
|
||||
/* This can occur when using the "Nintendo" directory from a different console, or when the "sdmc:/Nintendo/Contents/private" file is corrupted. */
|
||||
LOG_MSG("ncmOpenContentStorage failed for storage ID %u! (0x%08X).", storage_id, rc);
|
||||
LOG_MSG_ERROR("ncmOpenContentStorage failed for %s! (0x%X).", titleGetNcmStorageIdName(storage_id), rc);
|
||||
if (storage_id == NcmStorageId_SdCard && rc == 0x21005) success = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1275,11 +1275,11 @@ static bool titleInitializeTitleStorage(u8 storage_id)
|
|||
/* Generate title info entries for this storage. */
|
||||
if (!titleGenerateTitleInfoEntriesForTitleStorage(title_storage))
|
||||
{
|
||||
LOG_MSG("Failed to generate title info entries for storage ID %u!", storage_id);
|
||||
LOG_MSG_ERROR("Failed to generate title info entries for %s!", titleGetNcmStorageIdName(storage_id));
|
||||
goto end;
|
||||
}
|
||||
|
||||
LOG_MSG("Loaded %u title info %s from %s.", title_storage->title_count, (title_storage->title_count == 1 ? "entry" : "entries"), titleGetNcmStorageIdName(storage_id));
|
||||
LOG_MSG_INFO("Loaded %u title info %s from %s.", title_storage->title_count, (title_storage->title_count == 1 ? "entry" : "entries"), titleGetNcmStorageIdName(storage_id));
|
||||
|
||||
/* Update flag. */
|
||||
success = true;
|
||||
|
@ -1330,7 +1330,7 @@ static bool titleReallocateTitleInfoFromStorage(TitleStorage *title_storage, u32
|
|||
{
|
||||
if (!title_storage)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1343,7 +1343,7 @@ static bool titleReallocateTitleInfoFromStorage(TitleStorage *title_storage, u32
|
|||
{
|
||||
if (!title_info)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1373,7 +1373,7 @@ static bool titleReallocateTitleInfoFromStorage(TitleStorage *title_storage, u32
|
|||
/* Clear new title info pointer array area (if needed). */
|
||||
if (!free_entries && extra_title_count) memset(title_info + title_count, 0, extra_title_count * sizeof(TitleInfo*));
|
||||
} else {
|
||||
LOG_MSG("Failed to reallocate title info pointer array! (%u element[s]).", realloc_title_count);
|
||||
LOG_MSG_ERROR("Failed to reallocate title info pointer array! (%u element[s]).", realloc_title_count);
|
||||
goto end;
|
||||
}
|
||||
} else
|
||||
|
@ -1413,7 +1413,7 @@ static void titleAddOrphanTitleInfoEntry(TitleInfo *orphan_title)
|
|||
TitleInfo **tmp_orphan_info = realloc(g_orphanTitleInfo, (g_orphanTitleInfoCount + 1) * sizeof(TitleInfo*));
|
||||
if (!tmp_orphan_info)
|
||||
{
|
||||
LOG_MSG("Failed to reallocate orphan title info pointer array!");
|
||||
LOG_MSG_ERROR("Failed to reallocate orphan title info pointer array!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1435,7 +1435,7 @@ static bool titleGenerateMetadataEntriesFromSystemTitles(void)
|
|||
/* Reallocate application metadata pointer array. */
|
||||
if (!titleReallocateApplicationMetadata(g_systemTitlesCount, true, false))
|
||||
{
|
||||
LOG_MSG("Failed to reallocate application metadata pointer array for system titles!");
|
||||
LOG_MSG_ERROR("Failed to reallocate application metadata pointer array for system titles!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1446,7 +1446,7 @@ static bool titleGenerateMetadataEntriesFromSystemTitles(void)
|
|||
TitleApplicationMetadata *cur_app_metadata = calloc(1, sizeof(TitleApplicationMetadata));
|
||||
if (!cur_app_metadata)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for application metadata entry #%u!", extra_app_count);
|
||||
LOG_MSG_ERROR("Failed to allocate memory for application metadata entry #%u!", extra_app_count);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1491,7 +1491,7 @@ static bool titleGenerateMetadataEntriesFromNsRecords(void)
|
|||
tmp_app_records = realloc(app_records, app_records_size + app_records_block_size);
|
||||
if (!tmp_app_records)
|
||||
{
|
||||
LOG_MSG("Failed to reallocate NS application records buffer! (%u)", app_records_count);
|
||||
LOG_MSG_ERROR("Failed to reallocate NS application records buffer! (%u)", app_records_count);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1507,7 +1507,7 @@ static bool titleGenerateMetadataEntriesFromNsRecords(void)
|
|||
rc = nsListApplicationRecord(app_records_block, NS_APPLICATION_RECORD_BLOCK_SIZE, (s32)app_records_count, (s32*)&app_records_block_count);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("nsListApplicationRecord failed! (0x%08X) (%u).", rc, app_records_count);
|
||||
LOG_MSG_ERROR("nsListApplicationRecord failed! (0x%X) (%u).", rc, app_records_count);
|
||||
if (!app_records_count) goto end;
|
||||
break; /* Gotta work with what we have. */
|
||||
}
|
||||
|
@ -1525,7 +1525,7 @@ static bool titleGenerateMetadataEntriesFromNsRecords(void)
|
|||
/* Reallocate application metadata pointer array. */
|
||||
if (!titleReallocateApplicationMetadata(app_records_count, false, false))
|
||||
{
|
||||
LOG_MSG("Failed to reallocate application metadata pointer array for NS records!");
|
||||
LOG_MSG_ERROR("Failed to reallocate application metadata pointer array for NS records!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1541,7 +1541,7 @@ static bool titleGenerateMetadataEntriesFromNsRecords(void)
|
|||
cur_app_metadata = calloc(1, sizeof(TitleApplicationMetadata));
|
||||
if (!cur_app_metadata)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for application metadata entry #%u! (%u / %u).", extra_app_count, i + 1, app_records_count);
|
||||
LOG_MSG_ERROR("Failed to allocate memory for application metadata entry #%u! (%u / %u).", extra_app_count, i + 1, app_records_count);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1559,7 +1559,7 @@ static bool titleGenerateMetadataEntriesFromNsRecords(void)
|
|||
/* Check retrieved application metadata count. */
|
||||
if (!extra_app_count)
|
||||
{
|
||||
LOG_MSG("Unable to retrieve application metadata from NS application records! (%u element[s]).", app_records_count);
|
||||
LOG_MSG_ERROR("Unable to retrieve application metadata from NS application records! (%u element[s]).", app_records_count);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1588,7 +1588,7 @@ static TitleApplicationMetadata *titleGenerateDummySystemMetadataEntry(u64 title
|
|||
{
|
||||
if (!title_id)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1598,7 +1598,7 @@ static TitleApplicationMetadata *titleGenerateDummySystemMetadataEntry(u64 title
|
|||
/* Reallocate application metadata pointer array. */
|
||||
if (!titleReallocateApplicationMetadata(1, true, false))
|
||||
{
|
||||
LOG_MSG("Failed to reallocate application metadata pointer array for %016lX!", title_id);
|
||||
LOG_MSG_ERROR("Failed to reallocate application metadata pointer array for %016lX!", title_id);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1608,7 +1608,7 @@ static TitleApplicationMetadata *titleGenerateDummySystemMetadataEntry(u64 title
|
|||
cur_app_metadata = calloc(1, sizeof(TitleApplicationMetadata));
|
||||
if (!cur_app_metadata)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for application metadata %016lX!", title_id);
|
||||
LOG_MSG_ERROR("Failed to allocate memory for application metadata %016lX!", title_id);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1633,7 +1633,7 @@ static bool titleRetrieveUserApplicationMetadataByTitleId(u64 title_id, TitleApp
|
|||
{
|
||||
if (!g_nsAppControlData || !title_id || !out)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1648,13 +1648,13 @@ static bool titleRetrieveUserApplicationMetadataByTitleId(u64 title_id, TitleApp
|
|||
rc = nsGetApplicationControlData(NsApplicationControlSource_Storage, title_id, g_nsAppControlData, sizeof(NsApplicationControlData), &write_size);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("nsGetApplicationControlData failed for title ID \"%016lX\"! (0x%08X).", title_id, rc);
|
||||
LOG_MSG_ERROR("nsGetApplicationControlData failed for title ID \"%016lX\"! (0x%X).", title_id, rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (write_size < sizeof(NacpStruct))
|
||||
{
|
||||
LOG_MSG("Retrieved application control data buffer is too small! (0x%lX).", write_size);
|
||||
LOG_MSG_ERROR("Retrieved application control data buffer is too small! (0x%lX).", write_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1662,7 +1662,7 @@ static bool titleRetrieveUserApplicationMetadataByTitleId(u64 title_id, TitleApp
|
|||
rc = nacpGetLanguageEntry(&(g_nsAppControlData->nacp), &lang_entry);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("nacpGetLanguageEntry failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("nacpGetLanguageEntry failed! (0x%X).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1673,7 +1673,7 @@ static bool titleRetrieveUserApplicationMetadataByTitleId(u64 title_id, TitleApp
|
|||
icon = malloc(icon_size);
|
||||
if (!icon)
|
||||
{
|
||||
LOG_MSG("Error allocating memory for the icon buffer! (0x%X).", icon_size);
|
||||
LOG_MSG_ERROR("Error allocating memory for the icon buffer! (0x%X).", icon_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1713,7 +1713,7 @@ static bool titleGenerateTitleInfoEntriesForTitleStorage(TitleStorage *title_sto
|
|||
{
|
||||
if (!title_storage || title_storage->storage_id < NcmStorageId_GameCard || title_storage->storage_id > NcmStorageId_SdCard || !serviceIsActive(&(title_storage->ncm_db.s)))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1753,7 +1753,7 @@ static bool titleGenerateTitleInfoEntriesForTitleStorage(TitleStorage *title_sto
|
|||
cur_title_info = calloc(1, sizeof(TitleInfo));
|
||||
if (!cur_title_info)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for title info entry #%u! (%u / %u).", extra_title_count, i + 1, total);
|
||||
LOG_MSG_ERROR("Failed to allocate memory for title info entry #%u! (%u / %u).", extra_title_count, i + 1, total);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1764,7 +1764,7 @@ static bool titleGenerateTitleInfoEntriesForTitleStorage(TitleStorage *title_sto
|
|||
/* Get content infos. */
|
||||
if (!titleGetContentInfosForMetaKey(ncm_db, cur_meta_key, &(cur_title_info->content_infos), &(cur_title_info->content_count)))
|
||||
{
|
||||
LOG_MSG("Failed to get content infos for title ID %016lX!", cur_meta_key->id);
|
||||
LOG_MSG_ERROR("Failed to get content infos for title ID %016lX!", cur_meta_key->id);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1801,7 +1801,7 @@ static bool titleGenerateTitleInfoEntriesForTitleStorage(TitleStorage *title_sto
|
|||
/* Check retrieved title info count. */
|
||||
if (!extra_title_count)
|
||||
{
|
||||
LOG_MSG("Unable to generate title info entries! (%u element[s]).", total);
|
||||
LOG_MSG_ERROR("Unable to generate title info entries! (%u element[s]).", total);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1831,7 +1831,7 @@ static bool titleGetMetaKeysFromContentDatabase(NcmContentMetaDatabase *ncm_db,
|
|||
{
|
||||
if (!ncm_db || !serviceIsActive(&(ncm_db->s)) || !out_meta_keys || !out_meta_key_count)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1845,7 +1845,7 @@ static bool titleGetMetaKeysFromContentDatabase(NcmContentMetaDatabase *ncm_db,
|
|||
meta_keys = calloc(1, meta_keys_size);
|
||||
if (!meta_keys)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for the ncm application meta keys!");
|
||||
LOG_MSG_ERROR("Unable to allocate memory for the ncm application meta keys!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1854,7 +1854,7 @@ static bool titleGetMetaKeysFromContentDatabase(NcmContentMetaDatabase *ncm_db,
|
|||
rc = ncmContentMetaDatabaseList(ncm_db, (s32*)&total, (s32*)&written, meta_keys, 1, 0, 0, 0, UINT64_MAX, NcmContentInstallType_Full);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("ncmContentMetaDatabaseList failed! (0x%08X) (first entry).", rc);
|
||||
LOG_MSG_ERROR("ncmContentMetaDatabaseList failed! (0x%X) (first entry).", rc);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1877,7 +1877,7 @@ static bool titleGetMetaKeysFromContentDatabase(NcmContentMetaDatabase *ncm_db,
|
|||
meta_keys_tmp = realloc(meta_keys, meta_keys_size);
|
||||
if (!meta_keys_tmp)
|
||||
{
|
||||
LOG_MSG("Unable to reallocate application meta keys buffer! (%u entries).", total);
|
||||
LOG_MSG_ERROR("Unable to reallocate application meta keys buffer! (%u entries).", total);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1888,14 +1888,14 @@ static bool titleGetMetaKeysFromContentDatabase(NcmContentMetaDatabase *ncm_db,
|
|||
rc = ncmContentMetaDatabaseList(ncm_db, (s32*)&total, (s32*)&written, meta_keys, (s32)total, 0, 0, 0, UINT64_MAX, NcmContentInstallType_Full);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("ncmContentMetaDatabaseList failed! (0x%08X) (%u %s).", rc, total, total > 1 ? "entries" : "entry");
|
||||
LOG_MSG_ERROR("ncmContentMetaDatabaseList failed! (0x%X) (%u %s).", rc, total, total > 1 ? "entries" : "entry");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Safety check. */
|
||||
if (written != total)
|
||||
{
|
||||
LOG_MSG("Application meta key count mismatch! (%u != %u).", written, total);
|
||||
LOG_MSG_ERROR("Application meta key count mismatch! (%u != %u).", written, total);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1916,7 +1916,7 @@ static bool titleGetContentInfosForMetaKey(NcmContentMetaDatabase *ncm_db, const
|
|||
{
|
||||
if (!ncm_db || !serviceIsActive(&(ncm_db->s)) || !meta_key || !out_content_infos || !out_content_count)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1934,13 +1934,13 @@ static bool titleGetContentInfosForMetaKey(NcmContentMetaDatabase *ncm_db, const
|
|||
rc = ncmContentMetaDatabaseGet(ncm_db, meta_key, &content_meta_header_read_size, &content_meta_header, sizeof(NcmContentMetaHeader));
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("ncmContentMetaDatabaseGet failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("ncmContentMetaDatabaseGet failed! (0x%X).", rc);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (content_meta_header_read_size != sizeof(NcmContentMetaHeader))
|
||||
{
|
||||
LOG_MSG("Content meta header size mismatch! (0x%lX != 0x%lX).", content_meta_header_read_size, sizeof(NcmContentMetaHeader));
|
||||
LOG_MSG_ERROR("Content meta header size mismatch! (0x%lX != 0x%lX).", content_meta_header_read_size, sizeof(NcmContentMetaHeader));
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1948,7 +1948,7 @@ static bool titleGetContentInfosForMetaKey(NcmContentMetaDatabase *ncm_db, const
|
|||
content_count = (u32)content_meta_header.content_count;
|
||||
if (!content_count)
|
||||
{
|
||||
LOG_MSG("Content count is zero!");
|
||||
LOG_MSG_ERROR("Content count is zero!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1956,7 +1956,7 @@ static bool titleGetContentInfosForMetaKey(NcmContentMetaDatabase *ncm_db, const
|
|||
content_infos = calloc(content_count, sizeof(NcmContentInfo));
|
||||
if (!content_infos)
|
||||
{
|
||||
LOG_MSG("Unable to allocate memory for the content infos buffer! (%u content[s]).", content_count);
|
||||
LOG_MSG_ERROR("Unable to allocate memory for the content infos buffer! (%u content[s]).", content_count);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1964,13 +1964,13 @@ static bool titleGetContentInfosForMetaKey(NcmContentMetaDatabase *ncm_db, const
|
|||
rc = ncmContentMetaDatabaseListContentInfo(ncm_db, (s32*)&written, content_infos, (s32)content_count, meta_key, 0);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("ncmContentMetaDatabaseListContentInfo failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("ncmContentMetaDatabaseListContentInfo failed! (0x%X).", rc);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (written != content_count)
|
||||
{
|
||||
LOG_MSG("Content count mismatch! (%u != %u).", written, content_count);
|
||||
LOG_MSG_ERROR("Content count mismatch! (%u != %u).", written, content_count);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2072,7 +2072,7 @@ static bool titleCreateGameCardInfoThread(void)
|
|||
{
|
||||
if (!utilsCreateThread(&g_titleGameCardInfoThread, titleGameCardInfoThreadFunc, NULL, 1))
|
||||
{
|
||||
LOG_MSG("Failed to create gamecard title info thread!");
|
||||
LOG_MSG_ERROR("Failed to create gamecard title info thread!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2135,7 +2135,7 @@ static bool titleRefreshGameCardTitleInfo(void)
|
|||
/* Initialize gamecard title storage. */
|
||||
if (!titleInitializeTitleStorage(NcmStorageId_GameCard))
|
||||
{
|
||||
LOG_MSG("Failed to initialize gamecard title storage!");
|
||||
LOG_MSG_ERROR("Failed to initialize gamecard title storage!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2147,7 +2147,7 @@ static bool titleRefreshGameCardTitleInfo(void)
|
|||
/* Verify title count. */
|
||||
if (!title_count)
|
||||
{
|
||||
LOG_MSG("Gamecard title count is zero!");
|
||||
LOG_MSG_ERROR("Gamecard title count is zero!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2169,7 +2169,7 @@ static bool titleRefreshGameCardTitleInfo(void)
|
|||
/* Reallocate application metadata pointer array. */
|
||||
if (!titleReallocateApplicationMetadata(gamecard_app_count, false, false))
|
||||
{
|
||||
LOG_MSG("Failed to reallocate application metadata pointer array for gamecard user applications!");
|
||||
LOG_MSG_ERROR("Failed to reallocate application metadata pointer array for gamecard user applications!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2197,7 +2197,7 @@ static bool titleRefreshGameCardTitleInfo(void)
|
|||
cur_app_metadata = calloc(1, sizeof(TitleApplicationMetadata));
|
||||
if (!cur_app_metadata)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for application metadata entry #%u!", extra_app_count);
|
||||
LOG_MSG_ERROR("Failed to allocate memory for application metadata entry #%u!", extra_app_count);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2289,7 +2289,7 @@ static TitleInfo *_titleGetInfoFromStorageByTitleId(u8 storage_id, u64 title_id)
|
|||
{
|
||||
if (storage_id < NcmStorageId_GameCard || storage_id > NcmStorageId_Any || !title_id)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -2316,7 +2316,7 @@ static TitleInfo *_titleGetInfoFromStorageByTitleId(u8 storage_id, u64 title_id)
|
|||
if (out) break;
|
||||
}
|
||||
|
||||
//if (!info) LOG_MSG("Unable to find title info entry with ID \"%016lX\"! (storage ID %u).", title_id, storage_id);
|
||||
if (!out) LOG_MSG_INFO("Unable to find title info entry with ID \"%016lX\" in %s.", title_id, titleGetNcmStorageIdName(storage_id));
|
||||
|
||||
return out;
|
||||
}
|
||||
|
@ -2327,7 +2327,7 @@ static TitleInfo *titleDuplicateTitleInfo(TitleInfo *title_info, TitleInfo *pare
|
|||
(title_info->meta_key.type > NcmContentMetaType_BootImagePackageSafe && title_info->meta_key.type < NcmContentMetaType_Application) || title_info->meta_key.type > NcmContentMetaType_Delta || \
|
||||
!title_info->content_count || !title_info->content_infos)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -2339,7 +2339,7 @@ static TitleInfo *titleDuplicateTitleInfo(TitleInfo *title_info, TitleInfo *pare
|
|||
title_info_dup = calloc(1, sizeof(TitleInfo));
|
||||
if (!title_info_dup)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for TitleInfo duplicate!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for TitleInfo duplicate!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -2351,7 +2351,7 @@ static TitleInfo *titleDuplicateTitleInfo(TitleInfo *title_info, TitleInfo *pare
|
|||
content_infos_dup = calloc(title_info->content_count, sizeof(NcmContentInfo));
|
||||
if (!content_infos_dup)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for NcmContentInfo duplicates!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for NcmContentInfo duplicates!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2511,7 +2511,7 @@ static char *titleGetPatchVersionString(TitleInfo *title_info)
|
|||
|
||||
if (!title_info || title_info->meta_key.type != NcmContentMetaType_Patch || !(nacp_content = titleGetContentInfoByTypeAndIdOffset(title_info, NcmContentType_Control, 0)))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2523,21 +2523,21 @@ static char *titleGetPatchVersionString(TitleInfo *title_info)
|
|||
nca_ctx = calloc(1, sizeof(NcaContext));
|
||||
if (!nca_ctx)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for NCA context!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for NCA context!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Initialize NCA context. */
|
||||
if (!ncaInitializeContext(nca_ctx, storage_id, hfs_partition_type, nacp_content, title_info->version.value, NULL))
|
||||
{
|
||||
LOG_MSG("Failed to initialize NCA context for Control NCA from %016lX!", title_info->meta_key.id);
|
||||
LOG_MSG_ERROR("Failed to initialize NCA context for Control NCA from %016lX!", title_info->meta_key.id);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Initialize NACP context. */
|
||||
if (!nacpInitializeContext(&nacp_ctx, nca_ctx))
|
||||
{
|
||||
LOG_MSG("Failed to initialize NACP context for %016lX!", title_info->meta_key.id);
|
||||
LOG_MSG_ERROR("Failed to initialize NACP context for %016lX!", title_info->meta_key.id);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2548,13 +2548,13 @@ static char *titleGetPatchVersionString(TitleInfo *title_info)
|
|||
/* Check version string length. */
|
||||
if (!*display_version)
|
||||
{
|
||||
LOG_MSG("Display version string from %016lX is empty!", title_info->meta_key.id);
|
||||
LOG_MSG_ERROR("Display version string from %016lX is empty!", title_info->meta_key.id);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Duplicate version string. */
|
||||
str = strdup(display_version);
|
||||
if (!str) LOG_MSG("Failed to duplicate version string from %016lX!", title_info->meta_key.id);
|
||||
if (!str) LOG_MSG_ERROR("Failed to duplicate version string from %016lX!", title_info->meta_key.id);
|
||||
|
||||
end:
|
||||
nacpFreeContext(&nacp_ctx);
|
||||
|
|
|
@ -54,7 +54,7 @@ bool umsInitialize(void)
|
|||
Result rc = usbHsFsInitialize(0);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbHsFsInitialize failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("usbHsFsInitialize failed! (0x%X).", rc);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ UsbHsFsDevice *umsGetDevices(u32 *out_count)
|
|||
{
|
||||
if (!g_umsInterfaceInit || !out_count)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ UsbHsFsDevice *umsGetDevices(u32 *out_count)
|
|||
devices = calloc(g_umsDeviceCount, sizeof(UsbHsFsDevice));
|
||||
if (!devices)
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for %u devices!", g_umsDeviceCount);
|
||||
LOG_MSG_ERROR("Failed to allocate memory for %u devices!", g_umsDeviceCount);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ static bool umsCreateDetectionThread(void)
|
|||
{
|
||||
if (!utilsCreateThread(&g_umsDetectionThread, umsDetectionThreadFunc, NULL, 1))
|
||||
{
|
||||
LOG_MSG("Failed to create USB Mass Storage detection thread!");
|
||||
LOG_MSG_ERROR("Failed to create USB Mass Storage detection thread!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ static void umsDetectionThreadFunc(void *arg)
|
|||
|
||||
/* Get mounted device count. */
|
||||
g_umsDeviceCount = usbHsFsGetMountedDeviceCount();
|
||||
LOG_MSG("USB Mass Storage status change event triggered! Mounted USB Mass Storage device count: %u.", g_umsDeviceCount);
|
||||
LOG_MSG_INFO("USB Mass Storage status change event triggered! Mounted USB Mass Storage device count: %u.", g_umsDeviceCount);
|
||||
|
||||
if (g_umsDeviceCount)
|
||||
{
|
||||
|
@ -211,15 +211,15 @@ static void umsDetectionThreadFunc(void *arg)
|
|||
/* Update USB Mass Storage device info updated flag. */
|
||||
g_umsDeviceInfoUpdated = true;
|
||||
} else {
|
||||
LOG_MSG("USB Mass Storage device count mismatch! (%u != %u).", listed_device_count, g_umsDeviceCount);
|
||||
LOG_MSG_ERROR("USB Mass Storage device count mismatch! (%u != %u).", listed_device_count, g_umsDeviceCount);
|
||||
fail = true;
|
||||
}
|
||||
} else {
|
||||
LOG_MSG("Failed to list mounted USB Mass Storage devices!");
|
||||
LOG_MSG_ERROR("Failed to list mounted USB Mass Storage devices!");
|
||||
fail = true;
|
||||
}
|
||||
} else {
|
||||
LOG_MSG("Failed to allocate memory for mounted USB Mass Storage devices buffer!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for mounted USB Mass Storage devices buffer!");
|
||||
fail = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -237,14 +237,14 @@ bool usbInitialize(void)
|
|||
/* Allocate USB transfer buffer. */
|
||||
if (!usbAllocateTransferBuffer())
|
||||
{
|
||||
LOG_MSG("Failed to allocate memory for the USB transfer buffer!");
|
||||
LOG_MSG_ERROR("Failed to allocate memory for the USB transfer buffer!");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Initialize USB device interface. */
|
||||
if (!usbInitializeComms())
|
||||
{
|
||||
LOG_MSG("Failed to initialize USB device interface!");
|
||||
LOG_MSG_ERROR("Failed to initialize USB device interface!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ bool usbInitialize(void)
|
|||
g_usbStateChangeEvent = usbDsGetStateChangeEvent();
|
||||
if (!g_usbStateChangeEvent)
|
||||
{
|
||||
LOG_MSG("Failed to retrieve USB state change kernel event!");
|
||||
LOG_MSG_ERROR("Failed to retrieve USB state change kernel event!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ bool usbSendFileProperties(u64 file_size, const char *filename, u32 nsp_header_s
|
|||
if (!g_usbInterfaceInit || !g_usbTransferBuffer || !g_usbHostAvailable || !g_usbSessionStarted || !filename || !(filename_length = strlen(filename)) || filename_length >= FS_MAX_PATH || \
|
||||
(!g_nspTransferMode && ((file_size && nsp_header_size >= file_size) || g_usbTransferRemainingSize)) || (g_nspTransferMode && nsp_header_size))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -386,7 +386,7 @@ bool usbSendFileData(void *data, u64 data_size)
|
|||
if (!g_usbTransferBuffer || !g_usbInterfaceInit || !g_usbHostAvailable || !g_usbSessionStarted || !g_usbTransferRemainingSize || !data || !data_size || data_size > USB_TRANSFER_BUFFER_SIZE || \
|
||||
data_size > g_usbTransferRemainingSize)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -409,21 +409,21 @@ bool usbSendFileData(void *data, u64 data_size)
|
|||
{
|
||||
zlt_required = true;
|
||||
usbSetZltPacket(true);
|
||||
//LOG_MSG("ZLT enabled. Last chunk size: 0x%lX bytes.", data_size);
|
||||
LOG_MSG_DEBUG("ZLT enabled. Last chunk size: 0x%lX bytes.", data_size);
|
||||
}
|
||||
} else {
|
||||
/* Disable ZLT if this is the first of multiple data chunks. */
|
||||
if (!g_usbTransferWrittenSize)
|
||||
{
|
||||
usbSetZltPacket(false);
|
||||
//LOG_MSG("ZLT disabled (first chunk).");
|
||||
LOG_MSG_DEBUG("ZLT disabled (first chunk).");
|
||||
}
|
||||
}
|
||||
|
||||
/* Send data chunk. */
|
||||
if (!(ret = usbWrite(buf, data_size)))
|
||||
{
|
||||
LOG_MSG("Failed to write 0x%lX bytes long file data chunk from offset 0x%lX! (total size: 0x%lX).", data_size, g_usbTransferWrittenSize, \
|
||||
LOG_MSG_ERROR("Failed to write 0x%lX bytes long file data chunk from offset 0x%lX! (total size: 0x%lX).", data_size, g_usbTransferWrittenSize, \
|
||||
g_usbTransferRemainingSize + g_usbTransferWrittenSize);
|
||||
goto end;
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ bool usbSendFileData(void *data, u64 data_size)
|
|||
/* Check response from host device. */
|
||||
if (!(ret = usbRead(g_usbTransferBuffer, sizeof(UsbStatus))))
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%lX bytes long status block!", sizeof(UsbStatus));
|
||||
LOG_MSG_ERROR("Failed to read 0x%lX bytes long status block!", sizeof(UsbStatus));
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -445,7 +445,7 @@ bool usbSendFileData(void *data, u64 data_size)
|
|||
|
||||
if (!(ret = (cmd_status->magic == __builtin_bswap32(USB_CMD_HEADER_MAGIC))))
|
||||
{
|
||||
LOG_MSG("Invalid status block magic word!");
|
||||
LOG_MSG_ERROR("Invalid status block magic word! (0x%08X).", __builtin_bswap32(cmd_status->magic));
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -494,7 +494,7 @@ bool usbSendNspHeader(void *nsp_header, u32 nsp_header_size)
|
|||
if (!g_usbInterfaceInit || !g_usbTransferBuffer || !g_usbHostAvailable || !g_usbSessionStarted || g_usbTransferRemainingSize || !g_nspTransferMode || !nsp_header || !nsp_header_size || \
|
||||
nsp_header_size > (USB_TRANSFER_BUFFER_SIZE - sizeof(UsbCommandHeader)))
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -516,7 +516,7 @@ static bool usbCreateDetectionThread(void)
|
|||
{
|
||||
if (!utilsCreateThread(&g_usbDetectionThread, usbDetectionThreadFunc, NULL, 1))
|
||||
{
|
||||
LOG_MSG("Failed to create USB detection thread!");
|
||||
LOG_MSG_ERROR("Failed to create USB detection thread!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -574,7 +574,7 @@ static void usbDetectionThreadFunc(void *arg)
|
|||
g_usbSessionStarted = usbStartSession();
|
||||
if (g_usbSessionStarted)
|
||||
{
|
||||
LOG_MSG("USB session successfully established. Endpoint max packet size: 0x%04X.", g_usbEndpointMaxPacketSize);
|
||||
LOG_MSG_INFO("USB session successfully established. Endpoint max packet size: 0x%04X.", g_usbEndpointMaxPacketSize);
|
||||
} else {
|
||||
/* Update exit flag. */
|
||||
exit_flag = g_usbDetectionThreadExitFlag;
|
||||
|
@ -605,7 +605,7 @@ static bool usbStartSession(void)
|
|||
|
||||
if (!g_usbInterfaceInit || !g_usbTransferBuffer)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -629,7 +629,7 @@ static bool usbStartSession(void)
|
|||
g_usbEndpointMaxPacketSize = ((UsbStatus*)g_usbTransferBuffer)->max_packet_size;
|
||||
if (g_usbEndpointMaxPacketSize != USB_FS_EP_MAX_PACKET_SIZE && g_usbEndpointMaxPacketSize != USB_HS_EP_MAX_PACKET_SIZE && g_usbEndpointMaxPacketSize != USB_SS_EP_MAX_PACKET_SIZE)
|
||||
{
|
||||
LOG_MSG("Invalid endpoint max packet size value received from USB host: 0x%04X.", g_usbEndpointMaxPacketSize);
|
||||
LOG_MSG_ERROR("Invalid endpoint max packet size value received from USB host: 0x%04X.", g_usbEndpointMaxPacketSize);
|
||||
|
||||
/* Reset flags. */
|
||||
ret = false;
|
||||
|
@ -645,7 +645,7 @@ static void usbEndSession(void)
|
|||
{
|
||||
if (!g_usbInterfaceInit || !g_usbTransferBuffer || !g_usbHostAvailable || !g_usbSessionStarted)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -682,7 +682,7 @@ static bool usbSendCommand(void)
|
|||
|
||||
if ((sizeof(UsbCommandHeader) + cmd_block_size) > USB_TRANSFER_BUFFER_SIZE)
|
||||
{
|
||||
LOG_MSG("Invalid command size!");
|
||||
LOG_MSG_ERROR("Invalid command size!");
|
||||
status = UsbStatusType_InvalidCommandSize;
|
||||
goto end;
|
||||
}
|
||||
|
@ -690,7 +690,7 @@ static bool usbSendCommand(void)
|
|||
/* Write command header first. */
|
||||
if (!usbWrite(cmd_header, sizeof(UsbCommandHeader)))
|
||||
{
|
||||
if (!g_usbDetectionThreadExitFlag) LOG_MSG("Failed to write header for type 0x%X command!", cmd);
|
||||
if (!g_usbDetectionThreadExitFlag) LOG_MSG_ERROR("Failed to write header for type 0x%X command!", cmd);
|
||||
status = UsbStatusType_WriteCommandFailed;
|
||||
goto end;
|
||||
}
|
||||
|
@ -709,7 +709,7 @@ static bool usbSendCommand(void)
|
|||
cmd_block_written = usbWrite(g_usbTransferBuffer, cmd_block_size);
|
||||
if (!cmd_block_written)
|
||||
{
|
||||
LOG_MSG("Failed to write command block for type 0x%X command!", cmd);
|
||||
LOG_MSG_ERROR("Failed to write command block for type 0x%X command!", cmd);
|
||||
status = UsbStatusType_WriteCommandFailed;
|
||||
}
|
||||
|
||||
|
@ -723,7 +723,7 @@ static bool usbSendCommand(void)
|
|||
/* Read status block. */
|
||||
if (!usbRead(cmd_status, sizeof(UsbStatus)))
|
||||
{
|
||||
LOG_MSG("Failed to read 0x%lX bytes long status block for type 0x%X command!", sizeof(UsbStatus), cmd);
|
||||
LOG_MSG_ERROR("Failed to read 0x%lX bytes long status block for type 0x%X command!", sizeof(UsbStatus), cmd);
|
||||
status = UsbStatusType_ReadStatusFailed;
|
||||
goto end;
|
||||
}
|
||||
|
@ -731,6 +731,7 @@ static bool usbSendCommand(void)
|
|||
/* Verify magic word in status block. */
|
||||
if (cmd_status->magic != __builtin_bswap32(USB_CMD_HEADER_MAGIC))
|
||||
{
|
||||
LOG_MSG_ERROR("Invalid status block magic word! (0x%08X).", __builtin_bswap32(cmd_status->magic));
|
||||
status = UsbStatusType_InvalidMagicWord;
|
||||
goto end;
|
||||
}
|
||||
|
@ -754,22 +755,22 @@ static void usbLogStatusDetail(u32 status)
|
|||
case UsbStatusType_ReadStatusFailed:
|
||||
break;
|
||||
case UsbStatusType_InvalidMagicWord:
|
||||
LOG_MSG("Host replied with Invalid Magic Word status code.");
|
||||
LOG_MSG_INFO("Host replied with Invalid Magic Word status code.");
|
||||
break;
|
||||
case UsbStatusType_UnsupportedCommand:
|
||||
LOG_MSG("Host replied with Unsupported Command status code.");
|
||||
LOG_MSG_INFO("Host replied with Unsupported Command status code.");
|
||||
break;
|
||||
case UsbStatusType_UnsupportedAbiVersion:
|
||||
LOG_MSG("Host replied with Unsupported ABI Version status code.");
|
||||
LOG_MSG_INFO("Host replied with Unsupported ABI Version status code.");
|
||||
break;
|
||||
case UsbStatusType_MalformedCommand:
|
||||
LOG_MSG("Host replied with Malformed Command status code.");
|
||||
LOG_MSG_INFO("Host replied with Malformed Command status code.");
|
||||
break;
|
||||
case UsbStatusType_HostIoError:
|
||||
LOG_MSG("Host replied with I/O Error status code.");
|
||||
LOG_MSG_INFO("Host replied with I/O Error status code.");
|
||||
break;
|
||||
default:
|
||||
LOG_MSG("Unknown status code: 0x%X.", status);
|
||||
LOG_MSG_INFO("Unknown status code: 0x%X.", status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -852,7 +853,7 @@ static bool usbInitializeComms(void)
|
|||
rc = usbDsInitialize();
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInitialize failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("usbDsInitialize failed! (0x%X).", rc);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -860,27 +861,27 @@ static bool usbInitializeComms(void)
|
|||
{
|
||||
/* Set language string descriptor. */
|
||||
rc = usbDsAddUsbLanguageStringDescriptor(NULL, supported_langs, num_supported_langs);
|
||||
if (R_FAILED(rc)) LOG_MSG("usbDsAddUsbLanguageStringDescriptor failed! (0x%08X).", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("usbDsAddUsbLanguageStringDescriptor failed! (0x%X).", rc);
|
||||
|
||||
/* Set manufacturer string descriptor. */
|
||||
if (R_SUCCEEDED(rc))
|
||||
{
|
||||
rc = usbDsAddUsbStringDescriptor(&(device_descriptor.iManufacturer), APP_AUTHOR);
|
||||
if (R_FAILED(rc)) LOG_MSG("usbDsAddUsbStringDescriptor failed! (0x%08X) (manufacturer).", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("usbDsAddUsbStringDescriptor failed! (0x%X) (manufacturer).", rc);
|
||||
}
|
||||
|
||||
/* Set product string descriptor. */
|
||||
if (R_SUCCEEDED(rc))
|
||||
{
|
||||
rc = usbDsAddUsbStringDescriptor(&(device_descriptor.iProduct), APP_TITLE);
|
||||
if (R_FAILED(rc)) LOG_MSG("usbDsAddUsbStringDescriptor failed! (0x%08X) (product).", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("usbDsAddUsbStringDescriptor failed! (0x%X) (product).", rc);
|
||||
}
|
||||
|
||||
/* Set serial number string descriptor. */
|
||||
if (R_SUCCEEDED(rc))
|
||||
{
|
||||
rc = usbDsAddUsbStringDescriptor(&(device_descriptor.iSerialNumber), APP_VERSION);
|
||||
if (R_FAILED(rc)) LOG_MSG("usbDsAddUsbStringDescriptor failed! (0x%08X) (serial number).", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("usbDsAddUsbStringDescriptor failed! (0x%X) (serial number).", rc);
|
||||
}
|
||||
|
||||
/* Set device descriptors. */
|
||||
|
@ -888,7 +889,7 @@ static bool usbInitializeComms(void)
|
|||
if (R_SUCCEEDED(rc))
|
||||
{
|
||||
rc = usbDsSetUsbDeviceDescriptor(UsbDeviceSpeed_Full, &device_descriptor); /* Full Speed is USB 1.1. */
|
||||
if (R_FAILED(rc)) LOG_MSG("usbDsSetUsbDeviceDescriptor failed! (0x%08X) (USB 1.1).", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("usbDsSetUsbDeviceDescriptor failed! (0x%X) (USB 1.1).", rc);
|
||||
}
|
||||
|
||||
if (R_SUCCEEDED(rc))
|
||||
|
@ -897,7 +898,7 @@ static bool usbInitializeComms(void)
|
|||
device_descriptor.bcdUSB = USB_HS_BCD_REVISION;
|
||||
|
||||
rc = usbDsSetUsbDeviceDescriptor(UsbDeviceSpeed_High, &device_descriptor); /* High Speed is USB 2.0. */
|
||||
if (R_FAILED(rc)) LOG_MSG("usbDsSetUsbDeviceDescriptor failed! (0x%08X) (USB 2.0).", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("usbDsSetUsbDeviceDescriptor failed! (0x%X) (USB 2.0).", rc);
|
||||
}
|
||||
|
||||
if (R_SUCCEEDED(rc))
|
||||
|
@ -907,19 +908,19 @@ static bool usbInitializeComms(void)
|
|||
device_descriptor.bMaxPacketSize0 = USB_SS_EP0_MAX_PACKET_SIZE;
|
||||
|
||||
rc = usbDsSetUsbDeviceDescriptor(UsbDeviceSpeed_Super, &device_descriptor); /* Super Speed is USB 3.0. */
|
||||
if (R_FAILED(rc)) LOG_MSG("usbDsSetUsbDeviceDescriptor failed! (0x%08X) (USB 3.0).", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("usbDsSetUsbDeviceDescriptor failed! (0x%X) (USB 3.0).", rc);
|
||||
}
|
||||
|
||||
/* Set Binary Object Store. */
|
||||
if (R_SUCCEEDED(rc))
|
||||
{
|
||||
rc = usbDsSetBinaryObjectStore(bos, USB_BOS_SIZE);
|
||||
if (R_FAILED(rc)) LOG_MSG("usbDsSetBinaryObjectStore failed! (0x%08X).", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("usbDsSetBinaryObjectStore failed! (0x%X).", rc);
|
||||
}
|
||||
} else {
|
||||
/* Set VID, PID and BCD. */
|
||||
rc = usbDsSetVidPidBcd(&device_info);
|
||||
if (R_FAILED(rc)) LOG_MSG("usbDsSetVidPidBcd failed! (0x%08X).", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("usbDsSetVidPidBcd failed! (0x%X).", rc);
|
||||
}
|
||||
|
||||
if (R_FAILED(rc)) goto end;
|
||||
|
@ -928,7 +929,7 @@ static bool usbInitializeComms(void)
|
|||
init_dev_if = (hosversionAtLeast(5, 0, 0) ? usbInitializeDeviceInterface5x() : usbInitializeDeviceInterface1x());
|
||||
if (!init_dev_if)
|
||||
{
|
||||
LOG_MSG("Failed to initialize USB device interface!");
|
||||
LOG_MSG_ERROR("Failed to initialize USB device interface!");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -937,7 +938,7 @@ static bool usbInitializeComms(void)
|
|||
rc = usbDsEnable();
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsEnable failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("usbDsEnable failed! (0x%X).", rc);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1005,7 +1006,7 @@ static bool usbInitializeDeviceInterface5x(void)
|
|||
rc = usbDsRegisterInterface(&g_usbInterface);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsRegisterInterface failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("usbDsRegisterInterface failed! (0x%X).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1017,21 +1018,21 @@ static bool usbInitializeDeviceInterface5x(void)
|
|||
rc = usbDsInterface_AppendConfigurationData(g_usbInterface, UsbDeviceSpeed_Full, &interface_descriptor, USB_DT_INTERFACE_SIZE);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_AppendConfigurationData failed! (0x%08X) (USB 1.1) (interface).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_AppendConfigurationData failed! (0x%X) (USB 1.1) (interface).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = usbDsInterface_AppendConfigurationData(g_usbInterface, UsbDeviceSpeed_Full, &endpoint_descriptor_in, USB_DT_ENDPOINT_SIZE);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_AppendConfigurationData failed! (0x%08X) (USB 1.1) (in endpoint).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_AppendConfigurationData failed! (0x%X) (USB 1.1) (in endpoint).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = usbDsInterface_AppendConfigurationData(g_usbInterface, UsbDeviceSpeed_Full, &endpoint_descriptor_out, USB_DT_ENDPOINT_SIZE);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_AppendConfigurationData failed! (0x%08X) (USB 1.1) (out endpoint).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_AppendConfigurationData failed! (0x%X) (USB 1.1) (out endpoint).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1042,21 +1043,21 @@ static bool usbInitializeDeviceInterface5x(void)
|
|||
rc = usbDsInterface_AppendConfigurationData(g_usbInterface, UsbDeviceSpeed_High, &interface_descriptor, USB_DT_INTERFACE_SIZE);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_AppendConfigurationData failed! (0x%08X) (USB 2.0) (interface).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_AppendConfigurationData failed! (0x%X) (USB 2.0) (interface).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = usbDsInterface_AppendConfigurationData(g_usbInterface, UsbDeviceSpeed_High, &endpoint_descriptor_in, USB_DT_ENDPOINT_SIZE);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_AppendConfigurationData failed! (0x%08X) (USB 2.0) (in endpoint).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_AppendConfigurationData failed! (0x%X) (USB 2.0) (in endpoint).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = usbDsInterface_AppendConfigurationData(g_usbInterface, UsbDeviceSpeed_High, &endpoint_descriptor_out, USB_DT_ENDPOINT_SIZE);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_AppendConfigurationData failed! (0x%08X) (USB 2.0) (out endpoint).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_AppendConfigurationData failed! (0x%X) (USB 2.0) (out endpoint).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1067,35 +1068,35 @@ static bool usbInitializeDeviceInterface5x(void)
|
|||
rc = usbDsInterface_AppendConfigurationData(g_usbInterface, UsbDeviceSpeed_Super, &interface_descriptor, USB_DT_INTERFACE_SIZE);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_AppendConfigurationData failed! (0x%08X) (USB 3.0) (interface).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_AppendConfigurationData failed! (0x%X) (USB 3.0) (interface).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = usbDsInterface_AppendConfigurationData(g_usbInterface, UsbDeviceSpeed_Super, &endpoint_descriptor_in, USB_DT_ENDPOINT_SIZE);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_AppendConfigurationData failed! (0x%08X) (USB 3.0) (in endpoint).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_AppendConfigurationData failed! (0x%X) (USB 3.0) (in endpoint).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = usbDsInterface_AppendConfigurationData(g_usbInterface, UsbDeviceSpeed_Super, &endpoint_companion, USB_DT_SS_ENDPOINT_COMPANION_SIZE);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_AppendConfigurationData failed! (0x%08X) (USB 3.0) (in endpoint companion).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_AppendConfigurationData failed! (0x%X) (USB 3.0) (in endpoint companion).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = usbDsInterface_AppendConfigurationData(g_usbInterface, UsbDeviceSpeed_Super, &endpoint_descriptor_out, USB_DT_ENDPOINT_SIZE);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_AppendConfigurationData failed! (0x%08X) (USB 3.0) (out endpoint).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_AppendConfigurationData failed! (0x%X) (USB 3.0) (out endpoint).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = usbDsInterface_AppendConfigurationData(g_usbInterface, UsbDeviceSpeed_Super, &endpoint_companion, USB_DT_SS_ENDPOINT_COMPANION_SIZE);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_AppendConfigurationData failed! (0x%08X) (USB 3.0) (out endpoint companion).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_AppendConfigurationData failed! (0x%X) (USB 3.0) (out endpoint companion).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1103,21 +1104,21 @@ static bool usbInitializeDeviceInterface5x(void)
|
|||
rc = usbDsInterface_RegisterEndpoint(g_usbInterface, &g_usbEndpointIn, endpoint_descriptor_in.bEndpointAddress);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_RegisterEndpoint failed! (0x%08X) (in endpoint).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_RegisterEndpoint failed! (0x%X) (in endpoint).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = usbDsInterface_RegisterEndpoint(g_usbInterface, &g_usbEndpointOut, endpoint_descriptor_out.bEndpointAddress);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_RegisterEndpoint failed! (0x%08X) (out endpoint).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_RegisterEndpoint failed! (0x%X) (out endpoint).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = usbDsInterface_EnableInterface(g_usbInterface);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_EnableInterface failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_EnableInterface failed! (0x%X).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1161,7 +1162,7 @@ static bool usbInitializeDeviceInterface1x(void)
|
|||
rc = usbDsGetDsInterface(&g_usbInterface, &interface_descriptor, "usb");
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsGetDsInterface failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("usbDsGetDsInterface failed! (0x%X).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1169,21 +1170,21 @@ static bool usbInitializeDeviceInterface1x(void)
|
|||
rc = usbDsInterface_GetDsEndpoint(g_usbInterface, &g_usbEndpointIn, &endpoint_descriptor_in);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_GetDsEndpoint failed! (0x%08X) (in endpoint).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_GetDsEndpoint failed! (0x%X) (in endpoint).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = usbDsInterface_GetDsEndpoint(g_usbInterface, &g_usbEndpointOut, &endpoint_descriptor_out);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_GetDsEndpoint failed! (0x%08X) (out endpoint).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_GetDsEndpoint failed! (0x%X) (out endpoint).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = usbDsInterface_EnableInterface(g_usbInterface);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsInterface_EnableInterface failed! (0x%08X).", rc);
|
||||
LOG_MSG_ERROR("usbDsInterface_EnableInterface failed! (0x%X).", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1216,13 +1217,13 @@ static bool usbTransferData(void *buf, u64 size, UsbDsEndpoint *endpoint)
|
|||
{
|
||||
if (!buf || !IS_ALIGNED((u64)buf, USB_TRANSFER_ALIGNMENT) || !size || !endpoint)
|
||||
{
|
||||
LOG_MSG("Invalid parameters!");
|
||||
LOG_MSG_ERROR("Invalid parameters!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!usbIsHostAvailable())
|
||||
{
|
||||
LOG_MSG("USB host unavailable!");
|
||||
LOG_MSG_ERROR("USB host unavailable!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1235,7 +1236,7 @@ static bool usbTransferData(void *buf, u64 size, UsbDsEndpoint *endpoint)
|
|||
rc = usbDsEndpoint_PostBufferAsync(endpoint, buf, size, &urb_id);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsEndpoint_PostBufferAsync failed! (0x%08X) (URB ID %u).", rc, urb_id);
|
||||
LOG_MSG_ERROR("usbDsEndpoint_PostBufferAsync failed! (0x%X) (URB ID %u).", rc, urb_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1275,7 +1276,7 @@ static bool usbTransferData(void *buf, u64 size, UsbDsEndpoint *endpoint)
|
|||
/* This will "reset" the USB connection by making the background thread wait until a new session is established. */
|
||||
if (g_usbSessionStarted) ueventSignal(&g_usbTimeoutEvent);
|
||||
|
||||
if (!thread_exit) LOG_MSG("eventWait failed! (0x%08X) (URB ID %u).", rc, urb_id);
|
||||
if (!thread_exit) LOG_MSG_ERROR("eventWait failed! (0x%X) (URB ID %u).", rc, urb_id);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1283,20 +1284,20 @@ static bool usbTransferData(void *buf, u64 size, UsbDsEndpoint *endpoint)
|
|||
rc = usbDsEndpoint_GetReportData(endpoint, &report_data);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsEndpoint_GetReportData failed! (0x%08X) (URB ID %u).", rc, urb_id);
|
||||
LOG_MSG_ERROR("usbDsEndpoint_GetReportData failed! (0x%X) (URB ID %u).", rc, urb_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = usbDsParseReportData(&report_data, urb_id, NULL, &transferred_size);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOG_MSG("usbDsParseReportData failed! (0x%08X) (URB ID %u).", rc, urb_id);
|
||||
LOG_MSG_ERROR("usbDsParseReportData failed! (0x%X) (URB ID %u).", rc, urb_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (transferred_size != size)
|
||||
{
|
||||
LOG_MSG("USB transfer failed! Expected 0x%lX bytes, got 0x%X bytes (URB ID %u).", size, transferred_size, urb_id);
|
||||
LOG_MSG_ERROR("USB transfer failed! Expected 0x%lX bytes, got 0x%X bytes (URB ID %u).", size, transferred_size, urb_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace nxdt::utils {
|
|||
/* Find the memory region in which this function is stored. */
|
||||
/* The start of it will be the base address the homebrew was mapped to. */
|
||||
rc = svcQueryMemory(out, &p, static_cast<u64>(reinterpret_cast<uintptr_t>(&GetHomebrewMemoryInfo)));
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("svcQueryMemory failed! (0x%08X).", rc);
|
||||
if (R_FAILED(rc)) LOG_MSG_ERROR("svcQueryMemory failed! (0x%X).", rc);
|
||||
}
|
||||
|
||||
#if LOG_LEVEL == LOG_LEVEL_DEBUG
|
||||
|
@ -120,7 +120,7 @@ extern "C" {
|
|||
void diagAbortWithResult(Result res)
|
||||
{
|
||||
/* Log error. */
|
||||
LOG_MSG_ERROR("*** libnx aborted with error code: 0x%08X ***", res);
|
||||
LOG_MSG_ERROR("*** libnx aborted with error code: 0x%X ***", res);
|
||||
|
||||
/* Abort program execution. */
|
||||
std::string crash_str = (g_borealisInitialized ? i18n::getStr("generic/libnx_abort"_i18n, res) : fmt::format("Fatal error triggered in libnx!\nError code: 0x{:08X}.", res));
|
||||
|
|
|
@ -237,7 +237,7 @@ namespace nxdt::views
|
|||
}
|
||||
} else {
|
||||
/* Log downloaded data. */
|
||||
LOG_DATA(this->json_buf, this->json_buf_size, "Failed to parse GitHub release JSON. Downloaded data:");
|
||||
LOG_DATA_ERROR(this->json_buf, this->json_buf_size, "Failed to parse GitHub release JSON. Downloaded data:");
|
||||
|
||||
/* Update flag. */
|
||||
pop_view = true;
|
||||
|
|
Loading…
Reference in a new issue