node/lib/metasm/metasm/exe_format/coff_decode.rb
def decode_relocs
		if @directory['base_relocation_table'] and sect_at_rva(@directory['base_relocation_table'][0])
			end_ptr = curencoded.ptr + @directory['base_relocation_table'][1]
			@relocations = []
			while curencoded.ptr < end_ptr
				@relocations << RelocationTable.decode(self)
			end

			# interpret as EncodedData relocations
			relocfunc = ('decode_reloc_' << @header.machine.downcase).to_sym
			if not respond_to? relocfunc
				puts "W: COFF: unsupported relocs for architecture #{@header.machine}" if $VERBOSE
				return
			end
			@relocations.each { |rt|
				rt.relocs.each { |r|
					if s = sect_at_rva(rt.base_addr + r.offset)
						e, p = s.encoded, s.encoded.ptr
						rel = send(relocfunc, r)
						e.reloc[p] = rel if rel
					end
				}
			}
		end
	end
# decode COFF relocation tables from directory
decode COFF relocation tables from directory
decode COFF relocation tables from directory
def decode_relocs
		if @directory['base_relocation_table'] and sect_at_rva(@directory['base_relocation_table'][0])
			end_ptr = curencoded.ptr + @directory['base_relocation_table'][1]
			@relocations = []
			while curencoded.ptr < end_ptr
				@relocations << RelocationTable.decode(self)
			end
			relocfunc = ('decode_reloc_' << @header.machine.downcase).to_sym
			if not respond_to? relocfunc
				puts "W: COFF: unsupported relocs for architecture #{@header.machine}" if $VERBOSE
				return
			end
			@relocations.each { |rt|
				rt.relocs.each { |r|
					if s = sect_at_rva(rt.base_addr + r.offset)
						e, p = s.encoded, s.encoded.ptr
						rel = send(relocfunc, r)
						e.reloc[p] = rel if rel
					end
				}
			}
		end
	end
def decode_relocs if @directory [ 'base_relocation_table' ] and sect_at_rva ( @directory [ 'base_relocation_table' ] [ 0 ] ) end_ptr = curencoded . ptr + @directory [ 'base_relocation_table' ] [ 1 ] @relocations = [ ] while curencoded . ptr < end_ptr @relocations << RelocationTable . decode ( self ) end relocfunc = ( 'decode_reloc_' << @header . machine . downcase ) . to_sym if not respond_to? relocfunc puts "W: COFF: unsupported relocs for architecture #{@header.machine}" if $VERBOSE return end @relocations . each { | rt | rt . relocs . each { | r | if s = sect_at_rva ( rt . base_addr + r . offset ) e , p = s . encoded , s . encoded . ptr rel = send ( relocfunc , r ) e . reloc [ p ] = rel if rel end } } end end
decode COFF relocation tables from directory
decode COFF relocation tables from directory
# interpret as EncodedData relocations