示例#1
0
    def send_receive(self,
                     alpc_message,
                     receive_msg=None,
                     flags=gdef.ALPC_MSGFLG_SYNC_REQUEST,
                     timeout=None):
        """Send and receive a message with ``flags``.

            :param alpc_message: The message to send. If ``alpc_message`` is a :class:`str` it build an AlpcMessage with the message as data.
            :type alpc_message: AlpcMessage or str
            :param receive_msg: The message to send. If ``receive_msg`` is a ``None`` it create and return a simple :class:`AlpcMessage`
            :type receive_msg: AlpcMessage or None
            :param int flags: The flags for :func:`NtAlpcSendWaitReceivePort`
        """
        if isinstance(alpc_message, windows.pycompat.anybuff):
            raw_alpc_message = alpc_message
            alpc_message = AlpcMessage(max(0x1000, len(alpc_message) + 0x200))
            alpc_message.port_message.data = raw_alpc_message

        if receive_msg is None:
            receive_msg = AlpcMessage(DEFAULT_MESSAGE_SIZE)
        receive_size = gdef.SIZE_T(receive_msg.port_message_buffer_size)
        winproxy.NtAlpcSendWaitReceivePort(self.handle, flags,
                                           alpc_message.port_message,
                                           alpc_message.attributes,
                                           receive_msg.port_message,
                                           receive_size,
                                           receive_msg.attributes, timeout)
        return receive_msg
示例#2
0
    def recv(self, receive_msg=None, flags=0):
        """Receive a message into ``alpc_message`` with ``flags``.

            :param receive_msg: The message to send. If ``receive_msg`` is a ``None`` it create and return a simple :class:`AlpcMessage`
            :type receive_msg: AlpcMessage or None
            :param int flags: The flags for :func:`NtAlpcSendWaitReceivePort`
        """
        if receive_msg is None:
            receive_msg = AlpcMessage(0x1000)
        receive_size = gdef.SIZE_T(receive_msg.port_message_buffer_size)
        winproxy.NtAlpcSendWaitReceivePort(self.handle, flags, None, None, receive_msg.port_message, receive_size, receive_msg.attributes, None)
        return receive_msg
示例#3
0
    def send(self, alpc_message, flags=0):
        """Send the ``alpc_message`` with ``flags``

            :param alpc_message: The message to send. If ``alpc_message`` is a :class:`str` it build an AlpcMessage with the message as data.
            :type alpc_message: AlpcMessage or str
            :param int flags: The flags for :func:`NtAlpcSendWaitReceivePort`
        """
        if isinstance(alpc_message, basestring):
            raw_alpc_message = alpc_message
            alpc_message = AlpcMessage(max(0x1000, len(alpc_message)))
            alpc_message.port_message.data = raw_alpc_message
        winproxy.NtAlpcSendWaitReceivePort(self.handle, flags, alpc_message.port_message, alpc_message.attributes, None, None, None, None)