@@ -254,7 +254,8 @@ def pdbname_scan(cls,
254254 pdb_names : List [bytes ],
255255 progress_callback : constants .ProgressCallback = None ,
256256 start : Optional [int ] = None ,
257- end : Optional [int ] = None ) -> Generator [Dict [str , Optional [Union [bytes , str , int ]]], None , None ]:
257+ end : Optional [int ] = None ,
258+ maximum_invalid_count : int = 100 ) -> Generator [Dict [str , Optional [Union [bytes , str , int ]]], None , None ]:
258259 """Scans through `layer_name` at `ctx` looking for RSDS headers that
259260 indicate one of four common pdb kernel names (as listed in
260261 `self.pdb_names`) and returns the tuple (GUID, age, pdb_name,
@@ -264,6 +265,14 @@ def pdbname_scan(cls,
264265
265266 The UI should always provide the user an opportunity to specify the
266267 appropriate types and PDB values themselves
268+ Args:
269+ layer_name: The layer name to scan
270+ page_size: Size of page constant
271+ pdb_names: List of pdb names to scan
272+ progress_callback: Means of providing the user with feedback during long processes
273+ start: Start address to start scanning from the pdb_names
274+ end: Minimum address to scan the pdb_names
275+ maximum_invalid_count: Amount of pages that can be invalid during scanning before aborting signature search
267276 """
268277 min_pfn = 0
269278
@@ -279,11 +288,16 @@ def pdbname_scan(cls,
279288 sections = [(start , end - start )]):
280289 mz_offset = None
281290 sig_pfn = signature_offset // page_size
291+ current_invalid_counter = 0
282292
283293 for i in range (sig_pfn , min_pfn , - 1 ):
284- if not ctx . layers [ layer_name ]. is_valid ( i * page_size , 2 ) :
294+ if current_invalid_counter > maximum_invalid_count :
285295 break
286296
297+ if not ctx .layers [layer_name ].is_valid (i * page_size , 2 ):
298+ current_invalid_counter += 1
299+ continue
300+
287301 data = ctx .layers [layer_name ].read (i * page_size , 2 )
288302 if data == b'MZ' :
289303 mz_offset = i * page_size
0 commit comments