node/lib/metasm/metasm/exe_format/coff_decode.rb
# decodes COFF import tables from directory
# mark iat entries as encoded.export
decodes COFF import tables from directory
mark iat entries as encoded.export
decodes COFF import tables from directory mark iat entries as encoded . export
def decode_imports
		if @directory['import_table'] and sect_at_rva(@directory['import_table'][0])
			@imports = ImportDirectory.decode_all(self)
			iatlen = @bitsize/8
			@imports.each { |id|
				if sect_at_rva(id.iat_p)
					ptr = curencoded.ptr
					id.imports.each { |i|
						if i.name
							name = new_label i.name
						elsif i.ordinal
							name = new_label "ord_#{id.libname}_#{i.ordinal}"
						end
						if name
							i.target ||= name
							r = Metasm::Relocation.new(Expression[name], "u#@bitsize".to_sym, @endianness)
							curencoded.reloc[ptr] = r
							curencoded.add_export new_label('iat_'+name), ptr, true
						end
						ptr += iatlen
					}
				end
			}
		end
	end
def decode_imports if @directory [ 'import_table' ] and sect_at_rva ( @directory [ 'import_table' ] [ 0 ] ) @imports = ImportDirectory . decode_all ( self ) iatlen = @bitsize / 8 @imports . each { | id | if sect_at_rva ( id . iat_p ) ptr = curencoded . ptr id . imports . each { | i | if i . name name = new_label i . name elsif i . ordinal name = new_label "ord_#{id.libname}_#{i.ordinal}" end if name i . target ||= name r = Metasm :: Relocation . new ( Expression [ name ] , "u#@bitsize" . to_sym , @endianness ) curencoded . reloc [ ptr ] = r curencoded . add_export new_label ( 'iat_' + name ) , ptr , true end ptr += iatlen } end } end end
decodes COFF import tables from directory
mark iat entries as encoded.export
decodes COFF import tables from directory mark iat entries as encoded . export