Class: Exerb::Win32::PeFile
- Inherits:
-
Object
- Object
- Exerb::Win32::PeFile
- Defined in:
- lib/exerb/win32/pe_file.rb
Overview
#
Instance Attribute Summary collapse
-
#dos_header ⇒ Object
Returns the value of attribute dos_header.
-
#nt_headers ⇒ Object
Returns the value of attribute nt_headers.
-
#sections ⇒ Object
Returns the value of attribute sections.
Class Method Summary collapse
Instance Method Summary collapse
- #find_section(name) ⇒ Object
-
#initialize ⇒ PeFile
constructor
A new instance of PeFile.
- #read(io) ⇒ Object
Constructor Details
#initialize ⇒ PeFile
Returns a new instance of PeFile.
22 23 24 25 26 |
# File 'lib/exerb/win32/pe_file.rb', line 22 def initialize @dos_header = nil @nt_headers = nil @sections = nil end |
Instance Attribute Details
#dos_header ⇒ Object
Returns the value of attribute dos_header.
28 29 30 |
# File 'lib/exerb/win32/pe_file.rb', line 28 def dos_header @dos_header end |
#nt_headers ⇒ Object
Returns the value of attribute nt_headers.
28 29 30 |
# File 'lib/exerb/win32/pe_file.rb', line 28 def nt_headers @nt_headers end |
#sections ⇒ Object
Returns the value of attribute sections.
28 29 30 |
# File 'lib/exerb/win32/pe_file.rb', line 28 def sections @sections end |
Class Method Details
.new_from_binary(bin) ⇒ Object
34 35 36 |
# File 'lib/exerb/win32/pe_file.rb', line 34 def self.new_from_binary(bin) return self.read(StringIO.new(bin)) end |
.new_from_file(filepath) ⇒ Object
38 39 40 |
# File 'lib/exerb/win32/pe_file.rb', line 38 def self.new_from_file(filepath) return File.open(filepath, 'rb') { |file| self.read(file) } end |
.read(io) ⇒ Object
30 31 32 |
# File 'lib/exerb/win32/pe_file.rb', line 30 def self.read(io) return self.new.read(io) end |
Instance Method Details
#find_section(name) ⇒ Object
52 53 54 |
# File 'lib/exerb/win32/pe_file.rb', line 52 def find_section(name) return @sections.find { |section| section.name == name } end |
#read(io) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/exerb/win32/pe_file.rb', line 42 def read(io) @dos_header = Exerb::Win32::Struct::ImageDosHeader.read(io) io.seek(-@dos_header.size, IO::SEEK_CUR) io.seek(@dos_header.offset_to_new_header, IO::SEEK_CUR) @nt_headers = Exerb::Win32::Struct::ImageNtHeaders32.read(io) @sections = (1..@nt_headers.file_header.number_of_sections).collect { Exerb::Win32::Struct::ImageSectionHeader.read(io) } return self end |