Class: Exerb::Win32::ResourceEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/exerb/win32/resource_entry.rb

Overview

#

Defined Under Namespace

Classes: Data

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry_data, lang = nil) ⇒ ResourceEntry


19
20
21
22
# File 'lib/exerb/win32/resource_entry.rb', line 19

def initialize(entry_data, lang = nil)
  @entry_data = Exerb::Win32::ResourceEntry::Data.new(entry_data)
  @lang       = lang
end

Instance Attribute Details

#entry_dataObject

Returns the value of attribute entry_data


24
25
26
# File 'lib/exerb/win32/resource_entry.rb', line 24

def entry_data
  @entry_data
end

#langObject

Returns the value of attribute lang


24
25
26
# File 'lib/exerb/win32/resource_entry.rb', line 24

def lang
  @lang
end

Class Method Details

.read(io, base, lang) ⇒ Object


26
27
28
# File 'lib/exerb/win32/resource_entry.rb', line 26

def self.read(io, base, lang)
  return self.new(nil).read(io, base, lang)
end

Instance Method Details

#pack(table, reloc, base) ⇒ Object


37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/exerb/win32/resource_entry.rb', line 37

def pack(table, reloc, base)
  data = Exerb::Win32::Struct::ImageResourceDataEntry.new
  data.offset_to_data = table[@entry_data] + base
  data.size_of_data   = @entry_data.size
  data.code_page      = 0x0000
  data.reserved       = 0x0000

  reloc[self] ||= []
  reloc[self] << 0

  return data.pack
end

#read(io, base, lang) ⇒ Object


50
51
52
53
54
55
56
57
58
# File 'lib/exerb/win32/resource_entry.rb', line 50

def read(io, base, lang)
  data = Exerb::Win32::Struct::ImageResourceDataEntry.read(io)
  io.seek(data.offset_to_data - base)

  @entry_data = Exerb::Win32::ResourceEntry::Data.read(io, base, data.size_of_data)
  @lang       = lang

  return self
end

#serialize(elements, level) ⇒ Object


30
31
32
33
34
35
# File 'lib/exerb/win32/resource_entry.rb', line 30

def serialize(elements, level)
  elements[1][level] = [] if elements[1][level].nil?
  elements[1][level] << self
  @entry_data.serialize(elements, level + 1)
  return elements
end