+@header("{: <20s} {: <8s} {: <20s} {: <10s} {: <20s}".format("kmsgheader", "size", "body", "ds_count", "dsc_head"))
+def GetKMsgBody(kmsgp, prefix_str=""):
+ """ Routine that prints a complex kmsg's body
+ """
+ kmsghp = kmsgp.ikm_header
+ kmsgh = dereference(kmsghp)
+ format_string = "{: <#020x} {: <#08x} {: <#020x} {: <#010x} {: <#020x}"
+ out_string = ""
+ body = Cast(addressof(kmsghp[1]), 'mach_msg_body_t *')
+ dsc_count = body.msgh_descriptor_count
+
+ dschead = Cast(addressof(body[1]), 'mach_msg_descriptor_t *')
+ out_string += format_string.format(kmsghp, sizeof(dereference(kmsghp)), body, unsigned(dsc_count), dschead)
+
+ for i in range(dsc_count):
+ dsc = dschead[i]
+ out_string += "\n" + prefix_str + "Descriptor: " + xnudefines.mach_msg_type_descriptor_strings[unsigned(dsc.type.type)]
+ if unsigned(dsc.type.type) == 0:
+ # its a port.
+ p = dsc.port.name
+ out_string += " name: {: <#20x}".format(p)
+ elif unsigned(dsc.type.type) in (1,3):
+ # its OOL DESCRIPTOR or OOL VOLATILE DESCRIPTOR
+ ool = dsc.out_of_line
+ out_string += " " + GetMachMsgOOLDescriptorSummary(addressof(ool))
+ return out_string
+