Represent a full ALPC Message: a :class:`AlpcMessagePort` and a :class:`MessageAttribute`
| 20 | DEFAULT_MESSAGE_SIZE = 0x1000 |
| 21 | |
| 22 | class AlpcMessage(object): |
| 23 | """Represent a full ALPC Message: a :class:`AlpcMessagePort` and a :class:`MessageAttribute`""" |
| 24 | # PORT_MESSAGE + MessageAttribute |
| 25 | def __init__(self, msg_or_size=DEFAULT_MESSAGE_SIZE, attributes=None): |
| 26 | # Init the PORT_MESSAGE |
| 27 | if isinstance(msg_or_size, windows.pycompat.int_types): |
| 28 | self.port_message_buffer_size = msg_or_size |
| 29 | self.port_message_raw_buffer = ctypes.c_buffer(msg_or_size) |
| 30 | self.port_message = AlpcMessagePort.from_buffer(self.port_message_raw_buffer) |
| 31 | self.port_message.set_datalen(0) |
| 32 | elif isinstance(msg_or_size, AlpcMessagePort): |
| 33 | self.port_message = msg_or_size |
| 34 | self.port_message_raw_buffer = self.port_message.raw_buffer |
| 35 | self.port_message_buffer_size = len(self.port_message_raw_buffer) |
| 36 | else: |
| 37 | raise NotImplementedError("Uneexpected type for <msg_or_size>: {0}".format(msg_or_size)) |
| 38 | |
| 39 | # Init the MessageAttributes |
| 40 | if attributes is None: |
| 41 | # self.attributes = MessageAttribute.with_all_attributes() |
| 42 | self.attributes = MessageAttribute.with_all_attributes() ## Testing |
| 43 | else: |
| 44 | self.attributes = attributes |
| 45 | |
| 46 | # PORT_MESSAGE wrappers |
| 47 | @property |
| 48 | def type(self): |
| 49 | """The type of the message (``PORT_MESSAGE.u2.s2.Type``)""" |
| 50 | return self.port_message.u2.s2.Type |
| 51 | |
| 52 | def get_port_message_data(self): |
| 53 | return self.port_message.data |
| 54 | |
| 55 | def set_port_message_data(self, data): |
| 56 | self.port_message.data = data |
| 57 | |
| 58 | data = property(get_port_message_data, set_port_message_data) |
| 59 | "The data of the message (located after the PORT_MESSAGE header)" |
| 60 | |
| 61 | # MessageAttributes wrappers |
| 62 | |
| 63 | ## Low level attributes access |
| 64 | @property |
| 65 | def security_attribute(self): |
| 66 | """The :data:`~windows.generated_def.ALPC_MESSAGE_SECURITY_ATTRIBUTE` of the message |
| 67 | |
| 68 | :type: :class:`ALPC_SECURITY_ATTR` |
| 69 | """ |
| 70 | return self.attributes.get_attribute(gdef.ALPC_MESSAGE_SECURITY_ATTRIBUTE) |
| 71 | |
| 72 | @property |
| 73 | def view_attribute(self): |
| 74 | """The :data:`~windows.generated_def.ALPC_MESSAGE_VIEW_ATTRIBUTE` of the message: |
| 75 | |
| 76 | :type: :class:`ALPC_DATA_VIEW_ATTR` |
| 77 | """ |
| 78 | return self.attributes.get_attribute(gdef.ALPC_MESSAGE_VIEW_ATTRIBUTE) |
| 79 |
no outgoing calls
no test coverage detected