Rizin
unix-like reverse engineering framework and cli tools
|
#include <rz_userconf.h>
#include <rz_util.h>
#include <ctype.h>
#include "file.h"
#include "patchlevel.h"
#include "mdump.c"
Go to the source code of this file.
Classes | |
struct | rz_magic_entry |
struct | type_tbl_s |
Macros | |
#define | QUICK 0 |
#define | EATAB |
#define | LOWCASE(l) (isupper((ut8)(l)) ? tolower((ut8)(l)) : (l)) |
#define | MAP_FILE 0 |
#define | XX(s) s, (sizeof(s) - 1) |
#define | XX_NULL "", 0 |
#define | MULT 10 |
#define | SYMLEN 4 /* strlen("text") */ |
#define | ALLOC_CHUNK (size_t)10 |
#define | ALLOC_INCR (size_t)200 |
#define | RET 1 |
Functions | |
static int | getvalue (RzMagic *ms, struct rz_magic *, const char **, int) |
static int | hextoint (int) |
static const char * | getstr (RzMagic *, const char *, char *, int, int *, int) |
static int | parse (RzMagic *, struct rz_magic_entry **, ut32 *, const char *, size_t, int) |
static int | parse_mime (RzMagic *, struct rz_magic_entry **, ut32 *, const char *) |
static void | eatsize (const char **) |
static int | apprentice_1 (RzMagic *, const char *, int, struct mlist *) |
static size_t | apprentice_r_magic_strength (const struct rz_magic *) |
static int | apprentice_sort (const void *, const void *) |
static int | apprentice_load (RzMagic *, struct rz_magic **, ut32 *, const char *, int) |
static void | byteswap (struct rz_magic *, ut32) |
static void | bs1 (struct rz_magic *) |
static ut16 | swap2 (ut16) |
static ut32 | swap4 (ut32) |
static ut64 | swap8 (ut64) |
static char * | mkdbname (const char *, int) |
static int | apprentice_map (RzMagic *, struct rz_magic **, ut32 *, const char *) |
static int | apprentice_compile (RzMagic *, struct rz_magic **, ut32 *, const char *) |
static int | check_format_type (const char *, int) |
static int | check_format (RzMagic *, struct rz_magic *) |
static int | get_op (char) |
static int | get_type (const char *l, const char **t) |
static void | init_file_tables (void) |
void | file_delmagic (struct rz_magic *p, int type, size_t entries) |
struct mlist * | file_apprentice (RzMagic *ms, const char *fn, int action) |
static void | set_test_type (struct rz_magic *mstart, struct rz_magic *m) |
static const char * | bgets (char *line, size_t line_sz, const char *data) |
static void | load_b (RzMagic *ms, int action, const char *data, int *errs, struct rz_magic_entry **marray, ut32 *marraycount) |
static void | load_1 (RzMagic *ms, int action, const char *file, int *errs, struct rz_magic_entry **marray, ut32 *marraycount) |
ut64 | file_signextend (RzMagic *ms, struct rz_magic *m, ut64 v) |
static int | string_modifier_check (RzMagic *ms, struct rz_magic *m) |
static int | get_cond (const char *l, const char **t) |
static int | check_cond (RzMagic *ms, int cond, ut32 cont_level) |
void | file_showstr (FILE *fp, const char *s, size_t len) |
Variables | |
static int | magic_file_formats [FILE_NAMES_SIZE] |
static const size_t | file_nformats = FILE_NAMES_SIZE |
static const char * | magic_file_names [FILE_NAMES_SIZE] |
static const size_t | file_nnames = FILE_NAMES_SIZE |
static size_t | maxmagic = 0 |
static size_t | magicsize = sizeof(struct rz_magic) |
static const char | usg_hdr [] = "cont\toffset\ttype\topcode\tmask\tvalue\tdesc" |
static const char | mime_marker [] = "!:mime" |
static const size_t | mime_marker_len = sizeof(mime_marker) - 1 |
static const struct type_tbl_s | type_tbl [] |
static const ut32 | ar [] |
static const char | ext [] = ".mgc" |
#define ALLOC_CHUNK (size_t)10 |
#define ALLOC_INCR (size_t)200 |
#define EATAB |
Definition at line 57 of file apprentice.c.
Definition at line 63 of file apprentice.c.
#define MAP_FILE 0 |
Definition at line 66 of file apprentice.c.
#define MULT 10 |
#define QUICK 0 |
Definition at line 46 of file apprentice.c.
#define RET 1 |
#define SYMLEN 4 /* strlen("text") */ |
#define XX_NULL "", 0 |
Definition at line 193 of file apprentice.c.
References test-lz4-speed::action, apprentice_compile(), apprentice_load(), apprentice_map(), file_delmagic(), file_error(), file_oomem(), fn, free(), magicsize, malloc(), and NULL.
Referenced by file_apprentice().
|
static |
Definition at line 1942 of file apprentice.c.
References ar, close, fd, file_error(), fn, free(), lseek, mkdbname(), O_BINARY, O_CREAT, O_TRUNC, O_WRONLY, out, rz_sys_open(), SEEK_SET, and write.
Referenced by apprentice_1().
|
static |
Definition at line 593 of file apprentice.c.
References test-lz4-speed::action, apprentice_sort(), calloc(), rz_magic_entry::cont_count, d, eprintf, file_magwarn(), file_oomem(), fn, free(), HANDLE, i, INVALID_HANDLE_VALUE, isspace, L, load_1(), malloc(), maxmagic, memcpy(), rz_magic_entry::mp, NULL, out, p, qsort(), readdir, S_ISDIR, S_ISREG, set_test_type(), snprintf, stat, SYMLEN, and usg_hdr.
Referenced by apprentice_1().
|
static |
Definition at line 1836 of file apprentice.c.
References byteswap(), close, fd, file_badread(), file_error(), file_oomem(), FILE_VERSION_MAJOR, fn, free(), fstat, malloc(), MAP_FILE, MAP_PRIVATE, mkdbname(), mmap, munmap, NULL, O_BINARY, O_RDONLY, patchlevel, PROT_READ, read(), RET, rz_sys_open(), swap4(), and version.
Referenced by apprentice_1().
Definition at line 325 of file apprentice.c.
References eprintf, regress::m, MULT, RZ_MAX, and val.
Referenced by apprentice_sort().
Definition at line 416 of file apprentice.c.
References a, apprentice_r_magic_strength(), b, rz_magic_entry::mp, and sb.
Referenced by apprentice_load().
Definition at line 491 of file apprentice.c.
References setup::line, NULL, RZ_MIN, and rz_str_ncpy().
Referenced by load_b().
|
static |
Definition at line 2076 of file apprentice.c.
References regress::m, swap2(), swap4(), and swap8().
Referenced by byteswap().
|
static |
Definition at line 914 of file apprentice.c.
References cond, and file_magwarn().
Referenced by parse().
|
static |
Definition at line 1515 of file apprentice.c.
References check_format_type(), file_magwarn(), file_nformats, file_nnames, regress::m, magic_file_formats, and magic_file_names.
Referenced by parse().
|
static |
Definition at line 277 of file apprentice.c.
References test-lz4-speed::action, apprentice_1(), file_error(), file_oomem(), fn, free(), init_file_tables(), malloc(), NULL, p, RZ_FREE, RZ_MAX, and strdup().
Referenced by rz_magic_check(), rz_magic_compile(), rz_magic_load(), and rz_magic_load_buffer().
Definition at line 255 of file apprentice.c.
References entries(), munmap, p, RZ_FREE, and type.
Referenced by apprentice_1(), and free_mlist().
Definition at line 757 of file apprentice.c.
References file_magwarn(), regress::m, UNSIGNED, and v.
Referenced by getvalue(), magiccheck(), mprint(), and parse().
Definition at line 889 of file apprentice.c.
References cond, isspace, len, and p.
Referenced by parse().
|
static |
Definition at line 160 of file apprentice.c.
Referenced by parse().
|
static |
Definition at line 1637 of file apprentice.c.
References test-lz4-speed::action, c, file_error(), file_magwarn(), hextoint(), isprint, isspace, NULL, out, p, s, and val.
Referenced by getvalue().
Definition at line 1574 of file apprentice.c.
References test-lz4-speed::action, eatsize(), file_magwarn(), file_signextend(), test-lz4-speed::float, getstr(), regress::m, p, and ut64().
Referenced by parse().
|
static |
Definition at line 174 of file apprentice.c.
References done, magic_file_formats, magic_file_names, p, and type_tbl.
Referenced by file_apprentice().
|
static |
Definition at line 542 of file apprentice.c.
References test-lz4-speed::action, ENOENT, f, benchmark::FILE, file_error(), len, setup::line, load_b(), mime_marker, mime_marker_len, NULL, parse(), parse_mime(), and rz_sys_fopen().
Referenced by apprentice_load().
|
static |
Definition at line 506 of file apprentice.c.
References test-lz4-speed::action, bgets(), len, setup::line, mime_marker, mime_marker_len, NULL, parse(), and parse_mime().
Referenced by load_1().
Definition at line 1985 of file apprentice.c.
References ext, fn, malloc(), memcpy(), NULL, p, and cmd_descs_generate::strip().
Referenced by apprentice_compile(), and apprentice_map().
|
static |
Definition at line 958 of file apprentice.c.
References test-lz4-speed::action, ALLOC_CHUNK, ALLOC_INCR, check_cond(), check_format(), rz_magic_entry::cont_count, EATAB, eatsize(), file_check_mem(), file_error(), file_magwarn(), file_mdump(), file_oomem(), file_signextend(), get_cond(), get_op(), get_type(), getvalue(), i, isdigit, isspace, setup::line, regress::m, malloc(), rz_magic_entry::max_count, maxmagic, memset(), rz_magic_entry::mp, op, realloc(), string_modifier_check(), UNSIGNED, ut64(), and val.
|
static |
Definition at line 1341 of file apprentice.c.
References rz_magic_entry::cont_count, EATAB, file_error(), file_magwarn(), i, isalnum, setup::line, regress::m, and rz_magic_entry::mp.
|
static |
Definition at line 430 of file apprentice.c.
References file_looks_utf8(), regress::m, and NULL.
Referenced by apprentice_load().
|
static |
Definition at line 823 of file apprentice.c.
References file_magwarn(), and regress::m.
Referenced by parse().
Definition at line 1935 of file apprentice.c.
Referenced by apprentice_compile(), jemalloc_get_bins(), jemalloc_get_chunks(), jemalloc_print_narenas(), reloc_cmp(), and reloc_target_cmp().
|
static |
Definition at line 1981 of file apprentice.c.
Referenced by __isScriptFilename(), aarch64_wide_constant_p(), arc_sprintf(), build_3bit_d(), build_3bit_ea(), build_absolute_jump_with_immediate(), build_bitfield_ins(), build_cas2(), build_chk2_cmp2(), build_cpush_cinv(), build_d(), build_d_d_ea(), build_dbxx(), build_ea(), build_ea_a(), build_ea_ea(), build_er_gen_1(), build_imm(), build_imm_ea(), build_imm_special_reg(), build_init_op(), build_link(), build_mm(), build_move16(), build_movem_er(), build_movem_re(), build_movep_er(), build_movep_re(), build_moves(), build_pi_pi(), build_r(), build_re_gen_1(), build_relative_branch(), build_rr(), convert_dot_to_image(), d68000_exg_aa(), d68000_exg_da(), d68000_jmp(), d68000_jsr(), d68000_move_fr_sr(), d68000_move_fr_usp(), d68000_move_to_ccr(), d68000_move_to_sr(), d68000_move_to_usp(), d68000_moveq(), d68000_scc(), d68000_unlk(), d68010_move_fr_ccr(), d68010_movec(), d68020_bfins(), d68020_cpbcc_16(), d68020_cpbcc_32(), d68020_cpdbcc(), d68020_cpgen(), d68020_cprestore(), d68020_cpsave(), d68020_cpscc(), d68020_cptrapcc_16(), d68020_cptrapcc_32(), d68020_divl(), d68020_mull(), d68020_rtm(), extend(), fmove_fpcr(), fmovem(), load_buffer(), log_mark(), m68k_disassemble(), M68K_printInst(), mkdbname(), my_sprintf(), rz_core_run_script(), rz_file_is_c(), rz_lang_get_by_extension(), rz_x509_parse_extension(), rz_x509_parse_extensions(), and search_path_join_test().
Definition at line 76 of file apprentice.c.
Referenced by check_format().
Definition at line 78 of file apprentice.c.
Referenced by check_format(), and file_mdump().
|
static |
Definition at line 75 of file apprentice.c.
Referenced by check_format(), and init_file_tables().
|
static |
Definition at line 77 of file apprentice.c.
Referenced by check_format(), file_mdump(), and init_file_tables().
|
static |
Definition at line 103 of file apprentice.c.
Referenced by apprentice_1().
|
static |
Definition at line 102 of file apprentice.c.
Referenced by apprentice_load(), and parse().
|
static |
Definition at line 106 of file apprentice.c.
|
static |
Definition at line 107 of file apprentice.c.
|
static |
Referenced by get_type(), and init_file_tables().
|
static |
Definition at line 105 of file apprentice.c.
Referenced by apprentice_load().