panraven Grandmaster Cheater
  Reputation: 62
  Joined: 01 Oct 2008 Posts: 958
 
  | 
		
			
				 Posted: Wed Nov 12, 2014 3:18 pm    Post subject: Extended AOBScan with address range | 
				       | 
			 
			
				
  | 
			 
			
				 	  | Code: | 	 		  local function AOBScanEx(aob,p,a,n,s,e,pb)
 
  local p,a,n,s,e = p or '*X*W',a or fsmNotAligned,n or '0',s or 0x0,e or 0xffffffffffffffff
 
  local ms = pb and createMemScan(pb) or createMemScan()
 
  local fl = createFoundList(ms)
 
  ms.firstScan(soExactValue,vtByteArray,nil,aob,nil,s,e,p,a,n,true,false,false,false)
 
  ms.waitTillDone()
 
  fl.initialize()
 
  local result = nil
 
  if fl ~= nil and fl.getCount() > 0 then
 
    result = createStringlist()
 
    for i=1,fl.getCount() do result.add(fl.getAddress(i-1)) end
 
  end
 
  fl.destroy()
 
  ms.destroy()
 
  return result
 
end | 	  
 
 
This extend the original AOBScan (non bytes table version) with optional starting address, ending address and progress bar. It create a MemScan and a FoundList object and destroy after scanning, and return a string_list object, same as the original AOBScan.
 
 
After the AOBScanEx definition, with this assignment,
 
 	  | Code: | 	 		  | local AOBScan = AOBScanEx | 	  
 
your code using original AOBScan should behave the same. The original global AOBScan is still there, but only will be called in scope where the local AOBScan not applied.
 
 
It is convenient to scan in a known memory range, eg the 2M PSX working ram on a emu.
 | 
			 
		  |