node/lib/metasm/samples/dbg-plugins/heapscan/heapscan.rb
# scan chunks from a heap base addr
scan chunks from a heap base addr
scan chunks from a heap base addr
def scan_heap(base, len, ar)
		dw = dwcache(base, len)
		ptr = 0
		psz = dw[ptr]
		sz = dw[ptr+1]
		base += 2*@ptsz	
		raise "bad heap base %x %x  %x %x" % [psz, sz, base, len] if psz != 0 or sz & 1 == 0
		loop do
			clen = sz & -8	
			ptr += clen/@ptsz	
			break if ptr >= dw.length or clen == 0
			sz = dw[ptr+1]
			if sz & 1 > 0	
				@chunks[base] = clen-@ptsz
			else
			end
			base += clen
		end
		del_fastbin(ar)
	end
def scan_heap ( base , len , ar ) dw = dwcache ( base , len ) ptr = 0 psz = dw [ ptr ] sz = dw [ ptr + 1 ] base += 2 * @ptsz raise "bad heap base %x %x  %x %x" % [ psz , sz , base , len ] if psz != 0 or sz & 1 == 0 loop do clen = sz & - 8 ptr += clen / @ptsz break if ptr >= dw . length or clen == 0 sz = dw [ ptr + 1 ] if sz & 1 > 0 @chunks [ base ] = clen - @ptsz else end base += clen end del_fastbin ( ar ) end
scan chunks from a heap base addr
scan chunks from a heap base addr
# user pointer # chunk size # start of next chk # pv_inuse # user data length up to chucksize-4 (over next psz) #puts "used #{'%x' % base} #{clen-@ptsz}" if $VERBOSE #puts "free #{'%x' % base} #{clen-@ptsz}" if $VERBOSE
base
len
ar