class TurboRex::Windows::TinySDK

Constants

DEFAULT_LOAD_FILE

Attributes

include_path[R]
loaded_files[R]
np[R]

Public Class Methods

format_hex_ntstatus(integer, opts = {}) click to toggle source
# File lib/turborex/windows/tinysdk.rb, line 71
def self.format_hex_ntstatus(integer, opts = {})
  integer = 0 unless integer
  unpacked = [integer].pack('V').unpack('V')[0]
  if opts[:hex_str]
    '0x' + unpacked.to_s(16).upcase
  else
    unpacked
  end
end
new() click to toggle source
# File lib/turborex/windows/tinysdk.rb, line 18
def initialize
  @loaded = false
  @loaded_files = []
  set_include_path
end
nt_error?(ntstatus) click to toggle source
# File lib/turborex/windows/tinysdk.rb, line 67
def self.nt_error?(ntstatus)
  (0xC0000000..0xFFFFFFFF).include?(ntstatus)
end
nt_information?(ntstatus) click to toggle source
# File lib/turborex/windows/tinysdk.rb, line 59
def self.nt_information?(ntstatus)
  (0x40000000..0x7FFFFFFF).include?(ntstatus)
end
nt_success?(ntstatus) click to toggle source

docs.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values

# File lib/turborex/windows/tinysdk.rb, line 55
def self.nt_success?(ntstatus)
  (0..0x3FFFFFFF).include?(ntstatus) || (0x40000000..0x7FFFFFFF).include?(ntstatus) || ntstatus.nil?
end
nt_warning?(ntstatus) click to toggle source
# File lib/turborex/windows/tinysdk.rb, line 63
def self.nt_warning?(ntstatus)
  (0x80000000..0xBFFFFFFF).include?(ntstatus)
end

Public Instance Methods

load(opts = {}) click to toggle source
# File lib/turborex/windows/tinysdk.rb, line 24
def load(opts = {})
  return true if loaded?
  load!(opts)
end
load!(opts) click to toggle source
# File lib/turborex/windows/tinysdk.rb, line 29
def load!(opts)
  opts[:cpu] ||= ::Metasm::Ia32

  opts[:visual_studio] = true
  opts[:data_model] = 'llp64' if opts[:cpu] == Metasm::X86_64
  opts[:predefined] = true

  @np = TurboRex::CStruct::NativeParser.new(nil, opts)
  @cp = @np.parser

  if opts[:files]
    opts[:files].each {|f| @cp.parse_file(f)}
    @loaded_files = opts[:files]
  else
    @cp.parse_file(DEFAULT_LOAD_FILE)
    @loaded_files << DEFAULT_LOAD_FILE
  end

  true
end
loaded?() click to toggle source
# File lib/turborex/windows/tinysdk.rb, line 50
def loaded?
  @loaded
end

Private Instance Methods

set_include_path() click to toggle source
# File lib/turborex/windows/tinysdk.rb, line 83
def set_include_path
  root = TurboRex.root + '/resources/headers'
  @include_path = TurboRex::Utils.get_all_subdir(root)
end