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 <stdint.h> 17 #include <sys/param.h> 18 19 // This file includes the necessary headers that are not part of the 20 // iOS public SDK in order to support multiprocess and memory instrumentations 21 // on iOS. 22 23 __BEGIN_DECLS 24 25 #define BOOTSTRAP_MAX_NAME_LEN 128 26 typedef char name_t[BOOTSTRAP_MAX_NAME_LEN]; 27 kern_return_t bootstrap_check_in(mach_port_t bp, 28 const name_t service_name, 29 mach_port_t* sp); 30 kern_return_t bootstrap_look_up(mach_port_t bp, 31 const name_t service_name, 32 mach_port_t* sp); 33 pid_t audit_token_to_pid(audit_token_t atoken); 34 35 const 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 45 // 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 50 int proc_pidinfo(int pid, 51 int flavor, 52 uint64_t arg, 53 void* buffer, 54 int buffersize); 55 int proc_pidpath(int pid, void* buffer, uint32_t buffersize); 56 int proc_regionfilename(int pid, 57 uint64_t address, 58 void* buffer, 59 uint32_t buffersize); 60 61 #define PROC_PIDPATHINFO_MAXSIZE (4 * MAXPATHLEN) 62 63 // 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 65 struct 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 72 __END_DECLS 73 74 #endif // BASE_IOS_SIM_HEADER_SHIMS_H_ 75