mirror of
https://github.com/citra-emu/citra-nightly.git
synced 2024-12-23 18:45:31 +00:00
service/ldr: Migrate logging macros (#3867)
* service/ldr: Migrate logging macros * service/ldr: Fix clang format * service/ldr: Addressed comment about .c_str() equivalent .data() * service/ldr: Fix clang format
This commit is contained in:
parent
f50e505a5a
commit
c2efd49997
|
@ -131,7 +131,7 @@ ResultCode CROHelper::ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool
|
|||
ResultCode result = ApplyRelocation(relocation_target, relocation.type, relocation.addend,
|
||||
symbol_address, relocation_target);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying relocation %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying relocation {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -493,7 +493,7 @@ ResultCode CROHelper::ResetExternalRelocations() {
|
|||
ResultCode result = ApplyRelocation(relocation_target, relocation.type, relocation.addend,
|
||||
unresolved_symbol, relocation_target);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying relocation %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying relocation {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -525,7 +525,7 @@ ResultCode CROHelper::ClearExternalRelocations() {
|
|||
|
||||
ResultCode result = ClearRelocation(relocation_target, relocation.type);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error clearing relocation %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error clearing relocation {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -550,8 +550,8 @@ ResultCode CROHelper::ApplyStaticAnonymousSymbolToCRS(VAddr crs_address) {
|
|||
|
||||
CROHelper crs(crs_address);
|
||||
u32 offset_export_num = GetField(StaticAnonymousSymbolNum);
|
||||
LOG_INFO(Service_LDR, "CRO \"%s\" exports %d static anonymous symbols", ModuleName().data(),
|
||||
offset_export_num);
|
||||
NGLOG_INFO(Service_LDR, "CRO \"{}\" exports {} static anonymous symbols", ModuleName(),
|
||||
offset_export_num);
|
||||
for (u32 i = 0; i < offset_export_num; ++i) {
|
||||
StaticAnonymousSymbolEntry entry;
|
||||
GetEntry(i, entry);
|
||||
|
@ -563,11 +563,11 @@ ResultCode CROHelper::ApplyStaticAnonymousSymbolToCRS(VAddr crs_address) {
|
|||
}
|
||||
|
||||
u32 symbol_address = SegmentTagToAddress(entry.symbol_position);
|
||||
LOG_TRACE(Service_LDR, "CRO \"%s\" exports 0x%08X to the static module",
|
||||
ModuleName().data(), symbol_address);
|
||||
NGLOG_TRACE(Service_LDR, "CRO \"{}\" exports 0x{:08X} to the static module", ModuleName(),
|
||||
symbol_address);
|
||||
ResultCode result = crs.ApplyRelocationBatch(batch_address, symbol_address);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -603,12 +603,12 @@ ResultCode CROHelper::ApplyInternalRelocations(u32 old_data_segment_address) {
|
|||
|
||||
SegmentEntry symbol_segment;
|
||||
GetEntry(relocation.symbol_segment, symbol_segment);
|
||||
LOG_TRACE(Service_LDR, "Internally relocates 0x%08X with 0x%08X", target_address,
|
||||
symbol_segment.offset);
|
||||
NGLOG_TRACE(Service_LDR, "Internally relocates 0x{:08X} with 0x{:08X}", target_address,
|
||||
symbol_segment.offset);
|
||||
ResultCode result = ApplyRelocation(target_address, relocation.type, relocation.addend,
|
||||
symbol_segment.offset, target_addressB);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying relocation %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying relocation {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -628,7 +628,7 @@ ResultCode CROHelper::ClearInternalRelocations() {
|
|||
|
||||
ResultCode result = ClearRelocation(target_address, relocation.type);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error clearing relocation %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error clearing relocation {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -764,14 +764,13 @@ ResultCode CROHelper::ApplyImportNamedSymbol(VAddr crs_address) {
|
|||
u32 symbol_address = source.FindExportNamedSymbol(symbol_name);
|
||||
|
||||
if (symbol_address != 0) {
|
||||
LOG_TRACE(Service_LDR, "CRO \"%s\" imports \"%s\" from \"%s\"",
|
||||
ModuleName().data(), symbol_name.data(),
|
||||
source.ModuleName().data());
|
||||
NGLOG_TRACE(Service_LDR, "CRO \"{}\" imports \"{}\" from \"{}\"",
|
||||
ModuleName(), symbol_name, source.ModuleName());
|
||||
|
||||
ResultCode result = ApplyRelocationBatch(relocation_addr, symbol_address);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X",
|
||||
result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}",
|
||||
result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -801,7 +800,7 @@ ResultCode CROHelper::ResetImportNamedSymbol() {
|
|||
|
||||
ResultCode result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error reseting relocation batch %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error reseting relocation batch {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -821,7 +820,7 @@ ResultCode CROHelper::ResetImportIndexedSymbol() {
|
|||
|
||||
ResultCode result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error reseting relocation batch %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error reseting relocation batch {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -841,7 +840,7 @@ ResultCode CROHelper::ResetImportAnonymousSymbol() {
|
|||
|
||||
ResultCode result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error reseting relocation batch %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error reseting relocation batch {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -860,37 +859,36 @@ ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) {
|
|||
ResultCode result =
|
||||
ForEachAutoLinkCRO(crs_address, [&](CROHelper source) -> ResultVal<bool> {
|
||||
if (want_cro_name == source.ModuleName()) {
|
||||
LOG_INFO(Service_LDR, "CRO \"%s\" imports %d indexed symbols from \"%s\"",
|
||||
ModuleName().data(), entry.import_indexed_symbol_num,
|
||||
source.ModuleName().data());
|
||||
NGLOG_INFO(Service_LDR, "CRO \"{}\" imports {} indexed symbols from \"{}\"",
|
||||
ModuleName(), entry.import_indexed_symbol_num, source.ModuleName());
|
||||
for (u32 j = 0; j < entry.import_indexed_symbol_num; ++j) {
|
||||
ImportIndexedSymbolEntry im;
|
||||
entry.GetImportIndexedSymbolEntry(j, im);
|
||||
ExportIndexedSymbolEntry ex;
|
||||
source.GetEntry(im.index, ex);
|
||||
u32 symbol_address = source.SegmentTagToAddress(ex.symbol_position);
|
||||
LOG_TRACE(Service_LDR, " Imports 0x%08X", symbol_address);
|
||||
NGLOG_TRACE(Service_LDR, " Imports 0x{:08X}", symbol_address);
|
||||
ResultCode result =
|
||||
ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X",
|
||||
result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}",
|
||||
result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
LOG_INFO(Service_LDR, "CRO \"%s\" imports %d anonymous symbols from \"%s\"",
|
||||
ModuleName().data(), entry.import_anonymous_symbol_num,
|
||||
source.ModuleName().data());
|
||||
NGLOG_INFO(Service_LDR, "CRO \"{}\" imports {} anonymous symbols from \"{}\"",
|
||||
ModuleName(), entry.import_anonymous_symbol_num,
|
||||
source.ModuleName());
|
||||
for (u32 j = 0; j < entry.import_anonymous_symbol_num; ++j) {
|
||||
ImportAnonymousSymbolEntry im;
|
||||
entry.GetImportAnonymousSymbolEntry(j, im);
|
||||
u32 symbol_address = source.SegmentTagToAddress(im.symbol_position);
|
||||
LOG_TRACE(Service_LDR, " Imports 0x%08X", symbol_address);
|
||||
NGLOG_TRACE(Service_LDR, " Imports 0x{:08X}", symbol_address);
|
||||
ResultCode result =
|
||||
ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X",
|
||||
result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}",
|
||||
result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -906,8 +904,8 @@ ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) {
|
|||
}
|
||||
|
||||
ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) {
|
||||
LOG_DEBUG(Service_LDR, "CRO \"%s\" exports named symbols to \"%s\"", ModuleName().data(),
|
||||
target.ModuleName().data());
|
||||
NGLOG_DEBUG(Service_LDR, "CRO \"{}\" exports named symbols to \"{}\"", ModuleName(),
|
||||
target.ModuleName());
|
||||
u32 target_import_strings_size = target.GetField(ImportStringsSize);
|
||||
u32 target_symbol_import_num = target.GetField(ImportNamedSymbolNum);
|
||||
for (u32 i = 0; i < target_symbol_import_num; ++i) {
|
||||
|
@ -922,10 +920,10 @@ ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) {
|
|||
Memory::ReadCString(entry.name_offset, target_import_strings_size);
|
||||
u32 symbol_address = FindExportNamedSymbol(symbol_name);
|
||||
if (symbol_address != 0) {
|
||||
LOG_TRACE(Service_LDR, " exports symbol \"%s\"", symbol_name.data());
|
||||
NGLOG_TRACE(Service_LDR, " exports symbol \"{}\"", symbol_name);
|
||||
ResultCode result = target.ApplyRelocationBatch(relocation_addr, symbol_address);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -935,8 +933,8 @@ ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) {
|
|||
}
|
||||
|
||||
ResultCode CROHelper::ResetExportNamedSymbol(CROHelper target) {
|
||||
LOG_DEBUG(Service_LDR, "CRO \"%s\" unexports named symbols to \"%s\"", ModuleName().data(),
|
||||
target.ModuleName().data());
|
||||
NGLOG_DEBUG(Service_LDR, "CRO \"{}\" unexports named symbols to \"{}\"", ModuleName(),
|
||||
target.ModuleName());
|
||||
u32 unresolved_symbol = target.GetOnUnresolvedAddress();
|
||||
u32 target_import_strings_size = target.GetField(ImportStringsSize);
|
||||
u32 target_symbol_import_num = target.GetField(ImportNamedSymbolNum);
|
||||
|
@ -952,11 +950,11 @@ ResultCode CROHelper::ResetExportNamedSymbol(CROHelper target) {
|
|||
Memory::ReadCString(entry.name_offset, target_import_strings_size);
|
||||
u32 symbol_address = FindExportNamedSymbol(symbol_name);
|
||||
if (symbol_address != 0) {
|
||||
LOG_TRACE(Service_LDR, " unexports symbol \"%s\"", symbol_name.data());
|
||||
NGLOG_TRACE(Service_LDR, " unexports symbol \"{}\"", symbol_name);
|
||||
ResultCode result =
|
||||
target.ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -976,34 +974,34 @@ ResultCode CROHelper::ApplyModuleExport(CROHelper target) {
|
|||
if (Memory::ReadCString(entry.name_offset, target_import_string_size) != module_name)
|
||||
continue;
|
||||
|
||||
LOG_INFO(Service_LDR, "CRO \"%s\" exports %d indexed symbols to \"%s\"", module_name.data(),
|
||||
entry.import_indexed_symbol_num, target.ModuleName().data());
|
||||
NGLOG_INFO(Service_LDR, "CRO \"{}\" exports {} indexed symbols to \"{}\"", module_name,
|
||||
entry.import_indexed_symbol_num, target.ModuleName());
|
||||
for (u32 j = 0; j < entry.import_indexed_symbol_num; ++j) {
|
||||
ImportIndexedSymbolEntry im;
|
||||
entry.GetImportIndexedSymbolEntry(j, im);
|
||||
ExportIndexedSymbolEntry ex;
|
||||
GetEntry(im.index, ex);
|
||||
u32 symbol_address = SegmentTagToAddress(ex.symbol_position);
|
||||
LOG_TRACE(Service_LDR, " exports symbol 0x%08X", symbol_address);
|
||||
NGLOG_TRACE(Service_LDR, " exports symbol 0x{:08X}", symbol_address);
|
||||
ResultCode result =
|
||||
target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO(Service_LDR, "CRO \"%s\" exports %d anonymous symbols to \"%s\"",
|
||||
module_name.data(), entry.import_anonymous_symbol_num, target.ModuleName().data());
|
||||
NGLOG_INFO(Service_LDR, "CRO \"{}\" exports {} anonymous symbols to \"{}\"", module_name,
|
||||
entry.import_anonymous_symbol_num, target.ModuleName());
|
||||
for (u32 j = 0; j < entry.import_anonymous_symbol_num; ++j) {
|
||||
ImportAnonymousSymbolEntry im;
|
||||
entry.GetImportAnonymousSymbolEntry(j, im);
|
||||
u32 symbol_address = SegmentTagToAddress(im.symbol_position);
|
||||
LOG_TRACE(Service_LDR, " exports symbol 0x%08X", symbol_address);
|
||||
NGLOG_TRACE(Service_LDR, " exports symbol 0x{:08X}", symbol_address);
|
||||
ResultCode result =
|
||||
target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1025,28 +1023,28 @@ ResultCode CROHelper::ResetModuleExport(CROHelper target) {
|
|||
if (Memory::ReadCString(entry.name_offset, target_import_string_size) != module_name)
|
||||
continue;
|
||||
|
||||
LOG_DEBUG(Service_LDR, "CRO \"%s\" unexports indexed symbols to \"%s\"", module_name.data(),
|
||||
target.ModuleName().data());
|
||||
NGLOG_DEBUG(Service_LDR, "CRO \"{}\" unexports indexed symbols to \"{}\"", module_name,
|
||||
target.ModuleName());
|
||||
for (u32 j = 0; j < entry.import_indexed_symbol_num; ++j) {
|
||||
ImportIndexedSymbolEntry im;
|
||||
entry.GetImportIndexedSymbolEntry(j, im);
|
||||
ResultCode result =
|
||||
target.ApplyRelocationBatch(im.relocation_batch_offset, unresolved_symbol, true);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_DEBUG(Service_LDR, "CRO \"%s\" unexports anonymous symbols to \"%s\"",
|
||||
module_name.data(), target.ModuleName().data());
|
||||
NGLOG_DEBUG(Service_LDR, "CRO \"{}\" unexports anonymous symbols to \"{}\"", module_name,
|
||||
target.ModuleName());
|
||||
for (u32 j = 0; j < entry.import_anonymous_symbol_num; ++j) {
|
||||
ImportAnonymousSymbolEntry im;
|
||||
entry.GetImportAnonymousSymbolEntry(j, im);
|
||||
ResultCode result =
|
||||
target.ApplyRelocationBatch(im.relocation_batch_offset, unresolved_symbol, true);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1071,13 +1069,13 @@ ResultCode CROHelper::ApplyExitRelocations(VAddr crs_address) {
|
|||
u32 symbol_address = source.FindExportNamedSymbol("nnroAeabiAtexit_");
|
||||
|
||||
if (symbol_address != 0) {
|
||||
LOG_DEBUG(Service_LDR, "CRO \"%s\" import exit function from \"%s\"",
|
||||
ModuleName().data(), source.ModuleName().data());
|
||||
NGLOG_DEBUG(Service_LDR, "CRO \"{}\" import exit function from \"{}\"",
|
||||
ModuleName(), source.ModuleName());
|
||||
|
||||
ResultCode result = ApplyRelocationBatch(relocation_addr, symbol_address);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X",
|
||||
result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}",
|
||||
result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1087,7 +1085,7 @@ ResultCode CROHelper::ApplyExitRelocations(VAddr crs_address) {
|
|||
return MakeResult<bool>(true);
|
||||
});
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying exit relocation %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying exit relocation {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1118,13 +1116,13 @@ ResultCode CROHelper::Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment
|
|||
|
||||
ResultCode result = RebaseHeader(cro_size);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error rebasing header %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error rebasing header {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = VerifyStringTableLength(GetField(ModuleNameOffset), GetField(ModuleNameSize));
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error verifying module name %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error verifying module name {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1133,7 +1131,7 @@ ResultCode CROHelper::Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment
|
|||
auto result_val = RebaseSegmentTable(cro_size, data_segment_addresss, data_segment_size,
|
||||
bss_segment_address, bss_segment_size);
|
||||
if (result_val.Failed()) {
|
||||
LOG_ERROR(Service_LDR, "Error rebasing segment table %08X", result_val.Code().raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error rebasing segment table {:08X}", result_val.Code().raw);
|
||||
return result_val.Code();
|
||||
}
|
||||
prev_data_segment_address = *result_val;
|
||||
|
@ -1141,76 +1139,76 @@ ResultCode CROHelper::Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment
|
|||
|
||||
result = RebaseExportNamedSymbolTable();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error rebasing symbol export table %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error rebasing symbol export table {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = VerifyExportTreeTable();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error verifying export tree %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error verifying export tree {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = VerifyStringTableLength(GetField(ExportStringsOffset), GetField(ExportStringsSize));
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error verifying export strings %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error verifying export strings {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = RebaseImportModuleTable();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error rebasing object table %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error rebasing object table {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = ResetExternalRelocations();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error resetting all external relocations %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error resetting all external relocations {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = RebaseImportNamedSymbolTable();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error rebasing symbol import table %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error rebasing symbol import table {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = RebaseImportIndexedSymbolTable();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error rebasing index import table %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error rebasing index import table {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = RebaseImportAnonymousSymbolTable();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error rebasing offset import table %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error rebasing offset import table {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = VerifyStringTableLength(GetField(ImportStringsOffset), GetField(ImportStringsSize));
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error verifying import strings %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error verifying import strings {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!is_crs) {
|
||||
result = ApplyStaticAnonymousSymbolToCRS(crs_address);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying offset export to CRS %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying offset export to CRS {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
result = ApplyInternalRelocations(prev_data_segment_address);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying internal relocations %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying internal relocations {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!is_crs) {
|
||||
result = ApplyExitRelocations(crs_address);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying exit relocations %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying exit relocations {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1282,14 +1280,14 @@ ResultCode CROHelper::Link(VAddr crs_address, bool link_on_load_bug_fix) {
|
|||
// Imports named symbols from other modules
|
||||
result = ApplyImportNamedSymbol(crs_address);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying symbol import %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying symbol import {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Imports indexed and anonymous symbols from other modules
|
||||
result = ApplyModuleImport(crs_address);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying module import %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying module import {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1307,7 +1305,7 @@ ResultCode CROHelper::Link(VAddr crs_address, bool link_on_load_bug_fix) {
|
|||
return MakeResult<bool>(true);
|
||||
});
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error applying export %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error applying export {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1319,21 +1317,21 @@ ResultCode CROHelper::Unlink(VAddr crs_address) {
|
|||
// Resets all imported named symbols
|
||||
ResultCode result = ResetImportNamedSymbol();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error resetting symbol import %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error resetting symbol import {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Resets all imported indexed symbols
|
||||
result = ResetImportIndexedSymbol();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error resetting indexed import %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error resetting indexed import {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Resets all imported anonymous symbols
|
||||
result = ResetImportAnonymousSymbol();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error resetting anonymous import %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error resetting anonymous import {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1351,7 +1349,7 @@ ResultCode CROHelper::Unlink(VAddr crs_address) {
|
|||
return MakeResult<bool>(true);
|
||||
});
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error resetting export %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error resetting export {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1361,13 +1359,13 @@ ResultCode CROHelper::Unlink(VAddr crs_address) {
|
|||
ResultCode CROHelper::ClearRelocations() {
|
||||
ResultCode result = ClearExternalRelocations();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error clearing external relocations %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error clearing external relocations {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = ClearInternalRelocations();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error clearing internal relocations %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error clearing internal relocations {:08X}", result.raw);
|
||||
return result;
|
||||
}
|
||||
return RESULT_SUCCESS;
|
||||
|
|
|
@ -58,51 +58,52 @@ void RO::Initialize(Kernel::HLERequestContext& ctx) {
|
|||
// All other service functions below have the same issue.
|
||||
auto process = rp.PopObject<Kernel::Process>();
|
||||
|
||||
LOG_DEBUG(Service_LDR, "called, crs_buffer_ptr=0x%08X, crs_address=0x%08X, crs_size=0x%X",
|
||||
crs_buffer_ptr, crs_address, crs_size);
|
||||
NGLOG_DEBUG(Service_LDR,
|
||||
"called, crs_buffer_ptr=0x{:08X}, crs_address=0x{:08X}, crs_size=0x{:X}",
|
||||
crs_buffer_ptr, crs_address, crs_size);
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||
|
||||
ClientSlot* slot = GetSessionData(ctx.Session());
|
||||
if (slot->loaded_crs != 0) {
|
||||
LOG_ERROR(Service_LDR, "Already initialized");
|
||||
NGLOG_ERROR(Service_LDR, "Already initialized");
|
||||
rb.Push(ERROR_ALREADY_INITIALIZED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (crs_size < CRO_HEADER_SIZE) {
|
||||
LOG_ERROR(Service_LDR, "CRS is too small");
|
||||
NGLOG_ERROR(Service_LDR, "CRS is too small");
|
||||
rb.Push(ERROR_BUFFER_TOO_SMALL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (crs_buffer_ptr & Memory::PAGE_MASK) {
|
||||
LOG_ERROR(Service_LDR, "CRS original address is not aligned");
|
||||
NGLOG_ERROR(Service_LDR, "CRS original address is not aligned");
|
||||
rb.Push(ERROR_MISALIGNED_ADDRESS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (crs_address & Memory::PAGE_MASK) {
|
||||
LOG_ERROR(Service_LDR, "CRS mapping address is not aligned");
|
||||
NGLOG_ERROR(Service_LDR, "CRS mapping address is not aligned");
|
||||
rb.Push(ERROR_MISALIGNED_ADDRESS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (crs_size & Memory::PAGE_MASK) {
|
||||
LOG_ERROR(Service_LDR, "CRS size is not aligned");
|
||||
NGLOG_ERROR(Service_LDR, "CRS size is not aligned");
|
||||
rb.Push(ERROR_MISALIGNED_SIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!VerifyBufferState(*process, crs_buffer_ptr, crs_size)) {
|
||||
LOG_ERROR(Service_LDR, "CRS original buffer is in invalid state");
|
||||
NGLOG_ERROR(Service_LDR, "CRS original buffer is in invalid state");
|
||||
rb.Push(ERROR_INVALID_MEMORY_STATE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (crs_address < Memory::PROCESS_IMAGE_VADDR ||
|
||||
crs_address + crs_size > Memory::PROCESS_IMAGE_VADDR_END) {
|
||||
LOG_ERROR(Service_LDR, "CRS mapping address is not in the process image region");
|
||||
NGLOG_ERROR(Service_LDR, "CRS mapping address is not in the process image region");
|
||||
rb.Push(ERROR_ILLEGAL_ADDRESS);
|
||||
return;
|
||||
}
|
||||
|
@ -117,7 +118,7 @@ void RO::Initialize(Kernel::HLERequestContext& ctx) {
|
|||
.MapMemoryBlock(crs_address, crs_mem, 0, crs_size, Kernel::MemoryState::Code)
|
||||
.Code();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error mapping memory block %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error mapping memory block {:08X}", result.raw);
|
||||
rb.Push(result);
|
||||
return;
|
||||
}
|
||||
|
@ -125,7 +126,7 @@ void RO::Initialize(Kernel::HLERequestContext& ctx) {
|
|||
result =
|
||||
process->vm_manager.ReprotectRange(crs_address, crs_size, Kernel::VMAPermission::Read);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error reprotecting memory block %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error reprotecting memory block {:08X}", result.raw);
|
||||
rb.Push(result);
|
||||
return;
|
||||
}
|
||||
|
@ -136,7 +137,7 @@ void RO::Initialize(Kernel::HLERequestContext& ctx) {
|
|||
// TODO(wwylele): verify this behaviour. This is only seen in the web browser app,
|
||||
// and the actual behaviour is unclear. "Do nothing" is probably an incorrect implement.
|
||||
// There is also a chance that another issue causes the app passing wrong arguments.
|
||||
LOG_WARNING(Service_LDR, "crs_buffer_ptr == crs_address (0x%08X)", crs_address);
|
||||
NGLOG_WARNING(Service_LDR, "crs_buffer_ptr == crs_address (0x{:08X})", crs_address);
|
||||
}
|
||||
|
||||
CROHelper crs(crs_address);
|
||||
|
@ -144,7 +145,7 @@ void RO::Initialize(Kernel::HLERequestContext& ctx) {
|
|||
|
||||
result = crs.Rebase(0, crs_size, 0, 0, 0, 0, true);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error rebasing CRS 0x%08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error rebasing CRS 0x{:08X}", result.raw);
|
||||
rb.Push(result);
|
||||
return;
|
||||
}
|
||||
|
@ -165,8 +166,8 @@ void RO::LoadCRR(Kernel::HLERequestContext& ctx) {
|
|||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
|
||||
LOG_WARNING(Service_LDR, "(STUBBED) called, crr_buffer_ptr=0x%08X, crr_size=0x%08X",
|
||||
crr_buffer_ptr, crr_size);
|
||||
NGLOG_WARNING(Service_LDR, "(STUBBED) called, crr_buffer_ptr=0x{:08X}, crr_size=0x{:08X}",
|
||||
crr_buffer_ptr, crr_size);
|
||||
}
|
||||
|
||||
void RO::UnloadCRR(Kernel::HLERequestContext& ctx) {
|
||||
|
@ -177,7 +178,7 @@ void RO::UnloadCRR(Kernel::HLERequestContext& ctx) {
|
|||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
|
||||
LOG_WARNING(Service_LDR, "(STUBBED) called, crr_buffer_ptr=0x%08X", crr_buffer_ptr);
|
||||
NGLOG_WARNING(Service_LDR, "(STUBBED) called, crr_buffer_ptr=0x{:08X}", crr_buffer_ptr);
|
||||
}
|
||||
|
||||
void RO::LoadCRO(Kernel::HLERequestContext& ctx, bool link_on_load_bug_fix) {
|
||||
|
@ -195,55 +196,55 @@ void RO::LoadCRO(Kernel::HLERequestContext& ctx, bool link_on_load_bug_fix) {
|
|||
VAddr crr_address = rp.Pop<u32>();
|
||||
auto process = rp.PopObject<Kernel::Process>();
|
||||
|
||||
LOG_DEBUG(Service_LDR,
|
||||
"called (%s), cro_buffer_ptr=0x%08X, cro_address=0x%08X, cro_size=0x%X, "
|
||||
"data_segment_address=0x%08X, zero=%d, data_segment_size=0x%X, "
|
||||
"bss_segment_address=0x%08X, bss_segment_size=0x%X, auto_link=%s, "
|
||||
"fix_level=%d, crr_address=0x%08X",
|
||||
link_on_load_bug_fix ? "new" : "old", cro_buffer_ptr, cro_address, cro_size,
|
||||
data_segment_address, zero, data_segment_size, bss_segment_address, bss_segment_size,
|
||||
auto_link ? "true" : "false", fix_level, crr_address);
|
||||
NGLOG_DEBUG(Service_LDR,
|
||||
"called ({}), cro_buffer_ptr=0x{:08X}, cro_address=0x{:08X}, cro_size=0x{:X}, "
|
||||
"data_segment_address=0x{:08X}, zero={}, data_segment_size=0x{:X}, "
|
||||
"bss_segment_address=0x{:08X}, bss_segment_size=0x{:X}, auto_link={}, "
|
||||
"fix_level={}, crr_address=0x{:08X}",
|
||||
link_on_load_bug_fix ? "new" : "old", cro_buffer_ptr, cro_address, cro_size,
|
||||
data_segment_address, zero, data_segment_size, bss_segment_address,
|
||||
bss_segment_size, auto_link ? "true" : "false", fix_level, crr_address);
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
||||
|
||||
ClientSlot* slot = GetSessionData(ctx.Session());
|
||||
if (slot->loaded_crs == 0) {
|
||||
LOG_ERROR(Service_LDR, "Not initialized");
|
||||
NGLOG_ERROR(Service_LDR, "Not initialized");
|
||||
rb.Push(ERROR_NOT_INITIALIZED);
|
||||
rb.Push<u32>(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cro_size < CRO_HEADER_SIZE) {
|
||||
LOG_ERROR(Service_LDR, "CRO too small");
|
||||
NGLOG_ERROR(Service_LDR, "CRO too small");
|
||||
rb.Push(ERROR_BUFFER_TOO_SMALL);
|
||||
rb.Push<u32>(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cro_buffer_ptr & Memory::PAGE_MASK) {
|
||||
LOG_ERROR(Service_LDR, "CRO original address is not aligned");
|
||||
NGLOG_ERROR(Service_LDR, "CRO original address is not aligned");
|
||||
rb.Push(ERROR_MISALIGNED_ADDRESS);
|
||||
rb.Push<u32>(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cro_address & Memory::PAGE_MASK) {
|
||||
LOG_ERROR(Service_LDR, "CRO mapping address is not aligned");
|
||||
NGLOG_ERROR(Service_LDR, "CRO mapping address is not aligned");
|
||||
rb.Push(ERROR_MISALIGNED_ADDRESS);
|
||||
rb.Push<u32>(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cro_size & Memory::PAGE_MASK) {
|
||||
LOG_ERROR(Service_LDR, "CRO size is not aligned");
|
||||
NGLOG_ERROR(Service_LDR, "CRO size is not aligned");
|
||||
rb.Push(ERROR_MISALIGNED_SIZE);
|
||||
rb.Push<u32>(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!VerifyBufferState(*process, cro_buffer_ptr, cro_size)) {
|
||||
LOG_ERROR(Service_LDR, "CRO original buffer is in invalid state");
|
||||
NGLOG_ERROR(Service_LDR, "CRO original buffer is in invalid state");
|
||||
rb.Push(ERROR_INVALID_MEMORY_STATE);
|
||||
rb.Push<u32>(0);
|
||||
return;
|
||||
|
@ -251,14 +252,14 @@ void RO::LoadCRO(Kernel::HLERequestContext& ctx, bool link_on_load_bug_fix) {
|
|||
|
||||
if (cro_address < Memory::PROCESS_IMAGE_VADDR ||
|
||||
cro_address + cro_size > Memory::PROCESS_IMAGE_VADDR_END) {
|
||||
LOG_ERROR(Service_LDR, "CRO mapping address is not in the process image region");
|
||||
NGLOG_ERROR(Service_LDR, "CRO mapping address is not in the process image region");
|
||||
rb.Push(ERROR_ILLEGAL_ADDRESS);
|
||||
rb.Push<u32>(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (zero) {
|
||||
LOG_ERROR(Service_LDR, "Zero is not zero %d", zero);
|
||||
NGLOG_ERROR(Service_LDR, "Zero is not zero {}", zero);
|
||||
rb.Push(ResultCode(static_cast<ErrorDescription>(29), ErrorModule::RO,
|
||||
ErrorSummary::Internal, ErrorLevel::Usage));
|
||||
rb.Push<u32>(0);
|
||||
|
@ -275,7 +276,7 @@ void RO::LoadCRO(Kernel::HLERequestContext& ctx, bool link_on_load_bug_fix) {
|
|||
.MapMemoryBlock(cro_address, cro_mem, 0, cro_size, Kernel::MemoryState::Code)
|
||||
.Code();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error mapping memory block %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error mapping memory block {:08X}", result.raw);
|
||||
rb.Push(result);
|
||||
rb.Push<u32>(0);
|
||||
return;
|
||||
|
@ -284,7 +285,7 @@ void RO::LoadCRO(Kernel::HLERequestContext& ctx, bool link_on_load_bug_fix) {
|
|||
result =
|
||||
process->vm_manager.ReprotectRange(cro_address, cro_size, Kernel::VMAPermission::Read);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error reprotecting memory block %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error reprotecting memory block {:08X}", result.raw);
|
||||
process->vm_manager.UnmapRange(cro_address, cro_size);
|
||||
rb.Push(result);
|
||||
rb.Push<u32>(0);
|
||||
|
@ -298,14 +299,14 @@ void RO::LoadCRO(Kernel::HLERequestContext& ctx, bool link_on_load_bug_fix) {
|
|||
// This is derived from the case of LoadCRS with buffer_ptr==address,
|
||||
// and is never seen in any game. "Do nothing" is probably an incorrect implement.
|
||||
// There is also a chance that this case is just prohibited.
|
||||
LOG_WARNING(Service_LDR, "cro_buffer_ptr == cro_address (0x%08X)", cro_address);
|
||||
NGLOG_WARNING(Service_LDR, "cro_buffer_ptr == cro_address (0x{:08X})", cro_address);
|
||||
}
|
||||
|
||||
CROHelper cro(cro_address);
|
||||
|
||||
result = cro.VerifyHash(cro_size, crr_address);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error verifying CRO in CRR %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error verifying CRO in CRR {:08X}", result.raw);
|
||||
process->vm_manager.UnmapRange(cro_address, cro_size);
|
||||
rb.Push(result);
|
||||
rb.Push<u32>(0);
|
||||
|
@ -315,7 +316,7 @@ void RO::LoadCRO(Kernel::HLERequestContext& ctx, bool link_on_load_bug_fix) {
|
|||
result = cro.Rebase(slot->loaded_crs, cro_size, data_segment_address, data_segment_size,
|
||||
bss_segment_address, bss_segment_size, false);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error rebasing CRO %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error rebasing CRO {:08X}", result.raw);
|
||||
process->vm_manager.UnmapRange(cro_address, cro_size);
|
||||
rb.Push(result);
|
||||
rb.Push<u32>(0);
|
||||
|
@ -324,7 +325,7 @@ void RO::LoadCRO(Kernel::HLERequestContext& ctx, bool link_on_load_bug_fix) {
|
|||
|
||||
result = cro.Link(slot->loaded_crs, link_on_load_bug_fix);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error linking CRO %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error linking CRO {:08X}", result.raw);
|
||||
process->vm_manager.UnmapRange(cro_address, cro_size);
|
||||
rb.Push(result);
|
||||
rb.Push<u32>(0);
|
||||
|
@ -342,7 +343,7 @@ void RO::LoadCRO(Kernel::HLERequestContext& ctx, bool link_on_load_bug_fix) {
|
|||
if (fix_size != cro_size) {
|
||||
result = process->vm_manager.UnmapRange(cro_address + fix_size, cro_size - fix_size);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error unmapping memory block %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error unmapping memory block {:08X}", result.raw);
|
||||
process->vm_manager.UnmapRange(cro_address, cro_size);
|
||||
rb.Push(result);
|
||||
rb.Push<u32>(0);
|
||||
|
@ -361,7 +362,7 @@ void RO::LoadCRO(Kernel::HLERequestContext& ctx, bool link_on_load_bug_fix) {
|
|||
result = process->vm_manager.ReprotectRange(exe_begin, exe_size,
|
||||
Kernel::VMAPermission::ReadExecute);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error reprotecting memory block %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error reprotecting memory block {:08X}", result.raw);
|
||||
process->vm_manager.UnmapRange(cro_address, fix_size);
|
||||
rb.Push(result);
|
||||
rb.Push<u32>(0);
|
||||
|
@ -371,8 +372,8 @@ void RO::LoadCRO(Kernel::HLERequestContext& ctx, bool link_on_load_bug_fix) {
|
|||
|
||||
Core::CPU().InvalidateCacheRange(cro_address, cro_size);
|
||||
|
||||
LOG_INFO(Service_LDR, "CRO \"%s\" loaded at 0x%08X, fixed_end=0x%08X", cro.ModuleName().data(),
|
||||
cro_address, cro_address + fix_size);
|
||||
NGLOG_INFO(Service_LDR, "CRO \"{}\" loaded at 0x{:08X}, fixed_end=0x{:08X}", cro.ModuleName(),
|
||||
cro_address, cro_address + fix_size);
|
||||
|
||||
rb.Push(RESULT_SUCCESS, fix_size);
|
||||
}
|
||||
|
@ -384,8 +385,8 @@ void RO::UnloadCRO(Kernel::HLERequestContext& ctx) {
|
|||
VAddr cro_buffer_ptr = rp.Pop<u32>();
|
||||
auto process = rp.PopObject<Kernel::Process>();
|
||||
|
||||
LOG_DEBUG(Service_LDR, "called, cro_address=0x%08X, zero=%d, cro_buffer_ptr=0x%08X",
|
||||
cro_address, zero, cro_buffer_ptr);
|
||||
NGLOG_DEBUG(Service_LDR, "called, cro_address=0x{:08X}, zero={}, cro_buffer_ptr=0x{:08X}",
|
||||
cro_address, zero, cro_buffer_ptr);
|
||||
|
||||
CROHelper cro(cro_address);
|
||||
|
||||
|
@ -393,24 +394,24 @@ void RO::UnloadCRO(Kernel::HLERequestContext& ctx) {
|
|||
|
||||
ClientSlot* slot = GetSessionData(ctx.Session());
|
||||
if (slot->loaded_crs == 0) {
|
||||
LOG_ERROR(Service_LDR, "Not initialized");
|
||||
NGLOG_ERROR(Service_LDR, "Not initialized");
|
||||
rb.Push(ERROR_NOT_INITIALIZED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cro_address & Memory::PAGE_MASK) {
|
||||
LOG_ERROR(Service_LDR, "CRO address is not aligned");
|
||||
NGLOG_ERROR(Service_LDR, "CRO address is not aligned");
|
||||
rb.Push(ERROR_MISALIGNED_ADDRESS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cro.IsLoaded()) {
|
||||
LOG_ERROR(Service_LDR, "Invalid or not loaded CRO");
|
||||
NGLOG_ERROR(Service_LDR, "Invalid or not loaded CRO");
|
||||
rb.Push(ERROR_NOT_LOADED);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_INFO(Service_LDR, "Unloading CRO \"%s\"", cro.ModuleName().data());
|
||||
NGLOG_INFO(Service_LDR, "Unloading CRO \"{}\"", cro.ModuleName());
|
||||
|
||||
u32 fixed_size = cro.GetFixedSize();
|
||||
|
||||
|
@ -418,7 +419,7 @@ void RO::UnloadCRO(Kernel::HLERequestContext& ctx) {
|
|||
|
||||
ResultCode result = cro.Unlink(slot->loaded_crs);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error unlinking CRO %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error unlinking CRO {:08X}", result.raw);
|
||||
rb.Push(result);
|
||||
return;
|
||||
}
|
||||
|
@ -428,7 +429,7 @@ void RO::UnloadCRO(Kernel::HLERequestContext& ctx) {
|
|||
if (!cro.IsFixed()) {
|
||||
result = cro.ClearRelocations();
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error clearing relocations %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error clearing relocations {:08X}", result.raw);
|
||||
rb.Push(result);
|
||||
return;
|
||||
}
|
||||
|
@ -442,7 +443,7 @@ void RO::UnloadCRO(Kernel::HLERequestContext& ctx) {
|
|||
if (cro_address != cro_buffer_ptr) {
|
||||
result = process->vm_manager.UnmapRange(cro_address, fixed_size);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error unmapping CRO %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error unmapping CRO {:08X}", result.raw);
|
||||
}
|
||||
slot->memory_synchronizer.RemoveMemoryBlock(cro_address, cro_buffer_ptr);
|
||||
}
|
||||
|
@ -457,7 +458,7 @@ void RO::LinkCRO(Kernel::HLERequestContext& ctx) {
|
|||
VAddr cro_address = rp.Pop<u32>();
|
||||
auto process = rp.PopObject<Kernel::Process>();
|
||||
|
||||
LOG_DEBUG(Service_LDR, "called, cro_address=0x%08X", cro_address);
|
||||
NGLOG_DEBUG(Service_LDR, "called, cro_address=0x{:08X}", cro_address);
|
||||
|
||||
CROHelper cro(cro_address);
|
||||
|
||||
|
@ -465,28 +466,28 @@ void RO::LinkCRO(Kernel::HLERequestContext& ctx) {
|
|||
|
||||
ClientSlot* slot = GetSessionData(ctx.Session());
|
||||
if (slot->loaded_crs == 0) {
|
||||
LOG_ERROR(Service_LDR, "Not initialized");
|
||||
NGLOG_ERROR(Service_LDR, "Not initialized");
|
||||
rb.Push(ERROR_NOT_INITIALIZED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cro_address & Memory::PAGE_MASK) {
|
||||
LOG_ERROR(Service_LDR, "CRO address is not aligned");
|
||||
NGLOG_ERROR(Service_LDR, "CRO address is not aligned");
|
||||
rb.Push(ERROR_MISALIGNED_ADDRESS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cro.IsLoaded()) {
|
||||
LOG_ERROR(Service_LDR, "Invalid or not loaded CRO");
|
||||
NGLOG_ERROR(Service_LDR, "Invalid or not loaded CRO");
|
||||
rb.Push(ERROR_NOT_LOADED);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_INFO(Service_LDR, "Linking CRO \"%s\"", cro.ModuleName().data());
|
||||
NGLOG_INFO(Service_LDR, "Linking CRO \"{}\"", cro.ModuleName());
|
||||
|
||||
ResultCode result = cro.Link(slot->loaded_crs, false);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error linking CRO %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error linking CRO {:08X}", result.raw);
|
||||
}
|
||||
|
||||
slot->memory_synchronizer.SynchronizeOriginalMemory(*process);
|
||||
|
@ -499,7 +500,7 @@ void RO::UnlinkCRO(Kernel::HLERequestContext& ctx) {
|
|||
VAddr cro_address = rp.Pop<u32>();
|
||||
auto process = rp.PopObject<Kernel::Process>();
|
||||
|
||||
LOG_DEBUG(Service_LDR, "called, cro_address=0x%08X", cro_address);
|
||||
NGLOG_DEBUG(Service_LDR, "called, cro_address=0x{:08X}", cro_address);
|
||||
|
||||
CROHelper cro(cro_address);
|
||||
|
||||
|
@ -507,28 +508,28 @@ void RO::UnlinkCRO(Kernel::HLERequestContext& ctx) {
|
|||
|
||||
ClientSlot* slot = GetSessionData(ctx.Session());
|
||||
if (slot->loaded_crs == 0) {
|
||||
LOG_ERROR(Service_LDR, "Not initialized");
|
||||
NGLOG_ERROR(Service_LDR, "Not initialized");
|
||||
rb.Push(ERROR_NOT_INITIALIZED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cro_address & Memory::PAGE_MASK) {
|
||||
LOG_ERROR(Service_LDR, "CRO address is not aligned");
|
||||
NGLOG_ERROR(Service_LDR, "CRO address is not aligned");
|
||||
rb.Push(ERROR_MISALIGNED_ADDRESS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cro.IsLoaded()) {
|
||||
LOG_ERROR(Service_LDR, "Invalid or not loaded CRO");
|
||||
NGLOG_ERROR(Service_LDR, "Invalid or not loaded CRO");
|
||||
rb.Push(ERROR_NOT_LOADED);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_INFO(Service_LDR, "Unlinking CRO \"%s\"", cro.ModuleName().data());
|
||||
NGLOG_INFO(Service_LDR, "Unlinking CRO \"{}\"", cro.ModuleName());
|
||||
|
||||
ResultCode result = cro.Unlink(slot->loaded_crs);
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error unlinking CRO %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error unlinking CRO {:08X}", result.raw);
|
||||
}
|
||||
|
||||
slot->memory_synchronizer.SynchronizeOriginalMemory(*process);
|
||||
|
@ -541,13 +542,13 @@ void RO::Shutdown(Kernel::HLERequestContext& ctx) {
|
|||
VAddr crs_buffer_ptr = rp.Pop<u32>();
|
||||
auto process = rp.PopObject<Kernel::Process>();
|
||||
|
||||
LOG_DEBUG(Service_LDR, "called, crs_buffer_ptr=0x%08X", crs_buffer_ptr);
|
||||
NGLOG_DEBUG(Service_LDR, "called, crs_buffer_ptr=0x{:08X}", crs_buffer_ptr);
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||
|
||||
ClientSlot* slot = GetSessionData(ctx.Session());
|
||||
if (slot->loaded_crs == 0) {
|
||||
LOG_ERROR(Service_LDR, "Not initialized");
|
||||
NGLOG_ERROR(Service_LDR, "Not initialized");
|
||||
rb.Push(ERROR_NOT_INITIALIZED);
|
||||
return;
|
||||
}
|
||||
|
@ -563,7 +564,7 @@ void RO::Shutdown(Kernel::HLERequestContext& ctx) {
|
|||
if (slot->loaded_crs != crs_buffer_ptr) {
|
||||
result = process->vm_manager.UnmapRange(slot->loaded_crs, crs.GetFileSize());
|
||||
if (result.IsError()) {
|
||||
LOG_ERROR(Service_LDR, "Error unmapping CRS %08X", result.raw);
|
||||
NGLOG_ERROR(Service_LDR, "Error unmapping CRS {:08X}", result.raw);
|
||||
}
|
||||
slot->memory_synchronizer.RemoveMemoryBlock(slot->loaded_crs, crs_buffer_ptr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue