class Metasm::MachO::LoadCommand::UNIXTHREAD

Attributes

ctx[RW]

Public Instance Methods

ctx_keys(m) click to toggle source
# File metasm/exe_format/macho.rb, line 316
def ctx_keys(m)
        case m.header.cputype
        when 'I386'; %w[eax ebx ecx edx edi esi ebp esp ss eflags eip cs ds es fs gs]
        when 'X86_64'; %w[rax rbx rcx rdx rdi rsi rbp rsp r8 r9 r10 r11 r12 r13 r14 r15 rip rflags cs fs gs]
        when 'POWERPC'; %w[srr0 srr1 r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 r16 r17 r18 r19 r20 r21 r22 r23 r24 r25 r26 r27 r28 r29 r30 r31 cr xer lr ctr mq vrsave]
        when 'ARM'; %w[r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 sp lr pc]
        else [*1..@count].map { |i| "r#{i}" }
        end.map { |k| k.to_sym }
end
decode(m) click to toggle source
Calls superclass method Metasm::SerialStruct#decode
# File metasm/exe_format/macho.rb, line 326
def decode(m)
        super(m)
        @ctx = ctx_keys(m)[0, @count].inject({}) { |ctx, r| ctx.update r => m.decode_xword }
end
encode(m) click to toggle source
Calls superclass method Metasm::SerialStruct#encode
# File metasm/exe_format/macho.rb, line 338
def encode(m)
        ctx_keys(m).inject(super(m)) { |ed, r| ed << m.encode_word(@ctx[r]) }
end
entrypoint(m) click to toggle source
# File metasm/exe_format/macho.rb, line 296
def entrypoint(m)
        @ctx ||= {}
        case m.header.cputype
        when 'I386'; @ctx[:eip]
        when 'X86_64'; @ctx[:rip]
        when 'POWERPC'; @ctx[:srr0]
        when 'ARM'; @ctx[:pc]
        end
end
set_default_values(m) click to toggle source
Calls superclass method Metasm::SerialStruct#set_default_values
# File metasm/exe_format/macho.rb, line 331
def set_default_values(m)
        @ctx ||= {}
        ctx_keys(m).each { |k| @ctx[k] ||= 0 }
        @count ||= @ctx.length
        super(m)
end
set_entrypoint(m, ep) click to toggle source
# File metasm/exe_format/macho.rb, line 306
def set_entrypoint(m, ep)
        @ctx ||= {}
        case m.header.cputype
        when 'I386'; @ctx[:eip] = ep
        when 'X86_64'; @ctx[:rip] = ep
        when 'POWERPC'; @ctx[:srr0] = ep
        when 'ARM'; @ctx[:pc] = ep
        end
end