lib/pedump/loader.rb
# find first occurence of string
# returns VA
find first occurence of string
returns VA
find first occurence of string returns VA
def find needle, options = {}
    options[:align] ||= 1
    options[:limit] ||= @find_limit
    if needle.is_a?(Fixnum)
      needle = [needle].pack('L')
    end
    if options[:align] == 1
      processed_bytes = 0
      sections.each do |section|
        next unless section.data 
        pos = section.data.index(needle)
        return section.va+pos if pos
        processed_bytes += section.vsize
        return nil if processed_bytes >= options[:limit]
      end
    end
    nil
  end
def find needle , options = { } options [ :align ] ||= 1 options [ :limit ] ||= @find_limit if needle . is_a? ( Fixnum ) needle = [ needle ] . pack ( 'L' ) end if options [ :align ] == 1 processed_bytes = 0 sections . each do | section | next unless section . data pos = section . data . index ( needle ) return section . va + pos if pos processed_bytes += section . vsize return nil if processed_bytes >= options [ :limit ] end end nil end
find first occurence of string
returns VA
find first occurence of string returns VA
# silently convert to DWORD # fastest find? # skip empty sections
needle
options