Class: TurboRex::Windows::ALPC::Client::ServerProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/turborex/windows/alpc.rb

Instance Method Summary collapse

Constructor Details

#initialize(communication_handle, transport, server_pid, server_tid) ⇒ ServerProxy

Returns a new instance of ServerProxy.



605
606
607
608
609
610
# File 'lib/turborex/windows/alpc.rb', line 605

def initialize(communication_handle, transport, server_pid, server_tid)
  @communication_handle = communication_handle
  @transport = transport
  @server_pid = server_pid
  @server_tid = server_tid
end

Instance Method Details

#disconnectObject



646
647
648
# File 'lib/turborex/windows/alpc.rb', line 646

def disconnect
  @transport.close
end

#gets(opts = {}) ⇒ Object Also known as: read



612
613
614
# File 'lib/turborex/windows/alpc.rb', line 612

def gets(opts = {})
  @transport.recv(@communication_handle, opts)
end

#puts(message, opts = {}) ⇒ Object Also known as: write



616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
# File 'lib/turborex/windows/alpc.rb', line 616

def puts(message, opts = {})
  if message.is_a? String
    port_message = PortMessage.new(payload: message)
    if opts[:last_header]
      port_message.header = opts[:last_header]
    end
  elsif message.is_a? PortMessage
    port_message = message
  else
    raise TurboRex::Exception::ALPC::UnknownPayloadType
  end

  message_attr = opts.delete(:message_attr) || MessageAttribute.new.struct
  @transport.send(@communication_handle, port_message.message, message_attr, opts)
end

#send_recv(message, opts = {}) ⇒ Object



632
633
634
635
636
637
638
639
640
641
642
643
644
# File 'lib/turborex/windows/alpc.rb', line 632

def send_recv(message, opts = {})
  if message.is_a? String
    port_message = PortMessage.new(payload: message)
  elsif message.is_a? ::Metasm::C::AllocCStruct
    port_message = message
  else
    raise TurboRex::Exception::ALPC::UnknownPayloadType
  end

  send_attr = port_message.attributes || opts[:attributes] || 0
  recv_attr = opts[:recv_attr] || MessageAttribute.new.struct
  @transport.send_recv(@communication_handle, port_message.message, send_attr, recv_attr)
end