| 
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -195,6 +195,36 @@ function MemoryArea:delete()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    for k,v in pairs(self) do self[k] = nil end
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				end
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				-- Static code segment search
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				local function find_code_segment()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    local code_start, code_end
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    for i,mem in ipairs(dfhack.internal.getMemRanges()) do
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if code_end then
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if mem.start_addr == code_end and mem.read and not mem.write then
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                code_end = mem.end_addr
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            else
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                break
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            end
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        elseif mem.read and not mem.write
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				           and (string.match(mem.name,'/dwarfort%.exe$')
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				             or string.match(mem.name,'/Dwarf_Fortress$')
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				             or string.match(mem.name,'Dwarf Fortress%.exe'))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        then
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            code_start = mem.start_addr
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            code_end = mem.end_addr
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        end
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    end
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    return code_start,code_end
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				end
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				function get_code_segment()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    local s, e = find_code_segment()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if s and e then
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        return ms.MemoryArea.new(s, e)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    end
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				end
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				-- Static data segment search
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				local function find_data_segment()
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |