class PEdump::VS_VERSIONINFO

Constants

Children
Padding1
Padding2
Value

Public Class Methods

read(f, size = SIZE) click to toggle source
Calls superclass method
# File lib/pedump/version_info.rb, line 13
def self.read f, size = SIZE
  super.tap do |vi|
    vi.szKey.force_encoding('UTF-16LE').encode!('UTF-8').sub!(/\u0000$/,'') rescue nil
    vi.Padding1 = f.tell%4 > 0 ? f.read(4 - f.tell%4) : nil
    vi.Value = VS_FIXEDFILEINFO.read(f,vi.wValueLength)
    # As many zero words as necessary to align the Children member on a 32-bit boundary.
    # These bytes are not included in wValueLength. This member is optional.
    vi.Padding2 = f.tell%4 > 0 ? f.read(4 - f.tell%4) : nil
    vi.Children = [] # An array of zero or one StringFileInfo structures,
                     # and zero or one VarFileInfo structures

    2.times do
      pos = f.tell
      f.seek(pos+6)  # seek 6 bytes forward
      t = f.read(6)
      f.seek(pos)    # return back
      case t
      when "V\x00a\x00r\x00"
        vi.Children << VarFileInfo.read(f)
      when "S\x00t\x00r\x00"
        vi.Children << StringFileInfo.read(f)
      else
        PEdump.logger.warn "[?] invalid VS_VERSIONINFO child type #{t.inspect}"
        break
      end
    end
  end
end