}
+PRE(host_get_special_port)
+{
+#pragma pack(4)
+ typedef struct {
+ mach_msg_header_t Head;
+ NDR_record_t NDR;
+ int node;
+ int which;
+ } Request;
+#pragma pack()
+
+ Request *req = (Request *)ARG1;
+
+ PRINT("host_get_special_port(node %d)", req->node);
+
+ switch (req->which) {
+ case HOST_PORT:
+ PRINT("host_get_special_port(%s, HOST_PORT)",
+ name_for_port(MACH_REMOTE));
+ break;
+ case HOST_PRIV_PORT:
+ PRINT("host_get_special_port(%s, HOST_PRIV_PORT)",
+ name_for_port(MACH_REMOTE));
+ break;
+ case HOST_IO_MASTER_PORT:
+ PRINT("host_get_special_port(%s, HOST_IO_MASTER_PORT)",
+ name_for_port(MACH_REMOTE));
+ break;
+ // Not provided by kernel
+ case HOST_DYNAMIC_PAGER_PORT:
+ PRINT("host_get_special_port(%s, HOST_DYNAMIC_PAGER_PORT)",
+ name_for_port(MACH_REMOTE));
+ break;
+ case HOST_AUDIT_CONTROL_PORT:
+ PRINT("host_get_special_port(%s, HOST_AUDIT_CONTROL_PORT)",
+ name_for_port(MACH_REMOTE));
+ break;
+ case HOST_USER_NOTIFICATION_PORT:
+ PRINT("host_get_special_port(%s, HOST_USER_NOTIFICATION_PORT)",
+ name_for_port(MACH_REMOTE));
+ break;
+ // ...
+
+ default:
+ PRINT("host_get_special_port(%s, %d)",
+ name_for_port(MACH_REMOTE), req->which);
+ break;
+ }
+
+ MACH_ARG(host_get_special_port.which) = req->which;
+
+ AFTER = POST_FN(host_get_special_port);
+}
+
+
+POST(host_get_special_port)
+{
+#pragma pack(4)
+ typedef struct {
+ mach_msg_header_t Head;
+ /* start of the kernel processed data */
+ mach_msg_body_t msgh_body;
+ mach_msg_port_descriptor_t port;
+ /* end of the kernel processed data */
+ } Reply;
+#pragma pack()
+
+ Reply *reply = (Reply *)ARG1;
+
+ PRINT("got port %#x ", reply->port.name);
+
+ /* The required entry in the allocated_ports list (mapping) might
+ not exist, due perhaps to broken syscall wrappers (mach__N etc).
+ Create a minimal entry so that assign_port_name below doesn't
+ cause an assertion. */
+ if (!port_exists(reply->port.name)) {
+ port_create_vanilla(reply->port.name);
+ }
+
+ switch (MACH_ARG(host_get_special_port.which)) {
+ case HOST_PORT:
+ assign_port_name(reply->port.name, "port-%p");
+ break;
+ case HOST_PRIV_PORT:
+ assign_port_name(reply->port.name, "priv-%p");
+ break;
+ case HOST_IO_MASTER_PORT:
+ assign_port_name(reply->port.name, "io-master-%p");
+ break;
+ // Not provided by kernel
+ case HOST_DYNAMIC_PAGER_PORT:
+ assign_port_name(reply->port.name, "dynamic-pager-%p");
+ break;
+ case HOST_AUDIT_CONTROL_PORT:
+ assign_port_name(reply->port.name, "audit-control-%p");
+ break;
+ case HOST_USER_NOTIFICATION_PORT:
+ assign_port_name(reply->port.name, "user-notification-%p");
+ break;
+ // ...
+
+ default:
+ assign_port_name(reply->port.name, "special-%p");
+ break;
+ }
+
+ PRINT("%s", name_for_port(reply->port.name));
+}
+
/* ---------------------------------------------------------------------
mach_msg: messages to a task
------------------------------------------------------------------ */
case 217:
CALL_PRE(host_request_notification);
return;
+
+ case 412:
+ CALL_PRE(host_get_special_port);
+ return;
default:
// unknown message to host self