Class: Exerb::Win32::ResourceDirectoryRoot

Inherits:
ResourceDirectory show all
Defined in:
lib/exerb/win32/resource_directory_root.rb

Overview

#

Instance Attribute Summary

Attributes inherited from ResourceDirectory

#entries, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ResourceDirectory

#<<, #pack, #read, #serialize

Constructor Details

#initializeResourceDirectoryRoot

Returns a new instance of ResourceDirectoryRoot


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

def initialize
  super(0)
end

Class Method Details

.read(io, base) ⇒ Object


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

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

Instance Method Details

#pack_all(base, reloc_table = []) ⇒ Object


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/exerb/win32/resource_directory_root.rb', line 32

def pack_all(base, reloc_table = [])
  table   = Hash.new(0)
  reloc   = {}
  address = 0
  buffer  = ''

  self.serial.each { |entries|
    entries.flatten!
    entries.compact!
  }.each { |entries|
    entries.each { |entry|
      table[entry] = address
      address += entry.pack(table, {}, base).size
    }
    address += (address % 16 == 0 ? 0 : 16 - address % 16)
  }.each { |entries|
    entries.each { |entry|
      buffer << entry.pack(table, reloc, base)
    }
    buffer = Exerb::Utility.alignment16(buffer)
  }

  reloc.keys.each { |obj|
    reloc[obj].each { |delta|
      reloc_table << table[obj] + delta
    }
  }
  reloc_table.sort!

  return buffer
end

#serialObject


28
29
30
# File 'lib/exerb/win32/resource_directory_root.rb', line 28

def serial
  return self.serialize([[], [], []], 0)
end