Class: Haxor::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/haxor/header.rb

Constant Summary collapse

MAGIC =

HAXOR (ASCII)

0x72_65_88_79_82
SIZE =

max 8 values (64bit per entry)

64

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Header

Returns a new instance of Header.



11
12
13
# File 'lib/haxor/header.rb', line 11

def initialize
  @magic = MAGIC
end

Instance Attribute Details

#bss_size ⇒ Object

Returns the value of attribute bss_size.



8
9
10
# File 'lib/haxor/header.rb', line 8

def bss_size
  @bss_size
end

#entry_point ⇒ Object

Returns the value of attribute entry_point.



7
8
9
# File 'lib/haxor/header.rb', line 7

def entry_point
  @entry_point
end

#stack_size ⇒ Object

Returns the value of attribute stack_size.



9
10
11
# File 'lib/haxor/header.rb', line 9

def stack_size
  @stack_size
end

#version ⇒ Object

Returns the value of attribute version.



6
7
8
# File 'lib/haxor/header.rb', line 6

def version
  @version
end

Instance Method Details

#dump ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/haxor/header.rb', line 15

def dump
  result = ''
  result << [
    @magic,
    @version,
    @entry_point,
    @bss_size,
    @stack_size
  ].pack('q<*')
  result.ljust(SIZE)
end

#parse!(data) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/haxor/header.rb', line 27

def parse!(data)
  data = data.unpack('q<*')
  @magic       = data.shift
  @version     = data.shift
  @entry_point = data.shift
  @bss_size    = data.shift
  @stack_size  = data.shift
end

#size ⇒ Object



36
37
38
# File 'lib/haxor/header.rb', line 36

def size
  SIZE
end