diff options
Diffstat (limited to 'tmp')
-rw-r--r-- | tmp/Makefile | 27 | ||||
-rw-r--r-- | tmp/core | bin | 0 -> 17051648 bytes | |||
-rw-r--r-- | tmp/device.h | 336 | ||||
-rw-r--r-- | tmp/deviceServer.c | 1168 | ||||
-rw-r--r-- | tmp/deviceUser.c | 1893 | ||||
-rw-r--r-- | tmp/mach.h | 1263 | ||||
-rw-r--r-- | tmp/machServer.c | 4175 | ||||
-rw-r--r-- | tmp/machUser.c | 6562 | ||||
-rw-r--r-- | tmp/mach_port.h | 432 | ||||
-rw-r--r-- | tmp/mach_portServer.c | 1413 | ||||
-rw-r--r-- | tmp/mach_portUser.c | 2296 | ||||
-rwxr-xr-x | tmp/test | bin | 0 -> 18950 bytes | |||
-rw-r--r-- | tmp/test.c | 95 | ||||
-rw-r--r-- | tmp/test.c~ | 96 | ||||
-rw-r--r-- | tmp/test.d | 69 | ||||
-rw-r--r-- | tmp/test.o | bin | 0 -> 15788 bytes | |||
-rw-r--r-- | tmp/test.prof_d | 1 | ||||
-rw-r--r-- | tmp/test1.c | 26 |
18 files changed, 19852 insertions, 0 deletions
diff --git a/tmp/Makefile b/tmp/Makefile new file mode 100644 index 00000000..9de5107f --- /dev/null +++ b/tmp/Makefile @@ -0,0 +1,27 @@ +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 2008 Free Software Foundation, Inc. +# This file is part of the GNU Hurd. +# +# The GNU Hurd is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# The GNU Hurd is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with the GNU Hurd; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +dir := tmp +makemode := server + +SRCS = test.c +HURDLIBS = +target = test +OBJS = $(SRCS:.c=.o) $(MIGSTUBS) + +include ../Makeconf + diff --git a/tmp/core b/tmp/core Binary files differnew file mode 100644 index 00000000..5523cb96 --- /dev/null +++ b/tmp/core diff --git a/tmp/device.h b/tmp/device.h new file mode 100644 index 00000000..db0798d6 --- /dev/null +++ b/tmp/device.h @@ -0,0 +1,336 @@ +#ifndef _device_user_ +#define _device_user_ + +/* Module device */ + +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/message.h> + +#include <mach/std_types.h> +#include <mach/mach_types.h> +#include <device/device_types.h> +#include <device/net_status.h> + +/* Routine device_open */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t device_open +#if defined(LINTLIBRARY) + (master_port, mode, name, device) + mach_port_t master_port; + dev_mode_t mode; + dev_name_t name; + mach_port_t *device; +{ return device_open(master_port, mode, name, device); } +#else +( + mach_port_t master_port, + dev_mode_t mode, + dev_name_t name, + mach_port_t *device +); +#endif + +/* Routine device_close */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t device_close +#if defined(LINTLIBRARY) + (device) + mach_port_t device; +{ return device_close(device); } +#else +( + mach_port_t device +); +#endif + +/* Routine device_write */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t device_write +#if defined(LINTLIBRARY) + (device, mode, recnum, data, dataCnt, bytes_written) + mach_port_t device; + dev_mode_t mode; + recnum_t recnum; + io_buf_ptr_t data; + mach_msg_type_number_t dataCnt; + int *bytes_written; +{ return device_write(device, mode, recnum, data, dataCnt, bytes_written); } +#else +( + mach_port_t device, + dev_mode_t mode, + recnum_t recnum, + io_buf_ptr_t data, + mach_msg_type_number_t dataCnt, + int *bytes_written +); +#endif + +/* Routine device_write_inband */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t device_write_inband +#if defined(LINTLIBRARY) + (device, mode, recnum, data, dataCnt, bytes_written) + mach_port_t device; + dev_mode_t mode; + recnum_t recnum; + io_buf_ptr_inband_t data; + mach_msg_type_number_t dataCnt; + int *bytes_written; +{ return device_write_inband(device, mode, recnum, data, dataCnt, bytes_written); } +#else +( + mach_port_t device, + dev_mode_t mode, + recnum_t recnum, + io_buf_ptr_inband_t data, + mach_msg_type_number_t dataCnt, + int *bytes_written +); +#endif + +/* Routine device_read */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t device_read +#if defined(LINTLIBRARY) + (device, mode, recnum, bytes_wanted, data, dataCnt) + mach_port_t device; + dev_mode_t mode; + recnum_t recnum; + int bytes_wanted; + io_buf_ptr_t *data; + mach_msg_type_number_t *dataCnt; +{ return device_read(device, mode, recnum, bytes_wanted, data, dataCnt); } +#else +( + mach_port_t device, + dev_mode_t mode, + recnum_t recnum, + int bytes_wanted, + io_buf_ptr_t *data, + mach_msg_type_number_t *dataCnt +); +#endif + +/* Routine device_read_inband */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t device_read_inband +#if defined(LINTLIBRARY) + (device, mode, recnum, bytes_wanted, data, dataCnt) + mach_port_t device; + dev_mode_t mode; + recnum_t recnum; + int bytes_wanted; + io_buf_ptr_inband_t data; + mach_msg_type_number_t *dataCnt; +{ return device_read_inband(device, mode, recnum, bytes_wanted, data, dataCnt); } +#else +( + mach_port_t device, + dev_mode_t mode, + recnum_t recnum, + int bytes_wanted, + io_buf_ptr_inband_t data, + mach_msg_type_number_t *dataCnt +); +#endif + +/* Routine xxx_device_set_status */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t xxx_device_set_status +#if defined(LINTLIBRARY) + (device, flavor, status, statusCnt) + mach_port_t device; + dev_flavor_t flavor; + dev_status_t status; + mach_msg_type_number_t statusCnt; +{ return xxx_device_set_status(device, flavor, status, statusCnt); } +#else +( + mach_port_t device, + dev_flavor_t flavor, + dev_status_t status, + mach_msg_type_number_t statusCnt +); +#endif + +/* Routine xxx_device_get_status */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t xxx_device_get_status +#if defined(LINTLIBRARY) + (device, flavor, status, statusCnt) + mach_port_t device; + dev_flavor_t flavor; + dev_status_t status; + mach_msg_type_number_t *statusCnt; +{ return xxx_device_get_status(device, flavor, status, statusCnt); } +#else +( + mach_port_t device, + dev_flavor_t flavor, + dev_status_t status, + mach_msg_type_number_t *statusCnt +); +#endif + +/* Routine xxx_device_set_filter */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t xxx_device_set_filter +#if defined(LINTLIBRARY) + (device, receive_port, receive_portPoly, priority, filter, filterCnt) + mach_port_t device; + mach_port_t receive_port; + mach_msg_type_name_t receive_portPoly; + int priority; + filter_array_t filter; + mach_msg_type_number_t filterCnt; +{ return xxx_device_set_filter(device, receive_port, receive_portPoly, priority, filter, filterCnt); } +#else +( + mach_port_t device, + mach_port_t receive_port, + mach_msg_type_name_t receive_portPoly, + int priority, + filter_array_t filter, + mach_msg_type_number_t filterCnt +); +#endif + +/* Routine device_map */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t device_map +#if defined(LINTLIBRARY) + (device, prot, offset, size, pager, unmap) + mach_port_t device; + vm_prot_t prot; + vm_offset_t offset; + vm_size_t size; + mach_port_t *pager; + int unmap; +{ return device_map(device, prot, offset, size, pager, unmap); } +#else +( + mach_port_t device, + vm_prot_t prot, + vm_offset_t offset, + vm_size_t size, + mach_port_t *pager, + int unmap +); +#endif + +/* Routine device_set_status */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t device_set_status +#if defined(LINTLIBRARY) + (device, flavor, status, statusCnt) + mach_port_t device; + dev_flavor_t flavor; + dev_status_t status; + mach_msg_type_number_t statusCnt; +{ return device_set_status(device, flavor, status, statusCnt); } +#else +( + mach_port_t device, + dev_flavor_t flavor, + dev_status_t status, + mach_msg_type_number_t statusCnt +); +#endif + +/* Routine device_get_status */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t device_get_status +#if defined(LINTLIBRARY) + (device, flavor, status, statusCnt) + mach_port_t device; + dev_flavor_t flavor; + dev_status_t status; + mach_msg_type_number_t *statusCnt; +{ return device_get_status(device, flavor, status, statusCnt); } +#else +( + mach_port_t device, + dev_flavor_t flavor, + dev_status_t status, + mach_msg_type_number_t *statusCnt +); +#endif + +/* Routine device_set_filter */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t device_set_filter +#if defined(LINTLIBRARY) + (device, receive_port, receive_portPoly, priority, filter, filterCnt) + mach_port_t device; + mach_port_t receive_port; + mach_msg_type_name_t receive_portPoly; + int priority; + filter_array_t filter; + mach_msg_type_number_t filterCnt; +{ return device_set_filter(device, receive_port, receive_portPoly, priority, filter, filterCnt); } +#else +( + mach_port_t device, + mach_port_t receive_port, + mach_msg_type_name_t receive_portPoly, + int priority, + filter_array_t filter, + mach_msg_type_number_t filterCnt +); +#endif + +#endif /* not defined(_device_user_) */ diff --git a/tmp/deviceServer.c b/tmp/deviceServer.c new file mode 100644 index 00000000..c0d1cece --- /dev/null +++ b/tmp/deviceServer.c @@ -0,0 +1,1168 @@ +/* Module device */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_local_port +#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) +#define msgh_reply_port msgh_remote_port +#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) + +#include <mach/std_types.h> +#include <mach/mach_types.h> +#include <device/device_types.h> +#include <device/net_status.h> + +/* Routine device_open */ +mig_internal void _Xdevice_open + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_long_t nameType; + dev_name_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t deviceType; + mach_port_t device; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_open + (mach_port_t master_port, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, dev_name_t name, mach_port_t *device); + + auto const mach_msg_type_t modeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t deviceType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 172) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->nameType.msgtl_header.msgt_inline != TRUE) || + (In0P->nameType.msgtl_header.msgt_longform != TRUE) || + (In0P->nameType.msgtl_name != 12) || + (In0P->nameType.msgtl_number != 1) || + (In0P->nameType.msgtl_size != 1024)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_open(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->mode, In0P->name, &OutP->device); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 40; + + OutP->deviceType = deviceType; +} + +/* Routine device_close */ +mig_internal void _Xdevice_close + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_close + (mach_port_t device); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_close(In0P->Head.msgh_request_port); +} + +/* Routine device_write */ +mig_internal void _Xdevice_write + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_t recnumType; + recnum_t recnum; + mach_msg_type_long_t dataType; + io_buf_ptr_t data; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t bytes_writtenType; + int bytes_written; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_write + (mach_port_t device, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, recnum_t recnum, io_buf_ptr_t data, mach_msg_type_number_t dataCnt, int *bytes_written); + + auto const mach_msg_type_t modeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t recnumCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bytes_writtenType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 56) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->recnumType, &recnumCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->dataType.msgtl_header.msgt_inline != FALSE) || + (In0P->dataType.msgtl_header.msgt_longform != TRUE) || + (In0P->dataType.msgtl_name != 9) || + (In0P->dataType.msgtl_size != 8)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_write(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->mode, In0P->recnum, In0P->data, In0P->dataType.msgtl_number, &OutP->bytes_written); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->bytes_writtenType = bytes_writtenType; +} + +/* Routine device_write_inband */ +mig_internal void _Xdevice_write_inband + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_t recnumType; + recnum_t recnum; + mach_msg_type_t dataType; + char data[128]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t bytes_writtenType; + int bytes_written; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_write_inband + (mach_port_t device, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, recnum_t recnum, io_buf_ptr_inband_t data, mach_msg_type_number_t dataCnt, int *bytes_written); + + unsigned int msgh_size; + + auto const mach_msg_type_t modeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t recnumCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bytes_writtenType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 44) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->recnumType, &recnumCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->dataType.msgt_inline != TRUE) || + (In0P->dataType.msgt_longform != FALSE) || + (In0P->dataType.msgt_name != 8) || + (In0P->dataType.msgt_size != 8)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 44 + ((In0P->dataType.msgt_number + 3) & ~3)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_write_inband(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->mode, In0P->recnum, In0P->data, In0P->dataType.msgt_number, &OutP->bytes_written); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->bytes_writtenType = bytes_writtenType; +} + +/* Routine device_read */ +mig_internal void _Xdevice_read + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_t recnumType; + recnum_t recnum; + mach_msg_type_t bytes_wantedType; + int bytes_wanted; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t dataType; + io_buf_ptr_t data; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_read + (mach_port_t device, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, recnum_t recnum, int bytes_wanted, io_buf_ptr_t *data, mach_msg_type_number_t *dataCnt); + + auto const mach_msg_type_t modeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t recnumCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bytes_wantedCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t dataType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 9, + /* msgtl_size = */ 8, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t dataCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->recnumType, &recnumCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->bytes_wantedType, &bytes_wantedCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_read(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->mode, In0P->recnum, In0P->bytes_wanted, &OutP->data, &dataCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->dataType = dataType; + + OutP->dataType.msgtl_number = dataCnt; +} + +/* Routine device_read_inband */ +mig_internal void _Xdevice_read_inband + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_t recnumType; + recnum_t recnum; + mach_msg_type_t bytes_wantedType; + int bytes_wanted; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t dataType; + char data[128]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_read_inband + (mach_port_t device, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, recnum_t recnum, int bytes_wanted, io_buf_ptr_inband_t data, mach_msg_type_number_t *dataCnt); + + auto const mach_msg_type_t modeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t recnumCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bytes_wantedCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t dataType = { + /* msgt_name = */ 8, + /* msgt_size = */ 8, + /* msgt_number = */ 128, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_number_t dataCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->recnumType, &recnumCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->bytes_wantedType, &bytes_wantedCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + dataCnt = 128; + + OutP->RetCode = ds_device_read_inband(In0P->Head.msgh_request_port, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), In0P->mode, In0P->recnum, In0P->bytes_wanted, OutP->data, &dataCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->dataType = dataType; + + OutP->dataType.msgt_number = dataCnt; + OutP->Head.msgh_size = 36 + ((dataCnt + 3) & ~3); +} + +/* Routine xxx_device_set_status */ +mig_internal void _Xxxx_device_set_status + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + dev_flavor_t flavor; + mach_msg_type_long_t statusType; + int status[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_xxx_device_set_status + (mach_port_t device, dev_flavor_t flavor, dev_status_t status, mach_msg_type_number_t statusCnt); + + unsigned int msgh_size; + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 44) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->statusType.msgtl_header.msgt_inline != TRUE) || + (In0P->statusType.msgtl_header.msgt_longform != TRUE) || + (In0P->statusType.msgtl_name != 2) || + (In0P->statusType.msgtl_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 44 + (4 * In0P->statusType.msgtl_number)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_xxx_device_set_status(In0P->Head.msgh_request_port, In0P->flavor, In0P->status, In0P->statusType.msgtl_number); +} + +/* Routine xxx_device_get_status */ +mig_internal void _Xxxx_device_get_status + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + dev_flavor_t flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t statusType; + int status[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_xxx_device_get_status + (mach_port_t device, dev_flavor_t flavor, dev_status_t status, mach_msg_type_number_t *statusCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t statusType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + mach_msg_type_number_t statusCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + statusCnt = 1024; + + OutP->RetCode = ds_xxx_device_get_status(In0P->Head.msgh_request_port, In0P->flavor, OutP->status, &statusCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->statusType = statusType; + + OutP->statusType.msgtl_number = statusCnt; + OutP->Head.msgh_size = 44 + (4 * statusCnt); +} + +/* Routine xxx_device_set_filter */ +mig_internal void _Xxxx_device_set_filter + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t receive_portType; + mach_port_t receive_port; + mach_msg_type_t priorityType; + int priority; + mach_msg_type_long_t filterType; + filter_t filter[128]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_xxx_device_set_filter + (mach_port_t device, mach_port_t receive_port, int priority, filter_array_t filter, mach_msg_type_number_t filterCnt); + + unsigned int msgh_size; + + auto const mach_msg_type_t receive_portCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t priorityCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 52) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->receive_portType, &receive_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->priorityType, &priorityCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->filterType.msgtl_header.msgt_inline != TRUE) || + (In0P->filterType.msgtl_header.msgt_longform != TRUE) || + (In0P->filterType.msgtl_name != 1) || + (In0P->filterType.msgtl_size != 16)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 52 + ((2 * In0P->filterType.msgtl_number + 3) & ~3)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_xxx_device_set_filter(In0P->Head.msgh_request_port, In0P->receive_port, In0P->priority, In0P->filter, In0P->filterType.msgtl_number); +} + +/* Routine device_map */ +mig_internal void _Xdevice_map + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t protType; + vm_prot_t prot; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t unmapType; + int unmap; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t pagerType; + mach_port_t pager; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_map + (mach_port_t device, vm_prot_t prot, vm_offset_t offset, vm_size_t size, mach_port_t *pager, int unmap); + + auto const mach_msg_type_t protCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t unmapCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t pagerType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 56) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->protType, &protCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->unmapType, &unmapCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_map(In0P->Head.msgh_request_port, In0P->prot, In0P->offset, In0P->size, &OutP->pager, In0P->unmap); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 40; + + OutP->pagerType = pagerType; +} + +/* Routine device_set_status */ +mig_internal void _Xdevice_set_status + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + dev_flavor_t flavor; + mach_msg_type_t statusType; + int status[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_set_status + (mach_port_t device, dev_flavor_t flavor, dev_status_t status, mach_msg_type_number_t statusCnt); + + unsigned int msgh_size; + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 36) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->statusType.msgt_inline != TRUE) || + (In0P->statusType.msgt_longform != FALSE) || + (In0P->statusType.msgt_name != 2) || + (In0P->statusType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 36 + (4 * In0P->statusType.msgt_number)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_set_status(In0P->Head.msgh_request_port, In0P->flavor, In0P->status, In0P->statusType.msgt_number); +} + +/* Routine device_get_status */ +mig_internal void _Xdevice_get_status + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + dev_flavor_t flavor; + mach_msg_type_t statusCntType; + mach_msg_type_number_t statusCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t statusType; + int status[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_get_status + (mach_port_t device, dev_flavor_t flavor, dev_status_t status, mach_msg_type_number_t *statusCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t statusCntCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t statusType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_number_t statusCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->statusCntType, &statusCntCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + statusCnt = 1024; + if (In0P->statusCnt < statusCnt) + statusCnt = In0P->statusCnt; + + OutP->RetCode = ds_device_get_status(In0P->Head.msgh_request_port, In0P->flavor, OutP->status, &statusCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->statusType = statusType; + + OutP->statusType.msgt_number = statusCnt; + OutP->Head.msgh_size = 36 + (4 * statusCnt); +} + +/* Routine device_set_filter */ +mig_internal void _Xdevice_set_filter + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t receive_portType; + mach_port_t receive_port; + mach_msg_type_t priorityType; + int priority; + mach_msg_type_t filterType; + filter_t filter[128]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t ds_device_set_filter + (mach_port_t device, mach_port_t receive_port, int priority, filter_array_t filter, mach_msg_type_number_t filterCnt); + + unsigned int msgh_size; + + auto const mach_msg_type_t receive_portCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t priorityCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 44) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->receive_portType, &receive_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->priorityType, &priorityCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->filterType.msgt_inline != TRUE) || + (In0P->filterType.msgt_longform != FALSE) || + (In0P->filterType.msgt_name != 1) || + (In0P->filterType.msgt_size != 16)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 44 + ((2 * In0P->filterType.msgt_number + 3) & ~3)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = ds_device_set_filter(In0P->Head.msgh_request_port, In0P->receive_port, In0P->priority, In0P->filter, In0P->filterType.msgt_number); +} + +static mig_routine_t device_server_routines[] = { + _Xdevice_open, + _Xdevice_close, + _Xdevice_write, + _Xdevice_write_inband, + _Xdevice_read, + _Xdevice_read_inband, + _Xxxx_device_set_status, + _Xxxx_device_get_status, + _Xxxx_device_set_filter, + _Xdevice_map, + _Xdevice_set_status, + _Xdevice_get_status, + _Xdevice_set_filter, +}; + +mig_external boolean_t device_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + register mach_msg_header_t *InP = InHeadP; + register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; + + auto const mach_msg_type_t RetCodeType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + register mig_routine_t routine; + + OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); + OutP->Head.msgh_size = sizeof *OutP; + OutP->Head.msgh_remote_port = InP->msgh_reply_port; + OutP->Head.msgh_local_port = MACH_PORT_NULL; + OutP->Head.msgh_seqno = 0; + OutP->Head.msgh_id = InP->msgh_id + 100; + + OutP->RetCodeType = RetCodeType; + + if ((InP->msgh_id > 2812) || (InP->msgh_id < 2800) || + ((routine = device_server_routines[InP->msgh_id - 2800]) == 0)) { + OutP->RetCode = MIG_BAD_ID; + return FALSE; + } + (*routine) (InP, &OutP->Head); + return TRUE; +} + +mig_external mig_routine_t device_server_routine + (const mach_msg_header_t *InHeadP) +{ + register int msgh_id; + + msgh_id = InHeadP->msgh_id - 2800; + + if ((msgh_id > 12) || (msgh_id < 0)) + return 0; + + return device_server_routines[msgh_id]; +} + diff --git a/tmp/deviceUser.c b/tmp/deviceUser.c new file mode 100644 index 00000000..dcee3860 --- /dev/null +++ b/tmp/deviceUser.c @@ -0,0 +1,1893 @@ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#include "device.h" +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> +#include <mach/msg_type.h> +/* LINTLIBRARY */ + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_remote_port +#define msgh_reply_port msgh_local_port + +#include <mach/std_types.h> +#include <mach/mach_types.h> +#include <device/device_types.h> +#include <device/net_status.h> + +/* Routine device_open */ +mig_external kern_return_t device_open +( + mach_port_t master_port, + dev_mode_t mode, + dev_name_t name, + mach_port_t *device +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_long_t nameType; + dev_name_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t deviceType; + mach_port_t device; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t modeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t nameType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 12, + /* msgtl_size = */ 1024, + /* msgtl_number = */ 1, + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t deviceCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->modeType = modeType; + + InP->mode = mode; + + InP->nameType = nameType; + + (void) mig_strncpy(InP->name, name, 128); + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = master_port; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2800; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 172, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2900) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 40) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->deviceType, &deviceCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *device = OutP->device; + + return KERN_SUCCESS; +} + +/* Routine device_close */ +mig_external kern_return_t device_close +( + mach_port_t device +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = device; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2801; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2901) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine device_write */ +mig_external kern_return_t device_write +( + mach_port_t device, + dev_mode_t mode, + recnum_t recnum, + io_buf_ptr_t data, + mach_msg_type_number_t dataCnt, + int *bytes_written +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_t recnumType; + recnum_t recnum; + mach_msg_type_long_t dataType; + io_buf_ptr_t data; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t bytes_writtenType; + int bytes_written; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t modeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t recnumType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t dataType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 9, + /* msgtl_size = */ 8, + /* msgtl_number = */ 0, + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bytes_writtenCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->modeType = modeType; + + InP->mode = mode; + + InP->recnumType = recnumType; + + InP->recnum = recnum; + + InP->dataType = dataType; + + InP->data = data; + + InP->dataType.msgtl_number = dataCnt; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = device; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2802; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 56, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2902) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size != 40) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->bytes_writtenType, &bytes_writtenCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *bytes_written = OutP->bytes_written; + + return KERN_SUCCESS; +} + +/* Routine device_write_inband */ +mig_external kern_return_t device_write_inband +( + mach_port_t device, + dev_mode_t mode, + recnum_t recnum, + io_buf_ptr_inband_t data, + mach_msg_type_number_t dataCnt, + int *bytes_written +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_t recnumType; + recnum_t recnum; + mach_msg_type_t dataType; + char data[128]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t bytes_writtenType; + int bytes_written; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + unsigned int msgh_size; + + auto const mach_msg_type_t modeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t recnumType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t dataType = { + /* msgt_name = */ 8, + /* msgt_size = */ 8, + /* msgt_number = */ 128, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bytes_writtenCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->modeType = modeType; + + InP->mode = mode; + + InP->recnumType = recnumType; + + InP->recnum = recnum; + + InP->dataType = dataType; + + if (dataCnt > 128) { + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(InP->data, data, dataCnt); + } + + InP->dataType.msgt_number = dataCnt; + + msgh_size = 44 + ((dataCnt + 3) & ~3); + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = device; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2803; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2903) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size != 40) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->bytes_writtenType, &bytes_writtenCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *bytes_written = OutP->bytes_written; + + return KERN_SUCCESS; +} + +/* Routine device_read */ +mig_external kern_return_t device_read +( + mach_port_t device, + dev_mode_t mode, + recnum_t recnum, + int bytes_wanted, + io_buf_ptr_t *data, + mach_msg_type_number_t *dataCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_t recnumType; + recnum_t recnum; + mach_msg_type_t bytes_wantedType; + int bytes_wanted; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t dataType; + io_buf_ptr_t data; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t modeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t recnumType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bytes_wantedType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->modeType = modeType; + + InP->mode = mode; + + InP->recnumType = recnumType; + + InP->recnum = recnum; + + InP->bytes_wantedType = bytes_wantedType; + + InP->bytes_wanted = bytes_wanted; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = device; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2804; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2904) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 48) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->dataType.msgtl_header.msgt_inline != FALSE) || + (OutP->dataType.msgtl_header.msgt_longform != TRUE) || + (OutP->dataType.msgtl_name != 9) || + (OutP->dataType.msgtl_size != 8)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *data = OutP->data; + + *dataCnt = OutP->dataType.msgtl_number; + + return KERN_SUCCESS; +} + +/* Routine device_read_inband */ +mig_external kern_return_t device_read_inband +( + mach_port_t device, + dev_mode_t mode, + recnum_t recnum, + int bytes_wanted, + io_buf_ptr_inband_t data, + mach_msg_type_number_t *dataCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t modeType; + dev_mode_t mode; + mach_msg_type_t recnumType; + recnum_t recnum; + mach_msg_type_t bytes_wantedType; + int bytes_wanted; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t dataType; + char data[128]; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t modeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t recnumType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t bytes_wantedType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->modeType = modeType; + + InP->mode = mode; + + InP->recnumType = recnumType; + + InP->recnum = recnum; + + InP->bytes_wantedType = bytes_wantedType; + + InP->bytes_wanted = bytes_wanted; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = device; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2805; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2905) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size < 36) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->dataType.msgt_inline != TRUE) || + (OutP->dataType.msgt_longform != FALSE) || + (OutP->dataType.msgt_name != 8) || + (OutP->dataType.msgt_size != 8)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 36 + ((OutP->dataType.msgt_number + 3) & ~3)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->dataType.msgt_number > *dataCnt) { + memcpy(data, OutP->data, *dataCnt); + *dataCnt = OutP->dataType.msgt_number; + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(data, OutP->data, OutP->dataType.msgt_number); + } + + *dataCnt = OutP->dataType.msgt_number; + + return KERN_SUCCESS; +} + +/* Routine xxx_device_set_status */ +mig_external kern_return_t xxx_device_set_status +( + mach_port_t device, + dev_flavor_t flavor, + dev_status_t status, + mach_msg_type_number_t statusCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + dev_flavor_t flavor; + mach_msg_type_long_t statusType; + int status[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + unsigned int msgh_size; + + auto const mach_msg_type_t flavorType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t statusType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->flavorType = flavorType; + + InP->flavor = flavor; + + InP->statusType = statusType; + + if (statusCnt > 1024) { + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(InP->status, status, 4 * statusCnt); + } + + InP->statusType.msgtl_number = statusCnt; + + msgh_size = 44 + (4 * statusCnt); + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = device; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2806; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2906) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine xxx_device_get_status */ +mig_external kern_return_t xxx_device_get_status +( + mach_port_t device, + dev_flavor_t flavor, + dev_status_t status, + mach_msg_type_number_t *statusCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + dev_flavor_t flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t statusType; + int status[1024]; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t flavorType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->flavorType = flavorType; + + InP->flavor = flavor; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = device; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2807; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2907) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size < 44) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->statusType.msgtl_header.msgt_inline != TRUE) || + (OutP->statusType.msgtl_header.msgt_longform != TRUE) || + (OutP->statusType.msgtl_name != 2) || + (OutP->statusType.msgtl_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 44 + (4 * OutP->statusType.msgtl_number)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->statusType.msgtl_number > *statusCnt) { + memcpy(status, OutP->status, 4 * *statusCnt); + *statusCnt = OutP->statusType.msgtl_number; + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(status, OutP->status, 4 * OutP->statusType.msgtl_number); + } + + *statusCnt = OutP->statusType.msgtl_number; + + return KERN_SUCCESS; +} + +/* Routine xxx_device_set_filter */ +mig_external kern_return_t xxx_device_set_filter +( + mach_port_t device, + mach_port_t receive_port, + mach_msg_type_name_t receive_portPoly, + int priority, + filter_array_t filter, + mach_msg_type_number_t filterCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t receive_portType; + mach_port_t receive_port; + mach_msg_type_t priorityType; + int priority; + mach_msg_type_long_t filterType; + filter_t filter[128]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + boolean_t msgh_simple = TRUE; + unsigned int msgh_size; + + auto const mach_msg_type_t receive_portType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t priorityType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t filterType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 1, + /* msgtl_size = */ 16, + /* msgtl_number = */ 128, + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->receive_portType = receive_portType; + + InP->receive_port = receive_port; + + if (MACH_MSG_TYPE_PORT_ANY(receive_portPoly)) + msgh_simple = FALSE; + + InP->receive_portType.msgt_name = receive_portPoly; + + InP->priorityType = priorityType; + + InP->priority = priority; + + InP->filterType = filterType; + + if (filterCnt > 128) { + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(InP->filter, filter, 2 * filterCnt); + } + + InP->filterType.msgtl_number = filterCnt; + + msgh_size = 52 + ((2 * filterCnt + 3) & ~3); + InP->Head.msgh_bits = msgh_simple ? + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE) : + (MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE)); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = device; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2808; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2908) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine device_map */ +mig_external kern_return_t device_map +( + mach_port_t device, + vm_prot_t prot, + vm_offset_t offset, + vm_size_t size, + mach_port_t *pager, + int unmap +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t protType; + vm_prot_t prot; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t unmapType; + int unmap; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t pagerType; + mach_port_t pager; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t protType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t offsetType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t unmapType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t pagerCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->protType = protType; + + InP->prot = prot; + + InP->offsetType = offsetType; + + InP->offset = offset; + + InP->sizeType = sizeType; + + InP->size = size; + + InP->unmapType = unmapType; + + InP->unmap = unmap; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = device; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2809; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 56, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2909) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 40) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->pagerType, &pagerCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *pager = OutP->pager; + + return KERN_SUCCESS; +} + +/* Routine device_set_status */ +mig_external kern_return_t device_set_status +( + mach_port_t device, + dev_flavor_t flavor, + dev_status_t status, + mach_msg_type_number_t statusCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + dev_flavor_t flavor; + mach_msg_type_t statusType; + int status[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + unsigned int msgh_size; + + auto const mach_msg_type_t flavorType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t statusType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->flavorType = flavorType; + + InP->flavor = flavor; + + InP->statusType = statusType; + + if (statusCnt > 1024) { + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(InP->status, status, 4 * statusCnt); + } + + InP->statusType.msgt_number = statusCnt; + + msgh_size = 36 + (4 * statusCnt); + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = device; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2810; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2910) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine device_get_status */ +mig_external kern_return_t device_get_status +( + mach_port_t device, + dev_flavor_t flavor, + dev_status_t status, + mach_msg_type_number_t *statusCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + dev_flavor_t flavor; + mach_msg_type_t statusCntType; + mach_msg_type_number_t statusCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t statusType; + int status[1024]; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t flavorType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t statusCntType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->flavorType = flavorType; + + InP->flavor = flavor; + + InP->statusCntType = statusCntType; + + if (*statusCnt < 1024) + InP->statusCnt = *statusCnt; + else + InP->statusCnt = 1024; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = device; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2811; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2911) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size < 36) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->statusType.msgt_inline != TRUE) || + (OutP->statusType.msgt_longform != FALSE) || + (OutP->statusType.msgt_name != 2) || + (OutP->statusType.msgt_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 36 + (4 * OutP->statusType.msgt_number)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->statusType.msgt_number > *statusCnt) { + memcpy(status, OutP->status, 4 * *statusCnt); + *statusCnt = OutP->statusType.msgt_number; + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(status, OutP->status, 4 * OutP->statusType.msgt_number); + } + + *statusCnt = OutP->statusType.msgt_number; + + return KERN_SUCCESS; +} + +/* Routine device_set_filter */ +mig_external kern_return_t device_set_filter +( + mach_port_t device, + mach_port_t receive_port, + mach_msg_type_name_t receive_portPoly, + int priority, + filter_array_t filter, + mach_msg_type_number_t filterCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t receive_portType; + mach_port_t receive_port; + mach_msg_type_t priorityType; + int priority; + mach_msg_type_t filterType; + filter_t filter[128]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + boolean_t msgh_simple = TRUE; + unsigned int msgh_size; + + auto const mach_msg_type_t receive_portType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t priorityType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t filterType = { + /* msgt_name = */ 1, + /* msgt_size = */ 16, + /* msgt_number = */ 128, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->receive_portType = receive_portType; + + InP->receive_port = receive_port; + + if (MACH_MSG_TYPE_PORT_ANY(receive_portPoly)) + msgh_simple = FALSE; + + InP->receive_portType.msgt_name = receive_portPoly; + + InP->priorityType = priorityType; + + InP->priority = priority; + + InP->filterType = filterType; + + if (filterCnt > 128) { + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(InP->filter, filter, 2 * filterCnt); + } + + InP->filterType.msgt_number = filterCnt; + + msgh_size = 44 + ((2 * filterCnt + 3) & ~3); + InP->Head.msgh_bits = msgh_simple ? + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE) : + (MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE)); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = device; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2812; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2912) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} diff --git a/tmp/mach.h b/tmp/mach.h new file mode 100644 index 00000000..f970a64c --- /dev/null +++ b/tmp/mach.h @@ -0,0 +1,1263 @@ +#ifndef _mach_user_ +#define _mach_user_ + +/* Module mach */ + +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/message.h> + +#include <mach/std_types.h> +#include <mach/mach_types.h> + +/* Routine task_create */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t task_create +#if defined(LINTLIBRARY) + (target_task, inherit_memory, child_task) + mach_port_t target_task; + boolean_t inherit_memory; + mach_port_t *child_task; +{ return task_create(target_task, inherit_memory, child_task); } +#else +( + mach_port_t target_task, + boolean_t inherit_memory, + mach_port_t *child_task +); +#endif + +/* Routine task_terminate */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t task_terminate +#if defined(LINTLIBRARY) + (target_task) + mach_port_t target_task; +{ return task_terminate(target_task); } +#else +( + mach_port_t target_task +); +#endif + +/* Routine task_get_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t task_get_emulation_vector +#if defined(LINTLIBRARY) + (task, vector_start, emulation_vector, emulation_vectorCnt) + mach_port_t task; + int *vector_start; + emulation_vector_t *emulation_vector; + mach_msg_type_number_t *emulation_vectorCnt; +{ return task_get_emulation_vector(task, vector_start, emulation_vector, emulation_vectorCnt); } +#else +( + mach_port_t task, + int *vector_start, + emulation_vector_t *emulation_vector, + mach_msg_type_number_t *emulation_vectorCnt +); +#endif + +/* Routine task_set_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t task_set_emulation_vector +#if defined(LINTLIBRARY) + (task, vector_start, emulation_vector, emulation_vectorCnt) + mach_port_t task; + int vector_start; + emulation_vector_t emulation_vector; + mach_msg_type_number_t emulation_vectorCnt; +{ return task_set_emulation_vector(task, vector_start, emulation_vector, emulation_vectorCnt); } +#else +( + mach_port_t task, + int vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t emulation_vectorCnt +); +#endif + +/* Routine task_threads */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t task_threads +#if defined(LINTLIBRARY) + (target_task, thread_list, thread_listCnt) + mach_port_t target_task; + thread_array_t *thread_list; + mach_msg_type_number_t *thread_listCnt; +{ return task_threads(target_task, thread_list, thread_listCnt); } +#else +( + mach_port_t target_task, + thread_array_t *thread_list, + mach_msg_type_number_t *thread_listCnt +); +#endif + +/* Routine task_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t task_info +#if defined(LINTLIBRARY) + (target_task, flavor, task_info_out, task_info_outCnt) + mach_port_t target_task; + int flavor; + task_info_t task_info_out; + mach_msg_type_number_t *task_info_outCnt; +{ return task_info(target_task, flavor, task_info_out, task_info_outCnt); } +#else +( + mach_port_t target_task, + int flavor, + task_info_t task_info_out, + mach_msg_type_number_t *task_info_outCnt +); +#endif + +/* Routine thread_terminate */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t thread_terminate +#if defined(LINTLIBRARY) + (target_thread) + mach_port_t target_thread; +{ return thread_terminate(target_thread); } +#else +( + mach_port_t target_thread +); +#endif + +/* Routine thread_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t thread_get_state +#if defined(LINTLIBRARY) + (target_thread, flavor, old_state, old_stateCnt) + mach_port_t target_thread; + int flavor; + thread_state_t old_state; + mach_msg_type_number_t *old_stateCnt; +{ return thread_get_state(target_thread, flavor, old_state, old_stateCnt); } +#else +( + mach_port_t target_thread, + int flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); +#endif + +/* Routine thread_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t thread_set_state +#if defined(LINTLIBRARY) + (target_thread, flavor, new_state, new_stateCnt) + mach_port_t target_thread; + int flavor; + thread_state_t new_state; + mach_msg_type_number_t new_stateCnt; +{ return thread_set_state(target_thread, flavor, new_state, new_stateCnt); } +#else +( + mach_port_t target_thread, + int flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); +#endif + +/* Routine thread_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t thread_info +#if defined(LINTLIBRARY) + (target_thread, flavor, thread_info_out, thread_info_outCnt) + mach_port_t target_thread; + int flavor; + thread_info_t thread_info_out; + mach_msg_type_number_t *thread_info_outCnt; +{ return thread_info(target_thread, flavor, thread_info_out, thread_info_outCnt); } +#else +( + mach_port_t target_thread, + int flavor, + thread_info_t thread_info_out, + mach_msg_type_number_t *thread_info_outCnt +); +#endif + +/* Routine vm_allocate */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t vm_allocate +#if defined(LINTLIBRARY) + (target_task, address, size, anywhere) + mach_port_t target_task; + vm_address_t *address; + vm_size_t size; + boolean_t anywhere; +{ return vm_allocate(target_task, address, size, anywhere); } +#else +( + mach_port_t target_task, + vm_address_t *address, + vm_size_t size, + boolean_t anywhere +); +#endif + +/* Routine vm_deallocate */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t vm_deallocate +#if defined(LINTLIBRARY) + (target_task, address, size) + mach_port_t target_task; + vm_address_t address; + vm_size_t size; +{ return vm_deallocate(target_task, address, size); } +#else +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size +); +#endif + +/* Routine vm_protect */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t vm_protect +#if defined(LINTLIBRARY) + (target_task, address, size, set_maximum, new_protection) + mach_port_t target_task; + vm_address_t address; + vm_size_t size; + boolean_t set_maximum; + vm_prot_t new_protection; +{ return vm_protect(target_task, address, size, set_maximum, new_protection); } +#else +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size, + boolean_t set_maximum, + vm_prot_t new_protection +); +#endif + +/* Routine vm_inherit */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t vm_inherit +#if defined(LINTLIBRARY) + (target_task, address, size, new_inheritance) + mach_port_t target_task; + vm_address_t address; + vm_size_t size; + vm_inherit_t new_inheritance; +{ return vm_inherit(target_task, address, size, new_inheritance); } +#else +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size, + vm_inherit_t new_inheritance +); +#endif + +/* Routine vm_read */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t vm_read +#if defined(LINTLIBRARY) + (target_task, address, size, data, dataCnt) + mach_port_t target_task; + vm_address_t address; + vm_size_t size; + vm_offset_t *data; + mach_msg_type_number_t *dataCnt; +{ return vm_read(target_task, address, size, data, dataCnt); } +#else +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size, + vm_offset_t *data, + mach_msg_type_number_t *dataCnt +); +#endif + +/* Routine vm_write */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t vm_write +#if defined(LINTLIBRARY) + (target_task, address, data, dataCnt) + mach_port_t target_task; + vm_address_t address; + vm_offset_t data; + mach_msg_type_number_t dataCnt; +{ return vm_write(target_task, address, data, dataCnt); } +#else +( + mach_port_t target_task, + vm_address_t address, + vm_offset_t data, + mach_msg_type_number_t dataCnt +); +#endif + +/* Routine vm_copy */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t vm_copy +#if defined(LINTLIBRARY) + (target_task, source_address, size, dest_address) + mach_port_t target_task; + vm_address_t source_address; + vm_size_t size; + vm_address_t dest_address; +{ return vm_copy(target_task, source_address, size, dest_address); } +#else +( + mach_port_t target_task, + vm_address_t source_address, + vm_size_t size, + vm_address_t dest_address +); +#endif + +/* Routine vm_region */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t vm_region +#if defined(LINTLIBRARY) + (target_task, address, size, protection, max_protection, inheritance, is_shared, object_name, offset) + mach_port_t target_task; + vm_address_t *address; + vm_size_t *size; + vm_prot_t *protection; + vm_prot_t *max_protection; + vm_inherit_t *inheritance; + boolean_t *is_shared; + mach_port_t *object_name; + vm_offset_t *offset; +{ return vm_region(target_task, address, size, protection, max_protection, inheritance, is_shared, object_name, offset); } +#else +( + mach_port_t target_task, + vm_address_t *address, + vm_size_t *size, + vm_prot_t *protection, + vm_prot_t *max_protection, + vm_inherit_t *inheritance, + boolean_t *is_shared, + mach_port_t *object_name, + vm_offset_t *offset +); +#endif + +/* Routine vm_statistics */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t vm_statistics +#if defined(LINTLIBRARY) + (target_task, vm_stats) + mach_port_t target_task; + vm_statistics_data_t *vm_stats; +{ return vm_statistics(target_task, vm_stats); } +#else +( + mach_port_t target_task, + vm_statistics_data_t *vm_stats +); +#endif + +/* Routine mach_ports_register */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_ports_register +#if defined(LINTLIBRARY) + (target_task, init_port_set, init_port_setCnt) + mach_port_t target_task; + mach_port_array_t init_port_set; + mach_msg_type_number_t init_port_setCnt; +{ return mach_ports_register(target_task, init_port_set, init_port_setCnt); } +#else +( + mach_port_t target_task, + mach_port_array_t init_port_set, + mach_msg_type_number_t init_port_setCnt +); +#endif + +/* Routine mach_ports_lookup */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_ports_lookup +#if defined(LINTLIBRARY) + (target_task, init_port_set, init_port_setCnt) + mach_port_t target_task; + mach_port_array_t *init_port_set; + mach_msg_type_number_t *init_port_setCnt; +{ return mach_ports_lookup(target_task, init_port_set, init_port_setCnt); } +#else +( + mach_port_t target_task, + mach_port_array_t *init_port_set, + mach_msg_type_number_t *init_port_setCnt +); +#endif + +/* SimpleRoutine memory_object_data_provided */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t memory_object_data_provided +#if defined(LINTLIBRARY) + (memory_control, offset, data, dataCnt, lock_value) + mach_port_t memory_control; + vm_offset_t offset; + vm_offset_t data; + mach_msg_type_number_t dataCnt; + vm_prot_t lock_value; +{ return memory_object_data_provided(memory_control, offset, data, dataCnt, lock_value); } +#else +( + mach_port_t memory_control, + vm_offset_t offset, + vm_offset_t data, + mach_msg_type_number_t dataCnt, + vm_prot_t lock_value +); +#endif + +/* SimpleRoutine memory_object_data_unavailable */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t memory_object_data_unavailable +#if defined(LINTLIBRARY) + (memory_control, offset, size) + mach_port_t memory_control; + vm_offset_t offset; + vm_size_t size; +{ return memory_object_data_unavailable(memory_control, offset, size); } +#else +( + mach_port_t memory_control, + vm_offset_t offset, + vm_size_t size +); +#endif + +/* Routine memory_object_get_attributes */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t memory_object_get_attributes +#if defined(LINTLIBRARY) + (memory_control, object_ready, may_cache, copy_strategy) + mach_port_t memory_control; + boolean_t *object_ready; + boolean_t *may_cache; + memory_object_copy_strategy_t *copy_strategy; +{ return memory_object_get_attributes(memory_control, object_ready, may_cache, copy_strategy); } +#else +( + mach_port_t memory_control, + boolean_t *object_ready, + boolean_t *may_cache, + memory_object_copy_strategy_t *copy_strategy +); +#endif + +/* Routine vm_set_default_memory_manager */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t vm_set_default_memory_manager +#if defined(LINTLIBRARY) + (host_priv, default_manager) + mach_port_t host_priv; + mach_port_t *default_manager; +{ return vm_set_default_memory_manager(host_priv, default_manager); } +#else +( + mach_port_t host_priv, + mach_port_t *default_manager +); +#endif + +/* SimpleRoutine xxx_memory_object_lock_request */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t xxx_memory_object_lock_request +#if defined(LINTLIBRARY) + (memory_control, offset, size, should_clean, should_flush, lock_value, reply_to) + mach_port_t memory_control; + vm_offset_t offset; + vm_size_t size; + boolean_t should_clean; + boolean_t should_flush; + vm_prot_t lock_value; + mach_port_t reply_to; +{ return xxx_memory_object_lock_request(memory_control, offset, size, should_clean, should_flush, lock_value, reply_to); } +#else +( + mach_port_t memory_control, + vm_offset_t offset, + vm_size_t size, + boolean_t should_clean, + boolean_t should_flush, + vm_prot_t lock_value, + mach_port_t reply_to +); +#endif + +/* SimpleRoutine memory_object_lock_request */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t memory_object_lock_request +#if defined(LINTLIBRARY) + (memory_control, offset, size, should_return, should_flush, lock_value, reply_to) + mach_port_t memory_control; + vm_offset_t offset; + vm_size_t size; + memory_object_return_t should_return; + boolean_t should_flush; + vm_prot_t lock_value; + mach_port_t reply_to; +{ return memory_object_lock_request(memory_control, offset, size, should_return, should_flush, lock_value, reply_to); } +#else +( + mach_port_t memory_control, + vm_offset_t offset, + vm_size_t size, + memory_object_return_t should_return, + boolean_t should_flush, + vm_prot_t lock_value, + mach_port_t reply_to +); +#endif + +/* Routine xxx_task_get_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t xxx_task_get_emulation_vector +#if defined(LINTLIBRARY) + (task, vector_start, emulation_vector, emulation_vectorCnt) + mach_port_t task; + int *vector_start; + emulation_vector_t emulation_vector; + mach_msg_type_number_t *emulation_vectorCnt; +{ return xxx_task_get_emulation_vector(task, vector_start, emulation_vector, emulation_vectorCnt); } +#else +( + mach_port_t task, + int *vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t *emulation_vectorCnt +); +#endif + +/* Routine xxx_task_set_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t xxx_task_set_emulation_vector +#if defined(LINTLIBRARY) + (task, vector_start, emulation_vector, emulation_vectorCnt) + mach_port_t task; + int vector_start; + emulation_vector_t emulation_vector; + mach_msg_type_number_t emulation_vectorCnt; +{ return xxx_task_set_emulation_vector(task, vector_start, emulation_vector, emulation_vectorCnt); } +#else +( + mach_port_t task, + int vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t emulation_vectorCnt +); +#endif + +/* Routine xxx_host_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t xxx_host_info +#if defined(LINTLIBRARY) + (target_task, info) + mach_port_t target_task; + machine_info_data_t *info; +{ return xxx_host_info(target_task, info); } +#else +( + mach_port_t target_task, + machine_info_data_t *info +); +#endif + +/* Routine xxx_slot_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t xxx_slot_info +#if defined(LINTLIBRARY) + (target_task, slot, info) + mach_port_t target_task; + int slot; + machine_slot_data_t *info; +{ return xxx_slot_info(target_task, slot, info); } +#else +( + mach_port_t target_task, + int slot, + machine_slot_data_t *info +); +#endif + +/* Routine xxx_cpu_control */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t xxx_cpu_control +#if defined(LINTLIBRARY) + (target_task, cpu, running) + mach_port_t target_task; + int cpu; + boolean_t running; +{ return xxx_cpu_control(target_task, cpu, running); } +#else +( + mach_port_t target_task, + int cpu, + boolean_t running +); +#endif + +/* Routine task_suspend */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t task_suspend +#if defined(LINTLIBRARY) + (target_task) + mach_port_t target_task; +{ return task_suspend(target_task); } +#else +( + mach_port_t target_task +); +#endif + +/* Routine task_resume */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t task_resume +#if defined(LINTLIBRARY) + (target_task) + mach_port_t target_task; +{ return task_resume(target_task); } +#else +( + mach_port_t target_task +); +#endif + +/* Routine task_get_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t task_get_special_port +#if defined(LINTLIBRARY) + (task, which_port, special_port) + mach_port_t task; + int which_port; + mach_port_t *special_port; +{ return task_get_special_port(task, which_port, special_port); } +#else +( + mach_port_t task, + int which_port, + mach_port_t *special_port +); +#endif + +/* Routine task_set_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t task_set_special_port +#if defined(LINTLIBRARY) + (task, which_port, special_port) + mach_port_t task; + int which_port; + mach_port_t special_port; +{ return task_set_special_port(task, which_port, special_port); } +#else +( + mach_port_t task, + int which_port, + mach_port_t special_port +); +#endif + +/* Routine xxx_task_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t xxx_task_info +#if defined(LINTLIBRARY) + (target_task, flavor, task_info_out, task_info_outCnt) + mach_port_t target_task; + int flavor; + task_info_t task_info_out; + mach_msg_type_number_t *task_info_outCnt; +{ return xxx_task_info(target_task, flavor, task_info_out, task_info_outCnt); } +#else +( + mach_port_t target_task, + int flavor, + task_info_t task_info_out, + mach_msg_type_number_t *task_info_outCnt +); +#endif + +/* Routine thread_create */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t thread_create +#if defined(LINTLIBRARY) + (parent_task, child_thread) + mach_port_t parent_task; + mach_port_t *child_thread; +{ return thread_create(parent_task, child_thread); } +#else +( + mach_port_t parent_task, + mach_port_t *child_thread +); +#endif + +/* Routine thread_suspend */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t thread_suspend +#if defined(LINTLIBRARY) + (target_thread) + mach_port_t target_thread; +{ return thread_suspend(target_thread); } +#else +( + mach_port_t target_thread +); +#endif + +/* Routine thread_resume */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t thread_resume +#if defined(LINTLIBRARY) + (target_thread) + mach_port_t target_thread; +{ return thread_resume(target_thread); } +#else +( + mach_port_t target_thread +); +#endif + +/* Routine thread_abort */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t thread_abort +#if defined(LINTLIBRARY) + (target_thread) + mach_port_t target_thread; +{ return thread_abort(target_thread); } +#else +( + mach_port_t target_thread +); +#endif + +/* Routine xxx_thread_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t xxx_thread_get_state +#if defined(LINTLIBRARY) + (target_thread, flavor, old_state, old_stateCnt) + mach_port_t target_thread; + int flavor; + thread_state_t old_state; + mach_msg_type_number_t *old_stateCnt; +{ return xxx_thread_get_state(target_thread, flavor, old_state, old_stateCnt); } +#else +( + mach_port_t target_thread, + int flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); +#endif + +/* Routine xxx_thread_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t xxx_thread_set_state +#if defined(LINTLIBRARY) + (target_thread, flavor, new_state, new_stateCnt) + mach_port_t target_thread; + int flavor; + thread_state_t new_state; + mach_msg_type_number_t new_stateCnt; +{ return xxx_thread_set_state(target_thread, flavor, new_state, new_stateCnt); } +#else +( + mach_port_t target_thread, + int flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); +#endif + +/* Routine thread_get_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t thread_get_special_port +#if defined(LINTLIBRARY) + (thread, which_port, special_port) + mach_port_t thread; + int which_port; + mach_port_t *special_port; +{ return thread_get_special_port(thread, which_port, special_port); } +#else +( + mach_port_t thread, + int which_port, + mach_port_t *special_port +); +#endif + +/* Routine thread_set_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t thread_set_special_port +#if defined(LINTLIBRARY) + (thread, which_port, special_port) + mach_port_t thread; + int which_port; + mach_port_t special_port; +{ return thread_set_special_port(thread, which_port, special_port); } +#else +( + mach_port_t thread, + int which_port, + mach_port_t special_port +); +#endif + +/* Routine xxx_thread_info */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t xxx_thread_info +#if defined(LINTLIBRARY) + (target_thread, flavor, thread_info_out, thread_info_outCnt) + mach_port_t target_thread; + int flavor; + thread_info_t thread_info_out; + mach_msg_type_number_t *thread_info_outCnt; +{ return xxx_thread_info(target_thread, flavor, thread_info_out, thread_info_outCnt); } +#else +( + mach_port_t target_thread, + int flavor, + thread_info_t thread_info_out, + mach_msg_type_number_t *thread_info_outCnt +); +#endif + +/* Routine task_set_emulation */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t task_set_emulation +#if defined(LINTLIBRARY) + (target_port, routine_entry_pt, routine_number) + mach_port_t target_port; + vm_address_t routine_entry_pt; + int routine_number; +{ return task_set_emulation(target_port, routine_entry_pt, routine_number); } +#else +( + mach_port_t target_port, + vm_address_t routine_entry_pt, + int routine_number +); +#endif + +/* Routine task_ras_control */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t task_ras_control +#if defined(LINTLIBRARY) + (target_task, basepc, boundspc, flavor) + mach_port_t target_task; + vm_address_t basepc; + vm_address_t boundspc; + int flavor; +{ return task_ras_control(target_task, basepc, boundspc, flavor); } +#else +( + mach_port_t target_task, + vm_address_t basepc, + vm_address_t boundspc, + int flavor +); +#endif + +/* Routine vm_map */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t vm_map +#if defined(LINTLIBRARY) + (target_task, address, size, mask, anywhere, memory_object, offset, copy, cur_protection, max_protection, inheritance) + mach_port_t target_task; + vm_address_t *address; + vm_size_t size; + vm_address_t mask; + boolean_t anywhere; + mach_port_t memory_object; + vm_offset_t offset; + boolean_t copy; + vm_prot_t cur_protection; + vm_prot_t max_protection; + vm_inherit_t inheritance; +{ return vm_map(target_task, address, size, mask, anywhere, memory_object, offset, copy, cur_protection, max_protection, inheritance); } +#else +( + mach_port_t target_task, + vm_address_t *address, + vm_size_t size, + vm_address_t mask, + boolean_t anywhere, + mach_port_t memory_object, + vm_offset_t offset, + boolean_t copy, + vm_prot_t cur_protection, + vm_prot_t max_protection, + vm_inherit_t inheritance +); +#endif + +/* SimpleRoutine memory_object_data_error */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t memory_object_data_error +#if defined(LINTLIBRARY) + (memory_control, offset, size, error_value) + mach_port_t memory_control; + vm_offset_t offset; + vm_size_t size; + kern_return_t error_value; +{ return memory_object_data_error(memory_control, offset, size, error_value); } +#else +( + mach_port_t memory_control, + vm_offset_t offset, + vm_size_t size, + kern_return_t error_value +); +#endif + +/* SimpleRoutine memory_object_set_attributes */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t memory_object_set_attributes +#if defined(LINTLIBRARY) + (memory_control, object_ready, may_cache, copy_strategy) + mach_port_t memory_control; + boolean_t object_ready; + boolean_t may_cache; + memory_object_copy_strategy_t copy_strategy; +{ return memory_object_set_attributes(memory_control, object_ready, may_cache, copy_strategy); } +#else +( + mach_port_t memory_control, + boolean_t object_ready, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy +); +#endif + +/* SimpleRoutine memory_object_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t memory_object_destroy +#if defined(LINTLIBRARY) + (memory_control, reason) + mach_port_t memory_control; + kern_return_t reason; +{ return memory_object_destroy(memory_control, reason); } +#else +( + mach_port_t memory_control, + kern_return_t reason +); +#endif + +/* SimpleRoutine memory_object_data_supply */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t memory_object_data_supply +#if defined(LINTLIBRARY) + (memory_control, offset, data, dataCnt, dataDealloc, lock_value, precious, reply_to) + mach_port_t memory_control; + vm_offset_t offset; + vm_offset_t data; + mach_msg_type_number_t dataCnt; + boolean_t dataDealloc; + vm_prot_t lock_value; + boolean_t precious; + mach_port_t reply_to; +{ return memory_object_data_supply(memory_control, offset, data, dataCnt, dataDealloc, lock_value, precious, reply_to); } +#else +( + mach_port_t memory_control, + vm_offset_t offset, + vm_offset_t data, + mach_msg_type_number_t dataCnt, + boolean_t dataDealloc, + vm_prot_t lock_value, + boolean_t precious, + mach_port_t reply_to +); +#endif + +/* SimpleRoutine memory_object_ready */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t memory_object_ready +#if defined(LINTLIBRARY) + (memory_control, may_cache, copy_strategy) + mach_port_t memory_control; + boolean_t may_cache; + memory_object_copy_strategy_t copy_strategy; +{ return memory_object_ready(memory_control, may_cache, copy_strategy); } +#else +( + mach_port_t memory_control, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy +); +#endif + +/* SimpleRoutine memory_object_change_attributes */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t memory_object_change_attributes +#if defined(LINTLIBRARY) + (memory_control, may_cache, copy_strategy, reply_to) + mach_port_t memory_control; + boolean_t may_cache; + memory_object_copy_strategy_t copy_strategy; + mach_port_t reply_to; +{ return memory_object_change_attributes(memory_control, may_cache, copy_strategy, reply_to); } +#else +( + mach_port_t memory_control, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy, + mach_port_t reply_to +); +#endif + +/* Routine vm_machine_attribute */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t vm_machine_attribute +#if defined(LINTLIBRARY) + (target_task, address, size, attribute, value) + mach_port_t target_task; + vm_address_t address; + vm_size_t size; + vm_machine_attribute_t attribute; + vm_machine_attribute_val_t *value; +{ return vm_machine_attribute(target_task, address, size, attribute, value); } +#else +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size, + vm_machine_attribute_t attribute, + vm_machine_attribute_val_t *value +); +#endif + +#endif /* not defined(_mach_user_) */ diff --git a/tmp/machServer.c b/tmp/machServer.c new file mode 100644 index 00000000..676c72e4 --- /dev/null +++ b/tmp/machServer.c @@ -0,0 +1,4175 @@ +/* Module mach */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_local_port +#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) +#define msgh_reply_port msgh_remote_port +#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) + +#include <mach/std_types.h> +#include <mach/mach_types.h> + +/* Routine task_create */ +mig_internal void _Xtask_create + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t inherit_memoryType; + boolean_t inherit_memory; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t child_taskType; + mach_port_t child_task; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_create + (mach_port_t target_task, boolean_t inherit_memory, mach_port_t *child_task, mach_msg_type_name_t *child_taskPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t inherit_memoryCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t child_taskType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t child_taskPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->inherit_memoryType, &inherit_memoryCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_create(In0P->Head.msgh_request_port, In0P->inherit_memory, &OutP->child_task, &child_taskPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->child_taskType = child_taskType; + + if (MACH_MSG_TYPE_PORT_ANY(child_taskPoly)) + msgh_simple = FALSE; + + OutP->child_taskType.msgt_name = child_taskPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine task_terminate */ +mig_internal void _Xtask_terminate + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_terminate + (mach_port_t target_task); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_terminate(In0P->Head.msgh_request_port); +} + +/* Routine task_get_emulation_vector */ +mig_internal void _Xtask_get_emulation_vector + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t vector_startType; + int vector_start; + mach_msg_type_long_t emulation_vectorType; + emulation_vector_t emulation_vector; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_get_emulation_vector + (mach_port_t task, int *vector_start, emulation_vector_t *emulation_vector, mach_msg_type_number_t *emulation_vectorCnt); + + auto const mach_msg_type_t vector_startType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t emulation_vectorType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t emulation_vectorCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_get_emulation_vector(In0P->Head.msgh_request_port, &OutP->vector_start, &OutP->emulation_vector, &emulation_vectorCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 56; + + OutP->vector_startType = vector_startType; + + OutP->emulation_vectorType = emulation_vectorType; + + OutP->emulation_vectorType.msgtl_number = emulation_vectorCnt; +} + +/* Routine task_set_emulation_vector */ +mig_internal void _Xtask_set_emulation_vector + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t vector_startType; + int vector_start; + mach_msg_type_long_t emulation_vectorType; + emulation_vector_t emulation_vector; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_set_emulation_vector + (mach_port_t task, int vector_start, emulation_vector_t emulation_vector, mach_msg_type_number_t emulation_vectorCnt); + + auto const mach_msg_type_t vector_startCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->vector_startType, &vector_startCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->emulation_vectorType.msgtl_header.msgt_inline != FALSE) || + (In0P->emulation_vectorType.msgtl_header.msgt_longform != TRUE) || + (In0P->emulation_vectorType.msgtl_name != 2) || + (In0P->emulation_vectorType.msgtl_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_set_emulation_vector(In0P->Head.msgh_request_port, In0P->vector_start, In0P->emulation_vector, In0P->emulation_vectorType.msgtl_number); +} + +/* Routine task_threads */ +mig_internal void _Xtask_threads + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t thread_listType; + thread_array_t thread_list; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_threads + (mach_port_t target_task, thread_array_t *thread_list, mach_msg_type_number_t *thread_listCnt); + + auto const mach_msg_type_long_t thread_listType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 19, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t thread_listCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_threads(In0P->Head.msgh_request_port, &OutP->thread_list, &thread_listCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->thread_listType = thread_listType; + + OutP->thread_listType.msgtl_number = thread_listCnt; +} + +/* Routine task_info */ +mig_internal void _Xtask_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t task_info_outCntType; + mach_msg_type_number_t task_info_outCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t task_info_outType; + natural_t task_info_out[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_info + (mach_port_t target_task, int flavor, task_info_t task_info_out, mach_msg_type_number_t *task_info_outCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t task_info_outCntCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t task_info_outType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_number_t task_info_outCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->task_info_outCntType, &task_info_outCntCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + task_info_outCnt = 1024; + if (In0P->task_info_outCnt < task_info_outCnt) + task_info_outCnt = In0P->task_info_outCnt; + + OutP->RetCode = S_task_info(In0P->Head.msgh_request_port, In0P->flavor, OutP->task_info_out, &task_info_outCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->task_info_outType = task_info_outType; + + OutP->task_info_outType.msgt_number = task_info_outCnt; + OutP->Head.msgh_size = 36 + (4 * task_info_outCnt); +} + +/* Routine thread_terminate */ +mig_internal void _Xthread_terminate + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_terminate + (mach_port_t target_thread); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_terminate(In0P->Head.msgh_request_port); +} + +/* Routine thread_get_state */ +mig_internal void _Xthread_get_state + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t old_stateCntType; + mach_msg_type_number_t old_stateCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t old_stateType; + natural_t old_state[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_get_state + (mach_port_t target_thread, int flavor, thread_state_t old_state, mach_msg_type_number_t *old_stateCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t old_stateCntCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t old_stateType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_number_t old_stateCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->old_stateCntType, &old_stateCntCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + old_stateCnt = 1024; + if (In0P->old_stateCnt < old_stateCnt) + old_stateCnt = In0P->old_stateCnt; + + OutP->RetCode = S_thread_get_state(In0P->Head.msgh_request_port, In0P->flavor, OutP->old_state, &old_stateCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->old_stateType = old_stateType; + + OutP->old_stateType.msgt_number = old_stateCnt; + OutP->Head.msgh_size = 36 + (4 * old_stateCnt); +} + +/* Routine thread_set_state */ +mig_internal void _Xthread_set_state + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t new_stateType; + natural_t new_state[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_set_state + (mach_port_t target_thread, int flavor, thread_state_t new_state, mach_msg_type_number_t new_stateCnt); + + unsigned int msgh_size; + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 36) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->new_stateType.msgt_inline != TRUE) || + (In0P->new_stateType.msgt_longform != FALSE) || + (In0P->new_stateType.msgt_name != 2) || + (In0P->new_stateType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 36 + (4 * In0P->new_stateType.msgt_number)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_set_state(In0P->Head.msgh_request_port, In0P->flavor, In0P->new_state, In0P->new_stateType.msgt_number); +} + +/* Routine thread_info */ +mig_internal void _Xthread_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t thread_info_outCntType; + mach_msg_type_number_t thread_info_outCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t thread_info_outType; + natural_t thread_info_out[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_info + (mach_port_t target_thread, int flavor, thread_info_t thread_info_out, mach_msg_type_number_t *thread_info_outCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t thread_info_outCntCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t thread_info_outType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_number_t thread_info_outCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->thread_info_outCntType, &thread_info_outCntCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + thread_info_outCnt = 1024; + if (In0P->thread_info_outCnt < thread_info_outCnt) + thread_info_outCnt = In0P->thread_info_outCnt; + + OutP->RetCode = S_thread_info(In0P->Head.msgh_request_port, In0P->flavor, OutP->thread_info_out, &thread_info_outCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->thread_info_outType = thread_info_outType; + + OutP->thread_info_outType.msgt_number = thread_info_outCnt; + OutP->Head.msgh_size = 36 + (4 * thread_info_outCnt); +} + +/* Routine vm_allocate */ +mig_internal void _Xvm_allocate + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t anywhereType; + boolean_t anywhere; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t addressType; + vm_address_t address; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_allocate + (mach_port_t target_task, vm_address_t *address, vm_size_t size, boolean_t anywhere); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t anywhereCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->anywhereType, &anywhereCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_allocate(In0P->Head.msgh_request_port, &In0P->address, In0P->size, In0P->anywhere); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->addressType = addressType; + + OutP->address = In0P->address; +} + +/* Routine vm_deallocate */ +mig_internal void _Xvm_deallocate + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_deallocate + (mach_port_t target_task, vm_address_t address, vm_size_t size); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_deallocate(In0P->Head.msgh_request_port, In0P->address, In0P->size); +} + +/* Routine vm_protect */ +mig_internal void _Xvm_protect + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t set_maximumType; + boolean_t set_maximum; + mach_msg_type_t new_protectionType; + vm_prot_t new_protection; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_protect + (mach_port_t target_task, vm_address_t address, vm_size_t size, boolean_t set_maximum, vm_prot_t new_protection); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t set_maximumCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t new_protectionCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 56) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->set_maximumType, &set_maximumCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->new_protectionType, &new_protectionCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_protect(In0P->Head.msgh_request_port, In0P->address, In0P->size, In0P->set_maximum, In0P->new_protection); +} + +/* Routine vm_inherit */ +mig_internal void _Xvm_inherit + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t new_inheritanceType; + vm_inherit_t new_inheritance; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_inherit + (mach_port_t target_task, vm_address_t address, vm_size_t size, vm_inherit_t new_inheritance); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t new_inheritanceCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->new_inheritanceType, &new_inheritanceCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_inherit(In0P->Head.msgh_request_port, In0P->address, In0P->size, In0P->new_inheritance); +} + +/* Routine vm_read */ +mig_internal void _Xvm_read + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t dataType; + vm_offset_t data; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_read + (mach_port_t target_task, vm_address_t address, vm_size_t size, vm_offset_t *data, mach_msg_type_number_t *dataCnt); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t dataType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 9, + /* msgtl_size = */ 8, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t dataCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_read(In0P->Head.msgh_request_port, In0P->address, In0P->size, &OutP->data, &dataCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->dataType = dataType; + + OutP->dataType.msgtl_number = dataCnt; +} + +/* Routine vm_write */ +mig_internal void _Xvm_write + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_long_t dataType; + vm_offset_t data; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_write + (mach_port_t target_task, vm_address_t address, vm_offset_t data, mach_msg_type_number_t dataCnt); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->dataType.msgtl_header.msgt_inline != FALSE) || + (In0P->dataType.msgtl_header.msgt_longform != TRUE) || + (In0P->dataType.msgtl_name != 9) || + (In0P->dataType.msgtl_size != 8)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_write(In0P->Head.msgh_request_port, In0P->address, In0P->data, In0P->dataType.msgtl_number); +} + +/* Routine vm_copy */ +mig_internal void _Xvm_copy + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t source_addressType; + vm_address_t source_address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t dest_addressType; + vm_address_t dest_address; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_copy + (mach_port_t target_task, vm_address_t source_address, vm_size_t size, vm_address_t dest_address); + + auto const mach_msg_type_t source_addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t dest_addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->source_addressType, &source_addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->dest_addressType, &dest_addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_copy(In0P->Head.msgh_request_port, In0P->source_address, In0P->size, In0P->dest_address); +} + +/* Routine vm_region */ +mig_internal void _Xvm_region + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t protectionType; + vm_prot_t protection; + mach_msg_type_t max_protectionType; + vm_prot_t max_protection; + mach_msg_type_t inheritanceType; + vm_inherit_t inheritance; + mach_msg_type_t is_sharedType; + boolean_t is_shared; + mach_msg_type_t object_nameType; + mach_port_t object_name; + mach_msg_type_t offsetType; + vm_offset_t offset; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_region + (mach_port_t target_task, vm_address_t *address, vm_size_t *size, vm_prot_t *protection, vm_prot_t *max_protection, vm_inherit_t *inheritance, boolean_t *is_shared, mach_port_t *object_name, vm_offset_t *offset); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t protectionType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t max_protectionType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t inheritanceType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t is_sharedType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t object_nameType = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t offsetType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_region(In0P->Head.msgh_request_port, &In0P->address, &OutP->size, &OutP->protection, &OutP->max_protection, &OutP->inheritance, &OutP->is_shared, &OutP->object_name, &OutP->offset); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 96; + + OutP->addressType = addressType; + + OutP->address = In0P->address; + + OutP->sizeType = sizeType; + + OutP->protectionType = protectionType; + + OutP->max_protectionType = max_protectionType; + + OutP->inheritanceType = inheritanceType; + + OutP->is_sharedType = is_sharedType; + + OutP->object_nameType = object_nameType; + + OutP->offsetType = offsetType; +} + +/* Routine vm_statistics */ +mig_internal void _Xvm_statistics + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t vm_statsType; + vm_statistics_data_t vm_stats; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_statistics + (mach_port_t target_task, vm_statistics_data_t *vm_stats); + + auto const mach_msg_type_t vm_statsType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 13, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_statistics(In0P->Head.msgh_request_port, &OutP->vm_stats); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 88; + + OutP->vm_statsType = vm_statsType; +} + +/* Routine mach_ports_register */ +mig_internal void _Xmach_ports_register + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_long_t init_port_setType; + mach_port_array_t init_port_set; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_ports_register + (mach_port_t target_task, mach_port_array_t init_port_set, mach_msg_type_number_t init_port_setCnt); + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->init_port_setType.msgtl_header.msgt_inline != FALSE) || + (In0P->init_port_setType.msgtl_header.msgt_longform != TRUE) || + (In0P->init_port_setType.msgtl_name != 17) || + (In0P->init_port_setType.msgtl_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_ports_register(In0P->Head.msgh_request_port, In0P->init_port_set, In0P->init_port_setType.msgtl_number); +} + +/* Routine mach_ports_lookup */ +mig_internal void _Xmach_ports_lookup + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t init_port_setType; + mach_port_array_t init_port_set; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_mach_ports_lookup + (mach_port_t target_task, mach_port_array_t *init_port_set, mach_msg_type_number_t *init_port_setCnt); + + auto const mach_msg_type_long_t init_port_setType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 19, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t init_port_setCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_mach_ports_lookup(In0P->Head.msgh_request_port, &OutP->init_port_set, &init_port_setCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->init_port_setType = init_port_setType; + + OutP->init_port_setType.msgtl_number = init_port_setCnt; +} + +/* SimpleRoutine memory_object_data_provided */ +mig_internal void _Xmemory_object_data_provided + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_long_t dataType; + vm_offset_t data; + mach_msg_type_t lock_valueType; + vm_prot_t lock_value; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_data_provided + (mach_port_t memory_control, vm_offset_t offset, vm_offset_t data, mach_msg_type_number_t dataCnt, vm_prot_t lock_value); + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t lock_valueCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 56) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->dataType.msgtl_header.msgt_inline != FALSE) || + (In0P->dataType.msgtl_header.msgt_longform != TRUE) || + (In0P->dataType.msgtl_name != 9) || + (In0P->dataType.msgtl_size != 8)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->lock_valueType, &lock_valueCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_data_provided(In0P->Head.msgh_request_port, In0P->offset, In0P->data, In0P->dataType.msgtl_number, In0P->lock_value); +} + +/* SimpleRoutine memory_object_data_unavailable */ +mig_internal void _Xmemory_object_data_unavailable + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_data_unavailable + (mach_port_t memory_control, vm_offset_t offset, vm_size_t size); + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_data_unavailable(In0P->Head.msgh_request_port, In0P->offset, In0P->size); +} + +/* Routine memory_object_get_attributes */ +mig_internal void _Xmemory_object_get_attributes + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t object_readyType; + boolean_t object_ready; + mach_msg_type_t may_cacheType; + boolean_t may_cache; + mach_msg_type_t copy_strategyType; + memory_object_copy_strategy_t copy_strategy; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_get_attributes + (mach_port_t memory_control, boolean_t *object_ready, boolean_t *may_cache, memory_object_copy_strategy_t *copy_strategy); + + auto const mach_msg_type_t object_readyType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t may_cacheType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copy_strategyType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_get_attributes(In0P->Head.msgh_request_port, &OutP->object_ready, &OutP->may_cache, &OutP->copy_strategy); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 56; + + OutP->object_readyType = object_readyType; + + OutP->may_cacheType = may_cacheType; + + OutP->copy_strategyType = copy_strategyType; +} + +/* Routine vm_set_default_memory_manager */ +mig_internal void _Xvm_set_default_memory_manager + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t default_managerType; + mach_port_t default_manager; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t default_managerType; + mach_port_t default_manager; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_set_default_memory_manager + (mach_port_t host_priv, mach_port_t *default_manager); + + auto const mach_msg_type_t default_managerCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t default_managerType = { + /* msgt_name = */ 20, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->default_managerType, &default_managerCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_set_default_memory_manager(In0P->Head.msgh_request_port, &In0P->default_manager); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 40; + + OutP->default_managerType = default_managerType; + + OutP->default_manager = In0P->default_manager; +} + +/* SimpleRoutine xxx_memory_object_lock_request */ +mig_internal void _Xxxx_memory_object_lock_request + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t should_cleanType; + boolean_t should_clean; + mach_msg_type_t should_flushType; + boolean_t should_flush; + mach_msg_type_t lock_valueType; + vm_prot_t lock_value; + mach_msg_type_t reply_toType; + mach_port_t reply_to; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_memory_object_lock_request + (mach_port_t memory_control, vm_offset_t offset, vm_size_t size, boolean_t should_clean, boolean_t should_flush, vm_prot_t lock_value, mach_port_t reply_to, mach_msg_type_name_t reply_toPoly); + +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t should_cleanCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t should_flushCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t lock_valueCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + if ((In0P->Head.msgh_size != 72)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->should_cleanType, &should_cleanCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->should_flushType, &should_flushCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->lock_valueType, &lock_valueCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->reply_toType.msgt_inline != TRUE) || + (In0P->reply_toType.msgt_longform != FALSE) || + (MACH_MSG_TYPE_PORT_ANY(In0P->reply_toType.msgt_name) && msgh_simple) || + (In0P->reply_toType.msgt_number != 1) || + (In0P->reply_toType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_xxx_memory_object_lock_request(In0P->Head.msgh_request_port, In0P->offset, In0P->size, In0P->should_clean, In0P->should_flush, In0P->lock_value, In0P->reply_to, In0P->reply_toType.msgt_name); +} + +/* SimpleRoutine memory_object_lock_request */ +mig_internal void _Xmemory_object_lock_request + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t should_returnType; + memory_object_return_t should_return; + mach_msg_type_t should_flushType; + boolean_t should_flush; + mach_msg_type_t lock_valueType; + vm_prot_t lock_value; + mach_msg_type_t reply_toType; + mach_port_t reply_to; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_lock_request + (mach_port_t memory_control, vm_offset_t offset, vm_size_t size, memory_object_return_t should_return, boolean_t should_flush, vm_prot_t lock_value, mach_port_t reply_to, mach_msg_type_name_t reply_toPoly); + +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t should_returnCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t should_flushCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t lock_valueCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + if ((In0P->Head.msgh_size != 72)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->should_returnType, &should_returnCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->should_flushType, &should_flushCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->lock_valueType, &lock_valueCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->reply_toType.msgt_inline != TRUE) || + (In0P->reply_toType.msgt_longform != FALSE) || + (MACH_MSG_TYPE_PORT_ANY(In0P->reply_toType.msgt_name) && msgh_simple) || + (In0P->reply_toType.msgt_number != 1) || + (In0P->reply_toType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_lock_request(In0P->Head.msgh_request_port, In0P->offset, In0P->size, In0P->should_return, In0P->should_flush, In0P->lock_value, In0P->reply_to, In0P->reply_toType.msgt_name); +} + +/* Routine xxx_task_get_emulation_vector */ +mig_internal void _Xxxx_task_get_emulation_vector + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t vector_startType; + int vector_start; + mach_msg_type_long_t emulation_vectorType; + vm_offset_t emulation_vector[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_task_get_emulation_vector + (mach_port_t task, int *vector_start, emulation_vector_t emulation_vector, mach_msg_type_number_t *emulation_vectorCnt); + + auto const mach_msg_type_t vector_startType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t emulation_vectorType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + mach_msg_type_number_t emulation_vectorCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + emulation_vectorCnt = 1024; + + OutP->RetCode = S_xxx_task_get_emulation_vector(In0P->Head.msgh_request_port, &OutP->vector_start, OutP->emulation_vector, &emulation_vectorCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->vector_startType = vector_startType; + + OutP->emulation_vectorType = emulation_vectorType; + + OutP->emulation_vectorType.msgtl_number = emulation_vectorCnt; + OutP->Head.msgh_size = 52 + (4 * emulation_vectorCnt); +} + +/* Routine xxx_task_set_emulation_vector */ +mig_internal void _Xxxx_task_set_emulation_vector + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t vector_startType; + int vector_start; + mach_msg_type_long_t emulation_vectorType; + vm_offset_t emulation_vector[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_task_set_emulation_vector + (mach_port_t task, int vector_start, emulation_vector_t emulation_vector, mach_msg_type_number_t emulation_vectorCnt); + + unsigned int msgh_size; + + auto const mach_msg_type_t vector_startCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 44) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->vector_startType, &vector_startCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->emulation_vectorType.msgtl_header.msgt_inline != TRUE) || + (In0P->emulation_vectorType.msgtl_header.msgt_longform != TRUE) || + (In0P->emulation_vectorType.msgtl_name != 2) || + (In0P->emulation_vectorType.msgtl_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 44 + (4 * In0P->emulation_vectorType.msgtl_number)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_xxx_task_set_emulation_vector(In0P->Head.msgh_request_port, In0P->vector_start, In0P->emulation_vector, In0P->emulation_vectorType.msgtl_number); +} + +/* Routine xxx_host_info */ +mig_internal void _Xxxx_host_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t infoType; + machine_info_data_t info; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_host_info + (mach_port_t target_task, machine_info_data_t *info); + + auto const mach_msg_type_t infoType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 5, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_xxx_host_info(In0P->Head.msgh_request_port, &OutP->info); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 56; + + OutP->infoType = infoType; +} + +/* Routine xxx_slot_info */ +mig_internal void _Xxxx_slot_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t slotType; + int slot; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t infoType; + machine_slot_data_t info; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_slot_info + (mach_port_t target_task, int slot, machine_slot_data_t *info); + + auto const mach_msg_type_t slotCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t infoType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 8, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->slotType, &slotCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_xxx_slot_info(In0P->Head.msgh_request_port, In0P->slot, &OutP->info); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 68; + + OutP->infoType = infoType; +} + +/* Routine xxx_cpu_control */ +mig_internal void _Xxxx_cpu_control + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t cpuType; + int cpu; + mach_msg_type_t runningType; + boolean_t running; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_cpu_control + (mach_port_t target_task, int cpu, boolean_t running); + + auto const mach_msg_type_t cpuCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t runningCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->cpuType, &cpuCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->runningType, &runningCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_xxx_cpu_control(In0P->Head.msgh_request_port, In0P->cpu, In0P->running); +} + +/* Routine task_suspend */ +mig_internal void _Xtask_suspend + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_suspend + (mach_port_t target_task); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_suspend(In0P->Head.msgh_request_port); +} + +/* Routine task_resume */ +mig_internal void _Xtask_resume + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_resume + (mach_port_t target_task); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_resume(In0P->Head.msgh_request_port); +} + +/* Routine task_get_special_port */ +mig_internal void _Xtask_get_special_port + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t which_portType; + int which_port; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t special_portType; + mach_port_t special_port; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_get_special_port + (mach_port_t task, int which_port, mach_port_t *special_port); + + auto const mach_msg_type_t which_portCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t special_portType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->which_portType, &which_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_get_special_port(In0P->Head.msgh_request_port, In0P->which_port, &OutP->special_port); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 40; + + OutP->special_portType = special_portType; +} + +/* Routine task_set_special_port */ +mig_internal void _Xtask_set_special_port + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t which_portType; + int which_port; + mach_msg_type_t special_portType; + mach_port_t special_port; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_set_special_port + (mach_port_t task, int which_port, mach_port_t special_port); + + auto const mach_msg_type_t which_portCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t special_portCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->which_portType, &which_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->special_portType, &special_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_set_special_port(In0P->Head.msgh_request_port, In0P->which_port, In0P->special_port); +} + +/* Routine xxx_task_info */ +mig_internal void _Xxxx_task_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t task_info_outType; + natural_t task_info_out[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_task_info + (mach_port_t target_task, int flavor, task_info_t task_info_out, mach_msg_type_number_t *task_info_outCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t task_info_outType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + mach_msg_type_number_t task_info_outCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + task_info_outCnt = 1024; + + OutP->RetCode = S_xxx_task_info(In0P->Head.msgh_request_port, In0P->flavor, OutP->task_info_out, &task_info_outCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->task_info_outType = task_info_outType; + + OutP->task_info_outType.msgtl_number = task_info_outCnt; + OutP->Head.msgh_size = 44 + (4 * task_info_outCnt); +} + +/* Routine thread_create */ +mig_internal void _Xthread_create + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t child_threadType; + mach_port_t child_thread; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_create + (mach_port_t parent_task, mach_port_t *child_thread, mach_msg_type_name_t *child_threadPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t child_threadType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t child_threadPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_create(In0P->Head.msgh_request_port, &OutP->child_thread, &child_threadPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->child_threadType = child_threadType; + + if (MACH_MSG_TYPE_PORT_ANY(child_threadPoly)) + msgh_simple = FALSE; + + OutP->child_threadType.msgt_name = child_threadPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine thread_suspend */ +mig_internal void _Xthread_suspend + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_suspend + (mach_port_t target_thread); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_suspend(In0P->Head.msgh_request_port); +} + +/* Routine thread_resume */ +mig_internal void _Xthread_resume + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_resume + (mach_port_t target_thread); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_resume(In0P->Head.msgh_request_port); +} + +/* Routine thread_abort */ +mig_internal void _Xthread_abort + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_abort + (mach_port_t target_thread); + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_abort(In0P->Head.msgh_request_port); +} + +/* Routine xxx_thread_get_state */ +mig_internal void _Xxxx_thread_get_state + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t old_stateType; + natural_t old_state[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_thread_get_state + (mach_port_t target_thread, int flavor, thread_state_t old_state, mach_msg_type_number_t *old_stateCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t old_stateType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + mach_msg_type_number_t old_stateCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + old_stateCnt = 1024; + + OutP->RetCode = S_xxx_thread_get_state(In0P->Head.msgh_request_port, In0P->flavor, OutP->old_state, &old_stateCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->old_stateType = old_stateType; + + OutP->old_stateType.msgtl_number = old_stateCnt; + OutP->Head.msgh_size = 44 + (4 * old_stateCnt); +} + +/* Routine xxx_thread_set_state */ +mig_internal void _Xxxx_thread_set_state + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_long_t new_stateType; + natural_t new_state[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_thread_set_state + (mach_port_t target_thread, int flavor, thread_state_t new_state, mach_msg_type_number_t new_stateCnt); + + unsigned int msgh_size; + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_size = In0P->Head.msgh_size; + if ((msgh_size < 44) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->new_stateType.msgtl_header.msgt_inline != TRUE) || + (In0P->new_stateType.msgtl_header.msgt_longform != TRUE) || + (In0P->new_stateType.msgtl_name != 2) || + (In0P->new_stateType.msgtl_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 44 + (4 * In0P->new_stateType.msgtl_number)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_xxx_thread_set_state(In0P->Head.msgh_request_port, In0P->flavor, In0P->new_state, In0P->new_stateType.msgtl_number); +} + +/* Routine thread_get_special_port */ +mig_internal void _Xthread_get_special_port + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t which_portType; + int which_port; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t special_portType; + mach_port_t special_port; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_get_special_port + (mach_port_t thread, int which_port, mach_port_t *special_port); + + auto const mach_msg_type_t which_portCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t special_portType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->which_portType, &which_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_get_special_port(In0P->Head.msgh_request_port, In0P->which_port, &OutP->special_port); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 40; + + OutP->special_portType = special_portType; +} + +/* Routine thread_set_special_port */ +mig_internal void _Xthread_set_special_port + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t which_portType; + int which_port; + mach_msg_type_t special_portType; + mach_port_t special_port; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_thread_set_special_port + (mach_port_t thread, int which_port, mach_port_t special_port); + + auto const mach_msg_type_t which_portCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t special_portCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->which_portType, &which_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->special_portType, &special_portCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_thread_set_special_port(In0P->Head.msgh_request_port, In0P->which_port, In0P->special_port); +} + +/* Routine xxx_thread_info */ +mig_internal void _Xxxx_thread_info + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t thread_info_outType; + natural_t thread_info_out[1024]; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_xxx_thread_info + (mach_port_t target_thread, int flavor, thread_info_t thread_info_out, mach_msg_type_number_t *thread_info_outCnt); + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t thread_info_outType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + mach_msg_type_number_t thread_info_outCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + thread_info_outCnt = 1024; + + OutP->RetCode = S_xxx_thread_info(In0P->Head.msgh_request_port, In0P->flavor, OutP->thread_info_out, &thread_info_outCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->thread_info_outType = thread_info_outType; + + OutP->thread_info_outType.msgtl_number = thread_info_outCnt; + OutP->Head.msgh_size = 44 + (4 * thread_info_outCnt); +} + +/* Routine task_set_emulation */ +mig_internal void _Xtask_set_emulation + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t routine_entry_ptType; + vm_address_t routine_entry_pt; + mach_msg_type_t routine_numberType; + int routine_number; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_set_emulation + (mach_port_t target_port, vm_address_t routine_entry_pt, int routine_number); + + auto const mach_msg_type_t routine_entry_ptCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t routine_numberCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->routine_entry_ptType, &routine_entry_ptCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->routine_numberType, &routine_numberCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_set_emulation(In0P->Head.msgh_request_port, In0P->routine_entry_pt, In0P->routine_number); +} + +/* Routine task_ras_control */ +mig_internal void _Xtask_ras_control + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t basepcType; + vm_address_t basepc; + mach_msg_type_t boundspcType; + vm_address_t boundspc; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_task_ras_control + (mach_port_t target_task, vm_address_t basepc, vm_address_t boundspc, int flavor); + + auto const mach_msg_type_t basepcCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t boundspcCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t flavorCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->basepcType, &basepcCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->boundspcType, &boundspcCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_task_ras_control(In0P->Head.msgh_request_port, In0P->basepc, In0P->boundspc, In0P->flavor); +} + +/* Routine vm_map */ +mig_internal void _Xvm_map + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t maskType; + vm_address_t mask; + mach_msg_type_t anywhereType; + boolean_t anywhere; + mach_msg_type_t memory_objectType; + mach_port_t memory_object; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t copyType; + boolean_t copy; + mach_msg_type_t cur_protectionType; + vm_prot_t cur_protection; + mach_msg_type_t max_protectionType; + vm_prot_t max_protection; + mach_msg_type_t inheritanceType; + vm_inherit_t inheritance; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t addressType; + vm_address_t address; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_map + (mach_port_t target_task, vm_address_t *address, vm_size_t size, vm_address_t mask, boolean_t anywhere, mach_port_t memory_object, vm_offset_t offset, boolean_t copy, vm_prot_t cur_protection, vm_prot_t max_protection, vm_inherit_t inheritance); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t maskCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t anywhereCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t memory_objectCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copyCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t cur_protectionCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t max_protectionCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t inheritanceCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 104) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->maskType, &maskCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->anywhereType, &anywhereCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->memory_objectType, &memory_objectCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->copyType, ©Check)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->cur_protectionType, &cur_protectionCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->max_protectionType, &max_protectionCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->inheritanceType, &inheritanceCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_map(In0P->Head.msgh_request_port, &In0P->address, In0P->size, In0P->mask, In0P->anywhere, In0P->memory_object, In0P->offset, In0P->copy, In0P->cur_protection, In0P->max_protection, In0P->inheritance); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->addressType = addressType; + + OutP->address = In0P->address; +} + +/* SimpleRoutine memory_object_data_error */ +mig_internal void _Xmemory_object_data_error + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t error_valueType; + kern_return_t error_value; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_data_error + (mach_port_t memory_control, vm_offset_t offset, vm_size_t size, kern_return_t error_value); + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t error_valueCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->error_valueType, &error_valueCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_data_error(In0P->Head.msgh_request_port, In0P->offset, In0P->size, In0P->error_value); +} + +/* SimpleRoutine memory_object_set_attributes */ +mig_internal void _Xmemory_object_set_attributes + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t object_readyType; + boolean_t object_ready; + mach_msg_type_t may_cacheType; + boolean_t may_cache; + mach_msg_type_t copy_strategyType; + memory_object_copy_strategy_t copy_strategy; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_set_attributes + (mach_port_t memory_control, boolean_t object_ready, boolean_t may_cache, memory_object_copy_strategy_t copy_strategy); + + auto const mach_msg_type_t object_readyCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t may_cacheCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copy_strategyCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->object_readyType, &object_readyCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->may_cacheType, &may_cacheCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->copy_strategyType, ©_strategyCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_set_attributes(In0P->Head.msgh_request_port, In0P->object_ready, In0P->may_cache, In0P->copy_strategy); +} + +/* SimpleRoutine memory_object_destroy */ +mig_internal void _Xmemory_object_destroy + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t reasonType; + kern_return_t reason; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_destroy + (mach_port_t memory_control, kern_return_t reason); + + auto const mach_msg_type_t reasonCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->reasonType, &reasonCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_destroy(In0P->Head.msgh_request_port, In0P->reason); +} + +/* SimpleRoutine memory_object_data_supply */ +mig_internal void _Xmemory_object_data_supply + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_long_t dataType; + vm_offset_t data; + mach_msg_type_t lock_valueType; + vm_prot_t lock_value; + mach_msg_type_t preciousType; + boolean_t precious; + mach_msg_type_t reply_toType; + mach_port_t reply_to; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_data_supply + (mach_port_t memory_control, vm_offset_t offset, vm_offset_t data, mach_msg_type_number_t dataCnt, vm_prot_t lock_value, boolean_t precious, mach_port_t reply_to, mach_msg_type_name_t reply_toPoly); + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t lock_valueCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t preciousCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 72) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->dataType.msgtl_header.msgt_inline != FALSE) || + (In0P->dataType.msgtl_header.msgt_longform != TRUE) || + (In0P->dataType.msgtl_name != 9) || + (In0P->dataType.msgtl_size != 8)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->lock_valueType, &lock_valueCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->preciousType, &preciousCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->reply_toType.msgt_inline != TRUE) || + (In0P->reply_toType.msgt_longform != FALSE) || + (In0P->reply_toType.msgt_number != 1) || + (In0P->reply_toType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_data_supply(In0P->Head.msgh_request_port, In0P->offset, In0P->data, In0P->dataType.msgtl_number, In0P->lock_value, In0P->precious, In0P->reply_to, In0P->reply_toType.msgt_name); +} + +/* SimpleRoutine memory_object_ready */ +mig_internal void _Xmemory_object_ready + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t may_cacheType; + boolean_t may_cache; + mach_msg_type_t copy_strategyType; + memory_object_copy_strategy_t copy_strategy; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_ready + (mach_port_t memory_control, boolean_t may_cache, memory_object_copy_strategy_t copy_strategy); + + auto const mach_msg_type_t may_cacheCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copy_strategyCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->may_cacheType, &may_cacheCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->copy_strategyType, ©_strategyCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_ready(In0P->Head.msgh_request_port, In0P->may_cache, In0P->copy_strategy); +} + +/* SimpleRoutine memory_object_change_attributes */ +mig_internal void _Xmemory_object_change_attributes + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t may_cacheType; + boolean_t may_cache; + mach_msg_type_t copy_strategyType; + memory_object_copy_strategy_t copy_strategy; + mach_msg_type_t reply_toType; + mach_port_t reply_to; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_memory_object_change_attributes + (mach_port_t memory_control, boolean_t may_cache, memory_object_copy_strategy_t copy_strategy, mach_port_t reply_to, mach_msg_type_name_t reply_toPoly); + +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ + + auto const mach_msg_type_t may_cacheCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copy_strategyCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + if ((In0P->Head.msgh_size != 48)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->may_cacheType, &may_cacheCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->copy_strategyType, ©_strategyCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->reply_toType.msgt_inline != TRUE) || + (In0P->reply_toType.msgt_longform != FALSE) || + (MACH_MSG_TYPE_PORT_ANY(In0P->reply_toType.msgt_name) && msgh_simple) || + (In0P->reply_toType.msgt_number != 1) || + (In0P->reply_toType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_memory_object_change_attributes(In0P->Head.msgh_request_port, In0P->may_cache, In0P->copy_strategy, In0P->reply_to, In0P->reply_toType.msgt_name); +} + +/* Routine vm_machine_attribute */ +mig_internal void _Xvm_machine_attribute + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t attributeType; + vm_machine_attribute_t attribute; + mach_msg_type_t valueType; + vm_machine_attribute_val_t value; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t valueType; + vm_machine_attribute_val_t value; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t S_vm_machine_attribute + (mach_port_t target_task, vm_address_t address, vm_size_t size, vm_machine_attribute_t attribute, vm_machine_attribute_val_t *value); + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t attributeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t valueCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t valueType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 56) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->addressType, &addressCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->attributeType, &attributeCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->valueType, &valueCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = S_vm_machine_attribute(In0P->Head.msgh_request_port, In0P->address, In0P->size, In0P->attribute, &In0P->value); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->valueType = valueType; + + OutP->value = In0P->value; +} + +static mig_routine_t mach_server_routines[] = { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + _Xtask_create, + _Xtask_terminate, + _Xtask_get_emulation_vector, + _Xtask_set_emulation_vector, + _Xtask_threads, + _Xtask_info, + 0, + 0, + 0, + _Xthread_terminate, + _Xthread_get_state, + _Xthread_set_state, + _Xthread_info, + 0, + _Xvm_allocate, + 0, + _Xvm_deallocate, + _Xvm_protect, + _Xvm_inherit, + _Xvm_read, + _Xvm_write, + _Xvm_copy, + _Xvm_region, + _Xvm_statistics, + 0, + 0, + _Xmach_ports_register, + _Xmach_ports_lookup, + 0, + 0, + 0, + _Xmemory_object_data_provided, + _Xmemory_object_data_unavailable, + _Xmemory_object_get_attributes, + _Xvm_set_default_memory_manager, + 0, + _Xxxx_memory_object_lock_request, + _Xmemory_object_lock_request, + _Xxxx_task_get_emulation_vector, + _Xxxx_task_set_emulation_vector, + _Xxxx_host_info, + _Xxxx_slot_info, + _Xxxx_cpu_control, + 0, + 0, + 0, + 0, + 0, + 0, + _Xtask_suspend, + _Xtask_resume, + _Xtask_get_special_port, + _Xtask_set_special_port, + _Xxxx_task_info, + _Xthread_create, + _Xthread_suspend, + _Xthread_resume, + _Xthread_abort, + _Xxxx_thread_get_state, + _Xxxx_thread_set_state, + _Xthread_get_special_port, + _Xthread_set_special_port, + _Xxxx_thread_info, + _Xtask_set_emulation, + _Xtask_ras_control, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + _Xvm_map, + _Xmemory_object_data_error, + _Xmemory_object_set_attributes, + _Xmemory_object_destroy, + _Xmemory_object_data_supply, + _Xmemory_object_ready, + _Xmemory_object_change_attributes, + 0, + 0, + 0, + _Xvm_machine_attribute, + 0, +}; + +mig_external boolean_t mach_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + register mach_msg_header_t *InP = InHeadP; + register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; + + auto const mach_msg_type_t RetCodeType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + register mig_routine_t routine; + + OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); + OutP->Head.msgh_size = sizeof *OutP; + OutP->Head.msgh_remote_port = InP->msgh_reply_port; + OutP->Head.msgh_local_port = MACH_PORT_NULL; + OutP->Head.msgh_seqno = 0; + OutP->Head.msgh_id = InP->msgh_id + 100; + + OutP->RetCodeType = RetCodeType; + + if ((InP->msgh_id > 2100) || (InP->msgh_id < 2000) || + ((routine = mach_server_routines[InP->msgh_id - 2000]) == 0)) { + OutP->RetCode = MIG_BAD_ID; + return FALSE; + } + (*routine) (InP, &OutP->Head); + return TRUE; +} + +mig_external mig_routine_t mach_server_routine + (const mach_msg_header_t *InHeadP) +{ + register int msgh_id; + + msgh_id = InHeadP->msgh_id - 2000; + + if ((msgh_id > 100) || (msgh_id < 0)) + return 0; + + return mach_server_routines[msgh_id]; +} + diff --git a/tmp/machUser.c b/tmp/machUser.c new file mode 100644 index 00000000..ead3f4a2 --- /dev/null +++ b/tmp/machUser.c @@ -0,0 +1,6562 @@ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#include "mach.h" +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> +#include <mach/msg_type.h> +/* LINTLIBRARY */ + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_remote_port +#define msgh_reply_port msgh_local_port + +#include <mach/std_types.h> +#include <mach/mach_types.h> + +/* Routine task_create */ +mig_external kern_return_t task_create +( + mach_port_t target_task, + boolean_t inherit_memory, + mach_port_t *child_task +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t inherit_memoryType; + boolean_t inherit_memory; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t child_taskType; + mach_port_t child_task; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t inherit_memoryType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t child_taskCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->inherit_memoryType = inherit_memoryType; + + InP->inherit_memory = inherit_memory; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2007; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2107) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 40) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->child_taskType, &child_taskCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *child_task = OutP->child_task; + + return KERN_SUCCESS; +} + +/* Routine task_terminate */ +mig_external kern_return_t task_terminate +( + mach_port_t target_task +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2008; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2108) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine task_get_emulation_vector */ +mig_external kern_return_t task_get_emulation_vector +( + mach_port_t task, + int *vector_start, + emulation_vector_t *emulation_vector, + mach_msg_type_number_t *emulation_vectorCnt +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t vector_startType; + int vector_start; + mach_msg_type_long_t emulation_vectorType; + emulation_vector_t emulation_vector; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t vector_startCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2009; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2109) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 56) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->vector_startType, &vector_startCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *vector_start = OutP->vector_start; + +#if TypeCheck + if ((OutP->emulation_vectorType.msgtl_header.msgt_inline != FALSE) || + (OutP->emulation_vectorType.msgtl_header.msgt_longform != TRUE) || + (OutP->emulation_vectorType.msgtl_name != 2) || + (OutP->emulation_vectorType.msgtl_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *emulation_vector = OutP->emulation_vector; + + *emulation_vectorCnt = OutP->emulation_vectorType.msgtl_number; + + return KERN_SUCCESS; +} + +/* Routine task_set_emulation_vector */ +mig_external kern_return_t task_set_emulation_vector +( + mach_port_t task, + int vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t emulation_vectorCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t vector_startType; + int vector_start; + mach_msg_type_long_t emulation_vectorType; + emulation_vector_t emulation_vector; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t vector_startType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t emulation_vectorType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->vector_startType = vector_startType; + + InP->vector_start = vector_start; + + InP->emulation_vectorType = emulation_vectorType; + + InP->emulation_vector = emulation_vector; + + InP->emulation_vectorType.msgtl_number = emulation_vectorCnt; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2010; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2110) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine task_threads */ +mig_external kern_return_t task_threads +( + mach_port_t target_task, + thread_array_t *thread_list, + mach_msg_type_number_t *thread_listCnt +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t thread_listType; + thread_array_t thread_list; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2011; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2111) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 48) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->thread_listType.msgtl_header.msgt_inline != FALSE) || + (OutP->thread_listType.msgtl_header.msgt_longform != TRUE) || + (OutP->thread_listType.msgtl_name != 17) || + (OutP->thread_listType.msgtl_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *thread_list = OutP->thread_list; + + *thread_listCnt = OutP->thread_listType.msgtl_number; + + return KERN_SUCCESS; +} + +/* Routine task_info */ +mig_external kern_return_t task_info +( + mach_port_t target_task, + int flavor, + task_info_t task_info_out, + mach_msg_type_number_t *task_info_outCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t task_info_outCntType; + mach_msg_type_number_t task_info_outCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t task_info_outType; + natural_t task_info_out[1024]; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t flavorType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t task_info_outCntType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->flavorType = flavorType; + + InP->flavor = flavor; + + InP->task_info_outCntType = task_info_outCntType; + + if (*task_info_outCnt < 1024) + InP->task_info_outCnt = *task_info_outCnt; + else + InP->task_info_outCnt = 1024; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2012; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2112) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size < 36) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->task_info_outType.msgt_inline != TRUE) || + (OutP->task_info_outType.msgt_longform != FALSE) || + (OutP->task_info_outType.msgt_name != 2) || + (OutP->task_info_outType.msgt_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 36 + (4 * OutP->task_info_outType.msgt_number)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->task_info_outType.msgt_number > *task_info_outCnt) { + memcpy(task_info_out, OutP->task_info_out, 4 * *task_info_outCnt); + *task_info_outCnt = OutP->task_info_outType.msgt_number; + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(task_info_out, OutP->task_info_out, 4 * OutP->task_info_outType.msgt_number); + } + + *task_info_outCnt = OutP->task_info_outType.msgt_number; + + return KERN_SUCCESS; +} + +/* Routine thread_terminate */ +mig_external kern_return_t thread_terminate +( + mach_port_t target_thread +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_thread; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2016; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2116) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine thread_get_state */ +mig_external kern_return_t thread_get_state +( + mach_port_t target_thread, + int flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t old_stateCntType; + mach_msg_type_number_t old_stateCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t old_stateType; + natural_t old_state[1024]; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t flavorType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t old_stateCntType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->flavorType = flavorType; + + InP->flavor = flavor; + + InP->old_stateCntType = old_stateCntType; + + if (*old_stateCnt < 1024) + InP->old_stateCnt = *old_stateCnt; + else + InP->old_stateCnt = 1024; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_thread; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2017; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2117) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size < 36) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->old_stateType.msgt_inline != TRUE) || + (OutP->old_stateType.msgt_longform != FALSE) || + (OutP->old_stateType.msgt_name != 2) || + (OutP->old_stateType.msgt_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 36 + (4 * OutP->old_stateType.msgt_number)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->old_stateType.msgt_number > *old_stateCnt) { + memcpy(old_state, OutP->old_state, 4 * *old_stateCnt); + *old_stateCnt = OutP->old_stateType.msgt_number; + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(old_state, OutP->old_state, 4 * OutP->old_stateType.msgt_number); + } + + *old_stateCnt = OutP->old_stateType.msgt_number; + + return KERN_SUCCESS; +} + +/* Routine thread_set_state */ +mig_external kern_return_t thread_set_state +( + mach_port_t target_thread, + int flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t new_stateType; + natural_t new_state[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + unsigned int msgh_size; + + auto const mach_msg_type_t flavorType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t new_stateType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1024, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->flavorType = flavorType; + + InP->flavor = flavor; + + InP->new_stateType = new_stateType; + + if (new_stateCnt > 1024) { + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(InP->new_state, new_state, 4 * new_stateCnt); + } + + InP->new_stateType.msgt_number = new_stateCnt; + + msgh_size = 36 + (4 * new_stateCnt); + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_thread; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2018; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2118) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine thread_info */ +mig_external kern_return_t thread_info +( + mach_port_t target_thread, + int flavor, + thread_info_t thread_info_out, + mach_msg_type_number_t *thread_info_outCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_t thread_info_outCntType; + mach_msg_type_number_t thread_info_outCnt; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t thread_info_outType; + natural_t thread_info_out[1024]; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t flavorType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t thread_info_outCntType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->flavorType = flavorType; + + InP->flavor = flavor; + + InP->thread_info_outCntType = thread_info_outCntType; + + if (*thread_info_outCnt < 1024) + InP->thread_info_outCnt = *thread_info_outCnt; + else + InP->thread_info_outCnt = 1024; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_thread; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2019; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2119) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size < 36) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->thread_info_outType.msgt_inline != TRUE) || + (OutP->thread_info_outType.msgt_longform != FALSE) || + (OutP->thread_info_outType.msgt_name != 2) || + (OutP->thread_info_outType.msgt_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 36 + (4 * OutP->thread_info_outType.msgt_number)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->thread_info_outType.msgt_number > *thread_info_outCnt) { + memcpy(thread_info_out, OutP->thread_info_out, 4 * *thread_info_outCnt); + *thread_info_outCnt = OutP->thread_info_outType.msgt_number; + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(thread_info_out, OutP->thread_info_out, 4 * OutP->thread_info_outType.msgt_number); + } + + *thread_info_outCnt = OutP->thread_info_outType.msgt_number; + + return KERN_SUCCESS; +} + +/* Routine vm_allocate */ +mig_external kern_return_t vm_allocate +( + mach_port_t target_task, + vm_address_t *address, + vm_size_t size, + boolean_t anywhere +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t anywhereType; + boolean_t anywhere; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t addressType; + vm_address_t address; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t anywhereType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->addressType = addressType; + + InP->address = *address; + + InP->sizeType = sizeType; + + InP->size = size; + + InP->anywhereType = anywhereType; + + InP->anywhere = anywhere; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2021; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2121) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size != 40) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->addressType, &addressCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *address = OutP->address; + + return KERN_SUCCESS; +} + +/* Routine vm_deallocate */ +mig_external kern_return_t vm_deallocate +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->addressType = addressType; + + InP->address = address; + + InP->sizeType = sizeType; + + InP->size = size; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2023; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2123) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine vm_protect */ +mig_external kern_return_t vm_protect +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size, + boolean_t set_maximum, + vm_prot_t new_protection +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t set_maximumType; + boolean_t set_maximum; + mach_msg_type_t new_protectionType; + vm_prot_t new_protection; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t set_maximumType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t new_protectionType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->addressType = addressType; + + InP->address = address; + + InP->sizeType = sizeType; + + InP->size = size; + + InP->set_maximumType = set_maximumType; + + InP->set_maximum = set_maximum; + + InP->new_protectionType = new_protectionType; + + InP->new_protection = new_protection; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2024; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 56, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2124) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine vm_inherit */ +mig_external kern_return_t vm_inherit +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size, + vm_inherit_t new_inheritance +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t new_inheritanceType; + vm_inherit_t new_inheritance; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t new_inheritanceType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->addressType = addressType; + + InP->address = address; + + InP->sizeType = sizeType; + + InP->size = size; + + InP->new_inheritanceType = new_inheritanceType; + + InP->new_inheritance = new_inheritance; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2025; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2125) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine vm_read */ +mig_external kern_return_t vm_read +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size, + vm_offset_t *data, + mach_msg_type_number_t *dataCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t dataType; + vm_offset_t data; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->addressType = addressType; + + InP->address = address; + + InP->sizeType = sizeType; + + InP->size = size; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2026; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2126) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 48) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->dataType.msgtl_header.msgt_inline != FALSE) || + (OutP->dataType.msgtl_header.msgt_longform != TRUE) || + (OutP->dataType.msgtl_name != 9) || + (OutP->dataType.msgtl_size != 8)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *data = OutP->data; + + *dataCnt = OutP->dataType.msgtl_number; + + return KERN_SUCCESS; +} + +/* Routine vm_write */ +mig_external kern_return_t vm_write +( + mach_port_t target_task, + vm_address_t address, + vm_offset_t data, + mach_msg_type_number_t dataCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_long_t dataType; + vm_offset_t data; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t dataType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 9, + /* msgtl_size = */ 8, + /* msgtl_number = */ 0, + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->addressType = addressType; + + InP->address = address; + + InP->dataType = dataType; + + InP->data = data; + + InP->dataType.msgtl_number = dataCnt; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2027; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2127) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine vm_copy */ +mig_external kern_return_t vm_copy +( + mach_port_t target_task, + vm_address_t source_address, + vm_size_t size, + vm_address_t dest_address +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t source_addressType; + vm_address_t source_address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t dest_addressType; + vm_address_t dest_address; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t source_addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t dest_addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->source_addressType = source_addressType; + + InP->source_address = source_address; + + InP->sizeType = sizeType; + + InP->size = size; + + InP->dest_addressType = dest_addressType; + + InP->dest_address = dest_address; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2028; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2128) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine vm_region */ +mig_external kern_return_t vm_region +( + mach_port_t target_task, + vm_address_t *address, + vm_size_t *size, + vm_prot_t *protection, + vm_prot_t *max_protection, + vm_inherit_t *inheritance, + boolean_t *is_shared, + mach_port_t *object_name, + vm_offset_t *offset +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t protectionType; + vm_prot_t protection; + mach_msg_type_t max_protectionType; + vm_prot_t max_protection; + mach_msg_type_t inheritanceType; + vm_inherit_t inheritance; + mach_msg_type_t is_sharedType; + boolean_t is_shared; + mach_msg_type_t object_nameType; + mach_port_t object_name; + mach_msg_type_t offsetType; + vm_offset_t offset; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t protectionCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t max_protectionCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t inheritanceCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t is_sharedCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t object_nameCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t offsetCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->addressType = addressType; + + InP->address = *address; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2029; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2129) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 96) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->addressType, &addressCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *address = OutP->address; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->sizeType, &sizeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *size = OutP->size; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->protectionType, &protectionCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *protection = OutP->protection; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->max_protectionType, &max_protectionCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *max_protection = OutP->max_protection; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->inheritanceType, &inheritanceCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *inheritance = OutP->inheritance; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->is_sharedType, &is_sharedCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *is_shared = OutP->is_shared; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->object_nameType, &object_nameCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *object_name = OutP->object_name; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->offsetType, &offsetCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *offset = OutP->offset; + + return KERN_SUCCESS; +} + +/* Routine vm_statistics */ +mig_external kern_return_t vm_statistics +( + mach_port_t target_task, + vm_statistics_data_t *vm_stats +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t vm_statsType; + vm_statistics_data_t vm_stats; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t vm_statsCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 13, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2030; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2130) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size != 88) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->vm_statsType, &vm_statsCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *vm_stats = OutP->vm_stats; + + return KERN_SUCCESS; +} + +/* Routine mach_ports_register */ +mig_external kern_return_t mach_ports_register +( + mach_port_t target_task, + mach_port_array_t init_port_set, + mach_msg_type_number_t init_port_setCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_long_t init_port_setType; + mach_port_array_t init_port_set; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_long_t init_port_setType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 19, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->init_port_setType = init_port_setType; + + InP->init_port_set = init_port_set; + + InP->init_port_setType.msgtl_number = init_port_setCnt; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2033; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2133) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine mach_ports_lookup */ +mig_external kern_return_t mach_ports_lookup +( + mach_port_t target_task, + mach_port_array_t *init_port_set, + mach_msg_type_number_t *init_port_setCnt +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t init_port_setType; + mach_port_array_t init_port_set; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2034; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2134) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 48) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->init_port_setType.msgtl_header.msgt_inline != FALSE) || + (OutP->init_port_setType.msgtl_header.msgt_longform != TRUE) || + (OutP->init_port_setType.msgtl_name != 17) || + (OutP->init_port_setType.msgtl_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *init_port_set = OutP->init_port_set; + + *init_port_setCnt = OutP->init_port_setType.msgtl_number; + + return KERN_SUCCESS; +} + +/* SimpleRoutine memory_object_data_provided */ +mig_external kern_return_t memory_object_data_provided +( + mach_port_t memory_control, + vm_offset_t offset, + vm_offset_t data, + mach_msg_type_number_t dataCnt, + vm_prot_t lock_value +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_long_t dataType; + vm_offset_t data; + mach_msg_type_t lock_valueType; + vm_prot_t lock_value; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t offsetType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t dataType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 9, + /* msgtl_size = */ 8, + /* msgtl_number = */ 0, + }; + + auto const mach_msg_type_t lock_valueType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->offsetType = offsetType; + + InP->offset = offset; + + InP->dataType = dataType; + + InP->data = data; + + InP->dataType.msgtl_number = dataCnt; + + InP->lock_valueType = lock_valueType; + + InP->lock_value = lock_value; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = memory_control; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2038; + + return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 56, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine memory_object_data_unavailable */ +mig_external kern_return_t memory_object_data_unavailable +( + mach_port_t memory_control, + vm_offset_t offset, + vm_size_t size +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t offsetType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->offsetType = offsetType; + + InP->offset = offset; + + InP->sizeType = sizeType; + + InP->size = size; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = memory_control; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2039; + + return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* Routine memory_object_get_attributes */ +mig_external kern_return_t memory_object_get_attributes +( + mach_port_t memory_control, + boolean_t *object_ready, + boolean_t *may_cache, + memory_object_copy_strategy_t *copy_strategy +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t object_readyType; + boolean_t object_ready; + mach_msg_type_t may_cacheType; + boolean_t may_cache; + mach_msg_type_t copy_strategyType; + memory_object_copy_strategy_t copy_strategy; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t object_readyCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t may_cacheCheck = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copy_strategyCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = memory_control; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2040; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2140) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size != 56) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->object_readyType, &object_readyCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *object_ready = OutP->object_ready; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->may_cacheType, &may_cacheCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *may_cache = OutP->may_cache; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->copy_strategyType, ©_strategyCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *copy_strategy = OutP->copy_strategy; + + return KERN_SUCCESS; +} + +/* Routine vm_set_default_memory_manager */ +mig_external kern_return_t vm_set_default_memory_manager +( + mach_port_t host_priv, + mach_port_t *default_manager +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t default_managerType; + mach_port_t default_manager; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t default_managerType; + mach_port_t default_manager; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t default_managerType = { + /* msgt_name = */ 20, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t default_managerCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->default_managerType = default_managerType; + + InP->default_manager = *default_manager; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = host_priv; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2041; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2141) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 40) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->default_managerType, &default_managerCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *default_manager = OutP->default_manager; + + return KERN_SUCCESS; +} + +/* SimpleRoutine xxx_memory_object_lock_request */ +mig_external kern_return_t xxx_memory_object_lock_request +( + mach_port_t memory_control, + vm_offset_t offset, + vm_size_t size, + boolean_t should_clean, + boolean_t should_flush, + vm_prot_t lock_value, + mach_port_t reply_to +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t should_cleanType; + boolean_t should_clean; + mach_msg_type_t should_flushType; + boolean_t should_flush; + mach_msg_type_t lock_valueType; + vm_prot_t lock_value; + mach_msg_type_t reply_toType; + mach_port_t reply_to; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t offsetType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t should_cleanType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t should_flushType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t lock_valueType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t reply_toType = { + /* msgt_name = */ 21, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->offsetType = offsetType; + + InP->offset = offset; + + InP->sizeType = sizeType; + + InP->size = size; + + InP->should_cleanType = should_cleanType; + + InP->should_clean = should_clean; + + InP->should_flushType = should_flushType; + + InP->should_flush = should_flush; + + InP->lock_valueType = lock_valueType; + + InP->lock_value = lock_value; + + InP->reply_toType = reply_toType; + + InP->reply_to = reply_to; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = memory_control; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2043; + + return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 72, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine memory_object_lock_request */ +mig_external kern_return_t memory_object_lock_request +( + mach_port_t memory_control, + vm_offset_t offset, + vm_size_t size, + memory_object_return_t should_return, + boolean_t should_flush, + vm_prot_t lock_value, + mach_port_t reply_to +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t should_returnType; + memory_object_return_t should_return; + mach_msg_type_t should_flushType; + boolean_t should_flush; + mach_msg_type_t lock_valueType; + vm_prot_t lock_value; + mach_msg_type_t reply_toType; + mach_port_t reply_to; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t offsetType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t should_returnType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t should_flushType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t lock_valueType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t reply_toType = { + /* msgt_name = */ 21, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->offsetType = offsetType; + + InP->offset = offset; + + InP->sizeType = sizeType; + + InP->size = size; + + InP->should_returnType = should_returnType; + + InP->should_return = should_return; + + InP->should_flushType = should_flushType; + + InP->should_flush = should_flush; + + InP->lock_valueType = lock_valueType; + + InP->lock_value = lock_value; + + InP->reply_toType = reply_toType; + + InP->reply_to = reply_to; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = memory_control; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2044; + + return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 72, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* Routine xxx_task_get_emulation_vector */ +mig_external kern_return_t xxx_task_get_emulation_vector +( + mach_port_t task, + int *vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t *emulation_vectorCnt +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t vector_startType; + int vector_start; + mach_msg_type_long_t emulation_vectorType; + vm_offset_t emulation_vector[1024]; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t vector_startCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2045; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2145) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size < 52) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->vector_startType, &vector_startCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *vector_start = OutP->vector_start; + +#if TypeCheck + if ((OutP->emulation_vectorType.msgtl_header.msgt_inline != TRUE) || + (OutP->emulation_vectorType.msgtl_header.msgt_longform != TRUE) || + (OutP->emulation_vectorType.msgtl_name != 2) || + (OutP->emulation_vectorType.msgtl_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 52 + (4 * OutP->emulation_vectorType.msgtl_number)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->emulation_vectorType.msgtl_number > *emulation_vectorCnt) { + memcpy(emulation_vector, OutP->emulation_vector, 4 * *emulation_vectorCnt); + *emulation_vectorCnt = OutP->emulation_vectorType.msgtl_number; + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(emulation_vector, OutP->emulation_vector, 4 * OutP->emulation_vectorType.msgtl_number); + } + + *emulation_vectorCnt = OutP->emulation_vectorType.msgtl_number; + + return KERN_SUCCESS; +} + +/* Routine xxx_task_set_emulation_vector */ +mig_external kern_return_t xxx_task_set_emulation_vector +( + mach_port_t task, + int vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t emulation_vectorCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t vector_startType; + int vector_start; + mach_msg_type_long_t emulation_vectorType; + vm_offset_t emulation_vector[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + unsigned int msgh_size; + + auto const mach_msg_type_t vector_startType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t emulation_vectorType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->vector_startType = vector_startType; + + InP->vector_start = vector_start; + + InP->emulation_vectorType = emulation_vectorType; + + if (emulation_vectorCnt > 1024) { + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(InP->emulation_vector, emulation_vector, 4 * emulation_vectorCnt); + } + + InP->emulation_vectorType.msgtl_number = emulation_vectorCnt; + + msgh_size = 44 + (4 * emulation_vectorCnt); + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2046; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2146) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine xxx_host_info */ +mig_external kern_return_t xxx_host_info +( + mach_port_t target_task, + machine_info_data_t *info +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t infoType; + machine_info_data_t info; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t infoCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 5, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2047; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2147) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size != 56) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->infoType, &infoCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *info = OutP->info; + + return KERN_SUCCESS; +} + +/* Routine xxx_slot_info */ +mig_external kern_return_t xxx_slot_info +( + mach_port_t target_task, + int slot, + machine_slot_data_t *info +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t slotType; + int slot; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t infoType; + machine_slot_data_t info; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t slotType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t infoCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 8, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->slotType = slotType; + + InP->slot = slot; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2048; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2148) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size != 68) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->infoType, &infoCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *info = OutP->info; + + return KERN_SUCCESS; +} + +/* Routine xxx_cpu_control */ +mig_external kern_return_t xxx_cpu_control +( + mach_port_t target_task, + int cpu, + boolean_t running +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t cpuType; + int cpu; + mach_msg_type_t runningType; + boolean_t running; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t cpuType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t runningType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->cpuType = cpuType; + + InP->cpu = cpu; + + InP->runningType = runningType; + + InP->running = running; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2049; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2149) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine task_suspend */ +mig_external kern_return_t task_suspend +( + mach_port_t target_task +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2056; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2156) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine task_resume */ +mig_external kern_return_t task_resume +( + mach_port_t target_task +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2057; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2157) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine task_get_special_port */ +mig_external kern_return_t task_get_special_port +( + mach_port_t task, + int which_port, + mach_port_t *special_port +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t which_portType; + int which_port; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t special_portType; + mach_port_t special_port; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t which_portType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t special_portCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->which_portType = which_portType; + + InP->which_port = which_port; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2058; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2158) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 40) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->special_portType, &special_portCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *special_port = OutP->special_port; + + return KERN_SUCCESS; +} + +/* Routine task_set_special_port */ +mig_external kern_return_t task_set_special_port +( + mach_port_t task, + int which_port, + mach_port_t special_port +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t which_portType; + int which_port; + mach_msg_type_t special_portType; + mach_port_t special_port; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t which_portType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t special_portType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->which_portType = which_portType; + + InP->which_port = which_port; + + InP->special_portType = special_portType; + + InP->special_port = special_port; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2059; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2159) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine xxx_task_info */ +mig_external kern_return_t xxx_task_info +( + mach_port_t target_task, + int flavor, + task_info_t task_info_out, + mach_msg_type_number_t *task_info_outCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t task_info_outType; + natural_t task_info_out[1024]; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t flavorType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->flavorType = flavorType; + + InP->flavor = flavor; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2060; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2160) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size < 44) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->task_info_outType.msgtl_header.msgt_inline != TRUE) || + (OutP->task_info_outType.msgtl_header.msgt_longform != TRUE) || + (OutP->task_info_outType.msgtl_name != 2) || + (OutP->task_info_outType.msgtl_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 44 + (4 * OutP->task_info_outType.msgtl_number)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->task_info_outType.msgtl_number > *task_info_outCnt) { + memcpy(task_info_out, OutP->task_info_out, 4 * *task_info_outCnt); + *task_info_outCnt = OutP->task_info_outType.msgtl_number; + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(task_info_out, OutP->task_info_out, 4 * OutP->task_info_outType.msgtl_number); + } + + *task_info_outCnt = OutP->task_info_outType.msgtl_number; + + return KERN_SUCCESS; +} + +/* Routine thread_create */ +mig_external kern_return_t thread_create +( + mach_port_t parent_task, + mach_port_t *child_thread +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t child_threadType; + mach_port_t child_thread; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t child_threadCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = parent_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2061; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2161) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 40) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->child_threadType, &child_threadCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *child_thread = OutP->child_thread; + + return KERN_SUCCESS; +} + +/* Routine thread_suspend */ +mig_external kern_return_t thread_suspend +( + mach_port_t target_thread +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_thread; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2062; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2162) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine thread_resume */ +mig_external kern_return_t thread_resume +( + mach_port_t target_thread +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_thread; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2063; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2163) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine thread_abort */ +mig_external kern_return_t thread_abort +( + mach_port_t target_thread +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_thread; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2064; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2164) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine xxx_thread_get_state */ +mig_external kern_return_t xxx_thread_get_state +( + mach_port_t target_thread, + int flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t old_stateType; + natural_t old_state[1024]; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t flavorType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->flavorType = flavorType; + + InP->flavor = flavor; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_thread; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2065; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2165) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size < 44) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->old_stateType.msgtl_header.msgt_inline != TRUE) || + (OutP->old_stateType.msgtl_header.msgt_longform != TRUE) || + (OutP->old_stateType.msgtl_name != 2) || + (OutP->old_stateType.msgtl_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 44 + (4 * OutP->old_stateType.msgtl_number)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->old_stateType.msgtl_number > *old_stateCnt) { + memcpy(old_state, OutP->old_state, 4 * *old_stateCnt); + *old_stateCnt = OutP->old_stateType.msgtl_number; + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(old_state, OutP->old_state, 4 * OutP->old_stateType.msgtl_number); + } + + *old_stateCnt = OutP->old_stateType.msgtl_number; + + return KERN_SUCCESS; +} + +/* Routine xxx_thread_set_state */ +mig_external kern_return_t xxx_thread_set_state +( + mach_port_t target_thread, + int flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + mach_msg_type_long_t new_stateType; + natural_t new_state[1024]; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + unsigned int msgh_size; + + auto const mach_msg_type_t flavorType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t new_stateType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 1024, + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->flavorType = flavorType; + + InP->flavor = flavor; + + InP->new_stateType = new_stateType; + + if (new_stateCnt > 1024) { + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(InP->new_state, new_state, 4 * new_stateCnt); + } + + InP->new_stateType.msgtl_number = new_stateCnt; + + msgh_size = 44 + (4 * new_stateCnt); + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_thread; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2066; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2166) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine thread_get_special_port */ +mig_external kern_return_t thread_get_special_port +( + mach_port_t thread, + int which_port, + mach_port_t *special_port +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t which_portType; + int which_port; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t special_portType; + mach_port_t special_port; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t which_portType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t special_portCheck = { + /* msgt_name = */ 17, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->which_portType = which_portType; + + InP->which_port = which_port; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = thread; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2067; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2167) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 40) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->special_portType, &special_portCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *special_port = OutP->special_port; + + return KERN_SUCCESS; +} + +/* Routine thread_set_special_port */ +mig_external kern_return_t thread_set_special_port +( + mach_port_t thread, + int which_port, + mach_port_t special_port +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t which_portType; + int which_port; + mach_msg_type_t special_portType; + mach_port_t special_port; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t which_portType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t special_portType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->which_portType = which_portType; + + InP->which_port = which_port; + + InP->special_portType = special_portType; + + InP->special_port = special_port; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = thread; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2068; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2168) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine xxx_thread_info */ +mig_external kern_return_t xxx_thread_info +( + mach_port_t target_thread, + int flavor, + thread_info_t thread_info_out, + mach_msg_type_number_t *thread_info_outCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t thread_info_outType; + natural_t thread_info_out[1024]; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t flavorType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->flavorType = flavorType; + + InP->flavor = flavor; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_thread; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2069; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2169) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size < 44) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->thread_info_outType.msgtl_header.msgt_inline != TRUE) || + (OutP->thread_info_outType.msgtl_header.msgt_longform != TRUE) || + (OutP->thread_info_outType.msgtl_name != 2) || + (OutP->thread_info_outType.msgtl_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (msgh_size != 44 + (4 * OutP->thread_info_outType.msgtl_number)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->thread_info_outType.msgtl_number > *thread_info_outCnt) { + memcpy(thread_info_out, OutP->thread_info_out, 4 * *thread_info_outCnt); + *thread_info_outCnt = OutP->thread_info_outType.msgtl_number; + return MIG_ARRAY_TOO_LARGE; + } + else { + memcpy(thread_info_out, OutP->thread_info_out, 4 * OutP->thread_info_outType.msgtl_number); + } + + *thread_info_outCnt = OutP->thread_info_outType.msgtl_number; + + return KERN_SUCCESS; +} + +/* Routine task_set_emulation */ +mig_external kern_return_t task_set_emulation +( + mach_port_t target_port, + vm_address_t routine_entry_pt, + int routine_number +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t routine_entry_ptType; + vm_address_t routine_entry_pt; + mach_msg_type_t routine_numberType; + int routine_number; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t routine_entry_ptType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t routine_numberType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->routine_entry_ptType = routine_entry_ptType; + + InP->routine_entry_pt = routine_entry_pt; + + InP->routine_numberType = routine_numberType; + + InP->routine_number = routine_number; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_port; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2070; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2170) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine task_ras_control */ +mig_external kern_return_t task_ras_control +( + mach_port_t target_task, + vm_address_t basepc, + vm_address_t boundspc, + int flavor +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t basepcType; + vm_address_t basepc; + mach_msg_type_t boundspcType; + vm_address_t boundspc; + mach_msg_type_t flavorType; + int flavor; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t basepcType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t boundspcType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t flavorType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->basepcType = basepcType; + + InP->basepc = basepc; + + InP->boundspcType = boundspcType; + + InP->boundspc = boundspc; + + InP->flavorType = flavorType; + + InP->flavor = flavor; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2071; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2171) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine vm_map */ +mig_external kern_return_t vm_map +( + mach_port_t target_task, + vm_address_t *address, + vm_size_t size, + vm_address_t mask, + boolean_t anywhere, + mach_port_t memory_object, + vm_offset_t offset, + boolean_t copy, + vm_prot_t cur_protection, + vm_prot_t max_protection, + vm_inherit_t inheritance +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t maskType; + vm_address_t mask; + mach_msg_type_t anywhereType; + boolean_t anywhere; + mach_msg_type_t memory_objectType; + mach_port_t memory_object; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t copyType; + boolean_t copy; + mach_msg_type_t cur_protectionType; + vm_prot_t cur_protection; + mach_msg_type_t max_protectionType; + vm_prot_t max_protection; + mach_msg_type_t inheritanceType; + vm_inherit_t inheritance; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t addressType; + vm_address_t address; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t maskType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t anywhereType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t memory_objectType = { + /* msgt_name = */ 19, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t offsetType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copyType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t cur_protectionType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t max_protectionType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t inheritanceType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t addressCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->addressType = addressType; + + InP->address = *address; + + InP->sizeType = sizeType; + + InP->size = size; + + InP->maskType = maskType; + + InP->mask = mask; + + InP->anywhereType = anywhereType; + + InP->anywhere = anywhere; + + InP->memory_objectType = memory_objectType; + + InP->memory_object = memory_object; + + InP->offsetType = offsetType; + + InP->offset = offset; + + InP->copyType = copyType; + + InP->copy = copy; + + InP->cur_protectionType = cur_protectionType; + + InP->cur_protection = cur_protection; + + InP->max_protectionType = max_protectionType; + + InP->max_protection = max_protection; + + InP->inheritanceType = inheritanceType; + + InP->inheritance = inheritance; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2089; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 104, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2189) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size != 40) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->addressType, &addressCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *address = OutP->address; + + return KERN_SUCCESS; +} + +/* SimpleRoutine memory_object_data_error */ +mig_external kern_return_t memory_object_data_error +( + mach_port_t memory_control, + vm_offset_t offset, + vm_size_t size, + kern_return_t error_value +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t error_valueType; + kern_return_t error_value; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t offsetType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t error_valueType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->offsetType = offsetType; + + InP->offset = offset; + + InP->sizeType = sizeType; + + InP->size = size; + + InP->error_valueType = error_valueType; + + InP->error_value = error_value; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = memory_control; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2090; + + return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 48, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine memory_object_set_attributes */ +mig_external kern_return_t memory_object_set_attributes +( + mach_port_t memory_control, + boolean_t object_ready, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t object_readyType; + boolean_t object_ready; + mach_msg_type_t may_cacheType; + boolean_t may_cache; + mach_msg_type_t copy_strategyType; + memory_object_copy_strategy_t copy_strategy; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t object_readyType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t may_cacheType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copy_strategyType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->object_readyType = object_readyType; + + InP->object_ready = object_ready; + + InP->may_cacheType = may_cacheType; + + InP->may_cache = may_cache; + + InP->copy_strategyType = copy_strategyType; + + InP->copy_strategy = copy_strategy; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = memory_control; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2091; + + return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 48, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine memory_object_destroy */ +mig_external kern_return_t memory_object_destroy +( + mach_port_t memory_control, + kern_return_t reason +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t reasonType; + kern_return_t reason; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t reasonType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->reasonType = reasonType; + + InP->reason = reason; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = memory_control; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2092; + + return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 32, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine memory_object_data_supply */ +mig_external kern_return_t memory_object_data_supply +( + mach_port_t memory_control, + vm_offset_t offset, + vm_offset_t data, + mach_msg_type_number_t dataCnt, + boolean_t dataDealloc, + vm_prot_t lock_value, + boolean_t precious, + mach_port_t reply_to +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t offsetType; + vm_offset_t offset; + mach_msg_type_long_t dataType; + vm_offset_t data; + mach_msg_type_t lock_valueType; + vm_prot_t lock_value; + mach_msg_type_t preciousType; + boolean_t precious; + mach_msg_type_t reply_toType; + mach_port_t reply_to; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t offsetType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t dataType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 9, + /* msgtl_size = */ 8, + /* msgtl_number = */ 0, + }; + + auto const mach_msg_type_t lock_valueType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t preciousType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t reply_toType = { + /* msgt_name = */ 21, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->offsetType = offsetType; + + InP->offset = offset; + + InP->dataType = dataType; + + InP->data = data; + + InP->dataType.msgtl_number = dataCnt; + + InP->dataType.msgtl_header.msgt_deallocate = dataDealloc; + + InP->lock_valueType = lock_valueType; + + InP->lock_value = lock_value; + + InP->preciousType = preciousType; + + InP->precious = precious; + + InP->reply_toType = reply_toType; + + InP->reply_to = reply_to; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = memory_control; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2093; + + return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 72, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine memory_object_ready */ +mig_external kern_return_t memory_object_ready +( + mach_port_t memory_control, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t may_cacheType; + boolean_t may_cache; + mach_msg_type_t copy_strategyType; + memory_object_copy_strategy_t copy_strategy; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t may_cacheType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copy_strategyType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->may_cacheType = may_cacheType; + + InP->may_cache = may_cache; + + InP->copy_strategyType = copy_strategyType; + + InP->copy_strategy = copy_strategy; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = memory_control; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2094; + + return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* SimpleRoutine memory_object_change_attributes */ +mig_external kern_return_t memory_object_change_attributes +( + mach_port_t memory_control, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy, + mach_port_t reply_to +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t may_cacheType; + boolean_t may_cache; + mach_msg_type_t copy_strategyType; + memory_object_copy_strategy_t copy_strategy; + mach_msg_type_t reply_toType; + mach_port_t reply_to; + } Request; + + union { + Request In; + } Mess; + + register Request *InP = &Mess.In; + + + auto const mach_msg_type_t may_cacheType = { + /* msgt_name = */ 0, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t copy_strategyType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t reply_toType = { + /* msgt_name = */ 21, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->may_cacheType = may_cacheType; + + InP->may_cache = may_cache; + + InP->copy_strategyType = copy_strategyType; + + InP->copy_strategy = copy_strategy; + + InP->reply_toType = reply_toType; + + InP->reply_to = reply_to; + + InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, 0); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = memory_control; + InP->Head.msgh_reply_port = MACH_PORT_NULL; + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2095; + + return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 48, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +/* Routine vm_machine_attribute */ +mig_external kern_return_t vm_machine_attribute +( + mach_port_t target_task, + vm_address_t address, + vm_size_t size, + vm_machine_attribute_t attribute, + vm_machine_attribute_val_t *value +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t addressType; + vm_address_t address; + mach_msg_type_t sizeType; + vm_size_t size; + mach_msg_type_t attributeType; + vm_machine_attribute_t attribute; + mach_msg_type_t valueType; + vm_machine_attribute_val_t value; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t valueType; + vm_machine_attribute_val_t value; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t addressType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t sizeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t attributeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t valueType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t valueCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->addressType = addressType; + + InP->address = address; + + InP->sizeType = sizeType; + + InP->size = size; + + InP->attributeType = attributeType; + + InP->attribute = attribute; + + InP->valueType = valueType; + + InP->value = *value; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = target_task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 2099; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 56, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 2199) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size != 40) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->valueType, &valueCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *value = OutP->value; + + return KERN_SUCCESS; +} diff --git a/tmp/mach_port.h b/tmp/mach_port.h new file mode 100644 index 00000000..743750cb --- /dev/null +++ b/tmp/mach_port.h @@ -0,0 +1,432 @@ +#ifndef _mach_port_user_ +#define _mach_port_user_ + +/* Module mach_port */ + +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/message.h> + +#include <mach/std_types.h> +#include <mach/mach_types.h> + +/* Routine mach_port_names */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_names +#if defined(LINTLIBRARY) + (task, names, namesCnt, types, typesCnt) + mach_port_t task; + mach_port_array_t *names; + mach_msg_type_number_t *namesCnt; + mach_port_type_array_t *types; + mach_msg_type_number_t *typesCnt; +{ return mach_port_names(task, names, namesCnt, types, typesCnt); } +#else +( + mach_port_t task, + mach_port_array_t *names, + mach_msg_type_number_t *namesCnt, + mach_port_type_array_t *types, + mach_msg_type_number_t *typesCnt +); +#endif + +/* Routine mach_port_type */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_type +#if defined(LINTLIBRARY) + (task, name, ptype) + mach_port_t task; + mach_port_t name; + mach_port_type_t *ptype; +{ return mach_port_type(task, name, ptype); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_type_t *ptype +); +#endif + +/* Routine mach_port_rename */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_rename +#if defined(LINTLIBRARY) + (task, old_name, new_name) + mach_port_t task; + mach_port_t old_name; + mach_port_t new_name; +{ return mach_port_rename(task, old_name, new_name); } +#else +( + mach_port_t task, + mach_port_t old_name, + mach_port_t new_name +); +#endif + +/* Routine mach_port_allocate_name */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_allocate_name +#if defined(LINTLIBRARY) + (task, right, name) + mach_port_t task; + mach_port_right_t right; + mach_port_t name; +{ return mach_port_allocate_name(task, right, name); } +#else +( + mach_port_t task, + mach_port_right_t right, + mach_port_t name +); +#endif + +/* Routine mach_port_allocate */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_allocate +#if defined(LINTLIBRARY) + (task, right, name) + mach_port_t task; + mach_port_right_t right; + mach_port_t *name; +{ return mach_port_allocate(task, right, name); } +#else +( + mach_port_t task, + mach_port_right_t right, + mach_port_t *name +); +#endif + +/* Routine mach_port_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_destroy +#if defined(LINTLIBRARY) + (task, name) + mach_port_t task; + mach_port_t name; +{ return mach_port_destroy(task, name); } +#else +( + mach_port_t task, + mach_port_t name +); +#endif + +/* Routine mach_port_deallocate */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_deallocate +#if defined(LINTLIBRARY) + (task, name) + mach_port_t task; + mach_port_t name; +{ return mach_port_deallocate(task, name); } +#else +( + mach_port_t task, + mach_port_t name +); +#endif + +/* Routine mach_port_get_refs */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_get_refs +#if defined(LINTLIBRARY) + (task, name, right, refs) + mach_port_t task; + mach_port_t name; + mach_port_right_t right; + mach_port_urefs_t *refs; +{ return mach_port_get_refs(task, name, right, refs); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_right_t right, + mach_port_urefs_t *refs +); +#endif + +/* Routine mach_port_mod_refs */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_mod_refs +#if defined(LINTLIBRARY) + (task, name, right, delta) + mach_port_t task; + mach_port_t name; + mach_port_right_t right; + mach_port_delta_t delta; +{ return mach_port_mod_refs(task, name, right, delta); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_right_t right, + mach_port_delta_t delta +); +#endif + +/* Routine old_mach_port_get_receive_status */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t old_mach_port_get_receive_status +#if defined(LINTLIBRARY) + (task, name, status) + mach_port_t task; + mach_port_t name; + old_mach_port_status_t *status; +{ return old_mach_port_get_receive_status(task, name, status); } +#else +( + mach_port_t task, + mach_port_t name, + old_mach_port_status_t *status +); +#endif + +/* Routine mach_port_set_qlimit */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_set_qlimit +#if defined(LINTLIBRARY) + (task, name, qlimit) + mach_port_t task; + mach_port_t name; + mach_port_msgcount_t qlimit; +{ return mach_port_set_qlimit(task, name, qlimit); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_msgcount_t qlimit +); +#endif + +/* Routine mach_port_set_mscount */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_set_mscount +#if defined(LINTLIBRARY) + (task, name, mscount) + mach_port_t task; + mach_port_t name; + mach_port_mscount_t mscount; +{ return mach_port_set_mscount(task, name, mscount); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_mscount_t mscount +); +#endif + +/* Routine mach_port_get_set_status */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_get_set_status +#if defined(LINTLIBRARY) + (task, name, members, membersCnt) + mach_port_t task; + mach_port_t name; + mach_port_array_t *members; + mach_msg_type_number_t *membersCnt; +{ return mach_port_get_set_status(task, name, members, membersCnt); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_array_t *members, + mach_msg_type_number_t *membersCnt +); +#endif + +/* Routine mach_port_move_member */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_move_member +#if defined(LINTLIBRARY) + (task, member, after) + mach_port_t task; + mach_port_t member; + mach_port_t after; +{ return mach_port_move_member(task, member, after); } +#else +( + mach_port_t task, + mach_port_t member, + mach_port_t after +); +#endif + +/* Routine mach_port_request_notification */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_request_notification +#if defined(LINTLIBRARY) + (task, name, id, sync, notify, notifyPoly, previous) + mach_port_t task; + mach_port_t name; + mach_msg_id_t id; + mach_port_mscount_t sync; + mach_port_t notify; + mach_msg_type_name_t notifyPoly; + mach_port_t *previous; +{ return mach_port_request_notification(task, name, id, sync, notify, notifyPoly, previous); } +#else +( + mach_port_t task, + mach_port_t name, + mach_msg_id_t id, + mach_port_mscount_t sync, + mach_port_t notify, + mach_msg_type_name_t notifyPoly, + mach_port_t *previous +); +#endif + +/* Routine mach_port_insert_right */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_insert_right +#if defined(LINTLIBRARY) + (task, name, poly, polyPoly) + mach_port_t task; + mach_port_t name; + mach_port_t poly; + mach_msg_type_name_t polyPoly; +{ return mach_port_insert_right(task, name, poly, polyPoly); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_t poly, + mach_msg_type_name_t polyPoly +); +#endif + +/* Routine mach_port_extract_right */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_extract_right +#if defined(LINTLIBRARY) + (task, name, msgt_name, poly, polyPoly) + mach_port_t task; + mach_port_t name; + mach_msg_type_name_t msgt_name; + mach_port_t *poly; + mach_msg_type_name_t *polyPoly; +{ return mach_port_extract_right(task, name, msgt_name, poly, polyPoly); } +#else +( + mach_port_t task, + mach_port_t name, + mach_msg_type_name_t msgt_name, + mach_port_t *poly, + mach_msg_type_name_t *polyPoly +); +#endif + +/* Routine mach_port_get_receive_status */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_get_receive_status +#if defined(LINTLIBRARY) + (task, name, status) + mach_port_t task; + mach_port_t name; + mach_port_status_t *status; +{ return mach_port_get_receive_status(task, name, status); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_status_t *status +); +#endif + +/* Routine mach_port_set_seqno */ +#ifdef mig_external +mig_external +#else +extern +#endif +kern_return_t mach_port_set_seqno +#if defined(LINTLIBRARY) + (task, name, seqno) + mach_port_t task; + mach_port_t name; + mach_port_seqno_t seqno; +{ return mach_port_set_seqno(task, name, seqno); } +#else +( + mach_port_t task, + mach_port_t name, + mach_port_seqno_t seqno +); +#endif + +#endif /* not defined(_mach_port_user_) */ diff --git a/tmp/mach_portServer.c b/tmp/mach_portServer.c new file mode 100644 index 00000000..90ffd32e --- /dev/null +++ b/tmp/mach_portServer.c @@ -0,0 +1,1413 @@ +/* Module mach_port */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_local_port +#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) +#define msgh_reply_port msgh_remote_port +#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) + +#include <mach/std_types.h> +#include <mach/mach_types.h> + +/* Routine mach_port_names */ +mig_internal void _Xmach_port_names + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t namesType; + mach_port_array_t names; + mach_msg_type_long_t typesType; + mach_port_type_array_t types; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_names + (mach_port_t task, mach_port_array_t *names, mach_msg_type_number_t *namesCnt, mach_port_type_array_t *types, mach_msg_type_number_t *typesCnt); + + auto const mach_msg_type_long_t namesType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 15, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + auto const mach_msg_type_long_t typesType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 2, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t namesCnt; + mach_msg_type_number_t typesCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 24) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_names(In0P->Head.msgh_request_port, &OutP->names, &namesCnt, &OutP->types, &typesCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 64; + + OutP->namesType = namesType; + + OutP->namesType.msgtl_number = namesCnt; + + OutP->typesType = typesType; + + OutP->typesType.msgtl_number = typesCnt; +} + +/* Routine mach_port_type */ +mig_internal void _Xmach_port_type + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t ptypeType; + mach_port_type_t ptype; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_type + (mach_port_t task, mach_port_t name, mach_port_type_t *ptype); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t ptypeType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_type(In0P->Head.msgh_request_port, In0P->name, &OutP->ptype); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->ptypeType = ptypeType; +} + +/* Routine mach_port_rename */ +mig_internal void _Xmach_port_rename + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t old_nameType; + mach_port_t old_name; + mach_msg_type_t new_nameType; + mach_port_t new_name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_rename + (mach_port_t task, mach_port_t old_name, mach_port_t new_name); + + auto const mach_msg_type_t old_nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t new_nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->old_nameType, &old_nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->new_nameType, &new_nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_rename(In0P->Head.msgh_request_port, In0P->old_name, In0P->new_name); +} + +/* Routine mach_port_allocate_name */ +mig_internal void _Xmach_port_allocate_name + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t rightType; + mach_port_right_t right; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_allocate_name + (mach_port_t task, mach_port_right_t right, mach_port_t name); + + auto const mach_msg_type_t rightCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->rightType, &rightCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_allocate_name(In0P->Head.msgh_request_port, In0P->right, In0P->name); +} + +/* Routine mach_port_allocate */ +mig_internal void _Xmach_port_allocate + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t rightType; + mach_port_right_t right; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t nameType; + mach_port_t name; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_allocate + (mach_port_t task, mach_port_right_t right, mach_port_t *name); + + auto const mach_msg_type_t rightCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->rightType, &rightCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_allocate(In0P->Head.msgh_request_port, In0P->right, &OutP->name); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->nameType = nameType; +} + +/* Routine mach_port_destroy */ +mig_internal void _Xmach_port_destroy + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_destroy + (mach_port_t task, mach_port_t name); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_destroy(In0P->Head.msgh_request_port, In0P->name); +} + +/* Routine mach_port_deallocate */ +mig_internal void _Xmach_port_deallocate + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_deallocate + (mach_port_t task, mach_port_t name); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_deallocate(In0P->Head.msgh_request_port, In0P->name); +} + +/* Routine mach_port_get_refs */ +mig_internal void _Xmach_port_get_refs + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t rightType; + mach_port_right_t right; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t refsType; + mach_port_urefs_t refs; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_get_refs + (mach_port_t task, mach_port_t name, mach_port_right_t right, mach_port_urefs_t *refs); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t rightCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t refsType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->rightType, &rightCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_get_refs(In0P->Head.msgh_request_port, In0P->name, In0P->right, &OutP->refs); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 40; + + OutP->refsType = refsType; +} + +/* Routine mach_port_mod_refs */ +mig_internal void _Xmach_port_mod_refs + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t rightType; + mach_port_right_t right; + mach_msg_type_t deltaType; + mach_port_delta_t delta; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_mod_refs + (mach_port_t task, mach_port_t name, mach_port_right_t right, mach_port_delta_t delta); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t rightCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t deltaCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 48) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->rightType, &rightCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->deltaType, &deltaCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_mod_refs(In0P->Head.msgh_request_port, In0P->name, In0P->right, In0P->delta); +} + +/* Routine old_mach_port_get_receive_status */ +mig_internal void _Xold_mach_port_get_receive_status + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t statusType; + old_mach_port_status_t status; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t old_mach_port_get_receive_status + (mach_port_t task, mach_port_t name, old_mach_port_status_t *status); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t statusType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 8, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = old_mach_port_get_receive_status(In0P->Head.msgh_request_port, In0P->name, &OutP->status); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 68; + + OutP->statusType = statusType; +} + +/* Routine mach_port_set_qlimit */ +mig_internal void _Xmach_port_set_qlimit + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t qlimitType; + mach_port_msgcount_t qlimit; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_set_qlimit + (mach_port_t task, mach_port_t name, mach_port_msgcount_t qlimit); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t qlimitCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->qlimitType, &qlimitCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_set_qlimit(In0P->Head.msgh_request_port, In0P->name, In0P->qlimit); +} + +/* Routine mach_port_set_mscount */ +mig_internal void _Xmach_port_set_mscount + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t mscountType; + mach_port_mscount_t mscount; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_set_mscount + (mach_port_t task, mach_port_t name, mach_port_mscount_t mscount); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t mscountCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->mscountType, &mscountCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_set_mscount(In0P->Head.msgh_request_port, In0P->name, In0P->mscount); +} + +/* Routine mach_port_get_set_status */ +mig_internal void _Xmach_port_get_set_status + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t membersType; + mach_port_array_t members; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_get_set_status + (mach_port_t task, mach_port_t name, mach_port_array_t *members, mach_msg_type_number_t *membersCnt); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_long_t membersType = { + { + /* msgt_name = */ 0, + /* msgt_size = */ 0, + /* msgt_number = */ 0, + /* msgt_inline = */ FALSE, + /* msgt_longform = */ TRUE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }, + /* msgtl_name = */ 15, + /* msgtl_size = */ 32, + /* msgtl_number = */ 0, + }; + + mach_msg_type_number_t membersCnt; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_get_set_status(In0P->Head.msgh_request_port, In0P->name, &OutP->members, &membersCnt); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; + OutP->Head.msgh_size = 48; + + OutP->membersType = membersType; + + OutP->membersType.msgtl_number = membersCnt; +} + +/* Routine mach_port_move_member */ +mig_internal void _Xmach_port_move_member + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t memberType; + mach_port_t member; + mach_msg_type_t afterType; + mach_port_t after; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_move_member + (mach_port_t task, mach_port_t member, mach_port_t after); + + auto const mach_msg_type_t memberCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t afterCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->memberType, &memberCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->afterType, &afterCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_move_member(In0P->Head.msgh_request_port, In0P->member, In0P->after); +} + +/* Routine mach_port_request_notification */ +mig_internal void _Xmach_port_request_notification + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t idType; + mach_msg_id_t id; + mach_msg_type_t syncType; + mach_port_mscount_t sync; + mach_msg_type_t notifyType; + mach_port_t notify; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t previousType; + mach_port_t previous; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_request_notification + (mach_port_t task, mach_port_t name, mach_msg_id_t id, mach_port_mscount_t sync, mach_port_t notify, mach_port_t *previous, mach_msg_type_name_t *previousPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t idCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t syncCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t notifyCheck = { + /* msgt_name = */ 18, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t previousType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t previousPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 56) || + !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->idType, &idCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->syncType, &syncCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->notifyType, ¬ifyCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_request_notification(In0P->Head.msgh_request_port, In0P->name, In0P->id, In0P->sync, In0P->notify, &OutP->previous, &previousPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->previousType = previousType; + + if (MACH_MSG_TYPE_PORT_ANY(previousPoly)) + msgh_simple = FALSE; + + OutP->previousType.msgt_name = previousPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine mach_port_insert_right */ +mig_internal void _Xmach_port_insert_right + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t polyType; + mach_port_t poly; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_insert_right + (mach_port_t task, mach_port_t name, mach_port_t poly, mach_msg_type_name_t polyPoly); + +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + if ((In0P->Head.msgh_size != 40)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if ((In0P->polyType.msgt_inline != TRUE) || + (In0P->polyType.msgt_longform != FALSE) || + (MACH_MSG_TYPE_PORT_ANY(In0P->polyType.msgt_name) && msgh_simple) || + (In0P->polyType.msgt_number != 1) || + (In0P->polyType.msgt_size != 32)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_insert_right(In0P->Head.msgh_request_port, In0P->name, In0P->poly, In0P->polyType.msgt_name); +} + +/* Routine mach_port_extract_right */ +mig_internal void _Xmach_port_extract_right + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t msgt_nameType; + mach_msg_type_name_t msgt_name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t polyType; + mach_port_t poly; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_extract_right + (mach_port_t task, mach_port_t name, mach_msg_type_name_t msgt_name, mach_port_t *poly, mach_msg_type_name_t *polyPoly); + + boolean_t msgh_simple; + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t msgt_nameCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t polyType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + mach_msg_type_name_t polyPoly; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->msgt_nameType, &msgt_nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_extract_right(In0P->Head.msgh_request_port, In0P->name, In0P->msgt_name, &OutP->poly, &polyPoly); + if (OutP->RetCode != KERN_SUCCESS) + return; + + msgh_simple = TRUE; + OutP->Head.msgh_size = 40; + + OutP->polyType = polyType; + + if (MACH_MSG_TYPE_PORT_ANY(polyPoly)) + msgh_simple = FALSE; + + OutP->polyType.msgt_name = polyPoly; + + if (!msgh_simple) + OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; +} + +/* Routine mach_port_get_receive_status */ +mig_internal void _Xmach_port_get_receive_status + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t statusType; + mach_port_status_t status; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_get_receive_status + (mach_port_t task, mach_port_t name, mach_port_status_t *status); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t statusType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 9, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 32) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_get_receive_status(In0P->Head.msgh_request_port, In0P->name, &OutP->status); + if (OutP->RetCode != KERN_SUCCESS) + return; + + OutP->Head.msgh_size = 72; + + OutP->statusType = statusType; +} + +/* Routine mach_port_set_seqno */ +mig_internal void _Xmach_port_set_seqno + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t seqnoType; + mach_port_seqno_t seqno; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + register Request *In0P = (Request *) InHeadP; + register Reply *OutP = (Reply *) OutHeadP; + mig_external kern_return_t mach_port_set_seqno + (mach_port_t task, mach_port_t name, mach_port_seqno_t seqno); + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t seqnoCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#if TypeCheck + if ((In0P->Head.msgh_size != 40) || + (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK(&In0P->seqnoType, &seqnoCheck)) + { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } +#endif /* TypeCheck */ + + OutP->RetCode = mach_port_set_seqno(In0P->Head.msgh_request_port, In0P->name, In0P->seqno); +} + +static mig_routine_t mach_port_server_routines[] = { + _Xmach_port_names, + _Xmach_port_type, + _Xmach_port_rename, + _Xmach_port_allocate_name, + _Xmach_port_allocate, + _Xmach_port_destroy, + _Xmach_port_deallocate, + _Xmach_port_get_refs, + _Xmach_port_mod_refs, + _Xold_mach_port_get_receive_status, + _Xmach_port_set_qlimit, + _Xmach_port_set_mscount, + _Xmach_port_get_set_status, + _Xmach_port_move_member, + _Xmach_port_request_notification, + _Xmach_port_insert_right, + _Xmach_port_extract_right, + _Xmach_port_get_receive_status, + _Xmach_port_set_seqno, +}; + +mig_external boolean_t mach_port_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + register mach_msg_header_t *InP = InHeadP; + register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; + + auto const mach_msg_type_t RetCodeType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + register mig_routine_t routine; + + OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); + OutP->Head.msgh_size = sizeof *OutP; + OutP->Head.msgh_remote_port = InP->msgh_reply_port; + OutP->Head.msgh_local_port = MACH_PORT_NULL; + OutP->Head.msgh_seqno = 0; + OutP->Head.msgh_id = InP->msgh_id + 100; + + OutP->RetCodeType = RetCodeType; + + if ((InP->msgh_id > 3218) || (InP->msgh_id < 3200) || + ((routine = mach_port_server_routines[InP->msgh_id - 3200]) == 0)) { + OutP->RetCode = MIG_BAD_ID; + return FALSE; + } + (*routine) (InP, &OutP->Head); + return TRUE; +} + +mig_external mig_routine_t mach_port_server_routine + (const mach_msg_header_t *InHeadP) +{ + register int msgh_id; + + msgh_id = InHeadP->msgh_id - 3200; + + if ((msgh_id > 18) || (msgh_id < 0)) + return 0; + + return mach_port_server_routines[msgh_id]; +} + diff --git a/tmp/mach_portUser.c b/tmp/mach_portUser.c new file mode 100644 index 00000000..1aae6abf --- /dev/null +++ b/tmp/mach_portUser.c @@ -0,0 +1,2296 @@ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#include "mach_port.h" +#define EXPORT_BOOLEAN +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/message.h> +#include <mach/notify.h> +#include <mach/mach_types.h> +#include <mach/mig_errors.h> +#include <mach/mig_support.h> +#include <mach/msg_type.h> +/* LINTLIBRARY */ + +#ifndef mig_internal +#define mig_internal static +#endif + +#ifndef mig_external +#define mig_external +#endif + +#ifndef TypeCheck +#define TypeCheck 1 +#endif + +#ifndef UseExternRCSId +#define UseExternRCSId 1 +#endif + +#define BAD_TYPECHECK(type, check) ({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) +#define msgh_request_port msgh_remote_port +#define msgh_reply_port msgh_local_port + +#include <mach/std_types.h> +#include <mach/mach_types.h> + +/* Routine mach_port_names */ +mig_external kern_return_t mach_port_names +( + mach_port_t task, + mach_port_array_t *names, + mach_msg_type_number_t *namesCnt, + mach_port_type_array_t *types, + mach_msg_type_number_t *typesCnt +) +{ + typedef struct { + mach_msg_header_t Head; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t namesType; + mach_port_array_t names; + mach_msg_type_long_t typesType; + mach_port_type_array_t types; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3200; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3300) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 64) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->namesType.msgtl_header.msgt_inline != FALSE) || + (OutP->namesType.msgtl_header.msgt_longform != TRUE) || + (OutP->namesType.msgtl_name != 15) || + (OutP->namesType.msgtl_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *names = OutP->names; + + *namesCnt = OutP->namesType.msgtl_number; + +#if TypeCheck + if ((OutP->typesType.msgtl_header.msgt_inline != FALSE) || + (OutP->typesType.msgtl_header.msgt_longform != TRUE) || + (OutP->typesType.msgtl_name != 2) || + (OutP->typesType.msgtl_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *types = OutP->types; + + *typesCnt = OutP->typesType.msgtl_number; + + return KERN_SUCCESS; +} + +/* Routine mach_port_type */ +mig_external kern_return_t mach_port_type +( + mach_port_t task, + mach_port_t name, + mach_port_type_t *ptype +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t ptypeType; + mach_port_type_t ptype; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t ptypeCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->nameType = nameType; + + InP->name = name; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3201; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3301) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size != 40) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->ptypeType, &ptypeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *ptype = OutP->ptype; + + return KERN_SUCCESS; +} + +/* Routine mach_port_rename */ +mig_external kern_return_t mach_port_rename +( + mach_port_t task, + mach_port_t old_name, + mach_port_t new_name +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t old_nameType; + mach_port_t old_name; + mach_msg_type_t new_nameType; + mach_port_t new_name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t old_nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t new_nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->old_nameType = old_nameType; + + InP->old_name = old_name; + + InP->new_nameType = new_nameType; + + InP->new_name = new_name; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3202; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3302) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine mach_port_allocate_name */ +mig_external kern_return_t mach_port_allocate_name +( + mach_port_t task, + mach_port_right_t right, + mach_port_t name +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t rightType; + mach_port_right_t right; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t rightType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->rightType = rightType; + + InP->right = right; + + InP->nameType = nameType; + + InP->name = name; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3203; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3303) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine mach_port_allocate */ +mig_external kern_return_t mach_port_allocate +( + mach_port_t task, + mach_port_right_t right, + mach_port_t *name +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t rightType; + mach_port_right_t right; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t nameType; + mach_port_t name; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t rightType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t nameCheck = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->rightType = rightType; + + InP->right = right; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3204; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3304) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size != 40) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->nameType, &nameCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *name = OutP->name; + + return KERN_SUCCESS; +} + +/* Routine mach_port_destroy */ +mig_external kern_return_t mach_port_destroy +( + mach_port_t task, + mach_port_t name +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->nameType = nameType; + + InP->name = name; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3205; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3305) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine mach_port_deallocate */ +mig_external kern_return_t mach_port_deallocate +( + mach_port_t task, + mach_port_t name +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->nameType = nameType; + + InP->name = name; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3206; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3306) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine mach_port_get_refs */ +mig_external kern_return_t mach_port_get_refs +( + mach_port_t task, + mach_port_t name, + mach_port_right_t right, + mach_port_urefs_t *refs +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t rightType; + mach_port_right_t right; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t refsType; + mach_port_urefs_t refs; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t rightType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t refsCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->nameType = nameType; + + InP->name = name; + + InP->rightType = rightType; + + InP->right = right; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3207; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3307) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size != 40) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->refsType, &refsCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *refs = OutP->refs; + + return KERN_SUCCESS; +} + +/* Routine mach_port_mod_refs */ +mig_external kern_return_t mach_port_mod_refs +( + mach_port_t task, + mach_port_t name, + mach_port_right_t right, + mach_port_delta_t delta +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t rightType; + mach_port_right_t right; + mach_msg_type_t deltaType; + mach_port_delta_t delta; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t rightType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t deltaType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->nameType = nameType; + + InP->name = name; + + InP->rightType = rightType; + + InP->right = right; + + InP->deltaType = deltaType; + + InP->delta = delta; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3208; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3308) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine old_mach_port_get_receive_status */ +mig_external kern_return_t old_mach_port_get_receive_status +( + mach_port_t task, + mach_port_t name, + old_mach_port_status_t *status +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t statusType; + old_mach_port_status_t status; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t statusCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 8, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->nameType = nameType; + + InP->name = name; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3209; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3309) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size != 68) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->statusType, &statusCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *status = OutP->status; + + return KERN_SUCCESS; +} + +/* Routine mach_port_set_qlimit */ +mig_external kern_return_t mach_port_set_qlimit +( + mach_port_t task, + mach_port_t name, + mach_port_msgcount_t qlimit +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t qlimitType; + mach_port_msgcount_t qlimit; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t qlimitType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->nameType = nameType; + + InP->name = name; + + InP->qlimitType = qlimitType; + + InP->qlimit = qlimit; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3210; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3310) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine mach_port_set_mscount */ +mig_external kern_return_t mach_port_set_mscount +( + mach_port_t task, + mach_port_t name, + mach_port_mscount_t mscount +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t mscountType; + mach_port_mscount_t mscount; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t mscountType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->nameType = nameType; + + InP->name = name; + + InP->mscountType = mscountType; + + InP->mscount = mscount; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3211; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3311) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine mach_port_get_set_status */ +mig_external kern_return_t mach_port_get_set_status +( + mach_port_t task, + mach_port_t name, + mach_port_array_t *members, + mach_msg_type_number_t *membersCnt +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_long_t membersType; + mach_port_array_t members; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->nameType = nameType; + + InP->name = name; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3212; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3312) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 48) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->membersType.msgtl_header.msgt_inline != FALSE) || + (OutP->membersType.msgtl_header.msgt_longform != TRUE) || + (OutP->membersType.msgtl_name != 15) || + (OutP->membersType.msgtl_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *members = OutP->members; + + *membersCnt = OutP->membersType.msgtl_number; + + return KERN_SUCCESS; +} + +/* Routine mach_port_move_member */ +mig_external kern_return_t mach_port_move_member +( + mach_port_t task, + mach_port_t member, + mach_port_t after +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t memberType; + mach_port_t member; + mach_msg_type_t afterType; + mach_port_t after; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t memberType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t afterType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->memberType = memberType; + + InP->member = member; + + InP->afterType = afterType; + + InP->after = after; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3213; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3313) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine mach_port_request_notification */ +mig_external kern_return_t mach_port_request_notification +( + mach_port_t task, + mach_port_t name, + mach_msg_id_t id, + mach_port_mscount_t sync, + mach_port_t notify, + mach_msg_type_name_t notifyPoly, + mach_port_t *previous +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t idType; + mach_msg_id_t id; + mach_msg_type_t syncType; + mach_port_mscount_t sync; + mach_msg_type_t notifyType; + mach_port_t notify; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t previousType; + mach_port_t previous; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + boolean_t msgh_simple = TRUE; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t idType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t syncType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t notifyType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t previousCheck = { + /* msgt_name = */ 18, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->nameType = nameType; + + InP->name = name; + + InP->idType = idType; + + InP->id = id; + + InP->syncType = syncType; + + InP->sync = sync; + + InP->notifyType = notifyType; + + InP->notify = notify; + + if (MACH_MSG_TYPE_PORT_ANY(notifyPoly)) + msgh_simple = FALSE; + + InP->notifyType.msgt_name = notifyPoly; + + InP->Head.msgh_bits = msgh_simple ? + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE) : + (MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE)); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3214; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 56, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3314) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 40) || msgh_simple) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->previousType, &previousCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *previous = OutP->previous; + + return KERN_SUCCESS; +} + +/* Routine mach_port_insert_right */ +mig_external kern_return_t mach_port_insert_right +( + mach_port_t task, + mach_port_t name, + mach_port_t poly, + mach_msg_type_name_t polyPoly +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t polyType; + mach_port_t poly; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + boolean_t msgh_simple = TRUE; + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t polyType = { + /* msgt_name = */ -1, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->nameType = nameType; + + InP->name = name; + + InP->polyType = polyType; + + InP->poly = poly; + + if (MACH_MSG_TYPE_PORT_ANY(polyPoly)) + msgh_simple = FALSE; + + InP->polyType.msgt_name = polyPoly; + + InP->Head.msgh_bits = msgh_simple ? + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE) : + (MACH_MSGH_BITS_COMPLEX| + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE)); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3215; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3315) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} + +/* Routine mach_port_extract_right */ +mig_external kern_return_t mach_port_extract_right +( + mach_port_t task, + mach_port_t name, + mach_msg_type_name_t msgt_name, + mach_port_t *poly, + mach_msg_type_name_t *polyPoly +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t msgt_nameType; + mach_msg_type_name_t msgt_name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t polyType; + mach_port_t poly; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + boolean_t msgh_simple; +#endif /* TypeCheck */ +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t msgt_nameType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->nameType = nameType; + + InP->name = name; + + InP->msgt_nameType = msgt_nameType; + + InP->msgt_name = msgt_name; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3216; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3316) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); + + if (((msgh_size != 40)) && + ((msgh_size != sizeof(mig_reply_header_t)) || + !msgh_simple || + (OutP->RetCode == KERN_SUCCESS))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if ((OutP->polyType.msgt_inline != TRUE) || + (OutP->polyType.msgt_longform != FALSE) || + (MACH_MSG_TYPE_PORT_ANY(OutP->polyType.msgt_name) && msgh_simple) || + (OutP->polyType.msgt_number != 1) || + (OutP->polyType.msgt_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *poly = OutP->poly; + + *polyPoly = OutP->polyType.msgt_name; + + return KERN_SUCCESS; +} + +/* Routine mach_port_get_receive_status */ +mig_external kern_return_t mach_port_get_receive_status +( + mach_port_t task, + mach_port_t name, + mach_port_status_t *status +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + mach_msg_type_t statusType; + mach_port_status_t status; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; +#if TypeCheck + unsigned int msgh_size; +#endif /* TypeCheck */ + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t statusCheck = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 9, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->nameType = nameType; + + InP->name = name; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3217; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3317) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + msgh_size = OutP->Head.msgh_size; + + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + ((msgh_size != 72) && + ((msgh_size != sizeof(mig_reply_header_t)) || + (OutP->RetCode == KERN_SUCCESS)))) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + if (OutP->RetCode != KERN_SUCCESS) + return OutP->RetCode; + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->statusType, &statusCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + *status = OutP->status; + + return KERN_SUCCESS; +} + +/* Routine mach_port_set_seqno */ +mig_external kern_return_t mach_port_set_seqno +( + mach_port_t task, + mach_port_t name, + mach_port_seqno_t seqno +) +{ + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t nameType; + mach_port_t name; + mach_msg_type_t seqnoType; + mach_port_seqno_t seqno; + } Request; + + typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; + } Reply; + + union { + Request In; + Reply Out; + } Mess; + + register Request *InP = &Mess.In; + register Reply *OutP = &Mess.Out; + + mach_msg_return_t msg_result; + + auto const mach_msg_type_t nameType = { + /* msgt_name = */ 15, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t seqnoType = { + /* msgt_name = */ 2, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + auto const mach_msg_type_t RetCodeCheck = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + + InP->nameType = nameType; + + InP->name = name; + + InP->seqnoType = seqnoType; + + InP->seqno = seqno; + + InP->Head.msgh_bits = + MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + /* msgh_size passed as argument */ + InP->Head.msgh_request_port = task; + InP->Head.msgh_reply_port = mig_get_reply_port(); + InP->Head.msgh_seqno = 0; + InP->Head.msgh_id = 3218; + + msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (msg_result != MACH_MSG_SUCCESS) { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return msg_result; + } + mig_put_reply_port(InP->Head.msgh_reply_port); + + if (OutP->Head.msgh_id != 3318) { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) + return MIG_SERVER_DIED; + else { + mig_dealloc_reply_port(InP->Head.msgh_reply_port); + return MIG_REPLY_MISMATCH; + } + } + +#if TypeCheck + if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (OutP->Head.msgh_size != 32)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + +#if TypeCheck + if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) + return MIG_TYPE_ERROR; +#endif /* TypeCheck */ + + return OutP->RetCode; +} diff --git a/tmp/test b/tmp/test Binary files differnew file mode 100755 index 00000000..b30ec5bd --- /dev/null +++ b/tmp/test diff --git a/tmp/test.c b/tmp/test.c new file mode 100644 index 00000000..a58f1d32 --- /dev/null +++ b/tmp/test.c @@ -0,0 +1,95 @@ +#include <mach.h> +#include <mach/notify.h> +#include <hurd.h> + +#include <stdio.h> +#include <stdlib.h> +#include <assert.h> + +int test_change_kernel_port () +{ + task_t task = mach_task_self (); + mach_port_t kernel_port = MACH_PORT_NULL; + mach_port_t receive_port = mach_reply_port (); + kern_return_t err; + + err = mach_port_insert_right (task, receive_port, + receive_port, MACH_MSG_TYPE_MAKE_SEND); + if (err) + error (1, err, "mach_port_insert_right"); + err = task_set_kernel_port (task, receive_port); + if (err) + error (1, err, "task_set_kernel_port"); + err = task_get_kernel_port (task, &kernel_port); + if (err) + error (1, err, "task_get_kernel_port"); + printf ("task: %d, kernel port: %d, orig port: %d, receive port: %d\n", + (mach_task_self) (), kernel_port, task, receive_port); + return 0; +} + +int test_tasks_order () +{ + mach_port_t *psets; + mach_port_t priv_host; + size_t npsets; + int i; + + get_privileged_ports (&priv_host, NULL); + host_processor_sets (mach_host_self (), &psets, &npsets); + for (i = 0; i < npsets; i++) + { + mach_port_t psetpriv; + mach_port_t *tasks; + process_t proc; + size_t ntasks; + int j; + + proc = getproc (); + host_processor_set_priv (priv_host, psets[i], &psetpriv); + processor_set_tasks (psetpriv, &tasks, &ntasks); + printf ("get %d tasks\n", ntasks); + for (j = 0; j < ntasks; j++) + { + pid_t pid; + + printf ("task port (%d): %d\n", j, tasks[j]); + /* The kernel can deliver us an array with null slots in the + middle, e.g. if a task died during the call. */ + if (! MACH_PORT_VALID (tasks[j])) + continue; + proc_task2pid (proc, tasks[j], &pid); + printf ("task %d is valid, pid: %d\n", tasks[j], pid); + + mach_port_deallocate (mach_task_self (), tasks[j]); + } + munmap (tasks, ntasks * sizeof (task_t)); + mach_port_deallocate (mach_task_self (), psetpriv); + mach_port_deallocate (mach_task_self (), psets[i]); + } + munmap (psets, npsets * sizeof (mach_port_t)); + return 0; +} + +int test_port_notification () +{ + mach_port_t receive_port; + mach_port_t foo; + error_t err; + + err = mach_port_allocate (mach_task_self (), + MACH_PORT_RIGHT_RECEIVE, + &receive_port); + assert_perror (err); + err = mach_port_request_notification (mach_task_self (), receive_port, + MACH_NOTIFY_NO_SENDERS, 0, + MACH_PORT_NULL, + MACH_MSG_TYPE_MOVE_SEND_ONCE, &foo); + assert_perror (err); + return 0; +} + +int main () +{ + test_port_notification (); +} diff --git a/tmp/test.c~ b/tmp/test.c~ new file mode 100644 index 00000000..bd069620 --- /dev/null +++ b/tmp/test.c~ @@ -0,0 +1,96 @@ +#include <mach.h> +#include <mach/notify.h> +#include <hurd.h> + +#include <stdio.h> +#include <stdlib.h> +#include <assert.h> + +int test_change_kernel_port () +{ + task_t task = mach_task_self (); + mach_port_t kernel_port = MACH_PORT_NULL; + mach_port_t receive_port = mach_reply_port (); + kern_return_t err; + + err = mach_port_insert_right (task, receive_port, + receive_port, MACH_MSG_TYPE_MAKE_SEND); + if (err) + error (1, err, "mach_port_insert_right"); + err = task_set_kernel_port (task, receive_port); + if (err) + error (1, err, "task_set_kernel_port"); + err = task_get_kernel_port (task, &kernel_port); + if (err) + error (1, err, "task_get_kernel_port"); + printf ("task: %d, kernel port: %d, orig port: %d, receive port: %d\n", + (mach_task_self) (), kernel_port, task, receive_port); + return 0; +} + +int test_tasks_order () +{ + mach_port_t *psets; + mach_port_t priv_host; + size_t npsets; + int i; + + get_privileged_ports (&priv_host, NULL); + host_processor_sets (mach_host_self (), &psets, &npsets); + for (i = 0; i < npsets; i++) + { + mach_port_t psetpriv; + mach_port_t *tasks; + process_t proc; + size_t ntasks; + int j; + + proc = getproc (); + host_processor_set_priv (priv_host, psets[i], &psetpriv); + processor_set_tasks (psetpriv, &tasks, &ntasks); + printf ("get %d tasks\n", ntasks); + for (j = 0; j < ntasks; j++) + { + pid_t pid; + + printf ("task port (%d): %d\n", j, tasks[j]); + /* The kernel can deliver us an array with null slots in the + middle, e.g. if a task died during the call. */ + if (! MACH_PORT_VALID (tasks[j])) + continue; + proc_task2pid (proc, tasks[j], &pid); + printf ("task %d is valid, pid: %d\n", tasks[j], pid); + + mach_port_deallocate (mach_task_self (), tasks[j]); + } + munmap (tasks, ntasks * sizeof (task_t)); + mach_port_deallocate (mach_task_self (), psetpriv); + mach_port_deallocate (mach_task_self (), psets[i]); + } + munmap (psets, npsets * sizeof (mach_port_t)); + return 0; +} + +int test_port_notification () +{ + mach_port_t receive_port; + mach_port_t foo; + error_t err; + + err = mach_port_allocate (mach_task_self (), + MACH_PORT_RIGHT_RECEIVE, + &receive_port); + assert_perror (err); + err = mach_port_request_notification (mach_task_self (), receive_port, + MACH_NOTIFY_NO_SENDERS, 0, + MACH_PORT_NULL, + MACH_MSG_TYPE_MOVE_SEND_ONCE, &foo); + assert_perror (err); + return 0; +} + +int main () +{ + assert (0); + test_port_notification (); +} diff --git a/tmp/test.d b/tmp/test.d new file mode 100644 index 00000000..6120c01c --- /dev/null +++ b/tmp/test.d @@ -0,0 +1,69 @@ +test.o test_pic.o test_p.o test.d: test.c mach.h /usr/local/include/mach/kern_return.h \ + /usr/local/include/mach/machine/kern_return.h \ + /usr/local/include/mach/port.h /usr/local/include/mach/boolean.h \ + /usr/local/include/mach/machine/boolean.h \ + /usr/local/include/mach/machine/vm_types.h \ + /usr/local/include/mach/message.h /usr/local/include/mach/std_types.h \ + /usr/local/include/mach/mach_types.h \ + /usr/local/include/mach/host_info.h /usr/local/include/mach/machine.h \ + /usr/local/include/mach/memory_object.h \ + /usr/local/include/mach/pc_sample.h \ + /usr/local/include/mach/processor_info.h \ + /usr/local/include/mach/task_info.h \ + /usr/local/include/mach/time_value.h \ + /usr/local/include/mach/task_special_ports.h \ + /usr/local/include/mach/thread_info.h /usr/local/include/mach/policy.h \ + /usr/local/include/mach/thread_special_ports.h \ + /usr/local/include/mach/thread_status.h \ + /usr/local/include/mach/machine/thread_status.h \ + /usr/local/include/mach/machine/fp_reg.h \ + /usr/local/include/mach/vm_attributes.h \ + /usr/local/include/mach/vm_inherit.h /usr/local/include/mach/vm_prot.h \ + /usr/local/include/mach/vm_statistics.h \ + /usr/local/include/mach/notify.h /usr/include/hurd.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/gnu/stubs-pthread.h \ + /usr/local/include/mach/mig_errors.h ../hurd/hurd_types.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stddef.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/bits/byteswap.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/pthread/pthreadtypes.h /usr/include/xlocale.h \ + /usr/include/bits/pthread.h /usr/include/bits/thread-attr.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/mutex-attr.h /usr/include/bits/mutex.h \ + /usr/include/bits/spin-lock.h /usr/include/bits/condition-attr.h \ + /usr/include/bits/condition.h /usr/include/bits/rwlock-attr.h \ + /usr/include/bits/rwlock.h /usr/include/bits/barrier-attr.h \ + /usr/include/bits/barrier.h /usr/include/bits/thread-specific.h \ + /usr/include/bits/once.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/hurd/auth.h /usr/local/include/device/device_types.h \ + /usr/local/include/device/net_status.h /usr/local/include/device/bpf.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h \ + /usr/include/sys/statfs.h /usr/include/bits/statfs.h \ + /usr/include/sys/resource.h /usr/include/bits/resource.h \ + /usr/include/sys/utsname.h /usr/include/bits/utsname.h \ + /usr/include/hurd/process.h /usr/include/hurd/fs.h \ + /usr/include/hurd/io.h /usr/include/hurd/port.h \ + /usr/include/hurd/userlink.h /usr/include/hurd/signal.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/sys/ucontext.h /usr/include/bits/sigthread.h \ + /usr/include/hurd/msg.h ../include/cthreads.h \ + ../include/../libthreads/cthreads.h /usr/include/stdlib.h \ + /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \ + /usr/include/alloca.h /usr/local/include/mach/machine/vm_param.h \ + /usr/include/machine-sp.h /usr/include/spin-lock.h \ + /usr/include/lock-intern.h /usr/include/machine-lock.h \ + /usr/include/setjmp.h /usr/include/bits/setjmp.h \ + /usr/include/hurd/threadvar.h /usr/include/stdio.h \ + /usr/lib/gcc/i486-gnu/4.2.4/include/stdarg.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/stdio-lock.h /usr/include/bits/libc-lock.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h /usr/include/assert.h diff --git a/tmp/test.o b/tmp/test.o Binary files differnew file mode 100644 index 00000000..dff3bcdd --- /dev/null +++ b/tmp/test.o diff --git a/tmp/test.prof_d b/tmp/test.prof_d new file mode 100644 index 00000000..3233ded1 --- /dev/null +++ b/tmp/test.prof_d @@ -0,0 +1 @@ +test.prof: test_p.o diff --git a/tmp/test1.c b/tmp/test1.c new file mode 100644 index 00000000..bf560609 --- /dev/null +++ b/tmp/test1.c @@ -0,0 +1,26 @@ +#include <stdio.h> + +#include <hurd.h> +#include <mach.h> + +int main() +{ + pid_t *pp; + size_t npids = 0; + error_t err; + int i; + + err = proc_getallpids (getproc (), &pp, &npids); + if (err) + error (1, err, "get all pids"); + + for (i = 0; i < npids; i++) + { + task_t task = pid2task (pp[i]); + printf ("get task: %d\n", task); +// err = task_terminate (task); +// if (err) +// error (2, err, "terminate task: %d", task); + } + return 0; +} |