metasm/os/main.rb in metasm-1.0.3 vs metasm/os/main.rb in metasm-1.0.4
- old
+ new
@@ -244,18 +244,18 @@
# reads a range from the page cache
# returns a new VirtualString (using dup) if the request is bigger than @pagelength bytes
def read_range(from, len)
from += @addr_start
if not len
- base, page = cache_get_page(from)
- page[from - base]
+ base, page, inval = cache_get_page(from)
+ page[from - base] if not inval
elsif len <= @pagelength
- base, page = cache_get_page(from)
- s = page[from - base, len]
+ base, page, inval = cache_get_page(from)
+ s = page[from - base, len] if not inval
if from+len-base > @pagelength # request crosses a page boundary
- base, page = cache_get_page(from+len)
- s << page[0, from+len-base]
+ base, page, inval = cache_get_page(from+len)
+ s << page[0, from+len-base] if s and not inval
end
s
else
# big request: return a new virtual page
dup(from, len)
@@ -270,9 +270,14 @@
end
# overwrites a section of the original data
#def rewrite_at(addr, content)
#end
+
+ # decode an integer
+ def decode_imm(addr, len, cpu)
+ Expression.decode_imm(self, len, cpu, addr)
+ end
end
# on-demand reading of a file
class VirtualFile < VirtualString
# returns a new VirtualFile of the whole file content (defaults readonly)