From e529d358cfc3e05f9ac9c539348136fa492cb238 Mon Sep 17 00:00:00 2001 From: wwylele Date: Sat, 20 Aug 2016 20:25:58 +0800 Subject: [PATCH] LDR fixup VerifyStringTableLength can be local --- src/core/hle/service/ldr_ro/cro_helper.cpp | 25 +++++++++++++++------- src/core/hle/service/ldr_ro/cro_helper.h | 11 ---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/core/hle/service/ldr_ro/cro_helper.cpp b/src/core/hle/service/ldr_ro/cro_helper.cpp index 280b23598..3d2a613ee 100644 --- a/src/core/hle/service/ldr_ro/cro_helper.cpp +++ b/src/core/hle/service/ldr_ro/cro_helper.cpp @@ -266,14 +266,6 @@ ResultCode CROHelper::RebaseHeader(u32 cro_size) { return RESULT_SUCCESS; } -ResultCode CROHelper::VerifyStringTableLength(VAddr address, u32 size) { - if (size != 0) { - if (Memory::Read8(address + size - 1) != 0) - return CROFormatError(0x0B); - } - return RESULT_SUCCESS; -} - ResultVal CROHelper::RebaseSegmentTable(u32 cro_size, VAddr data_segment_address, u32 data_segment_size, VAddr bss_segment_address, u32 bss_segment_size) { @@ -1061,6 +1053,23 @@ ResultCode CROHelper::ApplyExitRelocations(VAddr crs_address) { return RESULT_SUCCESS; } +/** + * Verifies a string or a string table matching a predicted size (i.e. terminated by 0) + * if it is not empty. There can be many other nulls in the string table because + * they are composed by many sub strings. This function is to check whether the + * whole string (table) is terminated properly, despite that it is not actually one string. + * @param address the virtual address of the string (table) + * @param size the size of the string (table), including the terminating 0 + * @returns ResultCode RESULT_SUCCESS if the size matches, otherwise error code. + */ +static ResultCode VerifyStringTableLength(VAddr address, u32 size) { + if (size != 0) { + if (Memory::Read8(address + size - 1) != 0) + return CROFormatError(0x0B); + } + return RESULT_SUCCESS; +} + ResultCode CROHelper::Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment_addresss, u32 data_segment_size, VAddr bss_segment_address, u32 bss_segment_size, bool is_crs) { diff --git a/src/core/hle/service/ldr_ro/cro_helper.h b/src/core/hle/service/ldr_ro/cro_helper.h index eab6ec6ac..34e357afd 100644 --- a/src/core/hle/service/ldr_ro/cro_helper.h +++ b/src/core/hle/service/ldr_ro/cro_helper.h @@ -511,17 +511,6 @@ private: */ ResultCode RebaseHeader(u32 cro_size); - /** - * Verifies a string or a string table matching a predicted size (i.e. terminated by 0) - * if it is not empty. There can be many other nulls in the string table because - * they are composed by many sub strings. This function is to check whether the - * whole string (table) is terminated properly, despite that it is not actually one string. - * @param address the virtual address of the string (table) - * @param size the size of the string (table), including the terminating 0 - * @returns ResultCode RESULT_SUCCESS if the size matches, otherwise error code. - */ - static ResultCode VerifyStringTableLength(VAddr address, u32 size); - /** * Rebases offsets in segment table according to module address. * @param cro_size the size of the CRO file