Class: TurboRex::Windows::ALPC::Server::ClientStub

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

Instance Method Summary collapse

Constructor Details

#initialize(communication_handle, conn_handle, transport, conn_message) ⇒ ClientStub

Returns a new instance of ClientStub.



690
691
692
693
694
695
696
# File 'lib/turborex/windows/alpc.rb', line 690

def initialize(communication_handle, conn_handle, transport, conn_message)
  @communication_handle = communication_handle
  @connection_handle = conn_handle
  @conn_message = conn_message
  @transport = transport
  @client_id = conn_message.client_id
end

Instance Method Details

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



698
699
700
# File 'lib/turborex/windows/alpc.rb', line 698

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

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



702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
# File 'lib/turborex/windows/alpc.rb', line 702

def puts(message, message_id = nil, opts = {})
  if message.is_a? String
    port_message = PortMessage.new(payload: message)
    if opts[:last_header]
      port_message.header = opts[:last_header]
    elsif message_id
      port_message.message_id = message_id
    else
      raise "Message ID must be specified when :last_header option is not specified."
    end
  elsif message.is_a? PortMessage
    port_message = message
  else
    raise TurboRex::Exception::ALPC::UnknownPayloadType
  end

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