summaryrefslogtreecommitdiff
path: root/src/utilcode
diff options
context:
space:
mode:
Diffstat (limited to 'src/utilcode')
-rw-r--r--src/utilcode/pedecoder.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/utilcode/pedecoder.cpp b/src/utilcode/pedecoder.cpp
index 3b3c937419..babe374542 100644
--- a/src/utilcode/pedecoder.cpp
+++ b/src/utilcode/pedecoder.cpp
@@ -440,6 +440,37 @@ CHECK PEDecoder::CheckSection(COUNT_T previousAddressEnd, COUNT_T addressStart,
CHECK_OK;
}
+BOOL PEDecoder::HasWriteableSections() const
+{
+ CONTRACT_CHECK
+ {
+ INSTANCE_CHECK;
+ PRECONDITION(CheckFormat());
+ NOTHROW;
+ GC_NOTRIGGER;
+ SUPPORTS_DAC;
+ SO_TOLERANT;
+ }
+ CONTRACT_CHECK_END;
+
+ PTR_IMAGE_SECTION_HEADER pSection = FindFirstSection(FindNTHeaders());
+ _ASSERTE(pSection != NULL);
+
+ PTR_IMAGE_SECTION_HEADER pSectionEnd = pSection + VAL16(FindNTHeaders()->FileHeader.NumberOfSections);
+
+ while (pSection < pSectionEnd)
+ {
+ if ((pSection->Characteristics & VAL32(IMAGE_SCN_MEM_WRITE)) != 0)
+ {
+ return TRUE;
+ }
+
+ pSection++;
+ }
+
+ return FALSE;
+}
+
CHECK PEDecoder::CheckDirectoryEntry(int entry, int forbiddenFlags, IsNullOK ok) const
{
CONTRACT_CHECK