mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-21 18:35:13 -04:00
ams: revamp assertion system
This commit is contained in:
parent
9572fb2ce3
commit
40400aee1f
168 changed files with 1014 additions and 696 deletions
|
@ -92,11 +92,11 @@ namespace ams::patcher {
|
|||
|
||||
void ApplyIpsPatch(u8 *mapped_module, size_t mapped_size, size_t protected_size, size_t offset, bool is_ips32, FILE *f_ips) {
|
||||
/* Validate offset/protected size. */
|
||||
AMS_ASSERT(offset <= protected_size);
|
||||
AMS_ABORT_UNLESS(offset <= protected_size);
|
||||
|
||||
u8 buffer[sizeof(Ips32TailMagic)];
|
||||
while (true) {
|
||||
AMS_ASSERT(fread(buffer, is_ips32 ? sizeof(Ips32TailMagic) : sizeof(IpsTailMagic), 1, f_ips) == 1);
|
||||
AMS_ABORT_UNLESS(fread(buffer, is_ips32 ? sizeof(Ips32TailMagic) : sizeof(IpsTailMagic), 1, f_ips) == 1);
|
||||
|
||||
if (IsIpsTail(is_ips32, buffer)) {
|
||||
break;
|
||||
|
@ -106,18 +106,18 @@ namespace ams::patcher {
|
|||
u32 patch_offset = GetIpsPatchOffset(is_ips32, buffer);
|
||||
|
||||
/* Size of patch. */
|
||||
AMS_ASSERT(fread(buffer, 2, 1, f_ips) == 1);
|
||||
AMS_ABORT_UNLESS(fread(buffer, 2, 1, f_ips) == 1);
|
||||
u32 patch_size = GetIpsPatchSize(is_ips32, buffer);
|
||||
|
||||
/* Check for RLE encoding. */
|
||||
if (patch_size == 0) {
|
||||
/* Size of RLE. */
|
||||
AMS_ASSERT(fread(buffer, 2, 1, f_ips) == 1);
|
||||
AMS_ABORT_UNLESS(fread(buffer, 2, 1, f_ips) == 1);
|
||||
|
||||
u32 rle_size = (buffer[0] << 8) | (buffer[1]);
|
||||
|
||||
/* Value for RLE. */
|
||||
AMS_ASSERT(fread(buffer, 1, 1, f_ips) == 1);
|
||||
AMS_ABORT_UNLESS(fread(buffer, 1, 1, f_ips) == 1);
|
||||
|
||||
/* Ensure we don't write to protected region. */
|
||||
if (patch_offset < protected_size) {
|
||||
|
@ -160,7 +160,7 @@ namespace ams::patcher {
|
|||
if (patch_offset + read_size > mapped_size) {
|
||||
read_size = mapped_size - patch_offset;
|
||||
}
|
||||
AMS_ASSERT(fread(mapped_module + patch_offset, read_size, 1, f_ips) == 1);
|
||||
AMS_ABORT_UNLESS(fread(mapped_module + patch_offset, read_size, 1, f_ips) == 1);
|
||||
if (patch_size > read_size) {
|
||||
fseek(f_ips, patch_size - read_size, SEEK_CUR);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue