class TurboRex::Windows::COM::Interface

Attributes

iid[R]
methods[R]
parent[R]
pvtbl[R]
this[RW]
vtbl[R]

Public Class Methods

define_interface(iid, method_defs={}, parent=IUnknown) click to toggle source
# File lib/turborex/windows/com/interface.rb, line 496
def self.define_interface(iid, method_defs={}, parent=IUnknown)
  api_proxy = Win32API.dup
  methods = [*parent::METHODS]
  method_defs.each_value {|v| api_proxy.parse_c(v) }
  method_defs.each_key {|k| methods<<api_proxy.cp.toplevel.symbol[k.to_s]}
  methods.compact!

  new(iid, methods, parent)
end
new(iid, methods, parent=IUnknown) click to toggle source
# File lib/turborex/windows/com/interface.rb, line 469
def initialize(iid, methods, parent=IUnknown)
  @iid = iid
  @methods = methods
  @parent = parent
  @api_proxy = Win32API.dup

  @methods.freeze
  definie_rb_proxy
end

Public Instance Methods

marshal_to_string(mshctx=MSHCTX_DIFFERENTMACHINE, mshlflags=MSHLFLAGS_NORMAL) click to toggle source
# File lib/turborex/windows/com/interface.rb, line 492
def marshal_to_string(mshctx=MSHCTX_DIFFERENTMACHINE, mshlflags=MSHLFLAGS_NORMAL)
  Utils.marshal_interface_to_string(self, mshctx, mshlflags)
end
name() click to toggle source
# File lib/turborex/windows/com/interface.rb, line 506
def name
  self.class.to_s
end
this=(ptr) click to toggle source
# File lib/turborex/windows/com/interface.rb, line 479
def this=(ptr)
  @this = ptr
  ptr_len = @api_proxy.host_cpu.size / 8
  format = ptr_len == 8 ? 'Q' : 'L'

  pvtbl = @api_proxy.memory_read(@this, ptr_len).unpack(format).first
  vtbl = @api_proxy.memory_read(pvtbl, ptr_len*@methods.count).unpack(format*@methods.count)
  @pvtbl = pvtbl
  @vtbl = vtbl

  @vtbl.each_with_index {|addr, i| @api_proxy.new_caller_for(@methods[i], @methods[i].name, addr)}
end

Private Instance Methods

definie_rb_proxy() click to toggle source
# File lib/turborex/windows/com/interface.rb, line 512
def definie_rb_proxy
  @methods.each do |m|
    self.define_singleton_method(m.name) do |*args|
      @api_proxy.send m.name, @this, *args
    end
  end
end