node/lib/metasm/samples/dbg-plugins/heapscan/heapscan.rb
# yields all [ptr, len] for allocated segments of a _HEAP
# this maps to the _HEAP_SEGMENT further subdivised to skip
# the _HEAP_UNCOMMMTTED_RANGE areas
# for the last chunk of the _HEAP_SEGMENT, only yield up to chunk_header
yields all [ptr, len] for allocated segments of a _HEAP
this maps to the _HEAP_SEGMENT further subdivised to skip
the _HEAP_UNCOMMMTTED_RANGE areas
for the last chunk of the _HEAP_SEGMENT, only yield up to chunk_header
yields all [ ptr len ] for allocated segments of a _HEAP this maps to the _HEAP_SEGMENT further subdivised to skip the _HEAP_UNCOMMMTTED_RANGE areas for the last chunk of the _HEAP_SEGMENT only yield up to chunk_header
def each_heap_segment(ar)
		ar.segments.to_array.compact.each { |a|
			sg = @cp.decode_c_struct('_HEAP_SEGMENT', @dbg.memory, a)
			skiplist = []
			ptr = sg.uncommittedranges
			while ptr
				ucr = @cp.decode_c_struct('_HEAP_UNCOMMMTTED_RANGE', @dbg.memory, ptr)
				skiplist << [ucr.Address, ucr.Size]
				ptr = ucr.Next
			end
			ptr = sg.firstentry
			ptrend = sg.lastvalidentry
			skiplist.delete_if { |sa, sl| sa < ptr or sa + sl > ptrend }
			skiplist << [ptrend, 1]
			skiplist.sort.each { |sa, sl|
				yield(ptr, sa-ptr)
				ptr = sa + sl
			}
		}
	end
def each_heap_segment ( ar ) ar . segments . to_array . compact . each { | a | sg = @cp . decode_c_struct ( '_HEAP_SEGMENT' , @dbg . memory , a ) skiplist = [ ] ptr = sg . uncommittedranges while ptr ucr = @cp . decode_c_struct ( '_HEAP_UNCOMMMTTED_RANGE' , @dbg . memory , ptr ) skiplist << [ ucr . Address , ucr . Size ] ptr = ucr . Next end ptr = sg . firstentry ptrend = sg . lastvalidentry skiplist . delete_if { | sa , sl | sa < ptr or sa + sl > ptrend } skiplist << [ ptrend , 1 ] skiplist . sort . each { | sa , sl | yield ( ptr , sa - ptr ) ptr = sa + sl } } end
yields all [ptr, len] for allocated segments of a _HEAP
this maps to the _HEAP_SEGMENT further subdivised to skip
the _HEAP_UNCOMMMTTED_RANGE areas
for the last chunk of the _HEAP_SEGMENT, only yield up to chunk_header
yields all [ ptr len ] for allocated segments of a _HEAP this maps to the _HEAP_SEGMENT further subdivised to skip the _HEAP_UNCOMMMTTED_RANGE areas for the last chunk of the _HEAP_SEGMENT only yield up to chunk_header
# XXX lastentryinsegment == firstentry ??? # lastvalidentry = address of the end of the segment (may point to unmapped space)
ar