Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions LibCpp2IL/NintendoSwitch/NsoFile.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
Expand Down Expand Up @@ -309,7 +309,7 @@ public NsoFile Decompress()

public override long MapVirtualAddressToRaw(ulong addr, bool throwOnError = true)
{
var segment = segments.FirstOrDefault(x => addr - NsoGlobalOffset >= x.MemoryOffset && addr - NsoGlobalOffset <= x.MemoryOffset + x.DecompressedSize);
var segment = segments.FirstOrDefault(x => addr - NsoGlobalOffset >= x.MemoryOffset && addr - NsoGlobalOffset < x.MemoryOffset + x.DecompressedSize);
if (segment == null)
if (throwOnError)
throw new InvalidOperationException($"NSO: Address 0x{addr:X} is not present in any of the segments. Known segment ends are (hex) {string.Join(", ", segments.Select(s => (s.MemoryOffset + s.DecompressedSize).ToString("X")))}");
Expand All @@ -321,7 +321,7 @@ public override long MapVirtualAddressToRaw(ulong addr, bool throwOnError = true

public override ulong MapRawAddressToVirtual(uint offset)
{
var segment = segments.FirstOrDefault(x => offset >= x.FileOffset && offset <= x.FileOffset + x.DecompressedSize);
var segment = segments.FirstOrDefault(x => offset >= x.FileOffset && offset < x.FileOffset + x.DecompressedSize);
if (segment == null)
{
return 0;
Expand Down
2 changes: 1 addition & 1 deletion LibCpp2IL/PE/PE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public override long MapVirtualAddressToRaw(ulong uiAddr, bool throwOnError = tr
return VirtToRawInvalidOutOfBounds;
}

var section = peSectionHeaders.FirstOrDefault(x => addr >= x.VirtualAddress && addr <= x.VirtualAddress + x.VirtualSize);
var section = peSectionHeaders.FirstOrDefault(x => addr >= x.VirtualAddress && addr < x.VirtualAddress + x.VirtualSize);

if (section == null) return 0L;

Expand Down