node/lib/metasm/metasm/disassemble.rb
def dump(dump_data=true, &b)
		b ||= lambda { |l| puts l }
		@sections.sort_by { |addr, edata| addr.kind_of?(::Integer) ? addr : 0 }.each { |addr, edata|
			addr = Expression[addr] if addr.kind_of? ::String
			blockoffs = @decoded.values.grep(DecodedInstruction).map { |di| Expression[di.block.address, :-, addr].reduce if di.block_head? }.grep(::Integer).sort.reject { |o| o < 0 or o >= edata.length }
			b[@program.dump_section_header(addr, edata)]
			if not dump_data and edata.length > 16*1024 and blockoffs.empty?
				b["// [#{edata.length} data bytes]"]
				next
			end
			unk_off = 0	# last off displayed
			# blocks.sort_by { |b| b.addr }.each { |b|
			while unk_off < edata.length
				if unk_off == blockoffs.first
					blockoffs.shift
					di = @decoded[addr+unk_off]
					if unk_off != di.block.edata_ptr
						b["\n// ------ overlap (#{unk_off-di.block.edata_ptr}) ------"]
					elsif di.block.from_normal.kind_of? ::Array
						b["\n"]
					end
					dump_block(di.block, &b)
					unk_off += [di.block.bin_length, 1].max
					unk_off = blockoffs.first if blockoffs.first and unk_off > blockoffs.first
				else
					next_off = blockoffs.first || edata.length
					if dump_data or next_off - unk_off < 16
						unk_off = dump_data(addr + unk_off, edata, unk_off, &b)
					else
						b["// [#{next_off - unk_off} data bytes]"]
						unk_off = next_off
					end
				end
			end
		}
	end
# dumps the source, optionnally including data
# yields (defaults puts) each line
dumps the source, optionnally including data
yields (defaults puts) each line
dumps the source optionnally including data yields ( defaults puts ) each line
def dump(dump_data=true, &b)
		b ||= lambda { |l| puts l }
		@sections.sort_by { |addr, edata| addr.kind_of?(::Integer) ? addr : 0 }.each { |addr, edata|
			addr = Expression[addr] if addr.kind_of? ::String
			blockoffs = @decoded.values.grep(DecodedInstruction).map { |di| Expression[di.block.address, :-, addr].reduce if di.block_head? }.grep(::Integer).sort.reject { |o| o < 0 or o >= edata.length }
			b[@program.dump_section_header(addr, edata)]
			if not dump_data and edata.length > 16*1024 and blockoffs.empty?
				b["// [#{edata.length} data bytes]"]
				next
			end
			unk_off = 0	
			while unk_off < edata.length
				if unk_off == blockoffs.first
					blockoffs.shift
					di = @decoded[addr+unk_off]
					if unk_off != di.block.edata_ptr
						b["\n// ------ overlap (#{unk_off-di.block.edata_ptr}) ------"]
					elsif di.block.from_normal.kind_of? ::Array
						b["\n"]
					end
					dump_block(di.block, &b)
					unk_off += [di.block.bin_length, 1].max
					unk_off = blockoffs.first if blockoffs.first and unk_off > blockoffs.first
				else
					next_off = blockoffs.first || edata.length
					if dump_data or next_off - unk_off < 16
						unk_off = dump_data(addr + unk_off, edata, unk_off, &b)
					else
						b["// [#{next_off - unk_off} data bytes]"]
						unk_off = next_off
					end
				end
			end
		}
	end
def dump ( dump_data = true , & b ) b ||= lambda { | l | puts l } @sections . sort_by { | addr , edata | addr . kind_of? ( :: Integer ) ? addr : 0 } . each { | addr , edata | addr = Expression [ addr ] if addr . kind_of? :: String blockoffs = @decoded . values . grep ( DecodedInstruction ) . map { | di | Expression [ di . block . address , :- , addr ] . reduce if di . block_head? } . grep ( :: Integer ) . sort . reject { | o | o < 0 or o >= edata . length } b [ @program . dump_section_header ( addr , edata ) ] if not dump_data and edata . length > 16 * 1024 and blockoffs . empty? b [ "// [#{edata.length} data bytes]" ] next end unk_off = 0 while unk_off < edata . length if unk_off == blockoffs . first blockoffs . shift di = @decoded [ addr + unk_off ] if unk_off != di . block . edata_ptr b [ "\n// ------ overlap (#{unk_off-di.block.edata_ptr}) ------" ] elsif di . block . from_normal . kind_of? :: Array b [ "\n" ] end dump_block ( di . block , & b ) unk_off += [ di . block . bin_length , 1 ] . max unk_off = blockoffs . first if blockoffs . first and unk_off > blockoffs . first else next_off = blockoffs . first || edata . length if dump_data or next_off - unk_off < 16 unk_off = dump_data ( addr + unk_off , edata , unk_off , & b ) else b [ "// [#{next_off - unk_off} data bytes]" ] unk_off = next_off end end end } end
dumps the source, optionnally including data
yields (defaults puts) each line
dumps the source optionnally including data yields ( defaults puts ) each line
# last off displayed # blocks.sort_by { |b| b.addr }.each { |b|
dump_data
b