diff --git a/X86Disassembler/PE/PEFormat.cs b/X86Disassembler/PE/PEFormat.cs
index 257281f..bd41bfc 100644
--- a/X86Disassembler/PE/PEFormat.cs
+++ b/X86Disassembler/PE/PEFormat.cs
@@ -203,7 +203,7 @@ namespace X86Disassembler.PE
for (int i = 0; i < SectionHeaders.Count; i++)
{
- if (_sectionHeaderParser.IsSectionContainsCode(SectionHeaders[i]))
+ if (SectionHeaders[i].ContainsCode())
{
codeSections.Add(i);
}
@@ -219,7 +219,7 @@ namespace X86Disassembler.PE
/// True if the section contains code, false otherwise
public bool IsSectionContainsCode(SectionHeader section)
{
- return _sectionHeaderParser.IsSectionContainsCode(section);
+ return section.ContainsCode();
}
}
}
diff --git a/X86Disassembler/PE/Parsers/SectionHeaderParser.cs b/X86Disassembler/PE/Parsers/SectionHeaderParser.cs
index 74df093..8106c65 100644
--- a/X86Disassembler/PE/Parsers/SectionHeaderParser.cs
+++ b/X86Disassembler/PE/Parsers/SectionHeaderParser.cs
@@ -34,19 +34,5 @@ namespace X86Disassembler.PE.Parsers
return header;
}
-
- ///
- /// Checks if a section contains code
- ///
- /// The section to check
- /// True if the section contains code, false otherwise
- public bool IsSectionContainsCode(SectionHeader section)
- {
- const uint IMAGE_SCN_CNT_CODE = 0x00000020; // Section contains code
- const uint IMAGE_SCN_MEM_EXECUTE = 0x20000000; // Section is executable
-
- return (section.Characteristics & IMAGE_SCN_CNT_CODE) != 0 ||
- (section.Characteristics & IMAGE_SCN_MEM_EXECUTE) != 0;
- }
}
}
diff --git a/X86Disassembler/PE/SectionHeader.cs b/X86Disassembler/PE/SectionHeader.cs
index 7eac445..a18c929 100644
--- a/X86Disassembler/PE/SectionHeader.cs
+++ b/X86Disassembler/PE/SectionHeader.cs
@@ -5,6 +5,12 @@ namespace X86Disassembler.PE
///
public class SectionHeader
{
+ // Section characteristics flags
+ private const uint IMAGE_SCN_CNT_CODE = 0x00000020; // Section contains code
+ private const uint IMAGE_SCN_MEM_EXECUTE = 0x20000000; // Section is executable
+ private const uint IMAGE_SCN_MEM_READ = 0x40000000; // Section is readable
+ private const uint IMAGE_SCN_MEM_WRITE = 0x80000000; // Section is writable
+
public string Name; // Section name
public uint VirtualSize; // Virtual size
public uint VirtualAddress; // Virtual address
@@ -15,5 +21,42 @@ namespace X86Disassembler.PE
public ushort NumberOfRelocations; // Number of relocations
public ushort NumberOfLinenumbers; // Number of line numbers
public uint Characteristics; // Characteristics
+
+ ///
+ /// Checks if the section contains code
+ ///
+ /// True if the section contains code, false otherwise
+ public bool ContainsCode()
+ {
+ return (Characteristics & IMAGE_SCN_CNT_CODE) != 0 ||
+ (Characteristics & IMAGE_SCN_MEM_EXECUTE) != 0;
+ }
+
+ ///
+ /// Checks if the section is readable
+ ///
+ /// True if the section is readable, false otherwise
+ public bool IsReadable()
+ {
+ return (Characteristics & IMAGE_SCN_MEM_READ) != 0;
+ }
+
+ ///
+ /// Checks if the section is writable
+ ///
+ /// True if the section is writable, false otherwise
+ public bool IsWritable()
+ {
+ return (Characteristics & IMAGE_SCN_MEM_WRITE) != 0;
+ }
+
+ ///
+ /// Checks if the section is executable
+ ///
+ /// True if the section is executable, false otherwise
+ public bool IsExecutable()
+ {
+ return (Characteristics & IMAGE_SCN_MEM_EXECUTE) != 0;
+ }
}
}