• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // 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 
14 #include <mach/kern_return.h>
15 #include <mach/message.h>
16 #include <sys/param.h>
17 
18 // This file includes the necessary headers that are not part of the
19 // iOS public SDK in order to support multiprocess and memory instrumentations
20 // on iOS.
21 
22 __BEGIN_DECLS
23 
24 #define BOOTSTRAP_MAX_NAME_LEN 128
25 typedef char name_t[BOOTSTRAP_MAX_NAME_LEN];
26 kern_return_t bootstrap_check_in(mach_port_t bp,
27                                  const name_t service_name,
28                                  mach_port_t* sp);
29 kern_return_t bootstrap_look_up(mach_port_t bp,
30                                 const name_t service_name,
31                                 mach_port_t* sp);
32 pid_t audit_token_to_pid(audit_token_t atoken);
33 
34 const char* bootstrap_strerror(kern_return_t r);
35 #define BOOTSTRAP_SUCCESS 0
36 #define BOOTSTRAP_NOT_PRIVILEGED 1100
37 #define BOOTSTRAP_NAME_IN_USE 1101
38 #define BOOTSTRAP_UNKNOWN_SERVICE 1102
39 #define BOOTSTRAP_SERVICE_ACTIVE 1103
40 #define BOOTSTRAP_BAD_COUNT 1104
41 #define BOOTSTRAP_NO_MEMORY 1105
42 #define BOOTSTRAP_NO_CHILDREN 1106
43 
44 // These values are copied from darwin-xnu/osfmk/mach/shared_region.h.
45 // https://github.com/apple/darwin-xnu/blob/8f02f2a044b9bb1ad951987ef5bab20ec9486310/osfmk/mach/shared_region.h#L86-L87
46 #define SHARED_REGION_BASE_ARM64 0x180000000ULL
47 #define SHARED_REGION_SIZE_ARM64 0x100000000ULL
48 
49 int proc_pidpath(int pid, void* buffer, uint32_t buffersize);
50 int proc_regionfilename(int pid,
51                         uint64_t address,
52                         void* buffer,
53                         uint32_t buffersize);
54 #define PROC_PIDPATHINFO_MAXSIZE (4 * MAXPATHLEN)
55 
56 __END_DECLS
57 
58 #endif  // BASE_IOS_SIM_HEADER_SHIMS_H_
59