Class: PEdump::Loader::Section
Constant Summary collapse
- EMPTY_DATA =
''.force_encoding('binary')
Instance Attribute Summary collapse
- #data ⇒ Object
-
#hdr ⇒ Object
Returns the value of attribute hdr.
Instance Method Summary collapse
- #flags ⇒ Object
- #flags=(f) ⇒ Object
-
#initialize(x = nil, args = {}) ⇒ Section
constructor
A new instance of Section.
- #inspect ⇒ Object
- #name ⇒ Object
- #range ⇒ Object
- #va ⇒ Object
- #vsize ⇒ Object
Constructor Details
#initialize(x = nil, args = {}) ⇒ Section
Returns a new instance of Section.
8 9 10 11 12 13 14 15 16 |
# File 'lib/pedump/loader/section.rb', line 8 def initialize x = nil, args = {} if x.is_a?(PEdump::IMAGE_SECTION_HEADER) @hdr = x.dup end @data = EMPTY_DATA.dup @deferred_load_io = args[:deferred_load_io] @deferred_load_pos = args[:deferred_load_pos] || (@hdr && @hdr.PointerToRawData) @deferred_load_size = args[:deferred_load_size] || (@hdr && @hdr.SizeOfRawData) end |
Instance Attribute Details
#data ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pedump/loader/section.rb', line 24 def data if @data.empty? && @deferred_load_io && @deferred_load_pos && @deferred_load_size.to_i > 0 begin old_pos = @deferred_load_io.tell @deferred_load_io.seek @deferred_load_pos @data = @deferred_load_io.binmode.read(@deferred_load_size) || EMPTY_DATA.dup ensure if @deferred_load_io && old_pos @deferred_load_io.seek old_pos @deferred_load_io = nil # prevent read only on 1st access to data end end end @data end |
#hdr ⇒ Object
Returns the value of attribute hdr.
3 4 5 |
# File 'lib/pedump/loader/section.rb', line 3 def hdr @hdr end |
Instance Method Details
#flags ⇒ Object
21 |
# File 'lib/pedump/loader/section.rb', line 21 def flags; @hdr.Characteristics; end |
#flags=(f) ⇒ Object
22 |
# File 'lib/pedump/loader/section.rb', line 22 def flags= f; @hdr.Characteristics= f; end |
#inspect ⇒ Object
44 45 46 47 48 49 |
# File 'lib/pedump/loader/section.rb', line 44 def inspect "#<Section name=%-10s va=%8x vsize=%8x rawsize=%8s>" % [ name.inspect, va, vsize, @data.size > 0 ? @data.size.to_s(16) : (@deferred_load_io ? "<defer>" : 0) ] end |
#name ⇒ Object
18 |
# File 'lib/pedump/loader/section.rb', line 18 def name; @hdr.Name; end |
#range ⇒ Object
40 41 42 |
# File 'lib/pedump/loader/section.rb', line 40 def range va...(va+vsize) end |
#va ⇒ Object
19 |
# File 'lib/pedump/loader/section.rb', line 19 def va ; @hdr.VirtualAddress; end |
#vsize ⇒ Object
20 |
# File 'lib/pedump/loader/section.rb', line 20 def vsize; @hdr.VirtualSize; end |