17 #define RZ_FLIRT_NAME_MAX 1024
18 #define RZ_FLIRT_LIBRARY_NAME_MAX 0xFF
19 #define RZ_FLIRT_LIBRARY_NAME_DFL "Built with rizin " RZ_VERSION
20 #define RZ_FLIRT_MAX_PRELUDE_SIZE (32)
103 #define RZ_FLIRT_SIG_FILE_DOS_EXE_OLD 0x00000001
104 #define RZ_FLIRT_SIG_FILE_DOS_COM_OLD 0x00000002
105 #define RZ_FLIRT_SIG_FILE_BIN 0x00000004
106 #define RZ_FLIRT_SIG_FILE_DOSDRV 0x00000008
107 #define RZ_FLIRT_SIG_FILE_NE 0x00000010
108 #define RZ_FLIRT_SIG_FILE_INTELHEX 0x00000020
109 #define RZ_FLIRT_SIG_FILE_MOSHEX 0x00000040
110 #define RZ_FLIRT_SIG_FILE_LX 0x00000080
111 #define RZ_FLIRT_SIG_FILE_LE 0x00000100
112 #define RZ_FLIRT_SIG_FILE_NLM 0x00000200
113 #define RZ_FLIRT_SIG_FILE_COFF 0x00000400
114 #define RZ_FLIRT_SIG_FILE_PE 0x00000800
115 #define RZ_FLIRT_SIG_FILE_OMF 0x00001000
116 #define RZ_FLIRT_SIG_FILE_SREC 0x00002000
117 #define RZ_FLIRT_SIG_FILE_ZIP 0x00004000
118 #define RZ_FLIRT_SIG_FILE_OMFLIB 0x00008000
119 #define RZ_FLIRT_SIG_FILE_AR 0x00010000
120 #define RZ_FLIRT_SIG_FILE_LOADER 0x00020000
121 #define RZ_FLIRT_SIG_FILE_ELF 0x00040000
122 #define RZ_FLIRT_SIG_FILE_W32RUN 0x00080000
123 #define RZ_FLIRT_SIG_FILE_AOUT 0x00100000
124 #define RZ_FLIRT_SIG_FILE_PILOT 0x00200000
125 #define RZ_FLIRT_SIG_FILE_DOS_EXE 0x00400000
126 #define RZ_FLIRT_SIG_FILE_DOS_COM 0x00800000
127 #define RZ_FLIRT_SIG_FILE_AIXAR 0x01000000
128 #define RZ_FLIRT_SIG_FILE_ALL 0xFFFFFFFF
131 #define RZ_FLIRT_SIG_OS_MSDOS 0x0001
132 #define RZ_FLIRT_SIG_OS_WIN 0x0002
133 #define RZ_FLIRT_SIG_OS_OS2 0x0004
134 #define RZ_FLIRT_SIG_OS_NETWARE 0x0008
135 #define RZ_FLIRT_SIG_OS_UNIX 0x0010
136 #define RZ_FLIRT_SIG_OS_OTHER 0x0020
137 #define RZ_FLIRT_SIG_OS_ALL 0xFFFF
140 #define RZ_FLIRT_SIG_APP_CONSOLE 0x0001
141 #define RZ_FLIRT_SIG_APP_GRAPHICS 0x0002
142 #define RZ_FLIRT_SIG_APP_EXE 0x0004
143 #define RZ_FLIRT_SIG_APP_DLL 0x0008
144 #define RZ_FLIRT_SIG_APP_DRV 0x0010
145 #define RZ_FLIRT_SIG_APP_SINGLE_THREADED 0x0020
146 #define RZ_FLIRT_SIG_APP_MULTI_THREADED 0x0040
147 #define RZ_FLIRT_SIG_APP_16_BIT 0x0080
148 #define RZ_FLIRT_SIG_APP_32_BIT 0x0100
149 #define RZ_FLIRT_SIG_APP_64_BIT 0x0200
150 #define RZ_FLIRT_SIG_APP_ALL 0xFFFF
RzBinInfo * info(RzBinFile *bf)
static const char struct stat static buf struct stat static buf static vhangup int options
RZ_API RZ_OWN RzFlirtNode * rz_sign_flirt_parse_string_pattern_from_buffer(RZ_NONNULL RzBuffer *flirt_buf, ut32 optimization, RZ_NULLABLE RzFlirtInfo *info)
Parses the RzBuffer containing a FLIRT signature in string format and returns an RzFlirtNode.
RZ_API void rz_sign_flirt_node_free(RZ_NULLABLE RzFlirtNode *node)
Frees an RzFlirtNode struct.
RZ_API bool rz_sign_sigdb_merge(RZ_NONNULL RzSigDb *db, RZ_NONNULL RzSigDb *db2)
Merge the signatures from db2 into db.
RZ_API RZ_OWN bool rz_sign_flirt_parse_header_compressed_pattern_from_buffer(RZ_NONNULL RzBuffer *flirt_buf, RZ_NONNULL RzFlirtInfo *info)
Parses the RzBuffer containing a FLIRT structure and returns an RzFlirtInfo.
struct rz_flirt_compressed_options_t RzFlirtCompressedOptions
RZ_API RZ_OWN RzFlirtNode * rz_sign_flirt_node_new(RZ_NONNULL RzAnalysis *analysis, ut32 optimization)
Generates the FLIRT signatures and returns an RzFlirtNode.
struct rz_flirt_node_t RzFlirtNode
RZ_API void rz_sign_flirt_info_fini(RZ_NULLABLE RzFlirtInfo *info)
Frees an RzFlirtInfo struct elements without freeing the pointer.
RZ_API ut32 rz_sign_flirt_node_count_nodes(RZ_NONNULL const RzFlirtNode *node)
Counts the number of FLIRT signatures in the node.
RZ_API RZ_OWN RzSigDb * rz_sign_sigdb_new(void)
Create a new empty RzSigDb instance.
struct rz_flirt_module_t RzFlirtModule
RZ_API bool rz_sign_flirt_write_string_pattern_to_buffer(RZ_NONNULL const RzFlirtNode *node, RZ_NONNULL RzBuffer *buffer)
Writes in the the RzBuffer the FLIRT signatures in string format.
struct rz_flirt_function_t RzFlirtFunction
struct rz_flirt_tail_byte_t RzFlirtTailByte
RZ_API void rz_sign_sigdb_free(RzSigDb *db)
rz_flirt_node_optimization_t
@ RZ_FLIRT_NODE_OPTIMIZE_NONE
keeps the structure flattened (keep the tail bytes)
@ RZ_FLIRT_NODE_OPTIMIZE_NORMAL
optimize the tree structure (keeps the tail bytes)
@ RZ_FLIRT_NODE_OPTIMIZE_MAX
optimize the tree structure and drops the tail bytes
RZ_API bool rz_sign_flirt_apply(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL const char *flirt_file, ut8 expected_arch)
Parses the FLIRT file and applies the signatures.
struct rz_signature_database_entry_t RzSigDBEntry
struct rz_flirt_info_t RzFlirtInfo
RZ_API RZ_OWN RzList * rz_sign_sigdb_list(RZ_NONNULL const RzSigDb *db)
Return the signature database as a list of entries.
struct rz_signature_db_t RzSigDb
struct rz_flirt_sig_info_t RzFlirtSigInfo
RZ_API RZ_OWN RzFlirtNode * rz_sign_flirt_parse_compressed_pattern_from_buffer(RZ_NONNULL RzBuffer *flirt_buf, ut8 expected_arch, RZ_NULLABLE RzFlirtInfo *info)
Parses the RzBuffer containing a FLIRT structure and returns an RzFlirtNode.
struct rz_flirt_pat_info_t RzFlirtPatInfo
RZ_API bool rz_sign_flirt_write_compressed_pattern_to_buffer(RZ_NONNULL const RzFlirtNode *node, RZ_NONNULL RzBuffer *buffer, RzFlirtCompressedOptions *options)
Writes in the the RzBuffer the FLIRT signatures in compressed format.
enum rz_flirt_file_type_t RzFlirtFileType
@ RZ_FLIRT_SIG_ARCH_TMS320C28
@ RZ_FLIRT_SIG_ARCH_SPC700
@ RZ_FLIRT_SIG_ARCH_TMSC6
@ RZ_FLIRT_SIG_ARCH_M7700
@ RZ_FLIRT_SIG_ARCH_65C816
@ RZ_FLIRT_SIG_ARCH_MC6812
@ RZ_FLIRT_SIG_ARCH_M7900
@ RZ_FLIRT_SIG_ARCH_AD218X
@ RZ_FLIRT_SIG_ARCH_TMS320C1X
@ RZ_FLIRT_SIG_ARCH_AD2106X
@ RZ_FLIRT_SIG_ARCH_TRIMEDIA
@ RZ_FLIRT_SIG_ARCH_NEC_V850X
@ RZ_FLIRT_SIG_ARCH_TMS320C55
@ RZ_FLIRT_SIG_ARCH_NEC_78K0
@ RZ_FLIRT_SIG_ARCH_H8500
@ RZ_FLIRT_SIG_ARCH_TMS320C54
@ RZ_FLIRT_SIG_ARCH_ALPHA
@ RZ_FLIRT_SIG_ARCH_RISCV
@ RZ_FLIRT_SIG_ARCH_80196
@ RZ_FLIRT_SIG_ARCH_TMS320C3
@ RZ_FLIRT_SIG_ARCH_DSP56K
@ RZ_FLIRT_SIG_ARCH_OAKDSP
@ RZ_FLIRT_SIG_ARCH_SPARC
@ RZ_FLIRT_SIG_ARCH_TRICORE
@ RZ_FLIRT_SIG_ARCH_MC6816
@ RZ_FLIRT_SIG_ARCH_DALVIK
@ RZ_FLIRT_SIG_ARCH_SCR_ADPT
@ RZ_FLIRT_SIG_ARCH_PIC16
@ RZ_FLIRT_SIG_ARCH_MSP430
@ RZ_FLIRT_SIG_ARCH_KR1878
@ RZ_FLIRT_SIG_ARCH_DSP96K
@ RZ_FLIRT_SIG_ARCH_TLCS900
@ RZ_FLIRT_SIG_ARCH_NEC_78K0S
@ RZ_FLIRT_SIG_ARCH_XTENSA
@ RZ_FLIRT_SIG_ARCH_MN102L00
RZ_API RZ_OWN RzSigDb * rz_sign_sigdb_load_database(RZ_NONNULL const char *sigdb_path, bool with_details)
Returns a database of signatures loaded from the signature database path.
@ RZ_FLIRT_FILE_TYPE_PAT
.pat text format pattern file
@ RZ_FLIRT_FILE_TYPE_SIG
.sig compressed pattern file
@ RZ_FLIRT_FILE_TYPE_UNKNOWN
unknown type
#define RZ_FLIRT_NAME_MAX
RZ_API bool rz_sign_sigdb_add_entry(RZ_NONNULL RzSigDb *db, RZ_NONNULL const RzSigDBEntry *entry)
Add a new signature entry to a database.
RZ_API void rz_sign_sigdb_signature_free(RZ_NULLABLE RzSigDBEntry *entry)
Frees a RzSigDBEntry structure.
ut8 version
FLIRT version (supported only from v5 to v10)
ut16 app
FLIRT app type (RZ_FLIRT_SIG_APP_*)
ut32 file
FLIRT file type (RZ_FLIRT_SIG_FILE_*)
ut8 arch
FLIRT arch type (RZ_FLIRT_SIG_ARCH_*)
ut16 os
FLIRT os type (RZ_FLIRT_SIG_OS_*)
RzFlirtPatInfo pat
Pat info.
union rz_flirt_info_t::@278 u
RzFlirtSigInfo sig
Sig info.
RzFlirtFileType type
Flirt file type.
RzList * referenced_functions
RzList * public_functions
ut32 n_modules
FLIRT pat total number of modules/signatures contained.
ut8 architecture
FLIRT sig architecture/processor id.
ut32 n_modules
FLIRT sig total number of modules/signatures contained.
char * name
FLIRT sig name.
ut8 version
FLIRT sig version.
char * arch_name
RzAsmPlugin name.
char * bin_name
RzBinPlugin name (elf64 and pe64 are named as elf and pe)
char * details
signature name / description (only for .sig files)
ut32 n_modules
signature number of modules
const char * base_name
basename of file
const char * short_path
Short path without sigdb path.
char * file_path
full path to the signature file
ut32 arch_bits
Architecture bits.
ut64(WINAPI *w32_GetEnabledXStateFeatures)()