Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
// Copyright 2019 Google
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
 
15
#pragma once
16
 
17
#include <mach-o/arch.h>
18
#include <mach-o/loader.h>
19
#include <sys/types.h>
20
 
21
#include <CoreFoundation/CoreFoundation.h>
22
 
23
struct FIRCLSMachOFile {
24
  int fd;
25
  size_t mappedSize;
26
  void* mappedFile;
27
};
28
typedef struct FIRCLSMachOFile* FIRCLSMachOFileRef;
29
 
30
struct FIRCLSMachOSlice {
31
  const void* startAddress;
32
  cpu_type_t cputype;
33
  cpu_subtype_t cpusubtype;
34
};
35
typedef struct FIRCLSMachOSlice* FIRCLSMachOSliceRef;
36
 
37
typedef struct {
38
  uint32_t major;
39
  uint32_t minor;
40
  uint32_t bugfix;
41
} FIRCLSMachOVersion;
42
 
43
typedef struct {
44
  uint64_t addr;
45
  uint64_t size;
46
  uint32_t offset;
47
} FIRCLSMachOSection;
48
 
49
typedef struct {
50
  char segname[16];
51
  uint64_t vmaddr;
52
  uint64_t vmsize;
53
} FIRCLSMachOSegmentCommand;
54
 
55
typedef void (^FIRCLSMachOSliceIterator)(FIRCLSMachOSliceRef slice);
56
typedef void (^FIRCLSMachOLoadCommandIterator)(uint32_t type,
57
                                               uint32_t size,
58
                                               const struct load_command* cmd);
59
 
60
__BEGIN_DECLS
61
 
62
bool FIRCLSMachOFileInitWithPath(FIRCLSMachOFileRef file, const char* path);
63
bool FIRCLSMachOFileInitWithCurrent(FIRCLSMachOFileRef file);
64
void FIRCLSMachOFileDestroy(FIRCLSMachOFileRef file);
65
void FIRCLSMachOFileEnumerateSlices(FIRCLSMachOFileRef file, FIRCLSMachOSliceIterator block);
66
struct FIRCLSMachOSlice FIRCLSMachOFileSliceWithArchitectureName(FIRCLSMachOFileRef file,
67
                                                                 const char* name);
68
 
69
void FIRCLSMachOEnumerateSlicesAtAddress(void* executableData, FIRCLSMachOSliceIterator block);
70
void FIRCLSMachOSliceEnumerateLoadCommands(FIRCLSMachOSliceRef slice,
71
                                           FIRCLSMachOLoadCommandIterator block);
72
struct FIRCLSMachOSlice FIRCLSMachOSliceGetCurrent(void);
73
struct FIRCLSMachOSlice FIRCLSMachOSliceWithHeader(void* machHeader);
74
 
75
const char* FIRCLSMachOSliceGetExecutablePath(FIRCLSMachOSliceRef slice);
76
const char* FIRCLSMachOSliceGetArchitectureName(FIRCLSMachOSliceRef slice);
77
bool FIRCLSMachOSliceIs64Bit(FIRCLSMachOSliceRef slice);
78
bool FIRCLSMachOSliceGetSectionByName(FIRCLSMachOSliceRef slice,
79
                                      const char* segName,
80
                                      const char* sectionName,
81
                                      const void** ptr);
82
bool FIRCLSMachOSliceInitSectionByName(FIRCLSMachOSliceRef slice,
83
                                       const char* segName,
84
                                       const char* sectionName,
85
                                       FIRCLSMachOSection* section);
86
void FIRCLSMachOSliceGetUnwindInformation(FIRCLSMachOSliceRef slice,
87
                                          const void** ehFrame,
88
                                          const void** unwindInfo);
89
 
90
// load-command-specific calls for convenience
91
 
92
// returns a pointer to the 16-byte UUID
93
uint8_t const* FIRCLSMachOGetUUID(const struct load_command* cmd);
94
const char* FIRCLSMachOGetDylibPath(const struct load_command* cmd);
95
 
96
// return true if the header indicates the binary is encrypted
97
bool FIRCLSMachOGetEncrypted(const struct load_command* cmd);
98
 
99
// SDK minimums
100
FIRCLSMachOVersion FIRCLSMachOGetMinimumOSVersion(const struct load_command* cmd);
101
FIRCLSMachOVersion FIRCLSMachOGetLinkedSDKVersion(const struct load_command* cmd);
102
 
103
// Helpers
104
FIRCLSMachOSegmentCommand FIRCLSMachOGetSegmentCommand(const struct load_command* cmd);
105
 
106
#ifdef __OBJC__
107
NSString* FIRCLSMachONormalizeUUID(CFUUIDBytes* uuidBytes);
108
NSString* FIRCLSMachOFormatVersion(FIRCLSMachOVersion* version);
109
#endif
110
__END_DECLS