diff --git a/src/AsmResolver.PE.File/PEFile.cs b/src/AsmResolver.PE.File/PEFile.cs
index 56cf6999d..26bb6e1fe 100644
--- a/src/AsmResolver.PE.File/PEFile.cs
+++ b/src/AsmResolver.PE.File/PEFile.cs
@@ -216,8 +216,19 @@ public PESection GetSectionContainingOffset(ulong fileOffset)
/// true if the section was found, false otherwise.
public bool TryGetSectionContainingOffset(ulong fileOffset, [NotNullWhen(true)] out PESection? section)
{
- section = Sections.FirstOrDefault(s => s.ContainsFileOffset(fileOffset));
- return section != null;
+ var sections = Sections;
+
+ for (int i = 0; i < sections.Count; i++)
+ {
+ if (sections[i].ContainsFileOffset(fileOffset))
+ {
+ section = sections[i];
+ return true;
+ }
+ }
+
+ section = null;
+ return false;
}
///
@@ -231,8 +242,19 @@ public PESection GetSectionContainingRva(uint rva)
///
public bool TryGetSectionContainingRva(uint rva, [NotNullWhen(true)] out PESection? section)
{
- section = Sections.FirstOrDefault(s => s.ContainsRva(rva));
- return section != null;
+ var sections = Sections;
+
+ for (int i = 0; i < sections.Count; i++)
+ {
+ if (sections[i].ContainsRva(rva))
+ {
+ section = sections[i];
+ return true;
+ }
+ }
+
+ section = null;
+ return false;
}
///