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
def create_port_section(self, Flags, SectionHandle, SectionSize): AlpcSectionHandle = gdef.HANDLE() ActualSectionSize = gdef.SIZE_T() # RPCRT4 USE FLAGS 0x40000 ALPC_VIEWFLG_NOT_SECURE ? winproxy.NtAlpcCreatePortSection(self.handle, Flags, SectionHandle, SectionSize, AlpcSectionHandle, ActualSectionSize) return AlpcSection(AlpcSectionHandle.value, ActualSectionSize.value)
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