Skip to content

Commit 7bc153d

Browse files
authored
Merge pull request #76 from mrexodia/fix-guard-pages
Fix a bug in the minidump library to support guard pages
2 parents 19af557 + 4647c78 commit 7bc153d

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/minidump/streams/MemoryInfoListStream.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#
66
import io
77
import enum
8-
from minidump.common_structs import *
8+
from minidump.common_structs import *
99

10-
class AllocationProtect(enum.Enum):
10+
class AllocationProtect(enum.Flag):
1111
NONE = 0
1212
PAGE_EXECUTE = 0x10 #Enables execute access to the committed region of pages. An attempt to write to the committed region results in an access violation.
1313
#This flag is not supported by the CreateFileMapping function.
@@ -51,7 +51,7 @@ class AllocationProtect(enum.Enum):
5151
#The PAGE_WRITECOMBINE flag cannot be specified with the PAGE_NOACCESS, PAGE_GUARD, and PAGE_NOCACHE flags.
5252
#The PAGE_WRITECOMBINE flag can be used only when allocating private memory with the VirtualAlloc, VirtualAllocEx, or VirtualAllocExNuma functions. To enable write-combined memory access for shared memory, specify the SEC_WRITECOMBINE flag when calling the CreateFileMapping function.
5353
#Windows Server 2003 and Windows XP: This flag is not supported until Windows Server 2003 with SP1.
54-
54+
5555
class MemoryType(enum.Enum):
5656
MEM_IMAGE = 0x1000000 #Indicates that the memory pages within the region are mapped into the view of an image section.
5757
MEM_MAPPED = 0x40000 #Indicates that the memory pages within the region are mapped into the view of a section.
@@ -78,17 +78,17 @@ def to_bytes(self):
7878
t += self.SizeOfEntry.to_bytes(4, byteorder = 'little', signed = False)
7979
t += len(self.entries).to_bytes(8, byteorder = 'little', signed = False)
8080
return t
81-
81+
8282
@staticmethod
8383
def parse(buff):
8484
mhds = MINIDUMP_MEMORY_INFO_LIST()
8585
mhds.SizeOfHeader = int.from_bytes(buff.read(4), byteorder = 'little', signed = False)
8686
mhds.SizeOfEntry = int.from_bytes(buff.read(4), byteorder = 'little', signed = False)
8787
mhds.NumberOfEntries = int.from_bytes(buff.read(8), byteorder = 'little', signed = False)
88-
88+
8989
return mhds
90-
91-
# https://msdn.microsoft.com/en-us/library/windows/desktop/ms680386(v=vs.85).aspx
90+
91+
# https://msdn.microsoft.com/en-us/library/windows/desktop/ms680386(v=vs.85).aspx
9292
class MINIDUMP_MEMORY_INFO:
9393
def __init__(self):
9494
self.BaseAddress = None
@@ -121,7 +121,7 @@ def to_bytes(self):
121121
t += self.Type.value.to_bytes(4, byteorder = 'little', signed = False)
122122
t += self.__alignment2.to_bytes(4, byteorder = 'little', signed = False)
123123
return t
124-
124+
125125
@staticmethod
126126
def parse(buff):
127127
mmi = MINIDUMP_MEMORY_INFO()
@@ -143,9 +143,9 @@ def parse(buff):
143143
except:
144144
pass
145145
mmi.__alignment2 = int.from_bytes(buff.read(4), byteorder = 'little', signed = False)
146-
146+
147147
return mmi
148-
148+
149149
class MinidumpMemoryInfo:
150150
def __init__(self):
151151
self.BaseAddress = None
@@ -155,7 +155,7 @@ def __init__(self):
155155
self.State = None
156156
self.Protect = None
157157
self.Type = None
158-
158+
159159
@staticmethod
160160
def parse(t, buff):
161161
mmi = MinidumpMemoryInfo()
@@ -167,7 +167,7 @@ def parse(t, buff):
167167
mmi.Protect = t.Protect
168168
mmi.Type = t.Type
169169
return mmi
170-
170+
171171
@staticmethod
172172
def get_header():
173173
t = [
@@ -192,13 +192,13 @@ def to_row(self):
192192
self.Type.name if self.Type else 'N/A',
193193
]
194194
return t
195-
196-
195+
196+
197197
class MinidumpMemoryInfoList:
198198
def __init__(self):
199199
self.header = None
200200
self.infos = []
201-
201+
202202
@staticmethod
203203
def parse(dir, buff):
204204
t = MinidumpMemoryInfoList()
@@ -209,7 +209,7 @@ def parse(dir, buff):
209209
for _ in range(t.header.NumberOfEntries):
210210
mi = MINIDUMP_MEMORY_INFO.parse(chunk)
211211
t.infos.append(MinidumpMemoryInfo.parse(mi, buff))
212-
212+
213213
return t
214214

215215
@staticmethod
@@ -222,15 +222,15 @@ async def aparse(dir, buff):
222222
for _ in range(t.header.NumberOfEntries):
223223
mi = MINIDUMP_MEMORY_INFO.parse(chunk)
224224
t.infos.append(MinidumpMemoryInfo.parse(mi, None))
225-
225+
226226
return t
227-
227+
228228
def to_table(self):
229229
t = []
230230
t.append(MinidumpMemoryInfo.get_header())
231231
for info in self.infos:
232232
t.append(info.to_row())
233233
return t
234-
234+
235235
def __str__(self):
236236
return '== MinidumpMemoryInfoList ==\n' + construct_table(self.to_table())

0 commit comments

Comments
 (0)