6 #define RZ_BIN_MACH064 1
10 #include "../format/mach0/kernelcache.h"
16 if (!memcmp(
buf,
"\xfe\xed\xfa\xcf", 4)) {
19 if (!memcmp(
buf,
"\xcf\xfa\xed\xfe", 4)) {
27 const bool use_pagezero =
true;
28 const bool use_main =
true;
29 const bool use_dylinker =
true;
30 const bool use_libsystem =
true;
31 const bool use_linkedit =
true;
32 ut64 filesize, codeva, datava;
33 ut32 ncmds, magiclen, headerlen;
34 ut64 p_codefsz = 0, p_codeva = 0, p_codesz = 0, p_codepa = 0;
35 ut64 p_datafsz = 0, p_datava = 0, p_datasz = 0, p_datapa = 0;
36 ut64 p_cmdsize = 0, p_entry = 0, p_tmp = 0;
41 #define B(x, y) rz_buf_append_bytes(buf, (const ut8 *)(x), y)
42 #define D(x) rz_buf_append_ut32(buf, x)
43 #define Q(x) rz_buf_append_ut64(buf, x)
44 #define Z(x) rz_buf_append_nbytes(buf, x)
45 #define W(x, y, z) rz_buf_write_at(buf, x, (const ut8 *)(y), z)
47 p_tmp = rz_buf_size(buf); \
49 W(p_tmp, y, strlen(y))
53 B(
"\xcf\xfa\xed\xfe", 4);
59 ncmds = (data && datalen > 0) ? 3 : 2;
129 if (data && datalen > 0) {
135 W(p_tmp,
"__TEXT", 6);
171 WZ(16,
"__LINKEDIT");
192 Z(18 *
sizeof(
ut32));
195 const char *dyld =
"/usr/lib/dyld";
196 const int dyld_len = strlen(dyld) + 1;
198 D((4 * 3) + dyld_len);
204 const char *lib =
"/usr/lib/libSystem.B.dylib";
205 const int lib_len = strlen(lib) + 1;
224 #define STATESIZE (21 * sizeof(ut64))
241 W(p_entry, &codeva, 8);
245 W(p_cmdsize, &headerlen, 4);
246 filesize = magiclen + headerlen + codelen + datalen;
248 W(p_codefsz, &filesize, 8);
249 W(p_codefsz - 16, &filesize, 8);
250 W(p_codeva, &codeva, 8);
253 W(p_codesz, &clen, 8);
255 p_tmp = codeva -
baddr;
256 W(p_codepa, &p_tmp, 8);
260 if (data && datalen > 0) {
262 W(p_datafsz, &filesize, 8);
263 W(p_datava, &datava, 8);
264 W(p_datasz, &datalen, 8);
265 p_tmp = datava -
baddr;
266 W(p_datapa, &p_tmp, 8);
296 .desc =
"mach064 bin plugin",
323 #ifndef RZ_PLUGIN_INCORE
RZ_API RZ_OWN RzList * rz_bin_file_strings(RZ_NONNULL RzBinFile *bf, size_t min_length, bool raw_strings)
Generates a RzList struct containing RzBinString from a given RzBinFile.
static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb)
static void destroy(RzBinFile *bf)
static ut64 baddr(RzBinFile *bf)
static Sdb * get_sdb(RzBinFile *bf)
static RzList * maps(RzBinFile *bf)
static RzList * virtual_files(RzBinFile *bf)
static RzList * libs(RzBinFile *bf)
static RzList * classes(RzBinFile *bf)
static RzBinAddr * binsym(RzBinFile *bf, RzBinSpecialSymbol sym)
static RzBuffer * create(RzBin *bin, const ut8 *code, int codelen, const ut8 *data, int datalen, RzBinArchOptions *opt)
static RzList * strings(RzBinFile *bf)
RZ_API RzLibStruct rizin_plugin
static bool check_buffer(RzBuffer *b)
RzBinPlugin rz_bin_plugin_mach064
static char * entitlements(RzBinFile *bf, bool json)
RzList * entries(RzBinFile *bf)
RzBinInfo * info(RzBinFile *bf)
RzList * symbols(RzBinFile *bf)
RzList * imports(RzBinFile *bf)
RzList * sections(RzBinFile *bf)
RzList * relocs(RzBinFile *bf)
RZ_API bool rz_xnu_kernelcache_buf_is_kernelcache(RzBuffer *b)
RzList *MACH0_() mach_fields(RzBinFile *bf)
char *MACH0_() section_type_to_string(ut64 type)
RzList *MACH0_() section_flag_to_rzlist(ut64 flag)
void MACH0_() mach_headerfields(RzBinFile *bf)
ut64 MACH0_() get_main(struct MACH0_(obj_t) *bin)
@ RZ_BIN_SPECIAL_SYMBOL_MAIN
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
RZ_API RZ_OWN RzBuffer * rz_buf_new_with_bytes(RZ_NULLABLE RZ_BORROW const ut8 *bytes, ut64 len)
Creates a new buffer with a bytes array.
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
XX curplugin == o->plugin.
ut64(WINAPI *w32_GetEnabledXStateFeatures)()