blob: fbf643f13c72b5facdd999074fe03a82a9b75abc [file] [log] [blame]
Dave Tapuska6cd52722023-03-06 20:25:291// Copyright 2023 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef BASE_IOS_SIM_HEADER_SHIMS_H_
6#define BASE_IOS_SIM_HEADER_SHIMS_H_
7
8#include "build/blink_buildflags.h"
9
10#if !BUILDFLAG(USE_BLINK)
11#error File can only be included when USE_BLINK is true
12#endif
13
Dave Tapuskaed322d02023-03-07 23:33:3314#include <mach/kern_return.h>
15#include <mach/message.h>
Gyuyoung Kim3439dbbd2023-08-19 03:38:5916#include <stdint.h>
Dave Tapuskaed322d02023-03-07 23:33:3317#include <sys/param.h>
18
Dave Tapuska6cd52722023-03-06 20:25:2919// This file includes the necessary headers that are not part of the
Gyuyoung Kim52e9337892023-04-20 15:08:4120// iOS public SDK in order to support multiprocess and memory instrumentations
21// on iOS.
Dave Tapuska6cd52722023-03-06 20:25:2922
23__BEGIN_DECLS
24
25#define BOOTSTRAP_MAX_NAME_LEN 128
26typedef char name_t[BOOTSTRAP_MAX_NAME_LEN];
27kern_return_t bootstrap_check_in(mach_port_t bp,
28 const name_t service_name,
29 mach_port_t* sp);
30kern_return_t bootstrap_look_up(mach_port_t bp,
31 const name_t service_name,
32 mach_port_t* sp);
33pid_t audit_token_to_pid(audit_token_t atoken);
34
35const char* bootstrap_strerror(kern_return_t r);
36#define BOOTSTRAP_SUCCESS 0
37#define BOOTSTRAP_NOT_PRIVILEGED 1100
38#define BOOTSTRAP_NAME_IN_USE 1101
39#define BOOTSTRAP_UNKNOWN_SERVICE 1102
40#define BOOTSTRAP_SERVICE_ACTIVE 1103
41#define BOOTSTRAP_BAD_COUNT 1104
42#define BOOTSTRAP_NO_MEMORY 1105
43#define BOOTSTRAP_NO_CHILDREN 1106
44
Gyuyoung Kim52e9337892023-04-20 15:08:4145// These values are copied from darwin-xnu/osfmk/mach/shared_region.h.
46// https://github.com/apple/darwin-xnu/blob/8f02f2a044b9bb1ad951987ef5bab20ec9486310/osfmk/mach/shared_region.h#L86-L87
47#define SHARED_REGION_BASE_ARM64 0x180000000ULL
48#define SHARED_REGION_SIZE_ARM64 0x100000000ULL
49
Gyuyoung Kim3439dbbd2023-08-19 03:38:5950int proc_pidinfo(int pid,
51 int flavor,
52 uint64_t arg,
53 void* buffer,
54 int buffersize);
Dave Tapuskaed322d02023-03-07 23:33:3355int proc_pidpath(int pid, void* buffer, uint32_t buffersize);
Gyuyoung Kim52e9337892023-04-20 15:08:4156int proc_regionfilename(int pid,
57 uint64_t address,
58 void* buffer,
59 uint32_t buffersize);
Gyuyoung Kim3439dbbd2023-08-19 03:38:5960
Dave Tapuskaed322d02023-03-07 23:33:3361#define PROC_PIDPATHINFO_MAXSIZE (4 * MAXPATHLEN)
62
Gyuyoung Kim3439dbbd2023-08-19 03:38:5963// These values are copied from xnu/xnu-4570.1.46/bsd/sys/proc_info.h.
64// https://opensource.apple.com/source/xnu/xnu-4570.1.46/bsd/sys/proc_info.h#L697-L710
65struct proc_fdinfo {
66 int32_t proc_fd;
67 uint32_t proc_fdtype;
68};
69#define PROC_PIDLISTFDS 1
70#define PROC_PIDLISTFD_SIZE (sizeof(struct proc_fdinfo))
71
Dave Tapuska6cd52722023-03-06 20:25:2972__END_DECLS
73
Dave Tapuskaed322d02023-03-07 23:33:3374#endif // BASE_IOS_SIM_HEADER_SHIMS_H_