From 0be5bfdf0afb3b1f2aa263663b6bd9d75348c7c3 Mon Sep 17 00:00:00 2001 From: Farhan Saiyed Date: Sat, 17 Jan 2026 17:36:15 +0530 Subject: [PATCH 1/2] Minor documentation changes --- dest/bin/rizin.exe | Bin 0 -> 19456 bytes dest/bin/rz-asm.exe | Bin 0 -> 17408 bytes dest/bin/rz-ax.exe | Bin 0 -> 17408 bytes dest/bin/rz-bin.exe | Bin 0 -> 17408 bytes dest/bin/rz-diff.exe | Bin 0 -> 17408 bytes dest/bin/rz-find.exe | Bin 0 -> 17408 bytes dest/bin/rz-gg.exe | Bin 0 -> 17408 bytes dest/bin/rz-hash.exe | Bin 0 -> 17408 bytes dest/bin/rz-run.exe | Bin 0 -> 17408 bytes dest/bin/rz-sign.exe | Bin 0 -> 17408 bytes dest/bin/rz-test.exe | Bin 0 -> 75776 bytes dest/include/librz/rz_agraph.h | 117 + dest/include/librz/rz_analysis.h | 2494 ++++++++++++ dest/include/librz/rz_arch.h | 34 + dest/include/librz/rz_asm.h | 241 ++ dest/include/librz/rz_basefind.h | 54 + dest/include/librz/rz_bin.h | 1105 +++++ dest/include/librz/rz_bin_dwarf.h | 1911 +++++++++ dest/include/librz/rz_bin_source_line.h | 128 + dest/include/librz/rz_bind.h | 52 + dest/include/librz/rz_bp.h | 156 + dest/include/librz/rz_build_version.h | 11 + dest/include/librz/rz_cmd.h | 626 +++ dest/include/librz/rz_cmp.h | 55 + dest/include/librz/rz_config.h | 141 + dest/include/librz/rz_cons.h | 1276 ++++++ dest/include/librz/rz_constructor.h | 139 + dest/include/librz/rz_core.h | 1445 +++++++ dest/include/librz/rz_crypto.h | 121 + dest/include/librz/rz_crypto/rz_aes.h | 64 + dest/include/librz/rz_crypto/rz_des.h | 26 + dest/include/librz/rz_crypto/rz_sm4.h | 19 + dest/include/librz/rz_debug.h | 642 +++ dest/include/librz/rz_demangler.h | 61 + dest/include/librz/rz_diff.h | 104 + dest/include/librz/rz_egg.h | 242 ++ dest/include/librz/rz_endian.h | 2210 ++++++++++ dest/include/librz/rz_flag.h | 207 + dest/include/librz/rz_flirt.h | 269 ++ dest/include/librz/rz_getopt.h | 29 + dest/include/librz/rz_hash.h | 182 + dest/include/librz/rz_heap_glibc.h | 371 ++ dest/include/librz/rz_heap_jemalloc.h | 87 + dest/include/librz/rz_il.h | 9 + dest/include/librz/rz_il/definitions/bool.h | 29 + .../librz/rz_il/definitions/definitions.h | 15 + dest/include/librz/rz_il/definitions/float.h | 22 + dest/include/librz/rz_il/definitions/label.h | 41 + dest/include/librz/rz_il/definitions/mem.h | 44 + dest/include/librz/rz_il/definitions/sort.h | 93 + dest/include/librz/rz_il/definitions/value.h | 46 + .../librz/rz_il/definitions/variable.h | 59 + dest/include/librz/rz_il/rz_il_events.h | 98 + .../librz/rz_il/rz_il_opbuilder_begin.h | 198 + .../include/librz/rz_il/rz_il_opbuilder_end.h | 152 + dest/include/librz/rz_il/rz_il_opcodes.h | 872 ++++ dest/include/librz/rz_il/rz_il_reg.h | 41 + dest/include/librz/rz_il/rz_il_validate.h | 46 + dest/include/librz/rz_il/rz_il_vm.h | 110 + dest/include/librz/rz_io.h | 471 +++ dest/include/librz/rz_lang.h | 77 + dest/include/librz/rz_lib.h | 122 + dest/include/librz/rz_list.h | 117 + dest/include/librz/rz_magic.h | 417 ++ dest/include/librz/rz_main.h | 48 + dest/include/librz/rz_mark.h | 86 + dest/include/librz/rz_parse.h | 75 + dest/include/librz/rz_pdb.h | 398 ++ dest/include/librz/rz_platform.h | 69 + dest/include/librz/rz_project.h | 75 + dest/include/librz/rz_reg.h | 258 ++ dest/include/librz/rz_rop.h | 211 + dest/include/librz/rz_search.h | 294 ++ dest/include/librz/rz_sign.h | 17 + dest/include/librz/rz_skiplist.h | 56 + dest/include/librz/rz_skyline.h | 56 + dest/include/librz/rz_socket.h | 251 ++ dest/include/librz/rz_syscall.h | 97 + dest/include/librz/rz_th.h | 113 + dest/include/librz/rz_type.h | 484 +++ dest/include/librz/rz_types.h | 767 ++++ dest/include/librz/rz_types_base.h | 234 ++ dest/include/librz/rz_types_overflow.h | 86 + dest/include/librz/rz_userconf.h | 120 + dest/include/librz/rz_util.h | 98 + dest/include/librz/rz_util/ht_inc.h | 222 + dest/include/librz/rz_util/ht_pp.h | 25 + dest/include/librz/rz_util/ht_pu.h | 25 + dest/include/librz/rz_util/ht_sp.h | 25 + dest/include/librz/rz_util/ht_ss.h | 25 + dest/include/librz/rz_util/ht_su.h | 25 + dest/include/librz/rz_util/ht_up.h | 29 + dest/include/librz/rz_util/ht_uu.h | 27 + dest/include/librz/rz_util/rz_alloc.h | 20 + .../include/librz/rz_util/rz_annotated_code.h | 180 + dest/include/librz/rz_util/rz_ascii_table.h | 20 + dest/include/librz/rz_util/rz_asn1.h | 113 + dest/include/librz/rz_util/rz_assert.h | 235 ++ dest/include/librz/rz_util/rz_axml.h | 19 + dest/include/librz/rz_util/rz_base16.h | 23 + dest/include/librz/rz_util/rz_base32.h | 23 + dest/include/librz/rz_util/rz_base36.h | 23 + dest/include/librz/rz_util/rz_base64.h | 18 + dest/include/librz/rz_util/rz_base85.h | 23 + dest/include/librz/rz_util/rz_base91.h | 17 + dest/include/librz/rz_util/rz_big.h | 73 + dest/include/librz/rz_util/rz_bits.h | 186 + dest/include/librz/rz_util/rz_bitvector.h | 157 + dest/include/librz/rz_util/rz_buf.h | 410 ++ dest/include/librz/rz_util/rz_debruijn.h | 23 + dest/include/librz/rz_util/rz_event.h | 94 + dest/include/librz/rz_util/rz_file.h | 83 + dest/include/librz/rz_util/rz_float.h | 207 + dest/include/librz/rz_util/rz_graph.h | 72 + .../include/librz/rz_util/rz_graph_drawable.h | 112 + dest/include/librz/rz_util/rz_hex.h | 34 + dest/include/librz/rz_util/rz_idpool.h | 84 + dest/include/librz/rz_util/rz_intervaltree.h | 111 + dest/include/librz/rz_util/rz_iterator.h | 40 + dest/include/librz/rz_util/rz_itv.h | 132 + dest/include/librz/rz_util/rz_json.h | 75 + .../librz/rz_util/rz_lang_byte_array.h | 43 + dest/include/librz/rz_util/rz_log.h | 91 + dest/include/librz/rz_util/rz_luhn.h | 19 + dest/include/librz/rz_util/rz_mem.h | 64 + dest/include/librz/rz_util/rz_name.h | 19 + dest/include/librz/rz_util/rz_num.h | 178 + dest/include/librz/rz_util/rz_panels.h | 83 + dest/include/librz/rz_util/rz_path.h | 59 + dest/include/librz/rz_util/rz_pj.h | 90 + dest/include/librz/rz_util/rz_pkcs7.h | 100 + dest/include/librz/rz_util/rz_pkcs8.h | 35 + dest/include/librz/rz_util/rz_print.h | 245 ++ dest/include/librz/rz_util/rz_protobuf.h | 16 + dest/include/librz/rz_util/rz_punycode.h | 17 + dest/include/librz/rz_util/rz_range.h | 46 + dest/include/librz/rz_util/rz_rbtree.h | 125 + dest/include/librz/rz_util/rz_regex.h | 212 + dest/include/librz/rz_util/rz_serialize.h | 138 + dest/include/librz/rz_util/rz_set.h | 41 + dest/include/librz/rz_util/rz_signal.h | 29 + dest/include/librz/rz_util/rz_spaces.h | 120 + dest/include/librz/rz_util/rz_stack.h | 32 + dest/include/librz/rz_util/rz_str.h | 342 ++ dest/include/librz/rz_util/rz_str_constpool.h | 30 + dest/include/librz/rz_util/rz_str_search.h | 59 + dest/include/librz/rz_util/rz_str_util.h | 18 + dest/include/librz/rz_util/rz_strbuf.h | 47 + dest/include/librz/rz_util/rz_strpool.h | 36 + .../librz/rz_util/rz_structured_data.h | 74 + dest/include/librz/rz_util/rz_subprocess.h | 124 + dest/include/librz/rz_util/rz_sys.h | 213 + dest/include/librz/rz_util/rz_table.h | 97 + dest/include/librz/rz_util/rz_th_ht.h | 48 + dest/include/librz/rz_util/rz_time.h | 64 + dest/include/librz/rz_util/rz_tree.h | 35 + dest/include/librz/rz_util/rz_uleb128.h | 20 + dest/include/librz/rz_util/rz_unicode.h | 57 + dest/include/librz/rz_util/rz_utf16.h | 23 + dest/include/librz/rz_util/rz_utf32.h | 27 + dest/include/librz/rz_util/rz_utf8.h | 35 + dest/include/librz/rz_util/rz_version.h | 17 + dest/include/librz/rz_util/rz_x509.h | 104 + dest/include/librz/rz_vector.h | 491 +++ dest/include/librz/rz_windows.h | 74 + dest/include/librz/rz_windows_heap.h | 30 + dest/include/librz/sdb/buffer.h | 38 + dest/include/librz/sdb/cdb.h | 69 + dest/include/librz/sdb/cdb_make.h | 52 + dest/include/librz/sdb/sdb.h | 331 ++ dest/include/librz/sdb/sdbht.h | 62 + .../include/librz/sflib/common/sfsocketcall.h | 130 + dest/include/librz/sflib/common/sftypes.h | 3573 +++++++++++++++++ .../include/librz/sflib/darwin-arm-64/sflib.h | 213 + .../librz/sflib/darwin-arm-64/sfsyscall.h | 158 + .../librz/sflib/darwin-arm-64/sfsysnr.h | 684 ++++ .../include/librz/sflib/darwin-x86-32/sflib.h | 210 + .../librz/sflib/darwin-x86-32/sfsyscall.h | 154 + .../librz/sflib/darwin-x86-32/sfsysnr.h | 684 ++++ .../include/librz/sflib/darwin-x86-64/sflib.h | 152 + .../librz/sflib/darwin-x86-64/sfsyscall.h | 138 + .../librz/sflib/darwin-x86-64/sfsysnr.h | 681 ++++ dest/include/librz/sflib/linux-arm-32/sflib.h | 272 ++ .../librz/sflib/linux-arm-32/sfsyscall.h | 174 + .../librz/sflib/linux-arm-32/sfsysnr.h | 316 ++ dest/include/librz/sflib/linux-arm-64/sflib.h | 272 ++ .../librz/sflib/linux-arm-64/sfsyscall.h | 174 + .../librz/sflib/linux-arm-64/sfsysnr.h | 316 ++ dest/include/librz/sflib/linux-x86-32/sflib.h | 226 ++ .../librz/sflib/linux-x86-32/sfsyscall.h | 184 + .../librz/sflib/linux-x86-32/sfsysnr.h | 223 + dest/include/librz/sflib/linux-x86-64/sflib.h | 334 ++ .../librz/sflib/linux-x86-64/sfsyscall.h | 203 + .../librz/sflib/linux-x86-64/sfsysnr.h | 332 ++ dest/share/cons/ayu | 59 + dest/share/cons/basic | 59 + dest/share/cons/behelit | 69 + dest/share/cons/bold | 76 + dest/share/cons/bright | 75 + dest/share/cons/cga | 75 + dest/share/cons/consonance | 67 + dest/share/cons/cutter | 71 + dest/share/cons/dark | 63 + dest/share/cons/darkda | 64 + dest/share/cons/defragger | 74 + dest/share/cons/durian | 62 + dest/share/cons/focus | 64 + dest/share/cons/gb | 74 + dest/share/cons/gentoo | 71 + dest/share/cons/lima | 68 + dest/share/cons/mars | 65 + dest/share/cons/matrix | 64 + dest/share/cons/monokai | 59 + dest/share/cons/nord | 63 + dest/share/cons/ogray | 66 + dest/share/cons/onedark | 70 + dest/share/cons/pink | 67 + dest/share/cons/rasta | 68 + dest/share/cons/sepia | 81 + dest/share/cons/smyck | 61 + dest/share/cons/solarized | 66 + dest/share/cons/tango | 81 + dest/share/cons/twilight | 67 + dest/share/cons/white | 62 + dest/share/cons/white2 | 58 + dest/share/cons/xvilka | 70 + dest/share/cons/zenburn | 67 + dest/share/flag/tags.rz | 10 + dest/share/format/elf32 | 5 + dest/share/format/elf64 | 5 + dest/share/format/elf_enums | 15 + dest/share/format/mz | 1 + dest/share/format/pe32 | 5 + dest/share/format/zip | 6 + dest/share/fortunes/fortunes.fun | 231 ++ dest/share/fortunes/fortunes.tips | 86 + dest/share/gittip | 1 + dest/share/hud/main | 38 + dest/share/magic/apple | 377 ++ dest/share/magic/archive | 262 ++ dest/share/magic/cafebabe | 29 + dest/share/magic/code | 5 + dest/share/magic/compressed | 128 + dest/share/magic/database | 240 ++ dest/share/magic/elf | 255 ++ dest/share/magic/filesystems | 1538 +++++++ dest/share/magic/firmware | 1 + dest/share/magic/flash | 22 + dest/share/magic/freebsd | 144 + dest/share/magic/gimp | 38 + dest/share/magic/gpg | 15 + dest/share/magic/html | 2 + dest/share/magic/images | 182 + dest/share/magic/java | 49 + dest/share/magic/jpeg | 166 + dest/share/magic/linux | 227 ++ dest/share/magic/mach | 25 + dest/share/magic/mail.news | 55 + dest/share/magic/microsoft | 605 +++ dest/share/magic/mime | 9 + dest/share/magic/netbsd | 237 ++ dest/share/magic/network | 1 + dest/share/magic/openbsd | 239 ++ dest/share/magic/pdf | 16 + dest/share/magic/perl | 58 + dest/share/magic/python | 20 + dest/share/magic/riff | 226 ++ dest/share/magic/sniffer | 253 ++ dest/share/magic/sql | 37 + dest/share/magic/ssh | 10 + dest/share/magic/uuencode | 31 + dest/share/magic/video | 15 + dest/share/magic/vim | 10 + dest/share/magic/vorbis | 118 + dest/share/magic/zfs | 96 + dest/share/man/man1/rizin.1 | 191 + dest/share/man/man1/rz-asm.1 | 181 + dest/share/man/man1/rz-ax.1 | 143 + dest/share/man/man1/rz-bin.1 | 202 + dest/share/man/man1/rz-diff.1 | 130 + dest/share/man/man1/rz-find.1 | 86 + dest/share/man/man1/rz-gg.1 | 156 + dest/share/man/man1/rz-hash.1 | 97 + dest/share/man/man1/rz-run.1 | 189 + dest/share/man/man1/rz-sign.1 | 43 + dest/share/man/man1/rz-test.1 | 81 + dest/share/man/man7/rz-esil.7 | 36 + librz/core/cmd_descs/cmd_descs.c | 4 +- librz/core/cmd_descs/cmd_descs.yaml | 8 +- 289 files changed, 48734 insertions(+), 6 deletions(-) create mode 100644 dest/bin/rizin.exe create mode 100644 dest/bin/rz-asm.exe create mode 100644 dest/bin/rz-ax.exe create mode 100644 dest/bin/rz-bin.exe create mode 100644 dest/bin/rz-diff.exe create mode 100644 dest/bin/rz-find.exe create mode 100644 dest/bin/rz-gg.exe create mode 100644 dest/bin/rz-hash.exe create mode 100644 dest/bin/rz-run.exe create mode 100644 dest/bin/rz-sign.exe create mode 100644 dest/bin/rz-test.exe create mode 100644 dest/include/librz/rz_agraph.h create mode 100644 dest/include/librz/rz_analysis.h create mode 100644 dest/include/librz/rz_arch.h create mode 100644 dest/include/librz/rz_asm.h create mode 100644 dest/include/librz/rz_basefind.h create mode 100644 dest/include/librz/rz_bin.h create mode 100644 dest/include/librz/rz_bin_dwarf.h create mode 100644 dest/include/librz/rz_bin_source_line.h create mode 100644 dest/include/librz/rz_bind.h create mode 100644 dest/include/librz/rz_bp.h create mode 100644 dest/include/librz/rz_build_version.h create mode 100644 dest/include/librz/rz_cmd.h create mode 100644 dest/include/librz/rz_cmp.h create mode 100644 dest/include/librz/rz_config.h create mode 100644 dest/include/librz/rz_cons.h create mode 100644 dest/include/librz/rz_constructor.h create mode 100644 dest/include/librz/rz_core.h create mode 100644 dest/include/librz/rz_crypto.h create mode 100644 dest/include/librz/rz_crypto/rz_aes.h create mode 100644 dest/include/librz/rz_crypto/rz_des.h create mode 100644 dest/include/librz/rz_crypto/rz_sm4.h create mode 100644 dest/include/librz/rz_debug.h create mode 100644 dest/include/librz/rz_demangler.h create mode 100644 dest/include/librz/rz_diff.h create mode 100644 dest/include/librz/rz_egg.h create mode 100644 dest/include/librz/rz_endian.h create mode 100644 dest/include/librz/rz_flag.h create mode 100644 dest/include/librz/rz_flirt.h create mode 100644 dest/include/librz/rz_getopt.h create mode 100644 dest/include/librz/rz_hash.h create mode 100644 dest/include/librz/rz_heap_glibc.h create mode 100644 dest/include/librz/rz_heap_jemalloc.h create mode 100644 dest/include/librz/rz_il.h create mode 100644 dest/include/librz/rz_il/definitions/bool.h create mode 100644 dest/include/librz/rz_il/definitions/definitions.h create mode 100644 dest/include/librz/rz_il/definitions/float.h create mode 100644 dest/include/librz/rz_il/definitions/label.h create mode 100644 dest/include/librz/rz_il/definitions/mem.h create mode 100644 dest/include/librz/rz_il/definitions/sort.h create mode 100644 dest/include/librz/rz_il/definitions/value.h create mode 100644 dest/include/librz/rz_il/definitions/variable.h create mode 100644 dest/include/librz/rz_il/rz_il_events.h create mode 100644 dest/include/librz/rz_il/rz_il_opbuilder_begin.h create mode 100644 dest/include/librz/rz_il/rz_il_opbuilder_end.h create mode 100644 dest/include/librz/rz_il/rz_il_opcodes.h create mode 100644 dest/include/librz/rz_il/rz_il_reg.h create mode 100644 dest/include/librz/rz_il/rz_il_validate.h create mode 100644 dest/include/librz/rz_il/rz_il_vm.h create mode 100644 dest/include/librz/rz_io.h create mode 100644 dest/include/librz/rz_lang.h create mode 100644 dest/include/librz/rz_lib.h create mode 100644 dest/include/librz/rz_list.h create mode 100644 dest/include/librz/rz_magic.h create mode 100644 dest/include/librz/rz_main.h create mode 100644 dest/include/librz/rz_mark.h create mode 100644 dest/include/librz/rz_parse.h create mode 100644 dest/include/librz/rz_pdb.h create mode 100644 dest/include/librz/rz_platform.h create mode 100644 dest/include/librz/rz_project.h create mode 100644 dest/include/librz/rz_reg.h create mode 100644 dest/include/librz/rz_rop.h create mode 100644 dest/include/librz/rz_search.h create mode 100644 dest/include/librz/rz_sign.h create mode 100644 dest/include/librz/rz_skiplist.h create mode 100644 dest/include/librz/rz_skyline.h create mode 100644 dest/include/librz/rz_socket.h create mode 100644 dest/include/librz/rz_syscall.h create mode 100644 dest/include/librz/rz_th.h create mode 100644 dest/include/librz/rz_type.h create mode 100644 dest/include/librz/rz_types.h create mode 100644 dest/include/librz/rz_types_base.h create mode 100644 dest/include/librz/rz_types_overflow.h create mode 100644 dest/include/librz/rz_userconf.h create mode 100644 dest/include/librz/rz_util.h create mode 100644 dest/include/librz/rz_util/ht_inc.h create mode 100644 dest/include/librz/rz_util/ht_pp.h create mode 100644 dest/include/librz/rz_util/ht_pu.h create mode 100644 dest/include/librz/rz_util/ht_sp.h create mode 100644 dest/include/librz/rz_util/ht_ss.h create mode 100644 dest/include/librz/rz_util/ht_su.h create mode 100644 dest/include/librz/rz_util/ht_up.h create mode 100644 dest/include/librz/rz_util/ht_uu.h create mode 100644 dest/include/librz/rz_util/rz_alloc.h create mode 100644 dest/include/librz/rz_util/rz_annotated_code.h create mode 100644 dest/include/librz/rz_util/rz_ascii_table.h create mode 100644 dest/include/librz/rz_util/rz_asn1.h create mode 100644 dest/include/librz/rz_util/rz_assert.h create mode 100644 dest/include/librz/rz_util/rz_axml.h create mode 100644 dest/include/librz/rz_util/rz_base16.h create mode 100644 dest/include/librz/rz_util/rz_base32.h create mode 100644 dest/include/librz/rz_util/rz_base36.h create mode 100644 dest/include/librz/rz_util/rz_base64.h create mode 100644 dest/include/librz/rz_util/rz_base85.h create mode 100644 dest/include/librz/rz_util/rz_base91.h create mode 100644 dest/include/librz/rz_util/rz_big.h create mode 100644 dest/include/librz/rz_util/rz_bits.h create mode 100644 dest/include/librz/rz_util/rz_bitvector.h create mode 100644 dest/include/librz/rz_util/rz_buf.h create mode 100644 dest/include/librz/rz_util/rz_debruijn.h create mode 100644 dest/include/librz/rz_util/rz_event.h create mode 100644 dest/include/librz/rz_util/rz_file.h create mode 100644 dest/include/librz/rz_util/rz_float.h create mode 100644 dest/include/librz/rz_util/rz_graph.h create mode 100644 dest/include/librz/rz_util/rz_graph_drawable.h create mode 100644 dest/include/librz/rz_util/rz_hex.h create mode 100644 dest/include/librz/rz_util/rz_idpool.h create mode 100644 dest/include/librz/rz_util/rz_intervaltree.h create mode 100644 dest/include/librz/rz_util/rz_iterator.h create mode 100644 dest/include/librz/rz_util/rz_itv.h create mode 100644 dest/include/librz/rz_util/rz_json.h create mode 100644 dest/include/librz/rz_util/rz_lang_byte_array.h create mode 100644 dest/include/librz/rz_util/rz_log.h create mode 100644 dest/include/librz/rz_util/rz_luhn.h create mode 100644 dest/include/librz/rz_util/rz_mem.h create mode 100644 dest/include/librz/rz_util/rz_name.h create mode 100644 dest/include/librz/rz_util/rz_num.h create mode 100644 dest/include/librz/rz_util/rz_panels.h create mode 100644 dest/include/librz/rz_util/rz_path.h create mode 100644 dest/include/librz/rz_util/rz_pj.h create mode 100644 dest/include/librz/rz_util/rz_pkcs7.h create mode 100644 dest/include/librz/rz_util/rz_pkcs8.h create mode 100644 dest/include/librz/rz_util/rz_print.h create mode 100644 dest/include/librz/rz_util/rz_protobuf.h create mode 100644 dest/include/librz/rz_util/rz_punycode.h create mode 100644 dest/include/librz/rz_util/rz_range.h create mode 100644 dest/include/librz/rz_util/rz_rbtree.h create mode 100644 dest/include/librz/rz_util/rz_regex.h create mode 100644 dest/include/librz/rz_util/rz_serialize.h create mode 100644 dest/include/librz/rz_util/rz_set.h create mode 100644 dest/include/librz/rz_util/rz_signal.h create mode 100644 dest/include/librz/rz_util/rz_spaces.h create mode 100644 dest/include/librz/rz_util/rz_stack.h create mode 100644 dest/include/librz/rz_util/rz_str.h create mode 100644 dest/include/librz/rz_util/rz_str_constpool.h create mode 100644 dest/include/librz/rz_util/rz_str_search.h create mode 100644 dest/include/librz/rz_util/rz_str_util.h create mode 100644 dest/include/librz/rz_util/rz_strbuf.h create mode 100644 dest/include/librz/rz_util/rz_strpool.h create mode 100644 dest/include/librz/rz_util/rz_structured_data.h create mode 100644 dest/include/librz/rz_util/rz_subprocess.h create mode 100644 dest/include/librz/rz_util/rz_sys.h create mode 100644 dest/include/librz/rz_util/rz_table.h create mode 100644 dest/include/librz/rz_util/rz_th_ht.h create mode 100644 dest/include/librz/rz_util/rz_time.h create mode 100644 dest/include/librz/rz_util/rz_tree.h create mode 100644 dest/include/librz/rz_util/rz_uleb128.h create mode 100644 dest/include/librz/rz_util/rz_unicode.h create mode 100644 dest/include/librz/rz_util/rz_utf16.h create mode 100644 dest/include/librz/rz_util/rz_utf32.h create mode 100644 dest/include/librz/rz_util/rz_utf8.h create mode 100644 dest/include/librz/rz_util/rz_version.h create mode 100644 dest/include/librz/rz_util/rz_x509.h create mode 100644 dest/include/librz/rz_vector.h create mode 100644 dest/include/librz/rz_windows.h create mode 100644 dest/include/librz/rz_windows_heap.h create mode 100644 dest/include/librz/sdb/buffer.h create mode 100644 dest/include/librz/sdb/cdb.h create mode 100644 dest/include/librz/sdb/cdb_make.h create mode 100644 dest/include/librz/sdb/sdb.h create mode 100644 dest/include/librz/sdb/sdbht.h create mode 100644 dest/include/librz/sflib/common/sfsocketcall.h create mode 100644 dest/include/librz/sflib/common/sftypes.h create mode 100644 dest/include/librz/sflib/darwin-arm-64/sflib.h create mode 100644 dest/include/librz/sflib/darwin-arm-64/sfsyscall.h create mode 100644 dest/include/librz/sflib/darwin-arm-64/sfsysnr.h create mode 100644 dest/include/librz/sflib/darwin-x86-32/sflib.h create mode 100644 dest/include/librz/sflib/darwin-x86-32/sfsyscall.h create mode 100644 dest/include/librz/sflib/darwin-x86-32/sfsysnr.h create mode 100644 dest/include/librz/sflib/darwin-x86-64/sflib.h create mode 100644 dest/include/librz/sflib/darwin-x86-64/sfsyscall.h create mode 100644 dest/include/librz/sflib/darwin-x86-64/sfsysnr.h create mode 100644 dest/include/librz/sflib/linux-arm-32/sflib.h create mode 100644 dest/include/librz/sflib/linux-arm-32/sfsyscall.h create mode 100644 dest/include/librz/sflib/linux-arm-32/sfsysnr.h create mode 100644 dest/include/librz/sflib/linux-arm-64/sflib.h create mode 100644 dest/include/librz/sflib/linux-arm-64/sfsyscall.h create mode 100644 dest/include/librz/sflib/linux-arm-64/sfsysnr.h create mode 100644 dest/include/librz/sflib/linux-x86-32/sflib.h create mode 100644 dest/include/librz/sflib/linux-x86-32/sfsyscall.h create mode 100644 dest/include/librz/sflib/linux-x86-32/sfsysnr.h create mode 100644 dest/include/librz/sflib/linux-x86-64/sflib.h create mode 100644 dest/include/librz/sflib/linux-x86-64/sfsyscall.h create mode 100644 dest/include/librz/sflib/linux-x86-64/sfsysnr.h create mode 100644 dest/share/cons/ayu create mode 100644 dest/share/cons/basic create mode 100644 dest/share/cons/behelit create mode 100644 dest/share/cons/bold create mode 100644 dest/share/cons/bright create mode 100644 dest/share/cons/cga create mode 100644 dest/share/cons/consonance create mode 100644 dest/share/cons/cutter create mode 100644 dest/share/cons/dark create mode 100644 dest/share/cons/darkda create mode 100644 dest/share/cons/defragger create mode 100644 dest/share/cons/durian create mode 100644 dest/share/cons/focus create mode 100644 dest/share/cons/gb create mode 100644 dest/share/cons/gentoo create mode 100644 dest/share/cons/lima create mode 100644 dest/share/cons/mars create mode 100644 dest/share/cons/matrix create mode 100644 dest/share/cons/monokai create mode 100644 dest/share/cons/nord create mode 100644 dest/share/cons/ogray create mode 100644 dest/share/cons/onedark create mode 100644 dest/share/cons/pink create mode 100644 dest/share/cons/rasta create mode 100644 dest/share/cons/sepia create mode 100644 dest/share/cons/smyck create mode 100644 dest/share/cons/solarized create mode 100644 dest/share/cons/tango create mode 100644 dest/share/cons/twilight create mode 100644 dest/share/cons/white create mode 100644 dest/share/cons/white2 create mode 100644 dest/share/cons/xvilka create mode 100644 dest/share/cons/zenburn create mode 100644 dest/share/flag/tags.rz create mode 100644 dest/share/format/elf32 create mode 100644 dest/share/format/elf64 create mode 100644 dest/share/format/elf_enums create mode 100644 dest/share/format/mz create mode 100644 dest/share/format/pe32 create mode 100644 dest/share/format/zip create mode 100644 dest/share/fortunes/fortunes.fun create mode 100644 dest/share/fortunes/fortunes.tips create mode 100644 dest/share/gittip create mode 100644 dest/share/hud/main create mode 100644 dest/share/magic/apple create mode 100644 dest/share/magic/archive create mode 100644 dest/share/magic/cafebabe create mode 100644 dest/share/magic/code create mode 100644 dest/share/magic/compressed create mode 100644 dest/share/magic/database create mode 100644 dest/share/magic/elf create mode 100644 dest/share/magic/filesystems create mode 100644 dest/share/magic/firmware create mode 100644 dest/share/magic/flash create mode 100644 dest/share/magic/freebsd create mode 100644 dest/share/magic/gimp create mode 100644 dest/share/magic/gpg create mode 100644 dest/share/magic/html create mode 100644 dest/share/magic/images create mode 100644 dest/share/magic/java create mode 100644 dest/share/magic/jpeg create mode 100644 dest/share/magic/linux create mode 100644 dest/share/magic/mach create mode 100644 dest/share/magic/mail.news create mode 100644 dest/share/magic/microsoft create mode 100644 dest/share/magic/mime create mode 100644 dest/share/magic/netbsd create mode 100644 dest/share/magic/network create mode 100644 dest/share/magic/openbsd create mode 100644 dest/share/magic/pdf create mode 100644 dest/share/magic/perl create mode 100644 dest/share/magic/python create mode 100644 dest/share/magic/riff create mode 100644 dest/share/magic/sniffer create mode 100644 dest/share/magic/sql create mode 100644 dest/share/magic/ssh create mode 100644 dest/share/magic/uuencode create mode 100644 dest/share/magic/video create mode 100644 dest/share/magic/vim create mode 100644 dest/share/magic/vorbis create mode 100644 dest/share/magic/zfs create mode 100644 dest/share/man/man1/rizin.1 create mode 100644 dest/share/man/man1/rz-asm.1 create mode 100644 dest/share/man/man1/rz-ax.1 create mode 100644 dest/share/man/man1/rz-bin.1 create mode 100644 dest/share/man/man1/rz-diff.1 create mode 100644 dest/share/man/man1/rz-find.1 create mode 100644 dest/share/man/man1/rz-gg.1 create mode 100644 dest/share/man/man1/rz-hash.1 create mode 100644 dest/share/man/man1/rz-run.1 create mode 100644 dest/share/man/man1/rz-sign.1 create mode 100644 dest/share/man/man1/rz-test.1 create mode 100644 dest/share/man/man7/rz-esil.7 diff --git a/dest/bin/rizin.exe b/dest/bin/rizin.exe new file mode 100644 index 0000000000000000000000000000000000000000..eda5416c1eeb2b02070424e21e84aa3f41aafbea GIT binary patch literal 19456 zcmeHP4Rl<^b)J>>$+9h3B6w}_>u0kv>mS70f*^jJKG~9a!ZKcL8C1vVY9+0#t)di9P#INTT0+k<*E9@ax)yNMiFO8J0U=Ibj2Z)JE>aCr z&c{Gajbsx8Gf~loM6zI0?#B=!RTGhn+(-14`PSxgu^OW$8tm!okbM_}sHeW%b{1cO zhWz^XOYiJ~=Aj06)liGOa;Vu|Y9`+3Hj@v!2hq-2zgP$}ooYy?%;dvNN;bO((ylEl zgh-r8$G4_k-v^p3O}oATXhM)N(crEtMPqYV+rL55yuklj;T{tVI_gFJVT$qkG0E(D zmKcW1zYky?M&yjtk5Md}!>$t`NxiRN8YsPfrT6Mwy%c!wTCZeweOv1NN77qQdSRbW z2!}8`fSAe2wCg8OOMPoK6Zg1VMO-^|2&UDh5@#G0d#?uCkYv^tcPs3Sq+Khsc0L7^ z{PS@ogZ)z}?d%}ckW2pQQ~25bk<6}-Njo1RJ0FGTMo4FR(tN~(&emt0FqjbQQMV9~ z*#c8r9QSIc9)K>gufdyvuhPG z442;yV4cBKWdm=7;#kqNcIvyoOQ+euwCk~JY1q}^UJZ6-loNC{x_f|<*O~w`MqMtA z`t9vmqh_Kt)t_yYWOh{&!*KaR0IP$HG84zTkDkc;m^rae(Fq4~qqm^Qx(J zVohiFG$)a6cz2|y6fy$FoJ|EGeNcHQuYN95jsC$@+&B?zF3L179vNilXED?c`ir%U!mOyI-fY^;W1$QUq@3# zTjB{JjctWhbo9;x;3%t^Pr0OZ4=t3sG1ZFyPjUgj{7qJ>&XS&r&(h-;fhl0BInrzb=sdZEwYIZNQwqP)<_-ycE$h{_F%4;St=RZWT;I+PLn;pAG z)+Lz{kwU?TCO*W@(w1j3bk-~iPwRy%QC)EeRwI5&tkjY#$zGwOdv~vS<11`7z6Q0Yq zUv52?-~Ovq1oQG~8nWCqlgE2Lwoh7uz*RV+T<^_Rpln);smyk-B}{tAYt^EV$9t)2gkxh&Twk|*Qi_!Y3JP#wijo%LB9BOqS4W|Krn7{XCTt|DyD1E`0+ z-#Ui`djauS8-L46Wthw0l<|rAD%&4M`$7ZqS0NfMgL+y?Sf$xv+(JWIX%3ro-(jf(%Eac!BIu@Dw|$nZco7}&7fqOqf8t_PWN<~nRH?m2MbC>_Lw(1 z-4umRchV>`vALMhE9_FT%w1exinAP%`%8#C?VNswXK~JQE9dJA*g#cBGyah~Ufj7d zH60;sUa8jUu6RnUTE9hz7*%a%qqy5;?yT9$9q66x^`1JqhjELmNEn7ImF;{LiJXlo z!wf|S9XU=9LP0f7E%uJU@wL-M)0=H;w*Hkj0;AM~Hg*>r#K)}iL6es)3bWH@#gi8i zU8jEOB8IJr3h<66?mXy#Z;q`@L2uz6$?-IU^~Fl9Iar)WrZ2W$KiCJ&Tahq2v_ z*hUk7?QtuPB}dLT;>qa}%bO2>XKUwMGcx6w)@UT5xZJi)ztZ(-Fr3g-*2Gf9^N=iYB42_IZjpY?vUVT~{uqIR}SzgV<(${ZfvL zv*P7#Tn^Fw3aqBfZ-r@3fNx~F!umK&bje8>uCwA#--u+uBzGoIC+ zUyBvp`VwzVFGEb$PnTH#m?_VOkAHzuj;EwgNZy@yL2Gx#A#ERI!Oj^69j9JF2qm6z z4+4moOJNRdsu~E^A><>LF1vM;%@@a6y?h;HSbvMx0TQ$_b?Q;@gWOEy16lHYAW!e) z`wrp}r(ZSeIU;%fdowf~Hng`eAIxDsM4d5{zc^fl_HQ1@u<(FzGc!Z;q1pFTGt}oa zdsh2A=njsKZvP);4o|e6DF?Tbm^O+4(*CP|gNYOaH25BC29BOtKW`*fuBkJZO{#Sa z3i(_`>}P&0TVr43QKJyY!h=bdG~Ctb$e=wpXkwv~7ME6O)joOc^jLp`0}f)PXnHUZ)^ci7M_Qm^9_`y+>lL_AVlM)-XNui_ zxKSGSqYxy+v+e8^!=Slg&}kPVe5N*a7+alq^D7*RY1glC>X7EcO?uk( z63X-*fGyUnwL<~)Z=aJ+LU1XX2}7XVYmQH$6(I%fNxOa)ag2mo=acj~$PD8?(yv07UI z*R!jJw5fX8dtHjThy-RFuN=t!uT5p97+-BOr4uJ|s<_3NFfw}=5en-I%d}o%9pPIDo5ERP8H>S_kd!#=1SI8`ED+Q|D;m}|AS0RyGrQ9hjvv(fCvpb%bUY^N}=xIB>!_dD1mO$%4dq$ zYFa1i$P$X_2vuRvXmAe@hH+H7P~aP?$y+Y1B(1f_)2=5V4ZH1L_Zb*(4k@*0#N|W^ zN1DBE3NR8hNJ@CdJ_78`uS`f1P9_G>y`X`Sjkl$ZpqzHCgA%-5VQa1x%4pxh!I20rs+&zgY2Mt=qQ}84COD<%%ND3n95KdC^g;Ts> zzF4oL27yFJ`E$&tI_kF%ky8Hw(>pH47&BaBW;*T_EBEX9%^O0=Nx4lh|_}; zeO31K%DcQLF-8M2XD4lbSK4nUyxe;d&p7s>PVnhf9t?9QjGEuo;J|xQ<`|W6=vnShg~ULWGu|cX1G=t#`jXgEyR?u>m)oU9RN{-MzGpxe z#-omSjrD8X_~p8ctCrNHPTbaOstU8e)H+B9F{_Bdx(m6mAH%KAif>TMx43oMN^(Pyjj-D* zeZB8RU-!+>_Z@l*&Q81-A9HlMK9XkgGj1Mqls=aMS^dLWibhl$gbCCfH)ySf7AWAA zBn5#U7yrTtWT3%=q%C&Eolz)kopOo@d zM12bv-Mk~lyO6gePu|UW@_zg-4y}>W5mL^+RT9{gAJ03E;IK0 zA`}ib%^tUjMUohf1$$c4g}IZXMyDUc&ytNq9g~yvCvtPJL=ar zWF*TkG5AJdOV)8}DC0x#yX~U0;*isQf2v~d{nW1sZSe;I2N}HzD5e8lRh-qQ{~%ql zDpleTF<-XaR#GHlMz$QGvNv1yl@yDZo-MagxiVXhpd7DAYOg_4V$w0B{RoKd^CC3} zm2e_mgXminkAk>Da+$vV7Fa3WGb$eZC!k|^9mdP$+K{1x4tebP)Gq3J@yNy0@XG5Nqmt2uW6sS-1BrljJ2+C(R`pVrbZE+A5S z6nbpZIHY}SJAtuy5i~6 zc;eL7$@(hPmr{NI*{a&mer|PIIK_}=NTlnEE^D{|-9$-RH9JlX)-aI8NXe)tofYH}y4J zorSZbkY5$6!xHqJz2CG_(@0Vzrp~}OI+fZoUIKmGDw21JCCrF}ypy`prnU~Ckz`Zp z+dnWnj+`N_INrScN{gxk5`^rjarP4x)0zHI_>h~6_w?tUClt#uHWHnq^D;(1qOFA z?P{e*)`BCa-M&s;rk8^UQ8RrMLd}F01chvv(CBv^2rke<3bXG@5Lh0dmJ?0~tw>pVviwFb32t`k zHqn6@(PyU~9lqyI2$Lc1He?DKYDvd?ja+1;Q%_kxBAfiGL;I#8TP zJz1i9!Y5Ro4>`YKu*YdHzTi`a8p_ZwLYDO-iWxOf`^d1IfvS>*-c4Xgd*xa(bP~BV z^awCA6uXKkc2v^6*(c(37%)L)@|+#?0|zrbiFrXv@bjS|Z4~WtyYxAf(It%kTn8HK z)VSb>5%e{T-oFSEbj%7pJ)S&{?`s2S$PXq>NoUF&a{j~gKfoo$2uN$5I!4wVwc~Zb zRKH_NyXxt?+vHyNAQYL&!7~KNK=qd6qZwhQU5nILyax5mD16J|FH86>r;Qq8x+;Mv z@LP^SrkS*Q`Dm*Bh`y@FTpGxqxS9EwW8W9Snh}?^&j;riuvI$8;9rdxWLnX^-38B3 z+eiX+Nj*a~N!EAc>xlJ#4hFVCbPZ#082eYbpZt3#ZBnDh0VliqaoKf!V7 z>Z6>0lk+cg{wU{3&hO>CkMjWMn>cUe{07dKaDEx*<(#Kk{@t8UbKc1Lt(-S;zK-+F z%)f#0J2>AY>73K=57O0t$hoxtBaHhw4{+YWd60A2FWKMiOlib7-s$S^<5ZZg{sHGd z}W)i{K-c5Dh)pf#Vc^5PU{L@fg5#-_hh4vxTD5YdjIo#^}xYRQv7`z zC45A|uPHdG;7bbrQo%CSPFL_c1$_#J6&zIXn1bD^{bQK&m4b^EyhTA%L7##rmHwv{{F;J)qF`9TI~825;7SE`1?MR^OTp91UoR>6 zf`arrTlySR@M#6hZ2M)ksJvSK%-n{ePL}losMy6%ZYcO!`n>$I%@=V=y7xTwHeVs6 zm4iN~J7oKj&V2cX%^=zS_j0ALP@s3U)Nd$QSkFhOvxvVx!eC>*KWt5P%05#;pMvv8FCTPDOqH9~v|Y5uiB+=o=; z#h-8>ty_sxJJOGk=&9i?B>MY~4cKcj$Ap15!KoEOta0LyhbKx}PQ7(P^a5_&)UfG8 zw?^Oki}{b6pJ^O;_=T5tev_upnwz$+4Me*G;jPio?ofDZdpy+BxwSnMj_y_zrsGdL z+QBUZOy)#5U10eG8&1Q1{<{-*ZPAKV~eB>Fa!M^OHGLWZp3{(wZk04 zvICme+tIa6h;Ec|!VxuVHsYJqHTA?3DWDN?AfL8{_y+T6P26^00gZ?w1++DwJ(5pj zd5`DOd@S#Yd>Zo|%%in1-&j74`BI>z9O#?+I~@AW${=*hvU^RSKXz+85beCPD;8+) z3HGxf#L$I!$abs?;=!z(9eq8q-cFQhZvUnzBY*eq-JR`lu_$d)K90sZ+)eeYrZSJV zh3&1%rL{;tJ&z{&JfOWwdIsd*1JU0>k$yGKh+d2#Xf!_*jUrj>11%>Wcr~HDy$Y0-2-AA*$MO1GeEs4sp>Dl*=8W z{5}P#9)FABT>TEv=A(A!;h#zLBSI`eZ!rAgOY?;I8Qvght`cYek6@lWYFFwIrK@vbnM0IOc~-HQb)+PswE>^+5cAss z&(nu@O()w(_8fh~id~)r41#~Lg5baynOBs|G;rw^f zz_UUQZ4qcG&?<9iPk^=$w80$OmW@K30gdLW{dti#8pAG~4d1_qNT0la50QR&r+dh! zi=(^!J$=}kic5g?@9Ot&3&w)s9b$o9j>o#{{DJ7U9sY1|Cr%`1)4QU5uJ-1pT3KSD(K#hz5PT{5_%mm=Kqtz9Sxu;tN-QaG)a?iG}*Y;_`D*{T+SyZWn*4 zd*_;sn{RJvTHmHTyX z3iO0_s|pNRDB2h9g)@Zskb_3i=8-LP8Dg?MOz9QzEbb2qpEEcRf`p&JD};PUTG>T^ zZ!Sa=Y>fEfi|96-1J7iit zgu=`9_IMX({kzZGrwiHpPI_d2RwzAKQqQC1ymr1Pzd_GCcby z2d>ty;(r!|mP5pLzrG_B&`}eL&{r_HlkAT0Pl0mJyG3jP-SqjxMf$lAeQe@;h4x<# zyw`R%|8pPFpYQsYtbW^GyZ-+?tQ6vxAHe+?_i=Ht5Whn*fLG2H;;( z;0-XOBaHxW1MEji0Urchj0^oE#1GhrIN?G%fO3~CV}gK*CWMlgAITsm*R~BcqQPK zNcRBO0l$K@7kCPA5q?8j3ET_lM`{M%26!)01Moq>gGimg3I07&5Ac(KAH-YQEx_qb zErQenoZu&rwgMjk{8uC$_!Qu4cntFbKMnX%+_^2-JP7#LNL8R81pE&q5Agu@;;(96 z1WyF;Z;_^ervTqXItg6pLVO$PG4Q7VuUja@!@wU0d25D{y) zi)BLGfV3RA4{#Ok;tvBi0E0*efYbf_D@ezH9|ZhMysJI~JO%g?(n;X-);ez`{+S!x zg>}F;k=_7Z)WRP~uL9QrzlHQK)E4mMb$Gu8POu#>o^Jt<0MgGRe*>HzKZ}qK0>}3* zVlmPfaC#e}_nfgN2|o|K^fvHc=wqNA>b;|NqsFK?>Kknvjg0Oa9T}Y*Jvmyp-?zVY a|J437`^ACM1Cr$gH8X|1-~t^BcDtKAyeiov7p1UMupbhDmnt=gK}KYTRyY+BtF`)~Gl-+SNu z3n)F?p4~miFXz2`-+lMqci(;Yz3;vEP1bDeXW5J~D^fhp*dQQ18qYsCGf+Kk?z7X_ zcc+}0H)yFlGq1kg*Q5Fa-CF`pooY){S66pXZT6~xP?zfKQmgM+uXc8~ddmt5@*Gn2 ztc|t7&C9R3#!RmrUa-J}@@t133qH-^`~@30ELpG?(DCeo1)l_b5qu4Ro0l)R#>dO^ z7i{9Nl*4ttmUhx<_P|}kSnFpMwtm-EpGliwC2VTew1td}DG}6(%K_~i*DM4G&tfcx zlai42g8-+U`V@oz8h4vQQdSBk0f`H>gfaH+YQ}a5ROEifzDomPKD~^&fXAvBt2b#E zfW0d*R@_iosWCQ^TF#Iu3wn11LEAhZ85u-@m9fUMKxjjbYtwc(B zv`Lhd%8$^$$OC$$-eHf_Ic$3P?Fv0w@6e-l4$W8sC3>XV;Utoildb{@6g5dH0wqe6 z@QI4!@lqe+HC}oT&pVNyrUz=B#x>cD8O@ZfK-Pbh;?r1{%UI!&*xp!Z>QSJ~s4PI8 z@wy!?_Z2v%gHo7Bl${8Hy|JL=x{7nXJe6vm%;z-);BN)N*rpP73aG{m${qnRI%51Q zC%=UPZ!ef*tb)pZV{97bFCb50c|2kNdk~d0-k&XnP`+3w-$cq2?4rLL zV7EaNCrRhd5dLTv{m;UTN$)>3eG>j;#ub>64^%tmg;!+X!I&jfAUrgeIK~^oD}J*U z%0ssgD?bB5-qibwn&EOdq6)x>&gFf|8^nsv&Rq)*Fw7GSdBo5PhGFFpq-lPQE7Yu| z@JO9wp0N>wVeCccX#8C|2H2&CD_HPWiVTeiMVUZW6zS-@>4`} z$BXa=r@r zFG4=k0KQ(BO88J})KfbRoLz6xZlNKy>)9iEbciajTu=tgMwqSe8Epo!*z~??OEJ-l zO?r;LH3p~DfsznMnK&X=$9TRTwL0`LSWqIeQ(tCvP!w7nQ7vCzhWHE2F-y^WM|Pzx z8sp@i93qcf$DiY~m^(`Ln2+DU>_kV+t~vGay$%-(Sr^B~{nVOEG;4JfKEqb5*~nOs zs_x`Q@owikl4eVHpm(CzyDMn_!6oLCG7MKN+4*8pITcfeGh_`|Qk?EZ1ErX;OvWUS zulup`BJRn6I^(rC#xbhdbhO6Z1qYG2eFdYp^JR;|Y(g)5YC6$X>X*ubmysDNdB+*D z4p`uu6N_VLmtrvW;r^M)+Y8!^tL=!%@ym@@5Ia~i$pD*i^w05lziBk_m!C31SaQUC zC7zTnaeZg;E=ktTG=7vQPcdExo+85ehe0!rAv0S^T3Cm8R_oBQVtSF8qgP?HV!r|x zm7}-1CA5%w+aUVS`%S*0N$4(ri6Ty;dS|@oit`lFP3pd!nh(dKj%(UyBsDS<+Z@$@vX8c#w^(oeID zM-t_!@bM5zDV`EOA$@mkK&$PAN0e7}{u;;~u$+4fAryYj(F?$WMG~{%rK*5noJ8Jl zxUl!dsNQVyg(!&r5juMZ?a^Y$zw>BQlr{D!;i6UgOcx?)h|T z2%8bnKx!H(0;u(zvoMijfCk@b^hLj4 zE&>lAs!bV;sDe7M7LZH@wSpF|p!c@RI1CpG>@i^GOfmZpH!7p6pcuUtcE@Q})H&S7 z3p2STSYI(8_#7FZ!UqyPVMJ8NZydjY`i~JPh(d`G%@lD85vM7FJkPLZhU7bW6qjEfavdy>JjBJVBG>;15@ z5+>7g{4|v}=)2#ZP#8OknFBBSO8A;FHM++^*BH@}GuIx?MvW08!~6DN=TGB)9+P3z zDkj4|PQ!eFs1CW}EI@<`?d|oxdb~=}J?!jrs2+5kRzjTxSJJvsL6%UA`>6`=kZQ*c z!Z5C~Efmx`Xwdm9m{yjC@>B65V;+qsnmZ5U^@wa1LcAP~VT-fJK>h9{Nm(pmcR9#;XxXZY1`># zc=aGHx!CLT<=+{8&hh}tVy7)Oim4Mu&i7Jq#EYK9sWoH5PwJoCP~m+;ZxeC!Qh674 zSG4qWj)m^#h47AIYp6}occ`lJ#aY4Y%+fq6%{EIVRN@Cyb@vXHXHG#*Fa0(ihcsi-|V@va4wW))B7wZ zUUahxYWTPfHGy+_bQ7W_d_v6}@HBlJgg*BL_5B*oyA*v`KvE*seBTyxcW{4Vk%}f3 zDzhHJK%0;=w4{j06EUArzrw=TA`9YFT(D%+&k^;xM=LSlXRbB5lJkf2U%)=u{!buA z(?(c>k;se}vpwtr3np+LHF0@BaZ{`H#w#RE^Wki^ykZ9a`_30Om}&#{8Zt=I=u0; z$_T5BG*~Mmx~($e&L6~vgWd(uY}LT(FbNhSEWOR!6*?+dPGv{y^0nQ+^>uk`rw*CK zEJ5rFdOM~L;r*M3{m1Nt&A8T~GZ9D+STi(NhJx*;5~c`Fs<6sa>=d9_<6N7*$F!I^hvZM41i5^mUsBa?`Q_- zl(1MrY`GzMufvgBxbNSA4(1~Ju&(pLq$SF1DO@}~IR=m*D=sl1rXblh7u==cjvoH4BY=3`>-IINrn2HP0I`CXuTcSwa#}H0%on=%X zdP~)(j_T24G+k&oNjb9g-2`=Ww~g< z79LY!*Un+31O$cisGLWQC^Lb;E(d||*q>n6ETCurcVFyaOJ5yA?k}! zZ=?F2$xSsvenx4WSy@Es6~@gNGVJI-&fIVimOjb~u&`R_#2YQRiyDw8W~CMdT$PZ2 zu+jevZaS5ZQGIyq`)L3AWcw<$zd*K6=IH3XjfKc$D@nlQT!@@sBJNRf8XmXvMKW|ji-utoMa!Q}i@9Zn|7On_3 z=us05A=9qodYx*tM1xMkw8A4=wxf{WrU~D2O3c8;Ifz?hcKu(0y3InmcU}rhP)2QHq&J-LF8n+)bf_cOAZQ(UDcLP&uk>B!Kx*E;u#d{|3=v zCu9ni%D^vRW*qg%!o%#A_RM}XdCZf z-$9+r*wNAkh~I(n@0FRoKh5tGIFGnXn1ipH=)MhIb~I41^M+VH&l~`{tUW|H{d*Tphn1{DFf9&<*4!$frwH9_F=__To{@Kj10wFMQ7XW zbZ&OD5M4LwpmOrGZFz8v9v{KHphom~ETX)1W9o4A6}*Nrx`gqcVS%tp!s8^Tf*U!> z;j@g|Q$jS%3N=0yJ%#VL2O!8VOlqUnm>#jdF#ZBua_BPj>I%7ytT=AQ>kd7-&(RCj z@uE*+9nqtEcu9};o(GX8t}gF#+%zL}oHvP$PiXW^%e>3sA5ZvQP9rg4x=Mv)GTr59 zWSUN^mz$>AY&!TN+;*f-+{AoJvF|89Fi*124d-aERX9iE&e6!UtiNl|xQ6T>~&`%$Ey{y7~C&RDMKv4U*uG);Lxu_+b-nacji6AQuS5YqUm1 z+>kJp{*OQP>x6;rpAhhIS^lzw_euB}S^p&oza!xZ315}4P4cgm<&Vkol@jJi_&Zr| zy62^}0y`|>S0ywgJT2u+{t8Jq%K=&5m_h&j9fBj^7I2S*Uzac@;Tsa3m(VWlyIR5} z65b-~r%Cuzsee?$5eZ`w9+vQ*CH$;}Z4$1P@Ma0GldxFAb+VneW!Wmr%@UgZx0i^Y z0h%zjSd_;ypviwo(#^7Kdiu`@O?snU(AA67n|v38^v0ye)g<(cN+_tftT!1^< zb@=5N{|RS3>gqGRUR=}>j^ zrd3UW_NJ~)0pBiP*QVx>ucLKSv#%?#Yg1s?qNbis3GgG|X7JMkb9o}14srZJ`vd3$ z{|&OEvx{g0Xj=m`X%3ewVUM8g;0*Me<}x4shS-5~6n^7e$r$d4SeeV!(zXT2N;n!Vr_nZYd(~80z2I}E z(FC6hv=h{?9pbm)^qY8UUyd^(gRuro3YsI5hNBr{e$Z0l0q07@!dk|@ZcXsv?gvjJ z<`IDT8}#!1j>VOEUG2SStYzKiosAw9^%0~#2D1DY zlr#BCz&9nEO|i^iSr|9YYu2rlWrF$HEZ_1yrVx+xi6zg<@|NVVyu~^GG@RdU+)NZPsZ^^O=QSV$Ml>^+4c{8YC{-n@82igc|=P}RBCkOk_2S9VD z@M+i+kAX(>(R{wQ4wz<^Cc}@;8^S05-_ILaEU?Sd+2rf;0AdHg%<>{v*|M_Mjt(|A z2Q@uAdpx0FTZN}7uw|R4%ex)Bg30u@fY(d%p`foLA#YaMDFcdo6kT~l-85?3|1{&<$B$J_2{^K}Hh0qF6vlSB!6n*4s=H2W0U z;SGj*yn)W9V7oT}+n!;hvdy<86!3bs`&zxc-;DKGV5u+YYwGark`>;rZN5NvS0~J5 z>{g3s3v^2!A(_e$6!I{olZBGF$IIMS?+za{{F=c?ATJ6l+vxx7XxHcQ_&px7q6Paw zS=vs6!5)RJLiQ10Li$LSC*a)zH=@tM_JFsk)r0@WYU&^dc$(lUU(kbMM{`rlR>qz- zdn;HuruL%Fy0=Te-JRw)S(WM-7D(gh z?&2o$Z4m5B>5Z&u3w5>dc=#px%i9tPdOc}E$6!kUqs;rthRl-Z?vSr#t8fxqtLj;BIc}@wW1)*=_wq$Q#({_6FLz5fxo6-m2~pLM*^mX5HouR*A552fAClJw3Ip zY*h-ip8Fd_c4anr*YCtAbk_Siy_G$yd>vlG*jKY_6JfNz4&$U_h}aZmU9h97$sdIO zs$@h@Ct6*1_tubqmF#m(S1_;>yD6%<%NGcSnmX?6+V1N@iv!uUJ=Nak(3UOUfIHyr zp`iSOa%Y#Abgeb!G=d@288)b__XaOoZQ=F@o6v;6787&>8-#w@>+ZlRZxdN+w(|}0 z!J6*YP={CNb9@71l_`Faa_m*5-t@XjVykP`t*xmmU(B74e>?2-cDDG@$B&*%^#J|c zfbS(Bki~^)htD5gqPu}uOzJoHJ(nu~5#RsN19rS6kmxK% z_XD$W{%8k|`#y#{LFNZea5d5n;BLScq{o2!0qF~BFYyB|MXCU<0j@>Th#&CtNR7bz z0Ut%ufe!$lL23X#3ivA|H}DC->=~#BZU-zy+H^Z?0Q@hcAaI6zk!eV+!0muvMd|=P z0C?FI*tbGf1-t`k3FvOXPNapv{eb(C>VOk`8mS(53~&LyaXNsz02`5R0ZwomQZ?{i zK>BA18}L!UmvOc#20jM36=$nawCe|a1c`yZAMi~iJMjQ+z7p+#rxEZ8q!Hi)fImkX z1U>=y9sCe$5BLWF9k{Ex7kEG5H<9)c9q=U5mw>CdSn(o#4Y(ihL8M24j{?#^c+&rW z`2mNJzD;z%pCZM8PXK;dMZ3WF13rT^LOg(5=i&YcxF7H^(l3C=0JBOU2V4cb73q(_ zHNXZWE6(nXfPaUy1b8ptA*5S?#{kbFRRf;@oHrkR1MULcfK&&(5%3_=Lf`{{S2+-i zz*WE+q3BYBghymalU<4^hJb>>b)dOd^GrI|C25>jvitFK9 z;2NM8X&-Pphdqw;ZQuid-&zQN0*?Xy6loAR-JM;rh_SbUtAOty{SY`SgKnhLL_=!2N)9=KlrpEN1K&(!;=UU(bGpv>!O#%h9=gKVpO6W~2$= zf7M6BI6&dZfzbo69vC}d95{c#c2GU&JlKBFfAH0V69>;9>^=1Gq5X#*J2Y@;@X%ki M?T?iGuY2IX0Z%d`(f|Me literal 0 HcmV?d00001 diff --git a/dest/bin/rz-ax.exe b/dest/bin/rz-ax.exe new file mode 100644 index 0000000000000000000000000000000000000000..79f9c3d24ebc6cf86d3a0b3492cc8c40f482908e GIT binary patch literal 17408 zcmeHO4|J5(m4B1W7lx3KL5Ku_@)0I5D8`X!4Mpr1lHi8~oI(_qf|E%yA+zMqIGKUK z(rs{{G9A)pPus2Sx<~%?EUmk3bQJ@~wiDoxpwMPL+FG?W)ouM~Y&Wi+6|?o%F)LCc!Po#G{WP9`aAu%-@|+Ws z*%K4b&mFMTou6CZ>hDqm!Okr~Z@b#$?da$Xsf|80817L09cs

(utnW?y+>VZKAE zp0ROdX!Ftq3(WM=T!^_#SDR>~&jOkTvum{LIvuS+cOU&C%wNXkmV6d-Y-mN3TNT*X+oKt>E$e$@{q4P1ls0#$jBh-JNl9SQyFV04>o&4UdGN{gBlHK8j=$! z?WdupT(Gfza!>;je8p}@O8aT(MtMLm@;;)kyv;k(n1F&$D-ZhGI-5k_Sr3S$Z#h!h zPrHPYR{1gdkvyPB>mBxJox`R_-mKJP^$tB&=g^FDDAA)e4kwYEoJ3Oz6g5RD0wqS2 z$mz;ciL%{@*F;$t&o?7KM?a`_8Vhn6Ga4ydhOF;6#iy}$0%JwT;(O!aNymXQqpA>f z#>;lJ+*|0F0!mRnQFb5%_Qpe!YbNJ9N*s$@h zoctOJyuDDKu>valjM2%IKZ87_{%OedRm9OH=c%Oq??P14cz?E_=f+~8d=n{8vWxz% zhusEEoD`iqL-?ar^gjnPCbR$4^cnb*8P{S)?yGUkjV#N(n=wncPh-v^MHi!2qe*h~wyRZ-(V3;cy@`<4t3`5FcNYnfpQ>a-> z(Xl$mTw@~!!`O??(fGS`46sX&RI<<=6d5k#QPb?ujiN5b8Feb?B;u~Eh@T*>6=#X& zP80`jg4xD$sS;6EPj*{(d3>#X8z0eIh;% z&xTFe%~5@&@pYS+ipH~gqR*t$4A7NFK#qFJk>=qa{r^+v`* zRCNzGig&xfkuqDl1HBWy-d#!i4=yo}lwr8ysm_;>%1M|qoFS**lICNKO zehYkadT|`>QVgd5xPPYe_Chw}6L!Sp*i_>uh#jn%DunzI8)}do1^dK`wuhMA7eg!V7 zKyP(RcoFq>gXll+H~EStp}XQaia3qxor&Tz*VCMX!&*UXF!o=^+Z- zNvqU*l^V$Fy;#ci*hM||*6|X^zkMXh!Uu$l=}DR!Vr5bc^=V>fl;7S7ukq+;_1u>p z!e&HlATxSYI(8_#7FV$OjTVVMJ8NZXUad`i~JPj6sPJ%NB785vM7FisPQqI8G>YZ zO3qv{G@2V49zHzsD&og&5PJJNJQNefc^Ex1gD;_KqWE_>9pM=QGgZC932q9QssShkZ^y-b@xB;w7 zl)tILgq{lT27&1Bj_6V4D6p|wV+yqK;Y{a8%i$t@pu$vuaDXY4MHLrm;5b*~rDD?Y z(t+In74hU08=&21vUKiTS{0WVVA==PXYZ3r@;&h&le*Wh@5oRi{~q@>>~Y+Hd_d=}GP#?B^oG{GbG{S&Xx?)+r)~*XGb5 zB8q4hr$0Vu{7NFrqRZj6@WdgjgWNYZ0SF+AVPg|HU6S4d*ki#HAxT2{0@lD}nb!Lu zWjRcy->Gv{Ua#+db6jEUIA#vKIHQ!W8Ixjr9CVEl8$Q4AcrI#;I2qo%2RnZn_luYe zBUUjP_H!EM14MPmmE-^-RA_In_txW4itb@&|GT+@uG31Wv(R!{H!8^zitzx6;2Bcm z=oZu3Y>R@f4jOd+2&R=~L&e!d@lj~Q(|3>KB8=CgvRMf6awLu|&K?H^92wn1jc}tM z0`~TIh6D*a6%FVf(7?!zH?{SloG4y}Mj{t2;R!hMXcm6*(Xei!fCE=mQZr0!Ncska zRxS0R^8i@}w_s%; zueYKomLRMiFROg@Xp4+mu&zxidJ29de~E<+2TMjI70M3)&s2_PXnq)Ppay|NTl>q* zuS)7lvkDf{EB1ro33#;cCb1Z38C%>APBORlYHE`!;yrC^TSJ^q?C?ucyIKC!cSZ(i zKqhaehv6p%XvxK1pD+K;$kUd6D2tu8*eIq?7&+g|z>z2(!l^ZD!e7!qxuL@IhMp$k z=%w;5?5=F;Y99^X&kK?65^K0c(7RPt`O1vY^=4@eDlH7qCugWUSew(qAHq7aV4n4YwCTQeMRqvhs$J!9bgk^R%Rh$P+Q2Rlm%_*CGqzR9vuR)z2376OLD5z|Su)_G`Y)4;T0+TCFQ)Id;;uU9$ z4%Oj_r&UE+Rdj>3DyrM6qV9qLY&hsy0L@kntPYc4A;PV9`Z~hL1xiX`eMqb5%IhYATVMeH|hHC7PS6R@Wpo z(?%)H8>CsquAzW$g0HrV)}mup$KH6+p1sudA>|9SU+Uo~u37OCE|I|STFb^iohVus z&$F6tffS5kdk%M4| z6X_Yv0G$$+NJy`N7*^zx|uh{??yj3mQ3X(WTs8I0~l<>Ls@wT zs2&;p6OKt2fWmG&_9S+)`-UOqgk+2<1HdA~)~ND55{M~J6Nrrd2jm_DD&?4s0^lgZ z39hq@=!37R`lJy(c9NzG4JRpQc4BgaiB@ww{YUfk$i=*(z4QMH<#5k@z zl}AN=3F>WB-*stI4UnH!mS9#EReFSR(*_MY`j4|X9E7EhvO+AZ7CQ093h$)`1V) z*E~PU`|TsJ(?>M06Nsn2FT=N`%Y(6gqg;;T;zpSrrSFW6DMXm>(5_ zQv?2Ehz=>=0)=cCQXT<@-~#R25;M*BvAihma$i^QaJP| z_oG+Tf7}6z{!i( zNKOSea+1Sq8MUjFXqXjhVlZ|V?{5!6kYAXrj9KG))cVZWGjPe_YtXA}Wqi0(7T@HVF!tZh#hzZkG zDkPKXE=MENbXvXKG}T_g*^8p7J9FYD=Tn+}2l;{d68qe6js{zWb2RQ8jZDk=Tx-@f z6upn*Y<)x`vudrjO;|??K*yL|G>&i83$G*YVuP^G>)7be^x{ zc`eUx%f z^b~@gJPQz#egFDlWqP-f&XZln`65x4K)V^Oq}Kn$XhwxBq}7-GXNHN|Jy^|DJ@y+t zx?0m?wMg_%z83SfR*S6$7%}F_1xDR`>RdWMqPrGJ@W*N$%M^Urgj?KNaW0qugyJ<; zt0Hblm`eZ0f1B0{1MmBcfFTLLDB%$aPe}M92@MI~m(VWt9FTCogxwO>NWQydd69&s zdxqBt?5Ko&68=KMlUe)$NjK$nS$1X77rO;VtAslx{HlbJgqtL+kN;j zhpPnrMF}ry?k{A|CGAK;PwnOH9Fg{oN@z$pF5yK9NsakUD{TyGkP7hHw4j`7Qg!%p zjDN!EMx8sW4y!9W0^w%VHOo4Z{rLBn_W<3ieBJMsPFw`i&>T=>W%nXuBWw^Y4!x z?HxqxN4pxJNprYdNm~T1n={b&%;kRie%OIC6uxh+Vhr~~tlZ^lYS{v0IUU_ zwuRc8QKq%y{bYNNojZ3nHtBp>d5@N2*v0x-W%KY+45 z59P+LE|3`ui0|#q@6tK#12RjYg%vj91ZcG|>+%nQCf@^B=9@@*PBJ#{W^t6hh+1P`V3CE&P5tQ{)6MleGk$=NJ?jwE4$ zg%vCZJwKP_pUev=4Zx>c*z`ugtLZbzUWt!vqx#7fHrdoikop+R30zjrzir}-z7$nH`90Dw{@O6r+INcmOtj<#! zr98EpZs%*VY(mt#R!ijo4VW{-8sa03)&trAXyce;=I?#b_JO9S@qH3|;Ze|NE}Fk5 z)&kSa(xvd@bB6HA|MzpooV?&pPuGqvPdL<4>G1})Z1Z&Zw&Qt!DZM4=^D%ITL;kiK zUFA#4o7>u0E>YUO{tgeIx7#cw>ut>AsrGaQd`PU~3-Mo2_g1gH zXHEUe)wMU@;;P}+oyzfa`C2_K{`Ak?f|Yan*pGw-hy@Qf zVzp?ssk2?!bTY%U6bZ*nJ><0xZ!p-oUHa|*48O^$bjPq@21jQHH<53EU|(8qWKB!B zqlw4EugG7%rf|sT$q+gTTY?y6-d8qgmOS@|{Y_hilh`VS2EyL~CKd*Fqqob~%%f(v z^)q2#aEIF$Z0ST)bTs*@JHrUEAX}bur!Q13!qOe=Z1Qz=t!!p1(x~;^-ypK2W9 z2S%a2-rw%4>RRD%^AX0rnY%I>M(gS@PCAB&O;px~+N!;Q5d2pyBYFza>N-2Oh65{P zpKCip!5!E~QO&*nU?}WuyQgEjzXL7y=dSFk@im6GZ1Dx%L0=aIe-Ft~I9- z457}j0cD*pbj4~5w?E`X6M>bOpzGNH^vhm%23PpJWU1NCx5x*pJDbC8KAq3;^^8@e z`9;dH7nOR`>n4e0(B}qxPXW;!E>63A{^Lce zr=Lm8hUS;Z+4QR|pWm!L*YbQyzq$XpTKSLp{)Zm0<9UHZ=P|k;n1ypl1905;G298V zR^S9zAq9ZD0h^Ex01p6OI~D)OO#FbiBDsLmd(<^ZmBbJDC8Q0&`v8w1X~6pd&m*~k zj{yD}Ne4a-m^+QJqrmNeWk~gRK`-EcA+-T#xEGm>vVfwGzJRm|_&DH_GV~d^1{g(ZBObu_km`Ul+?m~mQ~=x!xavPvCLDUm*1Zr@OOjZ^S(va24=vq;tSoIqXF`O?1HTBRv5;4mffXV^0Go zNdKk#Jn#S@o&8@Sp2duvMCt>M`+D|kq=$ghy&Rq2A3|&p+>B%Z|Fixyi~|%79~?RO z;=$2_#=(mRZHLrD&O@z-0*78aG=Avfp`ODJ9X@dQ=;8ju1Bd^tZGWunf87KB4cMR| AkpKVy literal 0 HcmV?d00001 diff --git a/dest/bin/rz-bin.exe b/dest/bin/rz-bin.exe new file mode 100644 index 0000000000000000000000000000000000000000..5a55e7204947904484108b1593cf4aa68e432a25 GIT binary patch literal 17408 zcmeHO4Rlo1wLX)~O(r2BgAxe>a)Aks0&yfzgNVH$3EpVHDMU#rbn-VLv&hdlnc=U# zzTiN0I;7>T{%HI9DnIr;t8If4DSuy|ntCv48Wvea^Y_ z7f`xhyWV?id9%*h`|Pv#KKtym&$;KEJ6XHw0Lx~KS&`y##s&cC(Rlv;nStu5bDx>Y zzMFS$-hid<+`RgBUyte!bZ-qbb*e2*U0vNlwb`o%LS3q_ORc_hgWB2M>MbiQ%y&rD zGdI-+x2(MOS~I(TJO-Kbq>u~1|@o=+TkRUlapqF1d5uZ6oV2a zO88X8$#|&`@ft7v6wf=6pQQ(CoyN7guJQu6*t4>a6}b=5uMBXls|wKon5#N9AKCy81jjs6%0el5lGYg8dIoQ zOVP19$2?;b2E*8g&e8b0bPTXd4_C0@trQt9<8jmM;1W?6<%~KNbP{pbl*gVSt>tHk z=8hNpZ-CjxYN--YR_&)tUy^e7?ru*Dq+GyE~5~ID4#=hWFk!@7kZ-_JN_7tL$Qu_NuP+1 zBXeL=W^+_uVLWIPQ_=V(ct}G8(-(74#Fx{!AN7d)2QQ*Qmvh}|tp5{lRD`)1o^rkl z`7b~|(*V9+m`eCiYSdFZ4V+zX(Qct3wd>i#dUTK~uv}0E%tn~4=xJ>_vDoy!YD)>x zOH6u>zAXl))Pa%^N0~SxR>xR@9<@63Fj!C`vQuASbx;&q9Z{`7UxD}w%rQ&R0!MbG zEgIwGo*W{NS;wB`vzR+d_Lz@f|LjCZ&8|81@VyQf3t5-O#{ATpOEhbB6g|yWt=+^} zkgD$DM)7VJIFe>dcc6Eo*Lx~x|G^~|kTMKcEZO-IQaJ@vhBIXKTT-0vMFXXnu}sD! zkFWc&@*?iZfI8#VIL0xm*>tqV-314cxqXErxASF-!faeGdU6`kRqB_@f>)3kDtX5l zvi4ixn^Q|;XqRFz_2K@R!P^VkjBD(O$+0Vqmk~QyGsys(as1Em_yN;s;x9jAgs|j@ z`AR$~UE=!A<6V-honibaQO+}71D+zn`G-I=P9QT|Nm^KkcvkDsu@ZWbnWI->v|_&k z7nP&8x+S!jdfOoS&-+cjqDkm3e~}_iqk3n&`1JKO=isn*5F3sCSM#`-6fe14d9VmR zzPA>p-3Pt{V@1ZDFp;lEHxPl3qVz{8^*}|IIit<#D55R*v@#zGEyhz*!D>7KHAz3s zG#*Zrr@+U9D5ZEx_=NP`y%DXp7adbx(fMm2x8HK%O@vVRSw}Ab3l>Yvf|sfSf^i!8 z0mFs8FGlrdlP^R;^pDVCd}*dov@~|%E8qwDYefEZl6)V?V>|RA1Qp^D0V!uak4QfM zT?tx+-ltSUUhl(Fu16>I=x>jgK>qDV5-fZ`xR{=xxgl06#ZaFjc3Sz(ZSWe8j&{!{ zQ$yH{hz3&AND)A-=bVR$6azH)P9qoVZ_>}}iIvw>=!=HsI)(=8DNKlc;`c%t@5RI# zfrST?E~+_7(UD$rZqUTS5YZ~yAgp>oY_*)mNo;TsD_LVR=r!hoMAldVmZ!eLndpmt zzgz?!KvbJD7*PdvU@at>3Tg!{Tt)9~mvIy>6xgG{%$Z{LA8u4e)<7|OE$oidtf+Ii zjpt`@OR&CTKJYm*md6JYJz+#t$8H?Ef%=aTD2zgh5zQ2F3K6F%g5^^zC1(2-Xun;y zFV>)V2yc7ZYr3IqY|hv$YD$x%f=wsdx{2DFi)v_-lQ2ae$F*KSR8eTp;^2%e!Z4i3KX;%hK^WCmYC)p&6Z%6NysOjR#8Ljm+3;M6pk zPD)(yVhah8mj_27MM#D`wXRMg4$!=zBeCoBSp?P< z%BQL^p|6B@13>h5NA!sDD6p{_V;Z#a;Y{U6%b_BDpxjh|aDXY4MHCll;5b*)M8$;T zr31PD%VUWtHbA@2MCt6=lqxPUz_jX+Kv}LxM0$PDeIS`-tb`=&RkFX zEh)ypf)nx_Vvc`i8H>StRVfyt{M)oL?YDlE@Fe#R_H*H3eo%tfEXEmG>lBg0YqMw& z5k)kMQ(qr6ekI{mk=5{8C~wH>Aoq>s0s&-EY;3}(N>Y0Odn|Y(BuFSP!NvGb>KpTJ}o zv5LvCpVKfOAgV*IBnuFsLVJ6?uO6>bbPqfG9I6LhrG=6Iw;^sQ7<*ZjeZE& z+m8(i5_T#Y(7m9MYg4ryKsjFgDKrwEu!M4PI~jNb zWNDH&#)}sN1y42lUClz%NkJu+^C`l!ZL}rQ_ne|ppjn%Iu>S0M>mXSMw_s%;ueYNp zmLRMi+f=@Kbc9DOSl6Z$Jq%tAe`X zP{Bfa#eOi9i&y&|5{rVCw#Dt@By(%8CO5ev-cz==)x_z<4!hjbiGAk@LM29P#2OaB9t%@RRx{H&l4v(Az{Dy;R%@PCAkAP-jG$8{WfDaZJ1LJ9eQLlP0;XLs@^x}!E2$VZ`A<;E8pn3x@azxX4CsD zCtiHB3TpVI4K;xadUP|QC45TF9Pl)K8-+giMfLp}&bu6aSU^%D)_mWVaCdNjVv&j_ z7AmtI!9bgkbF`$0$P+Q2QNPN<*CGqzR9vuR)Xx$1xyLIp;ODM0xsvmT^Iyb1+5S%; zM$<-EgOSLL7qdO=0t?4+9yeAd)^Q@S#X^1z{)GIcA|^xM$&4~BFZ2>hwQrZuKU3(B3jH#op2NX6 zZ3Vgveb=SwTbZWsCzqiQ0GBpmJNok#FuD8`MW(wvR(_`Fa2?)w zT4jV)MjEV@5#3f9aTg3=!$I!?Xtru#b(jPT5tiTP?Ft!e(6S(3uFN2do*ID?`C{Q;F2O@pTbJL) zkY*LTh626`zT7Tai;h_x`(j0V_fgk}l+Vz9sh6X;X2nOicpSrPEgk=8yl7P{$HIc{ zWVtaXiv_i0*-vFxvh2>uWeNfl=VA2w0wv;Vfa>6oODcwP13d5|=!2#jntcbD? zh{=rRteWNC8+lXwZuI?Q$y8oKW;*UI8*uyuCQctxe)AErcN|jA1A}c0;rtFzJv{nn z9Fr~ph23`SN$h0zq9NrO$rx1zfQ5&x5#$?9kLKv%iJYQ+^b#FX)<7L?YIHcj}JQ(^`#&OzK3v+EC$ zyfgXc;&RC7&6T)haq+S-2QHxZZ9~eI4_c~%zFqr>rHhEm$goyONZPsqdc zZ15mza*xxxfDLM2;b##YMk!_@b-x1Pau0^p#LyzNO=;u==0;iM4z9MnAr{L^S436gmCGR=@t}^U5U1?lRe=(R6ZY4 zzhTR93i9h!Zm1>={TXx_ufuufKn;^aQwFMm%2DM>0ug0C*oPDwa$#r|FftTx6`gIj z)4AErLUi4zgUZQMx97t#dVCo3f*R4|v54~Kjj6-cSNJN*=n}?%x&^{236GJS3U1^i zhtD!<&wQd`R;cm8=ox&!Jp@61VNx5l#`K8w`LXBWk|S53S69hxWW`A{UU%xz{f=I! zju(F%>xdrR%S(E+cLGG3xVpT{anp>@ao!|0KB3VwE%Ppie>~xLIgP}G=_(bH$#j>a zk!d=uUT&Idv+3ZAaNC(aaTD_?#lGYGz&y!5H=LuvR^c3tJ4Ykavi`0;;~MJkNdt9B zUPD!XwsdQ~43yHAsR#TH{!y;D=4P#jO$Nf?OaJuhAM6 zaYMpX`ak~EuNMZke@wu~WckYy-Y4OwW&IZ={EmdDBz#4}Hp#zEmOmoPS4)^9;qPR< z>7EzY3GAqZUzO01@T`t#D{$+A_Jn+s7l{u9o6)YWIyVRdDXK$yPIw#zz_{qXtQdw}j$vU{_8AF9FT4)`ws>CWX~F=OYE z9-PV8Kj8N74WzR9j4j7yM&m-pK99riH;`uF7c2K6W#Mb^^+uBBF?CT2b-W=Gy1c(Iqk#95j>4CXC5l)9V{-FJS^nw2d z+0ofWw0^X$0h%<2%ayQ4&~|bL`b~40kA6e!z&Q%Pajs+xcSNkr1M-BGSu zkFSYUs6{!0Mnro$Z4>d8q|s`*teQb1qBDb51)3|J#`RUC(cE00mQLe*dK#^s^SMET zn`A%gIbS1aY8GhnH`%?_{K8O{9aT*|!P`Pjf!4d*f=$gG-X5+9anwtCxXff8vK?y= z+n?mw-rW)GY(<&Y4=WC|Qg-+5-L1{!VmpF}`#2D6anx4wW=hg%o4CDdDy?4dIn!u@ z&js2k>eo*3+i?0#Jhd;!8Ii$Q111H{5lO?*j4?lGDe-`FC1PP6V_&x>_;B}wrxEiA z!2FH+L6q$|C^z@?fDA?AH}~dm(>d(}GE1R_6*l7}h?!x!PtTu z#p&`((-?d83Na@MT5!Revoy<{XeZCY@~B;cq@N(^m*qTyhm-o^a9%Uk5EY&yn5K{9 zY!*IG60pF+3RZ)jpUv`5_2Ml;~$^qFKY#YeVL{ZtE^YU(3MeGFvzFDhs9 z%?DpzHp{b2XIU6G&TH1KmSutk*{s0wJ*E(k^ob?k%JP@xu>7St{xqEGxn60PStk2Q zw`s4bClyj#sr9MlD=q9wDt`c+S&V)k&2ss%Zo3h8yifB*09s@m66AUg1D06$T18cy zZjRkF3!By~<*D6NJKvOL6QbU^Rw@U$9rI>D!~991eHOG~&?Yd?%qIu?&j&zrr|@am z6OV#M^U-|1w;q^gmL|gw&l|!g|KHCWRu1^_Kc>u8kU}kxVt87JCYexs0n}eF3 zT|J&qu&u(=6xh1m)8*ZPUBP5}Tfplj`B2c;k&w4BkEhDhK|Jwe81p}r*)2;g&`$Gfw|>ks<6yV&fDQ9Ui) z_;QHG8IE+I$^BZvc9{>@-n=o+iJaH_bjlc6fuK z9&eztDcJ4}z_zCusciFY4F$ZO9llmC?>A#T7Fg;F`kFd?yJdy9Yr8Md-PH**8N1cu z*$Ul~M@XhJ1cf|I>13fK?(s6W)w|ON4ZmhE637d}$~O8xJKFVmJbsUdtZ2c0P?mPk zV6aDEtB`#dn2B)%-#xC z&go@85EfvpJ=}=3qScn}PGQrDG|y6`95eNh*SeYlf$kmBZ}+76O;)8kh6U0%y1TfE zd>aJ&QhFn6+Cp6|JRW{Y{_?hjf?iLW&|x()apyc>356gumDo!-ixHNFlnVeG5fwTUp=P=|5SF+?m+Ss(1EYVrr+zbYBg z(}-5r-Mua3UnBcm(-jQt!fuLc?)C+Op{9(|xPl`rMa$G;tRdOKVE=;Mda<$8dAZou~v z5Xj;}w8Q5QFH$`{CNUG5zeLWYUvBx_7WKupA13vi`<}~{|B&y0=m9(45=e9wqx*r` zIDfPQ$9*5eogniACwK?aPT+397Nkdk`vK_-YA^8vE=Q^Wt^uw?(ug1Mb4ZQA4*))b zqyz51)9KfL}s-1o#Lb{evg{|Cb+d z5b0Y)2mC2g4EQ+UmsPY2{2<`dNW;VfxNRQpkAV9Dk0Sj7cnmOWKIDL_fVU$35x54} zfMmtly%F&5kd^`O1w4Xu3-B1=d8BIK+Ycf(2yQ_d2mV)m zG>iij4j&ph^va>pL&l+rL$<@}VdvrY!~Vms93DSBak%%$Lq`rCdGtvCk%1$B)wVxW J_P_3d{|08?A@l$M literal 0 HcmV?d00001 diff --git a/dest/bin/rz-diff.exe b/dest/bin/rz-diff.exe new file mode 100644 index 0000000000000000000000000000000000000000..8dda3b5bd04de1b582fd1f3db21024b2042ea2a7 GIT binary patch literal 17408 zcmeHO4|J5(m4B1WmrO!J1|bqenB(X*_@L%s}%YHSIEmq^uN70TLH#31jT-m5gl{sK^71eTN3Z{Pi;C0v@krtkI-h z1oke&SaCyTrN-EBdO1s`GUVMJ0&UY=WMmNa9sNlEsf;yM2HToL&5S*N1!^>;X-H0_ zw4a8WO2NkZ$w5s>@D;laDeb4B8~0l(XT2bjzGX;h zKkWiaTIC1mU*rKj+UT%H8yq%0@%=O$6jw~Kg9G5Fg+Ft(~hEdbS+M%hCk#)gf5 zYsw#{;D{-0$^xRk^ly4;ENp{iS zb+Fr@iIbvpX9$0Ei2mnb#$@)Nnm!GGGUH0j$h~!rIgzEgcQR%P7Yh%~CXTW7k)^*` z4dvmF3@JYcLf+K-N?YJ^IHDH7h|T7GDjdLy&d$#V2N>oEhC*U!1H+JV7}7Mq#uRGS zQgW=pF~`_|!7%oqb2R=g9RuvrBh@T)J4J@ec+@mIbiJsHaYmgAI*GXJtKv_R)~Yi^ zb0VbZQC?q|sz6yc7?ru*Dq+GyE~6NQ7@tE8WFk!@7kZ-_+y0nHK(UT?NuP+1 z!?R#hc5_r;Z9HHTQ_=V(ct}GO(-(74#Fx{!AN7d)2QH#Pmvh}|toajfRD`)1o^rkl z`OiZ>+W@{^m`eCiYSdFZ4V+zX)o!C9wd=XVdTfv?uv}0E%tn~4xS894Uiv}t%W0{Oe z9$)vD()8xGH5e}@Fpe?JrlU3PE;xwH?JFMn2w%1+%*OSS$EFZnrGBX_bOo8Al6Rb8 zYrh4)IkhN`b}0taf80OQd3zz7ag7}@IX2aJ9A<&Ey$jnw!7B(QB)dqB|j2>j>=v5nS*ss7v zRp_m52`{AHt{461{U%@0By?9jOA)70y)#jI`Z}6(a99V3O~$^fcwAf%FZo<~s02Q~ zcLhwl4}AN_N{l;UB43YgAOasn>5mHPfr>19Mw`=7L|gu8r5p+^#^aO0YJ3}NQeK>4 zJd`X?f{zDLO7oQP3F*6g9a`-uIi|dz^T$AbzvcX^2%*SRj$Qy3DwUW84^;&O<23U9 zh6{UNjOwi>UzmdEAECqe;tZi^QT+Uu!4L9RiTtS)`96@xw&_C%D#RlKQqFoFk$nEU zlC)~QPpN~v-iM`Jk4@;YH;`u_EXmGfV zr>ApEu)bnG@HsM8zy}gNVMJ8NZXCOT`i~JPjzNhL%NB785vM7FzeBb! z)}TZfPkY*Hx}j`r*4RvHN|U34O()vAh1!~pYG{*_FijuH&Z1a@9||e(sPQqI8G>YZ zO3qv{G@2V49zHzss^Z6O5PIto9*T+5Jd7Th!Iw}qQTkh)j_?eDnW|o8h63n6xG0^J zxDusPpaeQx`rs&}2+5MC*3}D$12k{w2rg>oCY$3!fSza`gb=K+)&~|Hdgb~rF97Re zdU-nD(Ca+5EI#V&v~a+lkV@pL@ZADeG@Wz2U<$oV}j* zThfey1t;V=#2o+ZG8Th(Ytt-5`OSlBg0YjbE2 z5k)kM(;pu+er1uR(Pi*jxM0ZYAoq>s0|8_)Y-}Q@%F=rPdn|Y&BuOZr#~PR{(|SLo zEQ87PJ9(DM>-1f3j4O;C$IO8jXO#0bV^VClgRU`R!{_E7&qa+9C&T-8W9LufK7q+F zVil8NAE#kHKvaiZSq>mVh4%J(Un3r+=pJ_VznvrKI<15{3oWB{qna$C7!QyLo*{LP z?P6M+ZBfuQK!eU7!L+ihuR4<`Jpyfb`tEj2z<50>n}rZBN8;Gx>~>JVk2sipc zU~fG#BuLn)Xh3&^21ahYsck>XiPDv5Br;(M=i|tuS@_9E!@7wA4qP=!%`mYk=^GR} z$iO=wOOw1QQCb8PYLhGCJ#A}SN1RUV@XJ!WS^m^_Mh0j= zCU2vM;WY!a%+eexU2T@isl*Sa>aOi7)4ps8R~m2Q z20*OSIC_be3q7!{JJmS}XS6lv+9$c-@NWqVzJNqa|@ zqP=IZG^9?VzTs|%qr9JLJy&I`*sNZGlc$_&@UtE zyEyn}tU#BcZ+?cpB^mmDdKvmKuFumoQrbwvV(v^^YBlCVjtsLfHM-i?_a0rjpX@9C zE}c(ZbPd&4{O%tBmJEtLHO5Nrsez zD5ZIWG^^M(6!A^)<#y3pa?I-36EE4lhq^wbe46%4y&T0gD_+7S5*S`<#rTI4B}?OZ z78Y`+%1wDWETpB%0V=yvWp`dK3#qAc6P4|$ascIUNldB0=tPDsQRQkNrq6TaAlTtV zdPXxqr-Wq^(rX}wmC})4vhP2D4&)@}~IR=zGVKsl1HLblh7x;P?wnoHnHV=0jrdIHbG|47TB+th^0W zkBt5q$E5Q>VYeN75KRQWau#FVE9L`MG;a*qL(a?C~na0KB5 z*I7pN!BsxEnQ99N#o zqoTeH^){;Sxv;4w$WN!qP`sF&0(}op@u#cT)rM#H_49 z0aqpDA8hnLg_}<0LsTCb{XW`XkZND0_UFm=$s8TMx3MspY$XYpoDY$So5VdTjy!tR zStCj#5;@iMG1`V;wZnO?9^5Q+iM2N4JeRt!%zQ|a6*vxQ=o{X_(K23bVDHHI(vr3f zy6}0koP5a}c-0 z?fQcx?@T?pxEwNiawRWWT)b?|f(z(*yFP8p2d}rcm(1RcDh$Mu;vH28PrE)iXm5XK zFp&sbPU?ea?B|!E7ULt&1Gtnv2$y>(bnvXhJ1#o1Di$iolnn$hKdJ<$ z2K7WN&~xvU*6ZGiY47=K@x-TSlrK7sRyyM%N6)-q&6S6y_GK>deV#vZv!;n1Vp zgI-bpaR(^+Pi6F<0QwKZhLp#Ui#|UJO!WD2iJ9G?KL0Cdm=G>KI?aOOv8iZlzU&F# zq4N2V{tjD?6TLsiIFX^6H1y}tWxNdMnFBRU4ow@V^;C{2j}eF}}?tFQP)l+h)O|1=APRT3T} zIThT(gUT!zG8WK(DTp+sNvZX1s3K zWBVMvP@O2P!8)SHcJq=R>zx3RCax~;a@;f{^h9YnvGECwo@v>4IsD}bzsqSNCQMhU zkW8k#9F0uVY4vi`RC^g`FN&t^nG-iTpVI6*$PdgH*yo0GG}tPfqjBeGWLnNAJF>2! z=zTozlDvkh%eaQ(26NLpE^d0(HPjq3eJlrm_wx=UD!M^QR5bH^Ezi9??}p1j=lNQm z*Yo@qp3mp`Or96>Ji(>jh=Sz6L zl;?uKhU2w7ujl#S<84x+Vg}D=@_ZK0XY+gx&*$>Ig6G%rd_K?D^1PnsKg3(~M1`OW zJ;k6W&jN&G-@m?Jnci)r^JJHCzDQIg&~8R6sr5fGno%JOY4sJq%P>*93#*x`$9}Cx zS7~~z9*N$`*JHlcYq3=TBgS00z^I!}o=xXRbk`#Z{#da|yrzCtq!rw`lC*`k_@DT~WB;kD$u9p0bviu7~Hm-b#G;Y|{* zk@b@$v`YBn^45%d=%yr8+ikv$i*BMH6r7q@dn+BYhpA>p`$6B3dd^P5)M7}8#(2(L|xDyb$_ zhcCzYC!CF_Ys{*{>dGF5FukAckaZ;c!S8SH0lHVo?al3dupXN`;J*N*JC_5cjJ=NZ zzzoLz0k?mzAXSz#b~7$Bn&vU~IUIh!jx-%#tlWo`gSWxgA+5X~yH=!^kyc_X-=^`j zGqwT%bD6nuCpNl}v05weMTig3#{s(l*Q~8u`Twiqt&CT^`nKaI)XV4ls zpBpr|N%o_W^EH8{=71)@$?mP=7lyLzsBP{E-4SjMw%y$xYHsQD_Hadrqh8X(WiI3) z+p+ereJP%;-JPMXHk4`ou;M@~Wq0n}+15fXwj+qRkAtCB$BG)>Oj!nP1GiUAr!@*b zX9i91xj;Kb{n{?R4X1D7seL)lhz!QoV^Yu@ku)657z==w77sXAA{JIN_BCsg4|hNK zHDMkBnBS-$K-r#$a!XGS$WSD{xi`N}=d}09EX5X9+=7#!)xxY8m-mDw-+heI9+~m3S%!`A?74O3odx`7Uj5;?G#v80kunz^b;igvRpv$P)c6{&TGLMqQY|o zGxU+1&BEtN5*Arl(K65rb6MeuynxaKe7c2AZvniVK9lUF_{cV@pKM{1O??EZkHMV4 zMdeJsa_|-8vI5IAmVey*|A>)xxGy`F-GwQuO<1jw^t5+l{#6eJU3LXpwP9kn1@FSZ3jC z6;*M%Id)SlY)Xrir*_lrd{vfBi2CYPQaL~e=FPB%wJnYI8PEnmo4`CXe|gwnuy+2{8F(hkBbCpm1)fIcYE5rJ)vOt4o|1AC&buH)VGF%LA=iMc(=ED10i3xpIv=1 zs;9LZZw~SQPCHwZmmcA6+5Pjeu^n`R#) zJG`NAk2l!W9P01}VcQdoRJQvzhl5_vHeZ{Udxo(d3oP}8e9fJ{owCB~-|7o?`@3K! zW4Bv8o1t6s2+4GYkdTKdT`Zi!JznOvdbj(a;nxgC0(nMQ*-rmwN4q|cC*bjr6|LA0 z%F;F(F7_~N6|xTj6Vk_WJVEbfxDkC0bp*Z5Z65qLR&ysgz|#y@`9dBPJ6oDtw=nj& z*;~QNIlb%$!U9Btha0gW2PSRn!h<1?A|8*c29=iWL3IjSTKX5 z+s{qp+aTDN)*D&V9`?8Lc=#px%i9_bc|93ICtynuqs;rt2F;S^p0KZVi*OQKsn9_9 z{9s~XaJMw~c-wf??6Q6|><#X4dxP!WhzftJx3)Ws5DT(pId^zNwIVFt!R}UXPtS@r zwmgm6$o&l>yDAsFYj?^q|l3}#A0pp}&h**KLCe&Hm90JY?)2(>j;~{^Ce1HWj=i8XnqD_aY-RnL)%6Wki@5XgZ--spuGRqh_`&aTJwTru z@Vx{Ca<~xf@cEAysh)l&F&mm+B4^Vtw|s7s`fU4;Qu@t(&*jR0!1q7&fE`Z>Bsz=H z{lL{Ye{=xHeILV}APWE|xDshQa5rEp(h=YRz$>TX97+6uHzQR8r}wC55{47!v z@cn=fBk92V0nZ_=2R;J$DHtwzvp0PrCs2KoWOSCH()1Gwobv;&?dz(d{f7q* O|5e-mK-vGg2mTvE5F}Rs literal 0 HcmV?d00001 diff --git a/dest/bin/rz-find.exe b/dest/bin/rz-find.exe new file mode 100644 index 0000000000000000000000000000000000000000..18202537a785e5a571b51d67a24dd603831cd605 GIT binary patch literal 17408 zcmeHO4|J5(m4B1WmrO!J1|<>{ZplzIoj0~c_qaUe1m9eJsKwERLnX#8ILyd+s9m$E5 z^3zaLF4))rIj9KquehTc^}bN-sY_-OhCb>l?S|?J*}eetPe!ew*o2U zr%j@yRDOj1MIO*24Gw#x-eJ?jZ&&Kk28SN4cWB09DA6M|4kwYEoOBgPpr}boF(^@@ zgill+kC*unuko_a@VpE8Y5GB})3_#^F{6dD<;eCPq4+e`V0SDixvt_|FHNDECkl8?A^6)sFt(^f%>&h#PT9jCMn{Z) z<>WU};Ozx-jFnKi*BF~h`SZw=>Yst!-ijEyFG8t>1hA}C)Zly4yA33k!n zb+Fr@iIb#rX9$0Ei2i3`#-#V3nm!4CGUE!&$Omd1bHmHC?_|spDij`?LmcCc;pM+s z4dtQRhn1fLA#dva#Vv3-98nEmMCb56oGhJ0dZ1H-U#5YjZi#uaMT zQgpc9G1pj+!7z5Cb2R=g9Ruvr!<8&}D@BIOc-%BQxKPwZIipSmokZNV6|tkFwc-@f z-0@=n4KUkSAyp#EY8;hZGa*Q8PvEs!iEyii+f_~@tO^|Z{a{w+dlr;GT#+G#X-Bbkgf^izM4nFc?#Q1p6 z$m4M|8(f(q%Iou!6)5WlqcXQ!B}{n8WfYOr(kALT^-K>mTEBDAv&~=@apB za5ikpY>w(HjR$RFDjL584{3;C`eF`>_;MQeqaJbp-~}}3a;`g#HGkrbiZD0BQ_fc* z|7FN$8o<{JQwbkRje2UQfwSwa+ATDsc0GGUj}B1KHH3qgIC=1`A3=cIr#54vIpnBdQhXOA&v8*=8wP;K;7B zMPr=Yn?vMr>-aN#7IR0*9`o@Vn3d?L*)^vgzSrSmA?u>pxSv{ciDs>iqNmyNRqGiG zQq^7DDBkS?N78KR4)jj+dS@l=Ke)s^QikD*B|Be2DyLw|aE7b_ON!IIXrK%;mdTjp z@pV5|Uc@~aP;a~%$2dkcn~v7FyWk))x4&@ocD`&;m`&(KPfjDcO8rt<@G>$(CGR*x z)&UEAb7D~p?NSV;{<7zu%a{O}RWyB8FOftY`9QkuRzSlIG_$y8sAuKs! zz7kJLm$<&Oc$Oq5C zMHT3+ZV4@*-ZqN<^L~@BXcD?BUZjZAsNNYbK6xF@IXJ8X#3p0Ul{_vc#Y-+%9xQ^7 z@2!Jr_knNkc#&}@Oyuj)4MgChDE(1JJy4Nl&S-NwifGF{sgy#Y#dvBeSdAy3Ch4b{ z#>0v76!>@ur4&yIpOC)0*P+#pqQlB7I)4o04p`2;i4Y1u-|{D_2_v$`r9KVkbmcq1PdP!E~Y1FZitmhG1RAsom75v8@$G&qr>y* z)DSi!qLI`zQ3O!yIcH%a#Q+Vy)5yj8oAmP7n9Ycc+6eh%e{`W!}&&9+V zfrST?E~+`o(2+iKZqUTS5YZ~yD6D!wY_*)macpo9D_P?+=rQJkMAmo#mZ$#0ndpmt zzgz?!KvbJD7*PdvU@at>N@@iyTtUxmmvIO#6xgG{%$Z{LA8u4eS3)s*E$oidtf+Um zjpt`@OR&CTKJYm*p2r6gJz+#t$8Q|Jf%=aTD2zgh5zQ2F3K6F%g5^^zC1(4TXum_Y zFV>)V2v2+3Yr3IqeD?TN)RZPi1)EN^brZEU2i4FfCt->{lATSl20!Fe;8Ek_HZugt z@T8o%VrVosG(3EG}e&#aCnW$PB)Os`26+l<^FKnW|o4h63n6#HndA zos_uZ#TF7GFAt4DijWL>YF(W~9He%jcL%vhclHQEr*Kq!3t9W!U3jG7ExTJf#Y0FGZhn# zmk#9quZSh4*dXmb6Q$FqQ>wVcAk#juK9ir;ON{(oXggl~;Jir-rmSCrdc%ihICDK6 zu%s9R3y#Tih&le5Wh@5oSEpEr@^911wBP!1!js%P*w2MW_(2I?vlypjty4q}ug#)C zL=@31PJMjP_?3j0M^?aVp}b+MgWNZs3j~lwv9SrCC`s)B?6Kg9kRYLa4r^edOzZuy zvH~X4@AzpduhVzFJ)tmm1TzO-^p)~8V@hT5Wm_ny_0XX6M=-4{jTNWj#l~D3Pc(NP#_JK;EQEMD9K#l8mxBV16!lRf+~|jZ zz4O?xAYrGX0o?@}xi(eXUXV;OWZI49ySYENT!)w6(v${Hmm` zI8?BZUa=nx<>Jx4lfN@-x(gH0hzj$ z9)?#B(vpk4K41Qw;b$xlpe%OUVxyQkVdQ)-14q3037lFpCj6xS$qf~rH}o_SM=zCk zVP|D)Z`WAp9$pAUDqo%%yv{7mrP3_3R7xd&FjaSMQspa~j&Th;q#KX?ta^e^8_VA&hJR~F5I(rkL3 z<;06`RzVFPx1lC*PLFOtw1iKnnFF4tZ=KNRzM#He!+DpY4+}_2#G23B67CM}Pb^Z= z#6o4(BN%8Ca)y=^5qTo!GwPRH_*!H^oQeyUjQZK4KKDo!2K>ymCRcL)aQ+L}C)@ui z#AwW_xn{`wQQ~fC=PY!q0XuIVBQq_0 zjEY3*diWnBW=6y%$p1w6yjaMO!=I49Sj1%LJDyRd<%J$XsrGFb`ezFLQK4T()U!DF zrmaAipzqo=eaq7H{qz#_VO(FPYowHshQ-{Ow&ZHeha4GZVRCe}Egw9(azEK$_$-}I zU33lAU-~NP-MC*Vil)~4%Fj` zr&UE*Rix2c713=~5qH5LHXQUUfM%-(R)chK88WeCsTeC$7FC2YpE4xNcWdcc~YxhfRwFqKHn-tM4plIGT`RW%9Cv{6d& z25DBYYbfBG;7jeIwdk9W=q+!B_}MimC+qErZCLpUndo+Z*ermC746^!i z%0uYokCuq{pHbySVBrxhqMQN(Z7&lDkG%$MF93zG6WaR7J9IRCnyQPAPTe>{oHimf zBH>aAQ6 zY|x`tJnH#LrN+^LYi2v$G()CC$MrhZXo&`$glR>GwQNTbzfBXq<&>C#i*pb+$L#t; zB=1Z<%8GT+l%JxLKOyLS>g5ygr{8}8nU;)Hx!SD zEXVbsQ}%N!P>b=A=K)+w$BTP#!O8W;i#vhFi?2X_G|$RndUPaS%uq^uxYPKW=Lvb3 zo&_F6P3{p|7qCI?FZ=?c!zjZ{r0!QDT<)RJ!LttUxai2LSg0IT))T<|s1TeQ@PC8o zu<~tC$cAC%VPFU@(7q!v^Q;7gh5Jcz*lMAclk{le_C=()-m02J3ueS4CJ};tShS6I zuH z;|@^tpUUVz0rVe+4J%I~7kz#lnCSCU5;MC&ef}5FFd0!D`7siLzj zb~-n^S%|J1bx=8Z>Xv*sMvsqRUQi=?JQh*jyfJmS`U_u08C}BoPq#o=CE;Ui-dv5x4`UA&}6`_6+%6IYjaIc}N}I?kKK#wRp-re)sc@Ruk2E~kl@FkPiWGMVmj zG%`)6)yqv&Z5ADT5pLVkCvIXsrPz0bADAcE=Z14M*eaZ(ap!1cTGnSfGOnTijx?|2se?&lqdm-T=WFC%)qY%R~dJYR=S#>?t>zKrJ! zc|M2d(|DfE^Z(@hXL%+{p*L7>D@*uPi7hCi+EW)vz6rfA0JC=UKUd7%YFx=lRVm8Sj|*D`fEM1 zO4FmYNc2v=7W1`Mi>?9~HRj0$M%{S)bSgihyB10CM{6C+6@1u)TijZ4F31H!@fxjF z5jP}ErT^o~3%ksx$`AP|MB>bJM zH{J8%YJnY+@EZ~u5}uZFCV!=*o8^Ekug{?W{!YOWa0|Fg!f#0!lkjy3&r4{R_FXOE zVhL}N^;0GMnbbcj;fRDW2@gs5PZEA!!gdK)OL(({*GX6+;TqY_+p=tx?r&tzq;@2sulB-rj!OH+Bs3(Pknp^Oq{jTFl{SX77b(DN(}HrU zN!H=ZG5!f>1L_(w>ae=9M<7h^XFFsa$$s?v+k1fSRkHiC`yQ&r<_`ET0O`(UUom56 zksh4M*x%#!?+v8#QpT3xGNWleV_(AI_uEJ_@Wsk~NLhFrd>zsq3$bfOdL8KwjODvD zo_5CS05F%C8+T%33mB`m0$;?~TF@r|y8zd$tyz1^ofBKX@Lrz&wWGV9d+x200-6rh zH*Z+k9O!87-VpHZ@O5u!3HdtPHnjM<13NYZb}Vf7b+?%ipZT^xg3%XnJP}TZIQ~QX z1Ly<)2HDZoO|${DtpS=ehs%|)N6@x$2KuJC+(+LKJ8+J|H_laz;f{!vyIig9n}DpK zqdUsgYw$L)8nq~A(1>VHr>!Txk~CT!msK-pM094*szGz5)40CMG@6_1)6!|2Pfw#Y za6UI^aFgsu1Ltc3P0a#Lev{o-!!HbF*-_ox8@w&l9B8|{J=omR>Fwo;5J!Eahs#Xn zA=|O`usunhEj^vVt~Qiu{jlOdD`j`=*wNNPF190xxQ_$DR!3bGZ>A)Tww~LorqUV& zpEHdn_*|f!pnh!=--gpS@zlN?XG8{LjhGZPMd)!GE1R_6}I3cXtgja#^nQ{$#>ty`SM85 zF~;WIC{CAOoyOR!mx(z^(1HuzoJCpgL_2vFmPhRpB>e0^#}wj`KC$FmS^nZ2mcJ;+pN3OC*DLKZ z%Va<4HtjX_q(W*dwLZ0cxrJR$eMn%%2q67eE^U?L6k0`OCrn^8wJ@ zDSR6C#ABe*d^CU0tpTQ)rOEK4^M>%r|M&Ao4h!t?bT#|BJ%F?WFv|;F2% z9Mtq~@AZU&?UkP9z@{ypZtqs?3MSLr170u5hl0M&guIP;Jk_3Fzqi%b?rZg6`_b0v z4KP*)dT+4J6Ws3idVJmOJ)SmiZ!pla-P7so4Kj8W>RUsB0AA;LyxUs6{-Cd?o6Wiq z)zjL8H;4FtsJpAz+_k!)ZdL7#i(NI``r}!iUT+6_)*18$pvTKj5+&$q_WOC$>{Dci zHyG;m2D+Mq9o_(Jdzz8TcHgE@!0XxSYxDAcGuCT?rM{rAxzo2pR(QL&_yRrMT`-fe zTP>bV&@Fj{WGX{Y$itK_7E0nCFLPVH+kDXQYX&2MydbP>r~k8~U7yF}_jt&PR_q65 zX)6r|djz%$*@uA%>BCu`fOiwzh&~590^a5}5B?jgxsx2=X@;wOK@WcT01xw~a^5PU|N^-oSRZH_+aLsOWC>R`-MuVga@y>o#w&T7;!L(9`Pe?X7EL zD^sWq+}|LwE3?77b~{F)tHIaht?FIr>+}-FzL8y*2&1+27$+S=#PXCi!OrSte-Qqw zmJvOTX!Sikn?wGUvd^{M!N7Lxrl{s_UmzH2?!2peD@|QCkX_eX<829T+T;zm1KwT= z%0DP~b&E;YR%=cp7($(4gUVWO@S@cgZhx>DP5A3DLD#WC=$F0j39R%slci=m-zFcd z>S+sgdUZa>*D+R=;uk5$UQrrMubU)xN9~%`we=N?xbyLEhh5&TRzLdq(eF|{K%X1% zy#xfZxDf5|`HvT=o_;1V6PjNlXVNdVd}gEiV*8Jh`ptdMrOJQA_doQ29Zv})I*ZZ$ zz$~0UI)LN8kKs;``GFI>18Ey@H()E$qrm-u^aiz$_yLz7RRY%lS0ib}5BNo-Cg6Jk zA3@TA4*;G)Y6LzC_$wqg@Cm@|>8J;82P{L{a64=O{4b;+aE5!4sYq?W?SS7v>I6Oj zc-a-$w?bA0yc20L=x)F+qy@nJfcuc@ffIZRsR4Kla6aB~I)J+Xn~-h+PH+oS4e&ld z`ez9n@KL~*aJDJ|J_fiMXRA@P>j!)oiGjWk@C_t8@c?eT677Je3Gi{G5#R%WZy^l= zp8)(GKE&Du{sBM-?rQD@z8CPHk@gTB@Fdb#fUCGz@gjW_xF7JVNRI#?1*CuQr2qf& z0}dg5m*{{$Ly7^P0Q{PYc7g8$d>UzlcmOxg#r+X*Kj0yxUjUB*W|cw?xC(eH(jS3q zfQ?92oZXuMKZ~>&cpuR-~)hHIS`A$ zRlr)L0^n}IFClFJz8CN%q&DCafJ@5|1Hd)F2vU%E0N+Py0M2k{b`#Qc;BLU>*Tc8K zH9#-Y9^iBidkpEjzy|=ovjF}C9s~Rt(jaiUJG){bV{Zdj0pCIT5pY%x-AJd24)`q6 zGr(hjqc`B512{qYFWuLH`vK|9{|n+-#Mm*Uhk)b0p8X1GA8@*tqjUQ{#0J5QNE5*S zsy_|m0EHv_NB6(7e{8?8|NMU20ri0MK*s_9fmaSp95{cV@8ClR_Z@un;K0GbgMZbw LKT`I;?t%XXF{>mc literal 0 HcmV?d00001 diff --git a/dest/bin/rz-gg.exe b/dest/bin/rz-gg.exe new file mode 100644 index 0000000000000000000000000000000000000000..1fbc43508430792da7061ce1ca7dd8f5af7a8738 GIT binary patch literal 17408 zcmeHO4|J5(m4B1WmrO!J1|bqe%14;spcqG@H59R5NP=G^;1r@{DRlC0LgtV^<79?^ zYun&JWjds0Pus2Sx<~%?EY;ICx{86L?F2X^D70CRwpMLTbz46g+l{Md#nyKAci(&8 z`~wuvwr6+GadO_f_uY5zefQmW-}~Ns-^%!(9`Gd2WBKaJ-fo*Af~I``OA z_C(&+_?0bYs~cW;|mseP=5Jw$AT|#IDf%94oerT26P--u;A|ip95bb;Krp3uJQ5m z`~@30EaPyEueF18nmusWGS>DLg{|GO*=N!wSt*;6HFXgqV@d^eayp=$cSOQ_C4Ln%GV0SDixn^^&7pG9o4-0rrA^6)sFt(^f%>&h#LD|C~Mn{c* z<>c2<;Ozx-j1^EhV2n?t{8{8l^-n`?pdyAYIZq_)e-EOP#{07gJvSB$~X{2{F9?A$_dfMK3s$R~z2FpMY%Ax-mZLZN0Y zMMvr#^NjTv3}ZJsN8|6(F~BZ8T*-pBQDnG`M@_SX*NeI+XVj^nlZd;vB6f_lR-7i9 zJ6`O+0cIP^rAkCujiZvQoJ%SzjmCt^siH1wGv5Cc$@~CnC<={QjJj}EK17_xAXOI~ zfz^ng9OK7Sta$!0i*W|Jpx-%h3*;QY9Ds`qB~5;ju_ax8HxPj*`awJn#X8z0eIh;% z&Vfyt%~5@&@hzK}ipFoiLmDEOzLmnL-IoF-Wnm_YKMVOo6Dd($@ z|2pI|4dCmAse})uMm@FDz}fXy?N%C6yPiF&M~A5b%LQe?Y=qg0p3-Izi%svZv6K+K z#H8own`3ZFJtzrrl!+r^bxaiKQL94_g9RlbJM|@22SuUP5!DLxC5XSk9J3THaAa56 zqA^bH%^~uHb>eA0i@Bp@kNNlwUY+Qu*)^vgzSrSmA?xDUgr8b-iDs>iqNmuhRqGiG zQq^7DDBkS?N78KR4)jj+dS@l=Ke)tvQikD*B|Be2DyLw|aE7cwON!IIXrK%;mdTjp z@pXSOO>b^nz43A!;~3R!I$GoIf`iE1{=%_4__9S|HmMgqHjU^i^-E>JE65C$yyFa6 z2QBc;$;C0WOEH-Gqv${HH~EStp}XRFia3qxo$=yR*V3GW!#Y50GWK4@qv}Mey;x zbujHd@C{598F#`&z8>8`1U`z=A7#`76Ss*85CzdcL5K0pSwhj`*tu_mALNIK{G}xMK9DE2>LUm$#3KSy&Uzk^eEz!< zv`W2Sse!!SkEL9Xp4X#qA1#6WJBJc1d_cIEo}jrQRwl(zpCWcj`Tgzi8jp?+&lgfd z*o=rqQqx2cK&|Jz2@@#>Xz-mzF4o_qpVts8uc_3p862A@=is6w-JuCe{cn zJeYJ*%~6Jq^qF&mCKiT>R?$Xb)gH0cavCSF!9lEKP0Xanm z&g7P0eZ_p>b7Ufq458fGLzk6c=gWI9Jn5#f0Of z1G)bzVu>j>M7z&K>CBmwDlRd^v=6P%x6{hB-}-sNliWMl&xJ?%K?z>77^h{eQ$!B0&7wg> z6wxeBeSFaPm4uf?mcwhIyb-H|+&7U61dv6su?e3nN$mmbvEYf2AfbE?Yha>G>-~tb z946E6#2G5D(|5i#sW5gFGY4LrRm#_lDbZaHy2gl(o?Un}8#P9Z4Da8Coj;BHc}#{e ztC$RXISumxqB`VCvH%e(w71v$8}KMa_pr17!#qLPX(iNIa5=3Tm1GIUxSvGu45@K! z6Vuvki-N8m8g%{$rj@0!;&i#OcHiza+VvQ;Iferkx8TwS(-3NnDFaC@QYWRc=HGy+_bOWL#d{WIE@HBmQ3Vr%T_5BXcyBvL3KvE*seBPFDcW{4V zk%}f3DzhHJK%0=Ww4{j06EUArzs$ndA`9YFT(D%+&k^;xN2@U4XBV1W$@#X(Oz`NMy!~*&cR*g_Ags8%q;wJEk%YM)@SF#Ty(dMOtboawAN6*_KYVJ0?U=gnhe zmW7W|ktkgU|6|0=h`0>-UkINU3;7B76Y`gem<)XYrCOm{`B;&jo0 zdOY#8stBu!G+L`7x~(eWE*QdwgPsM@Y}LT(FbNhS+q5t0pZcC zh_V}q$&BW#n&sXbc~ksu^uuGxR9-@6I_@nWa(oOEXN)Mn|FqaUjwo*egKc;yEAIl; z!{dL!G3gvo*low2#7=f!H=-Pqj8SC>Sa{SLQGQ4QQRQg@;qm`~++#qc9J5gX97Z_7 zb(S%G_;ppEGNwn5({!QXB<0LbOl~mIYL2J>c#a-EpHsA(9-<@43aF!Pd{n6c79O=l zl%=8tTXLQVY=R)NCP2wIEM;^W6 zj1i#`37>5GJZ(d;+TlD`3vL#?#9Etno=e_WravUf3LJ+t^bPOeXc@0Guy<$gC4cwQO{2*I0NCD*-kgjkm=BIy-qb+qCqENTG0_L+fl@C(}Zt1C1&8_9K_8r zyZ#`_JCjc?E{BYsT!~8-7cU!g-~xKyHl}R(;Pv+QqPe?Jg@IUFxV-}5Y1fB`?d|Uk z$KxT(34Qpq{oHcYVtnLz0GHD7;`?#I$@RvI>w(6L??!$s&&pzYbTnS9p_KM;r|~t< z6Y?-k@52!_xkqVTzy`Iy@T-UpqYN{Vx?hQKxragr&pN#0q9dzfp>kANPXP0yLU3xp ze+tnN<-4Ge4I|3Kzz|%ZeNSTMSqTaY_mkv^)j};N>CwXNi%D_4RW*qg%!orK5rTbK zw2gPL@1V|Q>}Y8N#P7iP`^wDTpW*ijoJZUxoaMKcK^wa2qKgFTKg=?A%T)@89_1eN ziu#W`K+%6HqyGfZe;78RJceBK`B7k^&reFs><0Du`=DV$xb(;j3yMdkqpgLqCwzy> z=R@i{Y&lN!{utv#hHBE#UqhGiDx7By)F?SLWuO|V991485K&6OKBCx=3q!Mjk)e31 z=xmFf&dqKXqU%N-R8F3{B_HkS@lnhRYDAC6BFgJGrVdws;mataOBnwd76_{(JVA0Q zxRH|_UdyPxr9{K5P~*eV(|CWoAA|u2LbH zOm{gNnWod~<)*3jD$ZUMP218ZZel*A*tee_m@lx;4d-aERX9iE&e6!UtS@$CTtm_O zc-|#>4ONqN4aE)SrgvQ2^o(n$d1U%T7XI$%9f+6pfD$ij=J{HldwJdimx0dnwLGuo z`7JzO$n)7eFXVZgOTEqWH+cRc&qsKEl;@A~{GWOLS)NCDK80(znd7(cd+r|^Sq4b*YJEH&)4$2mghgkTl9FDpbI^P zpeN1(gk;{oepH#>ZKU#KmT|s_m&MU;S}V!*KR%vTAqy$>W&fFGqIMTnGgXiNPLHh8 z^k^*-y_2uSe67`@s{qD~`Er3#H=a0?%8%%-MH2kcTE{X4A2#6@w^p1Ba)D61Mr&2X z4GB}}|M+ji8e!lUJ||#M!mmnrNWxDF5wFjo|5oK5+0H8u!Ijuc&~&TB&?CpC7~+eR0$hp`)2>`rQ$O{6UG*c z@^}U``439ES$0iJ|BTS2H`xVUy+pmqcPU6uO!~Q+g`P191r?X|CWA@%D?zR4;;Kih z1pOrmFKF&>WX}cdNJ3xj#qAuE_KizuNH{6sc?n64`AsWr3~P`I@Y=MXoNAJF_;QSY z!s$kxJEIP(D?0??Hq^DrI+Fe5_qX=|-K%8xW%oT;i_IPIe+Q&Hmwm;Iy@~X#S&aPy zZvS3GDlcX1W(PjAU4ZY7arpf%(oB4@avxF_-UeTbwDNlFT9IBwT8XiIm&Vi1SRDZ7 zGIQfjYp)t}k0qB+pf z+`S>-+u`fp&=T@>wryzfbq98A2<*6i(1nhE&gTXVZj$|I z;CxM>sac@O@3H$Z!TX4ZmmSs3y}{c<&4ISN+k?$5o!(xq2r=|wJY+l89kw^AXG>3K zu&WJaT01^SwCC8dV@F#Hx!8sP;yw-pTOD;(ycv5MZN2bkDy>2AscAI9=LGE}wX;op z7f#>9Q~Pq95gCY2ObD7El7?d$V;!KS!~@Qh7>Cu2J!DPr;ob+oCd?rK^ZWFDDBE*T zZt3j>nK8fk-roE!ozp%fvlLobVGB-xRtvK({|IRE-FIoeJkoQVvH3TOQ{^|OG4}Em zVlEQ2;9@stah5yLUY>>JQM&|5KS9zj%XtJ3B=yDNxE8D(D!fK8O&`hGEPRe6V1b1d zEC)S5o8=$R@heThXIj|I7QoBtGs#|xk8Gp*sTMZX)JKr|7|8NpRLX*kt$z0xkTO!kv*(_T|gDx|hj z>r>0qEo?fKKLXAwM!z4=a`~}dyAgA|Po*OGEHVZOay2?z z)NZPsugkItQSVwMl>;3Hs{52*lg6dh5`Y+#PfK!wR-(QUr#r?`eIa1YY*NR;=iEou3mH3 z>V~>iwKv}6s^Qk1$nx}hJ3Q^a&Y(8{JzjQ-C_zuN-_M(7pC>!K!BDR^(A6C5@CIPp zQ;bx$`!!8LsjLJt%gzG`DVM>`Ak?f|YZ6*-wN8hy@Qf zVwGsMwWmwibUe+o6bVO6J><3S=0KoltMuDFX?~Mcsg7ZRG>)EbZX(|R!M>E<$eQ+0 zcPo#F-;lq&t)ZaTlO}W=wgfQBysvE7EP3t;`C2y%C$W_Z4TP^7Oe_TMmgZh>8;_cu z*3X5!f$eT@puGoC(cS8;?g=5p0&IEK?cQLu2upXMr`6lrTi3=`q);2Uzd>YIWrKI^ zc8o$-gRje5)w{yi=_QPPC%Y~YMr-RaPCAB&0$ApBP?BYGOq>U(-Nhx{vK zpKH5=f$i8wQO(`HKrqzYc~|#VUpHDD%&zOL@wS9EZSn@(0dFq_<)4(hy2Yext2L() z457}jA!V&Mc*$xDw?Ej7Cj51npzGKW^vhoN1Xg&P$x^eO?~)Hz^|XaLy*i)c>lmv_ z@r#sWFDVVC*G&>zS-WO+ZGFXJ?tJ{SVVAe7)sH@Y^85H6pwA8Xo&us-T%30K{Ktz_ zPd}5G3C%B&GwGLGKD$wUzWs%yeslkGx$>Xz{SQ50$MXV-&SP{xa5c^$O~7&A$8aae zI)D>giR1_F25d#z2iy;M<#hZXGw}o7jN}4N?@?DHRT4ko*N_^44*(uQ(tr;Fo<(v4 z9|Qa?k`8Rt3Bh zX%Xmdz%C>Qa6jNaq#ED^pG2w$9s^u}cbr!PcL6pb-2|NA7NlE&_W{yBOEBPLfG^^V zWd}YExEW`xQMBs^d>H9G@O^-d=x1Ld=T&rq(R`5fIq;8SoeZ| z5YU0Unjr82z<)v7MRdSZNPB^+xLolfeFL~3@S8{v0UraTfAAb7I^ZzUA)*8R3TX)V zB;Y@)&;){0!U$xDKfXcoX0OBnR+8z}XJmR{~c7YmuzL-GC1u zH2@y~d=Y5_@JYZWW#}_-4KRY#Nj!k>Bh>?ExHG#2sQ|beaM^Y6EpQFci?jX6wgc(`=Yfs`{sS)^m^^U)K;OX!5AHj7_~78dp@Vrn&2?oGkwF15AU@9z$&EnYPk_NzX>T6^ajwX3_$TTxV0;E<|k ztgjDkTzbtlW_s<=ym=m!UpwTO_el=t&Rff2*}PSNj%Vi0`#9hW;9Cc{ap}Bke7rn& z-UbfKIb7{)?I4|I58QQ(wS87$Yj$k*nY3|M#wO=Xna{|WGC>``9MH~j%|d|i9LDlE zDFxYH5a6_i5QG1kcA7#`Rtly7i3_!aG4{?KjBOLB$ODXhmj=T8^)luH9z_#iy}4pRwY@@!j$8H&kLYn5+m_p53 ziVrt9<{0ZS7{+dNj>g}mV}M6=ZrO0p@kDF$P7KpkSXVj^nlZd;nGX4x{tvpFI zccLV41I#v-OO=SST1OREIh#~g8S9cNr--_k&3Nx>lKBqQP!t+<7mL&dDAv&~=@apB za29OJZjS1!j0bIEDjL584{3;E`eF`>_;MQeqaJbp-~}}3a;`g#)qmoRiZD0BQ_fc* z|3%1W8^G5KQwbkRje2UQfwSwa+ATDsc0G4kj}1}KH53V^)VA0Sih*cIr#44vIpnBc>JVOAvp-S!O9#=*X?M z#p0aYlSkw+>)5k=7IR0*9`o_*pPB5a*)^vgx!2)hVe7*9Sb$n{iDs>i;-}fNmFpP` zQPo}CDBkTtN6KvJ4)jj+dS?~wKe)tPQikD*r#fFsDko#gaE6?IOPbTYXrLT3mdTjp z@pV5|Uc@~a&|tilz&OSlhkrq%a}&^S>9;crGT_ z2rN99bTQ3Qj*j%2bAu)phKN?tb;7C##8%5`9K!|&v63@3ogQN@NaTzaVtMK-nt{IP z_sd1#0YtSagAr9w2i78zsiIcU!WHz~b{U7@LV-OB%$zA^|KUbuWCawX*TU`u&58zx z+jxFDw*>1e<^!K2W0Uwmq9=@q>e!8AH&FjE0!1+>F=E*wP9fqnMX-E|rNnH%3hj5u z_Qe{M2;*r_drdc#jm;Xniki~os9@8Hwr--fW}_O~~a?qQpW%K_;9B4qvde1K2T{YKsdk@%A$&kG;o}&X{KV* z@zR0Z|CRCN6dR!3XR>taR9Y367+~7_)@Sq6dWn(03vDM#9-KR2!IbrjQE&LL3}>&W z{gyOiV8Ky&4l&0+yNt!)y_z%&QT}a4nf6;hPI{7i2m86mFh3~4YZl|AtaXaW;k7w5 zh=?MZ#p#a^8o$!WvgmSnEj($+>LB-xGui$4k?D0DCNWA|y#DpT!!OEYo^F zq%4QY^gDKn%4_wV=f)Mrj$r1%i@q|xW=xLla?mwKZ20uGM{-eP#L4i!UD)~4xSz*l z7_o}Uu!qwyA0Vnjt~3V_p+b9my{{3EQgjbH`#h=#U8j{$XQAb^Zd8#a6ypJ^!ZW1S zv5hc{t85DewE-G*{s^X(WnJaTM2Rtn#uLq*hw*w;HVYwMj>NIW+2x>sBSpQ`2sip6 zU~fM*BuLn)Xh3&?My^fQwio3@$*0grm~{~a8)NY!^Ea^dppR$ z8z4)QyeUyKA1HWg(eGLoo<<6)v7Ap9o^7Wsk-qadjRMWu)DP>=&U5?7GPngR19`mz zMX>~7_1LWP)uS^qYQefTx%g@Lk^ChVHXJM&kyI$(2Ru_bnxXk&oIwo&iMI9^m|s=Y z6^9BI(ku3Z;e0&Wcam5Pw2UpTpOeh3y_(wOig-`k+SU@M6FdCU)NYnP^_`Ic8jvYl z>0x;F04=%L>+|K`8F|+70Lo&gEjEhj6GqPWa&RO{p1`R!Yr;?HpWIO4c|%VVar9Do z7j{;)_H>Pg@8N~Wwo+@jUC_6ws`AAdq3g`j94gH;OJ!8z2UB(DHkD~#wS+5-cW?tB z)@dBQL`!l9ZoDb0F#B!B4%#rMA3F5t2AZIebE@7q>%nWFrEl3@0!!cQxw3dRl;+a& zEH6=VvkGeDm<=_-vwCa;q9t-%%^vU!eQSk2_XYL+8qT{EeON%!BG!D~mU4G+e`1k} zB^N5Q9>GAHkkhoJh{zK$pH;ui!q*}T;#6F)WYy0S_4!AtG2o}KHMvsrhx1>+KH2_H zAV$+hSc8$sju*2%>;j9%aUM68Cf9aMWgLtONK{KSI#i0Z^ibqRnDVl{uD_(cN0*_! z7qB#>O}r4__NZcgq?XCgIEmZ>+b(24s{KACu3|)$UYJ1QI8iGVa|CWDEeK3HiYK?Q zdY{6?zM}X30I+mW?5QzUa!(B;b=#X9@9gzgTLYIiVLSTsB`~@2I7OzrGG2MI_&@`m zcv^LoRY%uZtE0NDI_fSQz=ngK1<-8O!0Ipw79uRZ&Fc>z5iBQjV-1Dc&fog{-ulUd zCNW14{ULAXxi=>cn&=IU^$!&D+Qd;KBb1kJ70D{GUQX`__p z4brS)*HFke!I#=aYw=;LV|ToG*KX?ikn&mDFZFU1*Q|I6mq=iEt>xn%O%yMS=UG_D zohmow<*<;JDhH_SN|oJtxh$ln%1u9W=pxUB_}MimD3$GrZCLaz3wkH$6m$loe1%+xVDL3oJ5hiz-V+ z3%1Cp3cI!sDP(HL`MGvyJi4I0~iOEJAy}4?noGS{nTRlC}j0z zl!wvFA1xN|KV!;^z#_w1R5=L*+Fm9Q8GRkvUH}SVC$#mFcj##PG*uTrGma}y<#AD8 zih3K>_e^Z63G&m*6U@q@O0O_(+Mr=a|8eGqgRt~bR)mGsLMPr>(cRR5JTWWvDB!Au z{DY1DXK>T0e1z&Fqu)pS*QeT7sr`AfeKJQ!?`EOGWCe~x8v2HJaI}n98Q42AzOjE~YeMO%`bQtBBiPZfngv&h?I(XLM9Ty#06$_PP%6bBrAC-br1O6Wn z9a6pt3fVBEJPZuM1=_bHW}cOxuxLL?4p}YKa*7@++P;t!H&|7ZXu*tl#3Vwn7mK#> zHufFVxvU*6ZGiY47=K@x-TPDgK7sRyyM$SItBLO0&{Y>*BvAihma$u|QaJP|_n=qQ zf7}6z{!!=)4o+J=e%D_IP*pLfDbAXYdc&g}Z zi=EERZWgBNMjcd6p0cF?j?ojtm>1NDo`^@4w{A=yuD+tzP)3(9{?jZFR!Mk_4IsD}bzsqSNCQMhUkW8k# z9F0uVY4vi`RGUc$UxeGX%!!+vPigiY;Rogk_POC44YmsBXxup(nU?eEj;w2_e;^Ii zC3y{1n{f@r4d$kIT-fxiYp7;u+dGznzx#Oy66M{XB+7}NC||>KFVEMalZosY@9}&xr!VICO*~)1^QAmr z#`BNzyqf1VJg?(C%4hJrlIM$geiP4^@O&xHy*yvb^ZGRUOL%{tD4)$KXF2{l z&rc&yo&^ZWzJL9oGQHbK=gBVPe32+mWVe!9{}ZDb&C5bsefjTTbc#p23#*x`$9}Cx zS895!4vF5$*I~ZaX|a_6BgS00z^EIKol56Nbk`vX{#c!3nSu|SaEn_f&IS2EC|+ZA zD&mHOsq}yR*SK03*zqv|ACu*;NO+%wpON)nlJGkc9+&VH3EL(ADp~%BEMF;Mo`k=X z^`?7XTqUqW5`IlWL&8&1&g8F>bh8|k<@H(g-`^=Xf^GqKN%##3;}X6h;du$|(!Q%D zTqNNwvVMw$Kb87NBpjA7F5w{w|3$*jO4u&pDhY3v@Hz=gC0s4rIVa0jS#FWg?7zKC zdDSIzars;=KfChOlU_Edh0H1=ZLg#R6;|-aS6{$NNUV)T4`fQdyzuCHZ826 znp7RW9OIvGHlnUEs}8Fxdj!Jtezrr_k?e=RzrP3QUM06TxA&nsZ0>;n0+8-p_LVSp z2I;{WjQt~S|K3EZC}V6fE;E|uG4=%iYPq&JZ6z*xRR z<7sEC9sqNhxp5~pI-ju`EAWMg575T}y8u_Osa!{^`7683erZD{fNgF7|^cP!{=?&&ZgKJ#sX1fwtDcp{t*ar}q& z`_Tvf4YH%lPqcottpS=ehs%|;N6@x$2KuJC!bjf_J8+J|H_p|J;f{z^xLmF6n}95* zqdUqqtMN9m2DK<>(THfzq^&2u(hOQXmsPW9M094+YCv;k(zw2=44Rwk(=utCPtTw= zay~a`aFgsuBj;-ZP0ayKev{o>%P$ON*-_Kn6S^(j9BjM0J=EON>Fwc)5J$bFhs#Xl zA=|O`ustcBE!~}=t~Qiu{jlOdD`j`=*wNNPF190xxQ~OOR!4m`Z>BVZww~Lorqdb) zpEH9d_*|eJr+#e{--gpS@zlN?XG8{L>o6&3jz}7gW{d?uON$4bD-jE;82g4b$%nfi z{F*S20L*XH_n~ahL%F4=2V^J`-`tzurgPc{WR@ZeD{8?>&}v~;jLZ8%lkdKZ^GzZ> zM;V)Yqc~lDc`9SCT_)xvK?^Q;^A_f~lkH5huu0S|LDEl<^vm)jf(KIi5^!D%)({n* zBbcF&c&^~m> z&7H=lVNW~?8qG)Z_r2A?G_y1jet6yxKKcKC-mtOY4o_FJ&+h@G9e`P0;Hp?s(bn0? zX6K=%XM2w)9BQxfGzT|r@%X)4u`8HJZx4FCBp(j>I+OA?=JC{cdIH{7U%RgrZTQCHwZmmc7iA&Pjeu^n`WON zJG`NAk2l!W9P01}VcXM;RJQvzg@aztR$rT!_nWaE3oP}8e9fJ{9kRmf-{K2)`@3K! zW4Bs7o1k0r2+4GYkdTKdT`Zi!JznOvdbjzY;nxgC0(n7L*-rmwN4q|cC*bjr6|LA0 z%F z*;~QNIlb%$!UBx7ha0g{wA$L;C2TsH;aQ55!=@hcn!h<1?A|KyD}HNYqnz)x*C05-s+wezD_S;>}$F8$uL^efN|0>L~N3>I@DRy90Y9Q|oOBZ`$Myx`W;x z3d%nyclpJnYpXM-5e%WuumNR_H+0cz3%5Vij3xs0n4oLf0QAdVcL!H^o5@nMoo|v4 zR(7|AJH0xe<7*kKPVGeiOynl zKQI&Lj}G9t?_;{}tL0^W(V2y{1K7t(y-0lCdSn(o#9e4on%Sev^9|5F)@TC9$ z3IGlweVgcjKShcI9|!!3igtnT1AH23n0Np;&%yl>@BrW;q+bA!1Ll-L4!8<U2HXX>7O4Sv6W{@)`M~=DuW}$3 zfvbRZNQJ=NfL}n`0DLdtOGs_N#{rj=BL;wLfKj9n@c_Pu)Cip6&g>?nX~5lp%dUrS zfop(Xq&>jt9QGK}w}JNqerrDb2|Nz?Q=|dlba!^e0>;h(R{`Hf`Vnwe0o_Qahz|H1 z(zC$hfFn2Ho&z{R`Y+u#fCm8S%>N7GS;*K?q=$gxzMlOGX&-R9m!ot0KEwvWjY#9b z|E50;;{b)j`$zV_vVU~HvH$#j+X3}}^FYUez=2l|j2}3Ep!eWI2lpL(^kDzNfrEe3 Mwm($%zwUwm0m?=t2mk;8 literal 0 HcmV?d00001 diff --git a/dest/bin/rz-run.exe b/dest/bin/rz-run.exe new file mode 100644 index 0000000000000000000000000000000000000000..f5a714634bc9193187a21e69d78afbeb47e4c2db GIT binary patch literal 17408 zcmeHO4Rlo1wLX)~O(r2BgAxe}atRY072-&s1`&Hh61>rXQ;0$-bn-VLv&hdlnc=Ut zFE~({4rzI-Kia;&%8%`{+E*j5VsK$Q0Tu}geR-~Gt=gK}A1{qvO{?!2`#0~~=bSr# z0mb#&_1;^{n|03KXP>?I*=L`9&OPVc$*K+eSvF(LiWHACHULPE#`E{i3{+2@^Ym2q zy}WaC2Q2mH<~FqZdQ^X)dvlgo=v&0aMS>Qa4OYR#Q%)z0o#Z+T&1zC)^> zxuGt&Y1uW`nCays^XGd|e)))F{wFz{H-8<6rSn$gfaH^9gJ-ksL1_{eUAphe0mvk0gqKP)?m^u z0DD(pthk}FQe$j5wVWYS9`tSxg0^WMGBSwzj((&*Dr1f1f!3yA6Jsx4h8hiNI+7D9 z<!X$OC$$!C{ZoJ8XLR%}PDm;LxM>4$W8$C3>XB;Utoildb{@6g5dH1|>?A z@Ttm^@iHIcHD2~9o_8WYOApjKjcc+QGny$|j%@!iice!rE@MSUV|!wuDaU{^qpA>f z#w&KT+*jzB21-#rQFb5%_QZmc>nhIm!W61`ynxpfg1;36W2;KkJW!44lsyDublCVe zPJSH)-d-@rSP7N;jnS!;KZ`u6{y60JSH#dI=gEZq??6=2cz-q*LHQz~d?P7Ou#5h# zgWU#AoFtt)L-?az^gjzTCcXdE^lA8$8CPIN?yYgm4KL5WlQB!EP1O?kf!-Hrckq% zqNDYWxyA+zhOq~oqw#m?7+{wku4KVmDKcEfW2V``g`zIX8Feb?B;u~Eh&@eOE6xzj z9WVCZ0JDu1QYE6S#!<;t&LNeR#`=WHsiH1wGv2+LWWEbE6op1DMqM~7A0keppQ?+F z!fM1%j`0I3Ry_ZN#W)LH(C-|(333i#4!{M5k|w{v*qScChl*fcFh)bx&PQI17$5H$ zc|4A0gDZ1Hd3}De0%hG`ROWW8gb5G1j6xKmd=Ax0-u4fPH(Lt)fazPm|8)3Ghr?lzBV$=I-EG0xQ zG3hz_mKdB;4@yEDW#Wif9b*N0)auZ~U_ptK~ZRRM708aDdI0M+bl&39NAU2 zXpED4a)>-;9XrlvF?W>gF(1GFS&5FCU32Q;dmSzovM!2^`KdLRXx8c|dWtPywSlo9 zRo%sn;@vKAB+ZuYK<`AacU98Mck7C^~TF_jAK-@>1d6+3l1W4`wB;H=gSs_*|=Wx#5AI-)Gw6Y-SKASjW0xB*B6hH5k^wg3*k9xE{ie~xUvb6=VaXBm zm3UIR#Pz*_cS*8#hVkP>InQ_nc!~(;9|Fxdfy`_rX<) zRDs^=me2y~?RwFF-f!|1O+t6Y^AvF!)jQ+Gr>~&3{KJe`yD>CkciF`e}fe3sQr9aB32P(468EsBS5pB7rl~O3Q7*9?GtMNG0B>gng zcqmbx0v`{el;SDj6ViA0I<(qebX0js=dXd>e#`mS5klePj$Qy3ES8uBFI5Eu<23U9 zh6{UNjOxuMUxq$)`MF6#)^9D?$7@)y-8o5}1lYU-9th}aDzkXP*V`#8}!i3l-{wSpJUQDbJ zSa>k$qMD-&9qBda22Css5v`)@g;jgSR?BIe#0Cekk~KDiUSlpuWQ`SIdFm^iiN5If z%SB)>qS}ifzOe#JU)=<2_vF9cH`I$)PIaXVH8S?Xr_o$h&W9VET3X2G25?1`|YxQ zu?EFMc-zxn(+y=~v&XKYrZhP!*mR<;o2achsD?H<2~+fu>}-lP_#vMHj~XAdnITAq zC*{l)L!-H&;pM|4uOfEL2BEhe<)Iiaz8a%PX7D9cjTh&jjCTmkRP_oo6hQwWPEC{P zq{J03wvZ5cd2kd`gk;E5>*^%p0L>dZf{U7YiRSnapeLFKAq49y^?^l)UR(Ip>%qEI z`BV)i^yTnw0Eqt1h#pZM0X9}^OoKK)oT>b1IaH(%RG1174lsqXh~gp*9Or79sF-lP zbRhSCMJzGJ259%0D4jikbif1g&S{nn2Yp5)%ael9%B4@&Tw#W*8tog#90Z59n8 zqKIa3>g$8XuOz%YvI1TU22jZOGeNoo&Zj|Fdp1PSHySOXJfTJMLH z6)>5elV_>CPT%$BxWd>m%p7>pSIXCnDbd{yy2gkOpS$*0HfoF*8Q!-WJAWGY2~36& ztC$S?I1TdwqB`VCvH%e(w71v$8t^Jb_pr0ip?c7DS_yR)TtVwbC0Rl-?x!leLuwq` z3B$O`wop*(p+V=bU|Lz$SDc9#8*^zq(cA=#*CVo72=Q__hAqx+2L&7{>ZL}w(GLQ9 z>(L=W!cIj4x*IfdZK}5YD94LGg+{^?mQXH^Jeq}{d^D_^DB!?VmCy_m8&mCVCj)PQ zEKTypc<}!4+ z5`@)bi^^Azj_{}j>)Mo}r{G8Omsr?vuw+D1q5J^wbmeG<=7;eHY7j`YwZFjps-&(s zRIrd$047iR{qGfQ)+G|McNQi&f-)m__FrhU~CDmUK74S-mu zar6=`$sM@ynykX?w;4NW!<>5P&?6gZf`;Ez^}g8;TmvnA%l8vl_FB)CMRTAuo8D(R z@#33RP{Su}s0p0cqZ<(|;ZthnfT!tOC-k{5sP8v$-lgcn0+JH3=KHpUyMy}^i&QkR zP?_}z2HJ$2qa{T|o{0I3`sEhB7FiId;({fkezvI3JywMQKXO-!5pfCfKM_7J7V=~8C*&^{F&X+!W|V1pp_fpqeLIBynL>Y5=$8@o3=Y0& zE6^qAyEaYVvNU}^y##$2*B9v;DP^Q#F?Xgdxf=5!M}}FL99?bedylT%Pxci)L+4W$ zT|@O1zWXPDWrJc*jj@t@Y9Ptm-o$ukuD{w^xU>=5(O)cu$rYz4GTjxiiZexr>hZ?Y zsv@i^vff%1(QQ=`cfkNQ9P}=LW~&BPhe@yyVaaXYuFx^Tawa=kU!d*!y|2q#H)YTy zW(i_f(AzO(5bxi7>_28DY{s}b4%5#nuKQBD5ZFV zG^^M(6!1;(rFPL;bkyqD6D!)ihq^wbe3tf0y&T0gD?Y--;}~9R+4x7}MayG378Z0T z%Z)i%ET|>Rek!|?Wp_?C3#!R-BbDvRvLEG8QB*0z=!AzY5oHz-)8|=o5bSUwy`veR zQ^FDnvE_#3y$(li(Z2rxI*^O({kqNvla?s6rEJ-f6PDS^=nfiF7-oGQ4hRotMU*{2 zOlCA^)hzek$eZGKqwgI{rt%Up({XS4fa3$0IDJU@?MKAkaY%Us7;Iw*=eL3C;nBb1 zm~SwaM-WbMon=HH zd|lP2jOfu5G+k&oNjb9YsZjM3WCCURL-MDlo>!^mxDlf^e?b$CQvkhabVdactvH8gmBkSEtZW!R$oqe z2)+E#67l^rsyq)YJgh~OGeDs2MFQc`SD@`Vpb&OKTQ7Nsj;2phblwu1d&1 z*yw)-H=W8ys6IUU1GImAvVE1>pD)`db9D6H#zJJWl_X$tE<`34i+fZYdGw02MubKr ze5&yiv<<;(hx1%5xLNQbYi-(jE_q*>{*ojsa2(RmH++MmWxUeB-jVU8C1o2l`F*pV zMEy|~9-V-1R4O$lyaf87ktNO&*K$T|QNB8W`lEHWcYdO`oYCj;JNrt#g)4#$ zden+nJwK_`INEW|Y^R%M$h7OYUZ)x@(V&wst>~zh?I_~6X~MUh5;Jgd4&s)WU4M|| zoyj*BmqSKxuEZsaikRXEQas9|zw%0R8Ba#VSOKtw48`;cNoE)2~AMuy_8qO+}b zIybvnh^`xTP&s+()_gcdj}K#BP$POg7ExZmF?G253SUMUUBdWJw?J4W;W3g^!Ht~c z@L5LfDJ2?ag&H4>p27FqgAn8wCUsG3OpjQf9eWloIeZy^sH}%#-YM!#Nsk70%JPb2Kt7>(lKS*HHgJ8mLS1 z8mcDk8j2gtO>e)j=^58hP0+S~EDL}4^A5zzxWWfKgaWDcrN%q#__8-|37p53p{_9=TkU+3CC~Z`BI)Q-&}I+eRu+W*O&;cv(ENmE`&#A5Cjs7EK~DCSi+cuMN19Y#F-J9L}U@bOxz<&uycPk91L7}&WGzwVX*Kk{t`KRqy)C&K9v#~-xck3R6< zAUis{h}Ms`H9(W*aJdrp2-VHr)?m zVf&IiTe~}govkR-`eDU^R?6<&xwEyITx>@WaUTbQEsnY>-b_gvZ3DMgO{FymK4%(D z@VP)cMg7_?ej84|iKq7EI3qF`TaQUWb41c`G-J#UT1q_NT!~m%&Db}r2|nEY;AzA> z0x*B0egI{A4$93vJs?Ao_|3if+jLHQpUhHdVTH{&30f`8ig9^QX!6~6alSm#bAqvX zH;U8cm!~oI@?~O9613ogH)m0nJJC*_h2>GZ1W7+Z(l5(-1P>+k#o@eWtRX5qM=(tv z$=NJ?o+My_g%zv-JwKb}pUCkmjlgGE*obYKNmsuwJ zNw;aQsV5auTdDP_<;yMXaw@+MoLP*1AIWn0v2ME&cf3!fA^UuOpke-`&^`y+FlZB)XXcZG{pViL+$nq- z_Qa#0(R?(Y@2>%-nWf3_!}Esl$^ZBBMji|7^mI1)x;%i`0Whgn=s!>(X5y)EGNl6)xW>qyAkn8#D?>G6A8d~LoK54Inz9o_(A zWuW&2TRp)Yey_*Z)zvD=<>~RZd)j;*L2m$hyzDelf}SS7pEu1uL3Vh9 zp&oCbvnkl_4Zyai7^!UYZ4L#zo^8HXFYh;FJr-E%3;LQmd^=@@w`;2}(B0JuGa0+p z;@J${l1E6UG6aP@OzC8yB<}Gtx7EAd2MxbrFcQdf!pb)KKRep>c|3lPhpcG9eo&US z(O|HLVXKgR2$+yQn&k<2H^YtSbFe+&ZEE%4zpVtUcU_Rif3F?oMITi8Rkrq#QN%kk`7J0)g&r(r@>q`At@(I)(+(IJ&#I ziF_Lb`%-!%YuZ9xEj%86MgH=(go0jAn$QW@62K_)zOq5H~MPnZQY29t`=`~cL*UCU@Nk2^9HL$Sh@qmL_ zh1$UV4I;ZT8@y|GU=%tVe4XB^o|V21FJbI!*>#C9T3e5C(lJCVPgxV}sBZEH;lFAb z(bI@l-`%|>h+Vvp3)lczY-) z|D@d2B_>^KtvQWg2z7=HC~LjJi&k5>{lO+Q;jhC4UB?EXU-r5?u+rN^mYVH+lYFqM zyEW9|)%hG>$5>U0U!)v+Nog>>Zj#s?wQE+_)>kaz&d0wUc6vKo{OIF{&!u{Rer~|` z5)jDZLbSu@4=++ZJti>|n!iNOq+e?J+$Qz;wjU++oBN(imH&|Mf9L@_-V#W37Nh%t zSvY^R1IK+I!<``W11ER~(stl(z!s!OfcpXI3u-U%11>?T1g-(DM$(8M@bgHG!1n__ zjHCna2Rw(g9{330uaVrq#{sjaqaL^&uncMA?XUsxzmS5!8SX`HtwzwUAMhb02KoWO*O2VQ1Gwo*v;&?-z{ik=f%gOc0%-vF zIN*2jL#*B4?+0|?uI66g`vLz2X&=!6Pa}N^xQdGvFVfe6`vJd<^f2%dK>7zy`u{IK z;2_d>hz|HOq!{pVz^|xi7x)3dr;vt;2XM<=+#dn=10F&8CGZ$vRw?9wtAMv6{Ta9h zxE{%hvwI`pr;!!|?*%-JbPMnp;2TIaz{dgS&O_gTy8zcA)dOz?JcP6Wct7A(4#XmG z6|fem0Jt0Q3rHJ*?+1JVsTKG*;L+B}9!2^N@P5E=FMvOR#{hqZGyt6L&aPO<*qgvrz_*Zo1e}#aH_}<613rUv z9C!?Hw{&(8QtM!w()laQKnK{f7q*|4rNe KP}%>w2mTwW*CNIM literal 0 HcmV?d00001 diff --git a/dest/bin/rz-sign.exe b/dest/bin/rz-sign.exe new file mode 100644 index 0000000000000000000000000000000000000000..b352be25583d0fc2a4d0b3834c4cce8360751926 GIT binary patch literal 17408 zcmeHO4|J5pwVzG)OO}w3MTi6u`3M_a6yr*?MiKjkB=}JRZXrS*g>L?B$R3i-y4i)m zvu$vpx?R%pPXB28`YM0ydsO?{$g3DUw%q`S1cf%wQ>|57Q*G-=bKIPnd*{x*ckbM|GvCa7UsiA2$8s5CR-{CNu|YukX*_@L%s}+(=Jm;%1Xf$AaS9VFvi|q#aOREMIK=6J2VjHua7Yo@OTYl4JPdZ zux~lWiW@2`HO5BL%ULoNA#ZO8w9N~UkwMgV^dtSJGS*ZPY-x}QB#y+P+~-h zoUA&LDBp#6O_cZWd^7Sh^n+Tbadj?ZMhj)jknKB0@oB8hXRP>Wd`~<)^%ziQR2QMn zc*%~I`->dYK`AaE$_|9Uo_I)d&EZ_nO{JP|7xJ1S@V9|rY*UFk1yo}uWetk1Wf*lQB!UNO))-af~-cmi=Z8 zl!reuto$4Zc~kE%X@Se(h#CMRHjnqIU=S-hJGTfNV3;o$3W%W%48zJHNYnfpSEyM_ z@zHw6d}AX9!`Oq)(fGS`46sX&RI$+Q6d5k#QPb?ub)qiD8Feb?B;u~Cj6X?QD^C;6 zohS)h53`NsQYE6S)=|Y(&LfpoMq^UtG*K6`8Sh?2GT(w4ibA6fqb{6P01>A#K-I-Z zVKw3>&-gwSE1!MLVw{04=y#6a3^@ld2jF5u$&g=cY|E72Lq#wz9;YGe;3F?ajF0!M zDLjtmf-8GOd3`~u0%hG`ROWW8gb5G1j3N|bd=Axi;wRX$)f*WL zQPo}CDBkTtN6KvJ4)jj+dRGb^nz42lK;~3LyI$GoIf`iE1{-V*3@MVj_Y(g)7Y&y|Z>X*twmysDNdB+*H z4p`uulS|@gmtrve$Ne*lw->S*SJ@Gh<1>us5j$8j$pbdy*q;-LeWuaGUwPUHW62To zm3Y#+#Pz*CC%tx-@#AE9it!TgG!f1}44QEqnb}Ip!g|EBT91yE(u2$#y(*&(`xUsT z61~+e;l+*L#qjYx zD`DEb;M+G|Y}^SG`FeCc5%?%df0R=XRAkvR+MJFe+VW2+Wl(4_9-jtQC`PY^-3gi%^$xf3 z^ek=()>q62K1ar<@PR~67!lR+8^*7v{$m7+Vo+klvPGOi#A%9P`4mfu*?tw;?~v__ zH7F6r)1LO4ZYUd{J3fb+(&VUM(}}ijrncsx8rtL}Ow&iQb1Bx~hXM*bYJA*gh9DW9 zk~3Efjpl}ihYydu%J?xGgx-3Dhhm~652HtB@Fi4Dl>8Q_BRoT3rm9z(p#b_1E=VUO zu0+XnD1i=_J~Rd?LbBwkb#)SPkmd~?!9~r2WOIB7&=bvr5Q6np`rwj-uUz-#Yr%Sp z@{hHc&@25I-1ES))%R>dU-nf9Lb+5EI#V&v~a+li7-Ets@m%KDp7Z}_kbXRoIN zmNa8v!Et#GF~>ih`*J;}X;{aj>(AC%xVi*Z`kIz{C0+8i20 zL=ny6^v4H{Uuk4nbUC~ho-%B8ko(5-fdH}?Ha3xyrRhC@Jr+C>k|dPRVGT@{X}up- zmcwNFoj60~4f?J(CKSewVdlV#v&;CJF*UZ^LDv|uk+X}A<)X%jli~flvGb>KKaa^U zY88`VFQ;KXKvaiZX$~Mlh4%J(e*+$+=pJ_Vznw4WI<15{3oWO0qlzq{7!QyLo*}i4 zUNNoBwkYW8p+V=5U|LxkD^Dj%4nrHBzPlagVZ0ud%|eKmBXMkTb~`BG$ml+5gd6=J zu(uu=79{LcG@!dd10y%y)V2@hM9C^N5;<=P=i|tuS@_9E!@7wA4qVkq%`mYk=^GR} z$iO=wOOw1QQBnvLSX-lNYLhGCJ#A}SOPo&Z@Jmy>S^m^_Mh0m> zrfsK(;Z=jQ?J-Ue|Xygr5@1Og?)zH$vY#)K8uk>6|JP%59 z>3NoyD7jSyHFCm+n&3G-wh7S^IjLq3c!s_WLZADB`hE@PU5Y*|AZZb6K5t98JGeiw zNX3#1m06EqpiRhGT2e&hiI~r-UuNNJkp*!oE?Bba=ZgCLW7Qb&vx`iw)coQ67qCyZ z|5J$3v=P=|B(mehY!AD@q6wVGjit%89a9+xqXH7u5)BTOA}u`>xe=zkY_IDtY47kd zwD$~_hO~(n;@ciPM=*1E%j9RAL~es^7cwB#e!mh|F``NzOdxTbsFjNO0=JVE8|kyB zwy=B%IngDFOL1)4evzk;ycaOrljGlC^cpUAX?GgU2!rGR@uOJAB>_KYVJ0?U=gnhe zwuO&Tu_#>&|6|0=h`0p#p9r6q2>EgN6Y>{}m@IuKvdXl)&_gKQz8ymUY@t6U^vj6) zE)KpKE6^qATa=-1X@+^Jtls3|^m^;&!T8;UTBf~6Ajjp!sy+>E>C;N-O zOXpJ;T|@O3z554%r9)y*jj@t@Y9OiG-sE^^ufN(lxU>n|(bsN)$(1K5GToK&%G1RM z>+!_Xs-vtr+Gwqg>bB~ryKoR24tf?qvsDAD!z5UUaMK-LfB2YSIh`A;FVuFu>GOM6 zP8~9dIfCd9c{`^L;rUyD{l}F_n{ll}XCjd9w`OUs4u?8SB~r83AM#Do+*-Z5HmR95 zN@?C8%_?>cg?tlysa>=dAGJF6#EWGK>p2zEG; zp3w}@DPgIE^csj^rF7&M@BL4pgZaqbuj_m;X^Aph%9SlSVVSL*?w~P+Vb*8ifXGNr zRM`W>WJYsV&2rBTyeWP+`rff*Dla879rsiWI{pF^XAUdB`Hnx-C(5tFGbySZXr|Ck&Ny?d>nA~8Z)f`X%u{=F;KCgHWJw%6<6;Map_?S`)EHYw? zDoaHRw#b+YyLJpKWgsY=N98)MEJ< zWc6i~htbO)-6YsxE$V0#}~O zqoTeP^){;SncP$pOMaIs-~ z-pUoh20doQqn@8sa0bFPvz>05A=9DbdYx*tWP?t^wBn;$uA`XWrU~D2O5DK3Ifz^1 zcKtz;ccz|PTn-sMxssPGE?zd~!UgoaZA{zp!Rzhq#q)Nf3InmUXh$W&)246McSMVrDm}&;Je@CWK3m&a|L-bOzd5BzwYl zsC+)8zr&W}MDLF=PGqPi4gEQE885?m=0J^*L(>MTk;*aUF#=Jg4D7>-4Y@Eh2N)TO zr;5(D+3DQuW?{N+)IsIsY1<0Wo}L)Nyr4$(L_DgzdPDkf^%uQ}GP;EEpJ{=xO2XqL zr-BFt(+EYd}%nCIz6g!Rgw+A4|FHBa(tZ_YReR}+9xa81f=+)(N8(DS2jMrX0 zw%5@I)rpd7tRs4CH!tb2zVjf`#MR|pj+}&tK#Db37mB`7xe9%JYBW`Gu;UIbOr_I-Y+DZ<7+`vw1#;=W}^JkLUAwzJTZDJinUfi+H|{=XE^)A>N`V$^~8M zDFQut79b@1{`LLJ^ll@aC%cUEMWQ@`b~9Q@t^bL!j0#yut1tguhKbr;Sj|*D_G>-5 zTGL~7Nc2v=4)e86i>(G2H5SMPM%{ekOgcZJyADb4$Lbu*6nxl(TiiNvF31N$@fxdB z5jP}ErT^o<_O-&mj*klXNeRCo;kP6_Dd7te{!YR?DSw58k4X3>3GbC~jpT2TxP&iDcwR!gwD&3rZcZ0D%7Z%jf%!U+k_OGs+WZ(3<%NPCe&yf!VYpqf-2 zz8vG9a5kW>A*&9nD|;Bi^nSKO){*Q7zrVi+=w2naFSqZ(I&AKM{{oQiT=thR_Bzr7 zvl;s*-2T0SR8hv*O}NZxTFBVvaQOW?(ky(jaxYR2-UeTTwCXzST9IBxT7|KEo5s`5 z*h&D*W#-16*w|vmYOKJQFt!f#3BWGEwd-ov8DA>&7Wb~X^E>Mg4sSW~CVxL!bL*xR z&B2al|E8dCr_aBsCG6{L+tlLo2X}4??!2zYw*@r<;xpeCXkzpQ98ZMPA&&ph{s8*G zzd?3%`H41wwlzSL=5V=^_6S-pXP|GID}3|~u>S{xo)(sN&VqD%6ntbEQk;Or9g`$&!}fOXrAxZ`~)69H(EaY&HsIS5#4;cFFD zak@En(=BXziEfsB@oveT;UClnfhxA|vVV08|HsS$*X?IlUWn>x z?Z%r!{6EzCnzeVWX;`_s?uHv(wcNfFIi4PGho{}w8S)09$IDI;CFE%i1bEZzV`PUn z6z=f`yP88C-XLsyf|1I0-)GyW^K#EH)?UXa!ES#S%w+6# zi)RaTOCBMa&JYsvFr|xyQ@F>=+*WU|4;p^WU?h-dgq7{|e|EI%^LPRt4_VQQ{h%yu zr{Q7`!&V{t5HKNqG{+P4Zh;%o=TJw`+uY{Ce`7Uwk^?-=aFs9QL9w%?xpgaJkDI*} zten%!ejqGBG_4f3vY-20Z zs14lTAhIiR!Mkn;Mxm?0*X6D5S>fyS62`ugyD}L@>*_I1I);c%QPze!YnlTg_^(Dr z^mL-tcXw|M2Uf^F*ZD)i9oS7#&3a!j6mIUk%fH>{M~efwD|>3aE#WO&yg_%++e1P5 z2jwomm~?G*<}`vK)EPFYtn-F0T5aL>hnmquU?nE#1~v%&ve(_g72amD)NJSLppPH?F4Y6{xdGox zKp=+;(GH*gc#-PqXA-la`6Y5T{Zh+kH>=OK|0t#3-1l6n{0Dr0r3dVIN+8i$jP3`n z#QCEGIPUux?gUu?IKfp&y};dotw@J~2LLahfpaAB1KxyG1)Scau0hg>AMmqCO~Cg7 zK8&OT9{@ay)ChbO@K;D~;1htkGf@xR4p@$~=_9ZK@V}8lz!~mErXjTfw*!6!sT24B z;ANL%-wIh3@J^%~L3aaoAuR?T0NjsM51ioRNDaW_fD7@C(*fKC*o1T&aDv;AYJv9w z(mzYsfR6$`hqF~F@G-!xI9rXP-2mW2NDTD-fUh9gi3f1=6=(-MO@NOgjQ}42d<|(3 z_ypj$@FCW2@DBhwa948=@O^;)hP0RHfTxhY09?hziWljtzyp9^M0yzbC?NfVC;k6d z0B{KDn?wiv8B!eh1mKrcvKJJfz2LO*C{Q`I#FsBT1z*WH8k^Tr= z18hXH;_Ti8_z9#Nf%gF(Lb?rj9Po9dTHq6a^B16Rz+HeFkm`Xq0UktJ4154^jsvj> zTm`H{Dg^EZ{2bCI;QIidLuvy)0eDL}VgR@X7)1&Z58%5<4Zs=h%x*@S3EU01>{|F1 zxCZD&+6$b{VUHkv6Zin&Hx|R6z~g{FLmC85cW0Mh$JiUdRlv89egvFVKsVAEq62;x z=_%lGz|re*&jFku{g>{`zypAE=KlrpEMe?8(u2TpU(bGpv>!O#%h9=gKVpO6W~2$= zf773aae%^+1EU9CI52j=IB@=e?Vx(ld9dSP;NS}fCk~!J*mvl`L;DXMJ~VJ>@X+71 M?GKdwuY2Hs00cWFW&i*H literal 0 HcmV?d00001 diff --git a/dest/bin/rz-test.exe b/dest/bin/rz-test.exe new file mode 100644 index 0000000000000000000000000000000000000000..a1ed73f5c11aa8e82f96bee7bc47c2747b69ee7f GIT binary patch literal 75776 zcmeFad3;pW`9FRqWFRcV1Z6ZT>L5W!aTyKj;DQs4deNv+v8L8#tV*L+O<|&OL4p&M zIE)=Dwy3RAmlmyUu_^*}35pODEACrWv{vspw9?vz+Sd8L-_LpOojXZr{k%TE-|wH_ zH@rCObDr%yXM66scTPAXZw;|5s~Z1HCCgfln14wL|8r0iu&mL$t{iPWGW><{%LC0X zjGx|i;jC!;%*(zt^W00K=bd}$rI)3n-@G6?v*Xg}g_lN~PC7Mu$z|tXux}_dqFzz& z*?8i&FNsEvaQ}aL|M;nwA^++9?;dfX#1p1oDslbPZ%I6H>a~c+{&@UU*8damZHO<4 zjz8j;lCKx|f8HOR`fbVYCh;j3p4UbiTa&2eXv;eP`k*!as*5jlVK!U4StF}P?``#= z~Weq^m4zs1%iBD}`Dp_1+;>&~Iw4+eq7L!*aytM7!~G%d*ifw#BkK zS?KU4+zPmW%cgc zZU99_GF*d-UHps-Tyo!;7kvA&^B^}-KnE6dZ|yz+?nqYu-@pH^0lTNUzQ)d6Q(t3s zR5$b%huhgE6l9Y%&#WKp&+eICU#pEaCD<@&bsTKxf)8WzuzQ;7V{4o0qhWMNb1w8# zlr`sqOIVeQJcMWk=Njks#g+wHlNx&G^>+N46qBTAPid;RXOfFCT4veV=6c)CR`=PN z)rrA4DzgH}q_a<{RI-6|1i7G96l<75!UC&NODbrBrlOu8;bl$r^;^T=4E;o#Ay-|6 zp&8&{OybjXJ&ME9&{a~qYSDremHfp6ul2Fv{sje@M zgqBaCfU0PtR$JM&GwMzwevF+K1LPY-1TdAV z9>w)mno`vV(t9wfN*~NL1bwrkg>lr%?4T8Xg}yU9U^%g7qs=6A1eW`pWB&=7uoh$hYtLOp3v>2oDaC8fuClWm(E13r z{`7du@+|9`U7_{p*x7Zc-JiAVQ43k4rC!1m-$wb)EPn*$hLbN2#GiFo)#6-xppjHn-{+k5g^@H-3{lA`b}krA zF_YkYnF?ppV9xY_^w)IO_Bp3&OSQ?4QJ6iB#g0w&CfzGmjSYuoW0H&`Hs(E@iZz4X zcH(!Snz}I)Qn>pEgg4b@9D?&GOshsj(9!4u$XHYWu{{n~Qz!(?cvOHo7en4h!VE$~ zBI*LTBNGL7%vrv>VKL6?xU&M1b5e#7G=i&!p*w#+jZCAq6xs1bbWU*_YCVSPi&?z} z)v#=K!AN6xDHi_{#oEn}|Aq))r$0j?U$_jjn9s_+=~w6PxtkmjA-MB6XuM&y-P2tU zo1lHQEY!d0c3?fVbu05qPoi%|D^b##d*gOIZ<%>C!`QDcD zI`LDi6Dtb;=2)K82O_!99<nZrXcM@QZ2(5`7+~rmrdfii zxxTd&S%Q5rtjq1q>Exr&Ibf1UN|=(ZNi!!J*|T8IlRZnb*|W4TD;3=I%ATcVJ_ao} zFLA8hqcObWpi73@iX7|*?Wj3+XdBqtpKSg17-~H@i~Ha?GSTDEs(9Ek1Q zg8IdXOOcf*Ewh}g*cbPLo$hM30!Nd(uBo5=&Gd1M&P$)h zXhyo0(S_*-M&C)NiYe}a+Bx8o&W&g%`;U%oz}Tj0Fm^B)%NNFDFIPOYIK>D1Bw+K! zJzSyDz(X?xyyT0c3fx~5M-)CnRCtnWlbF~s-f!Os1oZ-3rNqw9i*uHBDoTz+d1*<9pR3`M9rglVo6+5S0MwadU*XtBwc8QLrq zDGPRR7>6B(ZUPw5n0vomXeUmTnOkLzjYBi>QpY56nJ7h;uEQ*WHlQ#YNl^WgRAKu= zn;<}86S|BVZow>`a&}ve97kIdiZGI-yd?!xn6&@ehss6vp{Pk8s5tjDIG zDQ3zIIv`8|N4n167i=ae|tpGMy&$ zBKxXL@1fU~$az9Uh9WQ|og^@<93g$n>>0}diFu&Wm@H7I$VU=<1j$FxBZ$_iQe-R% z8QNmC=&k@Ma5w7NjE%)(K1tvZgw+&un2O?L_b8_t6tpyF8)Y1$4^M8hvo+2?v0YM@ zm%@i2txA#mkfgfiyYBitNqei~Hh&(lItoB}b&Q(TG3u_4 zQ4dMQ>Zq;U)zM@tR>!DW9noGo2|bE#Ew7F+dl-i^9t`Q~XgldYl~>2VfNxzLL#rTy zK%eRYgy+3VxoB&&fPqY-S6Z;h{lbHyp4~+*8t#VKN^_Sz^o(qFd`laOnB&rRHwUWC zZiqR%Vux&|+LN?RjdS&Nzy?0zw1&8jg1FeGEF+t@HOolSHK(ge*lXXKBo8t)pL>== zEWv}f2>K2bn#a`29_`=T>(|exyJ7C8I!-0o;FsF~x!E4kkpsi({Y+d2&mzKnu|}fM zT13unB$*36!}NAYW6i%kAnBFbBleoA3dzBE?W;8P0Ij`YtIrqfI7aLNU56R>VGq;kQV1yapC z7kogoi=a2Oy+nZ*o9sfZU1GAgX?Cf}HYzZtP_~_;wY?^r*KD83Mih91$zG+kG9Gfl zdo;Vz)E352{O)?kWOG`(*<^pE*)1mfQ_WhO*mJ?fnx&r@*>^QdFCelnYqrj0O~0T^ zO?DJ0kZ#Om1DcJS?3da$VX`}EE&YbTT&r2zWQS{(8zs?E-LxY+Pn9=O@UT8L`0#fXyt}`}3zP9t)2Mra0#v zZKI2Ix`vZyat#of88Fq0o%)s%_OB+t9Qgx!3)84WQ}Pp(tiik_+oza?KW`tUjyd|4 zobM|kIkP9MbRFkh%;nrM{2S|m?8e_<>s;tz3<2kptg?@DUoNzSMXkh<3*F0fpI5yH zsRwkEvH2;pQ^C|2>E=knjx2o$`mlH{T3*kV+W<=*nc2+D9URU5J~U@3ntcS#!NPJW z@=HLNg$5c=P-G)}F4PG4Qe+R*Q*l+rVBs%3QB%@Vq*IzAL6Wp^wb_aWWOH%w_hFRi%v&1)LT*F3@Un zVZ^p#Pl-U`aI~a7Ca~2GqjdzFI`gsR%@;3pZUr;cTY`dv9mYI2J--d|xyYY3A;JX7 zV&_GL?IJ8>lsFf94KPju_z1|dQskn?ea#YRmUm64FcXMj&hbFuKFqR6O$ik4FsVZW zg_}+4ut4Dkrh>bU2v~u_)kt%kwUi>Yia8~8uKP7AAZ|;cRX`ThoAS3&j^cLcuHBlm zm)hlngw93w5t;g&1K~AmSm*2l*NABB%`ui$s8u|9sG$_On=K%f!8%r`nL$|iM3m4i zRa9Uv8WdheAw)VPP>^*EEf)!%Gb-?`r#k{oSXa19@GPi@se$1B6@d3BAnOX30}$&O zPh&1aMXm2cJv)!Fg%t$Dlu3?)!V!ueodEnVv4z+EC~eQW!gdO1WQ_?REWNqD%_;sK zr-s5`0mW`70Q7d+^+pO#7{1~JieYFY$q%cn*@s}Xzl6nU@X@{($>t&(36Kl@1Cg`m zJQz%2S}mBGTZ#Mw)KGI0E_(2EV^*&s-syC4U_66}lZ0|)n6ZS_ zrO15X%{y~ZVYVWBC_UTI8>94II>0CF6{AT!bP5_d^D)4{SAcN2(3b@i9mDbqgcN$1 zOhC&3gGrAC%zK1cnn5vmWHGB3dDUxKeX~}x*gHs5B&djaDM#L69?iil`Vf1dZb=Ge zR24Bz2CoG|w?J^Q4cf{!bNOdKU32`wJ&l%)PUBd+d^Edd5nwp#iev2yO}WGFLo3z@ z2a072VsQ!1$C?FMnVy1l0BL9B38qnvDuJ=p5%N~ReM83afbJpqnCk$Zi#*!NXhHo_ zmi>FK3leAckH}JBj&v)%lhesO*m9>k#?I9!%)|J@#D~f#3fYLUpZqUJ0k}$meUXj!8m3`_2XB!NAW6xz}uNsLN z;8aefcrL zA8A!2^MNE^SWge}t&}|%nc=bV{dO`BNgmTR>MFTTj_CJDx?T-BL8oW zbLDS!<$uIXoB{^B{ul_*ZS(eJtgURcVumoK$QKWr99bzvHX-MYm8uc`s+R~@VM8v8 z$54|mTnz7fArCB2%~?WM>BT%QCo7j{6ICv9gmU-EK8B9S^uRP92VKKaVPLhZm;YF3c?QeO$T3`wf?F(n7f{Z|_ z8Duv&yAlQs7Xu*$HF1q|)oeAZG_Fc`#ihte4;hYYfT|cRSCwTt1ucn@5FY;|h`iI| zq78S$<4c)mmt^#LGUE<}c^u`udWk`_7!A1*VC*ND3tjXPQ2u)oi_r$vrO1BZ5527@ z9)cmcs@W{60bdd?tT*{SXRm7vOsNk8Kgp)#v=sUMQs9NHGsnNeO>$gaARSVQtkG(A zom9WZCr@D0;O}#8eH(kA?)u57M=vr$FK+l9I6fX6vx^Tw7Y7Sx4@FVu+43Z9DvPJ` zlFToGQ%A~VQp!bsj;0*PPwYhr!PrKj%fd3zD2Q@RW!O2PK}YP)WBK0CP_Yh(K6QZ|4*?fr*%UKMn$%@Sk(L=HjbYP{ zC+z9j9X1a38%Z%2x*0ljc2>rhi>|N>L~M05XwO~$b3#T=`hYCN{JFBwH<|CMUfC7$`dl7#PW@jg$Wc4NZkV2=Q(3KA$(zfisq{3<15Hu=*_n%&mK%`2aSesW=}PTG}vjR z83RpYvP`)qYtqaU6DbzdGj@(3J7^`D1Ty*JEgnmo zE(gRv2{Fl>G#XxBkvuYN*?<2NS=%gq6T0MmK&5skbB{~eVV9r4)3*Uw0jG=GV1rOz zSTAud)Wn8+u;Inn9ii?paw1qKVe*ip9CL#p%RX&3T00QMM-vV0`GB?3Uni1UcH7zx zl)ITnm;uwaO3&E2@ivaybxqk`cAZ;AJkIryosC&oimZA7n&F&%C=3o8NHwreX*MiA ztfF|x?`TcX1}1dNx)wL?;Qydqz*bn4uHm)|h(%>v%0O)j#G*lfaN>25&fb@2~F6Ulr%ENnAsjR7y{<0a4GWQ{iZGt3XorOocT(Thc&lc za`#D2yiT_xDLA^MCd(R(Y3BGx>>MA?Czyqp;bF-6vt+nKyACOA06TH=%Hr}*De}NQ zSW~C-8c^uicL91KdBlV@84n+lu=8`C>A@oT*FCXl^9qaerq@3KEJSOz}TyO78}J-!Ulh_#d}nGI$=dEh(6+ z-YSzvbu(}N<|0$Q+LQgYP1$4}YGYpQ z6n`zYO{m<~tE?rx;<+dr=9P`DY#_w`^fqOqCO>Lti~Z2z1F!5ulzE~W66?LnhuJ_> zZL~WXN}OyiH%|_vCoxx*K7!GZ^r^**(5H*o7H54AMZ3^E2~|C&>PD~XG^v`5s%uTv z9IxsSsoDWmvrJXmtJ>A$iQSJ|D35O7?y?tDPxpYnxXeh^))Zcr457;Qs)}wE`l1#! zQ@xs}+#1|bs&!6;^HPrI>}k3|CVGHB6hOH&v>dJsQ4k5?DqduJ59&IFN;xMY#TzmG zo@!Ox--4;>-HoJk>U1FGz+<;XoxfjdvU&Tm)@fLQp+rkYY_%Lq8+a*=Pm zY)Yff4^fZKBZm74n(2Q-ZQ%XnR_{?I6LFZb2$vFz=Rj_^(l{2&wPW7qJcK(Ljt1H4 z%4J8++sn{JEKaZqu9#O9kAZhT8o<(u9{o2)BN+XX5x7e@wDVw=yEw|{6wmGL@?;D*36^k1U%4^Qz z$|-WKBo(!@WBV`xo&e^ZYjy@p#mA|SB+43D*2XgL(cB;eS`2|xh|*S+AOQL?C?%ju z!Q;@67eh*HBShb*3;p2@;I9#y@VuHE%^$GrFXPC^tpItQ+2128_wxH+NECfEfl}Rk z-^IZgamCU2M{K+Vjk$qwA9^ij;VnXd?=mDYF{-$CvgS&u!2k>0!R$rMBJ(|F&O(OW zgzI(_L|VCSm)_otCnefW$OdVaDZfc$R!racn7avzfhm}y5XUq$19K0xu>I#dfox$1 zoTps~ObuqnN*bnjVuW{Mp2Wn@Bo>121hEkO9)YioG0@d=pl_+=j$|XqI=4)#fRZ&L zo9tw#p$pyP8Rl-T6zVPaih&>VOtxzY1wd_{u~7>y5^EmX04DR;%Xy@keb5Vs&>oQR z&ey@g7)Urc@WGg-FfLpsTxvpPAb;knXKEmPuX4Az%v}=+O5SkC6=VmGwcWwmwq)({ z9Sv*!An(HcvwU$E8Aqn$#b{G#w&^uAI|9vod?)KNo#VvK=}MBU%eIUI^lu0~hR}tB zs|WT2WW>~2Zp2QBlWHQ{f(og%X(iNB7wTz+Vu2x+9GBS`fKiUX#Mv^HaNN|l>{9_yr2x|pa{;Cs0KxeBBpQupIRHfh)Q-Inr4XufK$k41Ci&bcUL=S< zkb;yrHAu%{n3`va0yR>hdeKaTgd;*Inx~PDgZC52H4Yo^{!lE`HJ5OAP5_1TWRh6B zv;Y!d@S}hyMX++qD~6RmW^pX*LTsf^W|9zA`WPNByO83TXOS~P#82b1q}X!A3+xyiJVw<5lG2UJlo0lt?i1B32%D_EG$YP|3C62yOf ztYIx?7Q`rqM$~NK@nVC#B3C7^DdMfm{ffAA5IUNz7Nb?ZI0@Nfn7vuDoQ{uW_BzRO z*|(XU#jJ43O)yN6HB(vhb+1PD)L(4Y{h|P4ZsJ?D37$GI9dQpeo{j3!$dx;gp2%d% zsD@i#lNk>^$>L%(BB!;K*%iSN_cWgBgCW@(ZU>)^%tNKfNF=d}(4F6Jt0)@|_k1qn zCy6C{5l1K#8zoho_~vt{YFgiBL%E&J%h1e)G8@4CjBTlmO#jU`C{);68?Hnbe-CsG zcw>yqOO6}$ZO-Fj3J)yyg8RUDP3e2z^xgmObk4XQ70~hygoH07GSY*51d#b+Efs+Z zV*EZ!O!9stsfkuz*?jRk$YfTx`9{Q``(<-oAIwfIGuzGqn)j5$qXO(7xOMNtF)`~9 z?~R41vt%A>MUi5C*x}=OCiQAwaf~wKjjQ5goaCcc$FPRp!gH$eD4WCDbw|>VLd-cv zDd-u=r4UmJGXDG&pqqqq@41F)5e15g+Tv&AVG`4@lnPv{z%7(b0#%uCk}SzZ?nH;1 zg8f(kwqx?bnQYDpSBGNJe!`g~NU-2i`zN;py#KxVLG_>6WV6p&oG*L5#~448eGqmR zy1K{A%Mg&=yecTtwqUm5Q_5@0z~(6>TIo|tXf)h?w$`JO^ikY&hQ2*lRlLv58`GIm zgBJ~ME|-}drSu?zu9^S@8^Re=^w~343Z$>;Re@((h7yt#6eH;;LO*E@0a?( zYRh1?6=1anEYn%nA9J+a1n;Ys*=ckcH4MbcV6h4?(O?uB#C%=JbE4cNQPD(Z4WKue zlVz}E1z1ve4lnDnpeYPuQMcP{{uY?~OuTC*(swcEZ#-8Dq>^u`_v5UkOtQt_su3OT z(`IWKthEA6RzS*}>W{gt+@!6d33}OwxxEb5UIEr_z%rfKlcoGk=66-d%bdUATq*F8 zkO{b~ADNDQy*t;PpCQF^4&VOdIH8xDGgm=Q3jE|2SHLq@0WSptpIN>HmHo*rMNyd? za}~{{z)x;@1w3;V@KT`UdQsV*TpxU(BKtiL7%cI>9Lbs0 zXk(DImINx++Zgtnjmxnw!uDRiWWn4151pweZOmydu_yC}SRBMY#PUO8M+&h_KL^ED z=4*_jh2|uX#p4$!!5P9$u1_v5Y`;LouSUo$>6`&Juo5mJ47M3qh|J0kMlp2gQ9D;L z#HB$g(g-HG+{De7T+XK=1hmsEVZ%a`~PQxmgTJy6d|%BhxJoYA`mk z(M~onx2Qug<$O!&MP;`58buskpZ>b2dpW$di7}X#rOfQZT<%1 zoh@+S)_D&}G|KJFF^Rl}W`f@_?`@WJJm1}b)_1O3&;x}AqP$1C6%YFq=yd&a#`T3y62U789d=Y7&|92E2s7)*$r*yyN+TT2V@^*e%}4-`Q$RW(a0NqD zBBQgvA5T;jcl~(C!Bh9x6&{`{8Nc4=vGjW>nN6ME)UR(YWA;5N2pMyc3s*A=-HoUe z`8K9XeuBx^gl~3DmdnfpD_xm%r8UB%%*;~eaD+C-FWO3pTGhhkwJJ{H|B!x!DR>$b z9RUfBCg}7Qwqj1cm5?&$SK^e{r=^y;1Yu?Hwcz{;ygwGax;`bHX_$1ywV!5Xw@VaD zL()pizTZ|S5T0z2AkQ|^Dc>l|Y|*a3%d|SqrcgUq`0TVObLb5oK-|>;b}YLIxtj{G zrfefl-U5#=8q_#bFvUqPbyirG*{1nsHP1g*UN2{v9y|6K>9HRa8?s}Q>br*QT zU@Gq-qy9V<2JRUcXF$SyqYI79VG{Kak%0?oa8o1^GZ#9QJcyvV(D6ufh@p*aA8MS_ z#2Mt@2pI7^dlZWxQXH5AX&B>NBibk<+R-A~`_~U9n&F%_(^q3OkF&KQd`gn~bJ;ir zy(2zBVd@kJBX4_}9BgPholM9zXOD}?^&`Q=>lz%+NgV;6lqAglW&pP%g z)P~Ghpux^|o?aub

E=vL}F`rKo>R!^~O0MCn<=R`z!Z=M~vS(~;y_7nWEV9!BM* z$jS4-L#A@M^zFxGB^UJO9bt|yax8mLef9tYC+k;$7OJ9rrW(U|@o`P+7@SbTKzz2~ z)9aK)3^YG#^je>@%hnOAee~OJRPYPYU4AKgi?_c>IupUGp7ukcJpJQ*EQ zaSl_0|AX&AdbY-%c>)CBhWuZ>(p{mD3N6HBlCX37)xmR46oV=+CTI!UiLI=|zDT=y zGL!%rJs4M^;uFM4DOkW`2+QEj)|4Xuy3Whlb@={^FN?be@AzKDarXtdZk3Z$AR7iwRTi;gXu9(`NY2GZsMMeM`XR*{MX&8_X4^UU;TD!DXU&eNLotR3XJwt_ zy~kqcm3Ky&*5;+82`E{Il9h)GQlhw!H)(((Nrtdcir3J*lwV#qlEouUbq5||ME>;@ zakBAJG{(MgqFz&ezssx-;4<=#0QEWNVHM05-Xa^h$j4sG%cW&_-kT~NmLx8>J@dIM zHfBU;S;sz#x?4~K#McXpm4qcEE>}sRS)2tsWOIeI@l|(BV(91-iMir@-Ca4j4fh4TuIHDd| z9x=}WmkRp>K^y8~V|Nws3x1hk?Q@2ao?;N~*)`2MZ+Xt~M4R4$yQQiX)ZcPUev(88((;-;)T*2X%@<`-7yJlXTP((Y$yzxgEE z4W{R{tiUk83m&3;Ap$`Q+2Le2Qji)-`}1!PlopO{Pg=}Bn`e8{K7k~p{ngee-lr7z zA;pTGP4t)cc09e-o^6CqDy2uU!Njn3G&5 z$kCLhl?PA8{L-paB9o-It@Uzws@^K^T}C@(1{(lf+`zpLmb^|XEm?~E`6}RBq#B${ zAvnc#>X(~3&ApnV)JlU!swbZyWAIuCjzMka9)iGTF2*bT`N9WqAQVnV0Gs(hYN*94 zAs^=g{|Lb&2hV1(BtCw%XEQxW!e$;&+EMON{IkJrO7S1?y;RyvOMjc05g~Ij8#H1M zSZOn@uFb&n=Z=t&p*>@3v`PNSo>}ZM!Qi78zICT@7t(YqURmoa*ayzKd6K^MxR# zz1kdS#(2{HsLe?Gj##tIuY5G)^({6u8?W@F{W+45_H7~_YzBHkDeg>)hGR4P&F=#K z{sP~C$K!7I!ptkWSN)VOL!Qi&3{;%RmI87Ap3jXb%TH4M2$?(I-E%xOaPbS$-rT|EpW0`-;+?K)MzE-v?9!P-NlN#y&^Nsw6xvL`lF>ithw#M$VxVl5c z?b#ZcYn04nk`Zy&$b&)uviRhAz=4%7#f1tps4R=AHAdQ$E{iEPmSr(zmc^8RSsVae z+yF`TQ%RD}`yhd1=V;}CLIjF408;CLJU$S_D!S|ByJ->gu77%yy$GZlY;gT>g69WMg$ zsZd9qCOa|liz5&=!5KQH)OSRy{!8pHl;-#UC^TVb&OdqG3e?+hk&A}se98hG*y0dH z*l%-oIRYsZwXvu$gJ=4=s}~{dxq-Yhx}3LdROxwp^(^vUKC)63^hLSn?J9iF*G#Q; ztQ5J4(3-`DbB-^Iold)C!DA_M0g`z?UY7x%e_-yWE#Sk>b=NOs41>c?+kBFs8HHvj zEi`ZM0zT^^(UZ8ftgHnN5EjNgBy+CGR7+;M$<#>ZSeG#f zkq0p~=xMl(hJIp+JD%inyqvUik(tXW5q`g-$bq?Ep}P3_ECrFQ@?~c zCBTUTLORdNQ*5tI@lEesgKrO>WdvUWBov&n{4|NVq7Hg1qpZSwl5jQ%FlT#MS0^EL z+Lt|*ZzAuNHNk6{a=x!EJJ|p;oBXClr%KbQ9gF=Tsr*G*S}OSUEm}`mqv56DTvpfT z3xymf$#K#$-=YSs!vtiBF6c?3$8uD|j!r^c&Wt^_EG4MZ&!P9&rk(|FQlC9`t!aR{ zx5pmG*K-%4oPQ*TB|IvJ(uGn?8aN9*AUZS;w(*=7ZD5`9C%A~51wbC94GBWrf5*JW zq%lZWGba)k(GIGaI@L_?C!S`GMuU9eA>s#}F2wM^!oxu%N%!YYATjy_48-|Cq&Bxs zMw&41C$J210qbq4)J$Xjv3!qf~P;g0}E2=XuAox4_t9 zRFoo%gfa7+m=CtJ`I3Wy6l$9fApR9!z^c0i3ID2V{M#th^>#XO{m1nd1Y|33!@IqU zsstLcS4VsrC)9CdiEi7ULUxqk9|4oG=8$aTnpf@KGpGP(kSD2%L6o)BSjEJY3ymc#)2 zeR3W4lUR`e8GMhv&8P*#QEtfahqvTcL7@Fex6F@yPT)XQ4(<`h*}E6H+JeSoAfGWt#Z@o3WP{fYXUibw=zBg$%QwHWLscZG+_*D)1W@|S-w$sd zlHk_OqGbRww{AGLIN-Q~IroDfdGH?Y#)rVm<+o90-`vW_^2ZY(N9|`C^rM?pTha=5 z<2Wf|CG~QF_aiNOO+bfDxce3b1n+|1mhYFC8&&2x$G*_lGgJ}gY}vksmOpI97#T*l z{2W=s#;>SMVd(7xNWaf{8;qHI1i`}9+_OvVw*KqF9t5>7VLcU@+~$4cd2v^ zy_m;{TDX6c&t!j#>SB`FtPWCr4sIy?8R5$jx4v6K42m5dr{NGw-=SPL(%jAyP&UO~r;D+l7)4yTtA*+taG5j`_3O2S>EdnNoU=3 zNCg&k{zx0P%{<}VycGH|&O{=}<%f_w3b|+v>BHwu!cQjg7I&y)eE*6y$&zKtj8|DO z*=!lr<(`)~i`((DFznRTWCtl2RsjCwLB}pf@W4mUt>sH(Xx|oovO192vPTD2Za!xE zwu+gQ(GV~aB&E(T!5$ss)ox~807fvs+(Ul)oPWJ9iv{1o9gNOl;dzUERq{b@WdT*Q zQAH)RVREXXvN6pdF!Q)eu*wiTRS9Md!4udNcZ;NyGs%xm6~BjT-s{h&c@rbP6QE67 zOjCS5A5BB={R*RK_x+IuVGLPLE47P;?!(-gJ$1k78|_dEn@)%P9mU&3 zH!uKQG2`am9=JC*@Z8QwOJ}(2uUS@8u&)!9qlEM1N#YyEHLb)_)5qig>h#aR?CD2e&K!~zYB?zy-9v&8h#g`4E)~8D!lWC z$ng8rUc&E-K&bq3n2=zi{32a0av$5F5SF(W93F5uH+oE@oLf#{Ej+xT9N?TkK?kz2 zfe$nnxn7&5oVVQaG_SIrQ~U;M+r8Rfd$o9mMP;obR)~=V-jj)UsgU7X>%HQaiyY-5 zC`Iz{G2lQzD&lq;KW-?yPM-4o-T&iK0o7c zv037Jxam#qp9<@P%&L$ToxC-cbRQFOzs~~B<*oEe;Qli2}1Oq-aignjtzG+W)cRQ8c+2Y)dyDetB z>$=G52B9`esV#g1)Cyr4wmcU>ZSW3<_Cd9ex7`TsYOe(p!8W@Mp99s);BMswdx&$A zu8St~bED`L-p6-7#X@habr^MT;kPXo@nq(<3<51B=ycwVQ6#_=-W|d+)xf7x+zZQd zZRLnFE4ZBhQ$qJSz4){sY-O=D_C8CC!M0GG+XU$YF4sW~ZsL$m_8CfQ7i@YV*$*KF zBxMA>=m(wnd6dccJPLm!nMr&yi{F4N?C0n8lD8lk+UOZat~bk92_ay@c^^tQhCA;! zz|Be8oPE0MyO1}ZEM&^Oq-shHlzC5;>eW`}JykUKzNX8D=_^;%Au2^))ib`#vv3Sl z74Kog*0sqR)C-bUYIrd-#vdm6E~&)tI2xB1%96D_a>wV-XUEf&(oVtgw zeK#prMe{u&E_wzNw zew6G->5%%FaE-aJ6nU1iq4T49x&ROsZ#e}-@jE-{`FwGX>fwGx6eA*dw&W>5R5pZP zx@by~&yma*<@sX_8p5Cl0ojQO74;CKS1{kmA*avz20EWiz!8S?3@sitF>2+YSD_U- zbn1TSe{jFJ^0QRjOkfI25bHU+fnKKktdSZV^t|DEg487;Z*cEsP9UxKkZ0FdfiG`d ziw=`fQj{}S8{`(jv5n`t;eyKh<%*-O5=WhLh~j8BINDttIOyp(XtC1gQbj;0)RINK z_KE3=07>>sQcoDrp#Y>*p=RIPYPPuYItrhYW38yAvH{Jd@gpcEU;G8}z~v}}%%B4D z{|5=#&eau!SCoKx6I6x)0$1;09wtQCFaA|L&js^u&&g?L=u;t~R< zTPA@EHiD1D*gQ?J=R<0y^J$fE1I@vab~C8c#+_hhJ0p^@tneW5_kMo}xhn{i{nIs^n3 zSL4ipj?5l~o7P+#3S?%d?43Uc&S$bh zbB`&mf1rYv;RA7I4l%Tn{4AiwvNmV*kv{qfv{^-l3=ce659#xKWFx}!?)55-PYjH5 ziCw?5L81##8lTc(@jWa?3Z7T6e*yP zPoVO!0+2T6CV*ft@|ekelX2!_S~MHIdYD_Zc$&dB0gc_4&$V?+xpmBI9b;=VQxh#t zb&7Uxf^h%1H_;lTckg0~qIA2fYTKMuNsp_zhc`|{Yz{*yyKdlR$46p>&alDpVm@&()C{xDC#wNGQQ zl*4qwITr<3CwTJYkKYmI3>3lUDSFc59hgKX*iNyciCKAW(&Xx-2|B@GCx)Sz72MrLT&AI9bPmDH0U>yPdV%&~`eq!8$A~g)#6T>DKGD(XV zIQgg;&8`^D5MzHs*V(DVqZEJo58i979uC zj-e)#7)C4~!prQ1R2wF|G0;HF>nR>4lLTtR^jyP43a^@qsid6zc7}D^V7_)IgBj!A zXWx7^te;cH%)hDf{F^GzzesxXZ^}3Su7XaWt&TfflK3XK|ggHmQ%$;?F?>3)S=cXQ?pUXui+>TPI=lyW6KHE}bN`GhWQG3m>NV3^xxC{-z z)0NF?P3eRFX0nN!=HhO`D;{uZ{R$XXMj@h|(@%ZY^nrm~%soFd7JWm4G#ONKK#Pgow*ru&}fGk;V4yNl7McQ-UM8PT;3Y zJDkaT8fAMF&ve#X_^}i`fbnooQQQj@w`^sAo3XQYiXqs?UWF%)G0%T+8!wOy-p8M2 zKo$`MyFL?Z`?J9tWN#rj5tbsa9Vf%B#hQb?f&0sZy(r8VclD$Y9K2kE+a_oW0dPY= z?Qm^`bf}eY0eRlFLFqnRQVVzA>FYlEYN^|kIHT++6P1qu&9U8et&&K**N z{vQbl^#2CYwYh}kw2MNt|D~pfAFbpPak{jV{*MXfOedazRTWQm5g(?AzpIEBD`LjZ z_CVaY{7@wI>8x($-|!P8q_~BQ=d=|03nn?Er=7>Tsco4Ojvhu^ug@@)lh~TR_8&Uz zLbim&%Si?X$e1ViAG1v^a?Y)c*kK{u8mIXQpp?jcT}iFdi@Gs3_EtoGGSh6TQsu6} zfE_{cV6<2a-C=Ax%y#|>ZoCe&oj;3M(qR(LyCH0M0E z?Et+lMO$YM8o3DWR|J0>ZV{m5Nqq*-)ZquXR2ypn-?wC@e)r9g8Ya?}6L6sYy(s zpKa%Pu$VX1)l#U;aT%m5=guhNxvRNO>ZYnrKH{vp1H%*ppGeKRynxTxz zh06{Ffr}_DhfH{HIidy-ai5D4w;6fdu*@>3d2)0=AA$jpzCe-koymhFZMI7td%6_> zsx|3sGHJXP9?1z{ix@?C(n~6&UFTGl3HJYdh`tZ)zhAC=@cHI`M;o1sN=lKaFN>Es z$M~{%4prsL;tJL0I8?YSBukNxBntz?d-X_ScVFpu((TjW{-?~QHtZGWLY*=qovC9? zN@VPmPp)vDYhW=(>wNaDyViDTCXQoqtUT;xBh1q{#y7Xjx(RM~vN8wif|GQvtR+rn zGZo+Uboq6+!gV}#VMhYh<7_8eVX?`mSjlcu3M;`bOCH@uwQq;7tv2V}VMu^eD|1-A z8GhBw$?&V@@Z*7{8a&kb4o`sp>{wJIVg+~C2z4ydC2m4(txtk^Bb~JoA*+pS&Xg&xNlP?wh z3$54@uzh+wa-lzd7xUK2(GcvMauXTA6)0-hC@v^gDvCH!z;zk=HBs=_Tg~TUlwIr! zLJzU#EY?)X4IR&i;`S9|-~2Ln6Q?lQs_Jh1Sap}kyaUfJcjGT}PXO^CgW2m~nG+9- za|}pvR$nX%>6VR<=>Yw~l-;53IGzA)1^|=jgy+zgOrjI`V?~9}5YS|~qY}jfUl-Em zL(X@>2>dRzUeq{e;IcaP(^jsb=j3;rGQ5!keFUuvu? zi3C|1+!Y|$IO{jfw?`Rda@6j32KT`1`F5zV;~+xGn8d}i zeox=n9stA3rbU&(cEg}7%w~xOHlTx<>Jl9)ER>Q;(^`ZwV_HqhAWLZ3y@;JTdMO@L zDxa@L@qL8~#^7TxjCJ}M>+~_!X&5`xGp{p&x6Ig?(3~@xGwdXH+{oh&ev-h9F6WLK z@hXq!ga>Qw*pmsa+UyaI8PjnoQV@Z`Y6^#h;vRm$^D$}-;Q2^+famixAqt(lnuEXJ zWa^twv82nGs4AY%21%J9PcTXMcQB#=!IZx}Bk%U)aOQ^a+m{NA1^6%6|M~7l);ZUk z*Zi?)l_JlmYpg_mRDF2a@cA{%MK>4s zLTr@CeZx>kom(0xmyW<0PIeGAdSOd&O1iqfc$Z*ZW3-2LY{1&X`E+akD*rkhW2TGU z0JfuCc{{oCVi@S}C8V4m$_AIKG1SM0oS1o6u!V1=*v@r;0t%U41NfRBFyX^KD9oGW z^@;_(B~O4ZMidXoSpKT69?G2L7)r=CmpzXy+vR#SJXwA+2giM?TuK8bGjGFs1qIYK z$ZePMdfiI+lyk{mfafj7K78Nl5ThY6JxoE=ftg1*Lqcxo5ko+_JluVs3}BPbY#E=H zZ9OY9TXqZ2E5QVO9S%~)4#tP)eS|90>v(mvmv~bKue_ZWg*Tt$4zH~NPBNJ-XLej7 zAX|mcY^gWXFK$$di-DJCh2Pqo>hhBd(3x0)jv24*f0sHvRwbS-(~a4h)nMW=d$Vg0^Cx_Dn(fbfaj`1Tym>W% z8BZ6LD%v`}1GZYFY>qJBPAy9qEKGn=7I<0KyGxyNX5+FAd&3Kk`f{&c^uWcc1*OB$QM*UM}rQ|HBWCp5>jl zle>W<7deFy8YG+>f=F#;ybLNu-X(H=oLI{3YxrvyIBBVghjE^(>cd6={=CfD zc92}u>EpABS2iR7~ZU4h65ENXDHFn%Y3!4GVl6Xj=R`bHTJ zH4EiBnzw5gIu}W=$u*Fv2Z0niaxpm?=b0@%7GWSAMOc+S2jP%( zTk#^AK$QD>{V+iB46j5ymHfc#2uv?>#50FIQ08{L+H9n-oajEL23*Q1u%;;Qbt>9q zZE+~?S02zS3v_AX=M6ZiO?+3v7bRRJ;lmQ%C*cny?2+(l2``cG90^aB@F)onl<>s^ zh;x;M4@-ETgg=mw_i;)S8}?`TZ%Kb5;ad_uFX0ms{!+ppOL&Wf^CY}N!r_A9P)Sde zaC-?qh!gX}`!Re}!p9_BA>pqjd_uyfBwQuoGZH>4;aUmTN%*{kFG%>JgfB_>iiEF8 z_=bdUN%)S0?@IW-gda%wI|+X;;U^LnBrHn!2MIru@J|wcF5zD#{JVtzkkH6`xX50T zl7}QcM5GQ%$jkkuiNhrvDPc&$u!LhI+*ZPfgxgEFgM>RtxU+=2N;qD^2@+0}a1ROh zlyH)S`$)K-g!@a_AmM=$9xUM$3Hd5RY2x7$9wA|)ghxquw1n^PLztH&d`H65Bs^Ba zDH2YSaA$P8+_4)`E=qCVwQbY@PoNX=a|m)!V?kv4)fXIbBua|hXS0C zNu-ZJ(b`}HCFEgkFpN~dV%ZLwTFwD1ACS(4#-PkzTOHtZS1!+nrpzJY=IW?hh#h+9 ze76uBc48PfpJQDg{L$Pe(f!SM)<%sU}vWS*!gR}3Ht@w;;3xak>-_fswDDR zM!Da@XUfW`+fTp6#u)uXMw80u$-w3O7E+Q?Y>0yiWz_AcJ^+Bx@rKdwT}wtg5gJBk zB1J~!fN^;(j|h0q&&{2UQYjvN`3RuK1s1HVB!W$6Pw*79^NVyG@(>CAKQ@5IQ8t#} zdXLI)y+_#&?;J&E?S@no)*3CX%C6&n1P!^LYMGX;?zMZWpDR8GmE3_5;%tX~lIdL6 zUOTzIbpdrLGKFUZEK1DbPLZtXWKh3rhAjY29;L`td!pL6$vcvdI1*?ho!QDN_|Lc< zMrz=ZEUC^=Y$rI>CIcHes<`ZcQ8@^Iw~_Eb{#rmjN%Eqcq$no|r6;Rqw<+s#2*T~l zr(%Y6J^iJdDp(hWg>|^J24fv>{p(Jsm8@S0Z24jp{@pN80FD>ulUj6PpEGu6kj+&3 zp?&^AypKpDNRntRQ?>SaNqkg1Y^O!Hu)A`3!bDso~iw$-<@Zn05FGXJ7}(#|gM= zg;EiFRDGFkRY#92_1r|u(b{4HkzvN}Eel^qlp`_i3ChYx5O~^9%|*y{#eiSiIX%q5 zFE5TXJ8$Ez1GZ3@iKXuuAO(8})pc>VDvsgJcKD$&ERRyIsD-NoU?WQH#5$^%2B4eO zvPJ6e6gKt%PcA1L=RG(O^2KeP*D)SZKn>J5D>z@tTVa^72#>e&J1~=!F97;PGWd4# z*KY5;;pK-r?;y<$n<5nWwJ39*M&MHMmOr0=#eeZ8;Y=2mI~pLZ9q5o#g$(hsJ;r2I z=p$ZgBZlvEVEWIC+XZHbr=>fJUHCmu!p|Ea(FcA3GPD|#mNNu!@LxG6fkpJoP^X#& zVo|D(iIgCUz?7Exch?_dZNt_CF9O1V(}8s{@B9*I%39pPxy#FsgpOAs=hKwINqk>B z9aQ1X4n~2Ci#cBK`Vc0B!x$_AW){&@AU$$L5CzUL5Ge0hMyx|zxDFc8?`ETZJKPc> zB0TNGMG-DsAF;Sp=M`Uv;^GyYm!hyo7^IGR8Nf3B<6c<;2cZRMZ{v7@`Ym?$PjYqq z^Lsszq?fY2R12D2qRmk6YqlnMAj$(`9c|~F?RONqYx*Zy(f8gd)1!vB80bF5={(-mdw&U2|@M zmlw8z-<_skHjWlm#Zefo_}$5Cpqd-_Gb9*K{MBT)4SMth)B!ZaHvG9{4&CkOCyG12 zLT8xN5~SRb;>r&-2J47e<_20@iKBwIxsS)r51e3rR7a7<6>%+%Knmg0hpobCOPJIGO!+FODkHzrE6=Ihu~<}7@2+zQ$@c8Dn!mqgpSRAQ zu!{00c-RLbInq}LSR{j|jVEQ!^r*qzWPA(+H89Nbo&{Mv-x*RLmRW;0k+r1P!NP^Y zi+gL$w_W{iC_+I2bQ(1Dsc#AdX;eEy1)Q?_`D$m(2=59<5B}^!L$}SsU6WdS)vDSV ze_vH9bp)QVSFNip+>I|FU_ZqD#2z?3INxM&ID))5x|~zsqA`=($Q8qY$yp_H-tpT4 zX)d%7krU?1;#`T95nZfMeEyMlg4oUHofi>uGywkIF@V2oEK8@L)M;YyA_}pO*&xN+ zpv0(UsB;WZ=A9HDJ2=N7ETcb+=w+86+i%1F_GqeQBF`si;(XH}zmmwIAp>sUe*nvo z^G3PcwLi|xM*b?yB9-z(3wiVCbUQr%z>}r%nZu9o#KhJSG8(#z5XIKa;RmAB>Nsv~ za8FjV8*-5YF!MkW+ahuvf%Z5mmX}ah*b@){_*1JLSqFaozM!+s(P6$1c=Oh@F^>!h%4KF_w zaMlAC@W+Y=qg_2x^@#U&=2f)c+qtc>{oTw0cyF1i+k6X%^!FQBBwC$D5lICHgPA8OqTNC8IO!OJh6u~QRk;W#4KheOyV>4u^wIEGb}YA)F+&^ z*xV3}Q$>uxfENyRrW1Z1Lp}IiIS2-K{){=N(D&@wt!tmjQ-L9c$@-bgz&S7Fq6-^( z8`g#IZpPs#+1O(>_OwxN{T zMB37dm^N~iTUccZFHK+Y?UAd{l_M~FkE210vu_*{=ynv%ukMGru_N8)B2mm2 zT$;Xc0Os==PiXQmM?K6@7jqQDY?M3+`l=#UhnH2?^8wI2;IP*QKfV-kmn46OBzHgP z-Rg;(k0^x??;RSj(kg!^$+qmO%2Dt>i3UKPiut`OJ|~YYg|f0lu`_w z)lB3Zg4qUaeLRb7RrLhlMZyJ!>!3OrxMqJLCAR&aZOKJmhh0j2{Wbe8$Mo@)Ssc4I zc)}%SPFx#27Aej|Fz4w=+L?`C!YwilN$_2ZiL#b_Pg)z?Q30_>LMqc&-4hJ6K{hy! zQD)<3Xg3B)ZD+wT9qwKNbAsvu8|+mdM(vRs?CjGVF6>Ssw`vK*8x)-JFo|v)YG<|# z4bM9qMQejU`L<1qPe}gZ6PmZlXa>$0m8FXN-CdG*x(bhhkVF#p~3_#qS2et!{%Je0Bf_oB8Hh2)D z%*JwJPVZB_@t0a{|`>_*CR<+d=eDgbk zZtNpK!(gQA^Wvk(UsC>-N^VZtnpW6YCzh}gsc)C4z)8-)FVK6S${bjS99tjr^)lYAo z`Ibd5H?O&F`CtgnGY!2fHejy&`~f?+K*~xHUJR$}s18;vGjTu1&`-EGhDL3kL~Q`DPYT!+!ip;XFx(0jU+G5PFyjjJ)^9P zM1<)@NPYeQJ}k&0+zL)2*^MLsg?SfS9{Eya5{U3}Fh5?949LzSDRX=hGjXGb87!v! z{I=0^^&;;a9-i9o-E{^kCfH>P!|828p9~piOdZfN&L5gDIXR#=Xr(eWUi5&JM>+dJ1(WSMa zw}L$D6XHLlD8y_0F>-}>E}MaNw8F)7sT8@cwP@MNge^Nd)#qAjk^*?r>dM|EhzOv} za(2k*D|i^)#dX$VvxTix=JCLM)EQ5g@w)W)cVJgJ5fJzuPvu^hdxin>sY64?cv81M zQ4wKo;=EaxZ0z`sWbkTCb;k@--WiPsZ`mPjz706HGdi9*^VT?WyD=vl!zglA^0q+7 zzD@zl7TJ%=rFvMB=K*tG)hf8bYMf874w~(}3MKm=UzfQ1p*mqj_{AX4dIR09hq8Gd zdVxbW<8JoZ->w74)N^Xbq!d6u8=!vmJDd7pD;l9tJYMjlqB;$}LHJYp@1hy-%hjH^ z12gUXIX4Ec(u&bj0^1eE~EtoZ(=P~sB z^yE4Sx(QY&l&NQU+V%!-gE8RpkI5?73kR1S>;emH4v%qgUwF`%t|gWl;;YpQ8Yq-5 zl)|_c9*V*%wla&m=QZs=?f+b;feQz`FFh4zAi7~N@cb`+MA)DA&Bz^0AInvdxHAd* z_gTbOX#bYcIi6zE;)>8G+HcKb`r&(~U!Fb5N#4)jl?Fd<<`aL`;8%-!LLaoKcD|Cl zSjK51ito@0eD8h*eCXHLVGaJC2FI8{=qel1rw$3}as=SH+`Gxk|8wuke9WQnb4<5R zoWE9;3;lz4Lk?YKd`9RibJmC=!HFLevVT4WHu$ac)*;wcwmCj#RFFT6O2eP za2Wxm$PDDM=K<5vvTG$;iX1a&xvoItS;@s|)kd_ERjRT*sYm-GwU@)t@J9v+KEYKS zAdOT>E>>KB?BxgC{r*0;O#RRwxtWN5;2LslKF)vE^3Md)C2%{`LLyGF9b5^S;IP>ARtU z^C73QT<8MSJH3Gc)$5lAe3LEcJ>Bp5djC9(b${UU8d0Cl!8un`B0bLgnLaEcvOEQx zb*e`gj93k8RYTqNO*5?&+Wr4ptjyj{Z8@NJYPE|YMHgttq$K*DP! zY?qLJy3)ky5*{OALc+Zy94Fyu2|Fdc2+q6G#NT2NmL|R@;YJBRl<*@7KbDZ|Z)xJE z5^j?4j}mT{@Xr$dMZ&*HxJAM*B>b0zHwi5qLxHDC!fFYJN?0S|2nk0?I9kG53Ad4O ztc2T1SSR6*5{{E_7YU;hZZncp(%8Y4CSERKr-WBYc#VYDO4udgbrN< z1rjckunr-|D*yVAr~j7cvkgB?|9t=PZm5*~&!vr~q%!o?Pkb7hF4rbcld+Kf)b2UK zwzEg$KYemX*JqEeKOCopUW~e35*UV7_UI@_!dWux{OyxykN>7U)7cX+>Nhx} zumo~%!zM)V|L4CO`K>PeHH|d!*&5H(_$G}X)VNpUS2ff*S<93CQD}Dh&uvpvOsPRmV+cZ8~RB4jh|Hd|5Ch5G+wOnB8_j- z_&SX{HJ+jIDHC{9BEeDE_e{4F1U)CpA7%1 zjhAcu8;#%7_>UTYp>eg&d!se3)A%pSSGV$Yk;W;FTQzRc_!x~RYrL1nyJ)&2Q+f%)8~5miKP0-UA#wL7v?I zgosWK2%o(gOJ?w<|Etoj21BPmlElYGPFv&t^}_6c!v7ZwJ{?@|N#(Ca<5rDR8nnthP;SgZ)S=QJh{=dPRave^A)+1;fLtRYk1mOP$|DS6B zjvZ@A*O0C{^x*=e??oI#JOfWQHsRbjFKSsQ)?3!16D+IxM7({A|JR*_!|&HE>%nip z4}m*NSKu03>ITdDR?e~}EyAU@yDaPZhb`;aM=a}1{C^(*(~nwKa)o8xfd2kdl7Iid|Ni^$zyE%BkH*;tm3lq!zAvx`0^Y;w{6k;G z81_eR-cKIrtV+W=Ouwda9sdSAg8OKDRq)WpH5>o#tFL){&kZkKb!+gM*Y>Rag!~bp z>gnFv=LVy0WouB}U94=)){3S4)@-p7?A{vePDNfAS)8usv!p>ToKkFd9MUp-u$kvx;=(BuGCSbmd!z?n0F(0{tFOSj0 z8RGMJJ*z}!yn!doJ=1yDiQMa^@%nYzeGNQe-qyhDfwzA;PwP84jW?+E9h%P5at}=7 z4Qsi>@NiRHj$th~39pO(o(`n^ME*qXE^T;zj~hl;*4!X}bs=)IB`*|3drl!EwksKT zru2;YrKp@IEaTDBXVvxZ-n~1Y#l`CAPh%ekQEqLz$JUCX;nc>Ccc+Q$;%$$IF)bL(_){O1$WFLoDD-A&*b*VlL%L>fad@^P8war^U>BaA25xEUMgJ-=C9j4cu-8>440*!n>75q+Zn?gSP-dUV;d=t+s5 zd0Ni{w(OEl^c(|QyCr-#;d7hRxulzskNCi*6Rdr8zVS_xugmwGnS7gH(wCAhF2}s* zieJvxcD_#ROqMfCIO)&5alB1`cN_-K>u6RNG(AV_IVyT2T^4Np#plv5CLbN%8^=p} zvFlhYC-T;>v44zx3$$K`u29z}cCL=)kANlI7UR8O?T-tm%46fLehJ@=oVJU0VdGiz zp0!%iH>vZo;H3X0EON&hu*eJF#_yd9pB?A3;vsnW<<3vAhGH(1`AcxqoMts=ar2p;RT;oYB%9Y{2+LmA665NZJYND{PX_iF6obh)}A(rpQX-jdb(9wTX~CD$LUXm#dpF#6}I_Ey$8+Jx~Qy5@EFj_yel4QRIikvX(hdJx!g@oc#=Sfx1v#q~@t-s*BaLSQTEP;?-l?8~30yvXacWVc8Icz&ioA z;_aF#>er%bEy_$wkq!JEUZpOZ8})KK>dG6~xpH3T*}yK;b{nG__}h18+%dOUlGRpY zROnY4RK>cdTW533B+HX4S2Ge}ic{BIH)Fbr?KZ2Ev6HGxzMHR?K2sc|nnX((@Ml)d))J+a*m3nT|m^Pnj%z6Q*aqIa`<4PN;GjxNI#ah-4 zz3Fb49wlWwNh)1@vEU@}NiS-p(^{G4RNV4ZJJ6iK3u~n)Q>+wxW7gsSmA+!0G0rlb z@6q=Xyd!eHDLmb$jND>5J330=Psn{2-XVC)erIIlw~e!{+rB>)PEt?YPvAqIC+;VV zAD+0Mh}%Pa@9@O^gc&WKxSufX;)(kS(;jY~&3cR(JzFbe+-lXUa1iqkGk6)!@NSvG zEvR=Scq3kEMz6<<%RYJVc8*hpEwH8vgB`wHS>%wHU zG|7?Whe{_oxsvCyW4J8I)2{1IassdHk9ipvJC`N-Ri7Q)i_~b839DvlqE^HqV=3}B zwkWmU8;8V@ePVqysvUoSOz(2VI|FgZ)ZrWBP|0V_txNFwB!|Cb@+iSgNgjn7!#{6G z^0cxmV@}SmPvF8rZ-3p%KA1_3^Q&vth&;+-jw9#i-E2+ zc4fEJ`9|)BdN@v+3A~beX(LzNQRjrET2NK5s)zHnGQQte50`g@kq7IU(vC)1Omn2Z zm_C=URn-@TSE-f7)G@bI%+rq8;;1iKK5On#^;-#vdD<~QtA|W2Tpsrti7coeNh?5m zCO7KxcW~&yI( zw;Fg}5UBrb;DxmLN@iD3#690^h%=Mfe>89#&NymOv6Sjczc8K0v?s~lHD4?gXbu%G z)E%X%&NC%_YCT-56bnU~x?IE2u1(6iu359L^rDSX{wlYU=afJ#Y$n`8Yw=6o27S)b zGpJO1g1gSoBX`B@jdeN0S(D&QrCi%Pw7z%Xvc=kPW}>oJ=G;SW0cqkg@TgTnX>zqt z{IAq`fjW&4otjsPm(JS@4Svj}F6vruG zi}CSb3;h5BD$~o=BF{#d zL`Sd%54uz%4*#?bWp>tzEICXq+zZ!GpP5z`Ic@yBa7bUR>dIGJ#D`u~W347Lt8`iQ zkz{#y74xj7bZNtBWziAS%DSRS<~&>8%nX6Zq^G!LRhyzS9v8C4^e-9f3T551`mwE= zq0Iy%w6(QyXqPtTPHZ%3KAiAkG#YrE_t7@plK3z7Q%2fr*3GdF{*W!35!I5O`l`v7 zL7XX*PQA|Lr5l{|@wKzX=wb!8t4EMEYn2b6tK^5o-$(DzLz?<0cxE22QBQI_m)HI0 z?Ab$6smHBGv>^r+-3!kX-hl7#s8##odhe}70e$@MbMANuyWkG0O}QgJuPz9-cjHOJrH#x)z3b~bis`S^row50%kM!#P46t z1M4>p42W{}Z;a4-Hnn>>*?Ot=u-h^71+$T}pgmmR6u3F?@=k|L)lPeU;fov=61AXG ztc*DAVJkD)mM&%q^K1&;5wF{UciB>5wukbc{IL8JAL5E4A8lkk0DfpIXm*@WoJWMI2d-NP%h($-N@-Dt$Ip~KW1FMmoC_#)1p3SOpdCI|iY zR;+iBNltWWo@1t1U2(~jI&z^((eP+*T+DG7VbkgGNfYW=oi95dDRG>w>Vr;};l&#_ zthc^P*vw8R?DR^7&K!+nN7?Hd@9N5GeLcqabQAsb$Ry)rJ!;F7s@D#&ougisg3mf_ z7tK(*h3uE*#-=m3D=#WlijEq3_%9zS8A@4cJ5`#3magl-lP_G_<-~&87WS03Y-W9H zl1K|obRDT{T};!Nr1U0L3a?1j+p>r)OlhTB-g8{c45DJLR&oPrALdlT*)^*DM=^AZ z*BzK6Dj8dHF71nxI^<1*p(LRxAN_@+1W~Wn*UDLn<`<|sme3IcQCOp|g&{Y2rXo~o z{Ey1V56yK`2u(TJRtx_hkT;xBC7u(5L$3wzyqT?pS) z2`OZ5r-oAFOP6SOl-(Vklj>poK!tQ0oGSK9E=e4}ZYcdwSA8My%Vrei)QnDas`x~{ zqPDKbHX(|k$K*c7EvdO23#-U;hIS8Lt*gY=T{_)Kn+vtpBnU6z>6RjKUZ zl^WeSw!J&(E_WBYd%6cISFew{`?`yMx7QtZk9SWf+1YiWJXXiJZ*uCd=+mHhIH1$B zgpiois8@#;Tr|mB@y(gpdjkE*b}&u1l!Xm+3)9DLvSyolOkisXk{5EGFalk@jVbm&qzQ zrRWyj)*iNLS?O4kgtBWgudUNzO-VO1@tW7J127u&i(f(~q1yJ7lgp($^V!x$J&CC= zp^W^7q`1~eHr|dJvPg;>_yDDc-Ci>Z>(#$;N3mKJeR^auO0!H zPHBG9eClsy)YIXABb+aWIS#}*;?sVdDyKdjiu+SN8S_-77>;6z>8{FY?_av4=Fp1R ziiR@7ivq*AFB&hq|& z74`JXsq+;Mf|r$XL3=KhYR}<}_Gxybm!2a#m~yr>!QLUIw=*VS?C2jL2l25MWSJpt zsXty{8@r_(bvw_mOdRbiFvSID@ai!>TZrQv!5nfW>vU(^HURvJL zmyBOpc4k&AdX~t-LDWi%h}}}JkM?D{|8H39IPEXc}e!n4ADhdzPxusA8nXl?ejjH6Jxi`*Rm|HPtv5Aiq{8XGX&D?@H$miar3MKwHsP~ zQz}xP3i)jer zb=NY38UCD#H~mg_14)_QHT}aIXyaqtcgsTymP5HjI^CbWJQs6$wpV&=i?fg!tY_Vt zjXGic)5|Rg>sq@l<3wCmSK&k@a>p0xlNvp8u#Dt-gMosL_kwgfy}%kAr(YK@%cM}E zfcsiDGQ7X+xCJ?tTE3hFGWNvsz4iFA9B?tnwGrF4$QfZ3th;2KAybGRuNv}^^ZM!e z#Ov=V|7rhD8`oIA*!)>mvk$GAbEqBOgw9ijSdo#Zo%1qtz$ueuw-e_-EF-nNO2CT1 z5nnnaw!S#sbY`q_IG>vuwL}l6Ud6mK;n(DRfg2cB=?-4GLguMB|Ec0}roiop-pcos z^J14aWBsaiGR!H98_RKxs}E|soi%dDt`*qgPfOpJZbtsPna%W}DCuK`C^lFubfdmg z*&}G-GSu%ms2w@ zDCTtI66PWfaXDRu%^@1QK-$nQv$WW_Vbf3#wPtZ+KBuzpWa-YNzUQ>OWOIHR@|jep1Bv%9`*Y_NNZ|L56#ay@5aw_SHxEPg&yyJY<)`+lpVF@0>$Nyd{b z?^}7yN_NVK$CI{8+hjIt>uO65DPrCX`!>b*dV45vGHeg!Wg)?673qUf zSz53P(PNyQiREBI-$!x|C-e0}tyb$gUIasBn$%aJxYPtNjoiX33t)Dt%KOnXk4UR>Ug`c(Py%AfW^7-#htlHZWe$FrBT zfqEwOMNk6+C zH_AzPO?(Adq;1Q}L~aRW0WU`%9Dw*f7tUVQ)T8yQq^qBsw})HV>)0c6PEi7nccnOr zb=*9g9c~ca5<28ff3K1w8`JP?6>N=(lk3a-((TxO=)VTkLrr`i?eHdNB$uD4lr~_` z3dFua89ek@R8P-2rdf<9W&fC*=&967O2+2Syf@ZKfTLjjq`WW}q~#T2`6o*8wGQi- zeKo^`6R#K;G2{v*-aAV3dU-yZ7H_A`>wA|M+!C)kk&c_z+-N%FMT!jXLyzFfFpkvu z%t$}VAzxiU-jzu0%&ArDH}>~zSg(ez%dFopII!u;{`GpzEoE^4>0NRHC0O=y`o=fD z?a)^tC0`eH`%WTxUfLE*v~{}#xQf5`hTaFB#R1?$&~w2*0KNl#9Q=zOrM?d>$BFj< zk3b&+x2#p_S0WFd%Te6p&`z!$7n>KteX{MHRhJqvn2_+>1D7eVg>e+O6s zeH^@I6YUFn5WI$WkJbncehe6ZR=j2R04MOn(1*dj*YdaSA_M;H7S1lAC&A+kED`h` z@Fjn*)D6&G;HC_3@>oKeT)w-~fH`gV6FlfX;yL_d&~d1+E1?3%w2e zKH$sHhr#b;26;&2!CwHr11;Ybn8mjQz7H+m6!`v2sTXMZZom~cP%qH(J%O8n$D!rB z0uKT$$4Lu*^UJ9hX!*uK*DI(O=#}8#0`sBg?%{l7FLeaH4gBpJsUv9lroq!*MIAvq z;A>w^9f=IM^R?6w^h)q6-bfum?*mugM7==o2Y(JILCd!fGH=1x(DDt1Yj38Gpyj&> zXWv2{LCZH4e*KTs5wv_Wp$E7HTE3U?6X14e`Q}3NZTMN_!7siOKZ^|bBm40!^kMMj zci~&%gC7OH3@zVn2!My64&qzrZQw_NUqSQot9tgk z@GW!~c-_14?az?`AA2vpg_dtby!jB{G7|m=C;~75y&oKY5Pw4N0p9{F5dzVG3ZI~tq2!0pg0!LI=B7a8#HfUVH#le~ot+_Hv+@Z@=cR30uE)F z1b^XE^gHOI;NJrs(CRRC4s3-!44wq?A`kv=pagv!JnPfg06iD{;Uly|kq3VRSOk3( z{3x(Q*!_afTgl)hi^kML~fTJP37 literal 0 HcmV?d00001 diff --git a/dest/include/librz/rz_agraph.h b/dest/include/librz/rz_agraph.h new file mode 100644 index 00000000000..7d168e00a69 --- /dev/null +++ b/dest/include/librz/rz_agraph.h @@ -0,0 +1,117 @@ +#ifndef RZ_AGRAPH_H +#define RZ_AGRAPH_H + +#include +#include +#include +#include + +typedef struct rz_ascii_node_t { + RzGraphNode *gnode; + char *title; + char *body; + + int x; + int y; + int w; + int h; + + int layer; + int layer_height; + int layer_width; + int pos_in_layer; + int is_dummy; + int is_reversed; + int klass; + ut32 shortcut_w; + bool is_mini; + ut64 offset; +} RzANode; + +typedef struct rz_core_graph_hits_t { + char *old_word; + RzVector /**/ word_list; + int word_nth; +} RzAGraphHits; + +#define RZ_AGRAPH_MODE_NORMAL 0 +#define RZ_AGRAPH_MODE_OFFSET 1 +#define RZ_AGRAPH_MODE_MINI 2 +#define RZ_AGRAPH_MODE_SUMMARY 3 +#define RZ_AGRAPH_MODE_COMMENTS 4 +#define RZ_AGRAPH_MODE_MAX 5 + +typedef void (*RzANodeCallback)(RzANode *n, void *user); +typedef void (*RAEdgeCallback)(RzANode *from, RzANode *to, void *user); + +typedef struct rz_ascii_graph_t { + RzConsCanvas *can; + RzGraph /**/ *graph; + const RzGraphNode *curnode; + char *title; + Sdb *db; + HtSP *nodes; // HT with title(key)=RzANode*(value) + RzList /**/ *dummy_nodes; + + int layout; + int is_instep; + bool is_dis; + int edgemode; + int mode; + bool is_callgraph; + bool is_il; + bool is_interactive; + int zoom; + int movspeed; + bool hints; + + RzANode *update_seek_on; + bool need_reload_nodes; + bool need_set_layout; + int need_update_dim; + int force_update_seek; + + /* events */ + RzANodeCallback on_curnode_change; + void *on_curnode_change_data; + bool dummy; // enable the dummy nodes for better layouting + bool show_node_titles; + bool show_node_body; + + int x, y; + int w, h; + + /* layout algorithm info */ + RzList /**/ *back_edges; + RzList /**/ *long_edges; + struct layer_t *layers; + unsigned int n_layers; + RzList /**/ *dists; + RzList /**/ *edges; + RzAGraphHits ghits; +} RzAGraph; + +#ifdef RZ_API +RZ_API RzAGraph *rz_agraph_new(RzConsCanvas *can); +RZ_API void rz_agraph_free(RzAGraph *g); +RZ_API void rz_agraph_reset(RzAGraph *g); +RZ_API void rz_agraph_set_title(RzAGraph *g, const char *title); +RZ_API RzANode *rz_agraph_get_first_node(const RzAGraph *g); +RZ_API RzANode *rz_agraph_get_node(const RzAGraph *g, const char *title); +RZ_API RzANode *rz_agraph_add_node(const RzAGraph *g, const char *title, const char *body); +RZ_API RZ_BORROW RzANode *rz_agraph_add_node_from_node_info(RZ_NONNULL const RzAGraph *g, RZ_NONNULL const RzGraphNodeInfo *info, bool utf8); +RZ_API bool rz_agraph_del_node(const RzAGraph *g, const char *title); +RZ_API void rz_agraph_add_edge(const RzAGraph *g, RzANode *a, RzANode *b); +RZ_API void rz_agraph_add_edge_at(const RzAGraph *g, RzANode *a, RzANode *b, int nth); +RZ_API void rz_agraph_del_edge(const RzAGraph *g, RzANode *a, RzANode *b); +RZ_API void rz_agraph_print(RzAGraph *g); +RZ_API void rz_agraph_print_json(RzAGraph *g, PJ *pj); +RZ_API Sdb *rz_agraph_get_sdb(RzAGraph *g); +RZ_API void rz_agraph_foreach(RzAGraph *g, RzANodeCallback cb, void *user); +RZ_API void rz_agraph_foreach_edge(RzAGraph *g, RAEdgeCallback cb, void *user); +RZ_API void rz_agraph_set_curnode(RzAGraph *g, RzANode *node); +RZ_API bool create_agraph_from_graph_at(RZ_NONNULL RzAGraph *ag, RZ_NONNULL const RzGraph /**/ *g, bool free_on_fail, bool utf8); +RZ_API RZ_OWN RzAGraph *create_agraph_from_graph(RZ_NONNULL const RzGraph /**/ *graph, bool utf8); +#endif + +#endif diff --git a/dest/include/librz/rz_analysis.h b/dest/include/librz/rz_analysis.h new file mode 100644 index 00000000000..638bd875d50 --- /dev/null +++ b/dest/include/librz/rz_analysis.h @@ -0,0 +1,2494 @@ +// SPDX-FileCopyrightText: 2009-2021 nibble +// SPDX-FileCopyrightText: 2009-2021 pancake +// SPDX-FileCopyrightText: 2009-2021 xvilka +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_ANALYSIS_H +#define RZ_ANALYSIS_H + +/* use old refs and function storage */ +// still required by core in lot of places +#define USE_VARSUBS 0 + +#define RZ_ANALYSIS_OP_INVALID_STACKPTR 0 +#define RZ_ANALYSIS_OP_MASK_WILDCARD 0xfffff + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define esilprintf(op, fmt, ...) rz_strbuf_setf(&op->esil, fmt, ##__VA_ARGS__) + +#ifdef __cplusplus +extern "C" { +#endif + +// TODO: save memory2 : fingerprints must be pointers to a buffer +// containing a dupped file in memory + +/* save memory: + bb_has_ops=1 -> 600M + bb_has_ops=0 -> 350MB + */ + +typedef struct { + struct rz_analysis_t *analysis; + int type; + int rad; + SdbForeachCallback cb; + void *user; + int count; + struct rz_analysis_function_t *fcn; + PJ *pj; +} RzAnalysisMetaUserItem; + +typedef struct rz_analysis_range_t { + ut64 from; + ut64 to; + int bits; + ut64 rb_max_addr; + RBNode rb; +} RzAnalysisRange; + +typedef enum { + RZ_ANALYSIS_DATA_INFO_TYPE_NULL = 0, + RZ_ANALYSIS_DATA_INFO_TYPE_UNKNOWN = 1, + RZ_ANALYSIS_DATA_INFO_TYPE_STRING = 2, + RZ_ANALYSIS_DATA_INFO_TYPE_POINTER = 3, + RZ_ANALYSIS_DATA_INFO_TYPE_NUMBER = 4, + RZ_ANALYSIS_DATA_INFO_TYPE_INVALID = 5, + RZ_ANALYSIS_DATA_INFO_TYPE_HEADER = 6, + RZ_ANALYSIS_DATA_INFO_TYPE_SEQUENCE = 7, + RZ_ANALYSIS_DATA_INFO_TYPE_PATTERN = 8, +} RzAnalysisDataInfoType; + +// used from core/analysis.c +#define RZ_ANALYSIS_ADDR_TYPE_EXEC 1 +#define RZ_ANALYSIS_ADDR_TYPE_READ 1 << 1 +#define RZ_ANALYSIS_ADDR_TYPE_WRITE 1 << 2 +#define RZ_ANALYSIS_ADDR_TYPE_FLAG 1 << 3 +#define RZ_ANALYSIS_ADDR_TYPE_FUNC 1 << 4 +#define RZ_ANALYSIS_ADDR_TYPE_HEAP 1 << 5 +#define RZ_ANALYSIS_ADDR_TYPE_STACK 1 << 6 +#define RZ_ANALYSIS_ADDR_TYPE_REG 1 << 7 +#define RZ_ANALYSIS_ADDR_TYPE_PROGRAM 1 << 8 +#define RZ_ANALYSIS_ADDR_TYPE_LIBRARY 1 << 9 +#define RZ_ANALYSIS_ADDR_TYPE_ASCII 1 << 10 +#define RZ_ANALYSIS_ADDR_TYPE_SEQUENCE 1 << 11 + +typedef enum rz_analysis_arch_info_type_t { + RZ_ANALYSIS_ARCHINFO_MIN_OP_SIZE = 0, ///< Min opcode size + RZ_ANALYSIS_ARCHINFO_MAX_OP_SIZE, ///< Max opcode size + RZ_ANALYSIS_ARCHINFO_TEXT_ALIGN, ///< Opcode memory alignment + RZ_ANALYSIS_ARCHINFO_DATA_ALIGN, ///< Data memory alignment + RZ_ANALYSIS_ARCHINFO_CAN_USE_POINTERS, ///< Defines if the architecture has the concept of memory pointers + /* The value below is used for runtime checks */ + RZ_ANALYSIS_ARCHINFO_ENUM_SIZE, +} RzAnalysisInfoType; + +/* copypaste from rz_asm.h */ + +#define RZ_ANALYSIS_GET_OFFSET(x, y, z) \ + (x && x->binb.bin && x->binb.get_offset) ? x->binb.get_offset(x->binb.bin, y, z) : -1 + +#define RZ_ANALYSIS_GET_NAME(x, y, z) \ + (x && x->binb.bin && x->binb.get_name) ? x->binb.get_name(x->binb.bin, y, z) : NULL + +enum { + RZ_ANALYSIS_FQUALIFIER_NONE = 0, + RZ_ANALYSIS_FQUALIFIER_STATIC = 1, + RZ_ANALYSIS_FQUALIFIER_VOLATILE = 2, + RZ_ANALYSIS_FQUALIFIER_INLINE = 3, + RZ_ANALYSIS_FQUALIFIER_NAKED = 4, + RZ_ANALYSIS_FQUALIFIER_VIRTUAL = 5, +}; + +#define RZ_ANALYSIS_CC_MAXARG 16 + +typedef enum { + RZ_ANALYSIS_FCN_TYPE_NULL = 0, + RZ_ANALYSIS_FCN_TYPE_FCN = 1 << 0, + RZ_ANALYSIS_FCN_TYPE_LOC = 1 << 1, + RZ_ANALYSIS_FCN_TYPE_SYM = 1 << 2, + RZ_ANALYSIS_FCN_TYPE_IMP = 1 << 3, + RZ_ANALYSIS_FCN_TYPE_INT = 1 << 4, /* privileged function - ends with iret/reti/.. */ + RZ_ANALYSIS_FCN_TYPE_ROOT = 1 << 5, /* matching flag */ + RZ_ANALYSIS_FCN_TYPE_ANY = -1 /* all the bits set */ +} RzAnalysisFcnType; + +typedef struct rz_analysis_attr_t { + char *key; + long value; + struct rz_analysis_attr_t *next; +} RzAnalysisAttr; + +/* Stores useful function metadata */ +/* TODO: Think about moving more stuff to this structure? */ +typedef struct rz_analysis_fcn_meta_t { + // _min and _max are calculated lazily when queried. + // On changes, they will either be updated (if this can be done trivially) or invalidated. + // They are invalid iff _min == UT64_MAX. + ut64 _min; // PRIVATE, min address, use rz_analysis_function_min_addr() to access + ut64 _max; // PRIVATE, max address, use rz_analysis_function_max_addr() to access + + int numrefs; // number of cross references + int numcallrefs; // number of calls +} RzAnalysisFcnMeta; + +typedef struct rz_analysis_function_t { + char *name; + int bits; // ((> bits 0) (set-bits bits)) + int type; + const char *cc; // calling convention, should come from RzAnalysis.constpool + ut64 addr; + HtUP /**/ *labels; + HtSP /**/ *label_addrs; + RzPVector /**/ vars; + RzType *ret_type; + /** + * \brief Maps the function's instruction to the variables they use. + * key: Instruction offset from function entry point. + * value: Vector of variables the instruction accesses. + */ + HtUP /*>*/ *inst_vars; + st64 bp_off; // offset of bp inside owned stack frame + RZ_DEPRECATE st64 stack; // stack frame size + int maxstack; + int ninstr; + bool is_pure : 1; + bool is_variadic : 1; + bool has_changed : 1; // true if function may have changed since last anaysis TODO: set this attribute where necessary + bool has_debuginfo : 1; ///< true if function has debug informations + bool bp_frame : 1; + bool is_noreturn : 1; // true if function does not return + int argnum; // number of arguments; + RzPVector /**/ *bbs; + RzAnalysisFcnMeta meta; + RzList /**/ *imports; // maybe bound to class? + struct rz_analysis_t *analysis; // this function is associated with this instance +} RzAnalysisFunction; + +typedef struct rz_analysis_func_arg_t { + const char *name; + char *fmt; + const char *cc_source; + RzType *orig_c_type; + RzType *c_type; + ut64 size; + ut64 src; // Function-call argument value or pointer to it +} RzAnalysisFuncArg; + +typedef enum { + RZ_META_TYPE_NONE = 0, + RZ_META_TYPE_ANY = -1, + RZ_META_TYPE_DATA = 'd', //< marks the data as data (not a code) + RZ_META_TYPE_CODE = 'c', //< marks the data as code + RZ_META_TYPE_STRING = 's', //< marks the data as string + RZ_META_TYPE_FORMAT = 'f', //< sets the specified format (pf) to the data + RZ_META_TYPE_MAGIC = 'm', //< sets the magic string to the data + RZ_META_TYPE_HIDE = 'h', //< set the data as hidden + RZ_META_TYPE_COMMENT = 'C', //< attaches the comment to the data + RZ_META_TYPE_HIGHLIGHT = 'H', //< sets the specified highlight to the data + RZ_META_TYPE_VARTYPE = 't', //< sets the specified type to the variable/address +} RzAnalysisMetaType; + +/* meta */ +typedef struct rz_analysis_meta_item_t { + RzAnalysisMetaType type; + int subtype; + char *str; + size_t size; + const RzSpace *space; +} RzAnalysisMetaItem; + +// anal +typedef enum { + RZ_ANALYSIS_OP_FAMILY_UNKNOWN = -1, + RZ_ANALYSIS_OP_FAMILY_CPU = 0, /* normal cpu instruction */ + RZ_ANALYSIS_OP_FAMILY_FPU, /* fpu (floating point) */ + RZ_ANALYSIS_OP_FAMILY_MMX, /* multimedia instruction (packed data) */ + RZ_ANALYSIS_OP_FAMILY_SSE, /* extended multimedia instruction (packed data) */ + RZ_ANALYSIS_OP_FAMILY_PRIV, /* privileged instruction */ + RZ_ANALYSIS_OP_FAMILY_CRYPTO, /* cryptographic instructions */ + RZ_ANALYSIS_OP_FAMILY_THREAD, /* thread/lock/sync instructions */ + RZ_ANALYSIS_OP_FAMILY_VIRT, /* virtualization instructions */ + RZ_ANALYSIS_OP_FAMILY_SECURITY, /* security instructions */ + RZ_ANALYSIS_OP_FAMILY_IO, /* IO instructions (i.e. IN/OUT) */ + RZ_ANALYSIS_OP_FAMILY_LAST +} RzAnalysisOpFamily; + +#if 0 +On x86 according to Wikipedia + + Prefix group 1 + 0xF0: LOCK prefix + 0xF2: REPNE/REPNZ prefix + 0xF3: REP or REPE/REPZ prefix + Prefix group 2 + 0x2E: CS segment override + 0x36: SS segment override + 0x3E: DS segment override + 0x26: ES segment override + 0x64: FS segment override + 0x65: GS segment override + 0x2E: Branch not taken (hinting) + 0x3E: Branch taken + Prefix group 3 + 0x66: Operand-size override prefix + Prefix group 4 + 0x67: Address-size override prefix +#endif +typedef enum { + RZ_ANALYSIS_OP_PREFIX_COND = 1, + RZ_ANALYSIS_OP_PREFIX_REP = 1 << 1, + RZ_ANALYSIS_OP_PREFIX_REPNE = 1 << 2, + RZ_ANALYSIS_OP_PREFIX_LOCK = 1 << 3, + RZ_ANALYSIS_OP_PREFIX_LIKELY = 1 << 4, + RZ_ANALYSIS_OP_PREFIX_UNLIKELY = 1 << 5, + RZ_ANALYSIS_OP_PREFIX_HWLOOP_END = 1 << 6, /* Hexagon specific. Last instruction in a hardware loop */ + /* TODO: add segment override typemods? */ +} RzAnalysisOpPrefix; + +// XXX: this definition is plain wrong. use enum or empower bits +#define RZ_ANALYSIS_OP_TYPE_MASK 0x8000ffff +#define RZ_ANALYSIS_OP_HINT_MASK 0xff000000 +typedef enum { + RZ_ANALYSIS_OP_TYPE_COND = 0x80000000, // TODO must be moved to prefix? + // TODO: MOVE TO PREFIX .. it is used by analysis_java.. must be updated + RZ_ANALYSIS_OP_TYPE_REP = 0x40000000, /* repeats next instruction N times */ + RZ_ANALYSIS_OP_TYPE_MEM = 0x20000000, // TODO must be moved to prefix? + RZ_ANALYSIS_OP_TYPE_REG = 0x10000000, // operand is a register + RZ_ANALYSIS_OP_TYPE_IND = 0x08000000, // operand is indirect + RZ_ANALYSIS_OP_TYPE_SIMD = 0x04000000, // SIMD + RZ_ANALYSIS_OP_TYPE_TAIL = 0x02000000, ///< Part of a tail call. This effectively marks the end of a sub-routine. + RZ_ANALYSIS_OP_TYPE_NULL = 0, + RZ_ANALYSIS_OP_TYPE_JMP = 1, /* mandatory jump */ + RZ_ANALYSIS_OP_TYPE_UJMP = 2, /* unknown jump (register or so) */ + RZ_ANALYSIS_OP_TYPE_RJMP = RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_UJMP, + RZ_ANALYSIS_OP_TYPE_IJMP = RZ_ANALYSIS_OP_TYPE_IND | RZ_ANALYSIS_OP_TYPE_UJMP, + RZ_ANALYSIS_OP_TYPE_IRJMP = RZ_ANALYSIS_OP_TYPE_IND | RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_UJMP, + RZ_ANALYSIS_OP_TYPE_CJMP = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_JMP, /* conditional jump */ + RZ_ANALYSIS_OP_TYPE_RCJMP = RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_CJMP, /* conditional jump register */ + RZ_ANALYSIS_OP_TYPE_MJMP = RZ_ANALYSIS_OP_TYPE_MEM | RZ_ANALYSIS_OP_TYPE_JMP, /* memory jump */ + RZ_ANALYSIS_OP_TYPE_MCJMP = RZ_ANALYSIS_OP_TYPE_MEM | RZ_ANALYSIS_OP_TYPE_CJMP, /* memory conditional jump */ + RZ_ANALYSIS_OP_TYPE_UCJMP = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_UJMP, /* conditional unknown jump */ + RZ_ANALYSIS_OP_TYPE_CALL = 3, /* call to subroutine (branch+link) */ + RZ_ANALYSIS_OP_TYPE_UCALL = 4, /* unknown call (register or so) */ + RZ_ANALYSIS_OP_TYPE_RCALL = RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_UCALL, + RZ_ANALYSIS_OP_TYPE_ICALL = RZ_ANALYSIS_OP_TYPE_IND | RZ_ANALYSIS_OP_TYPE_UCALL, + RZ_ANALYSIS_OP_TYPE_IRCALL = RZ_ANALYSIS_OP_TYPE_IND | RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_UCALL, + RZ_ANALYSIS_OP_TYPE_CCALL = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_CALL, /* conditional call to subroutine */ + RZ_ANALYSIS_OP_TYPE_UCCALL = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_UCALL, /* conditional unknown call */ + RZ_ANALYSIS_OP_TYPE_RET = 5, /* returns from subroutine */ + RZ_ANALYSIS_OP_TYPE_CRET = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_RET, /* conditional return from subroutine */ + RZ_ANALYSIS_OP_TYPE_ILL = 6, /* illegal instruction // trap */ + RZ_ANALYSIS_OP_TYPE_UNK = 7, /* unknown opcode type */ + RZ_ANALYSIS_OP_TYPE_NOP = 8, /* does nothing */ + RZ_ANALYSIS_OP_TYPE_MOV = 9, /* register move */ + RZ_ANALYSIS_OP_TYPE_CMOV = RZ_ANALYSIS_OP_TYPE_MOV | RZ_ANALYSIS_OP_TYPE_COND, /* conditional move */ + RZ_ANALYSIS_OP_TYPE_TRAP = 10, /* it's a trap! */ + RZ_ANALYSIS_OP_TYPE_SWI = 11, /* syscall, software interrupt */ + RZ_ANALYSIS_OP_TYPE_CSWI = RZ_ANALYSIS_OP_TYPE_SWI | RZ_ANALYSIS_OP_TYPE_COND, /* syscall, software interrupt */ + RZ_ANALYSIS_OP_TYPE_UPUSH = 12, /* unknown push of data into stack */ + RZ_ANALYSIS_OP_TYPE_RPUSH = RZ_ANALYSIS_OP_TYPE_UPUSH | RZ_ANALYSIS_OP_TYPE_REG, /* push register */ + RZ_ANALYSIS_OP_TYPE_PUSH = 13, /* push value into stack */ + RZ_ANALYSIS_OP_TYPE_POP = 14, /* pop value from stack to register */ + RZ_ANALYSIS_OP_TYPE_CMP = 15, /* compare something */ + RZ_ANALYSIS_OP_TYPE_ACMP = 16, /* compare via and */ + RZ_ANALYSIS_OP_TYPE_ADD = 17, + RZ_ANALYSIS_OP_TYPE_SUB = 18, + RZ_ANALYSIS_OP_TYPE_IO = 19, + RZ_ANALYSIS_OP_TYPE_MUL = 20, + RZ_ANALYSIS_OP_TYPE_DIV = 21, + RZ_ANALYSIS_OP_TYPE_SHR = 22, + RZ_ANALYSIS_OP_TYPE_SHL = 23, + RZ_ANALYSIS_OP_TYPE_SAL = 24, + RZ_ANALYSIS_OP_TYPE_SAR = 25, + RZ_ANALYSIS_OP_TYPE_OR = 26, + RZ_ANALYSIS_OP_TYPE_AND = 27, + RZ_ANALYSIS_OP_TYPE_XOR = 28, + RZ_ANALYSIS_OP_TYPE_NOR = 29, + RZ_ANALYSIS_OP_TYPE_NOT = 30, + RZ_ANALYSIS_OP_TYPE_STORE = 31, /* store from register to memory */ + RZ_ANALYSIS_OP_TYPE_LOAD = 32, /* load from memory to register */ + RZ_ANALYSIS_OP_TYPE_LEA = 33, /* TODO add ulea */ + RZ_ANALYSIS_OP_TYPE_LEAVE = 34, + RZ_ANALYSIS_OP_TYPE_ROR = 35, + RZ_ANALYSIS_OP_TYPE_ROL = 36, + RZ_ANALYSIS_OP_TYPE_XCHG = 37, + RZ_ANALYSIS_OP_TYPE_MOD = 38, + RZ_ANALYSIS_OP_TYPE_SWITCH = 39, + RZ_ANALYSIS_OP_TYPE_CASE = 40, + RZ_ANALYSIS_OP_TYPE_LENGTH = 41, + RZ_ANALYSIS_OP_TYPE_CAST = 42, + RZ_ANALYSIS_OP_TYPE_NEW = 43, + RZ_ANALYSIS_OP_TYPE_ABS = 44, + RZ_ANALYSIS_OP_TYPE_CPL = 45, /* complement */ + RZ_ANALYSIS_OP_TYPE_CRYPTO = 46, + RZ_ANALYSIS_OP_TYPE_SYNC = 47, +// RZ_ANALYSIS_OP_TYPE_DEBUG = 43, // monitor/trace/breakpoint +#if 0 + RZ_ANALYSIS_OP_TYPE_PRIV = 40, /* privileged instruction */ + RZ_ANALYSIS_OP_TYPE_FPU = 41, /* floating point stuff */ +#endif +} _RzAnalysisOpType; + +typedef enum { + RZ_ANALYSIS_OP_MASK_BASIC = 0, // Just fills basic op info , it's fast + RZ_ANALYSIS_OP_MASK_ESIL = (1 << 0), // It fills RzAnalysisop->esil info + RZ_ANALYSIS_OP_MASK_VAL = (1 << 1), // It fills RzAnalysisop->dst/src info + RZ_ANALYSIS_OP_MASK_HINT = (1 << 2), // It calls rz_analysis_op_hint to override analysis options + RZ_ANALYSIS_OP_MASK_OPEX = (1 << 3), // It fills RzAnalysisop->opex info + RZ_ANALYSIS_OP_MASK_DISASM = (1 << 4), // It fills RzAnalysisop->mnemonic // should be RzAnalysisOp->disasm // only from rz_core_analysis_op() + RZ_ANALYSIS_OP_MASK_IL = (1 << 5), // It fills RzAnalysisop->il_op + RZ_ANALYSIS_OP_MASK_ALL = RZ_ANALYSIS_OP_MASK_ESIL | RZ_ANALYSIS_OP_MASK_VAL | RZ_ANALYSIS_OP_MASK_HINT | RZ_ANALYSIS_OP_MASK_OPEX | RZ_ANALYSIS_OP_MASK_DISASM | RZ_ANALYSIS_OP_MASK_IL +} RzAnalysisOpMask; + +typedef enum { + RZ_ANALYSIS_STACK_NULL = 0, + RZ_ANALYSIS_STACK_NOP, + RZ_ANALYSIS_STACK_INC, + RZ_ANALYSIS_STACK_DEC, + RZ_ANALYSIS_STACK_GET, + RZ_ANALYSIS_STACK_SET, + RZ_ANALYSIS_STACK_RESET, + RZ_ANALYSIS_STACK_ALIGN, +} RzAnalysisStackOp; + +enum { + RZ_ANALYSIS_REFLINE_TYPE_UTF8 = 1, + RZ_ANALYSIS_REFLINE_TYPE_WIDE = 2, /* reflines have a space between them */ + RZ_ANALYSIS_REFLINE_TYPE_MIDDLE_BEFORE = 4, /* do not consider starts/ends of + * reflines (used for comment lines before disasm) */ + RZ_ANALYSIS_REFLINE_TYPE_MIDDLE_AFTER = 8 /* as above but for lines after disasm */ +}; + +typedef enum { + RZ_ANALYSIS_RET_NOP = 0, + RZ_ANALYSIS_RET_ERROR = -1, // Basic block ended because of analysis error. + RZ_ANALYSIS_RET_END = -4, // Basic block ended because of return instruction. + RZ_ANALYSIS_RET_BRANCH = -5, // Basic block ended because of branch instruction. + RZ_ANALYSIS_RET_COND = -6, // Basic block ended because of conditional return. +} RzAnalysisBBEndCause; + +typedef struct rz_analysis_case_obj_t { + ut64 addr; + ut64 jump; + ut64 value; +} RzAnalysisCaseOp; + +typedef struct rz_analysis_switch_obj_t { + ut64 addr; + ut64 min_val; + ut64 def_val; + ut64 max_val; + RzList /**/ *cases; + RzType *enum_type; +} RzAnalysisSwitchOp; + +struct rz_analysis_t; +struct rz_analysis_bb_t; +typedef struct rz_analysis_callbacks_t { + int (*on_fcn_new)(struct rz_analysis_t *, void *user, RzAnalysisFunction *fcn); + int (*on_fcn_delete)(struct rz_analysis_t *, void *user, RzAnalysisFunction *fcn); + int (*on_fcn_rename)(struct rz_analysis_t *, void *user, RzAnalysisFunction *fcn, const char *oldname); + int (*on_fcn_bb_new)(struct rz_analysis_t *, void *user, RzAnalysisFunction *fcn, struct rz_analysis_bb_t *bb); +} RzAnalysisCallbacks; + +#define RZ_ANALYSIS_ESIL_GOTO_LIMIT 4096 + +typedef struct rz_analysis_options_t { + int depth; + int graph_depth; + bool vars; // analysisyze local var and arguments + int cjmpref; + int jmpref; + int jmpabove; + bool ijmp; + bool jmpmid; // continue analysis after jmp into middle of insn + bool loads; + bool ignbithints; + int followdatarefs; + int searchstringrefs; + int followbrokenfcnsrefs; + int bb_max_size; + int fcn_max_size; + bool trycatch; + bool norevisit; + int afterjmp; // continue analysis after jmp eax or forward jmp // option + int aftertrap; // continue analysis after trap instructions + int recont; // continue on recurse analysis mode + int noncode; + int nopskip; // skip nops at the beginning of functions + int hpskip; // skip `mov reg,reg` and `lea reg,[reg]` + int jmptbl; // analyze jump tables + int jmptbl_maxcount; // maximum amount of entries to analyse in a jump table + ut32 jmptbl_maxoffset; // maximum offset from the jump table jump instruction to consider it valid + int nonull; + bool pushret; // analyze push+ret as jmp + bool armthumb; // + bool delay; + bool retpoline; +} RzAnalysisOptions; + +typedef enum { + RZ_ANALYSIS_CPP_ABI_ITANIUM = 0, + RZ_ANALYSIS_CPP_ABI_MSVC +} RzAnalysisCPPABI; + +typedef struct rz_analysis_hint_cb_t { + // add more cbs as needed + void (*on_bits)(struct rz_analysis_t *a, ut64 addr, int bits, bool set); +} RHintCb; + +typedef struct rz_analysis_il_vm_t RzAnalysisILVM; + +typedef struct { + HtUP /**/ *function_by_offset; ///< Store all functions parsed from DWARF by DIE offset + HtUP /**/ *function_by_addr; ///< Store all functions parsed from DWARF by address (some functions may have the same address) + HtUP /**/ *variable_by_offset; ///< Store all variables parsed from DWARF by DIE offset + HtUP /**/ *callable_by_offset; ///< Store all callables parsed from DWARF by DIE offset + HtUP /**/ *type_by_offset; ///< Store all RzType parsed from DWARF by DIE offset + HtUP /**/ *base_type_by_offset; ///< Store all RzBaseType parsed from DWARF by DIE offset + HtSP /*>*/ *base_types_by_name; ///< Store all RzBaseType parsed from DWARF by DIE offset + DWARF_RegisterMapping dwarf_register_mapping; ///< Store the mapping function between DWARF registers number and register name in current architecture + RzBinDWARF *dw; ///< Holds ownership of RzBinDwarf, avoid releasing it prematurely + RzSetU *visited; +} RzAnalysisDebugInfo; + +typedef struct rz_analysis_t { + void *core; + ut8 ptr_alignment_I; + // NOTE: Do not change the order of fields above! + // They are used in pointer passing hacks in rz_types.h. + char *cpu; // analysis.cpu + char *os; // asm.os + int bits; // asm.bits + int lineswidth; // asm.lines.width + int big_endian; // cfg.bigendian + int sleep; // analysis.sleep, sleep some usecs before analyzing more (avoid 100% cpu usages) + RzAnalysisCPPABI cpp_abi; // analysis.cpp.abi + void *plugin_data; + ut64 gp; // analysis.gp, global pointer. used for mips. but can be used by other arches too in the future + RBTree bb_tree; // all basic blocks by address. They can overlap each other, but must never start at the same address. + RzList /**/ *fcns; + HtUP *ht_addr_fun; // address => function + HtSP *ht_name_fun; // name => function + RzReg *reg; + ut8 *last_disasm_reg; + RzSyscall *syscall; + RzIOBind iob; + RzFlagBind flb; + RzFlagSet flg_class_set; + RzFlagGet flg_class_get; + RzFlagSet flg_fcn_set; + RzBinBind binb; // Set only from core when an analysis plugin is called. + RzCoreBind coreb; + int maxreflines; // asm.lines.maxref + int esil_goto_limit; // esil.gotolimit + int pcalign; // asm.pcalign + struct rz_analysis_esil_t *esil; + struct rz_analysis_esil_inter_state_t *esilinterstate; + RzAnalysisILVM *il_vm; ///< user-faced VM, NEVER use this for any analysis passes! + struct rz_analysis_plugin_t *cur; + RzAnalysisRange *limit; // analysis.from, analysis.to + HtSP /**/ *plugins; + Sdb *sdb_noret; + Sdb *sdb_fmts; + HtUP *ht_xrefs_from; + HtUP *ht_xrefs_to; + bool recursive_noreturn; // analysis.rnr + // moved from RzAnalysisFcn + Sdb *sdb; // root + HtUP /*>*/ *addr_hints; // all hints that correspond to a single address + RBTree /**/ arch_hints; + RBTree /**/ bits_hints; + RHintCb hint_cbs; + RzIntervalTree meta; + RzSpaces meta_spaces; + RzTypeDB *typedb; // Types management + Sdb *sdb_cc; // calling conventions + Sdb *sdb_classes; + Sdb *sdb_classes_attrs; + RzAnalysisCallbacks cb; + RzAnalysisOptions opt; + RzPVector /**/ *reflines; + // RzList *noreturn; + RzListComparator columnSort; + bool (*log)(struct rz_analysis_t *analysis, const char *msg); + bool (*read_at)(struct rz_analysis_t *analysis, ut64 addr, ut8 *buf, int len); + int seggrn; + RzFlagGetAtAddr flag_get; + RzEvent *ev; + RzList /**/ *imports; // global imports + RzSetU *visited; + RzStrConstPool constpool; + RzList /**/ *leaddrs; + RzPlatformTarget *arch_target; + RzPlatformTargetIndex *platform_target; + HtSP *ht_global_var; // global variables + HtUP *ht_rop_semantics; ///< cache rop gadget semantic information + HtUP *ht_rop; ///< cache rop gadget address list + bool is_rop_analysis; + RBTree global_var_tree; // global variables by address. must not overlap + RzHash *hash; + RzAnalysisDebugInfo *debug_info; ///< store all debug info parsed from DWARF, etc.. + char *sdb_types_path; ///< system path prefix, whether created in initialization or passed by RzCore. + ut64 cmpval; ///< last compare value for jump table. + ut64 lea_jmptbl_ip; ///< jump table x86 lea ip + ut64 gnu_thumb1_case_uqi_addr; ///< address of a `__gnu_thumb1_case_uqi_addr` function (specific to ARM / Thumb-1) + HtSP /**/ *ht_virtual_xrefs; ///< addresses of virtual function calls +} RzAnalysis; + +typedef enum rz_analysis_addr_hint_type_t { + RZ_ANALYSIS_ADDR_HINT_TYPE_IMMBASE, + RZ_ANALYSIS_ADDR_HINT_TYPE_JUMP, + RZ_ANALYSIS_ADDR_HINT_TYPE_FAIL, + RZ_ANALYSIS_ADDR_HINT_TYPE_STACKFRAME, + RZ_ANALYSIS_ADDR_HINT_TYPE_PTR, + RZ_ANALYSIS_ADDR_HINT_TYPE_NWORD, + RZ_ANALYSIS_ADDR_HINT_TYPE_RET, + RZ_ANALYSIS_ADDR_HINT_TYPE_NEW_BITS, + RZ_ANALYSIS_ADDR_HINT_TYPE_SIZE, + RZ_ANALYSIS_ADDR_HINT_TYPE_SYNTAX, + RZ_ANALYSIS_ADDR_HINT_TYPE_OPTYPE, + RZ_ANALYSIS_ADDR_HINT_TYPE_OPCODE, + RZ_ANALYSIS_ADDR_HINT_TYPE_TYPE_OFFSET, + RZ_ANALYSIS_ADDR_HINT_TYPE_ESIL, + RZ_ANALYSIS_ADDR_HINT_TYPE_HIGH, + RZ_ANALYSIS_ADDR_HINT_TYPE_VAL +} RzAnalysisAddrHintType; + +typedef struct rz_analysis_addr_hint_record_t { + RzAnalysisAddrHintType type; + union { + char *type_offset; + int nword; + ut64 jump; + ut64 fail; + int newbits; + int immbase; + ut64 ptr; + ut64 retval; + char *syntax; + char *opcode; + char *esil; + int optype; + ut64 size; + ut64 stackframe; + ut64 val; + }; +} RzAnalysisAddrHintRecord; + +typedef struct rz_analysis_hint_t { + ut64 addr; + ut64 ptr; + ut64 val; // used to hint jmp rax + ut64 jump; + ut64 fail; + ut64 ret; // hint for function ret values + char *arch; + char *opcode; + char *syntax; + char *esil; + char *offset; + ut32 type; + ut64 size; + int bits; + int new_bits; // change asm.bits after evaluating this instruction + int immbase; + bool high; // highlight hint + int nword; + ut64 stackframe; +} RzAnalysisHint; + +typedef RzAnalysisFunction *(*RzAnalysisGetFcnIn)(RzAnalysis *analysis, ut64 addr, int type); +typedef RzAnalysisHint *(*RzAnalysisGetHint)(RzAnalysis *analysis, ut64 addr); + +typedef struct rz_analysis_bind_t { + RzAnalysis *analysis; + RzAnalysisGetFcnIn get_fcn_in; + RzAnalysisGetHint get_hint; +} RzAnalysisBind; + +typedef const char *(*RzAnalysisLabelAt)(RzAnalysisFunction *fcn, ut64); + +/** + * \brief An address on the stack + * + * These addresses are a relative offset to the value of the stack pointer + * when entering a function, i.e. just before the first instruction inside the function is executed. + * Thus, with the most common calling conventions, the return address with be at addr 0, + * arguments at positive addresses and local variables at negative addresses: + * + * For example (stack grows down): + * + * ``` + * | ... | + * | arguments | + * |-----------------| < +8 + * | return addr | + * |-----------------| < 0 + * | saved registers | + * | ... | + * |-----------------| < negative values + * | local variables | + * | ... | + * ``` + */ +typedef st64 RzStackAddr; +#define RZ_STACK_ADDR_INVALID ST32_MAX + +#define VARPREFIX "var" +#define ARGPREFIX "arg" + +typedef enum { + RZ_ANALYSIS_VAR_ACCESS_TYPE_PTR = 0, + RZ_ANALYSIS_VAR_ACCESS_TYPE_READ = (1 << 0), + RZ_ANALYSIS_VAR_ACCESS_TYPE_WRITE = (1 << 1) +} RzAnalysisVarAccessType; + +typedef struct rz_analysis_var_access_t { + st64 offset; ///< address relative to the function's entrypoint where the access happens + + /** + * Register used for access. + * For example when accessing some stack variable by `[rbp - 0x10]`, this will be "rbp" + */ + const char *reg; + + /** + * Delta added to register when the var is accessed, + * For example for `[rbp - 0x10]`, this will be -0x10. + */ + st64 reg_addend; + + ut8 type; ///< RzAnalysisVarAccessType bits +} RzAnalysisVarAccess; + +typedef enum { + RZ_ANALYSIS_VAR_STORAGE_STACK, + RZ_ANALYSIS_VAR_STORAGE_REG, + RZ_ANALYSIS_VAR_STORAGE_COMPOSITE, + RZ_ANALYSIS_VAR_STORAGE_EVAL_PENDING, +} RzAnalysisVarStorageType; + +struct rz_analysis_var_storage_t; + +typedef struct { + ut32 offset_in_bits; + ut32 size_in_bits; + struct rz_analysis_var_storage_t *storage; +} RzAnalysisVarStoragePiece; + +/** + * Describes the location whether the contents of a variable are stored + */ +typedef struct rz_analysis_var_storage_t { + RzAnalysisVarStorageType type; + union { + /** + * Used iff type == RZ_ANALYSIS_VAR_STORAGE_STACK. + * See docs of RzStackAddr for exact meaning. + */ + RzStackAddr stack_off; + + /** + * Used iff type == RZ_ANALYSIS_VAR_STORAGE_REG. + * When this storage object is part of RzAnalysisVar, this string comes from the + * respective RzAnalysis.constpool. + */ + const char *reg; + RzVector /**/ *composite; + ut64 dw_var_off; ///< DIE offset of the variable + }; +} RzAnalysisVarStorage; + +static inline void rz_analysis_var_storage_init_reg(RZ_NONNULL RzAnalysisVarStorage *stor, RZ_NONNULL const char *reg) { + rz_return_if_fail(stor && reg); + stor->type = RZ_ANALYSIS_VAR_STORAGE_REG; + stor->reg = reg; +} + +static inline void rz_analysis_var_storage_init_stack(RZ_NONNULL RzAnalysisVarStorage *stor, RzStackAddr stack_off) { + rz_return_if_fail(stor); + stor->type = RZ_ANALYSIS_VAR_STORAGE_STACK; + stor->stack_off = stack_off; +} + +RZ_API void rz_analysis_var_storage_init_composite(RzAnalysisVarStorage *sto); + +/** + * \brief Kind of a variable + */ +typedef enum rz_analysis_var_kind_t { + RZ_ANALYSIS_VAR_KIND_INVALID = 0, ///< Invalid or unspecified variable + RZ_ANALYSIS_VAR_KIND_FORMAL_PARAMETER, ///< Variable is function formal parameter + RZ_ANALYSIS_VAR_KIND_VARIABLE, ///< Variable is local variable + /* End enum */ + RZ_ANALYSIS_VAR_KIND_END ///< Number of RzAnalysisVarKind enums +} RzAnalysisVarKind; + +RZ_API ut32 rz_analysis_guessed_mem_access_width(RZ_NONNULL const RzAnalysis *analysis); + +typedef struct dwarf_variable_t { + ut64 offset; ///< DIE offset of the variable + RzBinDwarfLocation *location; ///< location description + char *name; ///< name of the variable + char *link_name; ///< link name of the variable + const char *prefer_name; ///< prefer name of the variable, reference to name or link_name depends on language + RzType *type; ///< type of the variable + RzAnalysisVarKind kind; ///< kind of the variable + ut32 cu_index; ///< compile unit index +} RzAnalysisDwarfVariable; + +typedef enum { + RZ_ANALYSIS_VAR_ORIGIN_NONE = 0, ///< Variable was created from rizin + RZ_ANALYSIS_VAR_ORIGIN_DWARF, ///< Variable was created from DWARF information + /* End enum */ + RZ_ANALYSIS_VAR_ORIGIN_END ///< Number of RzAnalysisVarOriginKind enums +} RzAnalysisVarOriginKind; + +static const char *RzAnalysisVarKind_strings[RZ_ANALYSIS_VAR_KIND_END] = { + "invalid", /* RZ_ANALYSIS_VAR_KIND_INVALID */ + "formal_parameter", /* RZ_ANALYSIS_VAR_KIND_FORMAL_PARAMETER */ + "variable", /* RZ_ANALYSIS_VAR_KIND_VARIABLE */ +}; + +static const char *RzAnalysisVarOriginKind_strings[RZ_ANALYSIS_VAR_ORIGIN_END] = { + "none", /* RZ_ANALYSIS_VAR_ORIGIN_NONE */ + "DWARF", /* RZ_ANALYSIS_VAR_ORIGIN_DWARF */ +}; + +#define RZ_ANALYSIS_AS_STRING_IMPL(T, name, strings) \ + static inline const char *rz_analysis_##name##_as_string(T k) { \ + if (k < 0 || k >= RZ_ARRAY_SIZE(strings)) { \ + return NULL; \ + } \ + return strings[k]; \ + } \ + static inline T rz_analysis_##name##_from_string(const char *s) { \ + for (unsigned int i = 0; i < RZ_ARRAY_SIZE(strings); ++i) { \ + if (RZ_STR_EQ(s, strings[i])) { \ + return (T)i; \ + } \ + } \ + return (T)0; \ + } + +RZ_ANALYSIS_AS_STRING_IMPL(RzAnalysisVarKind, var_kind, RzAnalysisVarKind_strings); +RZ_ANALYSIS_AS_STRING_IMPL(RzAnalysisVarOriginKind, var_origin_kind, RzAnalysisVarOriginKind_strings); + +/** + * A local variable or parameter as part of a function + */ +typedef struct rz_analysis_var_t { + RZ_BORROW RzAnalysisFunction *fcn; ///< function containing this variable + char *name; + RzType *type; + RzAnalysisVarStorage storage; + RzVector /**/ accesses; // ordered by offset, touch this only through API or expect uaf + char *comment; + RzVector /**/ constraints; + RzAnalysisVarKind kind; + + // below members are just for caching, TODO: remove them and do it better + int argnum; + + struct { + RzAnalysisVarOriginKind kind; ///< Kind of origin + union { + RzAnalysisDwarfVariable *dw_var; ///< Variable description from DWARF + }; + } origin; ///< Origin of the variable, i.e. DWARF, PDB, OMF +} RzAnalysisVar; + +/** + * A declaration with its occurrence in the program source. + */ +typedef struct { + ut32 decl_line; ///< File containing source declaration + ut32 decl_col; ///< Line number of source declaration + const char *decl_file; ///< Column position of source declaration +} RzAnalysisDeclCoord; + +/** + * \brief Global variables + */ +typedef struct rz_analysis_var_global_t { + RBNode rb; ///< RBTree node for address management + char *name; ///< name of the variable + ut64 addr; ///< address of the global variable + RzType *type; ///< type of the variable + RzVector /**/ constraints; + RZ_BORROW RzAnalysis *analysis; ///< analysis pertaining to this global variable + RzAnalysisDeclCoord coord; ///< a declaration of the variable +} RzAnalysisVarGlobal; + +typedef struct dwarf_function_t { + ut64 offset; ///< DIE offset + ut64 low_pc; ///< address of the function + ut64 high_pc; ///< max address of the function (relative to low_pc) + ut64 entry_pc; ///< the address of the first executable instruction + char *name; ///< name of the function + char *link_name; ///< object file linkage name + char *demangle_name; ///< demanagle of link_name + const char *prefer_name; ///< prefer name (depends on the language) + ut64 vtable_addr; // location description + ut64 call_conv; // normal || program || nocall + RzType *ret_type; ///< return type of the function + RzVector /**/ variables; ///< function variables, includes parameters and variables + ut8 access; // public = 1, protected = 2, private = 3, if not set assume private + + bool has_unspecified_parameters : 1; ///< has unspecified parameters. \sa RzAnalysisFunction.is_variadic + bool is_external : 1; ///< is visable outside of the compilation unit + bool is_method : 1; ///< is class/struct method + bool is_virtual : 1; ///< is virtual function + bool is_trampoline : 1; ///< intermediary in making call to another func +} RzAnalysisDwarfFunction; + +typedef enum { + RZ_ANALYSIS_ACC_UNKNOWN = 0, + RZ_ANALYSIS_ACC_R = (1 << 0), + RZ_ANALYSIS_ACC_W = (1 << 1), +} RzAnalysisValueAccess; + +typedef enum { + RZ_ANALYSIS_VAL_UNK, + RZ_ANALYSIS_VAL_REG, + RZ_ANALYSIS_VAL_MEM, + RZ_ANALYSIS_VAL_IMM, +} RzAnalysisValueType; + +// base+reg+regdelta*mul+delta +typedef struct rz_analysis_value_t { + RzAnalysisValueType type; + RzAnalysisValueAccess access; + int absolute; // if true, unsigned cast is used + int memref; // is memory reference? which size? 1, 2 ,4, 8 + ut64 base; // numeric address + st64 delta; // numeric delta + st64 imm; // immediate value + ut64 mul; // multiplier (reg*4+base) + RzRegItem *seg; // segment selector register + RzRegItem *reg; // register / register base used (-1 if no reg) + RzRegItem *regdelta; // register index used (-1 if no reg) + ut64 plugin_specific; // Can be used differently by each analysis plugin. +} RzAnalysisValue; + +typedef enum { + RZ_ANALYSIS_OP_DIR_READ = 1, + RZ_ANALYSIS_OP_DIR_WRITE = 2, + RZ_ANALYSIS_OP_DIR_EXEC = 4, + RZ_ANALYSIS_OP_DIR_REF = 8, +} RzAnalysisOpDirection; + +typedef enum rz_analysis_data_type_t { + RZ_ANALYSIS_DATATYPE_NULL = 0, + RZ_ANALYSIS_DATATYPE_ARRAY, + RZ_ANALYSIS_DATATYPE_OBJECT, // instance + RZ_ANALYSIS_DATATYPE_STRING, + RZ_ANALYSIS_DATATYPE_CLASS, + RZ_ANALYSIS_DATATYPE_BOOLEAN, + RZ_ANALYSIS_DATATYPE_INT16, + RZ_ANALYSIS_DATATYPE_INT32, + RZ_ANALYSIS_DATATYPE_INT64, + RZ_ANALYSIS_DATATYPE_FLOAT, +} RzAnalysisDataType; + +typedef RzILOpEffect *RzAnalysisLiftedILOp; + +typedef struct rz_analysis_op_t { + char *mnemonic; /* mnemonic.. it actually contains the args too, we should replace rasm with this */ + ut64 addr; /* address */ + ut32 type; /* type of opcode */ + RzAnalysisOpPrefix prefix; /* type of opcode prefix (rep,lock,..) */ + ut32 type2; /* used by java */ + RzAnalysisStackOp stackop; /* operation on stack? */ + RzTypeCond cond; /* condition type */ + int size; /* size in bytes of opcode */ + int nopcode; /* number of bytes representing the opcode (not the arguments) TODO: find better name */ + int cycles; /* cpu-cycles taken by instruction */ + int failcycles; /* conditional cpu-cycles */ + RzAnalysisOpFamily family; /* family of opcode */ + int id; /* instruction id */ + bool eob; /* end of block (boolean) */ + bool sign; /* operates on signed values, false by default */ + /* Run N instructions before executing the current one */ + int delay; /* delay N slots (mips, ..)*/ + ut64 jump; /* true jmp */ + ut64 fail; /* false jmp */ + RzAnalysisOpDirection direction; + st64 ptr; /* reference to memory */ /* XXX signed? */ + ut64 val; /* reference to value */ /* XXX signed? */ + RzAnalysisValue analysis_vals[6]; /* Analyzable values */ + int ptrsize; /* f.ex: zero extends for 8, 16 or 32 bits only */ + st64 stackptr; /* stack pointer */ + int refptr; /* if (0) ptr = "reference" else ptr = "load memory of refptr bytes" */ + ut64 mmio_address; // mmio address + RzAnalysisValue *src[8]; + RzAnalysisValue *dst; + RzList /**/ *access; /* RzAnalysisValue access information */ + RzStrBuf esil; + RzStructuredData *opex; + RzAnalysisLiftedILOp il_op; + const char *reg; /* destination register */ + const char *ireg; /* register used for indirect memory computation*/ + ut64 scale; + ut64 disp; + RzAnalysisSwitchOp *switch_op; + RzAnalysisHint hint; + RzAnalysisDataType datatype; +} RzAnalysisOp; + +#define RZ_TYPE_COND_SINGLE(x) (!x->arg[1] || x->arg[0] == x->arg[1]) + +typedef struct rz_analysis_cond_t { + RzTypeCond type; // filled by CJMP opcode + RzAnalysisValue *arg[2]; // filled by CMP opcode +} RzAnalysisCond; + +typedef struct rz_analysis_bb_t { + RBNode _rb; // private, node in the RBTree + ut64 _max_end; // private, augmented value for RBTree + + ut64 addr; + ut64 size; + ut64 jump; + ut64 fail; + bool traced; + ut32 colorize; + RzAnalysisCond *cond; + RzAnalysisSwitchOp *switch_op; + + /** + * Offsets of instructions in this block + * Count is ninstr - 1 (first is always 0) + */ + ut16 *op_pos; + + /** + * Stack pointer deltas of instructions in this block. + * + * `sp_delta[i]` is the difference between the stack pointer value after + * executing the i-th instruction in the block and sp_entry. + * Count is ninstr. + */ + RzVector /**/ sp_delta; + + /** + * Value of the stack pointer when entering this block + * or RZ_STACK_ADDR_INVALID if unknown + */ + RzStackAddr sp_entry; + + ut8 *op_bytes; + ut8 *parent_reg_arena; + int op_pos_size; // size of the op_pos array + int ninstr; + ut64 cmpval; + const char *cmpreg; + ut32 bbhash; // calculated with xxhash + + RzList /**/ *fcns; + RzAnalysis *analysis; + int ref; +} RzAnalysisBlock; + +#define RZ_ANALYSIS_BLOCK_MAX_SIZE UT16_MAX + +typedef struct rz_analysis_task_item { + RzAnalysisFunction *fcn; ///< current function + RzAnalysisBlock *block; ///< block being analyzed + RzStackAddr sp; ///< stack pointer value for variable analysis + ut64 start_address; ///< if block = NULL, creates block at address, else continues analysis from here +} RzAnalysisTaskItem; + +typedef enum { + RZ_ANALYSIS_XREF_TYPE_NULL = 0, + RZ_ANALYSIS_XREF_TYPE_CODE = 'c', // code ref + RZ_ANALYSIS_XREF_TYPE_CALL = 'C', // code ref (call) + RZ_ANALYSIS_XREF_TYPE_DATA = 'd', // mem ref + RZ_ANALYSIS_XREF_TYPE_STRING = 's' // string ref +} RzAnalysisXRefType; + +typedef struct rz_analysis_ref_t { + ut64 from; + ut64 to; + RzAnalysisXRefType type; +} RzAnalysisXRef; +RZ_API const char *rz_analysis_ref_type_tostring(RzAnalysisXRefType t); + +/* represents a reference line from one address (from) to another (to) */ +typedef struct rz_analysis_refline_t { + ut64 from; + ut64 to; + int index; + int level; + int type; + int direction; +} RzAnalysisRefline; + +typedef struct rz_analysis_cycle_frame_t { + ut64 naddr; // next addr + RzList /**/ *hooks; + struct rz_analysis_cycle_frame_t *prev; +} RzAnalysisCycleFrame; + +typedef struct rz_analysis_cycle_hook_t { // rename ? + ut64 addr; + int cycles; +} RzAnalysisCycleHook; + +typedef struct rz_analysis_esil_word_t { + int type; + const char *str; +} RzAnalysisEsilWord; + +// only flags that affect control flow +enum { + RZ_ANALYSIS_ESIL_FLAG_ZERO = 1, + RZ_ANALYSIS_ESIL_FLAG_CARRY = 2, + RZ_ANALYSIS_ESIL_FLAG_OVERFLOW = 4, + RZ_ANALYSIS_ESIL_FLAG_PARITY = 8, + RZ_ANALYSIS_ESIL_FLAG_SIGN = 16, + // ... +}; + +enum { + RZ_ANALYSIS_TRAP_NONE = 0, + RZ_ANALYSIS_TRAP_UNHANDLED = 1, + RZ_ANALYSIS_TRAP_BREAKPOINT = 2, + RZ_ANALYSIS_TRAP_DIVBYZERO = 3, + RZ_ANALYSIS_TRAP_WRITE_ERR = 4, + RZ_ANALYSIS_TRAP_READ_ERR = 5, + RZ_ANALYSIS_TRAP_EXEC_ERR = 6, + RZ_ANALYSIS_TRAP_INVALID = 7, + RZ_ANALYSIS_TRAP_UNALIGNED = 8, + RZ_ANALYSIS_TRAP_TODO = 9, + RZ_ANALYSIS_TRAP_HALT = 10, +}; + +enum { + RZ_ANALYSIS_ESIL_PARM_INVALID = 0, + RZ_ANALYSIS_ESIL_PARM_REG, + RZ_ANALYSIS_ESIL_PARM_NUM, +}; + +typedef struct rz_analysis_ref_char { + char *str; + char *cols; +} RzAnalysisRefStr; + +// must be a char +#define ESIL_INTERNAL_PREFIX '$' +#define ESIL_STACK_NAME "esil.ram" +#define ANALYSIS_ESIL struct rz_analysis_esil_t + +typedef struct rz_analysis_esil_source_t { + ut32 id; + ut32 claimed; + void *content; +} RzAnalysisEsilSource; + +RZ_API void rz_analysis_esil_sources_init(ANALYSIS_ESIL *esil); +RZ_API ut32 rz_analysis_esil_load_source(ANALYSIS_ESIL *esil, const char *path); +RZ_API void *rz_analysis_esil_get_source(ANALYSIS_ESIL *esil, ut32 src_id); +RZ_API bool rz_analysis_esil_claim_source(ANALYSIS_ESIL *esil, ut32 src_id); +RZ_API void rz_analysis_esil_release_source(ANALYSIS_ESIL *esil, ut32 src_id); +RZ_API void rz_analysis_esil_sources_fini(ANALYSIS_ESIL *esil); + +typedef bool (*RzAnalysisEsilInterruptCB)(ANALYSIS_ESIL *esil, ut32 interrupt, void *user); + +typedef struct rz_analysis_esil_interrupt_handler_t { + const ut32 num; + const char *name; + void *(*init)(ANALYSIS_ESIL *esil); + RzAnalysisEsilInterruptCB cb; + void (*fini)(void *user); +} RzAnalysisEsilInterruptHandler; + +typedef struct rz_analysis_esil_change_reg_t { + int idx; + ut64 data; +} RzAnalysisEsilRegChange; + +typedef struct rz_analysis_esil_change_mem_t { + int idx; + ut8 data; +} RzAnalysisEsilMemChange; + +typedef struct rz_analysis_esil_trace_t { + int idx; + int end_idx; + HtUP *registers; + HtUP *memory; + RzRegArena *arena[RZ_REG_TYPE_LAST]; + ut64 stack_addr; + ut64 stack_size; + ut8 *stack_data; + RzPVector /**/ *instructions; +} RzAnalysisEsilTrace; + +typedef int (*RzAnalysisEsilHookRegWriteCB)(ANALYSIS_ESIL *esil, const char *name, ut64 *val); + +typedef struct rz_analysis_esil_callbacks_t { + void *user; + /* callbacks */ + int (*hook_flag_read)(ANALYSIS_ESIL *esil, const char *flag, ut64 *num); + int (*hook_command)(ANALYSIS_ESIL *esil, const char *op); + int (*hook_mem_read)(ANALYSIS_ESIL *esil, ut64 addr, ut8 *buf, int len); + int (*mem_read)(ANALYSIS_ESIL *esil, ut64 addr, ut8 *buf, int len); + int (*hook_mem_write)(ANALYSIS_ESIL *esil, ut64 addr, const ut8 *buf, int len); + int (*mem_write)(ANALYSIS_ESIL *esil, ut64 addr, const ut8 *buf, int len); + int (*hook_reg_read)(ANALYSIS_ESIL *esil, const char *name, ut64 *res, int *size); + int (*reg_read)(ANALYSIS_ESIL *esil, const char *name, ut64 *res, int *size); + RzAnalysisEsilHookRegWriteCB hook_reg_write; + int (*reg_write)(ANALYSIS_ESIL *esil, const char *name, ut64 val); +} RzAnalysisEsilCallbacks; + +typedef struct rz_analysis_esil_t { + RzAnalysis *analysis; + char **stack; + ut64 addrmask; + int stacksize; + int stackptr; + ut32 skip; + int nowrite; + int iotrap; + int exectrap; + int repeat; + int parse_stop; + int parse_goto; + int parse_goto_count; + int verbose; + ut64 flags; + ut64 address; + ut64 stack_addr; + ut32 stack_size; + int delay; // mapped to $ds in ESIL + ut64 jump_target; // mapped to $jt in ESIL + int jump_target_set; // mapped to $js in ESIL + int trap; + ut32 trap_code; // extend into a struct to store more exception info? + // parity flag? done with cur + ut64 old; // used for carry-flagging and borrow-flagging + ut64 cur; // used for carry-flagging and borrow-flagging + ut8 lastsz; // in bits //used for signature-flag + /* native ops and custom ops */ + HtSP *ops; + RzStrBuf current_opstr; + RzIDStorage *sources; + HtUP *interrupts; + /* deep esil parsing fills this */ + Sdb *stats; + RzAnalysisEsilTrace *trace; + RzAnalysisEsilCallbacks cb; + // this is so cursed, can we please remove external commands from esil internals. + // Function pointers are fine, but not commands + char *cmd_step; // rizin (external) command to run before a step is performed + char *cmd_step_out; // rizin (external) command to run after a step is performed + char *cmd_intr; // rizin (external) command to run when an interrupt occurs + char *cmd_trap; // rizin (external) command to run when a trap occurs + char *cmd_mdev; // rizin (external) command to run when an memory mapped device address is used + char *cmd_todo; // rizin (external) command to run when esil expr contains TODO + char *cmd_ioer; // rizin (external) command to run when esil fails to IO + char *mdev_range; // string containing the rz_str_range to match for read/write accesses + bool (*cmd)(ANALYSIS_ESIL *esil, const char *name, ut64 a0, ut64 a1); + void *user; + int stack_fd; // ahem, let's not do this + bool in_cmd_step; +} RzAnalysisEsil; + +/* During the analysis RzAnalysisEsil could be reset multiple times, + * thus there is a need to preserve some values between those runs. + */ +typedef struct rz_analysis_esil_inter_state_t { + bool analysis_stop; + ut64 last_read; + ut64 last_data; + ut64 emustack_min; + ut64 emustack_max; + RzList /**/ *memreads; + RzList /**/ *memwrites; + RzAnalysisEsilCallbacks callbacks; + bool callbacks_set; +} RzAnalysisEsilInterState; + +/* Alias RegChange and MemChange */ +typedef RzAnalysisEsilRegChange RzAnalysisRzilRegChange; +typedef RzAnalysisEsilMemChange RzAnalysisRzilMemChange; + +/* Alias esil strace */ +typedef RzAnalysisEsilTrace RzAnalysisRzilTrace; + +/** + * \brief Description of the contents of a single IL variable + */ +typedef struct rz_analysis_il_init_state_var_t { + RZ_NONNULL const char *name; + RZ_NONNULL RzILVal *val; +} RzAnalysisILInitStateVar; + +typedef void (*RzAnalysisILInitCallback)(RzAnalysisILVM *vm, RzReg *reg); + +/** + * \brief Description of an initial state of an RzAnalysisILVM + * + * This may be used by an analysis plugin to communicate how to initialize + * variables/registers for a clean vm. + * Everything unspecified by this may be initialized to anything (for example + * whatever contents the RzReg currently has). + */ +typedef struct rz_analysis_il_init_state_t { + RzVector /**/ vars; ///< Contents of global variables + RzAnalysisILInitCallback cb; ///< Callback to run after the initial state has been set up +} RzAnalysisILInitState; + +/** + * \brief Description of the global context of an RzAnalysisILVM + * + * This defines all information needed to initialize an IL vm in order to run + * in a declarative way, in particular: + * + * * Size of the program counter: given explicitly in `pc_size` + * * Endian: given explicitly in `big_endian` + * * Memories: currently always one memory with index 0 bound against IO, with key size given by `mem_key_size` and value size of 8 + * * Registers: given explicitly in `reg_bindings` or derived from the register profile with `rz_il_reg_binding_derive()` + * * Labels: given explicitly in `labels` + * * Initial State of Variables: optionally given in `init_state` + */ +typedef struct rz_analysis_il_config_t { + ut32 pc_size; ///< size of the program counter in bits + bool big_endian; + /** + * Optional null-terminated array of registers to bind to global vars of the same name. + * If not specified, rz_il_reg_binding_derive will be used. + */ + RZ_NULLABLE const char **reg_bindings; + ut32 mem_key_size; ///< address size for memory 0, bound against IO + RzPVector /**/ labels; ///< global labels, primarily for syscall/hook callbacks + RZ_NULLABLE RzAnalysisILInitState *init_state; ///< optional, initial contents for variables/registers, etc. + // more information might go in here, for example additional memories, etc. +} RzAnalysisILConfig; + +/** + * \brief High-level RzIL vm to emulate disassembled code + * + * This builds upon the low-level `RzILVM`, which by itself does not know about + * IO and lifting, and enables emulation of instructions obtained by disassembling + * and lifting with analysis plugins. + */ +struct rz_analysis_il_vm_t { + RZ_NONNULL RzILVM *vm; ///< low-level vm to execute IL code + RZ_NONNULL RzBuffer *io_buf; ///< buffer to use for memory 0 (io) + RZ_NONNULL RzILRegBinding *reg_binding; ///< specifies which (global) variables are bound to registers +} /* RzAnalysisILVM */; + +typedef enum { + RZ_ANALYSIS_IL_STEP_RESULT_SUCCESS, + RZ_ANALYSIS_IL_STEP_RESULT_NOT_SET_UP, + RZ_ANALYSIS_IL_STEP_IL_RUNTIME_ERROR, + RZ_ANALYSIS_IL_STEP_UNIMPLEMENTED_IL, + RZ_ANALYSIS_IL_STEP_INVALID_OP +} RzAnalysisILStepResult; + +#undef ESIL + +typedef struct rz_analysis_esil_interrupt_t { + RzAnalysisEsilInterruptHandler *handler; + void *user; + ut32 src_id; + RzAnalysisEsil *esil; +} RzAnalysisEsilInterrupt; + +enum { + RZ_ANALYSIS_ESIL_OP_TYPE_UNKNOWN = 0x1, + RZ_ANALYSIS_ESIL_OP_TYPE_CONTROL_FLOW, + RZ_ANALYSIS_ESIL_OP_TYPE_MEM_READ = 0x4, + RZ_ANALYSIS_ESIL_OP_TYPE_MEM_WRITE = 0x8, + RZ_ANALYSIS_ESIL_OP_TYPE_REG_WRITE = 0x10, + RZ_ANALYSIS_ESIL_OP_TYPE_MATH = 0x20, + RZ_ANALYSIS_ESIL_OP_TYPE_CUSTOM = 0x40 +}; + +typedef bool (*RzAnalysisEsilOpCb)(RzAnalysisEsil *esil); + +typedef struct rz_analysis_esil_operation_t { + RzAnalysisEsilOpCb code; + ut32 push; // amount of operands pushed + ut32 pop; // amount of operands popped + ut32 type; +} RzAnalysisEsilOp; + +// this is 80-bit offsets so we can address every piece of esil in an instruction +typedef struct rz_analysis_esil_expr_offset_t { + ut64 off; + ut16 idx; +} RzAnalysisEsilEOffset; + +typedef enum { + RZ_ANALYSIS_ESIL_BLOCK_ENTER_NORMAL = 0, + RZ_ANALYSIS_ESIL_BLOCK_ENTER_TRUE, + RZ_ANALYSIS_ESIL_BLOCK_ENTER_FALSE, + RZ_ANALYSIS_ESIL_BLOCK_ENTER_GLUE, +} RzAnalysisEsilBlockEnterType; + +typedef struct rz_analysis_esil_basic_block_t { + RzAnalysisEsilEOffset first; + RzAnalysisEsilEOffset last; + char *expr; // synthesized esil-expression for this block + RzAnalysisEsilBlockEnterType enter; // maybe more type is needed here +} RzAnalysisEsilBB; + +// Structure to represent memory reads and writes during ESIL tracing +typedef struct rz_analysis_esil_memory_region_t { + ut64 addr; ///< memory address + size_t size; ///< size of the region +} RzAnalysisEsilMemoryRegion; + +// TODO: rm data + len +typedef int (*RzAnalysisOpCallback)(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask); + +typedef bool (*RzAnalysisRegProfCallback)(RzAnalysis *a); +typedef char *(*RzAnalysisRegProfGetCallback)(RzAnalysis *a); +typedef int (*RzAnalysisFPBBCallback)(RzAnalysis *a, RzAnalysisBlock *bb); +typedef int (*RzAnalysisFPFcnCallback)(RzAnalysis *a, RzAnalysisFunction *fcn); + +typedef int (*RzAnalysisEsilCB)(RzAnalysisEsil *esil); +typedef int (*RzAnalysisEsilLoopCB)(RzAnalysisEsil *esil, RzAnalysisOp *op); +typedef int (*RzAnalysisEsilTrapCB)(RzAnalysisEsil *esil, int trap_type, int trap_code); + +typedef RZ_OWN RzAnalysisILConfig *(*RzAnalysisILConfigCB)(RzAnalysis *analysis); + +typedef struct rz_analysis_plugin_t { + const char *name; + const char *desc; + const char *license; + const char *arch; + const char *author; + const char *version; + int bits; + int esil; // can do esil or not + int fileformat_type; + bool (*init)(void **user); + bool (*fini)(void *user); + // int (*reset_counter) (RzAnalysis *analysis, ut64 start_addr); + int (*archinfo)(RzAnalysis *analysis, RzAnalysisInfoType query); + ut8 *(*analysis_mask)(RzAnalysis *analysis, int size, const ut8 *data, ut64 at); + RzList /**/ *(*preludes)(RzAnalysis *analysis); + + /** + * The actual bit-size of an address for given analysis.bits. + * If unimplemented or returns <= 0, analysis.bits will be used as-is. + */ + int (*address_bits)(RzAnalysis *analysis, int bits); + + // legacy rz_analysis_functions + RzAnalysisOpCallback op; + + RzAnalysisRegProfGetCallback get_reg_profile; + + RzAnalysisEsilCB esil_init; // initialize esil-related stuff + RzAnalysisEsilLoopCB esil_post_loop; // cycle-counting, firing interrupts, ... + RzAnalysisEsilTrapCB esil_trap; // traps / exceptions + RzAnalysisEsilCB esil_fini; // deinitialize + RzAnalysisILConfigCB il_config; ///< return an IL config to execute lifted code of the given analysis' arch/cpu/bits + +} RzAnalysisPlugin; + +/*----------------------------------------------------------------------------------------------*/ + +#ifdef RZ_API +/* --------- */ /* REFACTOR */ /* ---------- */ +/* type.c */ +RZ_API const char *rz_analysis_datatype_to_string(RzAnalysisDataType t); +RZ_API bool rz_analysis_op_nonlinear(int t); +RZ_API bool rz_analysis_op_ismemref(int t); +RZ_API const char *rz_analysis_optype_to_string(int t); +RZ_API int rz_analysis_optype_from_string(RZ_NONNULL const char *type); +RZ_API const char *rz_analysis_op_family_to_string(int n); +RZ_API int rz_analysis_op_family_from_string(RZ_NONNULL const char *f); +RZ_API int rz_analysis_op_hint(RzAnalysisOp *op, RzAnalysisHint *hint); + +/* block.c */ +typedef bool (*RzAnalysisBlockCb)(RzAnalysisBlock *block, void *user); +typedef bool (*RzAnalysisAddrCb)(ut64 addr, void *user); + +// lifetime +RZ_API void rz_analysis_block_ref(RzAnalysisBlock *bb); +RZ_API void rz_analysis_block_unref(RzAnalysisBlock *bb); + +// Create one block covering the given range. +// This will fail if the range overlaps any existing blocks. +RZ_API RzAnalysisBlock *rz_analysis_create_block(RzAnalysis *analysis, ut64 addr, ut64 size); + +static inline bool rz_analysis_block_contains(RzAnalysisBlock *bb, ut64 addr) { + return addr >= bb->addr && addr < bb->addr + bb->size; +} + +// Split the block at the given address into two blocks. +// bb will stay the first block, the second block will be returned (or NULL on failure) +// The returned block will always be refd, i.e. it is necessary to always call rz_analysis_block_unref() on the return value! +RZ_API RzAnalysisBlock *rz_analysis_block_split(RzAnalysisBlock *bb, ut64 addr); + +static inline bool rz_analysis_block_is_contiguous(RzAnalysisBlock *a, RzAnalysisBlock *b) { + return (a->addr + a->size) == b->addr; +} + +// Merge block b into a. +// b will be FREED (not just unrefd) and is NOT VALID anymore if this function is successful! +// This only works if b follows directly after a and their function lists are identical. +// returns true iff the blocks could be merged +RZ_API bool rz_analysis_block_merge(RzAnalysisBlock *a, RzAnalysisBlock *b); + +// Manually delete a block and remove it from all its functions +// If there are more references to it than from its functions only, it will not be removed immediately! +RZ_API void rz_analysis_delete_block(RzAnalysisBlock *bb); + +RZ_API void rz_analysis_block_set_size(RzAnalysisBlock *block, ut64 size); + +// Set the address and size of the block. +// This can fail (and return false) if there is already another block at the new address +RZ_API bool rz_analysis_block_relocate(RzAnalysisBlock *block, ut64 addr, ut64 size); + +RZ_API RzAnalysisBlock *rz_analysis_get_block_at(RzAnalysis *analysis, ut64 addr); +RZ_API bool rz_analysis_blocks_foreach_in(RzAnalysis *analysis, ut64 addr, RzAnalysisBlockCb cb, void *user); +RZ_API RzList /**/ *rz_analysis_get_blocks_in(RzAnalysis *analysis, ut64 addr); // values from rz_analysis_blocks_foreach_in as a list +RZ_API void rz_analysis_blocks_foreach_intersect(RzAnalysis *analysis, ut64 addr, ut64 size, RzAnalysisBlockCb cb, void *user); +RZ_API RzList /**/ *rz_analysis_get_blocks_intersect(RzAnalysis *analysis, ut64 addr, ut64 size); // values from rz_analysis_blocks_foreach_intersect as a list + +// Call cb on every direct successor address of block +// returns false if the loop was breaked by cb +RZ_API bool rz_analysis_block_successor_addrs_foreach(RzAnalysisBlock *block, RzAnalysisAddrCb cb, void *user); + +// Call cb on block and every (recursive) successor of it +// returns false if the loop was breaked by cb +RZ_API bool rz_analysis_block_recurse(RzAnalysisBlock *block, RzAnalysisBlockCb cb, void *user); + +// Call cb on block and every (recursive) successor of it +// If cb returns false, recursion stops only for that block +// returns false if the loop was breaked by cb +RZ_API bool rz_analysis_block_recurse_followthrough(RzAnalysisBlock *block, RzAnalysisBlockCb cb, void *user); + +// Call cb on block and every (recursive) successor of it +// Call on_exit on block that doesn't have non-visited successors +// returns false if the loop was breaked by cb +RZ_API bool rz_analysis_block_recurse_depth_first(RzAnalysisBlock *block, RzAnalysisBlockCb cb, RZ_NULLABLE RzAnalysisBlockCb on_exit, void *user); + +// same as rz_analysis_block_recurse, but returns the blocks as a list +RZ_API RzList /**/ *rz_analysis_block_recurse_list(RzAnalysisBlock *block); + +// return one shortest path from block to dst or NULL if none exists. +RZ_API RZ_NULLABLE RzList /**/ *rz_analysis_block_shortest_path(RzAnalysisBlock *block, ut64 dst); + +// Add a case to the block's switch_op. +// If block->switch_op is NULL, it will be created with the given switch_addr. +RZ_API void rz_analysis_block_add_switch_case(RzAnalysisBlock *block, ut64 switch_addr, ut64 case_value, ut64 case_addr); + +// Chop off the block at the specified address and remove all destinations. +// Blocks that have become unreachable after this operation will be automatically removed from all functions of block. +// addr must be the address directly AFTER the noreturn call! +// After the chopping, an rz_analysis_block_automerge() is performed on the touched blocks. +// IMPORTANT: The automerge might also FREE block! This function returns block iff it is still valid afterwards. +// If this function returns NULL, the pointer to block MUST not be touched anymore! +RZ_API RzAnalysisBlock *rz_analysis_block_chop_noreturn(RzAnalysisBlock *block, ut64 addr); + +// Merge every block in blocks with their contiguous predecessor, if possible. +// IMPORTANT: Merged blocks will be FREED! The blocks list will be updated to contain only the survived blocks. +RZ_API void rz_analysis_block_automerge(RzPVector /**/ *blocks); + +// return true iff an instruction in the given basic block starts at the given address +RZ_API bool rz_analysis_block_op_starts_at(RzAnalysisBlock *block, ut64 addr); + +// Updates bbhash based on current bytes inside the block +RZ_API void rz_analysis_block_update_hash(RzAnalysisBlock *block); + +// returns true if a byte in the given basic block was modified +RZ_API bool rz_analysis_block_was_modified(RzAnalysisBlock *block); + +RZ_API RzAnalysisBlock *rz_analysis_find_most_relevant_block_in(RzAnalysis *analysis, ut64 off); + +RZ_API ut16 rz_analysis_block_get_op_offset(RzAnalysisBlock *block, size_t i); +RZ_API ut64 rz_analysis_block_get_op_addr(RzAnalysisBlock *block, size_t i); +RZ_API int rz_analysis_block_get_op_index_in(RzAnalysisBlock *bb, ut64 addr); +RZ_API ut64 rz_analysis_block_get_op_addr_in(RzAnalysisBlock *bb, ut64 addr); +RZ_API bool rz_analysis_block_set_op_offset(RzAnalysisBlock *block, size_t i, ut16 v); +RZ_API ut64 rz_analysis_block_get_op_size(RzAnalysisBlock *bb, size_t i); +RZ_API st16 rz_analysis_block_get_op_sp_delta(RzAnalysisBlock *bb, size_t i); +RZ_API bool rz_analysis_block_set_op_sp_delta(RzAnalysisBlock *bb, size_t i, st16 delta); +RZ_API st16 rz_analysis_block_get_sp_delta_at(RzAnalysisBlock *bb, ut64 addr); +RZ_API st16 rz_analysis_block_get_sp_delta_at_end(RzAnalysisBlock *bb); +RZ_API RzStackAddr rz_analysis_block_get_sp_at_end(RzAnalysisBlock *bb); +RZ_API RzStackAddr rz_analysis_block_get_sp_at(RzAnalysisBlock *bb, ut64 addr); +RZ_API void rz_analysis_block_analyze_ops(RzAnalysisBlock *block); + +// --------------------------------------- + +/* function.c */ + +RZ_API RzAnalysisFunction *rz_analysis_function_new(RzAnalysis *analysis); +RZ_API void rz_analysis_function_free(void *fcn); + +// Add a function created with rz_analysis_function_new() to anal +RZ_API bool rz_analysis_add_function(RzAnalysis *analysis, RzAnalysisFunction *fcn); + +// Create a new function and add it to analysis (rz_analysis_function_new() + set members + rz_analysis_add_function()) +RZ_API RzAnalysisFunction *rz_analysis_create_function(RzAnalysis *analysis, const char *name, ut64 addr, RzAnalysisFcnType type); + +// returns all functions that have a basic block containing the given address +RZ_API RzList /**/ *rz_analysis_get_functions_in(RzAnalysis *analysis, ut64 addr); + +RZ_API RZ_BORROW RzAnalysisFunction *rz_analysis_first_function_in(RZ_NONNULL RZ_BORROW RzAnalysis *analysis, ut64 addr); + +RZ_API RzAnalysisFunction *rz_analysis_get_function_at(const RzAnalysis *analysis, ut64 addr); + +RZ_API bool rz_analysis_function_delete(RzAnalysisFunction *fcn); + +// returns the list of functions in the RzAnalysis instance +RZ_API RZ_BORROW RzList /**/ *rz_analysis_function_list(RzAnalysis *analysis); + +// rhange the entrypoint of fcn +// This can fail (and return false) if there is already another function at the new address +RZ_API bool rz_analysis_function_relocate(RzAnalysisFunction *fcn, ut64 addr); + +// rename the given function +// This can fail (and return false) if there is another function with the name given +RZ_API bool rz_analysis_function_rename(RZ_NONNULL RzAnalysisFunction *fcn, RZ_NONNULL const char *name); +RZ_API RZ_BORROW const char *rz_analysis_function_force_rename(RZ_NONNULL RzAnalysisFunction *fcn, RZ_NONNULL const char *name); + +RZ_API void rz_analysis_function_add_block(RzAnalysisFunction *fcn, RzAnalysisBlock *bb); +RZ_API void rz_analysis_function_remove_block(RzAnalysisFunction *fcn, RzAnalysisBlock *bb); + +// size of the entire range that the function spans, including holes. +// this is exactly rz_analysis_function_max_addr() - rz_analysis_function_min_addr() +RZ_API ut64 rz_analysis_function_linear_size(RzAnalysisFunction *fcn); + +// lowest address covered by the function +RZ_API ut64 rz_analysis_function_min_addr(RzAnalysisFunction *fcn); + +// first address directly after the function +RZ_API ut64 rz_analysis_function_max_addr(RzAnalysisFunction *fcn); + +// size from the function entrypoint (fcn->addr) to the end of the function (rz_analysis_function_max_addr) +RZ_API ut64 rz_analysis_function_size_from_entry(RzAnalysisFunction *fcn); + +// the "real" size of the function, that is the sum of the size of the +// basicblocks this function is composed of +RZ_API ut64 rz_analysis_function_realsize(const RzAnalysisFunction *fcn); + +// returns whether the function contains a basic block that contains addr +// This is completely independent of fcn->addr, which is only the entrypoint! +RZ_API bool rz_analysis_function_contains(RzAnalysisFunction *fcn, ut64 addr); + +// returns true if function bytes were modified +RZ_API bool rz_analysis_function_was_modified(RZ_NONNULL RzAnalysisFunction *fcn); + +RZ_API bool rz_analysis_function_is_autonamed(RZ_NONNULL char *name); +RZ_API RZ_OWN char *rz_analysis_function_name_guess(RzTypeDB *typedb, RZ_NONNULL char *name); + +/* analysis.c */ +RZ_API RzAnalysis *rz_analysis_new(RZ_NULLABLE const char *sdb_types_path); +RZ_API void rz_analysis_purge(RzAnalysis *analysis); +RZ_API RzAnalysis *rz_analysis_free(RzAnalysis *r); +RZ_API bool rz_analysis_plugin_add(RzAnalysis *analysis, RZ_NONNULL RzAnalysisPlugin *foo); +RZ_API bool rz_analysis_plugin_del(RzAnalysis *analysis, RZ_NONNULL RzAnalysisPlugin *foo); +RZ_API int rz_analysis_archinfo(RzAnalysis *analysis, RzAnalysisInfoType query); +RZ_API bool rz_analysis_use(RzAnalysis *analysis, const char *name); +RZ_API bool rz_analysis_set_reg_profile(RzAnalysis *analysis); +RZ_API char *rz_analysis_get_reg_profile(RzAnalysis *analysis); +RZ_API bool rz_analysis_is_reg_in_profile(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL const char *name); +RZ_API bool rz_analysis_set_bits(RzAnalysis *analysis, int bits); +RZ_API bool rz_analysis_set_os(RzAnalysis *analysis, const char *os); +RZ_API void rz_analysis_set_cpu(RzAnalysis *analysis, const char *cpu); +RZ_API int rz_analysis_set_big_endian(RzAnalysis *analysis, int boolean); +RZ_API ut8 *rz_analysis_mask(RzAnalysis *analysis, ut32 size, const ut8 *data, ut64 at); +RZ_API void rz_analysis_trace_bb(RzAnalysis *analysis, ut64 addr); +RZ_API const char *rz_analysis_fcntype_tostring(int type); +RZ_API void rz_analysis_bind(RzAnalysis *b, RzAnalysisBind *bnd); +RZ_API bool rz_analysis_set_triplet(RzAnalysis *analysis, const char *os, const char *arch, int bits); +RZ_API void rz_analysis_add_import(RzAnalysis *analysis, const char *imp); +RZ_API void rz_analysis_remove_import(RzAnalysis *analysis, const char *imp); +RZ_API void rz_analysis_purge_imports(RzAnalysis *analysis); +RZ_API int rz_analysis_get_address_bits(RzAnalysis *analysis); + +/* op.c */ +RZ_API const char *rz_analysis_stackop_tostring(int s); +RZ_API RzStackAddr rz_analysis_op_apply_sp_effect(RzAnalysisOp *op, RzStackAddr sp); +RZ_API RZ_NULLABLE RZ_OWN char *rz_analysis_op_describe_sp_effect(RzAnalysisOp *op); +RZ_API RzAnalysisOp *rz_analysis_op_new(void); +RZ_API void rz_analysis_op_free(void *op); +RZ_API void rz_analysis_op_init(RzAnalysisOp *op); +RZ_API bool rz_analysis_op_fini(RzAnalysisOp *op); +RZ_API int rz_analysis_op_reg_delta(RzAnalysis *analysis, ut64 addr, const char *name); +RZ_API bool rz_analysis_op_is_eob(const RzAnalysisOp *op); +RZ_API RzList /**/ *rz_analysis_op_list_new(void); +RZ_API int rz_analysis_op(RZ_NONNULL RzAnalysis *analysis, RZ_OUT RzAnalysisOp *op, ut64 addr, const ut8 *data, ut64 len, RzAnalysisOpMask mask); +RZ_API RzAnalysisOp *rz_analysis_op_hexstr(RzAnalysis *analysis, ut64 addr, const char *hexstr); +RZ_API char *rz_analysis_op_to_string(RzAnalysis *analysis, RzAnalysisOp *op); + +RZ_API RzAnalysisEsil *rz_analysis_esil_new(int stacksize, int iotrap, unsigned int addrsize); +RZ_API bool rz_analysis_esil_set_pc(RzAnalysisEsil *esil, ut64 addr); +RZ_API bool rz_analysis_esil_setup(RzAnalysisEsil *esil, RzAnalysis *analysis, int romem, int stats, int nonull); +RZ_API void rz_analysis_esil_free(RzAnalysisEsil *esil); +RZ_API bool rz_analysis_esil_runword(RzAnalysisEsil *esil, const char *word); +RZ_API bool rz_analysis_esil_parse(RzAnalysisEsil *esil, const char *str); +RZ_API int rz_analysis_esil_mem_read(RzAnalysisEsil *esil, ut64 addr, ut8 *buf, int len); +RZ_API int rz_analysis_esil_mem_write(RzAnalysisEsil *esil, ut64 addr, const ut8 *buf, int len); +RZ_API int rz_analysis_esil_reg_read(RzAnalysisEsil *esil, const char *regname, ut64 *num, int *size); +RZ_API int rz_analysis_esil_reg_write(RzAnalysisEsil *esil, const char *dst, ut64 num); +RZ_API bool rz_analysis_esil_pushnum(RzAnalysisEsil *esil, ut64 num); +RZ_API bool rz_analysis_esil_push(RzAnalysisEsil *esil, const char *str); +RZ_API char *rz_analysis_esil_pop(RzAnalysisEsil *esil); +RZ_API const char *rz_analysis_esil_trapstr(int type); +RZ_API bool rz_analysis_esil_set_op(RzAnalysisEsil *esil, const char *op, RzAnalysisEsilOpCb code, ut32 push, ut32 pop, ut32 type); +RZ_API void rz_analysis_esil_stack_free(RzAnalysisEsil *esil); +RZ_API int rz_analysis_esil_get_parm_type(RzAnalysisEsil *esil, const char *str); +RZ_API int rz_analysis_esil_get_parm(RzAnalysisEsil *esil, const char *str, ut64 *num); +RZ_API int rz_analysis_esil_condition(RzAnalysisEsil *esil, const char *str); + +// esil_interrupt.c +RZ_API void rz_analysis_esil_interrupts_init(RzAnalysisEsil *esil); +RZ_API RzAnalysisEsilInterrupt *rz_analysis_esil_interrupt_new(RzAnalysisEsil *esil, ut32 src_id, RzAnalysisEsilInterruptHandler *ih); +RZ_API void rz_analysis_esil_interrupt_free(RzAnalysisEsil *esil, RzAnalysisEsilInterrupt *intr); +RZ_API bool rz_analysis_esil_set_interrupt(RzAnalysisEsil *esil, RzAnalysisEsilInterrupt *intr); +RZ_API int rz_analysis_esil_fire_interrupt(RzAnalysisEsil *esil, ut32 intr_num); +RZ_API bool rz_analysis_esil_load_interrupts(RzAnalysisEsil *esil, RzAnalysisEsilInterruptHandler **handlers, ut32 src_id); +RZ_API bool rz_analysis_esil_load_interrupts_from_lib(RzAnalysisEsil *esil, const char *path); +RZ_API void rz_analysis_esil_interrupts_fini(RzAnalysisEsil *esil); + +RZ_API void rz_analysis_esil_mem_ro(RzAnalysisEsil *esil, int mem_readonly); +RZ_API void rz_analysis_esil_stats(RzAnalysisEsil *esil, int enable); + +/* new trace implementation */ +typedef enum { + RZ_IL_TRACE_OP_READ, ///< read + RZ_IL_TRACE_OP_WRITE ///< write +} RzILTraceOpType; + +typedef struct { + ut64 addr; ///< memory address + RzILTraceOpType behavior; ///< read or write, see RzILTraceOpType enums + ut8 data_buf[32]; ///< data either written to or read from + int data_len; ///< data length +} RzILTraceMemOp; + +typedef struct { + const char *reg_name; ///< name of register + RzILTraceOpType behavior; ///< READ or WRITE, see RzILTraceOpType enums + ut64 value; ///< data either written to or read from +} RzILTraceRegOp; + +typedef enum { + RZ_IL_TRACE_INS_HAS_MEM_R = 0x1U, ///< instruction include memory read + RZ_IL_TRACE_INS_HAS_MEM_W = 0x2U, ///< instruction include memory write + RZ_IL_TRACE_INS_HAS_REG_R = 0x4U, ///< instruction include register read + RZ_IL_TRACE_INS_HAS_REG_W = 0x8U ///< instruction include register write +} RzILTraceInsOp; + +typedef struct { + ut64 addr; ///< Address of instruction + ut32 stats; ///< Has write/read to reg/mem ? see RZ_IL_TRACE_INS_HAS_* enums + + RzPVector /**/ *write_mem_ops; ///< Vector + RzPVector /**/ *read_mem_ops; ///< Vector + + RzPVector /**/ *write_reg_ops; ///< Vector + RzPVector /**/ *read_reg_ops; ///< Vector +} RzILTraceInstruction; + +/* Independent Trace Functions */ +RZ_API RzILTraceInstruction *rz_analysis_il_trace_instruction_new(ut64 addr); +RZ_API void rz_analysis_il_trace_instruction_free(RzILTraceInstruction *instruction); +RZ_API bool rz_analysis_il_trace_add_mem(RzILTraceInstruction *trace, RzILTraceMemOp *mem); +RZ_API bool rz_analysis_il_trace_add_reg(RzILTraceInstruction *trace, RzILTraceRegOp *reg); +RZ_API RzILTraceMemOp *rz_analysis_il_get_mem_op_trace(RzILTraceInstruction *trace, ut64 addr, RzILTraceOpType op_type); +RZ_API RzILTraceRegOp *rz_analysis_il_get_reg_op_trace(RzILTraceInstruction *trace, const char *regname, RzILTraceOpType op_type); +RZ_API bool rz_analysis_il_mem_trace_contains(RzILTraceInstruction *trace, ut64 addr, RzILTraceOpType op_type); +RZ_API bool rz_analysis_il_reg_trace_contains(RzILTraceInstruction *trace, const char *regname, RzILTraceOpType op_type); + +/* ESIL trace */ +RZ_API RZ_BORROW RzILTraceInstruction *rz_analysis_esil_get_instruction_trace(RZ_NONNULL RzAnalysisEsilTrace *etrace, int idx); +RZ_API RzAnalysisEsilTrace *rz_analysis_esil_trace_new(RzAnalysisEsil *esil); +RZ_API void rz_analysis_esil_trace_free(RzAnalysisEsilTrace *trace); +RZ_API void rz_analysis_esil_trace_op(RzAnalysisEsil *esil, RZ_NONNULL RzAnalysisOp *op); +RZ_API void rz_analysis_esil_trace_list(RzAnalysisEsil *esil); +RZ_API void rz_analysis_esil_trace_show(RzAnalysisEsil *esil, int idx); +RZ_API void rz_analysis_esil_trace_restore(RzAnalysisEsil *esil, int idx); + +/* RzIL */ +RZ_API RzAnalysisILInitState *rz_analysis_il_init_state_new(); +RZ_API void rz_analysis_il_init_state_free(RzAnalysisILInitState *state); +RZ_API void rz_analysis_il_init_state_set_var(RZ_NONNULL RzAnalysisILInitState *state, + RZ_NONNULL const char *name, RZ_NONNULL RZ_OWN RzILVal *val); +RZ_API RZ_OWN RzAnalysisILConfig *rz_analysis_il_config_new(ut32 pc_size, bool big_endian, ut32 mem_key_size); +RZ_API void rz_analysis_il_config_free(RzAnalysisILConfig *cfg); +RZ_API void rz_analysis_il_config_add_label(RZ_NONNULL RzAnalysisILConfig *cfg, RZ_NONNULL RZ_OWN RzILEffectLabel *label); + +typedef bool (*RzAnalysisILVMCondCallback)(RzAnalysisILVM *vm, void *user); + +RZ_API RZ_OWN RzAnalysisILVM *rz_analysis_il_vm_new(RzAnalysis *a, RZ_NULLABLE RzReg *init_state_reg); +RZ_API void rz_analysis_il_vm_free(RZ_NULLABLE RzAnalysisILVM *vm); +RZ_API void rz_analysis_il_vm_sync_from_reg(RzAnalysisILVM *vm, RZ_NONNULL RzReg *reg); +RZ_API bool rz_analysis_il_vm_sync_to_reg(RzAnalysisILVM *vm, RZ_NONNULL RzReg *reg); +RZ_API RzAnalysisILStepResult rz_analysis_il_vm_step( + RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisILVM *vm, RZ_NULLABLE RzReg *reg); +RZ_API RzAnalysisILStepResult rz_analysis_il_vm_step_while( + RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisILVM *vm, RZ_NULLABLE RzReg *reg, + RZ_NONNULL RzAnalysisILVMCondCallback cond, RZ_NULLABLE void *user); +RZ_API RzAnalysisILStepResult rz_analysis_il_vm_step_while_with_events( + RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisILVM *vm, RZ_NULLABLE RzReg *reg, + RZ_NONNULL RzAnalysisILVMCondCallback cond, RZ_NULLABLE void *user); +RZ_API bool rz_analysis_il_vm_setup(RzAnalysis *analysis); +RZ_API void rz_analysis_il_vm_cleanup(RzAnalysis *analysis); + +/* trace */ +RZ_API RzAnalysisRzilTrace *rz_analysis_rzil_trace_new(RzAnalysis *analysis, RZ_NONNULL RzAnalysisILVM *rzil); +RZ_API void rz_analysis_rzil_trace_free(RzAnalysisRzilTrace *trace); +RZ_API void rz_analysis_rzil_trace_op(RzAnalysis *analysis, RZ_NONNULL RzAnalysisILVM *rzil, RZ_NONNULL RzAnalysisLiftedILOp op); + +RZ_API bool rz_analysis_add_device_peripheral_map(RzBinObject *o, RzAnalysis *analysis); + +/* fcn.c */ +RZ_API ut32 rz_analysis_function_cost(RzAnalysisFunction *fcn); +RZ_API ut32 rz_analysis_function_count_edges(const RzAnalysisFunction *fcn, RZ_NULLABLE int *ebbs); + +// Use rz_analysis_get_functions_in¿() instead +RZ_DEPRECATE RZ_API RzAnalysisFunction *rz_analysis_get_fcn_in(RzAnalysis *analysis, ut64 addr, int type); +RZ_DEPRECATE RZ_API RzAnalysisFunction *rz_analysis_get_fcn_in_bounds(RzAnalysis *analysis, ut64 addr, int type); + +RZ_API RzAnalysisFunction *rz_analysis_get_function_byname(RzAnalysis *analysis, const char *name); + +RZ_API int rz_analysis_fcn(RzAnalysis *analysis, RzAnalysisFunction *fcn, ut64 addr, ut64 len, int reftype); +RZ_API int rz_analysis_fcn_del(RzAnalysis *analysis, ut64 addr); +RZ_API int rz_analysis_fcn_del_locs(RzAnalysis *analysis, ut64 addr); +RZ_API bool rz_analysis_fcn_add_bb(RzAnalysis *analysis, RzAnalysisFunction *fcn, ut64 addr, ut64 size, ut64 jump, ut64 fail); +RZ_API bool rz_analysis_check_fcn(RzAnalysis *analysis, ut8 *buf, ut16 bufsz, ut64 addr, ut64 low, ut64 high); + +RZ_API void rz_analysis_function_check_bp_use(RzAnalysisFunction *fcn); +RZ_API void rz_analysis_update_analysis_range(RzAnalysis *analysis, ut64 addr, int size); +RZ_API void rz_analysis_function_update_analysis(RzAnalysisFunction *fcn); + +RZ_API bool rz_analysis_task_item_new(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzVector /**/ *tasks, RZ_NONNULL RzAnalysisFunction *fcn, RZ_NULLABLE RzAnalysisBlock *block, ut64 address, RzStackAddr sp); +RZ_API int rz_analysis_run_tasks(RZ_NONNULL RzVector /**/ *tasks); + +RZ_API ut32 rz_analysis_function_complexity(RzAnalysisFunction *fcn); +RZ_API ut32 rz_analysis_function_loops(RzAnalysisFunction *fcn); +RZ_API void rz_analysis_trim_jmprefs(RzAnalysis *analysis, RzAnalysisFunction *fcn); +RZ_API void rz_analysis_del_jmprefs(RzAnalysis *analysis, RzAnalysisFunction *fcn); +RZ_API RZ_OWN char *rz_analysis_function_get_json(RzAnalysisFunction *function); +RZ_API RzAnalysisFunction *rz_analysis_fcn_next(RzAnalysis *analysis, ut64 addr); +RZ_API RZ_OWN char *rz_analysis_function_get_signature(RZ_NONNULL RzAnalysisFunction *function); +RZ_API void rz_analysis_function_set_type(RzAnalysis *a, RZ_NONNULL RzAnalysisFunction *f, RZ_NONNULL RzCallable *callable); +RZ_API bool rz_analysis_function_set_type_str(RzAnalysis *a, RZ_NONNULL RzAnalysisFunction *f, RZ_NONNULL const char *sig); +RZ_API bool rz_analysis_function_set_cc(RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn, RZ_NULLABLE const char *cc); +RZ_API ut32 rz_analysis_fcn_count(RzAnalysis *a, ut64 from, ut64 to); +RZ_API RzAnalysisBlock *rz_analysis_fcn_bbget_in(const RzAnalysis *analysis, RzAnalysisFunction *fcn, ut64 addr); +RZ_API RzAnalysisBlock *rz_analysis_fcn_bbget_at(RzAnalysis *analysis, RzAnalysisFunction *fcn, ut64 addr); +RZ_API int rz_analysis_function_resize(RzAnalysisFunction *fcn, int newsize); +RZ_API bool rz_analysis_function_purity(RzAnalysisFunction *fcn); + +typedef bool (*RzAnalysisRefCmp)(RzAnalysisXRef *ref, void *data); +RZ_API RZ_OWN RzList /**/ *rz_analysis_xref_list_new(void); +RZ_API ut64 rz_analysis_xrefs_count(RzAnalysis *analysis); +RZ_API const char *rz_analysis_xrefs_type_tostring(RzAnalysisXRefType type); +RZ_API RzAnalysisXRefType rz_analysis_xrefs_type(char ch); +RZ_API RZ_OWN RzList /**/ *rz_analysis_xrefs_get_to(RzAnalysis *analysis, ut64 addr); +RZ_API RZ_OWN RzList /**/ *rz_analysis_xrefs_get_from(RzAnalysis *analysis, ut64 addr); +RZ_API RZ_OWN RzList /**/ *rz_analysis_xrefs_list(RzAnalysis *analysis); +RZ_API RZ_OWN RzList /**/ *rz_analysis_function_get_xrefs_from(const RzAnalysisFunction *fcn); +RZ_API RZ_OWN RzList /**/ *rz_analysis_function_get_xrefs_to(const RzAnalysisFunction *fcn); +RZ_API bool rz_analysis_xrefs_set(RzAnalysis *analysis, ut64 from, ut64 to, RzAnalysisXRefType type); +RZ_API bool rz_analysis_xrefs_deln(RzAnalysis *analysis, ut64 from, ut64 to, RzAnalysisXRefType type); +RZ_API bool rz_analysis_xref_del(RzAnalysis *analysis, ut64 from, ut64 to); + +/* var.c */ +RZ_API RZ_BORROW RzAnalysisVar *rz_analysis_function_set_var( + RzAnalysisFunction *fcn, + RZ_NONNULL RzAnalysisVarStorage *stor, + RZ_BORROW RZ_NULLABLE const RzType *type, + int size, + RZ_NONNULL const char *name); +RZ_API RZ_BORROW RzAnalysisVar *rz_analysis_function_add_var(RzAnalysisFunction *fcn, RZ_OWN RzAnalysisVar *var); +RZ_API RZ_BORROW RzAnalysisVar *rz_analysis_function_get_var_at(RzAnalysisFunction *fcn, RZ_NONNULL RzAnalysisVarStorage *stor); +RZ_API RZ_BORROW RzAnalysisVar *rz_analysis_function_get_stack_var_at(RzAnalysisFunction *fcn, RzStackAddr stack_off); +RZ_API RZ_BORROW RzAnalysisVar *rz_analysis_function_get_reg_var_at(RzAnalysisFunction *fcn, RZ_NONNULL const char *reg); +RZ_API RZ_BORROW RzAnalysisVar *rz_analysis_function_get_stack_var_in(RzAnalysisFunction *fcn, RzStackAddr stack_off); +RZ_API RZ_BORROW RzAnalysisVar *rz_analysis_function_get_var_byname(RzAnalysisFunction *fcn, const char *name); +RZ_API void rz_analysis_function_delete_vars_by_storage_type(RzAnalysisFunction *fcn, RzAnalysisVarStorageType stor); +RZ_API void rz_analysis_function_delete_arg_vars(RzAnalysisFunction *fcn); +RZ_API void rz_analysis_function_delete_all_vars(RzAnalysisFunction *fcn); +RZ_API void rz_analysis_function_delete_unused_vars(RzAnalysisFunction *fcn); +RZ_API void rz_analysis_function_delete_var(RzAnalysisFunction *fcn, RzAnalysisVar *var); +RZ_API RZ_NULLABLE char *rz_analysis_function_var_expr_for_reg_access_at(RzAnalysisFunction *fcn, ut64 addr, RZ_NONNULL const char *reg, st64 reg_addend); +RZ_API RZ_BORROW RzPVector /**/ *rz_analysis_function_get_vars_used_at(RzAnalysisFunction *fcn, ut64 op_addr); + +/* var */ +// There could be multiple vars used in multiple functions. Use rz_analysis_get_functions_in()+rz_analysis_function_get_vars_used_at() instead. +RZ_DEPRECATE RZ_API RzAnalysisVar *rz_analysis_get_used_function_var(RzAnalysis *analysis, ut64 addr); + +RZ_API bool rz_analysis_var_is_arg(RZ_NONNULL RzAnalysisVar *var); +RZ_API size_t rz_analysis_var_local_count(RZ_NONNULL RzAnalysisFunction *fcn); +RZ_API size_t rz_analysis_arg_count(RZ_NONNULL RzAnalysisFunction *fcn); +RZ_API void rz_analysis_var_init(RZ_BORROW RzAnalysisVar *var); +RZ_API void rz_analysis_var_fini(RZ_OWN RzAnalysisVar *var); +RZ_API RZ_OWN RzAnalysisVar *rz_analysis_var_new(); +RZ_API void rz_analysis_var_free(RZ_OWN RzAnalysisVar *var); +RZ_API bool rz_analysis_var_rename(RzAnalysisVar *var, const char *new_name, bool verbose); +RZ_API void rz_analysis_var_resolve_overlaps(RzAnalysisVar *var); +RZ_API ut64 rz_analysis_var_size(const RzAnalysis *analysis, RZ_NONNULL RzAnalysisVar *var); +RZ_API void rz_analysis_var_set_type(RzAnalysisVar *var, RZ_OWN RzType *type, bool resolve_overlaps); +RZ_API void rz_analysis_var_delete(RzAnalysisVar *var); +RZ_API void rz_analysis_var_set_access(RzAnalysisVar *var, const char *reg, ut64 access_addr, int access_type, st64 reg_addend); +RZ_API void rz_analysis_var_remove_access_at(RzAnalysisVar *var, ut64 address); +RZ_API void rz_analysis_var_clear_accesses(RzAnalysisVar *var); +RZ_API void rz_analysis_var_add_constraint(RzAnalysisVar *var, RZ_BORROW RzTypeConstraint *constraint); +RZ_API char *rz_analysis_var_get_constraints_readable(RzAnalysisVar *var); + +RZ_API int rz_analysis_var_storage_cmp( + RZ_NONNULL const RzAnalysisVarStorage *a, + RZ_NONNULL const RzAnalysisVarStorage *b); +RZ_API bool rz_analysis_var_storage_equals( + RZ_NONNULL const RzAnalysisVarStorage *a, + RZ_NONNULL const RzAnalysisVarStorage *b); + +// Get the access to var at exactly addr if there is one +RZ_API RzAnalysisVarAccess *rz_analysis_var_get_access_at(RzAnalysisVar *var, ut64 addr); + +RZ_API int rz_analysis_var_get_argnum(RzAnalysisVar *var); + +RZ_API void rz_analysis_extract_vars(RzAnalysis *analysis, RzAnalysisFunction *fcn, RzAnalysisOp *op, RzStackAddr sp); +RZ_API void rz_analysis_extract_rarg(RzAnalysis *analysis, RzAnalysisOp *op, RzAnalysisFunction *fcn, int *reg_set, int *count); + +RZ_API const char *rz_analysis_var_storage_type_to_string(RzAnalysisVarStorageType type); +RZ_API bool rz_analysis_var_storage_type_from_string( + RZ_NONNULL const char *type_str, + RZ_NONNULL RZ_BORROW RZ_OUT RzAnalysisVarStorageType *type); +RZ_API void rz_analysis_var_storage_dump( + RZ_NONNULL RZ_BORROW RzAnalysis *a, + RZ_NONNULL RZ_BORROW RZ_OUT RzStrBuf *sb, + RZ_NULLABLE RZ_BORROW const RzAnalysisVar *var, + RZ_NONNULL RZ_BORROW const RzAnalysisVarStorage *storage); +RZ_API void rz_analysis_var_storage_dump_pj( + RZ_NONNULL RZ_BORROW RZ_OUT PJ *pj, + RZ_NONNULL RZ_BORROW const RzAnalysisVar *var, + RZ_NONNULL RZ_BORROW const RzAnalysisVarStorage *storage); +RZ_API RZ_OWN char *rz_analysis_var_storage_to_string( + RZ_NONNULL RZ_BORROW RzAnalysis *a, + RZ_NULLABLE RZ_BORROW const RzAnalysisVar *var, + RZ_NONNULL RZ_BORROW const RzAnalysisVarStorage *storage); +RZ_API void rz_analysis_var_storage_poolify( + RZ_NONNULL RZ_BORROW RzAnalysis *analysis, + RZ_NONNULL RZ_BORROW RZ_OUT RzAnalysisVarStorage *stor); +RZ_API void rz_analysis_var_storage_piece_fini(RzAnalysisVarStoragePiece *p); +RZ_API void rz_analysis_var_storage_fini(RzAnalysisVarStorage *sto); +RZ_API void rz_analysis_var_storage_free(RzAnalysisVarStorage *sto); + +// Get the variable that var is written to at one of its accesses +// Useful for cases where a register-based argument is written away into a stack variable, +// so if var is the reg arg then this will return the stack var. +RZ_API RzAnalysisVar *rz_analysis_var_get_dst_var(RzAnalysisVar *var); + +typedef struct rz_analysis_fcn_vars_cache { + RzList /**/ *sorted_vars; + RzList /**/ *arg_vars; +} RzAnalysisFcnVarsCache; +RZ_API void rz_analysis_fcn_vars_cache_init( + RZ_NONNULL RZ_BORROW RzAnalysis *analysis, + RZ_NONNULL RZ_BORROW RZ_OUT RzAnalysisFcnVarsCache *cache, + RZ_NONNULL RZ_BORROW RzAnalysisFunction *fcn); +RZ_API RZ_OWN RzAnalysisFcnVarsCache *rz_analysis_fcn_vars_cache_from_fcn( + RZ_NONNULL RZ_BORROW RzAnalysis *analysis, + RZ_NONNULL RZ_BORROW RzAnalysisFunction *fcn); +RZ_API void rz_analysis_fcn_vars_cache_fini(RzAnalysisFcnVarsCache *cache); + +RZ_API char *rz_analysis_fcn_format_sig(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn, RZ_NULLABLE char *fcn_name, + RZ_NULLABLE RzAnalysisFcnVarsCache *reuse_cache, RZ_NULLABLE const char *fcn_name_pre, RZ_NULLABLE const char *fcn_name_post); + +RZ_API void rz_analysis_fcn_vars_add_types(RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn); + +// Global vars +RZ_API RZ_OWN RzAnalysisVarGlobal *rz_analysis_var_global_new(RZ_NONNULL const char *name, ut64 addr); +RZ_API bool rz_analysis_var_global_add(RzAnalysis *analysis, RZ_NONNULL RzAnalysisVarGlobal *global_var); +RZ_API bool rz_analysis_var_global_create_with_sourceline(RzAnalysis *analysis, + RZ_NONNULL const char *name, RZ_NONNULL RZ_BORROW RzType *type, ut64 addr, + RZ_NULLABLE const char *file, ut32 line, ut32 colum); +RZ_API bool rz_analysis_var_global_create(RzAnalysis *analysis, + RZ_NONNULL const char *name, RZ_NONNULL RZ_BORROW RzType *type, ut64 addr); +RZ_API void rz_analysis_var_global_free(RzAnalysisVarGlobal *glob); + +RZ_API RZ_NULLABLE RzFlagItem *rz_analysis_var_global_get_flag_item(RzAnalysisVarGlobal *glob); +RZ_API bool rz_analysis_var_global_delete(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisVarGlobal *glob); +RZ_API bool rz_analysis_var_global_delete_byname(RzAnalysis *analysis, RZ_NONNULL const char *name); +RZ_API bool rz_analysis_var_global_delete_byaddr_at(RzAnalysis *analysis, ut64 addr); +RZ_API bool rz_analysis_var_global_delete_byaddr_in(RzAnalysis *analysis, ut64 addr); +RZ_API RZ_BORROW RzAnalysisVarGlobal *rz_analysis_var_global_get_byname(RzAnalysis *analysis, RZ_NONNULL const char *name); +RZ_API RZ_BORROW RzAnalysisVarGlobal *rz_analysis_var_global_get_byaddr_at(RzAnalysis *analysis, ut64 addr); +RZ_API RZ_BORROW RzAnalysisVarGlobal *rz_analysis_var_global_get_byaddr_in(RzAnalysis *analysis, ut64 addr); +RZ_API RZ_OWN RzList /**/ *rz_analysis_var_global_get_all(RzAnalysis *analysis); +RZ_API bool rz_analysis_var_global_rename(RzAnalysis *analysis, RZ_NONNULL const char *old_name, RZ_NONNULL const char *newname); +RZ_API void rz_analysis_var_global_set_type(RzAnalysisVarGlobal *glob, RZ_NONNULL RZ_BORROW RzType *type); +RZ_API void rz_analysis_var_global_add_constraint(RzAnalysisVarGlobal *glob, RzTypeConstraint *constraint); +RZ_API RZ_OWN char *rz_analysis_var_global_get_constraints_readable(RzAnalysisVarGlobal *glob); +RZ_API RZ_OWN RzList /**/ *rz_analysis_var_global_xrefs(RzAnalysis *analysis, RZ_NONNULL const RzAnalysisVarGlobal *glob); +RZ_API RZ_OWN RzList /**/ *rz_analysis_type_paths_by_address(RzAnalysis *analysis, ut64 addr); + +/* project */ +RZ_API bool rz_analysis_xrefs_init(RzAnalysis *analysis); + +/* similarity.c */ +typedef enum { + RZ_ANALYSIS_SIMILARITY_COMPLETE = 'c', + RZ_ANALYSIS_SIMILARITY_PARTIAL = 'p', + RZ_ANALYSIS_SIMILARITY_UNLIKE = 'u' +} RzAnalysisSimilarity; + +#define RZ_ANALYSIS_SIMILARITY_COMPLETE_STR "COMPLETE" +#define RZ_ANALYSIS_SIMILARITY_PARTIAL_STR "PARTIAL" +#define RZ_ANALYSIS_SIMILARITY_UNLIKE_STR "UNLIKE" + +typedef struct rz_analysis_match_info_t { + ut32 queue_len; ///< Total number of element left in the queue. + ut32 percentage; ///< Progress made by the search thread. +} RzAnalysisMatchThreadInfo; + +typedef bool (*RzAnalysisMatchThreadInfoCb)(const size_t n_left, const size_t n_matches, void *user); + +typedef struct rz_analysis_match_options_t { + RZ_NONNULL RzAnalysis *analysis_a; ///< Analysis context for the first input + RZ_NONNULL RzAnalysis *analysis_b; ///< Analysis context for the second input (can be the same as analysis_a) + RzAnalysisMatchThreadInfoCb callback; ///< When set allows to get the thread information + void *user; ///< User pointer to pass to the callback function for the thread info +} RzAnalysisMatchOpt; + +typedef struct rz_analysis_match_pair_t { + const void *pair_a; ///< Match pair from input A (the pointers are either RzAnalysisBlock or RzAnalysisFunction) + const void *pair_b; ///< Match pair from input B (the pointers are either RzAnalysisBlock or RzAnalysisFunction) + double similarity; ///< Similarity score (from 0 to 1.0, where 1 is perfect match and 0 is complete mismatch) +} RzAnalysisMatchPair; + +typedef struct rz_analysis_match_result_t { + RzList /**/ *matches; ///< List of matched pairs between input A and B + RzList /**/ *unmatch_a; ///< List of unmatched elements from input A (the pointers are either RzAnalysisBlock or RzAnalysisFunction) + RzList /**/ *unmatch_b; ///< List of unmatched elements from input B (the pointers are either RzAnalysisBlock or RzAnalysisFunction) +} RzAnalysisMatchResult; + +#define RZ_ANALYSIS_SIMILARITY_THRESHOLD (0.5) + +#define RZ_ANALYSIS_SIMILARITY_TYPE(sim) \ + (sim < RZ_ANALYSIS_SIMILARITY_THRESHOLD ? RZ_ANALYSIS_SIMILARITY_UNLIKE : (sim >= 1.0 ? RZ_ANALYSIS_SIMILARITY_COMPLETE : RZ_ANALYSIS_SIMILARITY_PARTIAL)) + +#define RZ_ANALYSIS_SIMILARITY_TYPE_STR(sim) \ + (sim < RZ_ANALYSIS_SIMILARITY_THRESHOLD ? RZ_ANALYSIS_SIMILARITY_UNLIKE_STR : (sim >= 1.0 ? RZ_ANALYSIS_SIMILARITY_COMPLETE_STR : RZ_ANALYSIS_SIMILARITY_PARTIAL_STR)) + +RZ_API double rz_analysis_similarity_basic_block(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisBlock *bb_a, RZ_NONNULL RzAnalysisBlock *bb_b); +RZ_API double rz_analysis_similarity_function(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn_a, RZ_NONNULL RzAnalysisFunction *fcn_b); +RZ_API double rz_analysis_similarity_basic_block_2(RZ_NONNULL RzAnalysis *analysis_a, RZ_NONNULL RzAnalysisBlock *bb_a, RZ_NONNULL RzAnalysis *analysis_b, RZ_NONNULL RzAnalysisBlock *bb_b); +RZ_API double rz_analysis_similarity_function_2(RZ_NONNULL RzAnalysis *analysis_a, RZ_NONNULL RzAnalysisFunction *fcn_a, RZ_NONNULL RzAnalysis *analysis_b, RZ_NONNULL RzAnalysisFunction *fcn_b); +RZ_API RZ_OWN RzAnalysisMatchResult *rz_analysis_match_basic_blocks(RZ_NONNULL RzAnalysisFunction *fcn_a, RZ_NONNULL RzAnalysisFunction *fcn_b, RZ_NONNULL RzAnalysisMatchOpt *opt); +RZ_API RZ_OWN RzAnalysisMatchResult *rz_analysis_match_functions(RzList /**/ *list_a, RzList /**/ *list_b, RZ_NONNULL RzAnalysisMatchOpt *opt); +RZ_API bool rz_analysis_function_eq(RZ_NONNULL RzAnalysisFunction *fcn_a, RZ_NONNULL RzAnalysisFunction *fcn_b); +RZ_API void rz_analysis_match_result_free(RZ_NULLABLE RzAnalysisMatchResult *result); + +/* value.c */ +RZ_API RzAnalysisValue *rz_analysis_value_new(void); +RZ_API RzAnalysisValue *rz_analysis_value_copy(RzAnalysisValue *ov); +RZ_API char *rz_analysis_value_to_string(RzAnalysisValue *value); +RZ_API ut64 rz_analysis_value_to_ut64(RzAnalysis *analysis, RzAnalysisValue *val); +RZ_API int rz_analysis_value_set_ut64(RzAnalysis *analysis, RzAnalysisValue *val, ut64 num); +#define rz_analysis_value_free free + +RZ_API RzAnalysisCond *rz_analysis_cond_new(void); +RZ_API RzAnalysisCond *rz_analysis_cond_new_from_op(RzAnalysisOp *op); +RZ_API void rz_analysis_cond_fini(RzAnalysisCond *c); +RZ_API void rz_analysis_cond_free(RzAnalysisCond *c); +RZ_API char *rz_analysis_cond_to_string(RzAnalysisCond *cond); +RZ_API int rz_analysis_cond_eval(RzAnalysis *analysis, RzAnalysisCond *cond); +RZ_API RzAnalysisCond *rz_analysis_cond_new_from_string(const char *str); + +/* jmptbl */ +RZ_API bool rz_analysis_jmptbl(RzAnalysis *analysis, RzAnalysisFunction *fcn, RzAnalysisBlock *block, ut64 jmpaddr, ut64 table, ut64 tablesize, ut64 default_addr, RzStackAddr sp); + +typedef struct rz_jmptable_params_t { + ut64 jmp_address; ///< Address of the jump instruction + st64 case_shift; ///< Shift that is added to get the real number of the case. + ut64 jmptbl_loc; ///< Address of the jump table + ut64 casetbl_loc; ///< Address of the indirect case table + ut64 jmptbl_off; ///< Base of the jump table + ut64 entry_size; ///< Size in bytes of each case entry inside the jump table + ut64 table_count; ///< Count of cases inside the jump table + ut64 default_case; ///< Code address of the default case of the switch + RzStackAddr sp; ///< Value of the stack pointer after the jump instruction is executed + RzVector /**/ *tasks; /// RzVector of RzAnalysisTaskItem to add new tasks to +} RzAnalysisJmpTableParams; + +RZ_API bool rz_analysis_get_delta_jmptbl_info(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn, ut64 jmp_address, ut64 lea_address, RZ_NONNULL RzAnalysisJmpTableParams *params); +RZ_API bool rz_analysis_get_jmptbl_info(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn, RZ_NONNULL RzAnalysisBlock *block, ut64 jmp_address, RZ_NONNULL RzAnalysisJmpTableParams *params); +RZ_API bool rz_analysis_walkthrough_jmptbl(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn, RZ_NONNULL RzAnalysisBlock *block, RZ_NONNULL RzAnalysisJmpTableParams *params); +RZ_API bool rz_analysis_walkthrough_casetbl(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn, RZ_NONNULL RzAnalysisBlock *block, RZ_NONNULL RzAnalysisJmpTableParams *params); +RZ_API bool rz_analysis_walkthrough_arm_jmptbl_style(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn, RZ_NONNULL RzAnalysisBlock *block, RZ_NONNULL RzAnalysisJmpTableParams *params); +RZ_API bool rz_analysis_walkthrough_arm_thumb1_case_uqi_table(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn, RZ_NONNULL RzAnalysisBlock *block, RZ_NONNULL RzAnalysisJmpTableParams *params); + +/* reflines.c */ +RZ_API RZ_OWN RzPVector /**/ *rz_analysis_reflines_get(RZ_NONNULL RzAnalysis *analysis, ut64 addr, RZ_NONNULL const ut8 *buf, ut64 len, int nlines, int linesout, int linescall); +RZ_API bool rz_analysis_reflines_middle(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL const RzPVector /**/ *reflines, ut64 addr, int len); +RZ_API RzAnalysisRefStr *rz_analysis_reflines_str(void *core, ut64 addr, int opts); +RZ_API void rz_analysis_reflines_str_free(RzAnalysisRefStr *refstr); +RZ_API RZ_OWN RzList /**/ *rz_analysis_var_list(RZ_NONNULL RzAnalysisFunction *fcn, RzAnalysisVarStorageType kind); + +// calling conventions API +RZ_API bool rz_analysis_cc_exist(RzAnalysis *analysis, const char *convention); +RZ_API void rz_analysis_cc_del(RzAnalysis *analysis, const char *name); +RZ_API bool rz_analysis_cc_set(RzAnalysis *analysis, const char *expr); +RZ_API char *rz_analysis_cc_get(RzAnalysis *analysis, const char *name); +RZ_API const char *rz_analysis_cc_arg(RzAnalysis *analysis, const char *convention, int n); +RZ_API const char *rz_analysis_cc_self(RzAnalysis *analysis, const char *convention); +RZ_API void rz_analysis_cc_set_self(RzAnalysis *analysis, const char *convention, const char *self); +RZ_API const char *rz_analysis_cc_error(RzAnalysis *analysis, const char *convention); +RZ_API void rz_analysis_cc_set_error(RzAnalysis *analysis, const char *convention, const char *error); +RZ_API int rz_analysis_cc_max_arg(RzAnalysis *analysis, const char *cc); +RZ_API const char *rz_analysis_cc_ret(RzAnalysis *analysis, const char *convention); +RZ_API RzStackAddr rz_analysis_cc_shadow_store(RzAnalysis *analysis, const char *convention); +RZ_API const char *rz_analysis_cc_default(RzAnalysis *analysis); +RZ_API void rz_analysis_set_cc_default(RzAnalysis *analysis, const char *convention); +RZ_API const char *rz_analysis_syscc_default(RzAnalysis *analysis); +RZ_API void rz_analysis_set_syscc_default(RzAnalysis *analysis, const char *convention); +RZ_API const char *rz_analysis_cc_func(RzAnalysis *analysis, const char *func_name); +RZ_API RzList /**/ *rz_analysis_calling_conventions(RzAnalysis *analysis); + +typedef struct rz_analysis_data_t { + ut64 addr; + int type; + ut64 ptr; + char *str; + int len; + ut8 *buf; + ut8 sbuf[8]; +} RzAnalysisData; + +typedef enum { + RZ_ANALYSIS_DATA_KIND_UNKNOWN = 0, + RZ_ANALYSIS_DATA_KIND_INVALID, + RZ_ANALYSIS_DATA_KIND_CODE, + RZ_ANALYSIS_DATA_KIND_STRING, + RZ_ANALYSIS_DATA_KIND_DATA, +} RzAnalysisDataKind; + +RZ_API RZ_OWN RzAnalysisData *rz_analysis_data(RZ_NONNULL RzAnalysis *analysis, ut64 addr, RZ_NONNULL const ut8 *buf, size_t size, int wordsize); +RZ_API RzAnalysisDataKind rz_analysis_data_kind(RZ_NONNULL RzAnalysis *a, ut64 addr, RZ_NONNULL const ut8 *buf, size_t len); +RZ_API RzAnalysisData *rz_analysis_data_new(ut64 addr, RzAnalysisDataInfoType type, ut64 n, const ut8 *buf, int len); +RZ_API void rz_analysis_data_free(RZ_NULLABLE RzAnalysisData *d); +#include +RZ_API char *rz_analysis_data_to_string(RzAnalysisData *d, RzConsPrintablePalette *pal); + +/* meta + * + * Meta uses Condret's Klemmbaustein Priciple, i.e. intervals are defined inclusive/inclusive. + * A meta item from 0x42 to 0x42 has a size of 1. Items with size 0 do not exist. + * Meta items are allowed to overlap and the internal data structure allows for multiple meta items + * starting at the same address. + * Meta items are saved in an RzIntervalTree. To access the interval of an item, use the members of RzIntervalNode. + */ + +static inline ut64 rz_meta_item_size(ut64 start, ut64 end) { + // meta items use inclusive/inclusive intervals + return end - start + 1; +} + +static inline ut64 rz_meta_node_size(RzIntervalNode *node) { + return rz_meta_item_size(node->start, node->end); +} + +// Set a meta item at addr with the given contents in the current space. +// If there already exists an item with this type and space at addr (regardless of its size) it will be overwritten. +RZ_API bool rz_meta_set(RzAnalysis *a, RzAnalysisMetaType type, ut64 addr, ut64 size, const char *str); + +// Same as rz_meta_set() but also sets the subtype. +RZ_API bool rz_meta_set_with_subtype(RzAnalysis *m, RzAnalysisMetaType type, int subtype, ut64 addr, ut64 size, const char *str); + +// Delete all meta items in the current space that intersect with the given interval. +// If size == UT64_MAX, everything in the current space will be deleted. +RZ_API void rz_meta_del(RzAnalysis *a, RzAnalysisMetaType type, ut64 addr, ut64 size); + +// Same as rz_meta_set() with a size of 1. +RZ_API bool rz_meta_set_string(RzAnalysis *a, RzAnalysisMetaType type, ut64 addr, RZ_NULLABLE const char *s); + +// Convenience function to get the str content of the item at addr with given type in the current space. +RZ_API const char *rz_meta_get_string(RzAnalysis *a, RzAnalysisMetaType type, ut64 addr); + +// Convenience function to add an RZ_META_TYPE_DATA item at the given addr in the current space. +RZ_API void rz_meta_set_data_at(RzAnalysis *a, ut64 addr, ut64 wordsz); + +// Returns the item with given type that starts at addr in the current space or NULL. The size of this item optionally returned through size. +RZ_API RzAnalysisMetaItem *rz_meta_get_at(RzAnalysis *a, ut64 addr, RzAnalysisMetaType type, RZ_OUT RZ_NULLABLE ut64 *size); + +// Returns the node for one meta item with the given type that contains addr in the current space or NULL. +// To get all the nodes, use rz_meta_get_all_in(). +RZ_API RzIntervalNode *rz_meta_get_in(RzAnalysis *a, ut64 addr, RzAnalysisMetaType type); + +// Returns all nodes for items starting at the given address in the current space. +RZ_API RzPVector /* *>*/ *rz_meta_get_all_at(RzAnalysis *a, ut64 at); + +// Returns all nodes for items with the given type containing the given address in the current space. +RZ_API RzPVector /* *>*/ *rz_meta_get_all_in(RzAnalysis *a, ut64 at, RzAnalysisMetaType type); + +// Returns all nodes for items with the given type intersecting the given interval in the current space. +RZ_API RzPVector /* *>*/ *rz_meta_get_all_intersect(RzAnalysis *a, ut64 start, ut64 size, RzAnalysisMetaType type); + +// Delete all meta items in the given space +RZ_API void rz_meta_space_unset_for(RzAnalysis *a, const RzSpace *space); + +// Returns the number of meta items in the given space +RZ_API int rz_meta_space_count_for(RzAnalysis *a, const RzSpace *space); + +// Shift all meta items by the given delta, for rebasing between different memory layouts. +RZ_API void rz_meta_rebase(RzAnalysis *analysis, ut64 diff); + +// Calculate the total size covered by meta items of the given type. +RZ_API ut64 rz_meta_get_size(RzAnalysis *a, RzAnalysisMetaType type); + +RZ_API const char *rz_meta_type_to_string(int type); + +/* hints */ + +RZ_API void rz_analysis_hint_del(RzAnalysis *analysis, ut64 addr, ut64 size); // delete all hints that are contained within the given range, if size > 1, this operation is quite heavy! +RZ_API void rz_analysis_hint_clear(RzAnalysis *a); +RZ_API void rz_analysis_hint_free(RzAnalysisHint *h); +RZ_API void rz_analysis_hint_set_syntax(RzAnalysis *a, ut64 addr, const char *syn); +RZ_API void rz_analysis_hint_set_type(RzAnalysis *a, ut64 addr, int type); +RZ_API void rz_analysis_hint_set_jump(RzAnalysis *a, ut64 addr, ut64 jump); +RZ_API void rz_analysis_hint_set_fail(RzAnalysis *a, ut64 addr, ut64 fail); +RZ_API void rz_analysis_hint_set_newbits(RzAnalysis *a, ut64 addr, int bits); +RZ_API void rz_analysis_hint_set_nword(RzAnalysis *a, ut64 addr, int nword); +RZ_API void rz_analysis_hint_set_offset(RzAnalysis *a, ut64 addr, const char *typeoff); +RZ_API void rz_analysis_hint_set_immbase(RzAnalysis *a, ut64 addr, int base); +RZ_API void rz_analysis_hint_set_size(RzAnalysis *a, ut64 addr, ut64 size); +RZ_API void rz_analysis_hint_set_opcode(RzAnalysis *a, ut64 addr, const char *str); +RZ_API void rz_analysis_hint_set_esil(RzAnalysis *a, ut64 addr, const char *str); +RZ_API void rz_analysis_hint_set_pointer(RzAnalysis *a, ut64 addr, ut64 ptr); +RZ_API void rz_analysis_hint_set_ret(RzAnalysis *a, ut64 addr, ut64 val); +RZ_API void rz_analysis_hint_set_high(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_set_stackframe(RzAnalysis *a, ut64 addr, ut64 size); +RZ_API void rz_analysis_hint_set_val(RzAnalysis *a, ut64 addr, ut64 v); +RZ_API void rz_analysis_hint_set_arch(RzAnalysis *a, ut64 addr, RZ_NULLABLE const char *arch); // arch == NULL => use global default +RZ_API void rz_analysis_hint_set_bits(RzAnalysis *a, ut64 addr, int bits); // bits == NULL => use global default +RZ_API void rz_analysis_hint_unset_val(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_high(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_immbase(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_nword(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_size(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_type(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_esil(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_opcode(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_syntax(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_pointer(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_ret(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_offset(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_jump(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_fail(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_newbits(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_stackframe(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_arch(RzAnalysis *a, ut64 addr); +RZ_API void rz_analysis_hint_unset_bits(RzAnalysis *a, ut64 addr); +RZ_API RZ_NULLABLE const RzVector /**/ *rz_analysis_addr_hints_at(RzAnalysis *analysis, ut64 addr); +typedef bool (*RzAnalysisAddrHintRecordsCb)(ut64 addr, const RzVector /**/ *records, void *user); +RZ_API void rz_analysis_addr_hints_foreach(RzAnalysis *analysis, RzAnalysisAddrHintRecordsCb cb, void *user); +typedef bool (*RzAnalysisArchHintCb)(ut64 addr, RZ_NULLABLE const char *arch, void *user); +RZ_API void rz_analysis_arch_hints_foreach(RzAnalysis *analysis, RzAnalysisArchHintCb cb, void *user); +typedef bool (*RzAnalysisBitsHintCb)(ut64 addr, int bits, void *user); +RZ_API void rz_analysis_bits_hints_foreach(RzAnalysis *analysis, RzAnalysisBitsHintCb cb, void *user); + +// get the hint-specified arch value to be considered at addr +// hint_addr will optionally be set to the address where the hint that specifies this arch is placed or UT64_MAX +// if there is no hint affecting addr. +RZ_API RZ_NULLABLE RZ_BORROW const char *rz_analysis_hint_arch_at(RzAnalysis *analysis, ut64 addr, RZ_NULLABLE ut64 *hint_addr); + +// get the hint-specified bits value to be considered at addr +// hint_addr will optionally be set to the address where the hint that specifies this arch is placed or UT64_MAX +// if there is no hint affecting addr. +RZ_API int rz_analysis_hint_bits_at(RzAnalysis *analysis, ut64 addr, RZ_NULLABLE ut64 *hint_addr); + +RZ_API RzAnalysisHint *rz_analysis_hint_get(RzAnalysis *analysis, ut64 addr); // accumulate all available hints affecting the given address + +/* switch.c APIs */ +RZ_API RzAnalysisSwitchOp *rz_analysis_switch_op_new(ut64 addr, ut64 min_val, ut64 max_val, ut64 def_val); +RZ_API void rz_analysis_switch_op_free(RzAnalysisSwitchOp *swop); +RZ_API RzAnalysisCaseOp *rz_analysis_switch_op_add_case(RzAnalysisSwitchOp *swop, ut64 addr, ut64 value, ut64 jump); + +/* cycles.c */ +RZ_API RzAnalysisCycleFrame *rz_analysis_cycle_frame_new(void); +RZ_API void rz_analysis_cycle_frame_free(RzAnalysisCycleFrame *cf); + +/* labels */ +RZ_API ut64 rz_analysis_function_get_label(RzAnalysisFunction *fcn, const char *name); +RZ_API const char *rz_analysis_function_get_label_at(RzAnalysisFunction *fcn, ut64 addr); +RZ_API bool rz_analysis_function_set_label(RzAnalysisFunction *fcn, const char *name, ut64 addr); +RZ_API bool rz_analysis_function_delete_label(RzAnalysisFunction *fcn, const char *name); +RZ_API bool rz_analysis_function_delete_label_at(RzAnalysisFunction *fcn, ut64 addr); + +/* limits */ +RZ_API void rz_analysis_set_limits(RzAnalysis *analysis, ut64 from, ut64 to); +RZ_API void rz_analysis_unset_limits(RzAnalysis *analysis); + +/* no-return stuff */ +RZ_API bool rz_analysis_noreturn_add(RzAnalysis *analysis, const char *name, ut64 addr); +RZ_API bool rz_analysis_noreturn_drop(RzAnalysis *analysis, const char *expr); +RZ_API bool rz_analysis_noreturn_at_addr(RzAnalysis *analysis, ut64 addr); +RZ_API bool rz_analysis_noreturn_at(RzAnalysis *analysis, ut64 addr); +RZ_API RzList /**/ *rz_analysis_noreturn_functions(RzAnalysis *analysis); + +/* vtables */ +typedef struct { + RzAnalysis *analysis; + RzAnalysisCPPABI abi; + ut8 word_size; + bool (*read_addr)(RzAnalysis *analysis, ut64 addr, ut64 *buf); +} RVTableContext; + +typedef struct vtable_info_t { + ut64 saddr; // starting address + RzVector /**/ methods; +} RVTableInfo; + +typedef struct vtable_method_info_t { + ut64 addr; // addr of the function + ut64 vtable_offset; // offset inside the vtable +} RVTableMethodInfo; + +RZ_API void rz_analysis_vtable_info_free(RVTableInfo *vtable); +RZ_API ut64 rz_analysis_vtable_info_get_size(RVTableContext *context, RVTableInfo *vtable); +RZ_API bool rz_analysis_vtable_begin(RzAnalysis *analysis, RVTableContext *context); +RZ_API RVTableInfo *rz_analysis_vtable_parse_at(RVTableContext *context, ut64 addr); +RZ_API RzList /**/ *rz_analysis_vtable_search(RVTableContext *context); +RZ_API void rz_analysis_list_vtables(RzAnalysis *analysis, RzOutputMode mode); + +/* rtti */ +RZ_API char *rz_analysis_rtti_msvc_demangle_class_name(RVTableContext *context, const char *name); +RZ_API void rz_analysis_rtti_msvc_print_complete_object_locator(RVTableContext *context, ut64 addr, int mode); +RZ_API void rz_analysis_rtti_msvc_print_type_descriptor(RVTableContext *context, ut64 addr, int mode); +RZ_API void rz_analysis_rtti_msvc_print_class_hierarchy_descriptor(RVTableContext *context, ut64 addr, int mode); +RZ_API void rz_analysis_rtti_msvc_print_base_class_descriptor(RVTableContext *context, ut64 addr, int mode); +RZ_API bool rz_analysis_rtti_msvc_print_at_vtable(RVTableContext *context, ut64 addr, RzOutputMode mode, bool strict); +RZ_API void rz_analysis_rtti_msvc_recover_all(RVTableContext *vt_context, RzList /**/ *vtables); +RZ_API void rz_analysis_rtti_swift(RzAnalysis *analysis); + +RZ_API char *rz_analysis_rtti_itanium_demangle_class_name(RVTableContext *context, const char *name); +RZ_API bool rz_analysis_rtti_itanium_print_at_vtable(RVTableContext *context, ut64 addr, RzOutputMode mode); +RZ_API void rz_analysis_rtti_itanium_recover_all(RVTableContext *vt_context, RzList /**/ *vtables); +RZ_API void rz_analysis_no_rtti_analysis(RZ_NONNULL RVTableContext *context, RZ_NONNULL RzList /**/ *vtables); + +RZ_API char *rz_analysis_rtti_demangle_class_name(RzAnalysis *analysis, const char *name); +RZ_API void rz_analysis_rtti_print_at_vtable(RzAnalysis *analysis, ut64 addr, RzOutputMode mode); +RZ_API void rz_analysis_rtti_print_all(RzAnalysis *analysis, RzOutputMode mode); +RZ_API void rz_analysis_rtti_recover_all(RzAnalysis *analysis); + +RZ_API RzList /**/ *rz_analysis_preludes(RzAnalysis *analysis); +RZ_API bool rz_analysis_is_prelude(RzAnalysis *analysis, const ut8 *data, int len); + +/* devirualize */ +typedef struct rz_variable_book_t { + RzAnalysisFunction *function; ///< function to analyze + HtUP /**/ *class_variables; ///< hash map of stack address and variables that store objects + RzList /**/ *stack_variables; ///< list of all stack variables + RzList /**/ *class_var_list; ///< list of all variables that store objects +} RzCppVariableBook; + +RZ_API RzCppVariableBook *rz_analysis_mark_classes(RzAnalysis *analysis); +RZ_API void rz_analysis_devirtualize_cxx_methods(RzAnalysis *analysis); +RZ_API void rz_analysis_devirtualize_objc_methods(RZ_NULLABLE RzCore *core); +RZ_API void rz_analysis_devirtualize(RzAnalysis *analysis, RzCppVariableBook *var_book); +RZ_API void rz_analysis_virtual_xrefs_print(RzAnalysis *analysis, const char *vfunc); +RZ_API void rz_analysis_virtual_xrefs_print_table(RzAnalysis *analysis, const char *vfunc, RzTable *table); + +/* classes */ +typedef enum { + RZ_ANALYSIS_CLASS_METHOD_DEFAULT = 0, + RZ_ANALYSIS_CLASS_METHOD_VIRTUAL, + RZ_ANALYSIS_CLASS_METHOD_VIRTUAL_DESTRUCTOR, + RZ_ANALYSIS_CLASS_METHOD_DESTRUCTOR, + RZ_ANALYSIS_CLASS_METHOD_CONSTRUCTOR +} RzAnalysisMethodType; + +typedef struct rz_analysis_method_t { + char *name; + char *real_name; + ut64 addr; + st64 vtable_offset; // >= 0 if method is virtual, else -1 + RzAnalysisMethodType method_type; +} RzAnalysisMethod; + +typedef struct rz_analysis_base_class_t { + char *id; // id to identify the class attr + ut64 offset; // offset of the base class inside the derived class + char *class_name; +} RzAnalysisBaseClass; + +typedef struct rz_analysis_vtable_t { + char *id; // id to identify the class attr + ut64 offset; // offset inside the class + ut64 addr; // where the content of the vtable is + ut64 size; // size (in bytes) of the vtable +} RzAnalysisVTable; + +typedef enum { + RZ_ANALYSIS_CLASS_ERR_SUCCESS = 0, + RZ_ANALYSIS_CLASS_ERR_CLASH, + RZ_ANALYSIS_CLASS_ERR_NONEXISTENT_ATTR, + RZ_ANALYSIS_CLASS_ERR_NONEXISTENT_CLASS, + RZ_ANALYSIS_CLASS_ERR_OTHER +} RzAnalysisClassErr; + +RZ_API void rz_analysis_class_recover_from_rzbin(RzAnalysis *analysis); +RZ_API void rz_analysis_class_recover_all(RzAnalysis *analysis); +RZ_API RzAnalysisClassErr rz_analysis_class_create(RzAnalysis *analysis, const char *name); +RZ_API void rz_analysis_class_delete(RzAnalysis *analysis, const char *name); +RZ_API bool rz_analysis_class_exists(RzAnalysis *analysis, const char *name); +RZ_API RZ_OWN RzPVector /**/ *rz_analysis_class_get_all(RzAnalysis *analysis, bool sorted); +RZ_API void rz_analysis_class_foreach(RzAnalysis *analysis, SdbForeachCallback cb, void *user); +RZ_API RzAnalysisClassErr rz_analysis_class_rename(RzAnalysis *analysis, const char *old_name, const char *new_name); + +RZ_API void rz_analysis_class_method_fini(RZ_NULLABLE RzAnalysisMethod *meth); +RZ_API RzAnalysisClassErr rz_analysis_class_method_get(RzAnalysis *analysis, const char *class_name, const char *meth_name, RzAnalysisMethod *meth); +RZ_API RzAnalysisClassErr rz_analysis_class_method_get_by_addr(RzAnalysis *analysis, const char *class_name, ut64 addr, RzAnalysisMethod *method); +RZ_API RzVector /**/ *rz_analysis_class_method_get_all(RzAnalysis *analysis, const char *class_name); +RZ_API RzAnalysisClassErr rz_analysis_class_method_set(RzAnalysis *analysis, const char *class_name, RzAnalysisMethod *meth); +RZ_API RzAnalysisClassErr rz_analysis_class_method_rename(RzAnalysis *analysis, const char *class_name, const char *old_meth_name, const char *new_meth_name); +RZ_API RzAnalysisClassErr rz_analysis_class_method_delete(RzAnalysis *analysis, const char *class_name, const char *meth_name); +RZ_API bool rz_analysis_class_method_exists(RzAnalysis *analysis, const char *class_name, const char *meth_name); +RZ_API bool rz_analysis_class_method_exists_by_addr(RzAnalysis *analysis, const char *class_name, ut64 addr); +RZ_API void rz_analysis_class_method_recover(RzAnalysis *analysis, RzBinClass *cls, RzList /**/ *methods); + +RZ_API void rz_analysis_class_base_fini(RzAnalysisBaseClass *base); +RZ_API RzAnalysisClassErr rz_analysis_class_base_get(RzAnalysis *analysis, const char *class_name, const char *base_id, RzAnalysisBaseClass *base); +RZ_API RzVector /**/ *rz_analysis_class_base_get_all(RzAnalysis *analysis, const char *class_name); +RZ_API RzAnalysisClassErr rz_analysis_class_base_set(RzAnalysis *analysis, const char *class_name, RzAnalysisBaseClass *base); +RZ_API RzAnalysisClassErr rz_analysis_class_base_delete(RzAnalysis *analysis, const char *class_name, const char *base_id); + +RZ_API void rz_analysis_class_vtable_fini(RzAnalysisVTable *vtable); +RZ_API RzAnalysisClassErr rz_analysis_class_vtable_get(RzAnalysis *analysis, const char *class_name, const char *vtable_id, RzAnalysisVTable *vtable); +RZ_API RzVector /**/ *rz_analysis_class_vtable_get_all(RzAnalysis *analysis, const char *class_name); +RZ_API RzAnalysisClassErr rz_analysis_class_vtable_set(RzAnalysis *analysis, const char *class_name, RzAnalysisVTable *vtable); +RZ_API RzAnalysisClassErr rz_analysis_class_vtable_delete(RzAnalysis *analysis, const char *class_name, const char *vtable_id); + +RZ_API RzGraph /**/ *rz_analysis_class_get_inheritance_graph(RzAnalysis *analysis); + +RZ_API RZ_OWN RzPVector /**/ *rz_analysis_function_args(RzAnalysis *a, RzAnalysisFunction *fcn); +RZ_API RZ_OWN RzPVector /**/ *rz_analysis_function_vars(RZ_NONNULL RzAnalysis *a, RZ_NONNULL RzAnalysisFunction *fcn); +RZ_API RZ_BORROW RzAnalysisVar *rz_analysis_function_get_arg_idx(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *f, size_t index); +RZ_API RZ_OWN RzList /**/ *rz_analysis_types_from_fcn(RzAnalysis *analysis, RzAnalysisFunction *fcn); +RZ_API RZ_OWN RzCallable *rz_analysis_function_derive_type(RzAnalysis *analysis, RzAnalysisFunction *f); +RZ_API bool rz_analysis_function_is_malloc(const RzAnalysisFunction *fcn); + +/* PDB */ +RZ_API RzType *rz_type_db_pdb_parse(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type); +RZ_API void rz_type_db_pdb_load(const RzTypeDB *typedb, const RzPdb *pdb); + +/* DWARF */ +RZ_API void rz_analysis_dwarf_preprocess_info( + RZ_NONNULL RZ_BORROW RzAnalysis *analysis, + RZ_NONNULL RZ_BORROW RzBinDWARF *dw); +RZ_API void rz_analysis_dwarf_process_info(RzAnalysis *analysis, RzBinDWARF *dw); +RZ_API void rz_analysis_dwarf_integrate_functions(RzAnalysis *analysis, RzFlag *flags); +RZ_API RzAnalysisDebugInfo *rz_analysis_debug_info_new(); +RZ_API void rz_analysis_debug_info_free(RzAnalysisDebugInfo *debuginfo); + +/* serialize */ + +typedef void *RzSerializeAnalysisVarParser; +typedef void *RzSerializeAnalysisGlobalVarParser; +typedef struct { + RzAnalysis *analysis; + RzKeyParser *parser; + RzSerializeAnalysisVarParser var_parser; + RzKeyParser *storage_parser; + RzKeyParser *piece_parser; +} RzSerializeAnalysisFunctionLoadCtx; + +RZ_API void rz_serialize_analysis_case_op_save(RZ_NONNULL PJ *j, RZ_NONNULL RzAnalysisCaseOp *op); +RZ_API void rz_serialize_analysis_switch_op_save(RZ_NONNULL PJ *j, RZ_NONNULL RzAnalysisSwitchOp *op); +RZ_API RzAnalysisSwitchOp *rz_serialize_analysis_switch_op_load(RZ_NONNULL const RzJson *json); + +RZ_API void rz_serialize_analysis_blocks_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis); + +RZ_API void rz_serialize_analysis_global_var_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *a); +RZ_API RzSerializeAnalysisGlobalVarParser rz_serialize_analysis_global_var_parser_new(void); +RZ_API void rz_serialize_analysis_global_var_parser_free(RzSerializeAnalysisGlobalVarParser parser); +RZ_API bool rz_serialize_analysis_global_var_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzSerializeResultInfo *res); + +/** + * RzAnalysis must not contain any blocks when calling this function! + * All loaded blocks will have a ref of 1 after this function and should be unrefd once after loading functions. + */ +RZ_API bool rz_serialize_analysis_blocks_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzSerializeResultInfo *res); + +RZ_API RzSerializeAnalysisVarParser rz_serialize_analysis_var_parser_new(void); +RZ_API void rz_serialize_analysis_var_parser_free(RzSerializeAnalysisVarParser parser); +RZ_API RzSerializeAnalysisVarParser rz_serialize_analysis_var_storage_parser_new(void); + +RZ_API RZ_OWN RzAnalysisVar *rz_serialize_analysis_var_load( + RZ_NONNULL RzSerializeAnalysisFunctionLoadCtx *ctx, + RZ_NONNULL RzAnalysisFunction *fcn, + RZ_NONNULL const RzJson *json); +RZ_API bool rz_serialize_analysis_var_storage_load( + RZ_NONNULL RzSerializeAnalysisFunctionLoadCtx *ctx, + RZ_NONNULL const RzJson *json, + RZ_NONNULL RZ_BORROW RZ_OUT RzAnalysisVarStorage *storage); + +/** + * Save useful infomation when analyze and disassemble bytes + * \see rz_core_analysis_bytes + */ +typedef struct analysis_bytes_t { + RzAnalysisOp *op; + RzAnalysisHint *hint; + char *opcode; + char *disasm; + char *pseudo; + char *description; + char *mask; + char *bytes; + int oplen; +} RzAnalysisBytes; + +RZ_API void rz_serialize_analysis_functions_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis); +RZ_API bool rz_serialize_analysis_functions_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzSerializeResultInfo *res); +RZ_API void rz_serialize_analysis_function_noreturn_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis); +RZ_API bool rz_serialize_analysis_function_noreturn_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzSerializeResultInfo *res); +RZ_API void rz_serialize_analysis_xrefs_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis); +RZ_API bool rz_serialize_analysis_xrefs_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzSerializeResultInfo *res); +RZ_API void rz_serialize_analysis_meta_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis); +RZ_API bool rz_serialize_analysis_meta_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzSerializeResultInfo *res); +RZ_API void rz_serialize_analysis_hints_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis); +RZ_API bool rz_serialize_analysis_hints_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzSerializeResultInfo *res); +RZ_API void rz_serialize_analysis_classes_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis); +RZ_API bool rz_serialize_analysis_classes_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzSerializeResultInfo *res); +RZ_API void rz_serialize_analysis_types_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis); +RZ_API bool rz_serialize_analysis_types_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzSerializeResultInfo *res); +RZ_API void rz_serialize_analysis_sign_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis); +RZ_API bool rz_serialize_analysis_sign_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzSerializeResultInfo *res); +RZ_API void rz_serialize_analysis_imports_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis); +RZ_API bool rz_serialize_analysis_imports_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzSerializeResultInfo *res); +RZ_API void rz_serialize_analysis_cc_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis); +RZ_API bool rz_serialize_analysis_cc_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzSerializeResultInfo *res); + +RZ_API void rz_serialize_analysis_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis); +RZ_API bool rz_serialize_analysis_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzSerializeResultInfo *res); + +#ifdef __cplusplus +} +#endif + +#endif +#endif diff --git a/dest/include/librz/rz_arch.h b/dest/include/librz/rz_arch.h new file mode 100644 index 00000000000..bf628fe5ecc --- /dev/null +++ b/dest/include/librz/rz_arch.h @@ -0,0 +1,34 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_ARCH_H +#define RZ_ARCH_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_arch); + +typedef struct rz_arch_plugin_t { + RZ_DEPRECATE RzAsmPlugin *p_asm; ///< Assembly Plugin + RZ_DEPRECATE RzAnalysisPlugin *p_analysis; ///< Analysis Plugin + RZ_DEPRECATE RzParsePlugin *p_parse; ///< Parse Plugin +} RzArchPlugin; + +RZ_DEPRECATE RZ_API const size_t rz_arch_get_n_plugins(); +RZ_DEPRECATE RZ_API RZ_BORROW RzAsmPlugin *rz_arch_get_asm_plugin(size_t index); +RZ_DEPRECATE RZ_API RZ_BORROW RzAnalysisPlugin *rz_arch_get_analysis_plugin(size_t index); +RZ_DEPRECATE RZ_API RZ_BORROW RzParsePlugin *rz_arch_get_parse_plugin(size_t index); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_ARCH_H */ diff --git a/dest/include/librz/rz_asm.h b/dest/include/librz/rz_asm.h new file mode 100644 index 00000000000..3f9cae0758d --- /dev/null +++ b/dest/include/librz/rz_asm.h @@ -0,0 +1,241 @@ +// SPDX-FileCopyrightText: 2009-2020 nibble +// SPDX-FileCopyrightText: 2009-2020 pancake +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_ASM_H +#define RZ_ASM_H + +#include +#include +#include +#include // only for binding, no hard dep required +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* backward compatibility */ +#define RZ_ASM_ARCH_NONE RZ_SYS_ARCH_NONE +#define RZ_ASM_ARCH_X86 RZ_SYS_ARCH_X86 +#define RZ_ASM_ARCH_ARM RZ_SYS_ARCH_ARM +#define RZ_ASM_ARCH_PPC RZ_SYS_ARCH_PPC +#define RZ_ASM_ARCH_M68K RZ_SYS_ARCH_M68K +#define RZ_ASM_ARCH_JAVA RZ_SYS_ARCH_JAVA +#define RZ_ASM_ARCH_LM32 RZ_SYS_ARCH_LM32 +#define RZ_ASM_ARCH_MIPS RZ_SYS_ARCH_MIPS +#define RZ_ASM_ARCH_SPARC RZ_SYS_ARCH_SPARC +#define RZ_ASM_ARCH_XAP RZ_SYS_ARCH_XAP +#define RZ_ASM_ARCH_MSIL RZ_SYS_ARCH_MSIL +#define RZ_ASM_ARCH_OBJD RZ_SYS_ARCH_OBJD +#define RZ_ASM_ARCH_BF RZ_SYS_ARCH_BF +#define RZ_ASM_ARCH_SH RZ_SYS_ARCH_SH +#define RZ_ASM_ARCH_Z80 RZ_SYS_ARCH_Z80 +#define RZ_ASM_ARCH_I8080 RZ_SYS_ARCH_I8080 +#define RZ_ASM_ARCH_ARC RZ_SYS_ARCH_ARC +#define RZ_ASM_ARCH_HPPA RZ_SYS_ARCH_HPPA + +#define RZ_ASM_GET_OFFSET(x, y, z) \ + (x && x->binb.bin && x->binb.get_offset) ? x->binb.get_offset(x->binb.bin, y, z) : -1 + +#define RZ_ASM_GET_NAME(x, y, z) \ + (x && x->binb.bin && x->binb.get_name) ? x->binb.get_name(x->binb.bin, y, z) : NULL + +enum { + RZ_ASM_SYNTAX_NONE = 0, + RZ_ASM_SYNTAX_INTEL, + RZ_ASM_SYNTAX_ATT, + RZ_ASM_SYNTAX_MASM, + RZ_ASM_SYNTAX_REGNUM, // alias for capstone's NOREGNAME + RZ_ASM_SYNTAX_JZ, // hack to use jz instead of je on x86 +}; + +enum { + RZ_ASM_MOD_RAWVALUE = 'r', + RZ_ASM_MOD_VALUE = 'v', + RZ_ASM_MOD_DSTREG = 'd', + RZ_ASM_MOD_SRCREG0 = '0', + RZ_ASM_MOD_SRCREG1 = '1', + RZ_ASM_MOD_SRCREG2 = '2' +}; + +typedef struct rz_asm_op_t { + int size; // instruction size (must be deprecated. just use buf.len + int bitsize; // instruction size in bits (or 0 if fits in 8bit bytes) // why this field is dup? + int payload; // size of payload (opsize = (size-payload)) + // But this is pretty slow..so maybe we should add some accessors + RzStrBuf buf; + RzStrBuf buf_asm; + RzBuffer *buf_inc; // must die + RzAsmTokenString *asm_toks; ///< Tokenized asm string. +} RzAsmOp; + +typedef struct rz_asm_code_t { + int len; + ut8 *bytes; + char *assembly; + RzList /**/ *equs; // TODO: must be a hash + ut64 code_offset; + ut64 data_offset; + int code_align; +} RzAsmCode; + +// TODO: Must use Hashtable instead of this hack +typedef struct { + char *key; + char *value; +} RzAsmEqu; + +#define _RzAsmPlugin struct rz_asm_plugin_t +typedef struct rz_asm_t { + void *core; + ut8 ptr_alignment_I; + void *plugin_data; + ut8 ptr_alignment_II; + // NOTE: Do not change the order of fields above! + // They are used in pointer passing hacks in rz_types.h. + char *cpu; + int bits; + int big_endian; + int syntax; + ut64 pc; + _RzAsmPlugin *cur; + _RzAsmPlugin *acur; + HtSP /**/ *plugins; + RzBinBind binb; + RzParse *ifilter; + RzParse *ofilter; + Sdb *pair; + RzSyscall *syscall; + RzNum *num; + RzPath *sdb_opcodes_path; ///< pointer to RzPath, contains path prefix of the system + char *features; + char *platforms; + int invhex; // invalid instructions displayed in hex + int pcalign; + int dataalign; + int bitshift; + bool immsign; // Print signed immediates as negative values, not their unsigned representation. + bool immdisp; // Display immediates with # symbol (for arm architectures). false = show hashs + bool utf8; // Flag for plugins: Use utf-8 characters. + HtSS *flags; + int seggrn; + bool pseudo; +} RzAsm; + +typedef struct rz_asm_plugin_t { + const char *name; + const char *arch; + const char *author; + const char *version; + const char *cpus; + const char *desc; + const char *license; + int bits; + int endian; + bool (*init)(void **user); + bool (*fini)(void *user); + int (*disassemble)(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len); + int (*assemble)(RzAsm *a, RzAsmOp *op, const char *buf); + char *(*mnemonics)(RzAsm *a, int id, bool json); + RZ_OWN RzConfig *(*get_config)(void *plugin_data); + const char *features; + const char *platforms; + char **(*get_cpu_desc)(); + bool (*sw_breakpoint)(RzAsm *a, RzAsmOp *op); +} RzAsmPlugin; + +/** + * \brief Compare plugins by name (via strcmp). + */ +static inline int rz_asm_plugin_cmp(RZ_NULLABLE const RzAsmPlugin *a, RZ_NULLABLE const RzAsmPlugin *b) { + if (!a && !b) { + return 0; + } else if (!a) { + return -1; + } else if (!b) { + return 1; + } + return rz_str_cmp(a->name, b->name, -1); +} + +#ifdef RZ_API +/* asm.c */ +RZ_API RzAsm *rz_asm_new(void); +RZ_API void rz_asm_free(RzAsm *a); +RZ_API char *rz_asm_mnemonics(RzAsm *a, int id, bool json); +RZ_API int rz_asm_mnemonics_byname(RzAsm *a, const char *name); +RZ_API bool rz_asm_plugin_add(RzAsm *a, RZ_NONNULL RzAsmPlugin *foo); +RZ_API bool rz_asm_plugin_del(RzAsm *a, RZ_NONNULL RzAsmPlugin *foo); +RZ_API bool rz_asm_setup(RzAsm *a, const char *arch, int bits, int big_endian); +RZ_API bool rz_asm_is_valid(RzAsm *a, const char *name); +RZ_API bool rz_asm_use(RzAsm *a, RZ_NULLABLE const char *name); +RZ_API bool rz_asm_use_assembler(RzAsm *a, const char *name); +RZ_API bool rz_asm_set_arch(RzAsm *a, const char *name, int bits); +RZ_DEPRECATE RZ_API int rz_asm_set_bits(RzAsm *a, int bits); +RZ_DEPRECATE RZ_API void rz_asm_set_cpu(RzAsm *a, const char *cpu); +RZ_API bool rz_asm_set_big_endian(RzAsm *a, bool big_endian); +RZ_API bool rz_asm_set_syntax(RzAsm *a, int syntax); +RZ_API int rz_asm_syntax_from_string(const char *name); +RZ_API int rz_asm_set_pc(RzAsm *a, ut64 pc); +RZ_API int rz_asm_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len); +RZ_API int rz_asm_assemble(RzAsm *a, RzAsmOp *op, const char *buf); +RZ_API bool rz_asm_software_breakpoint(RZ_NONNULL RzAsm *a, RZ_NONNULL RzAsmOp *op); +RZ_API RzAsmCode *rz_asm_mdisassemble(RzAsm *a, const ut8 *buf, int len); +RZ_API RzAsmCode *rz_asm_mdisassemble_hexstr(RzAsm *a, RzParse *p, const char *hexstr); +RZ_API RzAsmCode *rz_asm_massemble(RzAsm *a, const char *buf); +RZ_API RzAsmCode *rz_asm_rasm_assemble(RzAsm *a, const char *buf, bool use_spp); +RZ_API char *rz_asm_to_string(RzAsm *a, ut64 addr, const ut8 *b, int l); +/* to ease the use of the native bindings (not used in r2) */ +RZ_API ut8 *rz_asm_from_string(RzAsm *a, ut64 addr, const char *b, int *l); +RZ_API int rz_asm_sub_names_input(RzAsm *a, const char *f); +RZ_API int rz_asm_sub_names_output(RzAsm *a, const char *f); +RZ_API char *rz_asm_describe(RzAsm *a, const char *str); +RZ_API RZ_BORROW HtSP /**/ *rz_asm_get_plugins(RZ_BORROW RZ_NONNULL RzAsm *a); +RZ_API void rz_asm_list_directives(void); + +/* code.c */ +RZ_API RzAsmCode *rz_asm_code_new(void); +RZ_API void *rz_asm_code_free(RzAsmCode *acode); +RZ_API void rz_asm_equ_item_free(RzAsmEqu *equ); +RZ_API bool rz_asm_code_set_equ(RzAsmCode *code, const char *key, const char *value); +RZ_API char *rz_asm_code_equ_replace(RzAsmCode *code, char *str); +RZ_API char *rz_asm_code_get_hex(RzAsmCode *acode); + +/* op.c */ +RZ_API RZ_OWN RzAsmOp *rz_asm_op_new(void); +RZ_API void rz_asm_op_init(RZ_NULLABLE RzAsmOp *op); +RZ_API void rz_asm_op_free(RZ_NULLABLE RzAsmOp *op); +RZ_API void rz_asm_op_fini(RZ_NULLABLE RzAsmOp *op); +RZ_API RZ_OWN char *rz_asm_op_get_hex(RZ_NONNULL RzAsmOp *op); +RZ_API RZ_BORROW char *rz_asm_op_get_asm(RZ_NONNULL RzAsmOp *op); +RZ_API int rz_asm_op_get_size(RZ_NONNULL RzAsmOp *op); +RZ_API void rz_asm_op_set_asm(RZ_NONNULL RzAsmOp *op, RZ_NONNULL const char *str); +RZ_API void rz_asm_op_setf_asm(RZ_NONNULL RzAsmOp *op, RZ_NONNULL const char *fmt, ...); +RZ_API int rz_asm_op_set_hex(RZ_NONNULL RzAsmOp *op, RZ_NONNULL const char *str); +RZ_API int rz_asm_op_set_hexbuf(RZ_NONNULL RzAsmOp *op, RZ_NONNULL const ut8 *buf, int len); +RZ_API void rz_asm_op_set_buf(RZ_NONNULL RzAsmOp *op, RZ_NONNULL const ut8 *str, int len); +RZ_API RZ_BORROW ut8 *rz_asm_op_get_buf(RZ_NONNULL RzAsmOp *op); + +// String tokenizing +RZ_API RZ_OWN RzAsmTokenString *rz_asm_token_string_new(const char *asm_str); +RZ_API void rz_asm_token_string_free(RZ_OWN RzAsmTokenString *toks); +RZ_API RZ_OWN RzAsmTokenString *rz_asm_token_string_clone(RZ_OWN RZ_NONNULL RzAsmTokenString *toks); +RZ_API void rz_asm_token_pattern_free(void *p); +RZ_API void rz_asm_compile_token_patterns(RZ_INOUT RzPVector /**/ *patterns); +RZ_API RZ_OWN RzAsmTokenString *rz_asm_tokenize_asm_regex(RZ_BORROW RzStrBuf *asm_str, RzPVector /**/ *patterns); +RZ_API RZ_OWN RzAsmParseParam *rz_asm_get_parse_param(RZ_NULLABLE const RzReg *reg, ut32 ana_op_type); +RZ_API void rz_asm_parse_param_free(RZ_OWN RZ_NULLABLE RzAsmParseParam *p); +RZ_DEPRECATE RZ_API RZ_OWN RzAsmTokenString *rz_asm_tokenize_asm_string(RZ_BORROW RzStrBuf *asm_str, RZ_NULLABLE const RzAsmParseParam *param); +RZ_DEPRECATE RZ_API RZ_OWN RzStrBuf *rz_asm_colorize_asm_str(RZ_BORROW RzStrBuf *asm_str, RZ_BORROW RzPrint *p, RZ_NULLABLE const RzAsmParseParam *param, RZ_NULLABLE const RzAsmTokenString *toks); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_basefind.h b/dest/include/librz/rz_basefind.h new file mode 100644 index 00000000000..5337a92dd13 --- /dev/null +++ b/dest/include/librz/rz_basefind.h @@ -0,0 +1,54 @@ +// SPDX-FileCopyrightText: 2021 deroad +// SPDX-License-Identifier: MIT + +#ifndef RZ_BASEFIND_H +#define RZ_BASEFIND_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RZ_BASEFIND_STRING_MIN_LENGTH (10) +#define RZ_BASEFIND_BASE_MIN_ADDRESS (0ull) +#define RZ_BASEFIND_BASE_MAX_ADDRESS (0xf0000000ull) +#define RZ_BASEFIND_BASE_ALIGNMENT (0x1000) +#define RZ_BASEFIND_SCORE_MIN_VALUE (1) + +typedef struct rz_basefind_t { + ut64 candidate; ///< Candidate physical base address + ut32 score; ///< Score of the candidate address +} RzBaseFindScore; + +typedef struct rz_basefind_info_t { + ut32 n_threads; ///< Total number of search threads. + ut32 thread_idx; ///< Thread number. + ut64 begin_address; ///< Thread related search address (start). + ut64 current_address; ///< Thread related search address (current). + ut64 end_address; ///< Thread related search address (end). + ut32 percentage; ///< Progress made by the search thread. +} RzBaseFindThreadInfo; + +// Used to provide user information regarding the running threads and to stop the execution when needed. +typedef bool (*RzBaseFindThreadInfoCb)(const RzBaseFindThreadInfo *th_info, void *user); + +typedef struct rz_basefind_options_t { + RzThreadNCores max_threads; ///< Max requested number of threads (not guaranteed). + ut32 pointer_size; ///< Pointer size in bits (32 or 64) + ut64 start_address; ///< Start search address + ut64 end_address; ///< End search address + ut64 alignment; ///< Memory alignment in bytes (suggested to set it to RZ_BASEFIND_BASE_ALIGNMENT) + ut32 min_score; ///< Minimum score to reach to be part of the list of possible addresses + ut32 min_string_len; ///< Min string length to search for + RzBaseFindThreadInfoCb callback; ///< When set allows to get the thread information + void *user; ///< User pointer to pass to the callback function for the thread info +} RzBaseFindOpt; + +RZ_API RZ_OWN RzList /**/ *rz_basefind(RZ_NONNULL RzCore *core, RZ_NONNULL RzBaseFindOpt *options); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_BASEFIND_H */ diff --git a/dest/include/librz/rz_bin.h b/dest/include/librz/rz_bin.h new file mode 100644 index 00000000000..f9f3d1c4d4a --- /dev/null +++ b/dest/include/librz/rz_bin.h @@ -0,0 +1,1105 @@ +#ifndef RZ_BIN_H +#define RZ_BIN_H + +#include "rz_vector.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct rz_bin_t RzBin; +typedef struct rz_bin_file_t RzBinFile; +typedef struct rz_bin_reloc_storage_t RzBinRelocStorage; + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_bin); + +#define RZ_BIN_DBG_STRIPPED 0x01 +#define RZ_BIN_DBG_STATIC 0x02 +#define RZ_BIN_DBG_LINENUMS 0x04 +#define RZ_BIN_DBG_SYMS 0x08 +#define RZ_BIN_DBG_RELOCS 0x10 + +#define RZ_BIN_ENTRY_TYPE_PROGRAM 0 +#define RZ_BIN_ENTRY_TYPE_MAIN 1 +#define RZ_BIN_ENTRY_TYPE_INIT 2 +#define RZ_BIN_ENTRY_TYPE_FINI 3 +#define RZ_BIN_ENTRY_TYPE_TLS 4 +#define RZ_BIN_ENTRY_TYPE_PREINIT 5 + +#define RZ_BIN_SIZEOF_STRINGS 512 +#define RZ_BIN_MAX_ARCH 1024 + +#define RZ_BIN_REQ_ALL UT64_MAX +#define RZ_BIN_REQ_UNK 0x000000 +#define RZ_BIN_REQ_ENTRIES 0x000001 +#define RZ_BIN_REQ_IMPORTS 0x000002 +#define RZ_BIN_REQ_SYMBOLS 0x000004 +#define RZ_BIN_REQ_SECTIONS 0x000008 +#define RZ_BIN_REQ_INFO 0x000010 +#define RZ_BIN_REQ_OPERATION 0x000020 +#define RZ_BIN_REQ_HELP 0x000040 +#define RZ_BIN_REQ_STRINGS 0x000080 +#define RZ_BIN_REQ_FIELDS 0x000100 +#define RZ_BIN_REQ_LIBS 0x000200 +#define RZ_BIN_REQ_SRCLINE 0x000400 +#define RZ_BIN_REQ_MAIN 0x000800 +#define RZ_BIN_REQ_EXTRACT 0x001000 +#define RZ_BIN_REQ_RELOCS 0x002000 +#define RZ_BIN_REQ_LISTARCHS 0x004000 +#define RZ_BIN_REQ_CREATE 0x008000 +#define RZ_BIN_REQ_CLASSES 0x010000 +#define RZ_BIN_REQ_DWARF 0x020000 +#define RZ_BIN_REQ_SIZE 0x040000 +#define RZ_BIN_REQ_PDB 0x080000 +#define RZ_BIN_REQ_PDB_DWNLD 0x100000 +#define RZ_BIN_REQ_DLOPEN 0x200000 +#define RZ_BIN_REQ_EXPORTS 0x400000 +#define RZ_BIN_REQ_VERSIONINFO 0x800000 +#define RZ_BIN_REQ_PACKAGE 0x1000000 +#define RZ_BIN_REQ_HEADER 0x2000000 +#define RZ_BIN_REQ_LISTPLUGINS 0x4000000 +#define RZ_BIN_REQ_RESOURCES 0x8000000 +#define RZ_BIN_REQ_INITFINI 0x10000000 +#define RZ_BIN_REQ_SEGMENTS 0x20000000 +#define RZ_BIN_REQ_HASHES 0x40000000 +#define RZ_BIN_REQ_SIGNATURE 0x80000000 +#define RZ_BIN_REQ_TRYCATCH 0x100000000 +#define RZ_BIN_REQ_SECTIONS_MAPPING 0x200000000 +#define RZ_BIN_REQ_CLASSES_SOURCES 0x400000000 +#define RZ_BIN_REQ_BASEFIND 0x800000000 +#define RZ_BIN_REQ_DEBUGINFOD 0x1000000000 + +/* RzBinSymbol->method_flags : */ +#define RZ_BIN_METH_CLASS 0x0000000000000001L +#define RZ_BIN_METH_STATIC 0x0000000000000002L +#define RZ_BIN_METH_PUBLIC 0x0000000000000004L +#define RZ_BIN_METH_PRIVATE 0x0000000000000008L +#define RZ_BIN_METH_PROTECTED 0x0000000000000010L +#define RZ_BIN_METH_INTERNAL 0x0000000000000020L +#define RZ_BIN_METH_OPEN 0x0000000000000040L +#define RZ_BIN_METH_FILEPRIVATE 0x0000000000000080L +#define RZ_BIN_METH_FINAL 0x0000000000000100L +#define RZ_BIN_METH_VIRTUAL 0x0000000000000200L +#define RZ_BIN_METH_CONST 0x0000000000000400L +#define RZ_BIN_METH_MUTATING 0x0000000000000800L +#define RZ_BIN_METH_ABSTRACT 0x0000000000001000L +#define RZ_BIN_METH_SYNCHRONIZED 0x0000000000002000L +#define RZ_BIN_METH_NATIVE 0x0000000000004000L +#define RZ_BIN_METH_BRIDGE 0x0000000000008000L +#define RZ_BIN_METH_VARARGS 0x0000000000010000L +#define RZ_BIN_METH_SYNTHETIC 0x0000000000020000L +#define RZ_BIN_METH_STRICT 0x0000000000040000L +#define RZ_BIN_METH_MIRANDA 0x0000000000080000L +#define RZ_BIN_METH_CONSTRUCTOR 0x0000000000100000L +#define RZ_BIN_METH_DECLARED_SYNCHRONIZED 0x0000000000200000L + +#define RZ_BIN_BIND_LOCAL_STR "LOCAL" +#define RZ_BIN_BIND_GLOBAL_STR "GLOBAL" +#define RZ_BIN_BIND_WEAK_STR "WEAK" +#define RZ_BIN_BIND_NUM_STR "NUM" +#define RZ_BIN_BIND_LOOS_STR "LOOS" +#define RZ_BIN_BIND_HIOS_STR "HIOS" +#define RZ_BIN_BIND_LOPROC_STR "LOPROC" +#define RZ_BIN_BIND_HIPROC_STR "HIPROC" +#define RZ_BIN_BIND_IMPORT_STR "IMPORT" +#define RZ_BIN_BIND_UNKNOWN_STR "UNKNOWN" + +#define RZ_BIN_TYPE_NOTYPE_STR "NOTYPE" +#define RZ_BIN_TYPE_OBJECT_STR "OBJ" +#define RZ_BIN_TYPE_FUNC_STR "FUNC" +#define RZ_BIN_TYPE_FIELD_STR "FIELD" +#define RZ_BIN_TYPE_IFACE_STR "IFACE" +#define RZ_BIN_TYPE_METH_STR "METH" +#define RZ_BIN_TYPE_STATIC_STR "STATIC" +#define RZ_BIN_TYPE_SECTION_STR "SECT" +#define RZ_BIN_TYPE_FILE_STR "FILE" +#define RZ_BIN_TYPE_COMMON_STR "COMMON" +#define RZ_BIN_TYPE_TLS_STR "TLS" +#define RZ_BIN_TYPE_NUM_STR "NUM" +#define RZ_BIN_TYPE_LOOS_STR "LOOS" +#define RZ_BIN_TYPE_HIOS_STR "HIOS" +#define RZ_BIN_TYPE_LOPROC_STR "LOPROC" +#define RZ_BIN_TYPE_HIPROC_STR "HIPROC" +#define RZ_BIN_TYPE_SPECIAL_SYM_STR "SPCL" +#define RZ_BIN_TYPE_UNKNOWN_STR "UNK" + +typedef enum { + RZ_BIN_SPECIAL_SYMBOL_ENTRY, + RZ_BIN_SPECIAL_SYMBOL_INIT, + RZ_BIN_SPECIAL_SYMBOL_MAIN, + RZ_BIN_SPECIAL_SYMBOL_FINI, + RZ_BIN_SPECIAL_SYMBOL_LAST +} RzBinSpecialSymbol; + +// name mangling types +typedef enum { + RZ_BIN_LANGUAGE_UNKNOWN = 0, + RZ_BIN_LANGUAGE_JAVA = 1, + RZ_BIN_LANGUAGE_C = 1 << 1, + RZ_BIN_LANGUAGE_GO = 1 << 2, + RZ_BIN_LANGUAGE_CXX = 1 << 3, + RZ_BIN_LANGUAGE_OBJC = 1 << 4, + RZ_BIN_LANGUAGE_SWIFT = 1 << 5, + RZ_BIN_LANGUAGE_DLANG = 1 << 6, + RZ_BIN_LANGUAGE_MSVC = 1 << 7, + RZ_BIN_LANGUAGE_RUST = 1 << 8, + RZ_BIN_LANGUAGE_KOTLIN = 1 << 9, + RZ_BIN_LANGUAGE_GROOVY = 1 << 10, + RZ_BIN_LANGUAGE_DART = 1 << 11, + RZ_BIN_LANGUAGE_PASCAL = 1 << 12, + RZ_BIN_LANGUAGE_NIM = 1 << 13, + RZ_BIN_LANGUAGE_BLOCKS = 1 << 31, +} RzBinLanguage; + +#define RZ_BIN_LANGUAGE_MASK(x) ((x) & ~RZ_BIN_LANGUAGE_BLOCKS) +#define RZ_BIN_LANGUAGE_HAS_BLOCKS(x) ((x) & RZ_BIN_LANGUAGE_BLOCKS) + +enum { + RZ_BIN_CLASS_PRIVATE, + RZ_BIN_CLASS_PUBLIC, + RZ_BIN_CLASS_FRIENDLY, + RZ_BIN_CLASS_PROTECTED, +}; + +typedef enum { + RZ_BIN_RELOC_8 = 8, + RZ_BIN_RELOC_16 = 16, + RZ_BIN_RELOC_24 = 24, + RZ_BIN_RELOC_32 = 32, + RZ_BIN_RELOC_64 = 64 +} RzBinRelocType; + +enum { + RZ_BIN_TYPE_DEFAULT = 0, + RZ_BIN_TYPE_CORE = 1 +}; + +#define RZ_BIN_STRING_SEARCH_MIN_STRING 4 +#define RZ_BIN_STRING_SEARCH_BUFFER_SIZE 2048 +#define RZ_BIN_STRING_SEARCH_MAX_REGION_SIZE (1024 * 1024 * 10) +#define RZ_BIN_STRING_SEARCH_RAW_FILE_ALIGNMENT 0x10000 +#define RZ_BIN_STRING_SEARCH_CHECK_ASCII_FREQ true + +typedef enum { + RZ_BIN_STRING_SEARCH_MODE_AUTO = 0, + RZ_BIN_STRING_SEARCH_MODE_READ_ONLY_SECTIONS, + RZ_BIN_STRING_SEARCH_MODE_RAW_BINARY, +} RzBinStringSearchMode; + +typedef struct rz_bin_string_search_opt_t { + RzThreadNCores max_threads; ///< Maximum thread number (normally set to RZ_THREAD_N_CORES_ALL_AVAILABLE). + size_t min_length; ///< Smallest string length that is possible to find. + size_t max_length; ///< Maximum buffer size, which will also determine the maximum string length. + size_t max_region_size; ///< Maximum allowable size for the search interval between two memory regions. + /** + * \brief Memory alignment of the intervals strings are searched in. + * This is not the same as string alignment. + * Which is always set to the alignment of the encoding or guessed. + */ + size_t raw_alignment; + bool check_ascii_freq; ///< If true, perform check on ASCII frequencies when looking for false positives + RzStrEnc string_encoding; ///< The default string encoding type (when set to guess, it is automatically guessed). + RzBinStringSearchMode mode; ///< String search mode (auto, ro sections or raw binary) +} RzBinStringSearchOpt; + +typedef struct rz_bin_addr_t { + ut64 vaddr; + /** + * \brief The offset into the binary file. + * Note: This is not related to the physical addresses an MMU would manage! + */ + ut64 paddr; + ut64 hvaddr; + /** + * \brief The offset into the binary file where the header is. + * Note: This is not related to the physical addresses an MMU would manage! + */ + ut64 hpaddr; + int type; + int bits; +} RzBinAddr; + +typedef struct rz_bin_hash_t { + const char *type; + ut64 addr; + int len; + ut64 from; + ut64 to; + ut8 buf[32]; + const char *cmd; +} RzBinHash; + +typedef struct rz_bin_file_hash_t { + const char *type; + const char *hex; +} RzBinFileHash; + +typedef struct rz_bin_info_t { + char *file; + char *type; + char *bclass; + char *rclass; + char *arch; + char *cpu; + char *machine; + char *head_flag; + char *features; + char *os; + char *subsystem; + char *rpath; + char *guid; + char *debug_file_name; + const char *lang; + char *default_cc; + RzPVector /**/ *file_hashes; + int bits; + int has_va; + int has_pi; // pic/pie + int has_canary; + int has_retguard; + int has_sanitizers; + int has_crypto; + int has_nx; + bool has_nobtcfi; ///< OpenBSD, linked with -Wl,-z,nobtcfi to opt-out of IBT/BTI + int big_endian; + char *actual_checksum; + char *claimed_checksum; + int pe_overlay; + bool signature; + ut64 dbg_info; + RzBinHash sum[3]; + ut64 baddr; + char *intrp; + char *compiler; +} RzBinInfo; + +typedef struct rz_bin_file_load_options_t { + /** + * \brief This flag is a work around for the inconsistent base addresses behavior of ELF objects. + * The ELF loader doesn't respect the RzBinObjectLoadOptions->baseaddr + * parameter when it loads an ELF file. + * Instead it either assumes a base address of: 0, the first executable section or, in case of relocatable ELFs, + * RZ_BIN_ELF_DEFAULT_BADDR_RELOC. + * + * This is annoyingly wrong, but fixing it breaks too many other things in Rizin. + * Because it was just built around it. And refactoring/replacing the old ELF module is + * no priority currently. + * So here we go, this flags makes Elf_(rz_bin_elf_get_baddr) always return the base address + * below. Assuming these BinLoaderOtions were passed to it. + */ + bool force_elf_to_use_baddr; + ut64 baseaddr; ///< where the linker maps the binary in memory + ut64 loadaddr; ///< starting physical address to read from the target file + bool patch_relocs; ///< ask the bin plugin to fill relocs with valid contents for analysis + bool big_endian; ///< only used for binary formats that do not specify the endian in the file, but need it to load, otherwise ignored. + bool elf_load_sections; ///< ELF specific, load or not ELF sections + bool elf_checks_sections; ///< ELF specific, checks or not ELF sections + bool elf_checks_segments; ///< ELF specific, checks or not ELF sections +} RzBinObjectLoadOptions; + +typedef struct rz_bin_string_database_t RzBinStrDb; + +typedef struct rz_bin_object_t { + RzBinObjectLoadOptions opts; + st64 baddr_shift; + ut64 boffset; + ut64 size; + ut64 obj_size; + RzPVector /**/ *vfiles; + RzPVector /**/ *maps; + RzPVector /**/ *sections; + RzPVector /**/ *imports; + RzPVector /**/ *symbols; + RzPVector /**/ *resources; + /** + * \brief Acceleration structure for fast access of the symbol for a given import. + * This associates the name of every symbol where is_imported == true to the symbol itself. + */ + HtSP /**/ *import_name_symbols; // currently only used for imports, but could be extended to all symbols if needed. + RzPVector /**/ *entries; + RzPVector /**/ *fields; + RzPVector /**/ *libs; + RzBinRelocStorage *relocs; + RzBinStrDb *strings; + RzPVector /**/ *classes; + HtSP /**/ *name_to_class_object; + HtSP /**/ *glue_to_class_method; + HtSP /**/ *glue_to_class_field; + HtUP /**/ *vaddr_to_class_method; + RzBinSourceLineInfo *lines; + RzPVector /**/ *mem; + char *regstate; + RzBinInfo *info; + RzStructuredData *structured_data; + RzBinAddr *binsym[RZ_BIN_SPECIAL_SYMBOL_LAST]; + struct rz_bin_plugin_t *plugin; + RzBinLanguage lang; + RZ_DEPRECATE RZ_BORROW Sdb *kv; ///< deprecated, put info in C structures instead of this (holds a copy of another pointer.) + void *bin_obj; // internal pointer used by formats +} RzBinObject; + +// XXX: RbinFile may hold more than one RzBinObject +/// XX curplugin == o->plugin +struct rz_bin_file_t { + char *file; + int fd; ///< when used in combination with RzIO, this refers to the io fd. + int size; + ut32 id; + RzBuffer *buf; + ut64 offset; + RzBinObject *o; + void *xtr_obj; + ut64 loadaddr; + /* values used when searching the strings */ + int narch; + struct rz_bin_xtr_plugin_t *curxtr; + // struct rz_bin_plugin_t *curplugin; // use o->plugin + RzList /**/ *xtr_data; + RZ_DEPRECATE Sdb *sdb; ///< deprecated, put info in C structures instead of this + struct rz_bin_t *rbin; +}; // RzBinFile + +typedef struct rz_bin_file_options_t { + int rawstr; + ut64 baddr; // base address + ut64 laddr; // load address + /** + * \brief The offset into the binary file. + * Note: This is not related to the physical addresses an MMU would manage! + */ + ut64 paddr; + const char *plugname; // force a plugin? why do i need this? + // const char *xtrname; +} RzBinFileOptions; + +struct rz_bin_t { + const char *file; + RZ_DEPRECATE RzBinFile *cur; ///< never use this in new code! Get a file from the binfiles list or track it yourself. + int narch; + void *user; + RzEvent *event; + /* preconfigured values */ + ut64 maxstrbuf; + int rawstr; + RZ_DEPRECATE Sdb *sdb; + RzIDStorage *ids; + HtSP /**/ *plugins; + HtSP /**/ *binxtrs; + RzList /**/ *binfiles; + PrintfCallback cb_printf; + int loadany; + RzIOBind iob; + RzConsBind consb; + char *force; + int is_debugger; + bool want_dbginfo; + int filter; // symbol filtering + char strfilter; // string filtering + char *strpurge; // purge false positive strings + char *srcdir; // dir.source + char *prefix; // bin.prefix + ut64 filter_rules; + bool verbose; + bool demangle; + bool use_xtr; // use extract plugins when loading a file? + RzStrConstPool constpool; + bool is_reloc_patched; // used to indicate whether relocations were patched or not + RzDemangler *demangler; + RzHash *hash; + RzList /**/ *default_hashes; // bin.hashes.default + RzBinStringSearchOpt str_search_cfg; +}; + +typedef struct rz_bin_xtr_metadata_t { + char *arch; + int bits; + char *libname; + char *machine; + char *type; + bool big_endian; + const char *xtr_type; +} RzBinXtrMetadata; + +typedef int (*FREE_XTR)(void *xtr_obj); +typedef struct rz_bin_xtr_extract_t { + char *file; + RzBuffer *buf; + ut64 size; + ut64 offset; + RzBinObjectLoadOptions obj_opts; + int file_count; + int loaded; + RzBinXtrMetadata *metadata; +} RzBinXtrData; + +RZ_API RzBinXtrData *rz_bin_xtrdata_new(RzBuffer *buf, ut64 offset, ut64 size, ut32 file_count, RzBinXtrMetadata *metadata); +RZ_API void rz_bin_xtrdata_free(RZ_NULLABLE void /*RzBinXtrData*/ *data); + +typedef struct rz_bin_xtr_plugin_t { + char *name; + char *desc; + char *license; + int (*init)(void *user); + int (*fini)(void *user); + bool (*check_buffer)(RzBuffer *b); + + RzBinXtrData *(*extract_from_bytes)(RzBin *bin, const ut8 *buf, ut64 size, int idx); + RzBinXtrData *(*extract_from_buffer)(RzBin *bin, RzBuffer *buf, int idx); + RzList /**/ *(*extractall_from_bytes)(RzBin *bin, const ut8 *buf, ut64 size); + RzList /**/ *(*extractall_from_buffer)(RzBin *bin, RzBuffer *buf); + RzBinXtrData *(*extract)(RzBin *bin, int idx); + RzList /**/ *(*extractall)(RzBin *bin); + + bool (*load)(RzBin *bin); + int (*size)(RzBin *bin); + void (*destroy)(RzBin *bin); + void (*free_xtr)(void *xtr_obj); +} RzBinXtrPlugin; + +typedef struct rz_bin_arch_options_t { + const char *arch; + int bits; +} RzBinArchOptions; + +typedef struct rz_bin_trycatch_t { + ut64 source; + ut64 from; + ut64 to; + ut64 handler; + ut64 filter; + // TODO: add type/name of exception +} RzBinTrycatch; + +RZ_API RzBinTrycatch *rz_bin_trycatch_new(ut64 source, ut64 from, ut64 to, ut64 handler, ut64 filter); +RZ_API void rz_bin_trycatch_free(RzBinTrycatch *tc); + +typedef struct rz_bin_plugin_t { + char *name; + char *desc; + char *author; + char *version; + char *license; + RZ_DEPRECATE Sdb *(*get_sdb)(RzBinFile *obj); ///< deprecated, put info in C structures instead of this + bool (*load_buffer)(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb); + ut64 (*size)(RzBinFile *bin); + void (*destroy)(RzBinFile *bf); + bool (*check_bytes)(const ut8 *buf, ut64 length); + bool (*check_buffer)(RzBuffer *buf); + bool (*check_filename)(const char *filename); + ut64 (*baddr)(RzBinFile *bf); + ut64 (*boffset)(RzBinFile *bf); + RzPVector /**/ *(*virtual_files)(RzBinFile *bf); + RzPVector /**/ *(*maps)(RzBinFile *bf); + RzBinAddr *(*binsym)(RzBinFile *bf, RzBinSpecialSymbol num); + RzPVector /**/ *(*entries)(RzBinFile *bf); + RzPVector /**/ *(*sections)(RzBinFile *bf); + RZ_OWN RzBinSourceLineInfo *(*lines)(RzBinFile *bf); //< only called once on load, ownership is transferred to the caller + RzPVector /**/ *(*symbols)(RzBinFile *bf); + RzPVector /**/ *(*imports)(RzBinFile *bf); + /** + * \brief A method to search for strings in the binary. + * If the binary always has a known string encoding (ASCII, UTF-8, UTF-16 etc.), + * it is advisable to implement this function. + * A simple implementation like the following is enough: + * ```c + * RzPVector *strings(RzBinFile *bf) { + * RzBinStringSearchOpt opt; + * rz_bin_string_search_opt_init(&opt); + * opt.mode = RZ_BIN_STRING_SEARCH_MODE_READ_ONLY_SECTIONS; + * opt.string_encoding = RZ_STRING_ENC_UTF8; + * return rz_bin_file_strings(bf, &opt); + * } + * ``` + */ + RzPVector /**/ *(*strings)(RzBinFile *bf); + RzBinInfo *(*info)(RzBinFile *bf); + RzStructuredData *(*bin_structure)(RzBinFile *bf); + RzPVector /**/ *(*fields)(RzBinFile *bf); + RzPVector /**/ *(*libs)(RzBinFile *bf); + RzPVector /**/ *(*relocs)(RzBinFile *bf); + RzPVector /**/ *(*trycatch)(RzBinFile *bf); + RzPVector /**/ *(*classes)(RzBinFile *bf); + RzPVector /**/ *(*mem)(RzBinFile *bf); + RzPVector /**/ *(*patch_relocs)(RzBinFile *bf); + RzPVector /**/ *(*hashes)(RzBinFile *bf); + RzPVector /**/ *(*resources)(RzBinFile *bf); + char *(*signature)(RzBinFile *bf, bool json); + int (*demangle_type)(const char *str); + char *(*enrich_asm)(RzBinFile *bf, const char *asm_str, int asm_len); + ut64 (*get_offset)(RzBinFile *bf, int type, int idx); + char *(*get_name)(RzBinFile *bf, int type, int idx); + ut64 (*get_vaddr)(RzBinFile *bf, ut64 baddr, ut64 paddr, ut64 vaddr); + char *(*section_type_to_string)(ut64 type); + RzList /**/ *(*section_flag_to_rzlist)(ut64 flag); + RzBuffer *(*create)(RzBin *bin, const ut8 *code, int codelen, const ut8 *data, int datalen, RzBinArchOptions *opt); + char *(*demangle)(const char *str); + char *(*regstate)(RzBinFile *bf); + int (*file_type)(RzBinFile *bf); + char strfilter; + void *user; +} RzBinPlugin; + +typedef void (*RzBinSymbollCallback)(RzBinObject *obj, void *symbol); + +/** + * A virtual file is a binary buffer, exposed by a bin plugin for a loaded file. + * These virtual files can be used whenever data that is related to the file but + * not directly represented-as is in the raw file should be mapped into the virtual + * address space. + * Common examples for this include compressed segments or patching relocations. + * The idea is that the bin plugin exposes virtual files and then refers to them + * in the RzBinMap it returns. + * + * For example, when there is a binary format that contains a compressed segment + * called "text", the bin plugin would create a virtual file: + * + * RzBinVirtualFile { + * .name = "text_decompressed", + * .buf = rz_buf_new_with_bytes(, ), + * ... + * } + * + * which it can then use for mapping by referring to its exact name: + * + * RzBinMap { + * .vsize = , + * .name = "text", + * .vfile_name = "text_decompressed", + * ... + * } + * + * When RzBin is used as part of RzCore, these virtual files can be opened as RzIO + * files using an URI like `vfile:///`. By default, RzCore + * sets everything up automatically though so it is rather rare that one has to + * manually work with these URIs. + */ +typedef struct rz_bin_virtual_file_t { + RZ_OWN RZ_NONNULL char *name; + RZ_NONNULL RzBuffer *buf; + bool buf_owned; ///< whether buf is owned and freed by this RzBinVirtualFile +} RzBinVirtualFile; + +/// Description of a single memory mapping into virtual memory from a binary +typedef struct rz_bin_map_t { + /** + * \brief The offset into the binary file. + * Note: This is not related to the physical addresses an MMU would manage! + */ + ut64 paddr; + ut64 psize; ///< size of the data inside the file + ut64 vaddr; ///< address in the destination address space to map to + ut64 vsize; ///< size to map in the destination address space. If vsize > psize, excessive bytes are meant to be filled with 0 + RZ_NULLABLE char *name; + ut32 perm; + + /** + * If not NULL, the data will be taken from the virtual file returned by the + * plugin's virtual_file callback matching the given name. + * If NULL, the mapping will simply be taken from the raw file. + */ + RZ_NULLABLE char *vfile_name; +} RzBinMap; + +#define RZ_BIN_MAX_HANDLED_LAYOUT_SIZE (1024 * 1024 * 2) + +/** + * \brief A repetitive data layout of a section. The type will be applied to + * element_size * element_count. + */ +typedef struct rz_bin_section_format_t { + int /* RzAnalysisMetaType */ type; ///< The meta type of the elements. + ut64 element_size; ///< Size of an element in this section. + size_t count; ///< The number of consecutive elements in this section. +} RzBinSectionLayout; + +typedef struct rz_bin_section_t { + char *name; + ut64 size; + ut64 vsize; + ut64 vaddr; + /** + * \brief The offset into the binary file. + * Note: This is not related to the physical addresses an MMU would manage! + */ + ut64 paddr; + ut32 perm; + ut64 align; + // per section platform info + const char *arch; + ut64 type; + ut64 flags; + RzBinSectionLayout layout; + int bits; + bool has_strings; + bool is_data; + bool is_segment; +} RzBinSection; + +/** + * Structure to associate a segment with the list of sections that fall in that + * segment. + */ +typedef struct rz_bin_section_map_t { + const RzBinSection *segment; + RzPVector /**/ sections; +} RzBinSectionMap; + +typedef struct rz_bin_class_t { + char *name; ///< Class name + char *super; ///< Class parent name + int visibility; ///< Generic class visibility + char *visibility_str; ///< Only used by java to express the visibility of the class. + ut64 addr; ///< Virtual address pointing to some objc metadata + RzList /**/ *methods; + RzList /**/ *fields; +} RzBinClass; + +#define RzBinSectionName rz_offsetof(RzBinSection, name) +#define RzBinSectionOffset rz_offsetof(RzBinSection, offset) + +#define REBASE_PADDR(o, l, type_t) \ + do { \ + if ((o)->opts.loadaddr) { \ + void **_it; \ + type_t *_el; \ + rz_pvector_foreach ((l), _it) { \ + _el = *_it; \ + _el->paddr += (o)->opts.loadaddr; \ + } \ + } \ + } while (0) + +typedef struct rz_bin_symbol_t { + /* heap-allocated */ + char *name; + char *dname; + char *libname; + char *classname; + /* const-unique-strings */ + const char *forwarder; + const char *bind; + const char *type; + const char *rtype; + bool is_imported; + /* only used by java */ + char *visibility_str; + // ---------------- + // char descriptor[RZ_BIN_SIZEOF_STRINGS+1]; + ut64 vaddr; + /** + * \brief The offset into the binary file. + * Note: This is not related to the physical addresses an MMU would manage! + */ + ut64 paddr; + ut32 size; + ut32 ordinal; + ut32 visibility; + int bits; + /* see RZ_BIN_METH_* constants */ + ut64 method_flags; + int dup_count; +} RzBinSymbol; + +typedef struct rz_bin_import_t { + char *name; + char *dname; + char *libname; + const char *bind; + const char *type; + char *classname; + char *descriptor; + ut32 ordinal; + ut32 visibility; +} RzBinImport; + +typedef struct rz_bin_reloc_t { + RzBinRelocType type; + RzBinSymbol *symbol; + RzBinImport *import; + st64 addend; + ut64 vaddr; ///< the vaddr where the value should be patched into + /** + * \brief The offset into the binary file. + * Note: This is not related to the physical addresses an MMU would manage! + */ + ut64 paddr; + ut64 target_vaddr; ///< the target address that the patched reloc points to + ut64 section_vaddr; ///< the subsection address + ut32 visibility; + bool additive; + const char *print_name; ///< Name of the relocation type. NULL if none is specified. Not setting this field is deprecated. + /* is_ifunc: indirect function, `addend` points to a resolver function + * that returns the actual relocation value, e.g. chooses + * an optimized version depending on the CPU. + * cf. https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html + */ + bool is_ifunc; +} RzBinReloc; + +RZ_API ut64 rz_bin_reloc_size(RzBinReloc *reloc); + +/// Efficient storage of relocations to query by address +struct rz_bin_reloc_storage_t { + RzBinReloc **relocs; ///< all relocs, ordered by their vaddr + size_t relocs_count; + RzPVectorFree relocs_free; + RzBinReloc **target_relocs; ///< all relocs that have a valid target_vaddr, ordered by their target_vaddr. size is target_relocs_count! + size_t target_relocs_count; +}; // RzBinRelocStorage + +RZ_API RzBinRelocStorage *rz_bin_reloc_storage_new(RZ_OWN RzPVector /**/ *relocs); +RZ_API void rz_bin_reloc_storage_free(RzBinRelocStorage *storage); +RZ_API RzBinReloc *rz_bin_reloc_storage_get_reloc_in(RzBinRelocStorage *storage, ut64 vaddr, ut64 size); + +/// return true iff there is at least one reloc in the storage with a target address +static inline bool rz_bin_reloc_storage_targets_available(RzBinRelocStorage *storage) { + return storage->target_relocs_count != 0; +} + +RZ_API RzBinReloc *rz_bin_reloc_storage_get_reloc_to(RzBinRelocStorage *storage, ut64 vaddr); + +typedef struct rz_bin_string_t { + // TODO: rename string->name (avoid colisions) + char *string; + ut64 vaddr; + /** + * \brief The offset into the binary file. + * Note: This is not related to the physical addresses an MMU would manage! + */ + ut64 paddr; + ut32 size; ///< Size of buffer containing the string in bytes. Including the NUL byte. + ut32 length; // length of string in chars + RzStrEnc type; // Ascii Wide cp850 utf8 mutf8 ... +} RzBinString; + +typedef struct rz_bin_field_t { + ut64 vaddr; + /** + * \brief The offset into the binary file. + * Note: This is not related to the physical addresses an MMU would manage! + */ + ut64 paddr; + int size; + int offset; + char *name; + char *type; + char *comment; + char *format; + bool format_named; // whether format is the name of a format or a raw pf format string + ut64 flags; +} RzBinField; + +typedef struct rz_bin_class_field_t { + ut64 vaddr; + /** + * \brief The offset into the binary file. + * Note: This is not related to the physical addresses an MMU would manage! + */ + ut64 paddr; + char *name; + char *classname; + char *libname; + char *type; + ut32 visibility; + char *visibility_str; + ut64 flags; +} RzBinClassField; + +typedef struct rz_bin_mem_t { + char *name; + ut64 addr; + int size; + int perms; + RzPVector /**/ *mirrors; // for mirror access; stuff here should only create new maps not new fds +} RzBinMem; + +typedef struct rz_bin_resource_t { + size_t index; + char *name; + char *time; + ut64 vaddr; + ut64 size; + char *type; + char *language; +} RzBinResource; + +// TODO: deprecate rz_bin_is_big_endian +// TODO: has_dbg_syms... maybe flags? + +typedef ut64 (*RzBinGetOffset)(RzBin *bin, int type, int idx); +typedef char *(*RzBinGetName)(RzBin *bin, int type, int idx); +typedef const RzPVector *(*RzBinGetSections)(RzBinObject *obj); +typedef RzBinSection *(*RzBinGetSectionAt)(RzBin *bin, ut64 addr); +typedef char *(*RzBinDemangle)(RzBin *bin, const char *language, const char *mangled); + +typedef struct rz_bin_bind_t { + RzBin *bin; + RzBinGetOffset get_offset; + RzBinGetName get_name; + RzBinGetSections get_sections; + RzBinGetSectionAt get_vsect_at; + RzBinDemangle demangle; + ut32 visibility; +} RzBinBind; + +/** + * \brief Compare plugins by name (via strcmp). + */ +static inline int rz_bin_plugin_cmp(RZ_NULLABLE const RzBinPlugin *a, RZ_NULLABLE const RzBinPlugin *b) { + if (!a && !b) { + return 0; + } else if (!a) { + return -1; + } else if (!b) { + return 1; + } + return rz_str_cmp(a->name, b->name, -1); +} + +/** + * \brief Compare plugins by name (via strcmp). + */ +static inline int rz_bin_xtr_plugin_cmp(RZ_NULLABLE const RzBinXtrPlugin *a, RZ_NULLABLE const RzBinXtrPlugin *b) { + if (!a && !b) { + return 0; + } else if (!a) { + return -1; + } else if (!b) { + return 1; + } + return rz_str_cmp(a->name, b->name, -1); +} + +RZ_API RzBinField *rz_bin_field_new(ut64 paddr, ut64 vaddr, int size, const char *name, const char *comment, const char *format, bool format_named); +RZ_API void rz_bin_field_free(RZ_NULLABLE RzBinField *field); +RZ_API RzBinClassField *rz_bin_class_field_new(ut64 vaddr, ut64 paddr, const char *name, const char *classname, const char *libname, const char *type); +RZ_API void rz_bin_class_field_free(RZ_NULLABLE RzBinClassField *field); +RZ_API void rz_bin_class_free(RZ_NULLABLE RzBinClass *k); + +RZ_API RZ_OWN RzBinVirtualFile *rz_bin_virtual_file_clone(RZ_BORROW RZ_NONNULL RzBinVirtualFile *vfile); +RZ_API void rz_bin_virtual_file_free(RZ_NULLABLE RzBinVirtualFile *vfile); +RZ_API RZ_OWN RzBinMap *rz_bin_map_clone(RZ_NONNULL RzBinMap *map); +RZ_API void rz_bin_map_free(RZ_NULLABLE RzBinMap *map); +RZ_API bool rz_bin_map_is_data(RZ_NONNULL const RzBinMap *map); +RZ_API RZ_OWN RzPVector /**/ *rz_bin_maps_of_file_sections(RZ_NONNULL RzBinFile *binfile); +RZ_API RzPVector /**/ *rz_bin_sections_of_maps(RzPVector /**/ *maps); +RZ_API RzBinSection *rz_bin_section_new(const char *name); +RZ_API void rz_bin_section_free(RZ_NULLABLE RzBinSection *bs); +RZ_API bool rz_bin_section_is_data(RZ_NONNULL const RzBinSection *section); +RZ_API RZ_OWN char *rz_bin_section_type_to_string(RzBin *bin, int type); +RZ_API RZ_OWN RzList /**/ *rz_bin_section_flag_to_list(RzBin *bin, ut64 flag); +RZ_API void rz_bin_info_free(RZ_NULLABLE RzBinInfo *rb); +RZ_API void rz_bin_import_free(RZ_NULLABLE RzBinImport *imp); +RZ_API void rz_bin_resource_free(RZ_NULLABLE RzBinResource *res); +RZ_API void rz_bin_symbol_free(RZ_NULLABLE RzBinSymbol *sym); +static inline bool rz_bin_reloc_has_target(RzBinReloc *reloc) { + return reloc->target_vaddr && reloc->target_vaddr != UT64_MAX; +} +RZ_API void rz_bin_reloc_free(RZ_NULLABLE RzBinReloc *reloc); +RZ_API RzBinSymbol *rz_bin_symbol_new(const char *name, ut64 paddr, ut64 vaddr); +RZ_API void rz_bin_string_free(RZ_NULLABLE void *_str); + +#ifdef RZ_API + +typedef struct rz_bin_options_t { + const char *pluginname; + RzBinObjectLoadOptions obj_opts; + ut64 sz; + int xtr_idx; // load Nth binary + int fd; + const char *filename; +} RzBinOptions; + +typedef struct rz_event_bin_file_del_t { + RzBinFile *bf; +} RzEventBinFileDel; + +RZ_API RzBinImport *rz_bin_import_clone(RzBinImport *o); +RZ_API RZ_OWN char *rz_bin_symbol_name(RZ_NONNULL RzBinSymbol *s); +typedef void (*RzBinSymbolCallback)(RzBinObject *obj, RzBinSymbol *symbol); + +// common functionality for patching relocs +RZ_API ut64 rz_bin_relocs_patch_find_targets_map_base(RzPVector /**/ *maps, ut64 target_sz); + +typedef struct rz_bin_reloc_target_builder RzBinRelocTargetBuilder; +RZ_API RzBinRelocTargetBuilder *rz_bin_reloc_target_builder_new(ut64 target_size, ut64 target_base); +RZ_API void rz_bin_reloc_target_builder_free(RZ_NULLABLE RzBinRelocTargetBuilder *builder); +RZ_API ut64 rz_bin_reloc_target_builder_get_target(RzBinRelocTargetBuilder *builder, ut64 sym); + +RZ_API void rz_bin_relocs_patch_maps(RZ_NONNULL RzPVector /**/ *maps, + RZ_NULLABLE RzBuffer *buf_patched, ut64 buf_patched_offset, + ut64 target_vfile_base, ut64 target_vfile_size, + RZ_NONNULL const char *vfile_name_patched, RZ_NONNULL const char *vfile_name_reloc_targets); + +// options functions +RZ_API void rz_bin_options_init(RzBinOptions *opt, int fd, ut64 baseaddr, ut64 loadaddr, bool patch_relocs); +RZ_API void rz_bin_arch_options_init(RzBinArchOptions *opt, const char *arch, int bits); + +// open/close/reload functions +RZ_API RzBin *rz_bin_new(void); +RZ_API void rz_bin_free(RZ_NULLABLE RzBin *bin); +RZ_API RzBinFile *rz_bin_open(RzBin *bin, const char *file, RzBinOptions *opt); +RZ_API RzBinFile *rz_bin_open_io(RzBin *bin, RzBinOptions *opt); +RZ_API RzBinFile *rz_bin_open_buf(RzBin *bin, RzBuffer *buf, RzBinOptions *opt); +RZ_API RzBinFile *rz_bin_reload(RzBin *bin, RzBinFile *bf, ut64 baseaddr); + +// plugins/bind functions +RZ_API void rz_bin_bind(RzBin *b, RzBinBind *bnd); +RZ_API bool rz_bin_plugin_add(RzBin *bin, RZ_NONNULL RzBinPlugin *plugin); +RZ_API bool rz_bin_plugin_del(RzBin *bin, RZ_NONNULL RzBinPlugin *plugin); +RZ_API bool rz_bin_xtr_plugin_add(RzBin *bin, RZ_NONNULL RzBinXtrPlugin *plugin); +RZ_API bool rz_bin_xtr_plugin_del(RzBin *bin, RZ_NONNULL RzBinXtrPlugin *plugin); +RZ_API bool rz_bin_list_plugin(RzBin *bin, const char *name, PJ *pj, int json); +RZ_API RzBinPlugin *rz_bin_get_binplugin_by_buffer(RzBin *bin, RzBuffer *buf); +RZ_API const RzBinPlugin *rz_bin_plugin_get(RZ_NONNULL RzBin *bin, RZ_NONNULL const char *name); +RZ_API const RzBinXtrPlugin *rz_bin_xtrplugin_get(RZ_NONNULL RzBin *bin, RZ_NONNULL const char *name); +RZ_API void rz_bin_force_plugin(RzBin *bin, const char *pname); + +// get/set various bin information +RZ_API ut64 rz_bin_get_baddr(RzBin *bin); +RZ_API ut64 rz_bin_file_get_baddr(RzBinFile *bf); +RZ_API void rz_bin_set_user_ptr(RzBin *bin, void *user); +RZ_API void rz_bin_set_baddr(RzBin *bin, ut64 baddr); +RZ_API ut64 rz_bin_get_laddr(RzBin *bin); +RZ_API ut64 rz_bin_get_size(RzBin *bin); + +// string search within the bin +RZ_API void rz_bin_string_search_opt_init(RZ_NONNULL RzBinStringSearchOpt *opt); +RZ_API RZ_OWN RzPVector /**/ *rz_bin_file_strings(RZ_NONNULL RzBinFile *bf, RZ_NONNULL const RzBinStringSearchOpt *opt); + +// use RzBinFile instead +RZ_DEPRECATE RZ_API int rz_bin_is_static(RZ_NONNULL RzBin *bin); +RZ_API RZ_OWN RzPVector /**/ *rz_bin_file_get_trycatch(RZ_NONNULL RzBinFile *bf); + +RZ_API RZ_BORROW const RzPVector /**/ *rz_bin_object_get_entries(RZ_NONNULL RzBinObject *obj); +RZ_API const RzPVector /**/ *rz_bin_object_get_fields(RZ_NONNULL RzBinObject *obj); +RZ_API const RzPVector /**/ *rz_bin_object_get_imports(RZ_NONNULL RzBinObject *obj); +RZ_API const RzBinInfo *rz_bin_object_get_info(RZ_NONNULL RzBinObject *obj); +RZ_API const RzStructuredData *rz_bin_object_get_structured_data(RZ_BORROW RZ_NONNULL RzBinObject *obj); +RZ_API const RzPVector /**/ *rz_bin_object_get_libs(RZ_NONNULL RzBinObject *obj); +RZ_API const RzPVector /**/ *rz_bin_object_get_sections_all(RZ_NONNULL RzBinObject *obj); +RZ_API RZ_OWN RzPVector /**/ *rz_bin_object_get_sections(RZ_NONNULL RzBinObject *obj); +RZ_API RZ_OWN RzPVector /**/ *rz_bin_object_get_segments(RZ_NONNULL RzBinObject *obj); +RZ_API RZ_OWN RzPVector /**/ *rz_bin_object_get_maps(RZ_NONNULL RzBinObject *obj); +RZ_API const RzPVector /**/ *rz_bin_object_get_classes(RZ_NONNULL RzBinObject *obj); +RZ_API const RzPVector /**/ *rz_bin_object_get_strings(RZ_NONNULL RzBinObject *obj); +RZ_API RZ_BORROW const RzPVector /**/ *rz_bin_object_get_mem(RZ_NONNULL RzBinObject *obj); +RZ_API const RzPVector /**/ *rz_bin_object_get_resources(RZ_NONNULL RzBinObject *obj); +RZ_API const RzPVector /**/ *rz_bin_object_get_symbols(RZ_NONNULL RzBinObject *obj); +RZ_API bool rz_bin_object_reset_strings(RZ_NONNULL RzBin *bin, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzBinObject *obj); +RZ_API RZ_BORROW RzBinString *rz_bin_object_get_string_at(RZ_NONNULL RzBinObject *obj, ut64 address, bool is_va); +RZ_API bool rz_bin_object_is_big_endian(RZ_NONNULL RzBinObject *obj); +RZ_API bool rz_bin_object_is_static(RZ_NONNULL RzBinObject *obj); +RZ_API RZ_OWN RzVector /**/ *rz_bin_object_sections_mapping_list(RZ_NONNULL RzBinObject *obj); +RZ_API RZ_OWN RzPVector /**/ *rz_bin_object_get_maps_at(RzBinObject *o, ut64 off, bool va); +RZ_API RZ_BORROW RzBinMap *rz_bin_object_get_map_at(RZ_NONNULL RzBinObject *o, ut64 off, bool va); +RZ_API ut64 rz_bin_object_p2v(RZ_NONNULL RzBinObject *obj, ut64 paddr); +RZ_API RzVector /**/ *rz_bin_object_p2v_all(RZ_NONNULL RzBinObject *obj, ut64 paddr); +RZ_API ut64 rz_bin_object_v2p(RZ_NONNULL RzBinObject *obj, ut64 vaddr); + +RZ_API RzBinLanguage rz_bin_language_detect(RzBinFile *binfile); +RZ_API RzBinLanguage rz_bin_language_to_id(const char *language); +RZ_API const char *rz_bin_language_to_string(RzBinLanguage language); + +RZ_API RzBinFile *rz_bin_cur(RzBin *bin); +RZ_API RzBinObject *rz_bin_cur_object(RzBin *bin); + +// select/list binfiles functions +RZ_API bool rz_bin_select(RzBin *bin, RZ_NONNULL const char *arch, int bits, RZ_NULLABLE const char *machine, RZ_NULLABLE const char *filename); +RZ_API bool rz_bin_select_bfid(RzBin *bin, ut32 bf_id); +RZ_API bool rz_bin_use_arch(RzBin *bin, const char *arch, int bits, RZ_NULLABLE const char *machine, RZ_NULLABLE const char *filename); +RZ_API RzBuffer *rz_bin_create(RzBin *bin, const char *plugin_name, const ut8 *code, int codelen, const ut8 *data, int datalen, RzBinArchOptions *opt); + +RZ_API const char *rz_bin_entry_type_string(int etype); +RZ_API ut64 rz_bin_get_first_entrypoint(RZ_NULLABLE RzBinObject *obj); + +RZ_API bool rz_bin_file_set_xtr_data_as_current_obj( + RZ_BORROW RZ_NONNULL RzBin *bin, + RZ_BORROW RZ_NONNULL RzBinFile *bf, + RZ_BORROW RZ_NONNULL RzBinObjectLoadOptions *opts, + RZ_BORROW RZ_NONNULL RzBinXtrData *data); + +// RzBinFile.get +RZ_API RzBinFile *rz_bin_file_at(RzBin *bin, ut64 addr); +RZ_API RzPVector /**/ *rz_bin_file_get_symbols(RzBinFile *bf); +// RzBinFile.find +RZ_API RZ_BORROW RzBinFile *rz_bin_file_find_by_arch_bits(RzBin *bin, const char *arch, int bits, RZ_NULLABLE const char *machine, RZ_NULLABLE const char *filename); +RZ_API RzBinFile *rz_bin_file_find_by_id(RzBin *bin, ut32 bin_id); +RZ_API RzBinFile *rz_bin_file_find_by_fd(RzBin *bin, ut32 bin_fd); +RZ_API RzBinFile *rz_bin_file_find_by_name(RzBin *bin, const char *name); + +RZ_API bool rz_bin_file_set_obj(RZ_BORROW RZ_NONNULL RzBinFile *bf, RZ_OWN RZ_NULLABLE RzBinObject *obj); +RZ_API bool rz_bin_set_cur_binfile(RzBin *bin, RzBinFile *bf); +RZ_API bool rz_bin_file_set_cur_by_fd(RzBin *bin, ut32 bin_fd); +RZ_API bool rz_bin_file_set_cur_by_id(RzBin *bin, ut32 bin_id); +RZ_API bool rz_bin_file_set_cur_by_name(RzBin *bin, const char *name); +RZ_API ut64 rz_bin_file_delete_all(RzBin *bin); +RZ_API bool rz_bin_file_delete(RzBin *bin, RzBinFile *bf); +RZ_API RZ_OWN RzPVector /**/ *rz_bin_file_compute_hashes(RzBin *bin, RzBinFile *bf, ut64 limit); +RZ_API RZ_OWN RzPVector /**/ *rz_bin_file_set_hashes(RzBin *bin, RZ_OWN RzPVector /**/ *new_hashes); +RZ_API RzBinPlugin *rz_bin_file_cur_plugin(RzBinFile *binfile); +RZ_API void rz_bin_file_hash_free(RZ_NULLABLE RzBinFileHash *fhash); + +static inline bool rz_bin_file_rclass_is(RzBinFile *bf, const char *x) { + const char *rc = (bf && bf->o && bf->o->info) ? bf->o->info->rclass : NULL; + return RZ_STR_EQ(rc, x); +} + +// binobject functions +RZ_API ut64 rz_bin_object_addr_with_base(RzBinObject *o, ut64 addr); +RZ_API ut64 rz_bin_object_get_vaddr(RzBinObject *o, ut64 paddr, ut64 vaddr); +RZ_API RZ_BORROW const RzBinAddr *rz_bin_object_get_special_symbol(RZ_NULLABLE RzBinObject *o, RzBinSpecialSymbol sym); +RZ_API RzBinRelocStorage *rz_bin_object_patch_relocs(RzBinFile *bf, RzBinObject *o); +RZ_API RzBinSymbol *rz_bin_object_get_symbol_of_import(RzBinObject *o, RzBinImport *imp); +RZ_API RzBinVirtualFile *rz_bin_object_get_virtual_file(RzBinObject *o, const char *name); +RZ_API RZ_BORROW RzBinSymbol *rz_bin_object_get_symbol_at(RZ_NONNULL RzBinObject *o, ut64 off, bool va); + +// class +RZ_API RZ_BORROW RzBinClass *rz_bin_object_find_class(RZ_NONNULL RzBinObject *o, RZ_NONNULL const char *name); +RZ_API RzBinSymbol *rz_bin_object_find_method(RZ_NONNULL RzBinObject *o, RZ_NONNULL const char *klass, RZ_NONNULL const char *method); +RZ_API RzBinSymbol *rz_bin_object_find_method_by_vaddr(RZ_NONNULL RzBinObject *o, ut64 vaddr); +RZ_API RzBinClassField *rz_bin_object_find_field(RZ_NONNULL RzBinObject *o, RZ_NONNULL const char *klass, RZ_NONNULL const char *field); +RZ_API RZ_BORROW RzBinClass *rz_bin_object_add_class(RZ_NONNULL RzBinObject *o, RZ_NONNULL const char *name, RZ_NULLABLE const char *super, ut64 vaddr); +RZ_API RZ_BORROW RzBinSymbol *rz_bin_object_add_method(RZ_NONNULL RzBinObject *o, RZ_NONNULL const char *klass, RZ_NONNULL const char *method, ut64 paddr, ut64 vaddr); +RZ_API RZ_BORROW RzBinClassField *rz_bin_object_add_field(RZ_NONNULL RzBinObject *o, RZ_NONNULL const char *klass, RZ_NONNULL const char *field, ut64 paddr, ut64 vaddr); + +RZ_API void rz_bin_mem_free(RZ_NULLABLE void *data); + +// demangle functions +RZ_API void rz_bin_demangle_with_flags(RZ_NONNULL RzBin *bin, RzDemanglerFlag flags); +RZ_API RZ_OWN char *rz_bin_demangle(RZ_NULLABLE RzBin *bin, RZ_NULLABLE const char *language, RZ_NULLABLE const char *mangled); +RZ_API const char *rz_bin_get_meth_flag_string(ut64 flag, bool compact); + +RZ_API RZ_BORROW RzBinSection *rz_bin_get_section_at(RZ_NONNULL RzBinObject *o, ut64 off, bool va); +RZ_API RZ_BORROW RzBinSection *rz_bin_get_segment_at(RZ_NONNULL RzBinObject *o, ut64 off, bool va); + +/* filter.c */ +RZ_API void rz_bin_load_filter(RzBin *bin, ut64 rules); +RZ_API bool rz_bin_strpurge(RzBin *bin, const char *str, ut64 addr); +RZ_API bool rz_bin_string_filter(RzBin *bin, const char *str, ut64 addr); + +/* bin string */ +RZ_API RZ_OWN RzBinStrDb *rz_bin_string_database_new(RZ_NULLABLE RZ_OWN RzPVector /**/ *pvector); +RZ_API void rz_bin_string_database_free(RZ_NULLABLE RzBinStrDb *db); +RZ_API bool rz_bin_string_database_add(RZ_NONNULL RzBinStrDb *db, RZ_NONNULL RzBinString *bstr); +RZ_API bool rz_bin_string_database_remove(RZ_NONNULL RzBinStrDb *db, ut64 address, bool is_va); + +#ifdef __cplusplus +} +#endif + +#endif +#endif diff --git a/dest/include/librz/rz_bin_dwarf.h b/dest/include/librz/rz_bin_dwarf.h new file mode 100644 index 00000000000..574c170f42c --- /dev/null +++ b/dest/include/librz/rz_bin_dwarf.h @@ -0,0 +1,1911 @@ +#ifndef RZ_BIN_DWARF_H +#define RZ_BIN_DWARF_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + DW_LNS_copy = 0x01, + DW_LNS_advance_pc = 0x02, + DW_LNS_advance_line = 0x03, + DW_LNS_set_file = 0x04, + DW_LNS_set_column = 0x05, + DW_LNS_negate_stmt = 0x06, + DW_LNS_set_basic_block = 0x07, + DW_LNS_const_add_pc = 0x08, + DW_LNS_fixed_advance_pc = 0x09, + DW_LNS_set_prologue_end = 0x0a, /* DWARF3 */ + DW_LNS_set_epilogue_begin = 0x0b, /* DWARF3 */ + DW_LNS_set_isa = 0x0c, /* DWARF3 */ +} DW_LNS; + +/* Line number extended opcode name. */ +typedef enum { + DW_LNE_end_sequence = 0x01, + DW_LNE_set_address = 0x02, + DW_LNE_define_file = 0x03, + DW_LNE_set_discriminator = 0x04, /* DWARF4 */ + DW_LNE_lo_user = 0x80, /* DWARF3 */ + DW_LNE_hi_user = 0xff, /* DWARF3 */ + /* HP extensions. */ + DW_LNE_HP_negate_is_UV_update = 0x11, /* 17 HP */ + DW_LNE_HP_push_context = 0x12, /* 18 HP */ + DW_LNE_HP_pop_context = 0x13, /* 19 HP */ + DW_LNE_HP_set_file_line_column = 0x14, /* 20 HP */ + DW_LNE_HP_set_routine_name = 0x15, /* 21 HP */ + DW_LNE_HP_set_sequence = 0x16, /* 22 HP */ + DW_LNE_HP_negate_post_semantics = 0x17, /* 23 HP */ + DW_LNE_HP_negate_function_exit = 0x18, /* 24 HP */ + DW_LNE_HP_negate_front_end_logical = 0x19, /* 25 HP */ + DW_LNE_HP_define_proc = 0x20, /* 32 HP */ +} DW_LNE; + +/* debug_info tags */ +// this is not a real dwarf named entry, but I wanted to give it +// a name so it's more obvious and readable that it's just a type of entry +typedef enum { + DW_TAG_null_entry = 0x00, + DW_TAG_array_type = 0x01, + DW_TAG_class_type = 0x02, + DW_TAG_entry_point = 0x03, + DW_TAG_enumeration_type = 0x04, + DW_TAG_formal_parameter = 0x05, + DW_TAG_imported_declaration = 0x08, + DW_TAG_label = 0x0a, + DW_TAG_lexical_block = 0x0b, + DW_TAG_member = 0x0d, + DW_TAG_pointer_type = 0x0f, + DW_TAG_reference_type = 0x10, + DW_TAG_compile_unit = 0x11, // + DW_TAG_string_type = 0x12, + DW_TAG_structure_type = 0x13, + DW_TAG_subroutine_type = 0x15, + DW_TAG_typedef = 0x16, + DW_TAG_union_type = 0x17, + DW_TAG_unspecified_parameters = 0x18, + DW_TAG_variant = 0x19, + DW_TAG_common_block = 0x1a, + DW_TAG_common_inclusion = 0x1b, + DW_TAG_inheritance = 0x1c, + DW_TAG_inlined_subroutine = 0x1d, + DW_TAG_module = 0x1e, + DW_TAG_ptr_to_member_type = 0x1f, + DW_TAG_set_type = 0x20, + DW_TAG_subrange_type = 0x21, + DW_TAG_with_stmt = 0x22, + DW_TAG_access_declaration = 0x23, + DW_TAG_base_type = 0x24, + DW_TAG_catch_block = 0x25, + DW_TAG_const_type = 0x26, + DW_TAG_constant = 0x27, + DW_TAG_enumerator = 0x28, + DW_TAG_file_type = 0x29, + DW_TAG_friend = 0x2a, + DW_TAG_namelist = 0x2b, + /* Early releases of this header had the following + misspelled with a trailing 's' */ + DW_TAG_namelist_item = 0x2c, /* DWARF3/2 spelling */ + DW_TAG_namelist_items = 0x2c, /* SGI misspelling/typo */ + DW_TAG_packed_type = 0x2d, + DW_TAG_subprogram = 0x2e, + /* The DWARF2 document had two spellings of the following + two TAGs, DWARF3 specifies the longer spelling. */ + DW_TAG_template_type_parameter = 0x2f, /* DWARF3/2 spelling*/ + DW_TAG_template_type_param = 0x2f, /* DWARF2 spelling*/ + DW_TAG_template_value_parameter = 0x30, /* DWARF3/2 spelling*/ + DW_TAG_template_value_param = 0x30, /* DWARF2 spelling*/ + DW_TAG_thrown_type = 0x31, + DW_TAG_try_block = 0x32, + DW_TAG_variant_part = 0x33, + DW_TAG_variable = 0x34, + DW_TAG_volatile_type = 0x35, + DW_TAG_dwarf_procedure = 0x36, /* DWARF3 */ + DW_TAG_restrict_type = 0x37, /* DWARF3 */ + DW_TAG_interface_type = 0x38, /* DWARF3 */ + DW_TAG_namespace = 0x39, /* DWARF3 */ + DW_TAG_imported_module = 0x3a, /* DWARF3 */ + DW_TAG_unspecified_type = 0x3b, /* DWARF3 */ + DW_TAG_partial_unit = 0x3c, /* DWARF3 */ + DW_TAG_imported_unit = 0x3d, /* DWARF3 */ + /* Do not use DW_TAG_mutable_type */ + DW_TAG_mutable_type = 0x3e, /* Withdrawn from DWARF3 by DWARF3f. */ + DW_TAG_condition = 0x3f, /* DWARF3f */ + DW_TAG_shared_type = 0x40, /* DWARF3f */ + DW_TAG_type_unit = 0x41, /* DWARF4 */ + DW_TAG_rvalue_reference_type = 0x42, /* DWARF4 */ + DW_TAG_template_alias = 0x43, /* DWARF4 */ + + // DWARF 5. + DW_TAG_coarray_type = 0x44, + DW_TAG_generic_subrange = 0x45, + DW_TAG_dynamic_type = 0x46, + DW_TAG_atomic_type = 0x47, + DW_TAG_call_site = 0x48, + DW_TAG_call_site_parameter = 0x49, + DW_TAG_skeleton_unit = 0x4a, + DW_TAG_immutable_type = 0x4b, + + DW_TAG_lo_user = 0x4080, + DW_TAG_hi_user = 0xffff, + + // SGI/MIPS extensions. + DW_TAG_MIPS_loop = 0x4081, + + // HP extensions. + DW_TAG_HP_array_descriptor = 0x4090, + DW_TAG_HP_Bliss_field = 0x4091, + DW_TAG_HP_Bliss_field_set = 0x4092, + + // GNU extensions. + DW_TAG_format_label = 0x4101, + DW_TAG_function_template = 0x4102, + DW_TAG_class_template = 0x4103, + DW_TAG_GNU_BINCL = 0x4104, + DW_TAG_GNU_EINCL = 0x4105, + DW_TAG_GNU_template_template_param = 0x4106, + DW_TAG_GNU_template_parameter_pack = 0x4107, + DW_TAG_GNU_formal_parameter_pack = 0x4108, + DW_TAG_GNU_call_site = 0x4109, + DW_TAG_GNU_call_site_parameter = 0x410a, + + DW_TAG_APPLE_property = 0x4200, + + // SUN extensions. + DW_TAG_SUN_function_template = 0x4201, + DW_TAG_SUN_class_template = 0x4202, + DW_TAG_SUN_struct_template = 0x4203, + DW_TAG_SUN_union_template = 0x4204, + DW_TAG_SUN_indirect_inheritance = 0x4205, + DW_TAG_SUN_codeflags = 0x4206, + DW_TAG_SUN_memop_info = 0x4207, + DW_TAG_SUN_omp_child_func = 0x4208, + DW_TAG_SUN_rtti_descriptor = 0x4209, + DW_TAG_SUN_dtor_info = 0x420a, + DW_TAG_SUN_dtor = 0x420b, + DW_TAG_SUN_f90_interface = 0x420c, + DW_TAG_SUN_fortran_vax_structure = 0x420d, + + // ALTIUM extensions. + DW_TAG_ALTIUM_circ_type = 0x5101, + DW_TAG_ALTIUM_mwa_circ_type = 0x5102, + DW_TAG_ALTIUM_rev_carry_type = 0x5103, + DW_TAG_ALTIUM_rom = 0x5111, + + // Extensions for UPC. + DW_TAG_upc_shared_type = 0x8765, + DW_TAG_upc_strict_type = 0x8766, + DW_TAG_upc_relaxed_type = 0x8767, + + // PGI (STMicroelectronics) extensions. + DW_TAG_PGI_kanji_type = 0xa000, + DW_TAG_PGI_interface_block = 0xa020, + + // Borland extensions. + DW_TAG_BORLAND_property = 0xb000, + DW_TAG_BORLAND_Delphi_string = 0xb001, + DW_TAG_BORLAND_Delphi_dynamic_array = 0xb002, + DW_TAG_BORLAND_Delphi_set = 0xb003, + DW_TAG_BORLAND_Delphi_variant = 0xb004, +} DW_TAG; + +typedef enum { + DW_CHILDREN_no = 0x00, + DW_CHILDREN_yes = 0x01, +} DW_CHILDREN; + +typedef enum { + DW_AT_sibling = 0x01, + DW_AT_location = 0x02, + DW_AT_name = 0x03, + DW_AT_ordering = 0x09, + DW_AT_byte_size = 0x0b, + DW_AT_bit_offset = 0x0c, + DW_AT_bit_size = 0x0d, + DW_AT_stmt_list = 0x10, + DW_AT_low_pc = 0x11, + DW_AT_high_pc = 0x12, + DW_AT_language = 0x13, + DW_AT_discr = 0x15, + DW_AT_discr_value = 0x16, + DW_AT_visibility = 0x17, + DW_AT_import = 0x18, + DW_AT_string_length = 0x19, + DW_AT_common_reference = 0x1a, + DW_AT_comp_dir = 0x1b, + DW_AT_const_value = 0x1c, + DW_AT_containing_type = 0x1d, + DW_AT_default_value = 0x1e, + DW_AT_inline = 0x20, + DW_AT_is_optional = 0x21, + DW_AT_lower_bound = 0x22, + DW_AT_producer = 0x25, + DW_AT_prototyped = 0x27, + DW_AT_return_addr = 0x2a, + DW_AT_start_scope = 0x2c, + DW_AT_stride_size = 0x2e, + DW_AT_upper_bound = 0x2f, + DW_AT_abstract_origin = 0x31, + DW_AT_accessibility = 0x32, + DW_AT_address_class = 0x33, + DW_AT_artificial = 0x34, + DW_AT_base_types = 0x35, + DW_AT_calling_convention = 0x36, + DW_AT_count = 0x37, + DW_AT_data_member_location = 0x38, + DW_AT_decl_column = 0x39, + DW_AT_decl_file = 0x3a, + DW_AT_decl_line = 0x3b, + DW_AT_declaration = 0x3c, + DW_AT_discr_list = 0x3d, + DW_AT_encoding = 0x3e, + DW_AT_external = 0x3f, + DW_AT_frame_base = 0x40, + DW_AT_friend = 0x41, + DW_AT_identifier_case = 0x42, + DW_AT_macro_info = 0x43, + DW_AT_namelist_item = 0x44, + DW_AT_priority = 0x45, + DW_AT_segment = 0x46, + DW_AT_specification = 0x47, + DW_AT_static_link = 0x48, + DW_AT_type = 0x49, + DW_AT_use_location = 0x4a, + DW_AT_variable_parameter = 0x4b, + DW_AT_virtuality = 0x4c, + DW_AT_vtable_elem_location = 0x4d, + DW_AT_allocated = 0x4e, // DWARF 3 additions start + DW_AT_associated = 0x4f, + DW_AT_data_location = 0x50, + DW_AT_byte_stride = 0x51, + DW_AT_entry_pc = 0x52, + DW_AT_use_UTF8 = 0x53, + DW_AT_extension = 0x54, + DW_AT_ranges = 0x55, + DW_AT_trampoline = 0x56, + DW_AT_call_column = 0x57, + DW_AT_call_file = 0x58, + DW_AT_call_line = 0x59, + DW_AT_description = 0x5a, + DW_AT_binary_scale = 0x5b, + DW_AT_decimal_scale = 0x5c, + DW_AT_small = 0x5d, + DW_AT_decimal_sign = 0x5e, + DW_AT_digit_count = 0x5f, + DW_AT_picture_string = 0x60, + DW_AT_mutable = 0x61, + DW_AT_threads_scaled = 0x62, + DW_AT_explicit = 0x63, + DW_AT_object_pointer = 0x64, + DW_AT_endianity = 0x65, + DW_AT_elemental = 0x66, + DW_AT_pure = 0x67, + DW_AT_recursive = 0x68, // DWARF 3 additions end + DW_AT_signature = 0x69, + DW_AT_main_subprogram = 0x6a, + DW_AT_data_bit_offset = 0x6b, + DW_AT_const_expr = 0x6c, + DW_AT_enum_class = 0x6d, + DW_AT_linkage_name = 0x6e, + DW_AT_string_length_bit_size = 0x6f, + DW_AT_string_length_byte_size = 0x70, + DW_AT_rank = 0x71, + DW_AT_str_offsets_base = 0x72, + DW_AT_addr_base = 0x73, + DW_AT_rnglists_base = 0x74, + DW_AT_reserved = 0x75, + DW_AT_dwo_name = 0x76, + DW_AT_reference = 0x77, + DW_AT_rvalue_reference = 0x78, + DW_AT_macros = 0x79, + DW_AT_call_all_calls = 0x7a, + DW_AT_call_all_source_calls = 0x7b, + DW_AT_call_all_tail_calls = 0x7c, + DW_AT_call_return_pc = 0x7d, + DW_AT_call_value = 0x7e, + DW_AT_call_origin = 0x7f, + DW_AT_call_parameter = 0x80, + DW_AT_call_pc = 0x81, + DW_AT_call_tail_call = 0x82, + DW_AT_call_target = 0x83, + DW_AT_call_target_clobbered = 0x84, + DW_AT_call_data_location = 0x85, + DW_AT_call_data_value = 0x86, + DW_AT_noreturn = 0x87, + DW_AT_alignment = 0x88, + DW_AT_export_symbols = 0x89, + DW_AT_deleted = 0x8a, + DW_AT_defaulted = 0x8b, + DW_AT_loclists_base = 0x8c, + /* <_lo_user ; _hi_user> Interval is reserved for vendor extensions */ + DW_AT_lo_user = 0x2000, + // extensions: + DW_AT_MIPS_fde = 0x2001, + DW_AT_MIPS_loop_begin = 0x2002, + DW_AT_MIPS_tail_loop_begin = 0x2003, + DW_AT_MIPS_epilog_begin = 0x2004, + DW_AT_MIPS_loop_unroll_factor = 0x2005, + DW_AT_MIPS_software_pipeline_depth = 0x2006, + DW_AT_MIPS_linkage_name = 0x2007, // Same as DWARF4 DW_AT_linkage_name + DW_AT_MIPS_stride = 0x2008, + DW_AT_MIPS_abstract_name = 0x2009, + DW_AT_MIPS_clone_origin = 0x200a, + DW_AT_MIPS_has_inlines = 0x200b, + DW_AT_MIPS_stride_byte = 0x200c, + DW_AT_MIPS_stride_elem = 0x200d, + DW_AT_MIPS_ptr_dopetype = 0x200e, + DW_AT_MIPS_allocatable_dopetype = 0x200f, + DW_AT_MIPS_assumed_shape_dopetype = 0x2010, + // This one appears to have only been implemented by Open64 for + // fortran and may conflict with other extensions. + DW_AT_MIPS_assumed_size = 0x2011, + // TODO: HP/CPQ extensions. + // These conflict with the MIPS extensions. + DW_AT_INTEL_other_endian = 0x2026, + // GNU extensions + DW_AT_sf_names = 0x2101, + DW_AT_src_info = 0x2102, + DW_AT_mac_info = 0x2103, + DW_AT_src_coords = 0x2104, + DW_AT_body_begin = 0x2105, + DW_AT_body_end = 0x2106, + DW_AT_GNU_vector = 0x2107, + DW_AT_GNU_guarded_by = 0x2108, + DW_AT_GNU_pt_guarded_by = 0x2109, + DW_AT_GNU_guarded = 0x210a, + DW_AT_GNU_pt_guarded = 0x210b, + DW_AT_GNU_locks_excluded = 0x210c, + DW_AT_GNU_exclusive_locks_required = 0x210d, + DW_AT_GNU_shared_locks_required = 0x210e, + DW_AT_GNU_odr_signature = 0x210f, + DW_AT_GNU_template_name = 0x2110, + DW_AT_GNU_call_site_value = 0x2111, + DW_AT_GNU_call_site_data_value = 0x2112, + DW_AT_GNU_call_site_target = 0x2113, + DW_AT_GNU_call_site_target_clobbered = 0x2114, + DW_AT_GNU_tail_call = 0x2115, + DW_AT_GNU_all_tail_call_sites = 0x2116, + DW_AT_GNU_all_call_sites = 0x2117, + DW_AT_GNU_all_source_call_sites = 0x2118, + DW_AT_GNU_macros = 0x2119, + DW_AT_GNU_deleted = 0x211a, + // Extensions for Fission proposal. + DW_AT_GNU_dwo_name = 0x2130, + DW_AT_GNU_dwo_id = 0x2131, + DW_AT_GNU_ranges_base = 0x2132, + DW_AT_GNU_addr_base = 0x2133, + DW_AT_GNU_pubnames = 0x2134, + DW_AT_GNU_pubtypes = 0x2135, + DW_AT_GNU_discriminator = 0x2136, + DW_AT_GNU_locviews = 0x2137, + DW_AT_GNU_entry_view = 0x2138, + // Conflict with Sun. + // DW_AT_VMS_rtnbeg_pd_address = 0x2201, + + // Sun extensions. + DW_AT_SUN_template = 0x2201, + DW_AT_SUN_alignment = 0x2202, + DW_AT_SUN_vtable = 0x2203, + DW_AT_SUN_count_guarantee = 0x2204, + DW_AT_SUN_command_line = 0x2205, + DW_AT_SUN_vbase = 0x2206, + DW_AT_SUN_compile_options = 0x2207, + DW_AT_SUN_language = 0x2208, + DW_AT_SUN_browser_file = 0x2209, + DW_AT_SUN_vtable_abi = 0x2210, + DW_AT_SUN_func_offsets = 0x2211, + DW_AT_SUN_cf_kind = 0x2212, + DW_AT_SUN_vtable_index = 0x2213, + DW_AT_SUN_omp_tpriv_addr = 0x2214, + DW_AT_SUN_omp_child_func = 0x2215, + DW_AT_SUN_func_offset = 0x2216, + DW_AT_SUN_memop_type_ref = 0x2217, + DW_AT_SUN_profile_id = 0x2218, + DW_AT_SUN_memop_signature = 0x2219, + DW_AT_SUN_obj_dir = 0x2220, + DW_AT_SUN_obj_file = 0x2221, + DW_AT_SUN_original_name = 0x2222, + DW_AT_SUN_hwcprof_signature = 0x2223, + DW_AT_SUN_amd64_parmdump = 0x2224, + DW_AT_SUN_part_link_name = 0x2225, + DW_AT_SUN_link_name = 0x2226, + DW_AT_SUN_pass_with_const = 0x2227, + DW_AT_SUN_return_with_const = 0x2228, + DW_AT_SUN_import_by_name = 0x2229, + DW_AT_SUN_f90_pointer = 0x222a, + DW_AT_SUN_pass_by_ref = 0x222b, + DW_AT_SUN_f90_allocatable = 0x222c, + DW_AT_SUN_f90_assumed_shape_array = 0x222d, + DW_AT_SUN_c_vla = 0x222e, + DW_AT_SUN_return_value_ptr = 0x2230, + DW_AT_SUN_dtor_start = 0x2231, + DW_AT_SUN_dtor_length = 0x2232, + DW_AT_SUN_dtor_state_initial = 0x2233, + DW_AT_SUN_dtor_state_final = 0x2234, + DW_AT_SUN_dtor_state_deltas = 0x2235, + DW_AT_SUN_import_by_lname = 0x2236, + DW_AT_SUN_f90_use_only = 0x2237, + DW_AT_SUN_namelist_spec = 0x2238, + DW_AT_SUN_is_omp_child_func = 0x2239, + DW_AT_SUN_fortran_main_alias = 0x223a, + DW_AT_SUN_fortran_based = 0x223b, + + DW_AT_ALTIUM_loclist = 0x2300, + + DW_AT_use_GNAT_descriptive_type = 0x2301, + DW_AT_GNAT_descriptive_type = 0x2302, + DW_AT_GNU_numerator = 0x2303, + DW_AT_GNU_denominator = 0x2304, + DW_AT_GNU_bias = 0x2305, + + DW_AT_upc_threads_scaled = 0x3210, + + // PGI (STMicroelectronics) extensions. + DW_AT_PGI_lbase = 0x3a00, + DW_AT_PGI_soffset = 0x3a01, + DW_AT_PGI_lstride = 0x3a02, + + // Borland extensions. + DW_AT_BORLAND_property_read = 0x3b11, + DW_AT_BORLAND_property_write = 0x3b12, + DW_AT_BORLAND_property_implements = 0x3b13, + DW_AT_BORLAND_property_index = 0x3b14, + DW_AT_BORLAND_property_default = 0x3b15, + DW_AT_BORLAND_Delphi_unit = 0x3b20, + DW_AT_BORLAND_Delphi_class = 0x3b21, + DW_AT_BORLAND_Delphi_record = 0x3b22, + DW_AT_BORLAND_Delphi_metaclass = 0x3b23, + DW_AT_BORLAND_Delphi_constructor = 0x3b24, + DW_AT_BORLAND_Delphi_destructor = 0x3b25, + DW_AT_BORLAND_Delphi_anonymous_method = 0x3b26, + DW_AT_BORLAND_Delphi_interface = 0x3b27, + DW_AT_BORLAND_Delphi_ABI = 0x3b28, + DW_AT_BORLAND_Delphi_return = 0x3b29, + DW_AT_BORLAND_Delphi_frameptr = 0x3b30, + DW_AT_BORLAND_closure = 0x3b31, + + // LLVM project extensions. + DW_AT_LLVM_include_path = 0x3e00, + DW_AT_LLVM_config_macros = 0x3e01, + DW_AT_LLVM_isysroot = 0x3e02, + DW_AT_LLVM_tag_offset = 0x3e03, + DW_AT_LLVM_ptrauth_key = 0x3e04, + DW_AT_LLVM_ptrauth_address_discriminated = 0x3e05, + DW_AT_LLVM_ptrauth_extra_discriminator = 0x3e06, + DW_AT_LLVM_apinotes = 0x3e07, + DW_AT_LLVM_ptrauth_isa_pointer = 0x3e08, + DW_AT_LLVM_ptrauth_authenticates_null_values = 0x3e09, + + // Apple extensions. + DW_AT_APPLE_optimized = 0x3fe1, + DW_AT_APPLE_flags = 0x3fe2, + DW_AT_APPLE_isa = 0x3fe3, + DW_AT_APPLE_block = 0x3fe4, + DW_AT_APPLE_major_runtime_vers = 0x3fe5, + DW_AT_APPLE_runtime_class = 0x3fe6, + DW_AT_APPLE_omit_frame_ptr = 0x3fe7, + DW_AT_APPLE_property_name = 0x3fe8, + DW_AT_APPLE_property_getter = 0x3fe9, + DW_AT_APPLE_property_setter = 0x3fea, + DW_AT_APPLE_property_attribute = 0x3feb, + DW_AT_APPLE_objc_complete_type = 0x3fec, + DW_AT_APPLE_property = 0x3fed, + DW_AT_APPLE_objc_direct = 0x3fee, + DW_AT_APPLE_sdk = 0x3fef, + DW_AT_APPLE_origin = 0x3ff0, + DW_AT_hi_user = 0x3fff, +} DW_AT; + +typedef enum { + DW_FORM_addr = 0x01, + DW_FORM_block2 = 0x03, + DW_FORM_block4 = 0x04, + DW_FORM_data2 = 0x05, + DW_FORM_data4 = 0x06, + DW_FORM_data8 = 0x07, + DW_FORM_string = 0x08, + DW_FORM_block = 0x09, + DW_FORM_block1 = 0x0a, + DW_FORM_data1 = 0x0b, + DW_FORM_flag = 0x0c, + DW_FORM_sdata = 0x0d, + DW_FORM_strp = 0x0e, + DW_FORM_udata = 0x0f, + DW_FORM_ref_addr = 0x10, + DW_FORM_ref1 = 0x11, + DW_FORM_ref2 = 0x12, + DW_FORM_ref4 = 0x13, + DW_FORM_ref8 = 0x14, + DW_FORM_ref_udata = 0x15, + DW_FORM_indirect = 0x16, + DW_FORM_sec_offset = 0x17, // DWARF 4 new attribute for section offset + DW_FORM_exprloc = 0x18, + DW_FORM_flag_present = 0x19, + DW_FORM_strx = 0x1a, + DW_FORM_addrx = 0x1b, + DW_FORM_ref_sup4 = 0x1c, + DW_FORM_strp_sup = 0x1d, + DW_FORM_data16 = 0x1e, + DW_FORM_line_ptr = 0x1f, + DW_FORM_ref_sig8 = 0x20, + DW_FORM_implicit_const = 0x21, + DW_FORM_loclistx = 0x22, + DW_FORM_rnglistx = 0x23, + DW_FORM_ref_sup8 = 0x24, + DW_FORM_strx1 = 0x25, + DW_FORM_strx2 = 0x26, + DW_FORM_strx3 = 0x27, + DW_FORM_strx4 = 0x28, + DW_FORM_addrx1 = 0x29, + DW_FORM_addrx2 = 0x2a, + DW_FORM_addrx3 = 0x2b, + DW_FORM_addrx4 = 0x2c, + // Extensions for Fission proposal + DW_FORM_GNU_addr_index = 0x1f01, + DW_FORM_GNU_str_index = 0x1f02, + + // Alternate debug sections proposal (output of "dwz" tool). + DW_FORM_GNU_ref_alt = 0x1f20, + DW_FORM_GNU_strp_alt = 0x1f21 +} DW_FORM; + +typedef enum { + DW_OP_addr = 0x03, + DW_OP_deref = 0x06, + DW_OP_const1u = 0x08, + DW_OP_const1s = 0x09, + DW_OP_const2u = 0x0a, + DW_OP_const2s = 0x0b, + DW_OP_const4u = 0x0c, + DW_OP_const4s = 0x0d, + DW_OP_const8u = 0x0e, + DW_OP_const8s = 0x0f, + DW_OP_constu = 0x10, + DW_OP_consts = 0x11, + DW_OP_dup = 0x12, + DW_OP_drop = 0x13, + DW_OP_over = 0x14, + DW_OP_pick = 0x15, + DW_OP_swap = 0x16, + DW_OP_rot = 0x17, + DW_OP_xderef = 0x18, + DW_OP_abs = 0x19, + DW_OP_and = 0x1a, + DW_OP_div = 0x1b, + DW_OP_minus = 0x1c, + DW_OP_mod = 0x1d, + DW_OP_mul = 0x1e, + DW_OP_neg = 0x1f, + DW_OP_not = 0x20, + DW_OP_or = 0x21, + DW_OP_plus = 0x22, + DW_OP_plus_uconst = 0x23, + DW_OP_shl = 0x24, + DW_OP_shr = 0x25, + DW_OP_shra = 0x26, + DW_OP_xor = 0x27, + DW_OP_skip = 0x2f, + DW_OP_bra = 0x28, + DW_OP_eq = 0x29, + DW_OP_ge = 0x2a, + DW_OP_gt = 0x2b, + DW_OP_le = 0x2c, + DW_OP_lt = 0x2d, + DW_OP_ne = 0x2e, + DW_OP_lit0 = 0x30, + DW_OP_lit1 = 0x31, + DW_OP_lit2 = 0x32, + DW_OP_lit3 = 0x33, + DW_OP_lit4 = 0x34, + DW_OP_lit5 = 0x35, + DW_OP_lit6 = 0x36, + DW_OP_lit7 = 0x37, + DW_OP_lit8 = 0x38, + DW_OP_lit9 = 0x39, + DW_OP_lit10 = 0x3a, + DW_OP_lit11 = 0x3b, + DW_OP_lit12 = 0x3c, + DW_OP_lit13 = 0x3d, + DW_OP_lit14 = 0x3e, + DW_OP_lit15 = 0x3f, + DW_OP_lit16 = 0x40, + DW_OP_lit17 = 0x41, + DW_OP_lit18 = 0x42, + DW_OP_lit19 = 0x43, + DW_OP_lit20 = 0x44, + DW_OP_lit21 = 0x45, + DW_OP_lit22 = 0x46, + DW_OP_lit23 = 0x47, + DW_OP_lit24 = 0x48, + DW_OP_lit25 = 0x49, + DW_OP_lit26 = 0x4a, + DW_OP_lit27 = 0x4b, + DW_OP_lit28 = 0x4c, + DW_OP_lit29 = 0x4d, + DW_OP_lit30 = 0x4e, + DW_OP_lit31 = 0x4f, + DW_OP_reg0 = 0x50, + DW_OP_reg1 = 0x51, + DW_OP_reg2 = 0x52, + DW_OP_reg3 = 0x53, + DW_OP_reg4 = 0x54, + DW_OP_reg5 = 0x55, + DW_OP_reg6 = 0x56, + DW_OP_reg7 = 0x57, + DW_OP_reg8 = 0x58, + DW_OP_reg9 = 0x59, + DW_OP_reg10 = 0x5a, + DW_OP_reg11 = 0x5b, + DW_OP_reg12 = 0x5c, + DW_OP_reg13 = 0x5d, + DW_OP_reg14 = 0x5e, + DW_OP_reg15 = 0x5f, + DW_OP_reg16 = 0x60, + DW_OP_reg17 = 0x61, + DW_OP_reg18 = 0x62, + DW_OP_reg19 = 0x63, + DW_OP_reg20 = 0x64, + DW_OP_reg21 = 0x65, + DW_OP_reg22 = 0x66, + DW_OP_reg23 = 0x67, + DW_OP_reg24 = 0x68, + DW_OP_reg25 = 0x69, + DW_OP_reg26 = 0x6a, + DW_OP_reg27 = 0x6b, + DW_OP_reg28 = 0x6c, + DW_OP_reg29 = 0x6d, + DW_OP_reg30 = 0x6e, + DW_OP_reg31 = 0x6f, + DW_OP_breg0 = 0x70, + DW_OP_breg1 = 0x71, + DW_OP_breg2 = 0x72, + DW_OP_breg3 = 0x73, + DW_OP_breg4 = 0x74, + DW_OP_breg5 = 0x75, + DW_OP_breg6 = 0x76, + DW_OP_breg7 = 0x77, + DW_OP_breg8 = 0x78, + DW_OP_breg9 = 0x79, + DW_OP_breg10 = 0x7a, + DW_OP_breg11 = 0x7b, + DW_OP_breg12 = 0x7c, + DW_OP_breg13 = 0x7d, + DW_OP_breg14 = 0x7e, + DW_OP_breg15 = 0x7f, + DW_OP_breg16 = 0x80, + DW_OP_breg17 = 0x81, + DW_OP_breg18 = 0x82, + DW_OP_breg19 = 0x83, + DW_OP_breg20 = 0x84, + DW_OP_breg21 = 0x85, + DW_OP_breg22 = 0x86, + DW_OP_breg23 = 0x87, + DW_OP_breg24 = 0x88, + DW_OP_breg25 = 0x89, + DW_OP_breg26 = 0x8a, + DW_OP_breg27 = 0x8b, + DW_OP_breg28 = 0x8c, + DW_OP_breg29 = 0x8d, + DW_OP_breg30 = 0x8e, + DW_OP_breg31 = 0x8f, + DW_OP_regx = 0x90, + DW_OP_fbreg = 0x91, + DW_OP_bregx = 0x92, + DW_OP_piece = 0x93, + DW_OP_deref_size = 0x94, + DW_OP_xderef_size = 0x95, + DW_OP_nop = 0x96, + DW_OP_push_object_address = 0x97, + DW_OP_call2 = 0x98, + DW_OP_call4 = 0x99, + DW_OP_call_ref = 0x9a, + DW_OP_form_tls_address = 0x9b, + DW_OP_call_frame_cfa = 0x9c, + DW_OP_bit_piece = 0x9d, + DW_OP_implicit_value = 0x9e, + DW_OP_stack_value = 0x9f, + DW_OP_implicit_pointer = 0xa0, + DW_OP_addrx = 0xa1, + DW_OP_constx = 0xa2, + DW_OP_entry_value = 0xa3, + DW_OP_const_type = 0xa4, + DW_OP_regval_type = 0xa5, + DW_OP_deref_type = 0xa6, + DW_OP_xderef_type = 0xa7, + DW_OP_convert = 0xa8, + DW_OP_reinterpret = 0xa9, + + // GNU extensions + DW_OP_GNU_push_tls_address = 0xe0, + DW_OP_GNU_uninit = 0xf0, + DW_OP_GNU_encoded_addr = 0xf1, + DW_OP_GNU_implicit_pointer = 0xf2, + DW_OP_GNU_entry_value = 0xf3, + DW_OP_GNU_const_type = 0xf4, + DW_OP_GNU_regval_type = 0xf5, + DW_OP_GNU_deref_type = 0xf6, + DW_OP_GNU_convert = 0xf7, + DW_OP_GNU_reinterpret = 0xf9, + DW_OP_GNU_parameter_ref = 0xfa, + DW_OP_GNU_addr_index = 0xfb, + DW_OP_GNU_const_index = 0xfc, + + // Wasm extensions + DW_OP_WASM_location = 0xed, + /* <_lo_user ; _hi_user> Interval is reserved for vendor extensions */ + DW_OP_lo_user = 0xe0, + DW_OP_hi_user = 0xff, +} DW_OP; + +typedef enum { + DW_ATE_address = 0x01, + DW_ATE_boolean = 0x02, + DW_ATE_complex_float = 0x03, + DW_ATE_float = 0x04, + DW_ATE_signed = 0x05, + DW_ATE_signed_char = 0x06, + DW_ATE_unsigned = 0x07, + DW_ATE_unsigned_char = 0x08, + DW_ATE_imaginary_float = 0x09, + DW_ATE_packed_decimal = 0x0a, + DW_ATE_numeric_string = 0x0b, + DW_ATE_edited = 0x0c, + DW_ATE_signed_fixed = 0x0d, + DW_ATE_unsigned_fixed = 0x0e, + DW_ATE_decimal_float = 0x0f, + DW_ATE_UTF = 0x10, + /* <_lo_user ; _hi_user> Interval is reserved for vendor extensions */ + DW_ATE_lo_user = 0x80, + DW_ATE_hi_user = 0xff, +} DW_ATE; + +/// Range list entry encoding values. +/// +/// See Section 7.25, Table 7.30. +typedef enum { + DW_RLE_end_of_list = 0x00, + DW_RLE_base_addressx = 0x01, + DW_RLE_startx_endx = 0x02, + DW_RLE_startx_length = 0x03, + DW_RLE_offset_pair = 0x04, + DW_RLE_base_address = 0x05, + DW_RLE_start_end = 0x06, + DW_RLE_start_length = 0x07, +} DW_RLE; + +/// The encodings of the constants used in location list entries. +/// +/// See Section 7.7.3, Table 7.10. +enum DW_LLE { + DW_LLE_end_of_list = 0x00, + DW_LLE_base_addressx = 0x01, + DW_LLE_startx_endx = 0x02, + DW_LLE_startx_length = 0x03, + DW_LLE_offset_pair = 0x04, + DW_LLE_default_location = 0x05, + DW_LLE_base_address = 0x06, + DW_LLE_start_end = 0x07, + DW_LLE_start_length = 0x08, + DW_LLE_GNU_view_pair = 0x09, +}; + +typedef enum { + DW_DS_unsigned = 0x01, + DW_DS_leading_overpunch = 0x02, + DW_DS_trailing_overpunch = 0x03, + DW_DS_leading_separate = 0x04, + DW_DS_trailing_separate = 0x05, +} DW_DS; + +typedef enum { + DW_END_default = 0x00, + DW_END_big = 0x01, + DW_END_little = 0x02, + /* <_lo_user ; _hi_user> Interval is reserved for vendor extensions */ + DW_END_lo_user = 0x40, + DW_END_hi_user = 0xff, +} DW_END; + +typedef enum { + DW_ACCESS_public = 0x01, + DW_ACCESS_protected = 0x02, + DW_ACCESS_private = 0x03, +} DW_ACCESS; + +typedef enum { + DW_VIS_local = 0x01, + DW_VIS_exported = 0x02, + DW_VIS_qualified = 0x03, +} DW_VIS; + +typedef enum { + DW_VIRTUALITY_none = 0x00, + DW_VIRTUALITY_virtual = 0x01, + DW_VIRTUALITY_pure_virtual = 0x02, +} DW_VIRTUALITY; + +typedef enum { + DW_LANG_C89 = 0x0001, + DW_LANG_C = 0x0002, + DW_LANG_Ada83 = 0x0003, + DW_LANG_C_plus_plus = 0x0004, + DW_LANG_Cobol74 = 0x0005, + DW_LANG_Cobol85 = 0x0006, + DW_LANG_Fortran77 = 0x0007, + DW_LANG_Fortran90 = 0x0008, + DW_LANG_Pascal83 = 0x0009, + DW_LANG_Modula2 = 0x000a, + DW_LANG_Java = 0x000b, + DW_LANG_C99 = 0x000c, + DW_LANG_Ada95 = 0x000d, + DW_LANG_Fortran95 = 0x000e, + DW_LANG_PLI = 0x000f, + DW_LANG_ObjC = 0x0010, + DW_LANG_ObjC_plus_plus = 0x0011, + DW_LANG_UPC = 0x0012, + DW_LANG_D = 0x0013, + DW_LANG_Python = 0x0014, + DW_LANG_Rust = 0x001c, + DW_LANG_C11 = 0x001d, + DW_LANG_Swift = 0x001e, + DW_LANG_Julia = 0x001f, + DW_LANG_Dylan = 0x0020, + DW_LANG_C_plus_plus_14 = 0x0021, + DW_LANG_Fortran03 = 0x0022, + DW_LANG_Fortran08 = 0x0023, + DW_LANG_RenderScript = 0x0024, + DW_LANG_BLISS = 0x0025, + + // Since Version 5 + DW_LANG_Kotlin = 0x0026, + DW_LANG_Zig = 0x0027, + DW_LANG_Crystal = 0x0028, + DW_LANG_C_plus_plus_17 = 0x002a, + DW_LANG_C_plus_plus_20 = 0x002b, + DW_LANG_C17 = 0x002c, + DW_LANG_Fortran18 = 0x002d, + DW_LANG_Ada2005 = 0x002e, + DW_LANG_Ada2012 = 0x002f, + DW_LANG_HIP = 0x0030, + DW_LANG_Assembly = 0x0031, + DW_LANG_C_sharp = 0x0032, + DW_LANG_Mojo = 0x0033, + + DW_LANG_lo_user = 0x8000, + DW_LANG_hi_user = 0xffff, + + DW_LANG_Mips_Assembler = 0x8001, + DW_LANG_GOOGLE_RenderScript = 0x8e57, + DW_LANG_SUN_Assembler = 0x9001, + DW_LANG_ALTIUM_Assembler = 0x9101, + DW_LANG_BORLAND_Delphi = 0xb000, +} DW_LANG; + +typedef enum { + DW_ID_case_sensitive = 0x00, + DW_ID_up_case = 0x01, + DW_ID_down_case = 0x02, + DW_ID_case_insensitive = 0x03, +} DW_ID; + +typedef enum { + DW_CC_normal = 0x01, + DW_CC_program = 0x02, + DW_CC_nocall = 0x03, + DW_CC_lo_user = 0x40, + DW_CC_hi_user = 0xff, +} DW_CC; + +typedef enum { + DW_INL_not_inlined = 0x00, + DW_INL_inlined = 0x01, + DW_INL_declared_not_inlined = 0x02, + DW_INL_declared_inlined = 0x03, +} DW_INL; + +typedef enum { + DW_ORD_row_major = 0x00, + DW_ORD_col_major = 0x01, +} DW_ORD; + +typedef enum { + DW_DSC_label = 0x00, + DW_DSC_range = 0x01, +} DW_DSC; + +typedef enum { + DW_MACINFO_define = 0x01, + DW_MACINFO_undef = 0x02, + DW_MACINFO_start_file = 0x03, + DW_MACINFO_end_file = 0x04, + DW_MACINFO_vendor_ext = 0xff, +} DW_MACINFO; + +typedef enum { + DW_CFA_advance_loc = 0x40, + DW_CFA_offset = 0x80, + DW_CFA_restore = 0xc0, + DW_CFA_nop = 0x00, + DW_CFA_set_loc = 0x01, + DW_CFA_advance_loc1 = 0x02, + DW_CFA_advance_loc2 = 0x03, + DW_CFA_advance_loc4 = 0x04, + DW_CFA_offse_extended = 0x05, + DW_CFA_restore_extended = 0x06, + DW_CFA_undefined = 0x07, + DW_CFA_same_value = 0x08, + DW_CFA_register = 0x09, + DW_CFA_remember_state = 0x0a, + DW_CFA_restore_state = 0x0b, + DW_CFA_def_cfa = 0x0c, + DW_CFA_def_cfa_register = 0x0d, + DW_CFA_def_cfa_offset = 0x0e, + DW_CFA_def_cfa_expression = 0x0f, + DW_CFA_expression = 0x10, + DW_CFA_offset_extended_sf = 0x11, + DW_CFA_def_cfa_sf = 0x12, + DW_CFA_def_cfa_offset_sf = 0x13, + DW_CFA_val_offset = 0x14, + DW_CFA_val_offset_sf = 0x15, + DW_CFA_val_expression = 0x16, + DW_CFA_lo_user = 0x1c, + DW_CFA_hi_user = 0x3f, +} DW_CFA; + +typedef enum { + DW_UT_compile = 0x01, + DW_UT_type = 0x02, + DW_UT_partial = 0x03, + DW_UT_skeleton = 0x04, + DW_UT_split_compile = 0x05, + DW_UT_split_type = 0x06, + DW_UT_lo_user = 0x80, + DW_UT_hi_user = 0xff, +} DW_UT; + +/// The encodings for the line number header entry formats. +/// +/// See Section 7.22, Table 7.27. +typedef enum { + DW_LNCT_path = 0x1, + DW_LNCT_directory_index = 0x2, + DW_LNCT_timestamp = 0x3, + DW_LNCT_size = 0x4, + DW_LNCT_MD5 = 0x5, + DW_LNCT_lo_user = 0x2000, + DW_LNCT_hi_user = 0x3fff, +} DW_LNCT; + +struct rz_bin_section_t; + +typedef struct { + ut8 *data; + bool owned; + ut64 length; + ut64 offset; + bool big_endian; + HtUP *relocations; +} RzBinEndianReader; + +typedef struct { + DW_AT at; + DW_FORM form; + st64 special; // Used for values coded directly into abbrev +} RzBinDwarfAttrSpec; + +typedef RzBinEndianReader RzBinDwarfBlock; + +// http://www.dwarfstd.org/doc/DWARF4.pdf#page=29&zoom=100,0,0 +typedef enum { + RzBinDwarfAttr_Addr, + RzBinDwarfAttr_AddrBase, /// An offset to a set of addresses in the `.debug_addr` section. + RzBinDwarfAttr_AddrIndex, /// An index into a set of addresses in the `.debug_addr` section. + RzBinDwarfAttr_Block, + RzBinDwarfAttr_Constant, + RzBinDwarfAttr_UConstant, + RzBinDwarfAttr_Exprloc, + RzBinDwarfAttr_Flag, + RzBinDwarfAttr_LoclistPtr, + RzBinDwarfAttr_MacPtr, + RzBinDwarfAttr_RangelistPtr, + RzBinDwarfAttr_Reference, + RzBinDwarfAttr_UnitRef, + RzBinDwarfAttr_SecOffset, + RzBinDwarfAttr_StrRef, /// An offset into the .debug_str section. + RzBinDwarfAttr_StrOffsetIndex, /// An offset to a set of entries in the .debug_str_offsets section. + RzBinDwarfAttr_LineStrRef, /// An offset into the .debug_line_str section. + RzBinDwarfAttr_String, /// A slice of bytes representing a string. Does not include a final null byte. Not guaranteed to be UTF-8 or anything like that. +} RzBinDwarfAttrClass; + +typedef struct { + RzBinDwarfAttrClass kind; + union { + RzBinDwarfBlock block; + ut64 u64; + ut128 u128; + st64 s64; + ut8 flag; + const char *string; + }; +} RzBinDwarfAttrValue; + +typedef struct dwarf_attr_t { + DW_AT at; + DW_FORM form; + RzBinDwarfAttrValue value; +} RzBinDwarfAttr; + +typedef struct { + ut8 address_size; + ut16 version; + bool is_64bit; +} RzBinDwarfEncoding; + +typedef struct { + // A 4-byte (or 8 byte for 64bit dwarf) unsigned length of the .debug_info contribution + // for that compilation unit, not including the length field itself. + ut64 length; + // A 4-byte unsigned offset into the .debug_abbrev section. + ut64 abbrev_offset; + DW_UT ut; // DWARF 5 addition + union { + ut64 dwo_id; // DWARF 5 addition + struct { + ut64 type_sig; // DWARF 5 addition + ut64 type_offset; // DWARF 5 addition + }; + }; + ut64 header_size; // excluding length field + RzBinDwarfEncoding encoding; +} RzBinDwarfCompUnitHdr; + +typedef struct { + ut64 offset; // important for parsing types + DW_TAG tag; + ut64 abbrev_code; + DW_CHILDREN has_children; // important for parsing types + RzVector /**/ attrs; + size_t unit_offset; + size_t index; + size_t depth; + ut64 sibling; +} RzBinDwarfDie; + +typedef struct rz_bin_dwarf_comp_unit_t { + ut64 offset; + ut64 index; + RzBinDwarfCompUnitHdr hdr; + RzVector /**/ dies; + const char *name; + const char *comp_dir; + const char *producer; + const char *dwo_name; + DW_LANG language; + ut64 low_pc; + ut64 high_pc; + ut64 stmt_list; + ut64 str_offsets_base; + ut64 addr_base; + ut64 loclists_base; + ut64 rnglists_base; +} RzBinDwarfCompUnit; + +typedef struct { + RzBinEndianReader *R; + RzVector /**/ units; + HtUP /**/ *die_by_offset; + HtUP /**/ *unit_by_offset; + size_t die_count; + /** + * Cache mapping from an offset in the debug_line section to a string + * representing the DW_AT_comp_dir attribute of the compilation unit + * that references this particular line information. + */ + HtUP /**/ *comp_dir_by_offset; + HtUP /**/ *location_encoding; +} RzBinDwarfInfo; + +typedef struct { + ut64 code; + DW_TAG tag; + ut64 offset; + DW_CHILDREN has_children; + RzVector /**/ defs; +} RzBinDwarfAbbrevDecl; + +typedef struct { + RzVector /**/ abbrevs; + size_t offset; +} RzBinDwarfAbbrevTable; + +typedef struct { + RzBinEndianReader *R; + HtUP /**/ *by_offset; + size_t count; +} RzBinDwarfAbbrev; + +typedef struct rz_bin_dwarf_line_file_entry_format_t { + DW_LNCT content_type; + DW_FORM form; +} RzBinDwarfFileEntryFormat; + +typedef struct { + const char *path_name; + ut64 directory_index; + ut64 timestamp; + ut64 size; + ut8 md5[16]; +} RzBinDwarfFileEntry; + +typedef struct { + ut64 offset; //< offset inside the debug_line section, for references from outside + ut64 unit_length; + ut64 header_length; + ut8 min_inst_len; + ut8 max_ops_per_inst; + ut8 default_is_stmt; + st32 line_base; + ut8 line_range; + ut8 opcode_base; + ut8 segment_selector_size; + RzBinDwarfEncoding encoding; + + /** + * \brief The number of LEB128 operands for each of the standard opcodes + * From standard_opcode_lengths in DWARF 3 standard: + * The first element of the array corresponds to the opcode whose value is 1, + * and the last element corresponds to the opcode whose value is opcode_base - 1. + * Thus, the size of this array is opcode_base - 1. + */ + const ut8 *std_opcode_lengths; + + RzVector /**/ directory_entry_formats; + RzPVector /**/ directories; + RzVector /**/ file_name_entry_formats; + RzVector /**/ file_names; +} RzBinDwarfLineUnitHdr; + +typedef enum { + RZ_BIN_DWARF_LINE_OP_TYPE_SPEC, //< single byte op, no args + RZ_BIN_DWARF_LINE_OP_TYPE_STD, //< fixed-size op, 0 or more leb128 args (except DW_LNS_fixed_advance_pc) + RZ_BIN_DWARF_LINE_OP_TYPE_EXT, //< variable-size op, arbitrary format of args + RZ_BIN_DWARF_LINE_OP_TYPE_EXT_UNKNOWN, //< variable-size op, arbitrary format of args +} RzBinDwarfLineOpType; + +typedef struct { + ut64 offset; + RzBinDwarfLineOpType type; + union { + DW_LNS opcode; + DW_LNE ext_opcode; + }; + struct { + union { + ut64 advance_pc; //< DW_LNS_advance_pc + st64 advance_line; //< DW_LNS_advance_line + ut64 set_file; //< DW_LNS_set_file + ut64 set_column; //< DW_LNS_set_column + ut64 fixed_advance_pc; //< DW_LNS_fixed_advance_pc + ut64 set_isa; //< DW_LNS_set_isa + ut64 set_address; //< DW_LNE_set_address + RzBinDwarfFileEntry define_file; //< DW_LNE_define_file + ut64 set_discriminator; //< DW_LNE_set_discriminator + }; + } args; +} RzBinDwarfLineOp; + +/** + * \brief DWARF 3 Standard Section 6.2 Line Number Information + * This contains the entire raw line info for one compilation unit. + */ +typedef struct { + RzBinDwarfLineUnitHdr hdr; + RzVector /**/ ops; +} RzBinDwarfLineUnit; + +/** + * \brief Line info of all compilation units from the entire debug_line section + */ +typedef struct { + RzBinEndianReader *R; + RzPVector /**/ *units; + RzBinSourceLineInfo *lines; +} RzBinDwarfLine; + +typedef struct rz_bin_dwarf_arange_t { + ut64 addr; + ut64 length; +} RzBinDwarfARange; + +/** + * \brief DWARF 3 Standard Section 6.1.2 Lookup by Address + */ +typedef struct rz_bin_dwarf_arange_set_t { + ut64 unit_length; + bool is_64bit; + ut16 version; + ut64 debug_info_offset; + ut8 address_size; + ut8 segment_size; + size_t aranges_count; + RzBinDwarfARange *aranges; +} RzBinDwarfARangeSet; + +typedef struct { + RzBinEndianReader *R; + RzList /**/ *list; +} RzBinDwarfARanges; + +typedef struct { + RzBinDwarfEncoding encoding; + ut64 unit_length; + ut32 offset_entry_count; + ut8 segment_selector_size; + ut64 *location_offsets; +} RzBinDwarfListsHdr; + +/// The raw contents of the `.debug_addr` section. +typedef struct { + RzBinEndianReader *R; +} RzBinDwarfAddr; + +typedef struct { + RzBinEndianReader *R; +} RzBinDwarfStr; + +typedef RzBinDwarfStr RzBinDwarfLineStr; + +typedef struct { + RzBinEndianReader *R; + RzBinDwarfEncoding encoding; + ut64 unit_length; + ut16 padding; +} RzBinDwarfStrOffsets; + +/// A raw address range from the `.debug_ranges` section. +typedef struct { + /// The beginning address of the range. + ut64 begin; + /// The first address past the end of the range. + ut64 end; +} RzBinDwarfRange; + +typedef enum { + /// The bare range list format used before DWARF 5. + RzBinDwarfRngListsFormat_Bare, + /// The DW_RLE encoded range list format used in DWARF 5. + RzBinDwarfRngListsFormat_Rle, +} RzBinDwarfRngListsFormat; + +/// A raw entry in .debug_rnglists +typedef struct { + DW_RLE encoding; + bool is_address_or_offset_pair; + union { + /// A range from DWARF version <= 4. + struct { + ut64 begin; /// Start of range. May be an address or an offset. + ut64 end; /// End of range. May be an address or an offset. + } address_or_offset_pair; + /// DW_RLE_base_address + struct { + ut64 addr; /// base address + } base_address; + /// DW_RLE_base_addressx + struct { + ut64 addr; /// base address + } base_addressx; + /// DW_RLE_startx_endx + struct { + ut64 begin; /// Start of range. + ut64 end; /// End of range. + } startx_endx; + /// DW_RLE_startx_length + struct { + ut64 begin; /// start of range + ut64 length; /// length of range + } startx_length; + /// DW_RLE_offset_pair + struct { + ut64 begin; /// Start of range. + ut64 end; /// End of range. + } offset_pair; + /// DW_RLE_start_end + struct { + ut64 begin; /// Start of range. + ut64 end; /// End of range. + } start_end; + /// DW_RLE_start_length + struct { + ut64 begin; /// Start of range. + ut64 length; /// Length of range. + } start_length; + }; +} RzBinDwarfRawRngListEntry; + +typedef struct { + ut64 offset; + RzPVector /**/ raw_entries; + RzPVector /**/ entries; +} RzBinDwarfRngList; + +typedef struct { + RzBinEndianReader *rnglists; + RzBinEndianReader *ranges; + ut64 base_address; + RzBinDwarfListsHdr hdr; + HtUP /**/ *by_offset; +} RzBinDwarfRngLists; + +typedef enum { + /// The bare location list format used before DWARF 5. + RzBinDwarfLocListsFormat_BARE, + /// The DW_LLE encoded range list format used in DWARF 5 and the non-standard GNU + /// split dwarf extension. + RzBinDwarfLocListsFormat_LLE, +} RzBinDwarfLocListsFormat; + +typedef struct { + enum DW_LLE encoding; + bool is_address_or_offset_pair; + union { + /// A location from DWARF version <= 4. + struct { + ut64 begin; /// Start of range. May be an address or an offset. + ut64 end; /// End of range. May be an address or an offset. + RzBinDwarfBlock data; /// expression + } address_or_offset_pair; + /// DW_LLE_base_address + struct { + ut64 addr; /// base address + } base_address; + /// DW_LLE_base_addressx + struct { + ut64 addr; /// base address + } base_addressx; + /// DW_LLE_startx_endx + struct { + ut64 begin; /// Start of range. + ut64 end; /// End of range. + RzBinDwarfBlock data; /// expression + } startx_endx; + /// DW_LLE_startx_length + struct { + ut64 begin; /// start of range + ut64 length; /// length of range + RzBinDwarfBlock data; /// expression + } startx_length; + /// DW_LLE_offset_pair + struct { + ut64 begin; /// Start of range. + ut64 end; /// End of range. + RzBinDwarfBlock data; /// expression + } offset_pair; + /// DW_LLE_default_location + struct { + RzBinDwarfBlock data; /// expression + } default_location; + /// DW_LLE_start_end + struct { + ut64 begin; /// Start of range. + ut64 end; /// End of range. + RzBinDwarfBlock data; /// expression + } start_end; + /// DW_LLE_start_length + struct { + ut64 begin; /// Start of range. + ut64 length; /// Length of range. + RzBinDwarfBlock data; /// expression + } start_length; + }; +} RzBinDwarfRawLocListEntry; + +struct rz_bin_dwarf_location_t; + +typedef struct { + RzBinDwarfRange range; + const RzBinDwarfBlock *expression; + struct rz_bin_dwarf_location_t *location; +} RzBinDwarfLocListEntry; + +typedef struct { + ut64 offset; + bool has_location; + RzPVector /**/ raw_entries; + RzPVector /**/ entries; +} RzBinDwarfLocList; + +typedef struct { + RzBinEndianReader *loclists; + RzBinEndianReader *loc; + ut64 base_address; + RzBinDwarfListsHdr hdr; + HtUP /**/ *by_offset; +} RzBinDwarfLocLists; + +struct rz_core_bin_dwarf_t; + +typedef struct rz_core_bin_dwarf_t { + struct rz_core_bin_dwarf_t *parent; + + RzBinDwarfARanges *aranges; + RzBinDwarfLine *line; + RzBinDwarfLocLists *loclists; + RzBinDwarfRngLists *rnglists; + RzBinDwarfInfo *info; + RzBinDwarfAbbrev *abbrev; + RzBinDwarfAddr *addr; + RzBinDwarfStr *str; + RzBinDwarfStrOffsets *str_offsets; + RzBinDwarfLineStr *line_str; +} RzBinDWARF; + +#define DWARF_FIELD_IMPL(T, F) \ + static inline T *rz_bin_dwarf_##F( \ + RZ_BORROW RZ_NONNULL const RzBinDWARF *dw) { \ + rz_return_val_if_fail(dw, NULL); \ + return dw->F ? dw->F : (dw->parent ? dw->parent->F : NULL); \ + } + +DWARF_FIELD_IMPL(RzBinDwarfAddr, addr); +DWARF_FIELD_IMPL(RzBinDwarfLine, line); +DWARF_FIELD_IMPL(RzBinDwarfLineStr, line_str); + +#undef DWARF_FIELD_IMPL + +RZ_API const char *rz_bin_dwarf_tag(DW_TAG tag); +RZ_API const char *rz_bin_dwarf_attr(DW_AT attr_code); +RZ_API const char *rz_bin_dwarf_form(DW_FORM form_code); +RZ_API const char *rz_bin_dwarf_unit_type(DW_UT unit_type); +RZ_API const char *rz_bin_dwarf_lang(DW_LANG lang); +RZ_API const char *rz_bin_dwarf_lang_for_demangle(DW_LANG lang); +RZ_API const char *rz_bin_dwarf_children(DW_CHILDREN children); +RZ_API const char *rz_bin_dwarf_lns(DW_LNS lns); +RZ_API const char *rz_bin_dwarf_lne(DW_LNE lne); +RZ_API const char *rz_bin_dwarf_lnct(DW_LNCT lnct); +RZ_API const char *rz_bin_dwarf_op(DW_OP op); +RZ_API const char *rz_bin_dwarf_ate(DW_ATE op); + +/// .debug_str +RZ_API RZ_OWN RzBinDwarfStr *rz_bin_dwarf_str_new(RZ_NONNULL RZ_OWN RzBinEndianReader *R); +RZ_API RZ_OWN RzBinDwarfStr *rz_bin_dwarf_str_from_file(RZ_NONNULL RZ_BORROW RzBinFile *bf); +RZ_API void rz_bin_dwarf_str_free(RZ_NULLABLE RzBinDwarfStr *str); +RZ_API RZ_BORROW const char *rz_bin_dwarf_str_get(RZ_NONNULL RZ_BORROW RzBinDwarfStr *str, ut64 offset); + +RZ_API RZ_OWN RzBinDwarfLineStr *rz_bin_dwarf_line_str_new(RZ_NONNULL RZ_OWN RzBinEndianReader *R); +RZ_API RZ_OWN RzBinDwarfLineStr *rz_bin_dwarf_line_str_from_file(RZ_NONNULL RZ_BORROW RzBinFile *bf); +RZ_API void rz_bin_dwarf_line_str_free(RZ_NULLABLE RzBinDwarfLineStr *str); +RZ_API RZ_BORROW const char *rz_bin_dwarf_line_str_get(RZ_NONNULL RZ_BORROW RzBinDwarfLineStr *str, ut64 offset); + +/// .debug_str_offsets +RZ_API RZ_OWN RzBinDwarfStrOffsets *rz_bin_dwarf_str_offsets_new(RZ_NONNULL RZ_OWN RzBinEndianReader *R); +RZ_API RZ_OWN RzBinDwarfStrOffsets *rz_bin_dwarf_str_offsets_from_file(RZ_NONNULL RZ_BORROW RzBinFile *bf); +RZ_API void rz_bin_dwarf_str_offsets_free(RZ_NULLABLE RzBinDwarfStrOffsets *str_offsets); +RZ_API RZ_BORROW const char *rz_bin_dwarf_str_offsets_get( + RZ_NONNULL RZ_BORROW RzBinDwarfStr *str, + RZ_NONNULL RZ_BORROW RzBinDwarfStrOffsets *str_offsets, + ut64 base, ut64 index); + +/// .debug_aranges +RZ_API RZ_OWN RzBinDwarfARanges *rz_bin_dwarf_aranges_new(RZ_NONNULL RZ_OWN RzBinEndianReader *R); +RZ_API RZ_OWN RzBinDwarfARanges *rz_bin_dwarf_aranges_from_file(RZ_BORROW RZ_NONNULL RzBinFile *bf); +RZ_API void rz_bin_dwarf_arange_set_free(RZ_OWN RZ_NULLABLE RzBinDwarfARangeSet *set); +RZ_API void rz_bin_dwarf_aranges_free(RZ_OWN RZ_NULLABLE RzBinDwarfARanges *aranges); +RZ_API void rz_bin_dwarf_aranges_dump( + RZ_NONNULL RZ_BORROW RzBinDwarfARanges *aranges, + RZ_NONNULL RZ_BORROW RzStrBuf *sb); + +/// .debug_abbrev +RZ_API RZ_OWN RzBinDwarfAbbrev *rz_bin_dwarf_abbrev_new(RZ_OWN RZ_NONNULL RzBinEndianReader *R); +RZ_API RZ_OWN RzBinDwarfAbbrev *rz_bin_dwarf_abbrev_from_file(RZ_BORROW RZ_NONNULL RzBinFile *bf); + +RZ_API void rz_bin_dwarf_abbrev_free(RZ_OWN RZ_NULLABLE RzBinDwarfAbbrev *abbrevs); +RZ_API size_t rz_bin_dwarf_abbrev_count(RZ_BORROW RZ_NONNULL const RzBinDwarfAbbrev *da); +RZ_API RZ_BORROW RzBinDwarfAbbrevDecl *rz_bin_dwarf_abbrev_get( + RZ_BORROW RZ_NONNULL const RzBinDwarfAbbrevTable *tbl, size_t idx); +RZ_API size_t rz_bin_dwarf_abbrev_decl_count(RZ_BORROW RZ_NONNULL const RzBinDwarfAbbrevDecl *decl); +RZ_API RZ_BORROW RzBinDwarfAttrSpec *rz_bin_dwarf_abbrev_attr_by_name( + RZ_BORROW RZ_NONNULL const RzBinDwarfAbbrevDecl *abbrev, DW_AT name); +RZ_API void rz_core_bin_dwarf_abbrevs_dump( + RZ_NONNULL RZ_BORROW const RzBinDwarfAbbrev *abbrevs, + RZ_NONNULL RZ_BORROW RzStrBuf *sb); +/// .debug_info +RZ_API RZ_OWN RzBinDwarfInfo *rz_bin_dwarf_info_from_buf( + RZ_OWN RZ_NONNULL RzBinEndianReader *R, + RZ_BORROW RZ_NONNULL RzBinDWARF *dw); +RZ_API RZ_OWN RzBinDwarfInfo *rz_bin_dwarf_info_from_file( + RZ_BORROW RZ_NULLABLE RzBinDWARF *dw, + RZ_BORROW RZ_NONNULL RzBinFile *bf); +RZ_API void rz_bin_dwarf_info_free(RZ_OWN RZ_NULLABLE RzBinDwarfInfo *info); +RZ_API RZ_BORROW RzBinDwarfAttr *rz_bin_dwarf_die_get_attr( + RZ_BORROW RZ_NONNULL const RzBinDwarfDie *die, DW_AT name); +RZ_API void rz_bin_dwarf_debug_info_dump( + RZ_NONNULL RZ_BORROW const RzBinDwarfInfo *info, + RZ_NONNULL RZ_BORROW const RzBinDWARF *dw, + RZ_NONNULL RZ_BORROW RzStrBuf *sb); + +/// .debug_line +RZ_API RZ_OWN RzBinDwarfLine *rz_bin_dwarf_line_new( + RZ_BORROW RZ_NONNULL RzBinEndianReader *R, + RZ_BORROW RZ_NONNULL RzBinDwarfEncoding *encoding, + RZ_BORROW RZ_NULLABLE RzBinDWARF *dw); +RZ_API RZ_OWN RzBinDwarfLine *rz_bin_dwarf_line_from_file( + RZ_BORROW RZ_NULLABLE RzBinDWARF *dw, + RZ_BORROW RZ_NONNULL RzBinFile *bf); +RZ_API void rz_bin_dwarf_line_free(RZ_OWN RZ_NULLABLE RzBinDwarfLine *li); +RZ_API void rz_bin_dwarf_line_units_dump( + RZ_NONNULL RZ_BORROW RzBinDwarfLine *line, + RZ_NONNULL RZ_BORROW RzStrBuf *sb); +RZ_API char *rz_bin_dwarf_file_path(RZ_NONNULL RZ_BORROW RzBinDWARF *dw, + RZ_NONNULL RZ_BORROW RzBinDwarfLineUnit *lu, ut64 index); + +/// dwarf +RZ_API RZ_OWN RzBinDWARF *rz_bin_dwarf_from_file(RZ_BORROW RZ_NONNULL RzBinFile *bf); +RZ_API RZ_OWN RzBinDWARF *rz_bin_dwarf_from_path( + RZ_BORROW RZ_NONNULL const char *filepath, + RZ_BORROW RZ_NULLABLE RzBinDWARF *parent); +RZ_API RZ_OWN RzBinDWARF *rz_bin_dwarf_load_dsym(RZ_BORROW RZ_NONNULL RzBinFile *bf); +RZ_API RZ_OWN RzBinDWARF *rz_bin_dwarf_search_debug_file_directory( + RZ_BORROW RZ_NONNULL RzBinFile *bf, + RZ_BORROW RZ_NONNULL RzList /**/ *debug_file_directorys); +RZ_API RZ_OWN RzBinDWARF *rz_bin_dwarf_from_debuginfod( + RZ_BORROW RZ_NONNULL RzBinFile *bf, + RZ_BORROW RZ_NONNULL RzList /**/ *debuginfod_urls); +RZ_API void rz_bin_dwarf_free(RZ_OWN RZ_NULLABLE RzBinDWARF *dw); +RZ_API void rz_bin_dwarf_dump( + RZ_BORROW RZ_NONNULL RzBinDWARF *dw, + RZ_BORROW RZ_NONNULL RzStrBuf *sb); + +// Assuming ValueType is an enum defined elsewhere +typedef enum { + RzBinDwarfValueType_GENERIC, + RzBinDwarfValueType_I8, + RzBinDwarfValueType_U8, + RzBinDwarfValueType_I16, + RzBinDwarfValueType_U16, + RzBinDwarfValueType_I32, + RzBinDwarfValueType_U32, + RzBinDwarfValueType_F32, + RzBinDwarfValueType_I64, + RzBinDwarfValueType_U64, + RzBinDwarfValueType_F64, + RzBinDwarfValueType_I128, + RzBinDwarfValueType_U128, + RzBinDwarfValueType_LOCATION, +} RzBinDwarfValueType; + +struct rz_bin_dwarf_location_t; + +typedef struct { + RzBinDwarfValueType type; + union { + ut64 generic; + ut8 u8; + st8 i8; + ut16 u16; + st16 i16; + ut32 u32; + st32 i32; + ut64 u64; + st64 i64; + float f32; + double f64; + struct rz_bin_dwarf_location_t *location; + }; +} RzBinDwarfValue; + +typedef ut64 UnitOffset; +typedef ut64 DebugInfoOffset; + +struct rz_bin_dwarf_location_t; + +typedef struct { + bool has_bit_offset; + ut64 bit_offset; + struct rz_bin_dwarf_location_t *location; + bool has_size_in_bits; + ut64 size_in_bits; +} RzBinDwarfPiece; + +typedef enum { + EvaluationStateWaiting_MEMORY, + EvaluationStateWaiting_ENTRY_VALUE, + EvaluationStateWaiting_RelocatedAddress, + EvaluationStateWaiting_IndexedAddress, + EvaluationStateWaiting_TLS, + EvaluationStateWaiting_AtLocation, + EvaluationStateWaiting_ParameterRef, + EvaluationStateWaiting_FbReg, +} RzBinDwarfEvaluationStateWaiting; + +typedef struct { + enum { + EVALUATION_STATE_START, + EVALUATION_STATE_READY, + EVALUATION_STATE_ERROR, + EVALUATION_STATE_DECODE_ERROR, + EVALUATION_STATE_COMPLETE, + EVALUATION_STATE_WAITING, + EVALUATION_STATE_WAITING_RESOLVE, + } kind; + + union { + RzBinDwarfValue *start; // nullable + // Error error; + RzBinDwarfEvaluationStateWaiting waiting; + }; +} RzBinDwarfEvaluationState; + +typedef struct { + const RzBinDWARF *dw; + const RzBinDwarfCompUnit *unit; + const RzBinDwarfDie *fn_die; + RzBinEndianReader bytecode; + const RzBinDwarfEncoding *encoding; + ut64 *object_address; + ut32 max_iterations; + ut32 iteration; + RzBinDwarfEvaluationState state; + + // Stack operations are done on word-sized values. We do all + // operations on 64-bit values, and then mask the results + // appropriately when popping. + ut64 addr_mask; + // The stack. + RzVector /**/ stack; + + // The next operation to decode and evaluate. + RzBinEndianReader pc; + + // If we see a DW_OP_call* operation, the previous PC and bytecode + // is stored here while evaluating the subroutine. + RzVector /**/ expression_stack; + + RzVector /**/ result; +} RzBinDwarfEvaluation; + +typedef struct { + enum { + EvaluationResult_COMPLETE, + EvaluationResult_INCOMPLETE, + EvaluationResult_ERR, + EvaluationResult_REQUIRES_MEMORY, + EvaluationResult_REQUIRES_ENTRY_VALUE, + EvaluationResult_REQUIRES_RESOLVE, + } kind; + union { + struct { + ut64 address; + ut8 size; + bool has_space : 1; + ut64 space : 63; + UnitOffset base_type; + } requires_memory; + struct { + RzBinDwarfBlock expression; + } requires_entry_value; + ut64 requires_relocated_address; + struct { + ut64 index; + bool relocate; + } requires_indexed_address; + struct { + ut64 offset; + } requires_at_location; + struct { + ut64 offset; + } requires_parameter_ref; + }; +} RzBinDwarfEvaluationResult; + +typedef enum { + RzBinDwarfLocationKind_EMPTY, + RzBinDwarfLocationKind_DECODE_ERROR, + RzBinDwarfLocationKind_REGISTER, + RzBinDwarfLocationKind_REGISTER_OFFSET, + RzBinDwarfLocationKind_ADDRESS, + RzBinDwarfLocationKind_VALUE, + RzBinDwarfLocationKind_BYTES, + RzBinDwarfLocationKind_IMPLICIT_POINTER, + RzBinDwarfLocationKind_COMPOSITE, + RzBinDwarfLocationKind_EVALUATION_WAITING, + RzBinDwarfLocationKind_CFA_OFFSET, + RzBinDwarfLocationKind_FB_OFFSET, + RzBinDwarfLocationKind_LOCLIST, +} RzBinDwarfLocationKind; + +typedef struct rz_bin_dwarf_location_t { + RzBinDwarfLocationKind kind; + st64 offset; + RzBinDwarfEncoding encoding; + union { + ut64 register_number; + ut64 address; + RzBinDwarfValue value; + RzBinDwarfBlock bytes; + DebugInfoOffset implicit_pointer; + struct { + RzBinDwarfEvaluation *eval; + RzBinDwarfEvaluationResult *result; + } eval_waiting; + RzVector /**/ *composite; + const RzBinDwarfLocList *loclist; + }; +} RzBinDwarfLocation; + +typedef const char *(*DWARF_RegisterMapping)(ut32 register_number); + +/// loclists +RZ_API RZ_OWN RzBinDwarfEvaluation *rz_bin_dwarf_evaluation_new( + RZ_OWN RZ_NONNULL RzBinEndianReader *byte_code, + RZ_BORROW RZ_NONNULL const RzBinDWARF *dw, + RZ_BORROW RZ_NULLABLE const RzBinDwarfCompUnit *unit, + RZ_BORROW RZ_NULLABLE const RzBinDwarfDie *fn_die); +RZ_API RZ_OWN RzBinDwarfEvaluation *rz_bin_dwarf_evaluation_new_from_block( + RZ_BORROW RZ_NONNULL RzBinDwarfBlock *block, + RZ_BORROW RZ_NONNULL const RzBinDWARF *dw, + RZ_BORROW RZ_NULLABLE const RzBinDwarfCompUnit *unit, + RZ_BORROW RZ_NULLABLE const RzBinDwarfDie *die); +RZ_API void rz_bin_dwarf_evaluation_free(RZ_OWN RzBinDwarfEvaluation *self); +RZ_API void RzBinDwarfEvaluationResult_free(RZ_OWN RzBinDwarfEvaluationResult *self); +RZ_API bool rz_bin_dwarf_evaluation_evaluate( + RZ_BORROW RZ_NONNULL RzBinDwarfEvaluation *self, + RZ_BORROW RZ_NONNULL RzBinDwarfEvaluationResult *out); +RZ_API RZ_BORROW RzVector /**/ *rz_bin_dwarf_evaluation_result( + RZ_BORROW RZ_NONNULL RzBinDwarfEvaluation *self); +RZ_API RZ_OWN RzBinDwarfLocation *rz_bin_dwarf_location_from_block( + RZ_BORROW RZ_NULLABLE const RzBinDwarfBlock *block, + RZ_BORROW RZ_NONNULL const RzBinDWARF *dw, + RZ_BORROW RZ_NONNULL const RzBinDwarfCompUnit *unit, + RZ_BORROW RZ_NULLABLE const RzBinDwarfDie *die); + +typedef struct { + DWARF_RegisterMapping dwarf_register_mapping; + const char *loclist_sep; + const char *loclist_indent; + const bool loclist_breaklines; + const char *expr_sep; + const char *expr_indent; + const bool expr_breaklines; + const char *composite_sep; + const char *composite_indent; + const bool compose_breaklines; + const bool value_detail; +} RzBinDWARFDumpOption; + +RZ_API void rz_bin_dwarf_expression_dump( + RZ_BORROW RZ_NONNULL const RzBinDwarfEncoding *encoding, + RZ_BORROW RZ_NONNULL const RzBinDwarfBlock *block, + RZ_BORROW RZ_NONNULL RzStrBuf *sb, + RZ_BORROW RZ_NONNULL const RzBinDWARFDumpOption *opt); +RZ_API char *rz_bin_dwarf_expression_to_string( + RZ_BORROW RZ_NONNULL const RzBinDwarfEncoding *encoding, + RZ_BORROW RZ_NONNULL const RzBinDwarfBlock *block, + RZ_BORROW RZ_NONNULL const RzBinDWARFDumpOption *opt); +RZ_API void rz_bin_dwarf_loclist_dump( + RZ_BORROW RZ_NONNULL const RzBinDwarfLocList *loclist, + RZ_BORROW RZ_NONNULL RzStrBuf *sb, + RZ_BORROW RZ_NONNULL const RzBinDWARFDumpOption *opt); +RZ_API void rz_bin_dwarf_location_composite_dump( + RZ_BORROW RZ_NONNULL const RzVector /**/ *composite, + RZ_BORROW RZ_NONNULL RzStrBuf *sb, + RZ_BORROW RZ_NONNULL const RzBinDWARFDumpOption *opt); +RZ_API void rz_bin_dwarf_location_dump( + RZ_BORROW RZ_NONNULL const RzBinDwarfLocation *loc, + RZ_BORROW RZ_NONNULL RzStrBuf *sb, + RZ_BORROW RZ_NONNULL const RzBinDWARFDumpOption *opt); +RZ_API RZ_OWN char *rz_bin_dwarf_location_to_string( + RZ_BORROW RZ_NONNULL const RzBinDwarfLocation *loc, + RZ_BORROW RZ_NONNULL const RzBinDWARFDumpOption *opt); + +RZ_API void rz_bin_dwarf_location_fini(RZ_BORROW RZ_NONNULL RzBinDwarfLocation *self); +RZ_API void rz_bin_dwarf_location_free(RZ_BORROW RZ_NONNULL RzBinDwarfLocation *self); +RZ_API RZ_OWN RzBinDwarfLocation *rz_bin_dwarf_location_clone( + RZ_BORROW RZ_NONNULL RzBinDwarfLocation *self); +RZ_API void rz_bin_dwarf_loclists_free(RZ_OWN RZ_NULLABLE RzBinDwarfLocLists *self); +RZ_API void rz_bin_dwarf_loclists_dump( + RZ_NONNULL RZ_BORROW RzBinDwarfLocLists *loclists, + RZ_NONNULL RZ_BORROW RzBinDWARF *dw, + RZ_NONNULL RZ_BORROW RzStrBuf *sb); +RZ_API RzBinDwarfLocList *rz_bin_dwarf_loclists_get( + RZ_BORROW RZ_NONNULL RzBinDwarfLocLists *self, + RZ_BORROW RZ_NONNULL RzBinDwarfAddr *addr, + RZ_BORROW RZ_NONNULL RzBinDwarfCompUnit *cu, + ut64 offset); +RZ_API RZ_OWN RzBinDwarfLocLists *rz_bin_dwarf_loclists_new( + RzBinEndianReader *loclists, RzBinEndianReader *loc); +RZ_API RZ_OWN RzBinDwarfLocLists *rz_bin_dwarf_loclists_new_from_file(RZ_BORROW RZ_NONNULL RzBinFile *bf); + +RZ_API RzBinDwarfRngList *rz_bin_dwarf_rnglists_get( + RZ_BORROW RZ_NONNULL RzBinDwarfRngLists *self, + RZ_BORROW RZ_NONNULL RzBinDwarfAddr *addr, + RZ_BORROW RZ_NONNULL RzBinDwarfCompUnit *cu, + ut64 offset); +RZ_API void rz_bin_dwarf_rnglists_dump( + RZ_NONNULL RZ_BORROW RzBinDwarfRngLists *rnglists, + RZ_NONNULL RZ_BORROW RzStrBuf *sb); +/// rnglists +RZ_API RZ_OWN RzBinDwarfRngLists *rz_bin_dwarf_rnglists_new( + RZ_OWN RZ_NULLABLE RzBinEndianReader *rnglists, RZ_OWN RZ_NULLABLE RzBinEndianReader *ranges); +RZ_API RZ_OWN RzBinDwarfRngLists *rz_bin_dwarf_rnglists_new_from_file(RZ_BORROW RZ_NONNULL RzBinFile *bf); + +/// Block +RZ_API bool rz_bin_dwarf_block_empty(RZ_NULLABLE const RzBinDwarfBlock *self); +RZ_API void rz_bin_dwarf_block_dump(RZ_NONNULL const RzBinDwarfBlock *self, RZ_NONNULL RzStrBuf *sb); +RZ_API RZ_BORROW const ut8 *rz_bin_dwarf_block_data(RZ_NONNULL const RzBinDwarfBlock *self); + +/// addr +RZ_API bool rz_bin_dwarf_addr_get( + RZ_BORROW RZ_NONNULL const RzBinDwarfAddr *self, + RZ_BORROW RZ_NONNULL ut64 *address, + ut8 address_size, ut64 base, ut64 index); +RZ_API void rz_bin_dwarf_addr_free(RzBinDwarfAddr *self); +RZ_API RZ_OWN RzBinDwarfAddr *rz_bin_dwarf_addr_new(RZ_OWN RZ_NONNULL RzBinEndianReader *R); +RZ_API RZ_OWN RzBinDwarfAddr *rz_bin_dwarf_addr_from_file(RZ_BORROW RZ_NONNULL RzBinFile *bf); + +RZ_API const char *rz_bin_dwarf_attr_string( + RZ_BORROW RZ_NONNULL const RzBinDwarfAttr *attr, + RZ_BORROW RZ_NULLABLE const RzBinDWARF *dw, + ut64 str_offsets_base); +RZ_API RZ_OWN char *rz_bin_dwarf_attr_string_escaped( + RZ_BORROW RZ_NONNULL const RzBinDwarfAttr *attr, + RZ_BORROW RZ_NULLABLE const RzBinDWARF *dw, + ut64 str_offsets_base); + +static inline ut64 rz_bin_dwarf_attr_addr( + const RzBinDwarfAttr *attr, + const RzBinDWARF *dw, + ut64 addr_size, ut64 base) { + rz_return_val_if_fail(attr, UT64_MAX); + + const RzBinDwarfAttrValue *v = &attr->value; + if (v->kind == RzBinDwarfAttr_Addr) { + return attr->value.u64; + } else if (v->kind == RzBinDwarfAttr_AddrIndex && rz_bin_dwarf_addr(dw)) { + ut64 addr = 0; + if (dw && rz_bin_dwarf_addr_get(rz_bin_dwarf_addr(dw), &addr, addr_size, base, attr->value.u64)) { + return addr; + } + } else if (v->kind == RzBinDwarfAttr_UConstant) { + return attr->value.u64; + } + return attr->value.u64; +} + +static inline ut64 rz_bin_dwarf_attr_udata(const RzBinDwarfAttr *attr) { + rz_return_val_if_fail(attr, UT64_MAX); + return attr->value.u64; +} + +static inline bool rz_bin_dwarf_attr_flag( + const RzBinDwarfAttr *attr) { + rz_return_val_if_fail(attr, UT64_MAX); + return attr->value.flag; +} + +static inline st64 rz_bin_dwarf_attr_sdata( + const RzBinDwarfAttr *attr) { + rz_return_val_if_fail(attr, UT64_MAX); + return attr->value.s64; +} + +static inline const RzBinDwarfBlock *rz_bin_dwarf_attr_block( + const RzBinDwarfAttr *attr) { + rz_return_val_if_fail(attr && attr->value.kind == RzBinDwarfAttr_Block, NULL); + return &attr->value.block; +} + +RZ_API void rz_bin_dwarf_attr_dump( + RZ_NONNULL RZ_BORROW const RzBinDwarfAttr *attr, + RZ_BORROW RZ_NULLABLE RzBinDWARF *dw, + ut64 str_offsets_base, + RZ_NONNULL RZ_BORROW RzStrBuf *sb); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_bin_source_line.h b/dest/include/librz/rz_bin_source_line.h new file mode 100644 index 00000000000..de3fa1b2814 --- /dev/null +++ b/dest/include/librz/rz_bin_source_line.h @@ -0,0 +1,128 @@ +// SPDX-FileCopyrightText: 2009-2020 nibble +// SPDX-FileCopyrightText: 2009-2020 pancake +// SPDX-FileCopyrightText: 2021 thestr4ng3r +// SPDX-FileCopyrightText: 2024 billow +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RIZIN_RZ_BIN_SOURCE_LINE_H +#define RIZIN_RZ_BIN_SOURCE_LINE_H + +#include +#include + +typedef struct rz_bin_source_line_info_t RzBinSourceLineInfo; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief A single sample of source line info for a specific address + * + * If at least one of the line, column and file members is not 0/NULL, such a sample specifies the line info + * for all addresses greater or equal to address until the next address that has another sample. + * + * If all the members line, column and file are 0/NULL, then this is a closing sample, indicating that the + * previous entry stops here. The address is the first address **not contained** by the previous record. + * Such a case corresponds for example to what DW_LNE_end_sequence emits in Dwarf. + * Use rz_bin_source_line_sample_is_closing() for checking if a sample is closing. + */ +typedef struct rz_bin_source_line_sample_t { + /** + * The first address that is covered by the given line and column, + * or, if all other members are 0/NULL, this is the first. + */ + ut64 address; + + /** + * If > 0, then indicates the line for the given address and the following. + * If == 0, then indicates that no line information is known. + * + * 32bit for this value is an intentional decision to lower memory consumption. + */ + ut32 line; + + /** + * If > 0, then indicates the column. + * If == 0, then no column information is known. + * + * 32bit for this value is an intentional decision to lower memory consumption. + */ + ut32 column; + + /** + * Filename, which must come out of the const pool of the owning + * RzBinSourceLineInfo or RzBinSourceLineInfoBuilder. + */ + const char *file; +} RzBinSourceLineSample; + +/* + * see documentation of RzBinSourceLineSample about what closing exactly means. + */ +static inline bool rz_bin_source_line_sample_is_closing(const RzBinSourceLineSample *s) { + return !s->line && !s->column && !s->file; +} + +struct rz_bin_source_line_info_t { + /** + * \brief All source line references for given adresses + * + * These elements must be sorted by address and addresses must be unique, so binary search can be applied. + * Source file information is not contained within this array because source file changes + * are generally much sparser than line changes. + */ + RzBinSourceLineSample *samples; + size_t samples_count; + RzStrConstPool filename_pool; +}; // RzBinSourceLineInfo + +/** + * Temporary data structure for building an RzBinSourceLineInfo. + */ +typedef struct rz_bin_source_line_info_builder_t { + RzVector /**/ samples; //< may be unsorted and will be sorted in the finalization step + RzStrConstPool filename_pool; +} RzBinSourceLineInfoBuilder; + +typedef struct { + char *file_content; + ut64 file_size; + RzPVector /**/ *line_by_ln; +} RzBinSourceLineCacheItem; + +typedef struct { + HtSP /**/ *items; +} RzBinSourceLineCache; + +typedef struct { + RzBinSourceLineCache cache; + bool enable : 1; + bool file : 1; + bool abspath : 1; + bool lines : 1; +} RzDebugInfoOption; + +RZ_API void rz_bin_source_line_info_builder_init(RzBinSourceLineInfoBuilder *builder); +RZ_API void rz_bin_source_line_info_builder_fini(RzBinSourceLineInfoBuilder *builder); +RZ_API void rz_bin_source_line_info_builder_push_sample(RzBinSourceLineInfoBuilder *builder, ut64 address, ut32 line, ut32 column, const char *file); +RZ_API RzBinSourceLineInfo *rz_bin_source_line_info_builder_build_and_fini(RzBinSourceLineInfoBuilder *builder); + +RZ_API bool rz_bin_source_line_info_merge(RZ_BORROW RZ_NONNULL RzBinSourceLineInfo *dst, RZ_BORROW RZ_NONNULL RzBinSourceLineInfo *src); +RZ_API void rz_bin_source_line_info_free(RzBinSourceLineInfo *sli); +RZ_API const RzBinSourceLineSample *rz_bin_source_line_info_get_first_at(const RzBinSourceLineInfo *sli, ut64 addr); +RZ_API const RzBinSourceLineSample *rz_bin_source_line_info_get_next(const RzBinSourceLineInfo *sli, RZ_NONNULL const RzBinSourceLineSample *cur); + +RZ_API bool rz_bin_source_line_addr2line( + RZ_BORROW RZ_IN RZ_NONNULL const RzBinSourceLineInfo *sl, + ut64 addr, + RZ_BORROW RZ_OUT RZ_NULLABLE char *file, + int len, + RZ_BORROW RZ_OUT RZ_NULLABLE int *line); +RZ_API RZ_OWN char *rz_bin_source_line_addr2text( + RZ_BORROW RZ_IN RZ_NONNULL const RzBinSourceLineInfo *sl, ut64 addr, RzDebugInfoOption opt); + +#ifdef __cplusplus +} +#endif +#endif // RIZIN_RZ_BIN_SOURCE_LINE_H diff --git a/dest/include/librz/rz_bind.h b/dest/include/librz/rz_bind.h new file mode 100644 index 00000000000..1ab53c8337e --- /dev/null +++ b/dest/include/librz/rz_bind.h @@ -0,0 +1,52 @@ +// SPDX-FileCopyrightText: 2015-2020 pancake +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_BIND_H +#define RZ_BIND_H + +#include + +// TODO: These binds needs to be removed. + +typedef int (*RzCoreCmd)(void *core, const char *cmd); +typedef int (*RzCoreCmdF)(void *user, const char *fmt, ...); +typedef int (*RzCoreDebugBpHit)(void *core, void *bp); +typedef void (*RzCoreDebugSyscallHit)(void *core); +typedef char *(*RzCoreCmdStr)(void *core, const char *cmd); +typedef char *(*RzCoreCmdStrF)(void *core, const char *cmd, ...); +typedef void (*RzCorePuts)(const char *cmd); +typedef void (*RzCoreSetArchBits)(void *core, const char *arch, int bits); +typedef const char *(*RzCoreGetName)(void *core, ut64 off); +typedef char *(*RzCoreGetNameDelta)(void *core, ut64 off); +typedef void (*RzCoreSeekArchBits)(void *core, ut64 addr); +typedef ut64 (*RzCoreConfigGetI)(void *core, const char *key); +typedef const char *(*RzCoreConfigGet)(void *core, const char *key); +typedef bool (*RzCoreConfigSet)(void *core, const char *key, const char *value); +typedef bool (*RzCoreConfigSetI)(void *core, const char *key, ut64 value); +typedef ut64 (*RzCoreNumGet)(void *core, const char *str); +typedef const RzList *(*RzCoreFlagsGet)(void *core, ut64 offset); +typedef bool (*RzCoreBinApplyInfo)(void *core, void *binfile, ut32 mask); + +typedef struct rz_core_bind_t { + void *core; + RzCoreCmd cmd; + RzCoreCmdF cmdf; + RzCoreCmdStr cmdstr; + RzCoreCmdStrF cmdstrf; + RzCorePuts puts; + RzCoreDebugBpHit bphit; + RzCoreDebugSyscallHit syshit; + RzCoreSetArchBits setab; + RzCoreGetName getName; + RzCoreGetNameDelta getNameDelta; + RzCoreSeekArchBits archbits; + RzCoreConfigGetI cfggeti; + RzCoreConfigGet cfgGet; + RzCoreConfigSet cfgSet; + RzCoreConfigSetI cfgSetI; + RzCoreNumGet numGet; + RzCoreFlagsGet flagsGet; + RzCoreBinApplyInfo applyBinInfo; +} RzCoreBind; + +#endif diff --git a/dest/include/librz/rz_bp.h b/dest/include/librz/rz_bp.h new file mode 100644 index 00000000000..57d305a01c7 --- /dev/null +++ b/dest/include/librz/rz_bp.h @@ -0,0 +1,156 @@ +#ifndef RZ_BP_H +#define RZ_BP_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RZ_BP_MAXPIDS 10 +#define RZ_BP_CONT_NORMAL 0 + +enum { + RZ_BP_TYPE_SW, + RZ_BP_TYPE_HW, + RZ_BP_TYPE_COND, + RZ_BP_TYPE_FAULT, + RZ_BP_TYPE_DELETE, +}; + +typedef struct rz_bp_item_t { + char *name; + char *module_name; /*module where you get the base address*/ + st64 module_delta; /*delta to apply to module */ + ut64 addr; + ut64 delta; + int size; /* size of breakpoint area */ + bool swstep; /* is this breakpoint from a swstep? */ + int perm; + int hw; + int trace; + int internal; /* used for internal purposes */ + int enabled; + int togglehits; /* counter that toggles breakpoint on reaching 0 */ + int hits; + ut8 *obytes; /* original bytes */ + ut8 *bbytes; /* breakpoint bytes */ + int pids[RZ_BP_MAXPIDS]; + char *data; + char *cond; /* used for conditional breakpoints */ + char *expr; /* to be used for named breakpoints (see rz_debug_bp_update) */ +} RzBreakpointItem; + +struct rz_bp_t; +typedef int (*RzBreakpointCallback)(struct rz_bp_t *bp, RzBreakpointItem *b, bool set); + +/** + * \brief Outer context of mappings/etc. in which the RzBreakpoint instance will operate in. + * In practical Rizin, this is implemented by RzCore. + */ +typedef struct rz_bp_context_t { + void *user; + bool (*is_mapped)(ut64 addr, int perm, void *user); ///< check if the address is mapped and has the given permissions + void (*maps_sync)(void *user); ///< synchronize any maps from the debugee + RzStrBuf *(*get_sw_breakpoint_at)(ut64 addr, void *user); ///< get the software breakpoint based on the address hints + size_t (*get_sw_breakpoint_size_at)(ut64 addr, void *user); ///< get the software breakpoint based on the address hints +} RzBreakpointContext; + +typedef struct rz_bp_t { + void *user; + RzBreakpointContext ctx; + int stepcont; + int endian; + bool bpinmaps; /* Only enable breakpoints inside a valid map */ + RzIOBind iob; // compile time dependency + RzStrBuf *opcode; + RzList /**/ *traces; // XXX + PrintfCallback cb_printf; + RzBreakpointCallback breakpoint; + /* storage of breakpoints */ + int nbps; + int nhwbps; + RzList /**/ *bps; // list of breakpoints + RzBreakpointItem **bps_idx; + int bps_idx_count; + ut64 baddr; +} RzBreakpoint; + +typedef struct rz_bp_trace_t { + ut64 addr; + ut64 addr_end; + ut8 *traps; + ut8 *buffer; + ut8 *bits; + int length; + int bitlen; +} RzBreakpointTrace; + +#ifdef RZ_API +RZ_API RzBreakpoint *rz_bp_new(RZ_BORROW RZ_NONNULL RzBreakpointContext *ctx); +RZ_API void rz_bp_free(RzBreakpoint *bp); + +RZ_API bool rz_bp_set_opcode(RZ_NONNULL RzBreakpoint *bp, ut64 addr); +RZ_API bool rz_bp_del(RzBreakpoint *bp, ut64 addr); +RZ_API bool rz_bp_del_all(RzBreakpoint *bp); + +RZ_API size_t rz_bp_size(RZ_NONNULL RzBreakpoint *bp); +RZ_API size_t rz_bp_size_at(RZ_NONNULL RzBreakpoint *bp, ut64 addr); + +/* bp item attribs setters */ +RZ_API size_t rz_bp_get_bytes(RZ_NONNULL RzBreakpoint *bp, ut64 addr, RZ_NONNULL ut8 *buf, int len); +RZ_API int rz_bp_set_trace(RzBreakpoint *bp, ut64 addr, int set); +RZ_API int rz_bp_set_trace_all(RzBreakpoint *bp, int set); +RZ_API RzBreakpointItem *rz_bp_enable(RzBreakpoint *bp, ut64 addr, int set, int count); +RZ_API bool rz_bp_enable_all(RzBreakpoint *bp, int set); + +/* index api */ +RZ_API int rz_bp_del_index(RzBreakpoint *bp, int idx); +RZ_API RzBreakpointItem *rz_bp_get_index(RzBreakpoint *bp, int idx); +RZ_API int rz_bp_get_index_at(RzBreakpoint *bp, ut64 addr); + +RZ_API RZ_BORROW RzBreakpointItem *rz_bp_get_at(RZ_NONNULL RzBreakpoint *bp, ut64 addr); +RZ_API RZ_BORROW RzBreakpointItem *rz_bp_get_ending_at(RZ_NONNULL RzBreakpoint *bp, ut64 addr); +RZ_API RzBreakpointItem *rz_bp_get_in(RzBreakpoint *bp, ut64 addr, int perm); + +RZ_API bool rz_bp_is_valid(RzBreakpoint *bp, RzBreakpointItem *b); +RZ_API bool rz_bp_item_set_cond(RZ_NONNULL RzBreakpointItem *item, RZ_NULLABLE const char *cond); +RZ_API bool rz_bp_item_set_data(RZ_NONNULL RzBreakpointItem *item, RZ_NULLABLE const char *data); +RZ_API bool rz_bp_item_set_expr(RZ_NONNULL RzBreakpointItem *item, RZ_NULLABLE const char *expr); +RZ_API bool rz_bp_item_set_name(RZ_NONNULL RzBreakpointItem *item, RZ_NULLABLE const char *name); + +RZ_API RZ_BORROW RzBreakpointItem *rz_bp_add_sw(RZ_NONNULL RzBreakpoint *bp, ut64 addr, int size, int perm); +RZ_API RzBreakpointItem *rz_bp_add_hw(RzBreakpoint *bp, ut64 addr, int size, int perm); +RZ_API void rz_bp_restore_one(RzBreakpoint *bp, RzBreakpointItem *b, bool set); +RZ_API int rz_bp_restore(RzBreakpoint *bp, bool set); +RZ_API bool rz_bp_restore_except(RzBreakpoint *bp, bool set, ut64 addr); + +/* traptrace */ +RZ_API void rz_bp_traptrace_free(void *ptr); +RZ_API void rz_bp_traptrace_enable(RzBreakpoint *bp, int enable); +RZ_API void rz_bp_traptrace_reset(RzBreakpoint *bp, int hard); +RZ_API ut64 rz_bp_traptrace_next(RzBreakpoint *bp, ut64 addr); +RZ_API int rz_bp_traptrace_add(RzBreakpoint *bp, ut64 from, ut64 to); +RZ_API int rz_bp_traptrace_free_at(RzBreakpoint *bp, ut64 from); +RZ_API void rz_bp_traptrace_list(RzBreakpoint *bp); +RZ_API int rz_bp_traptrace_at(RzBreakpoint *bp, ut64 from, int len); +RZ_API RzList /**/ *rz_bp_traptrace_new(void); + +/* watchpoint */ +RZ_API RZ_BORROW RzBreakpointItem *rz_bp_watch_add(RZ_NONNULL RzBreakpoint *bp, ut64 addr, int size, int hw, int perm); + +/* serialize */ +typedef void *RzSerializeBpParser; +RZ_API void rz_serialize_bp_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzBreakpoint *bp); +RZ_API RzSerializeBpParser rz_serialize_bp_parser_new(void); +RZ_API bool rz_serialize_bp_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzBreakpoint *bp, RZ_NULLABLE RzSerializeResultInfo *res); + +#endif +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_build_version.h b/dest/include/librz/rz_build_version.h new file mode 100644 index 00000000000..0bbc3c086c7 --- /dev/null +++ b/dest/include/librz/rz_build_version.h @@ -0,0 +1,11 @@ +#ifndef RZ_BUILD_VERSION_H +#define RZ_BUILD_VERSION_H + +#define RZ_VERSION_MAJOR 0 +#define RZ_VERSION_MINOR 9 +#define RZ_VERSION_PATCH 0 +#define RZ_VERSION_NUMBER 9000 +#define RZ_VERSION "0.9.0" +/* #undef RZ_PACKAGER_VERSION */ +/* #undef RZ_PACKAGER */ +#endif /* RZ_BUILD_VERSION_H */ diff --git a/dest/include/librz/rz_cmd.h b/dest/include/librz/rz_cmd.h new file mode 100644 index 00000000000..f788fed5490 --- /dev/null +++ b/dest/include/librz/rz_cmd.h @@ -0,0 +1,626 @@ +#ifndef RZ_CMD_H +#define RZ_CMD_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// RZ_LIB_VERSION_HEADER (rz_cmd); + +/** + * Value returned by a command handler. + */ +typedef enum rz_cmd_status_t { + RZ_CMD_STATUS_OK = 0, ///< command handler exited in the right way + RZ_CMD_STATUS_WRONG_ARGS, ///< command handler could not handle the arguments passed to it + RZ_CMD_STATUS_ERROR, ///< command handler had issues while running (e.g. allocation error, etc.) + RZ_CMD_STATUS_INVALID, ///< command could not be executed (e.g. shell level error, bad expression, etc.) + RZ_CMD_STATUS_NONEXISTINGCMD, ///< command does not exist + RZ_CMD_STATUS_EXIT, ///< command handler asks to exit the prompt loop +} RzCmdStatus; + +/** + * Type of argument a command handler can have. This is used for visualization + * in help messages and for autocompletion as well. + */ +typedef enum rz_cmd_arg_type_t { + RZ_CMD_ARG_TYPE_FAKE, ///< This is not considered a real argument, just used to show something in the help. Name of arg is shown as-is and it is not counted. + RZ_CMD_ARG_TYPE_NUM, ///< Argument is a number + RZ_CMD_ARG_TYPE_RZNUM, ///< Argument that can be interpreted by RzNum (numbers, flags, operations, etc.) + RZ_CMD_ARG_TYPE_STRING, ///< Argument that can be an arbitrary string + RZ_CMD_ARG_TYPE_RAW, ///< Like RZ_CMD_ARG_TYPE_STRING, but unescaping and quote unwrapping is not done + RZ_CMD_ARG_TYPE_ENV, ///< Argument can be the name of an existing rizin variable + RZ_CMD_ARG_TYPE_CHOICES, ///< Argument can be one of the provided choices + RZ_CMD_ARG_TYPE_FCN, ///< Argument can be the name of an existing function + RZ_CMD_ARG_TYPE_FILE, ///< Argument is a filename + RZ_CMD_ARG_TYPE_OPTION, ///< Argument is an option, prefixed with `-`. It is present or not. No argument. + RZ_CMD_ARG_TYPE_CMD, ///< Argument is an rizin command + RZ_CMD_ARG_TYPE_MACRO, ///< Argument is the name of a pre-defined macro + RZ_CMD_ARG_TYPE_EVAL_KEY, ///< Argument is the name of a evaluable variable (e.g. `et` command) + RZ_CMD_ARG_TYPE_EVAL_FULL, ///< Argument is the name+(optional)value of a evaluable variable (e.g. `e` command) + RZ_CMD_ARG_TYPE_FCN_VAR, ///< Argument is the name of a function variable/argument + RZ_CMD_ARG_TYPE_FLAG, ///< Argument is a rizin flag + RZ_CMD_ARG_TYPE_ENUM_TYPE, ///< Argument is a C enum type name + RZ_CMD_ARG_TYPE_STRUCT_TYPE, ///< Argument is a C struct type name + RZ_CMD_ARG_TYPE_UNION_TYPE, ///< Argument is a C union type name + RZ_CMD_ARG_TYPE_ALIAS_TYPE, ///< Argument is a C typedef (alias) name + RZ_CMD_ARG_TYPE_CLASS_TYPE, ///< Argument is a C++/etc class name + RZ_CMD_ARG_TYPE_ANY_TYPE, ///< Argument is the any of the C or C++ type name + RZ_CMD_ARG_TYPE_GLOBAL_VAR, ///< Argument is a user defined global variable + RZ_CMD_ARG_TYPE_REG_FILTER, ///< Argument is a register name, size, type or "all" + RZ_CMD_ARG_TYPE_REG_TYPE, ///< Argument is a register type/arena like "gpr" + RZ_CMD_ARG_TYPE_FOLDER, ///< Argument is a directory or path +} RzCmdArgType; + +/** + * Argument can contain spaces when it is the last of a command and it would + * be considered as a single argument by the command handler. + */ +#define RZ_CMD_ARG_FLAG_LAST (1 << 0) +/** + * Argument is an array of elements. It must be the last in the list of + * arguments of a command. + */ +#define RZ_CMD_ARG_FLAG_ARRAY (1 << 1) +/** + * Argument is an option, prefixed with `-`. It is present or not. + */ +#define RZ_CMD_ARG_FLAG_OPTION (1 << 2) + +typedef enum rz_cmd_escape_t { + RZ_CMD_ESCAPE_ONE_ARG, ///< The string should be escaped so that it appears as one single argument + RZ_CMD_ESCAPE_MULTI_ARG, ///< The string should be escaped so that it appears as one or multiple arguments + RZ_CMD_ESCAPE_PF_ARG, ///< The string should be escaped so that it appears as one or multiple `pf` arguments + RZ_CMD_ESCAPE_DOUBLE_QUOTED_ARG, ///< The string should be escaped so that it can be wrapped in "...." + RZ_CMD_ESCAPE_SINGLE_QUOTED_ARG, ///< The string should be escaped so that it can be wrapped in '....' +} RzCmdEscape; + +/** + * \brief Enum to describe the way data are printed + */ +typedef enum { + RZ_OUTPUT_MODE_STANDARD = 1 << 0, + RZ_OUTPUT_MODE_JSON = 1 << 1, + RZ_OUTPUT_MODE_QUIET = 1 << 2, + RZ_OUTPUT_MODE_SDB = 1 << 3, + RZ_OUTPUT_MODE_LONG = 1 << 4, + RZ_OUTPUT_MODE_LONG_JSON = 1 << 5, + RZ_OUTPUT_MODE_TABLE = 1 << 6, + RZ_OUTPUT_MODE_QUIETEST = 1 << 7, + RZ_OUTPUT_MODE_GRAPH = 1 << 8, + RZ_OUTPUT_MODE_STR_BUF = 1 << 9, +} RzOutputMode; + +RZ_OWN RZ_OUT typedef char *(*pipe_fn)(const char *, int *); +/** + * \brief List of fallback pipe handlers for specific commands. + * + * Each entry maps a command name to the internal implementation used + * when no external binary is available in the system PATH. + */ +typedef struct pipe_fallbacks { + const char *command; + pipe_fn fallback_fn; +} PipeFallbacks; + +/** + * \brief Represent the output state of a command handler. + * + * This structure is passed to commands of type \p RZ_CMD_DESC_TYPE_ARGV_STATE . + */ +typedef struct rz_cmd_state_output_t { + /** + * Output mode expected from the command handler + */ + RzOutputMode mode; + /** + * mode-specific data. Handlers are called with these data already + * initialized as necessary, based on the requested mode, and they do not + * need to be freed by the handler. + */ + union { + PJ *pj; + RzTable *t; + RzStrBuf *sbuf; + } d; +} RzCmdStateOutput; + +typedef int (*RzCmdCb)(void *user, const char *input); +typedef RzCmdStatus (*RzCmdArgvCb)(RzCore *core, int argc, const char **argv); +typedef RzCmdStatus (*RzCmdArgvModesCb)(RzCore *core, int argc, const char **argv, RzOutputMode mode); +typedef RzCmdStatus (*RzCmdArgvStateCb)(RzCore *core, int argc, const char **argv, RzCmdStateOutput *state); +typedef RzCmdStatus (*RzCmdMacroCb)(RzCore *core, int argc, const char **argv, int macro); +typedef int (*RzCmdNullCb)(void *user); + +/** + * argc/argv data created from parsing the input command string. + */ +typedef struct rz_cmd_parsed_args_t { + int argc; + char **argv; + bool has_space_after_cmd; + char *extra; ///< Extra data that is neither a command name nor an argument (e.g. command modifiers/specifiers, table queries, etc.) +} RzCmdParsedArgs; + +typedef struct rz_cmd_macro_t { + char *name; + char **args; + size_t nargs; + char *code; +} RzCmdMacro; + +typedef struct rz_cmd_item_t { + char cmd[64]; + RzCmdCb callback; +} RzCmdItem; + +typedef struct rz_cmd_alias_t { + int count; + char **keys; + char **values; + int *remote; +} RzCmdAlias; + +/** + * \brief A detailed entry that can be used to show additional info about a command entry. + * + * It can contain whatever relevant information (e.g. examples, specific uses of + * a command, variables, etc.). + * + * Displayed as: + * | # + */ +typedef struct rz_cmd_desc_detail_entry_t { + /** + * Main text of the detailed entry + */ + const char *text; + /** + * Short explanation of the entry, shown with the comment color + */ + const char *comment; + /** + * Text to show in a different color, after `text`, usually used to show + * arguments for examples. + * + * Optional. + */ + const char *arg_str; +} RzCmdDescDetailEntry; + +/** + * A detail section used to better describe a command. + */ +typedef struct rz_cmd_desc_detail_t { + /** + * Name of the section, displayed at the beginning of the section. + */ + const char *name; + /** + * NULL-terminated array of entries, displayed one per line. + */ + const RzCmdDescDetailEntry *entries; +} RzCmdDescDetail; + +/** + * Callback used to dynamically generate the details sections in the help of a command. + * NOTE: The array of RzCmdDescDetail returned will be freed, so all fields + * within need to be dynamically allocated even if they are marked as `const`. + */ +typedef RZ_OWN RzCmdDescDetail *(*RzCmdDescDetailCb)(RzCore *core, int argc, const char **argv); + +/** + * Callback used to dynamically generate the choices of an argument with type \p RZ_CMD_ARG_TYPE_CHOICES + */ +typedef RZ_OWN char **(*RzCmdArgChoiceCb)(RzCore *core); + +/** + * A description of an argument of a RzCmdDesc. + */ +typedef struct rz_cmd_desc_arg_t { + /** + * The name of the argument, shown also in its help. + */ + const char *name; + /** + * True if the argument is optional. If argument X is optional, then all + * arguments after X can only be specified if X was provided as well and + * they don't need to be set as optional. + * + * Example: + * CMDNAME [ [ [optional-arg4]]] + * has optional=false + * has optional=true + * has optional=false (it can be specified only if arg1 + * was specified as well, so it doesn't need to be optional) + * has optional=true + * has optional=true + * Given the above: + * - `CMDNAME a0` is a valid command + * - `CMDNAME a0 a1 a2` is a valid command + * - `CMDNAME a0 a1` is not a valid command, because if a1 is specified, also a2 has to be + * - `CMDNAME a0 a1 a2 a3` is a valid command + * - `CMDNAME a0 a1 a2 a3 a4` is a valid command + */ + bool optional; + /** + * True if no space should be displayed before this argument in the help. By default it is + * false and a space is displayed before this argument. + */ + bool no_space; + /** + * Type of the argument. + */ + RzCmdArgType type; + /** + * Flag of the argument, used to modify the behaviour of this argument. See RZ_CMD_ARG_FLAG_ values. + */ + int flags; + /** + * Default value for the argument, if it is not specified. This field + * shall be used only when \p optional is true. + */ + const char *default_value; + /** + * Additional data which is type specific. + */ + union { + /** + * Data associated with an argument of \p type RZ_CMD_ARG_TYPE_CHOICES. + */ + struct { + /** + * Predefined list of possible values. + */ + const char **choices; + /** + * Callback used to generate a list of possible values. + * When this is specified, \p choices is ignored. + */ + RzCmdArgChoiceCb choices_cb; + } choices; + }; +} RzCmdDescArg; + +/** + * Define how the command looks like in the help. + */ +typedef struct rz_cmd_desc_help_t { + /** + * Short-sentence explaining what the command does. + * This is shown, for example, when the list of sub-commands is printed + * and each sub-command has a very short description on the right, + * explaining what it does. + */ + const char *summary; + /** + * Long description of what the command does. It can be as long as you + * want and it should explain well how the command behaves. This is + * shown, for example, when `??` is appended on a command. In that case, + * the short summary is extended with this longer description. + * + * Optional. + */ + const char *description; + /** + * String used to identify the arguments. This usually comes together + * with the summary. + * TODO: explain how to differentiate between required and optional arguments + */ + const char *args_str; + /** + * String that overrides the name+args_str usually used to describe the + * command. + * + * Optional. + */ + const char *usage; + /** + * String to use as sub-commands suggestions instead of the + * auto-generated one (e.g. [abcd] or [?] that you can see near command + * names when doing `w?`). If not provided, the options will be + * auto-generated. + * + * Optional. + */ + const char *options; + /** + * When true, the subcommands are automatically sorted alphabetically. By + * default subcommands are shown in the order provided by the developer. + * + * Optional. + */ + bool sort_subcommands; + /** + * NULL-terminated array of details sections used to better explain how + * to use the command. This is shown together with the long description. + * + * Optional. + */ + const RzCmdDescDetail *details; + /** + * Function that returns an array of details sections used to better explain + * how to use the command. This is shown together with the long description + * and can be used in addition or in alternative of \p details , when the + * output needs to be generated dynamically. + * + * Optional. + */ + RzCmdDescDetailCb details_cb; + /** + * Description of the arguments accepted by this command. + */ + const RzCmdDescArg *args; +} RzCmdDescHelp; + +typedef enum rz_cmd_desc_type_t { + /** + * For handlers that accept argc/argv. It cannot have children. Use + * RZ_CMD_DESC_TYPE_GROUP if you need a command that can be both + * executed and has sub-commands. + */ + RZ_CMD_DESC_TYPE_ARGV = 0, + /** + * For cmd descriptors that are parent of other sub-commands, even if + * they may also have a sub-command with the same name. For example, + * `wc` is both the parent of `wci`, `wc*`, etc. but there is also `wc` + * as a sub-command. + */ + RZ_CMD_DESC_TYPE_GROUP, + /** + * For cmd descriptors that are just used to group together related + * sub-commands. Do not use this if the command can be used by itself or + * if it's necessary to show its help. Because this descriptor is not + * stored in the hashtable and cannot be retrieved except by listing the + * children of its parent. Most of the time you want RZ_CMD_DESC_TYPE_GROUP. + */ + RZ_CMD_DESC_TYPE_INNER, + /** + * For entries that shall be shown in the help tree but that are not + * commands on their own. `|?`, `@?`, `>?` are example of this. It is + * useful to provide help entries for them in the tree, but there are no + * command handlers for these. The RzCmdDescDetail in the help can be + * used to show fake children of this descriptor. + */ + RZ_CMD_DESC_TYPE_FAKE, + /** + * For handlers that accept argc/argv and that provides multiple output + * modes (e.g. rizin commands, quiet output, json, long). It cannot have + * children. Use RZ_CMD_DESC_TYPE_GROUP if you need a command that can + * be both executed and has sub-commands. + */ + RZ_CMD_DESC_TYPE_ARGV_MODES, + /** + * For handlers that accept argc/argv and that provides multiple output + * modes (e.g. rizin commands, quiet output, json, long). It cannot have + * children. Use RZ_CMD_DESC_TYPE_GROUP if you need a command that can + * be both executed and has sub-commands. + * + * Differently from \p RZ_CMD_DESC_TYPE_ARGV_MODES, these handlers receive + * an output structure with the mode and data already initialized (e.g. PJ, + * RzTable, etc.) and the handler just has to fill the data in those + * structure, while RzCmd will allocate, free and print the data within. + */ + RZ_CMD_DESC_TYPE_ARGV_STATE, +} RzCmdDescType; + +/** + * Command Descriptor structure. It represents a command that can be executed + * by the user on the shell or a part of the command help (e.g. groups of + * commands). Anything that appears under `?` has an associated command + * descriptor. + */ +typedef struct rz_cmd_desc_t { + /** + * Type of the command descriptor. There are several types of commands: + * groups, fake and inner have no handlers; argv, mode and state can + * have handlers and get arguments via int argc, char **argv. + */ + RzCmdDescType type; + /** + * Base name of the command. This is used to retrieve the \p RzCmdDesc when + * a user executes a command. It can match multiple user-called commands. + * For example a command that accepts STANDARD and JSON \p modes is called + * for both `` and `j`. + */ + char *name; + /** + * Parent of this command descriptor. + * + * Commands are organized in a tree, with the root being shown when doing + * `?`. This relationship is used when showing commands helps. + */ + struct rz_cmd_desc_t *parent; + /** + * Number of children command descriptors of this node. + */ + int n_children; + /** + * Vector of childrens command descriptors. + */ + RzPVector /**/ children; + /** + * Reference to the help structure of this command descriptor. + */ + const RzCmdDescHelp *help; + + /** + * Type-specific fields. + */ + union { + struct { + RzCmdArgvCb cb; + int min_argc; + int max_argc; + } argv_data; + struct { + struct rz_cmd_desc_t *exec_cd; + } group_data; + struct { + RzCmdArgvModesCb cb; + int modes; ///< A combination of RzOutputMode values + RzOutputMode default_mode; ///< Make one of the modes the default one, used even when the special suffix is not specified. + int min_argc; + int max_argc; + } argv_modes_data; + struct { + RzCmdArgvStateCb cb; + int modes; ///< A combination of RzOutputMode values + RzOutputMode default_mode; ///< Make one of the modes the default one, used even when the special suffix is not specified. + int min_argc; + int max_argc; + } argv_state_data; + } d; +} RzCmdDesc; + +typedef struct rz_cmd_t { + RzCore *core; + RzCmdNullCb nullcallback; + RzCmdItem *cmds[UT8_MAX]; + RzCmdAlias aliases; + HtSP *macros; ///< Map of macros (char *)name -> RzCmdMacro + void *language; // used to store TSLanguage * + HtUP *ts_symbols_ht; + RzCmdDesc *root_cmd_desc; + HtSP *ht_cmds; + /** + * True if a rz_cons_instance exists. When used from RzCore this is + * commonly true. However, it can be used in tests to avoid access to + * non-initialized RzCons. + */ + bool has_cons; + /** + * True when you want to add multiple commands in batch. This is an + * optimization mainly for groups that require sorted sub-commands, so + * instead of sorting on each addition we just sort one time at the end. + * False by default. + */ + bool batch; +} RzCmd; + +// TODO: remove this once transitioned to RzCmdDesc +typedef struct rz_cmd_descriptor_t { + const char *cmd; + const char **help_msg; + const char **help_detail; + const char **help_detail2; + struct rz_cmd_descriptor_t *sub[127]; +} RzCmdDescriptor; + +typedef bool (*RzCmdForeachNameCb)(RzCmd *cmd, const RzCmdDesc *desc, void *user); +typedef bool (*RzCmdForeachMacroCb)(RzCmd *cmd, const RzCmdMacro *macro, void *user); + +#ifdef RZ_API +RZ_API RzCmd *rz_cmd_new(RzCore *core, bool has_cons); +RZ_API RzCmd *rz_cmd_free(RzCmd *cmd); +RZ_API void rz_cmd_batch_start(RzCmd *cmd); +RZ_API void rz_cmd_batch_end(RzCmd *cmd); +RZ_API int rz_cmd_add(RzCmd *cmd, const char *command, RzCmdCb callback); +RZ_API int rz_cmd_call(RzCmd *cmd, const char *command); +RZ_API RzCmdStatus rz_cmd_call_parsed_args(RzCmd *cmd, RzCmdParsedArgs *args); +RZ_API RzCmdDesc *rz_cmd_get_root(RzCmd *cmd); +RZ_API RzCmdDesc *rz_cmd_get_desc(RzCmd *cmd, const char *cmd_identifier); +RZ_API RzCmdDesc *rz_cmd_get_desc_best(RzCmd *cmd, const char *cmd_identifier); +RZ_API RZ_OWN char *rz_cmd_get_help(RZ_BORROW RzCmd *cmd, RZ_BORROW RzCmdParsedArgs *args, bool use_color, int gutter_size); +RZ_API bool rz_cmd_get_help_json(RzCmd *cmd, const RzCmdDesc *cd, PJ *j); +RZ_API bool rz_cmd_get_help_strbuf(RzCmd *cmd, const RzCmdDesc *cd, bool use_color, RzStrBuf *sb, int gutter_size); + +static inline RzCmdStatus rz_cmd_int2status(int v) { + if (v == -2) { + return RZ_CMD_STATUS_EXIT; + } else if (v < 0) { + return RZ_CMD_STATUS_ERROR; + } else { + return RZ_CMD_STATUS_OK; + } +} + +static inline int rz_cmd_status2int(RzCmdStatus s) { + switch (s) { + case RZ_CMD_STATUS_OK: + return 0; + case RZ_CMD_STATUS_ERROR: + case RZ_CMD_STATUS_WRONG_ARGS: + case RZ_CMD_STATUS_INVALID: + case RZ_CMD_STATUS_NONEXISTINGCMD: + return -1; + case RZ_CMD_STATUS_EXIT: + default: + return -2; + } +} + +/* RzCmdDescriptor */ +RZ_API RzCmdDesc *rz_cmd_desc_argv_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, RzCmdArgvCb cb, const RzCmdDescHelp *help); +RZ_API RzCmdDesc *rz_cmd_desc_argv_modes_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, int modes, RzCmdArgvModesCb cb, const RzCmdDescHelp *help); +RZ_API RzCmdDesc *rz_cmd_desc_argv_state_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, int modes, RzCmdArgvStateCb cb, const RzCmdDescHelp *help); +RZ_API RzCmdDesc *rz_cmd_desc_inner_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, const RzCmdDescHelp *help); +RZ_API RzCmdDesc *rz_cmd_desc_group_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, RzCmdArgvCb cb, const RzCmdDescHelp *help, const RzCmdDescHelp *group_help); +RZ_API RzCmdDesc *rz_cmd_desc_group_modes_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, int modes, RzCmdArgvModesCb cb, const RzCmdDescHelp *help, const RzCmdDescHelp *group_help); +RZ_API RzCmdDesc *rz_cmd_desc_group_state_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, int modes, RzCmdArgvStateCb cb, const RzCmdDescHelp *help, const RzCmdDescHelp *group_help); +RZ_API RzCmdDesc *rz_cmd_desc_fake_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, const RzCmdDescHelp *help); +RZ_API RzCmdDesc *rz_cmd_desc_parent(RzCmdDesc *cd); +RZ_API RzCmdDesc *rz_cmd_desc_get_exec(RzCmdDesc *cd); +RZ_API bool rz_cmd_desc_set_default_mode(RzCmdDesc *cd, RzOutputMode mode); +RZ_API bool rz_cmd_desc_has_handler(const RzCmdDesc *cd); +RZ_API bool rz_cmd_desc_remove(RzCmd *cmd, RzCmdDesc *cd); +RZ_API void rz_cmd_foreach_cmdname(RzCmd *cmd, RzCmdDesc *begin, RzCmdForeachNameCb cb, void *user); +RZ_API const RzCmdDescArg *rz_cmd_desc_get_arg(const RzCmdDesc *cd, size_t i); + +#define rz_cmd_desc_children_foreach(root, it_cd) rz_pvector_foreach (&root->children, it_cd) +#define rz_cmd_desc_children_foreach_idx(root, it_cd, idx) rz_pvector_enumerate (&root->children, it_cd, idx) + +RZ_API void rz_cmd_desc_details_free(RzCmdDescDetail *details); + +/* RzCmdParsedArgs */ +RZ_API RzCmdParsedArgs *rz_cmd_parsed_args_new(const char *cmd, int n_args, char **args); +RZ_API RzCmdParsedArgs *rz_cmd_parsed_args_newcmd(const char *cmd); +RZ_API RzCmdParsedArgs *rz_cmd_parsed_args_newargs(int n_args, char **args); +RZ_API void rz_cmd_parsed_args_free(RzCmdParsedArgs *args); +RZ_API bool rz_cmd_parsed_args_setargs(RzCmdParsedArgs *arg, int n_args, char **args); +RZ_API bool rz_cmd_parsed_args_addarg(RzCmdParsedArgs *a, const char *arg); +RZ_API bool rz_cmd_parsed_args_setcmd(RzCmdParsedArgs *arg, const char *cmd); +RZ_API char *rz_cmd_parsed_args_argstr(RzCmdParsedArgs *arg); +RZ_API char *rz_cmd_parsed_args_execstr(RzCmdParsedArgs *arg); +RZ_API const char *rz_cmd_parsed_args_cmd(RzCmdParsedArgs *arg); + +RZ_API char *rz_cmd_escape_arg(const char *arg, RzCmdEscape escape); +RZ_API char *rz_cmd_unescape_arg(const char *arg, RzCmdEscape escape); + +RZ_API void rz_cmd_state_output_array_start(RzCmdStateOutput *state); +RZ_API void rz_cmd_state_output_array_end(RzCmdStateOutput *state); +RZ_API void rz_cmd_state_output_set_columnsf(RzCmdStateOutput *state, const char *fmt, ...); +RZ_API void rz_cmd_state_output_set_color_selector(RzCmdStateOutput *state, RzTableColorSelector color_cb, void *user); +RZ_API bool rz_cmd_state_output_init(RZ_NONNULL RzCmdStateOutput *state, RzOutputMode mode, RZ_NULLABLE const RzCore *core); +RZ_API void rz_cmd_state_output_fini(RZ_NONNULL RzCmdStateOutput *state); +RZ_API void rz_cmd_state_output_free(RZ_NONNULL RzCmdStateOutput *state); +RZ_API void rz_cmd_state_output_print(RZ_NONNULL RzCmdStateOutput *state); + +#define rz_cmd_parsed_args_foreach_arg(args, i, arg) for ((i) = 1; (i) < (args->argc) && ((arg) = (args)->argv[i]); (i)++) + +/* rz_cmd_macro */ +RZ_API bool rz_cmd_macro_add(RZ_NONNULL RzCmd *cmd, RZ_NONNULL const char *name, const char **args, RZ_NONNULL const char *code); +RZ_API bool rz_cmd_macro_update(RZ_NONNULL RzCmd *cmd, RZ_NONNULL const char *name, const char **args, RZ_NONNULL const char *code); +RZ_API bool rz_cmd_macro_rm(RZ_NONNULL RzCmd *cmd, RZ_NONNULL const char *name); +RZ_API const RzCmdMacro *rz_cmd_macro_get(RZ_NONNULL RzCmd *cmd, RZ_NONNULL const char *name); +RZ_API RZ_OWN RzList /**/ *rz_cmd_macro_list(RZ_NONNULL RzCmd *cmd); +RZ_API RzCmdStatus rz_cmd_macro_call(RZ_NONNULL RzCmd *cmd, RZ_NONNULL const char *name, RZ_NONNULL const char **argv); +RZ_API RzCmdStatus rz_cmd_macro_call_multiple(RZ_NONNULL RzCmd *cmd, RZ_NONNULL const char *name, RZ_NONNULL const char **argv); +RZ_API void rz_cmd_macro_foreach(RZ_NONNULL RzCmd *cmd, RzCmdForeachMacroCb cb, void *user); + +RZ_API bool rz_cmd_alias_del(RzCmd *cmd, const char *k); +RZ_API char **rz_cmd_alias_keys(RzCmd *cmd, int *sz); +RZ_API int rz_cmd_alias_set(RzCmd *cmd, const char *k, const char *v, int remote); +RZ_API char *rz_cmd_alias_get(RzCmd *cmd, const char *k, int remote); +RZ_API void rz_cmd_alias_free(RzCmd *cmd); + +#ifdef __cplusplus +} +#endif + +#endif +#endif diff --git a/dest/include/librz/rz_cmp.h b/dest/include/librz/rz_cmp.h new file mode 100644 index 00000000000..e4db6836021 --- /dev/null +++ b/dest/include/librz/rz_cmp.h @@ -0,0 +1,55 @@ +// SPDX-FileCopyrightText: 2021 Dhruv Maroo +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_CMP_H +#define RZ_CMP_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + ut32 len; // max 255 bytes diff in one struct + bool same; + ut8 *data1; + ut8 *data2; + ut64 addr1; + ut64 addr2; +} RzCompareData; + +RZ_API RZ_OWN RzCompareData *rz_core_cmp_mem_mem(RzCore *core, ut64 addr1, ut64 addr2, ut32 len); +RZ_API RZ_OWN RzCompareData *rz_core_cmp_mem_data(RzCore *core, ut64 addr, RZ_NONNULL const ut8 *data, ut32 len); +RZ_API int rz_core_cmp_print(RzCore *core, RZ_NONNULL const RzCompareData *cmp, RzCmdStateOutput *state); +RZ_API RZ_OWN RzList /**/ *rz_core_cmp_disasm(RzCore *core, ut64 addr1, ut64 addr2, ut32 len); +RZ_API void rz_core_cmp_free(RzCompareData *cmp); +RZ_API bool rz_core_cmp_disasm_print(RzCore *core, const RzList /**/ *compare, bool unified); + +/** + * \struct RzCoreCmpWatcher + * \brief Watcher which executes a command when listed + */ +typedef struct rz_core_cmpwatch_t { + ut64 addr; ///< Address of the watcher + int size; ///< Size of the watcher + char cmd[32]; ///< Command to be executed by the watcher + ut8 *odata; ///< original data at the given address + ut8 *ndata; ///< New data at the given address +} RzCoreCmpWatcher; + +/* watchers */ +RZ_API void rz_core_cmpwatch_free(RzCoreCmpWatcher *w); +RZ_API RzCoreCmpWatcher *rz_core_cmpwatch_get(RzCore *core, ut64 addr); +RZ_API bool rz_core_cmpwatch_add(RzCore *core, ut64 addr, int size, const char *cmd); +RZ_API bool rz_core_cmpwatch_del(RzCore *core, ut64 addr); +RZ_API bool rz_core_cmpwatch_update(RzCore *core, ut64 addr); +RZ_API void rz_core_cmpwatch_show(RzCore *core, ut64 addr, RzOutputMode mode); +RZ_API bool rz_core_cmpwatch_revert(RzCore *core, ut64 addr); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_CMP_H */ diff --git a/dest/include/librz/rz_config.h b/dest/include/librz/rz_config.h new file mode 100644 index 00000000000..1adae7acad5 --- /dev/null +++ b/dest/include/librz/rz_config.h @@ -0,0 +1,141 @@ +#ifndef RZ_CONFIG_H +#define RZ_CONFIG_H + +#include "rz_types.h" +#include "rz_util.h" +#include "rz_util/rz_serialize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_config); + +#define CN_BOOL 0x000001 +#define CN_INT 0x000002 +// NOTE: removed because this is redundant and it does not add any value +// compared to CN_INT. Use that instead for consistency +// #define CN_OFFT 0x000004 +#define CN_STR 0x000008 +#define CN_RO 0x000010 +#define CN_RW 0x000020 + +#define NODECB(w, x, y) rz_config_set_cb(cfg, w, x, y) +#define NODEICB(w, x, y) rz_config_set_i_cb(cfg, w, x, y) +#define SETDESC(x, y) rz_config_node_desc(x, y) +#define SETOPTIONS(x, ...) set_options(x, __VA_ARGS__) +#define SETI(x, y, z) SETDESC(rz_config_set_i(cfg, x, y), z) +#define SETB(x, y, z) SETDESC(rz_config_set_b(cfg, x, y), z) +#define SETICB(w, x, y, z) SETDESC(NODEICB(w, x, y), z) +#define SETPREF(x, y, z) SETDESC(rz_config_set(cfg, x, y), z) +#define SETCB(w, x, y, z) SETDESC(NODECB(w, x, y), z) +#define SETBPREF(x, y, z) SETDESC(NODECB(x, y, boolify_var_cb), z) + +typedef bool (*RzConfigCallback)(void *user, void *data); + +typedef struct rz_config_node_t { + char *name; + int flags; + char *value; + ut64 i_value; + ut64 *cb_ptr_q; + int *cb_ptr_i; + char **cb_ptr_s; + RzConfigCallback getter; + RzConfigCallback setter; + char *desc; + RzList /**/ *options; +} RzConfigNode; + +RZ_API const char *rz_config_node_type(RzConfigNode *node); + +typedef struct rz_config_t { + int lock; + void *user; + RzNum *num; + RzList /**/ *nodes; + HtSP *ht; +} RzConfig; + +typedef struct rz_config_hold_num_t { + char *key; + ut64 value; +} RzConfigHoldNum; + +typedef struct rz_config_hold_char_t { + char *key; + char *value; +} RzConfigHoldChar; + +typedef struct rz_config_hold_t { + RzConfig *cfg; + RzList /**/ *list_num; // holds numeric values + RzList /**/ *list_char; // holds char values +} RzConfigHold; + +#ifdef RZ_API +RZ_API RzConfigHold *rz_config_hold_new(RzConfig *cfg); +RZ_API void rz_config_hold_free(RzConfigHold *h); + +RZ_API bool rz_config_hold_i(RzConfigHold *h, ...); +RZ_API bool rz_config_hold_s(RzConfigHold *h, ...); + +RZ_API void rz_config_hold_restore(RzConfigHold *h); + +RZ_API RZ_OWN RzConfig *rz_config_new(RZ_BORROW void *user); +RZ_API RZ_OWN RzConfig *rz_config_clone(RZ_BORROW RzConfig *cfg); +RZ_API void rz_config_free(RZ_OWN RzConfig *cfg); +RZ_API void rz_config_lock(RZ_BORROW RzConfig *cfg, int l); +RZ_API void rz_config_bump(RZ_BORROW RzConfig *cfg, const char *key); +RZ_API RZ_BORROW RzConfigNode *rz_config_set_i(RZ_BORROW RzConfig *cfg, RZ_NONNULL const char *name, const ut64 i); +RZ_API RZ_BORROW RzConfigNode *rz_config_set_b(RZ_BORROW RzConfig *cfg, RZ_NONNULL const char *name, bool value); +RZ_API RZ_BORROW RzConfigNode *rz_config_set_cb(RZ_BORROW RzConfig *cfg, const char *name, const char *value, bool (*callback)(void *user, void *data)); +RZ_API RZ_BORROW RzConfigNode *rz_config_set_i_cb(RZ_BORROW RzConfig *cfg, const char *name, st64 ivalue, bool (*callback)(void *user, void *data)); +RZ_API RZ_BORROW RzConfigNode *rz_config_set(RZ_BORROW RzConfig *cfg, RZ_NONNULL const char *name, const char *value); +RZ_API bool rz_config_add_node(RZ_BORROW RzConfig *cfg, RZ_OWN RzConfigNode *node); +RZ_API bool rz_config_rm(RzConfig *cfg, RZ_NONNULL const char *name); +RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name); +RZ_API bool rz_config_get_b(RzConfig *cfg, RZ_NONNULL const char *name); +RZ_API RZ_BORROW const char *rz_config_get(RzConfig *cfg, RZ_NONNULL const char *name); +RZ_API const char *rz_config_desc(RzConfig *cfg, RZ_NONNULL const char *name, RZ_NULLABLE const char *desc); +RZ_API const char *rz_config_node_desc(RzConfigNode *node, RZ_NULLABLE const char *desc); +RZ_API RZ_BORROW RzConfigNode *rz_config_node_get(RZ_BORROW RzConfig *cfg, RZ_NONNULL const char *name); +RZ_API RZ_OWN RzConfigNode *rz_config_node_new(RZ_NONNULL const char *name, RZ_NONNULL const char *value); +RZ_API RZ_OWN RzConfigNode *rz_config_node_clone(RZ_BORROW RzConfigNode *n); +RZ_API void rz_config_node_free(RZ_NULLABLE void *n); +RZ_API void rz_config_node_value_format_i(RZ_OUT char *buf, size_t buf_size, const ut64 i, RZ_NULLABLE RzConfigNode *node); +RZ_API bool rz_config_toggle(RZ_BORROW RzConfig *cfg, RZ_NONNULL const char *name); +RZ_API bool rz_config_readonly(RZ_BORROW RzConfig *cfg, const char *key); +RZ_API bool rz_config_eval(RZ_NONNULL RzConfig *cfg, RZ_NONNULL const char *str); + +RZ_API bool rz_config_set_setter(RzConfig *cfg, const char *key, RzConfigCallback cb); +RZ_API bool rz_config_set_getter(RzConfig *cfg, const char *key, RzConfigCallback cb); + +RZ_API void rz_config_serialize(RZ_NONNULL RzConfig *config, RZ_NONNULL Sdb *db); +RZ_API bool rz_config_unserialize(RZ_NONNULL RzConfig *config, RZ_NONNULL Sdb *db, RZ_NULLABLE char **err); + +static inline bool rz_config_node_is_bool(RzConfigNode *node) { + return node->flags & CN_BOOL; +} +static inline bool rz_config_node_is_int(RzConfigNode *node) { + return node->flags & CN_INT; +} +static inline bool rz_config_node_is_ro(RzConfigNode *node) { + return node->flags & CN_RO; +} +static inline bool rz_config_node_is_str(RzConfigNode *node) { + return node->flags & CN_STR; +} + +/* serialize */ + +RZ_API void rz_serialize_config_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzConfig *config); +RZ_API bool rz_serialize_config_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzConfig *config, + RZ_NULLABLE const char *const *exclude, RZ_NULLABLE RzSerializeResultInfo *res); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_cons.h b/dest/include/librz/rz_cons.h new file mode 100644 index 00000000000..d215db3cd21 --- /dev/null +++ b/dest/include/librz/rz_cons.h @@ -0,0 +1,1276 @@ +#ifndef RZ_CONS_H +#define RZ_CONS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#if __UNIX__ +#include +#include +#include +#include +#endif +#if !__WINDOWS__ +#include +#endif + +/* constants */ +#define CONS_MAX_USER 102400 +#define CONS_BUFSZ 0x4f00 +#define STR_IS_NULL(x) (!x || !x[0]) + +/* palette */ +#define CONS_PALETTE_SIZE 22 +#define CONS_COLORS_SIZE 21 + +#define RZ_CONS_GREP_WORDS 10 +#define RZ_CONS_GREP_WORD_SIZE 64 +#define RZ_CONS_GREP_TOKENS 64 + +RZ_LIB_VERSION_HEADER(rz_cons); + +#define RZ_CONS_CMD_DEPTH 100 + +typedef int (*RzConsGetSize)(int *rows); +typedef int (*RzConsGetCursor)(RZ_NONNULL int *rows); +typedef bool (*RzConsIsBreaked)(void); +typedef void (*RzConsFlush)(void); +typedef void (*RzConsGrepCallback)(const char *grep); + +typedef struct rz_cons_bind_t { + RzConsGetSize get_size; + RzConsGetCursor get_cursor; + PrintfCallback cb_printf; + RzConsIsBreaked is_breaked; + RzConsFlush cb_flush; + RzConsGrepCallback cb_grep; +} RzConsBind; + +typedef struct rz_cons_grep_t { + char strings[RZ_CONS_GREP_WORDS][RZ_CONS_GREP_WORD_SIZE]; + int nstrings; + char *str; + int counter; + bool charCounter; + int less; + bool hud; + bool human; + int json; + char *json_path; + int range_line; + int line; + int sort; + int sort_row; + bool sort_invert; + int f_line; // first line + int l_line; // last line + int tokens[RZ_CONS_GREP_TOKENS]; + int tokens_used; + int amp; + int zoom; + int zoomy; // if set then its scaled unproportionally + int neg; + int begin; + int end; + int icase; + int sorted_column; + RzList /**/ *sorted_lines; + RzList /**/ *unsorted_lines; +} RzConsGrep; + +#if 0 +// TODO Might be better than using rz_cons_pal_get_i +// And have smaller RzConsPrintablePalette and RzConsPalette +enum { + RZ_CONS_PAL_0x00 = 0, + RZ_CONS_PAL_0x7f, + RZ_CONS_PAL_0xff, + RZ_CONS_PAL_ARGS, + RZ_CONS_PAL_BIN, + RZ_CONS_PAL_BTEXT, + RZ_CONS_PAL_CALL, + RZ_CONS_PAL_CJMP, + RZ_CONS_PAL_CMP, + RZ_CONS_PAL_COMMENT, + RZ_CONS_PAL_CREG, + RZ_CONS_PAL_FLAG, + RZ_CONS_PAL_FLINE, + RZ_CONS_PAL_FLOC, + RZ_CONS_PAL_FLOW, + RZ_CONS_PAL_FLOW2, + RZ_CONS_PAL_FNAME, + RZ_CONS_PAL_HELP, + RZ_CONS_PAL_INPUT, + RZ_CONS_PAL_INVALID, + RZ_CONS_PAL_JMP, + RZ_CONS_PAL_LABEL, + RZ_CONS_PAL_MATH, + RZ_CONS_PAL_MOV, + RZ_CONS_PAL_NOP, + RZ_CONS_PAL_NUM, + RZ_CONS_PAL_OFFSET, + RZ_CONS_PAL_OTHER, + RZ_CONS_PAL_POP, + RZ_CONS_PAL_PROMPT, + RZ_CONS_PAL_PUSH, + RZ_CONS_PAL_CRYPTO, + RZ_CONS_PAL_REG, + RZ_CONS_PAL_RESET, + RZ_CONS_PAL_RET, + RZ_CONS_PAL_SWI, + RZ_CONS_PAL_TRAP, + RZ_CONS_PAL_AI_READ, + RZ_CONS_PAL_AI_WRITE, + RZ_CONS_PAL_AI_EXEC, + RZ_CONS_PAL_AI_SEQ, + RZ_CONS_PAL_AI_ASCII, + RZ_CONS_PAL_AI_UNMAP, + RZ_CONS_PAL_GUI_CFLOW, + RZ_CONS_PAL_GUI_DATAOFFSET, + RZ_CONS_PAL_GUI_BACKGROUND, + RZ_CONS_PAL_GUI_ALT_BACKGROUND, + RZ_CONS_PAL_GUI_BORDER, + RZ_CONS_PAL_LINEHL, + RZ_CONS_PAL_GRAPH_BOX, + RZ_CONS_PAL_GRAPH_BOX2, + RZ_CONS_PAL_GRAPH_BOX3, + RZ_CONS_PAL_GRAPH_BOX4, + RZ_CONS_PAL_GRAPH_TRUE, + RZ_CONS_PAL_GRAPH_FALSE, + RZ_CONS_PAL_GRAPH_TRUFAE, + RZ_CONS_PAL_GRAPH_TRACED, + RZ_CONS_PAL_GRAPH_CURRENT, + RZ_CONS_PAL_LAST +}; +#endif + +enum { + ALPHA_RESET = 0x00, + ALPHA_FG = 0x01, + ALPHA_BG = 0x02, + ALPHA_FGBG = 0x03 +}; + +enum { + RZ_CONS_ATTR_BOLD = 1u << 1, + RZ_CONS_ATTR_DIM = 1u << 2, + RZ_CONS_ATTR_ITALIC = 1u << 3, + RZ_CONS_ATTR_UNDERLINE = 1u << 4, + RZ_CONS_ATTR_BLINK = 1u << 5 +}; + +typedef struct rcolor_t { + // bold, italic, underline, ... + ut8 attr; + ut8 a; + ut8 r; + ut8 g; + ut8 b; + ut8 r2; // Background color + ut8 g2; // Only used when a &= ALPHA_FGBG + ut8 b2; + st8 id16; // Mapping to 16-color table +} RzColor; + +typedef struct rz_cons_palette_t { + RzColor b0x00; + RzColor b0x7f; + RzColor b0xff; + RzColor args; + RzColor bin; + RzColor btext; + RzColor call; + RzColor cjmp; + RzColor cmp; + RzColor comment; + RzColor usercomment; + RzColor creg; + RzColor flag; + RzColor fline; + RzColor floc; + RzColor flow; + RzColor flow2; + RzColor fname; + RzColor help; + RzColor input; + RzColor invalid; + RzColor jmp; + RzColor label; + RzColor math; + RzColor mov; + RzColor nop; + RzColor num; + RzColor offset; + RzColor other; + RzColor pop; + RzColor prompt; + RzColor push; + RzColor crypto; + RzColor reg; + RzColor reset; + RzColor ret; + RzColor swi; + RzColor trap; + RzColor ucall; + RzColor ujmp; + RzColor ai_read; + RzColor ai_write; + RzColor ai_exec; + RzColor ai_seq; + RzColor ai_ascii; + RzColor gui_cflow; + RzColor gui_dataoffset; + RzColor gui_background; + RzColor gui_alt_background; + RzColor gui_border; + RzColor wordhl; + RzColor linehl; + RzColor func_var; + RzColor func_var_type; + RzColor func_var_addr; + RzColor widget_bg; + RzColor widget_sel; + RzColor meta; + + /* Graph colors */ + RzColor graph_box; + RzColor graph_box2; + RzColor graph_box3; + RzColor graph_box4; + RzColor graph_true; + RzColor graph_false; + RzColor graph_ujump; + RzColor graph_traced; + RzColor graph_current; + RzColor diff_match; + RzColor diff_unmatch; + RzColor diff_unknown; + RzColor diff_new; +} RzConsPalette; + +typedef struct rz_cons_printable_palette_t { + char *b0x00; + char *b0x7f; + char *b0xff; + char *args; + char *bin; + char *btext; + char *call; + char *cjmp; + char *cmp; + char *comment; + char *usercomment; + char *creg; + char *flag; + char *fline; + char *floc; + char *flow; + char *flow2; + char *fname; + char *help; + char *input; + char *invalid; + char *jmp; + char *label; + char *math; + char *mov; + char *nop; + char *num; + char *offset; + char *other; + char *pop; + char *prompt; + char *push; + char *crypto; + char *reg; + char *reset; + char *ret; + char *swi; + char *trap; + char *ucall; + char *ujmp; + char *ai_read; + char *ai_write; + char *ai_exec; + char *ai_seq; + char *ai_ascii; + char *ai_unmap; + char *gui_cflow; + char *gui_dataoffset; + char *gui_background; + char *gui_alt_background; + char *gui_border; + char *wordhl; + char *linehl; + char *func_var; + char *func_var_type; + char *func_var_addr; + char *widget_bg; + char *widget_sel; + char *meta; + + /* graph colors */ + char *graph_box; + char *graph_box2; + char *graph_box3; + char *graph_box4; + char *diff_match; + char *diff_unmatch; + char *diff_unknown; + char *diff_new; + char *graph_true; + char *graph_false; + char *graph_ujump; + char *graph_traced; + char *graph_current; + char **rainbow; // rainbow + int rainbow_sz; // size of rainbow +} RzConsPrintablePalette; + +typedef void (*RzConsEvent)(void *); + +#define CONS_MAX_ATTR_SZ 16 + +typedef struct rz_cons_canvas_t { + int w; + int h; + int x; + int y; + char **b; + int *blen; + int *bsize; + const char *attr; // The current attr (inserted on each write) + HtUP *attrs; // all the different attributes + RzStrConstPool constpool; // Pool for non-compile-time attrs + int sx; // scrollx + int sy; // scrolly + int color; + int linemode; // 0 = diagonal , 1 = square +} RzConsCanvas; + +#define RUNECODE_MIN 0xc8 // 200 +#define RUNECODE_LINE_VERT 0xc8 +#define RUNECODE_LINE_CROSS 0xc9 +#define RUNECODE_CORNER_BR 0xca +#define RUNECODE_CORNER_BL 0xcb +#define RUNECODE_ARROW_RIGHT 0xcc +#define RUNECODE_ARROW_LEFT 0xcd +#define RUNECODE_LINE_HORIZ 0xce +#define RUNECODE_CORNER_TL 0xcf +#define RUNECODE_CORNER_TR 0xd0 +#define RUNECODE_LINE_UP 0xd1 +#define RUNECODE_CURVE_CORNER_TL 0xd2 +#define RUNECODE_CURVE_CORNER_TR 0xd3 +#define RUNECODE_CURVE_CORNER_BR 0xd4 +#define RUNECODE_CURVE_CORNER_BL 0xd5 +#define RUNECODE_MAX 0xd6 + +#define RUNECODESTR_MIN 0xc8 // 200 +#define RUNECODESTR_LINE_VERT "\xc8" +#define RUNECODESTR_LINE_CROSS "\xc9" +#define RUNECODESTR_CORNER_BR "\xca" +#define RUNECODESTR_CORNER_BL "\xcb" +#define RUNECODESTR_ARROW_RIGHT "\xcc" +#define RUNECODESTR_ARROW_LEFT "\xcd" +#define RUNECODESTR_LINE_HORIZ "\xce" +#define RUNECODESTR_CORNER_TL "\xcf" +#define RUNECODESTR_CORNER_TR "\xd0" +#define RUNECODESTR_LINE_UP "\xd1" +#define RUNECODESTR_CURVE_CORNER_TL "\xd2" +#define RUNECODESTR_CURVE_CORNER_TR "\xd3" +#define RUNECODESTR_CURVE_CORNER_BR "\xd4" +#define RUNECODESTR_CURVE_CORNER_BL "\xd5" +#define RUNECODESTR_MAX 0xd5 + +#define RUNE_LINE_VERT "│" +#define RUNE_LINE_CROSS "┼" /* ├ */ +#define RUNE_LINE_HORIZ "─" +#define RUNE_LINE_UP "↑" +#define RUNE_CORNER_BR "┘" +#define RUNE_CORNER_BL "â””" +#define RUNE_CORNER_TL "┌" +#define RUNE_CORNER_TR "â”" +#define RUNE_ARROW_RIGHT "á³" +#define RUNE_ARROW_LEFT "á¸" +#define RUNE_ARROW_UP "á±" +#define RUNE_ARROW_DOWN "á¯" +#define RUNE_CURVE_CORNER_TL "â•­" +#define RUNE_CURVE_CORNER_TR "â•®" +#define RUNE_CURVE_CORNER_BR "╯" +#define RUNE_CURVE_CORNER_BL "â•°" +#define RUNE_LONG_LINE_HORIZ "―" +#define UTF_CIRCLE "\u25EF" +#define UTF_BLOCK "\u2588" + +// Emoji +#define UTF8_POLICE_CARS_REVOLVING_LIGHT "🚨" +#define UTF8_WHITE_HEAVY_CHECK_MARK "✅" +#define UTF8_SEE_NO_EVIL_MONKEY "🙈" +#define UTF8_SKULL_AND_CROSSBONES "☠" +#define UTF8_KEYBOARD "⌨" +#define UTF8_LEFT_POINTING_MAGNIFYING_GLASS "ðŸ”" +#define UTF8_DOOR "🚪" + +// Variation Selectors +#define UTF8_VS16 "\xef\xb8\x8f" + +typedef char *(*RzConsEditorCallback)(void *core, const char *file, const char *str); +typedef int (*RzConsClickCallback)(void *core, int x, int y); +typedef void (*RzConsBreakCallback)(void *core); +typedef void *(*RzConsSleepBeginCallback)(void *core); +typedef void (*RzConsSleepEndCallback)(void *core, void *user); +typedef void (*RzConsQueueTaskOneshot)(void *core, void *task, void *user); +typedef void (*RzConsFunctionKey)(void *core, int fkey); + +typedef enum { + COLOR_MODE_DISABLED = 0, + COLOR_MODE_16, + COLOR_MODE_256, + COLOR_MODE_16M +} RzConsColorMode; + +typedef enum { + RZ_VIRT_TERM_MODE_DISABLE = 0, ///< Windows only: Use console c api for everything (Windows <= 8) + RZ_VIRT_TERM_MODE_OUTPUT_ONLY, ///< Windows only: Use console c api for input, but output on VT (Windows >= 10) + RZ_VIRT_TERM_MODE_COMPLETE, ///< All the sequences goes through VT (Windows Terminal, mintty, all OSs) +} RzVirtTermMode; + +typedef struct rz_cons_input_context_t { + size_t readbuffer_length; + char *readbuffer; + bool bufactive; +} RzConsInputContext; + +typedef enum { + RZ_CONS_PAL_SEEK_PREVIOUS, + RZ_CONS_PAL_SEEK_NEXT, +} RzConsPalSeekMode; + +typedef struct rz_cons_context_t { + RzConsGrep grep; + RzStack *cons_stack; + char *buffer; + size_t buffer_len; + size_t buffer_sz; + + bool breaked; + RzStack *break_stack; + RzConsEvent event_interrupt; + void *event_interrupt_data; + int cmd_depth; + + // Used for per-task logging redirection + RzLogCallback log_callback; // TODO: RzList of callbacks + + char *lastOutput; + int lastLength; + bool lastMode; + bool lastEnabled; + bool is_interactive; + bool last_interactive_option; ///< To be deprecated for a push/pop behavior + bool pageable; + bool noflush; + + int color_mode; + RzConsPalette cpal; + RzConsPrintablePalette pal; + + // Memoized last calculated row/column inside buffer + int row; + int col; + int rowcol_calc_start; +} RzConsContext; + +#define HUD_BUF_SIZE 512 + +typedef enum { + MOUSE_NONE = 0, + MOUSE_DEFAULT, // indicate an event with no consideration of specific type + LEFT_PRESS, + LEFT_RELEASE, + WHEEL_PRESS, + WHEEL_RELEASE, + RIGHT_PRESS, + RIGHT_RELEASE, + WHEEL_UP, + WHEEL_DOWN, +} MouseEvent; + +typedef struct rz_cons_t { + RzConsContext *context; + RzConsInputContext *input; + bool is_html; + bool was_html; + int lines; + int rows; + int echo; // dump to stdout in realtime + int columns; + int force_rows; + int force_columns; + int fix_rows; + int fix_columns; + bool break_lines; + bool show_autocomplete_widget; + FILE *fdin; // FILE? and then int ?? + int fdout; // only used in pipe.c :?? remove? + const char *teefile; + int (*user_fgets)(char *buf, int len, void *user); + void *user_fgets_user; + RzConsEvent event_resize; + void *event_data; + MouseEvent mouse_event; + + RzConsEditorCallback cb_editor; + RzConsBreakCallback cb_break; + RzConsSleepBeginCallback cb_sleep_begin; + RzConsSleepEndCallback cb_sleep_end; + RzConsClickCallback cb_click; + RzConsQueueTaskOneshot cb_task_oneshot; + RzConsFunctionKey cb_fkey; + + void *user; // Used by + int oldraw; ///< To be deprecated for a push/pop behavior +#if __UNIX__ + struct termios term_raw, term_buf; +#elif __WINDOWS__ + unsigned long term_raw, term_buf, term_pty; + unsigned long old_input_mode, old_output_mode; + ut32 old_cp; + ut32 old_ocp; +#endif + RzNum *num; + /* Pager (like more or less) to use if the output doesn't fit on the + * current window. If NULL or "" no pager is used. */ + char *pager; + int blankline; + char *highlight; + bool enable_highlight; + int null; // if set, does not show anything + int mouse; + int is_wine; + struct rz_line_t *line; + const char **vline; + int refcnt; + RZ_DEPRECATE bool newline; + RzVirtTermMode vtmode; + bool flush; + bool use_utf8; // use utf8 features + bool use_utf8_curvy; // use utf8 curved corners + bool dotted_lines; + int linesleep; + int pagesize; + char *break_word; + int break_word_len; + ut64 timeout; // must come from rz_time_now_mono() + bool grep_color; + bool grep_highlight; + int grep_icase; + bool filter; + char *(*rgbstr)(char *str, size_t sz, ut64 addr); + bool click_set; + int click_x; + int click_y; + bool show_vals; // show which section in Vv + RzStrBuf *echobuf; + // TODO: move into instance? + avoid unnecessary copies +} RzCons; + +#define RZ_CONS_SEARCH_CASE_SENSITIVE 0 +#define RZ_CONS_SEARCH_CASE_INSENSITIVE 1 +#define RZ_CONS_SEARCH_CASE_SMART 2 + +#define RZ_CONS_KEY_F1 0xf1 +#define RZ_CONS_KEY_F2 0xf2 +#define RZ_CONS_KEY_F3 0xf3 +#define RZ_CONS_KEY_F4 0xf4 +#define RZ_CONS_KEY_F5 0xf5 +#define RZ_CONS_KEY_F6 0xf6 +#define RZ_CONS_KEY_F7 0xf7 +#define RZ_CONS_KEY_F8 0xf8 +#define RZ_CONS_KEY_F9 0xf9 +#define RZ_CONS_KEY_F10 0xfa +#define RZ_CONS_KEY_F11 0xfb +#define RZ_CONS_KEY_F12 0xfc + +#define RZ_CONS_KEY_ESC 0x1b + +#define RZ_CONS_CLEAR_LINE "\x1b[2K\r" +#define RZ_CONS_CLEAR_SCREEN "\x1b[2J\r" +#define RZ_CONS_CLEAR_FROM_CURSOR_TO_END "\x1b[0J\r" + +#define RZ_CONS_CURSOR_SAVE "\x1b[s" +#define RZ_CONS_CURSOR_RESTORE "\x1b[u" +#define RZ_CONS_GET_CURSOR_POSITION "\x1b[6n" +#define RZ_CONS_CURSOR_UP "\x1b[A" +#define RZ_CONS_CURSOR_DOWN "\x1b[B" +#define RZ_CONS_CURSOR_RIGHT "\x1b[C" +#define RZ_CONS_CURSOR_LEFT "\x1b[D" + +#define Color_BLINK "\x1b[5m" +#define Color_INVERT "\x1b[7m" +#define Color_INVERT_RESET "\x1b[27m" +/* See 'man 4 console_codes' for details: + * "ESC c" -- Reset + * "ESC ( K" -- Select user mapping + * "ESC [ 0 m" -- Reset all display attributes + * "ESC [ J" -- Erase to the end of screen + * "ESC [ ? 25 h" -- Make cursor visible + */ +#define Color_RESET_TERMINAL "\x1b" \ + "c\x1b(K\x1b[0m\x1b[J\x1b[?25h" +#define Color_RESET "\x1b[0m" /* reset all */ +#define Color_RESET_NOBG "\x1b[27;22;24;25;28;39m" /* Reset everything except background (order is important) */ +#define Color_RESET_BG "\x1b[49m" +#define Color_RESET_ALL "\x1b[0m\x1b[49m" +#define Color_BLACK "\x1b[30m" +#define Color_BGBLACK "\x1b[40m" +#define Color_RED "\x1b[31m" +#define Color_BGRED "\x1b[41m" +#define Color_WHITE "\x1b[37m" +#define Color_BGWHITE "\x1b[47m" +#define Color_GREEN "\x1b[32m" +#define Color_BGGREEN "\x1b[42m" +#define Color_MAGENTA "\x1b[35m" +#define Color_BGMAGENTA "\x1b[45m" +#define Color_YELLOW "\x1b[33m" +#define Color_BGYELLOW "\x1b[43m" +#define Color_CYAN "\x1b[36m" +#define Color_BGCYAN "\x1b[46m" +#define Color_BLUE "\x1b[34m" +#define Color_BGBLUE "\x1b[44m" +#define Color_GRAY "\x1b[90m" +#define Color_BGGRAY "\x1b[100m" +/* bright colors */ +#define Color_BBLACK Color_GRAY +#define Color_BBGBLACK Color_BGGRAY +#define Color_BRED "\x1b[91m" +#define Color_BBGRED "\x1b[101m" +#define Color_BWHITE "\x1b[97m" +#define Color_BBGWHITE "\x1b[107m" +#define Color_BGREEN "\x1b[92m" +#define Color_BBGGREEN "\x1b[102m" +#define Color_BMAGENTA "\x1b[95m" +#define Color_BBGMAGENTA "\x1b[105m" +#define Color_BYELLOW "\x1b[93m" +#define Color_BBGYELLOW "\x1b[103m" +#define Color_BCYAN "\x1b[96m" +#define Color_BBGCYAN "\x1b[106m" +#define Color_BBLUE "\x1b[94m" +#define Color_BBGBLUE "\x1b[104m" + +#if defined(_MSC_VER) || (defined(__GNUC__) && __GNUC__ < 5) +#define RZCOLOR(a, r, g, b, bgr, bgg, bgb, id16) \ + { 0, a, r, g, b, bgr, bgg, bgb, id16 } +#else +#define RZCOLOR(a, r, g, b, bgr, bgg, bgb, id16) \ + (RzColor) { \ + 0, a, r, g, b, bgr, bgg, bgb, id16 \ + } +#endif +#define RzColor_NULL RZCOLOR(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -1) +#if __WINDOWS__ +#define RzColor_BLACK RZCOLOR(ALPHA_FG, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0) +#define RzColor_BGBLACK RZCOLOR(ALPHA_BG, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0) +#define RzColor_RED RZCOLOR(ALPHA_FG, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 1) +#define RzColor_BGRED RZCOLOR(ALPHA_BG, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 1) +#define RzColor_WHITE RZCOLOR(ALPHA_FG, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 7) +#define RzColor_BGWHITE RZCOLOR(ALPHA_BG, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 7) +#define RzColor_GREEN RZCOLOR(ALPHA_FG, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 2) +#define RzColor_BGGREEN RZCOLOR(ALPHA_BG, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 2) +#define RzColor_MAGENTA RZCOLOR(ALPHA_FG, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 5) +#define RzColor_BGMAGENTA RZCOLOR(ALPHA_BG, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 5) +#define RzColor_YELLOW RZCOLOR(ALPHA_FG, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 3) +#define RzColor_BGYELLOW RZCOLOR(ALPHA_BG, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 3) +#define RzColor_CYAN RZCOLOR(ALPHA_FG, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 6) +#define RzColor_BGCYAN RZCOLOR(ALPHA_BG, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 6) +#define RzColor_BLUE RZCOLOR(ALPHA_FG, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 4) +#define RzColor_BGBLUE RZCOLOR(ALPHA_BG, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 4) +#define RzColor_BBLACK RZCOLOR(ALPHA_FG, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 8) +#define RzColor_BBGBLACK RZCOLOR(ALPHA_BG, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 8) +#define RzColor_BRED RZCOLOR(ALPHA_FG, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 9) +#define RzColor_BBGRED RZCOLOR(ALPHA_BG, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 9) +#define RzColor_BWHITE RZCOLOR(ALPHA_FG, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 15) +#define RzColor_BBGWHITE RZCOLOR(ALPHA_BG, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 15) +#define RzColor_BGREEN RZCOLOR(ALPHA_FG, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 10) +#define RzColor_BBGGREEN RZCOLOR(ALPHA_BG, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 10) +#define RzColor_BMAGENTA RZCOLOR(ALPHA_FG, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 13) +#define RzColor_BBGMAGENTA RZCOLOR(ALPHA_BG, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 13) +#define RzColor_BYELLOW RZCOLOR(ALPHA_FG, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 11) +#define RzColor_BBGYELLOW RZCOLOR(ALPHA_BG, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 11) +#define RzColor_BCYAN RZCOLOR(ALPHA_FG, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 14) +#define RzColor_BBGCYAN RZCOLOR(ALPHA_BG, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 14) +#define RzColor_BBLUE RZCOLOR(ALPHA_FG, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 12) +#define RzColor_BBGBLUE RZCOLOR(ALPHA_BG, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 12) +#else +// Campbell (https://devblogs.microsoft.com/commandline/updating-the-windows-console-colors/). +// Not used on Windows since cmd.exe doesn't support bold (needed for easier +// differentiation between normal and bright color text for some colors). +#define RzColor_BLACK RZCOLOR(ALPHA_FG, 12, 12, 12, 0x00, 0x00, 0x00, 0) +#define RzColor_BGBLACK RZCOLOR(ALPHA_BG, 12, 12, 12, 0x00, 0x00, 0x00, 0) +#define RzColor_RED RZCOLOR(ALPHA_FG, 197, 15, 31, 0x00, 0x00, 0x00, 1) +#define RzColor_BGRED RZCOLOR(ALPHA_BG, 197, 15, 31, 0x00, 0x00, 0x00, 1) +#define RzColor_WHITE RZCOLOR(ALPHA_FG, 204, 204, 204, 0x00, 0x00, 0x00, 7) +#define RzColor_BGWHITE RZCOLOR(ALPHA_BG, 204, 204, 204, 0x00, 0x00, 0x00, 7) +#define RzColor_GREEN RZCOLOR(ALPHA_FG, 19, 161, 14, 0x00, 0x00, 0x00, 2) +#define RzColor_BGGREEN RZCOLOR(ALPHA_BG, 19, 161, 14, 0x00, 0x00, 0x00, 2) +#define RzColor_MAGENTA RZCOLOR(ALPHA_FG, 136, 23, 152, 0x00, 0x00, 0x00, 5) +#define RzColor_BGMAGENTA RZCOLOR(ALPHA_BG, 136, 23, 152, 0x00, 0x00, 0x00, 5) +#define RzColor_YELLOW RZCOLOR(ALPHA_FG, 193, 156, 0, 0x00, 0x00, 0x00, 3) +#define RzColor_BGYELLOW RZCOLOR(ALPHA_BG, 193, 156, 0, 0x00, 0x00, 0x00, 3) +#define RzColor_CYAN RZCOLOR(ALPHA_FG, 58, 150, 221, 0x00, 0x00, 0x00, 6) +#define RzColor_BGCYAN RZCOLOR(ALPHA_BG, 58, 150, 221, 0x00, 0x00, 0x00, 6) +#define RzColor_BLUE RZCOLOR(ALPHA_FG, 0, 55, 218, 0x00, 0x00, 0x00, 4) +#define RzColor_BGBLUE RZCOLOR(ALPHA_BG, 0, 55, 218, 0x00, 0x00, 0x00, 4) +#define RzColor_BBLACK RZCOLOR(ALPHA_FG, 118, 118, 118, 0x00, 0x00, 0x00, 8) +#define RzColor_BBGBLACK RZCOLOR(ALPHA_BG, 118, 118, 118, 0x00, 0x00, 0x00, 8) +#define RzColor_BRED RZCOLOR(ALPHA_FG, 231, 72, 86, 0x00, 0x00, 0x00, 9) +#define RzColor_BBGRED RZCOLOR(ALPHA_BG, 231, 72, 86, 0x00, 0x00, 0x00, 9) +#define RzColor_BWHITE RZCOLOR(ALPHA_FG, 242, 242, 242, 0x00, 0x00, 0x00, 15) +#define RzColor_BBGWHITE RZCOLOR(ALPHA_BG, 242, 242, 242, 0x00, 0x00, 0x00, 15) +#define RzColor_BGREEN RZCOLOR(ALPHA_FG, 22, 198, 12, 0x00, 0x00, 0x00, 10) +#define RzColor_BBGGREEN RZCOLOR(ALPHA_BG, 22, 198, 12, 0x00, 0x00, 0x00, 10) +#define RzColor_BMAGENTA RZCOLOR(ALPHA_FG, 180, 0, 158, 0x00, 0x00, 0x00, 13) +#define RzColor_BBGMAGENTA RZCOLOR(ALPHA_BG, 180, 0, 158, 0x00, 0x00, 0x00, 13) +#define RzColor_BYELLOW RZCOLOR(ALPHA_FG, 249, 241, 165, 0x00, 0x00, 0x00, 11) +#define RzColor_BBGYELLOW RZCOLOR(ALPHA_BG, 249, 241, 165, 0x00, 0x00, 0x00, 11) +#define RzColor_BCYAN RZCOLOR(ALPHA_FG, 97, 214, 214, 0x00, 0x00, 0x00, 14) +#define RzColor_BBGCYAN RZCOLOR(ALPHA_BG, 97, 214, 214, 0x00, 0x00, 0x00, 14) +#define RzColor_BBLUE RZCOLOR(ALPHA_FG, 59, 120, 255, 0x00, 0x00, 0x00, 12) +#define RzColor_BBGBLUE RZCOLOR(ALPHA_BG, 59, 120, 255, 0x00, 0x00, 0x00, 12) +#endif +#define RzColor_GRAY RzColor_BBLACK +#define RzColor_BGGRAY RzColor_BBGBLACK + +#define Colors_PLAIN \ + { \ + Color_BLACK, Color_RED, Color_WHITE, \ + Color_GREEN, Color_MAGENTA, Color_YELLOW, \ + Color_CYAN, Color_BLUE, Color_GRAY \ + } + +enum { + PAL_PROMPT = 0, + PAL_ADDRESS, + PAL_DEFAULT, + PAL_CHANGED, + PAL_JUMP, + PAL_CALL, + PAL_PUSH, + PAL_TRAP, + PAL_CMP, + PAL_RET, + PAL_NOP, + PAL_METADATA, + PAL_HEADER, + PAL_PRINTABLE, + PAL_LINES0, + PAL_LINES1, + PAL_LINES2, + PAL_00, + PAL_7F, + PAL_FF +}; + +/* canvas line colors */ +enum { + LINE_NONE = 0, + LINE_TRUE, + LINE_FALSE, + LINE_UNCJMP, + LINE_NOSYM_VERT, + LINE_NOSYM_HORIZ +}; + +typedef enum { + INSERT_MODE = 'i', + CONTROL_MODE = 'c' +} RViMode; + +#define DOT_STYLE_NORMAL 0 +#define DOT_STYLE_CONDITIONAL 1 +#define DOT_STYLE_BACKEDGE 2 + +typedef struct rz_cons_canvas_line_style_t { + int color; + int symbol; + int dot_style; +} RzCanvasLineStyle; + +// UTF-8 symbols indexes +#define LINE_VERT 0 +#define LINE_CROSS 1 +#define LINE_HORIZ 2 +#define LINE_UP 3 +#define CORNER_TL 6 +#define CORNER_BR 4 +#define CORNER_BL 5 +#define CORNER_TR 6 +#define ARROW_RIGHT 8 +#define ARROW_LEFT 9 +#define SELF_LOOP 10 + +typedef struct rz_histogram_options_t { + bool unicode; //<< Use Unicode characters instead of ASCII + bool thinline; //<< Use thin lines instead of block lines + bool ruler; //<< Show ruler + bool legend; //<< Show axes and legend + bool offset; //<< Show offsets + ut64 offpos; //<< Starting offset value + bool cursor; //<< Show cursor position + ut64 curpos; //<< Cursor position + bool color; //<< Use colors + RzConsPrintablePalette *pal; //<< Colors palette if color is enabled +} RzHistogramOptions; + +typedef struct rz_bar_options_t { + bool unicode; //<< Use Unicode characters instead of ASCII + bool thinline; //<< Use thin lines instead of block lines + bool legend; //<< Show axes and legend + bool offset; //<< Show offsets + ut64 offpos; //<< Starting offset value + bool cursor; //<< Show cursor position + ut64 curpos; //<< Cursor position + bool color; //<< Use colors +} RzBarOptions; + +typedef struct rz_histogram_interactive_t { + RzConsCanvas *can; + + int barnumber; + int size; + int zoom; + int movspeed; + + int x, y; + int w, h; + + RzHistogramOptions *opts; +} RzHistogramInteractive; + +#ifdef RZ_API +RZ_API RzConsCanvas *rz_cons_canvas_new(int w, int h); +RZ_API void rz_cons_canvas_free(RzConsCanvas *c); +RZ_API void rz_cons_canvas_clear(RzConsCanvas *c); +RZ_API void rz_cons_canvas_print(RzConsCanvas *c); +RZ_API void rz_cons_canvas_print_region(RzConsCanvas *c); +RZ_API RZ_OWN char *rz_cons_canvas_to_string(RzConsCanvas *c); +RZ_API void rz_cons_canvas_write(RzConsCanvas *c, const char *_s); +RZ_API bool rz_cons_canvas_gotoxy(RzConsCanvas *c, int x, int y); +RZ_API void rz_cons_canvas_box(RzConsCanvas *c, int x, int y, int w, int h, const char *color); +RZ_API void rz_cons_canvas_line(RzConsCanvas *c, int x, int y, int x2, int y2, RzCanvasLineStyle *style); +RZ_API void rz_cons_canvas_line_diagonal(RzConsCanvas *c, int x, int y, int x2, int y2, RzCanvasLineStyle *style); +RZ_API void rz_cons_canvas_line_square(RzConsCanvas *c, int x, int y, int x2, int y2, RzCanvasLineStyle *style); +RZ_API int rz_cons_canvas_resize(RzConsCanvas *c, int w, int h); +RZ_API void rz_cons_canvas_fill(RzConsCanvas *c, int x, int y, int w, int h, char ch); +RZ_API void rz_cons_canvas_line_square_defined(RzConsCanvas *c, int x, int y, int x2, int y2, RzCanvasLineStyle *style, int bendpoint, int isvert); +RZ_API void rz_cons_canvas_line_back_edge(RzConsCanvas *c, int x, int y, int x2, int y2, RzCanvasLineStyle *style, int ybendpoint1, int xbendpoint, int ybendpoint2, int isvert); +RZ_API RzCons *rz_cons_new(void); +RZ_API RzCons *rz_cons_singleton(void); +RZ_API RzCons *rz_cons_free(void); +RZ_API char *rz_cons_lastline(int *size); +RZ_API char *rz_cons_lastline_utf8_ansi_len(int *len); +RZ_API void rz_cons_set_click(int x, int y, MouseEvent event); +RZ_API bool rz_cons_get_click(int *x, int *y); + +typedef void (*RzConsBreak)(void *); +RZ_API bool rz_cons_is_breaked(void); +RZ_API bool rz_cons_is_interactive(void); +RZ_API bool rz_cons_default_context_is_interactive(void); +RZ_API void *rz_cons_sleep_begin(void); +RZ_API void rz_cons_sleep_end(void *user); + +/* ^C */ +RZ_API void rz_cons_break_push(RzConsBreak cb, void *user); +RZ_API void rz_cons_break_pop(void); +RZ_API void rz_cons_break_clear(void); +RZ_API void rz_cons_breakword(RZ_NULLABLE const char *s); +RZ_API void rz_cons_break_end(void); +RZ_API void rz_cons_break_timeout(int timeout); + +/* pipe */ +typedef struct rz_cons_pipe_t RzConsPipe; +RZ_API RZ_OWN RzConsPipe *rz_cons_pipe_open(RZ_NONNULL const char *file, int old_fd, bool append); +RZ_API void rz_cons_pipe_close(RZ_NULLABLE RzConsPipe *cpipe); + +#if __WINDOWS__ +RZ_API RzVirtTermMode rz_cons_detect_vt_mode(void); +RZ_API void rz_cons_w32_clear(void); +RZ_API void rz_cons_w32_gotoxy(int fd, int x, int y); +RZ_API int rz_cons_w32_print(const char *ptr, int len, bool vmode); +RZ_API int rz_cons_win_printf(bool vmode, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); +RZ_API int rz_cons_win_eprintf(bool vmode, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); +RZ_API int rz_cons_win_vhprintf(unsigned long hdl, bool vmode, const char *fmt, va_list ap); +#endif + +RZ_API void rz_cons_push(void); +RZ_API void rz_cons_pop(void); +RZ_API RzConsContext *rz_cons_context_new(RZ_NULLABLE RzConsContext *parent); +RZ_API void rz_cons_context_free(RzConsContext *context); +RZ_API void rz_cons_context_load(RzConsContext *context); +RZ_API void rz_cons_context_reset(void); +RZ_API bool rz_cons_context_is_main(void); +RZ_API void rz_cons_context_break(RzConsContext *context); +RZ_API void rz_cons_context_break_push(RzConsContext *context, RzConsBreak cb, void *user, bool sig); +RZ_API void rz_cons_context_break_pop(RzConsContext *context, bool sig); + +/* control */ +RZ_API void rz_cons_reset(void); +RZ_API void rz_cons_reset_colors(void); +RZ_API void rz_cons_goto_origin_reset(void); +RZ_API void rz_cons_echo(const char *msg); +RZ_API void rz_cons_zero(void); +RZ_API void rz_cons_highlight(const char *word); +RZ_API void rz_cons_clear(void); +RZ_API void rz_cons_clear_buffer(void); +RZ_API void rz_cons_clear00(void); +RZ_API void rz_cons_clear_line(FILE *stream); +RZ_API void rz_cons_fill_line(void); +RZ_API void rz_cons_gotoxy(int x, int y); +RZ_API int rz_cons_get_cur_line(void); +RZ_API void rz_cons_show_cursor(int cursor); +RZ_API char *rz_cons_swap_ground(const char *col); +RZ_API bool rz_cons_drop(int n); +RZ_API void rz_cons_chop(void); +RZ_API void rz_cons_set_raw(bool b); +RZ_API void rz_cons_set_interactive(bool b); +RZ_API void rz_cons_set_last_interactive(void); +RZ_API void rz_cons_set_utf8(bool b); +RZ_API void rz_cons_grep(const char *grep); + +/* output */ +RZ_API int rz_cons_printf(const char *format, ...) RZ_PRINTF_CHECK(1, 2); +RZ_API void rz_cons_printf_list(const char *format, va_list ap); +RZ_API void rz_cons_strcat(const char *str); +RZ_API void rz_cons_strcat_at(const char *str, int x, char y, int w, int h); +#define rz_cons_print(x) rz_cons_strcat(x) +RZ_API void rz_cons_println(const char *str); + +RZ_API void rz_cons_strcat_justify(const char *str, int j, char c); +RZ_API int rz_cons_memcat(const char *str, int len); +RZ_API void rz_cons_newline(void); +RZ_API void rz_cons_filter(void); +RZ_API void rz_cons_flush(void); +RZ_API void rz_cons_set_flush(bool flush); +RZ_API void rz_cons_last(void); +RZ_API int rz_cons_less_str(const char *str, const char *exitkeys); +RZ_API void rz_cons_less(void); +RZ_API void rz_cons_memset(char ch, int len); +RZ_API void rz_cons_visual_flush(void); +RZ_API void rz_cons_visual_write(char *buffer); +RZ_API bool rz_cons_is_utf8(void); +RZ_API void rz_cons_cmd_help(const char *help[], bool use_color); + +/* input */ +RZ_API int rz_cons_controlz(int ch); +RZ_API int rz_cons_readchar(void); +RZ_API bool rz_cons_readbuffer_readchar(char *ch); +RZ_API bool rz_cons_readpush(const char *str, int len); +RZ_API void rz_cons_readflush(void); +RZ_API void rz_cons_switchbuf(bool active); +RZ_API int rz_cons_readchar_timeout(ut32 usec); +RZ_API int rz_cons_any_key(const char *msg); +RZ_API int rz_cons_eof(void); + +RZ_API int rz_cons_pal_set(const char *key, const char *val); +RZ_API void rz_cons_pal_update_event(void); +RZ_API void rz_cons_pal_free(RzConsContext *ctx); +RZ_API void rz_cons_pal_init(RzConsContext *ctx); +RZ_API void rz_cons_pal_copy(RzConsContext *dst, RzConsContext *src); +RZ_API char *rz_cons_pal_parse(const char *str, RzColor *outcol); +RZ_API void rz_cons_pal_random(void); +RZ_API RzColor rz_cons_pal_get(const char *key); +RZ_API RzColor rz_cons_pal_get_i(int index); +RZ_API const char *rz_cons_pal_get_name(int index); +RZ_API int rz_cons_pal_len(void); +RZ_API int rz_cons_rgb_parse(const char *p, ut8 *r, ut8 *g, ut8 *b, ut8 *a); +RZ_API char *rz_cons_rgb_tostring(ut8 r, ut8 g, ut8 b); +RZ_API void rz_cons_pal_list_as_json(RZ_NONNULL PJ *pj); +RZ_API void rz_cons_pal_list_as_css(RZ_NULLABLE const char *name_prefix); +RZ_API void rz_cons_pal_list_visual(void); +RZ_API void rz_cons_pal_show(void); +RZ_API int rz_cons_get_size(int *rows); +RZ_API bool rz_cons_isatty(void); +RZ_API int rz_cons_get_cursor(RZ_NONNULL int *rows); +RZ_API int rz_cons_arrow_to_hjkl(int ch); +RZ_API char *rz_cons_html_filter(const char *ptr, int *newlen); +RZ_API char *rz_cons_rainbow_get(int idx, int last, bool bg); +RZ_API void rz_cons_rainbow_free(RzConsContext *ctx); +RZ_API void rz_cons_rainbow_new(RzConsContext *ctx, int sz); + +RZ_API int rz_cons_fgets(char *buf, int len, int argc, const char **argv); +RZ_API char *rz_cons_hud(RzList /**/ *list, const char *prompt); +RZ_API char *rz_cons_hud_path(const char *path, int dir); +RZ_API char *rz_cons_hud_string(const char *s); +RZ_API char *rz_cons_hud_file(const char *f); + +RZ_API const char *rz_cons_get_buffer(void); +RZ_API RZ_OWN char *rz_cons_get_buffer_dup(void); +RZ_API int rz_cons_get_buffer_len(void); +RZ_API void rz_cons_grep_help(void); +RZ_API void rz_cons_grep_parsecmd(char *cmd, const char *quotestr); +RZ_API char *rz_cons_grep_strip(char *cmd, const char *quotestr); +RZ_API void rz_cons_grep_process(RZ_OWN char *grep); +RZ_API int rz_cons_grep_line(char *buf, int len); // must be static +RZ_API void rz_cons_grepbuf(void); + +RZ_API void rz_cons_rgb_init(void); +RZ_API char *rz_cons_rgb_str_mode(RzConsColorMode mode, char *outstr, size_t sz, const RzColor *rcolor); +RZ_API char *rz_cons_rgb_str(char *outstr, size_t sz, const RzColor *rcolor); +RZ_API char *rz_cons_rgb_str_off(char *outstr, size_t sz, ut64 off); +RZ_API void rz_cons_color(int fg, int r, int g, int b); + +RZ_API RzColor rz_cons_color_random(ut8 alpha); +RZ_API void rz_cons_invert(int set, int color); +RZ_API bool rz_cons_yesno(int def, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); +RZ_API char *rz_cons_input(const char *msg); +RZ_API bool rz_cons_set_cup(bool enable); +RZ_API void rz_cons_column(int c); +RZ_API int rz_cons_get_column(void); +RZ_API void rz_cons_message(RZ_NONNULL const char *msg); +RZ_API void rz_cons_set_title(const char *str); +RZ_API bool rz_cons_enable_mouse(const bool enable); +RZ_API void rz_cons_enable_highlight(const bool enable); +RZ_API void rz_cons_bind(RzConsBind *bind); +RZ_API const char *rz_cons_get_rune(const ut8 ch); + +/* Histograms */ +RZ_API RZ_OWN RzStrBuf *rz_histogram_horizontal(RZ_NONNULL RzHistogramOptions *opts, RZ_NONNULL const ut8 *data, ut32 width, ut32 height); +RZ_API RZ_OWN RzStrBuf *rz_histogram_vertical(RZ_NONNULL RzHistogramOptions *opts, RZ_NONNULL const ut8 *data, int width, int step); +RZ_API RZ_OWN RzStrBuf *rz_histogram_interactive_horizontal(RZ_NONNULL RzHistogramInteractive *hist, const unsigned char *data); +RZ_API RzHistogramOptions *rz_histogram_options_new(); +RZ_API void rz_histogram_options_free(RzHistogramOptions *histops); +RZ_API RzHistogramInteractive *rz_histogram_interactive_new(RzConsCanvas *can, RzHistogramOptions *opts); +RZ_API void rz_histogram_interactive_free(RzHistogramInteractive *hist); +RZ_API void rz_histogram_interactive_zoom_in(RzHistogramInteractive *hist); +RZ_API void rz_histogram_interactive_zoom_out(RzHistogramInteractive *hist); +#endif + +/* Bars */ +RZ_API RZ_OWN RzStrBuf *rz_progressbar(RZ_NONNULL RzBarOptions *opts, int pc, int width); +RZ_API RZ_OWN RzStrBuf *rz_rangebar(RZ_NONNULL RzBarOptions *opts, ut64 startA, ut64 endA, ut64 min, + ut64 max, int width); + +/* rz_line */ +#define RZ_LINE_BUFSIZE 4096 +#define RZ_LINE_HISTSIZE 256 +#define RZ_LINE_UNDOSIZE 512 + +#define RZ_EDGES_X_INC 4 + +#define RZ_SELWIDGET_MAXH 15 +#define RZ_SELWIDGET_MAXW 30 +#define RZ_SELWIDGET_DIR_UP 0 +#define RZ_SELWIDGET_DIR_DOWN 1 + +typedef struct rz_selection_widget_t { + const char **options; + int options_len; + int selection; + int w, h; + int scroll; + bool complete_common; + bool direction; +} RzSelWidget; + +typedef struct rz_line_hist_t { + char **data; + char *match; + int size; + int index; + int top; + int autosave; + bool do_setup_match; +} RzLineHistory; + +typedef struct rz_line_buffer_t { + char data[RZ_LINE_BUFSIZE]; + int index; + int length; +} RzLineBuffer; + +typedef struct rz_hud_t { + int current_entry_n; + int top_entry_n; + char activate; + int vi; +} RzLineHud; + +typedef struct rz_line_t RzLine; // forward declaration +typedef struct rz_line_comp_t RzLineCompletion; + +typedef enum { RZ_LINE_PROMPT_DEFAULT, + RZ_LINE_PROMPT_OFFSET, + RZ_LINE_PROMPT_FILE } RzLinePromptType; + +typedef int (*RzLineCompletionCb)(RzLineCompletion *completion, RzLineBuffer *buf, RzLinePromptType prompt_type, void *user); + +struct rz_line_comp_t { + bool opt; + size_t args_limit; + bool quit; + RzPVector /**/ args; + RzLineCompletionCb run; + void *run_user; +}; + +typedef struct rz_line_ns_completion_t RzLineNSCompletion; + +/** + * Result returned by a completion callback function. It includes all the + * information required to provide meaningful autocompletion suggestion to the + * user. + */ +typedef struct rz_line_ns_completion_result_t { + RzPVector /**/ options; ///< Vector of options that can be used for autocompletion + HtPP *options_ht; ///< Hash table to keep track of duplicated autocompletion suggestions + size_t start; ///< First byte that was considered for autocompletion. Everything before this will be left intact. + size_t end; ///< Last byte that was considered for autocompletion. Everything after this will be left intact. + const char *end_string; ///< String to place after the only option available is autocompleted. By default a space is used. +} RzLineNSCompletionResult; + +/** + * Callback that analyze the current user input and provides options for autocompletion. + * + * \param buf RLineBuffer pointer, containing all the info about the current user input + * \param prompt_type Type of prompt used + * \param user User data that was previously setup in \p RzLineNSCompletion + */ +typedef RzLineNSCompletionResult *(*RzLineNSCompletionCb)(RzLineBuffer *buf, RzLinePromptType prompt_type, void *user); + +/** + * Autocompletion callback data. + */ +struct rz_line_ns_completion_t { + RzLineNSCompletionCb run; ///< Callback function that is called when autocompletion is required. (e.g. TAB is pressed) + void *run_user; ///< User data that can be passed to the callback +}; + +typedef char *(*RzLineEditorCb)(void *core, const char *str); +typedef int (*RzLineHistoryUpCb)(RzLine *line); +typedef int (*RzLineHistoryDownCb)(RzLine *line); + +typedef struct rz_line_undo_entry_t RzLineUndoEntry; + +struct rz_line_t { + RzLineCompletion completion; + RzLineNSCompletion ns_completion; + RzLineBuffer buffer; + RzLineHistory history; + RzVector /**/ *undo_vec; + RzSelWidget *sel_widget; + /* callbacks */ + RzLineHistoryUpCb cb_history_up; + RzLineHistoryDownCb cb_history_down; + RzLineEditorCb cb_editor; + // RzLineFunctionKeyCb cb_fkey; + RzConsFunctionKey cb_fkey; + /* state , TODO: use more bool */ + int gcomp; + int gcomp_idx; + int echo; + int has_echo; + char *prompt; + RzList /**/ *kill_ring; + int kill_ring_ptr; + bool yank_flag; + int undo_cursor; + bool undo_continue; + char *clipboard; + int disable; + void *user; + int (*hist_up)(void *user); + int (*hist_down)(void *user); + char *contents; + bool zerosep; + bool enable_vi_mode; + int vi_mode; + bool prompt_mode; + RzLinePromptType prompt_type; + int offset_hist_index; + int file_hist_index; + RzLineHud *hud; + RzList /**/ *sdbshell_hist; + RzListIter /**/ *sdbshell_hist_iter; + RzVirtTermMode vtmode; +}; /* RzLine */ + +#ifdef RZ_API + +RZ_API RZ_OWN RzLine *rz_line_new(void); +RZ_API void rz_line_free(RZ_NULLABLE RzLine *line); +RZ_API RZ_OWN char *rz_line_get_prompt(RZ_NONNULL RzLine *line); +RZ_API void rz_line_set_prompt(RZ_NONNULL RzLine *line, RZ_NONNULL const char *prompt); +RZ_API bool rz_line_dietline_init(RZ_NONNULL RzLine *line); +RZ_API void rz_line_clipboard_push(RZ_NONNULL RzLine *line, RZ_NONNULL const char *str); +RZ_API void rz_line_hist_free(RZ_NULLABLE RzLine *line); +RZ_API void rz_line_autocomplete(RZ_NONNULL RzLine *line); + +typedef int(RzLineReadCallback)(void *user, const char *line); +RZ_API const char *rz_line_readline(RZ_NONNULL RzLine *line); +RZ_API const char *rz_line_readline_cb(RZ_NONNULL RzLine *line, RzLineReadCallback cb, void *user); + +RZ_API bool rz_line_hist_load(RZ_NONNULL RzLine *line, RZ_NONNULL const char *file); +RZ_API bool rz_line_hist_add(RZ_NONNULL RzLine *line, RZ_NONNULL const char *str); +RZ_API bool rz_line_hist_save(RZ_NONNULL RzLine *line, const char *file); +RZ_API int rz_line_hist_list(RZ_NONNULL RzLine *line); +RZ_API const char *rz_line_hist_get(RZ_NONNULL RzLine *line, int n); + +RZ_API int rz_line_set_hist_callback(RZ_NONNULL RzLine *line, RzLineHistoryUpCb cb_up, RzLineHistoryDownCb cb_down); +RZ_API int rz_line_hist_cmd_up(RZ_NONNULL RzLine *line); +RZ_API int rz_line_hist_cmd_down(RZ_NONNULL RzLine *line); + +RZ_API void rz_line_completion_init(RzLineCompletion *completion, size_t args_limit); +RZ_API void rz_line_completion_fini(RzLineCompletion *completion); +RZ_API void rz_line_completion_push(RzLineCompletion *completion, const char *str); +RZ_API void rz_line_completion_set(RzLineCompletion *completion, int argc, const char **argv); +RZ_API void rz_line_completion_clear(RzLineCompletion *completion); + +RZ_API RzLineNSCompletionResult *rz_line_ns_completion_result_new(size_t start, size_t end, const char *end_string); +RZ_API void rz_line_ns_completion_result_free(RzLineNSCompletionResult *res); +RZ_API void rz_line_ns_completion_result_add(RzLineNSCompletionResult *res, const char *option); +RZ_API void rz_line_ns_completion_result_propose(RzLineNSCompletionResult *res, const char *option, const char *cur, size_t cur_len); + +RZ_API RZ_OWN char *rz_cons_prompt(RZ_NONNULL const char *str, RZ_NULLABLE const char *txt); + +#define RZ_CONS_INVERT(x, y) (y ? (x ? Color_INVERT : Color_INVERT_RESET) : (x ? "[" : "]")) + +#endif + +#ifdef __sun +static inline void cfmakeraw(struct termios *tm) { + tm->c_cflag &= ~(CSIZE | PARENB); + tm->c_cflag |= CS8; + tm->c_iflag &= ~(IMAXBEL | IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); + tm->c_oflag &= ~OPOST; + tm->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); +} +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/dest/include/librz/rz_constructor.h b/dest/include/librz/rz_constructor.h new file mode 100644 index 00000000000..9903757b79e --- /dev/null +++ b/dest/include/librz/rz_constructor.h @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +// SPDX-FileCopyrightText: 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + +// Taken from https://github.com/GNOME/glib/blob/main/glib/gconstructor.h and adapted to Rizin + +#ifndef __RZ_CONSTRUCTOR_H__ +#define __RZ_CONSTRUCTOR_H__ + +/* + If RZ_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and + destructors, in a usable way, including e.g. on library unload. If not you're on + your own. + Some compilers need #pragma to handle this, which does not work with macros, + so the way you need to use this is (for constructors): + #ifdef RZ_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA + #pragma RZ_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor) + #endif + RZ_DEFINE_CONSTRUCTOR(my_constructor) + static void my_constructor(void) { + ... + } +*/ + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) + +#define RZ_HAS_CONSTRUCTORS 1 + +#define RZ_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func(void); +#define RZ_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func(void); + +#elif defined(_MSC_VER) && (_MSC_VER >= 1500) +/* Visual studio 2008 and later has _Pragma */ + +#include + +#define RZ_HAS_CONSTRUCTORS 1 + +/* We do some weird things to avoid the constructors being optimized + * away on VS2015 if WholeProgramOptimization is enabled. First we + * make a reference to the array from the wrapper to make sure its + * references. Then we use a pragma to make sure the wrapper function + * symbol is always included at the link stage. Also, the symbols + * need to be extern (but not dllexport), even though they are not + * really used from another object file. + */ + +/* We need to account for differences between the mangling of symbols + * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed + * with an underscore but symbols on x64/ARM/ARM64 are not. + */ +#ifdef _M_IX86 +#define RZ_MSVC_SYMBOL_PREFIX "_" +#else +#define RZ_MSVC_SYMBOL_PREFIX "" +#endif + +#define RZ_DEFINE_CONSTRUCTOR(_func) RZ_MSVC_CTOR(_func, RZ_MSVC_SYMBOL_PREFIX) +#define RZ_DEFINE_DESTRUCTOR(_func) RZ_MSVC_DTOR(_func, RZ_MSVC_SYMBOL_PREFIX) + +#define RZ_MSVC_CTOR(_func, _sym_prefix) \ + static void _func(void); \ + extern int (*_array##_func)(void); \ + int _func##_wrapper(void) { \ + _func(); \ + char *_func##_var = rz_str_dup(""); \ + free(_func##_var); \ + return 0; \ + } \ + __pragma(comment(linker, "/include:" _sym_prefix #_func "_wrapper")) \ + __pragma(section(".CRT$XCU", read)) __declspec(allocate(".CRT$XCU")) int (*_array##_func)(void) = _func##_wrapper; + +#define RZ_MSVC_DTOR(_func, _sym_prefix) \ + static void _func(void); \ + extern int (*_array##_func)(void); \ + int _func##_constructor(void) { \ + atexit(_func); \ + char *_func##_var = rz_str_dup(""); \ + free(_func##_var); \ + return 0; \ + } \ + __pragma(comment(linker, "/include:" _sym_prefix #_func "_constructor")) \ + __pragma(section(".CRT$XCU", read)) __declspec(allocate(".CRT$XCU")) int (*_array##_func)(void) = _func##_constructor; + +#elif defined(_MSC_VER) + +#define RZ_HAS_CONSTRUCTORS 1 + +/* Pre Visual studio 2008 must use #pragma section */ +#define RZ_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1 +#define RZ_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1 + +#define RZ_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \ + section(".CRT$XCU", read) +#define RZ_DEFINE_CONSTRUCTOR(_func) \ + static void _func(void); \ + static int _func##_wrapper(void) { \ + _func(); \ + return 0; \ + } \ + __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func##_wrapper; + +#define RZ_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \ + section(".CRT$XCU", read) +#define RZ_DEFINE_DESTRUCTOR(_func) \ + static void _func(void); \ + static int _func##_constructor(void) { \ + atexit(_func); \ + return 0; \ + } \ + __declspec(allocate(".CRT$XCU")) static int (*_array##_func)(void) = _func##_constructor; + +#elif defined(__SUNPRO_C) + +/* This is not tested, but i believe it should work, based on: + * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c + */ + +#define RZ_HAS_CONSTRUCTORS 1 + +#define RZ_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1 +#define RZ_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1 + +#define RZ_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \ + init(_func) +#define RZ_DEFINE_CONSTRUCTOR(_func) \ + static void _func(void); + +#define RZ_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \ + fini(_func) +#define RZ_DEFINE_DESTRUCTOR(_func) \ + static void _func(void); + +#else + +/* constructors not supported for this compiler */ + +#endif + +#endif /* __RZ_CONSTRUCTOR_H__ */ diff --git a/dest/include/librz/rz_core.h b/dest/include/librz/rz_core.h new file mode 100644 index 00000000000..6a37c00476d --- /dev/null +++ b/dest/include/librz/rz_core.h @@ -0,0 +1,1445 @@ +// SPDX-FileCopyrightText: 2009-2021 pancake +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_CORE_H +#define RZ_CORE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +RZ_LIB_VERSION_HEADER(rz_core); + +#define RZ_CORE_CMD_OK 0 +#define RZ_CORE_CMD_INVALID -1 +#define RZ_CORE_CMD_EXIT -2 + +#define RZ_CORE_BLOCKSIZE 0x100 +#define RZ_CORE_BLOCKSIZE_MAX 0x3200000 /* 32MB */ + +#define RZ_FLAGS_FS_CLASSES "classes" +#define RZ_FLAGS_FS_FUNCTIONS "functions" +#define RZ_FLAGS_FS_IMPORTS "imports" +#define RZ_FLAGS_FS_RELOCS "relocs" +#define RZ_FLAGS_FS_REGISTERS "registers" +#define RZ_FLAGS_FS_RESOURCES "resources" +#define RZ_FLAGS_FS_SECTIONS "sections" +#define RZ_FLAGS_FS_SEGMENTS "segments" +#define RZ_FLAGS_FS_SIGNS "sign" +#define RZ_FLAGS_FS_STRINGS "strings" +#define RZ_FLAGS_FS_SYMBOLS "symbols" +#define RZ_FLAGS_FS_SYMBOLS_SECTIONS "symbols.sections" +#define RZ_FLAGS_FS_SYSCALLS "syscalls" +#define RZ_FLAGS_FS_MMIO_REGISTERS "registers.mmio" +#define RZ_FLAGS_FS_MMIO_REGISTERS_EXTENDED "registers.extended" +#define RZ_FLAGS_FS_PLATFORM_PORTS "platform.ports" +#define RZ_FLAGS_FS_GLOBALS "globals" +#define RZ_FLAGS_FS_DEBUG_MAPS "maps" +#define RZ_FLAGS_FS_POINTERS "pointers" + +/// +#define RZ_CONS_COLOR_DEF(x, def) ((core->cons && core->cons->context->pal.x) ? core->cons->context->pal.x : def) +#define RZ_CONS_COLOR(x) RZ_CONS_COLOR_DEF(x, "") + +/* rtr */ +#define RTR_PROTOCOL_RAP 0 +#define RTR_PROTOCOL_TCP 1 +#define RTR_PROTOCOL_UDP 2 +#define RTR_PROTOCOL_HTTP 3 +#define RTR_PROTOCOL_UNIX 4 + +#define RTR_MAX_HOSTS 255 + +typedef enum { + RZ_CORE_WRITE_OP_BYTESWAP2, ///< Swap the endianess of 2-bytes values + RZ_CORE_WRITE_OP_BYTESWAP4, ///< Swap the endianess of 4-bytes values + RZ_CORE_WRITE_OP_BYTESWAP8, ///< Swap the endianess of 8-bytes values + RZ_CORE_WRITE_OP_ADD, ///< Write the addition of existing byte and argument value + RZ_CORE_WRITE_OP_SUB, ///< Write the subtraction of existing byte and argument value + RZ_CORE_WRITE_OP_DIV, ///< Write the division of existing byte and argument value + RZ_CORE_WRITE_OP_MUL, ///< Write the multiplication of existing byte and argument value + RZ_CORE_WRITE_OP_AND, ///< Write the bitwise-and of existing byte and argument value + RZ_CORE_WRITE_OP_OR, ///< Write the bitwise-or of existing byte and argument value + RZ_CORE_WRITE_OP_XOR, ///< Write the bitwise-xor of existing byte and argument value + RZ_CORE_WRITE_OP_SHIFT_LEFT, ///< Write the shift left of existing byte by argument value + RZ_CORE_WRITE_OP_SHIFT_RIGHT, ///< Write the shift right of existing byte and argument value +} RzCoreWriteOp; + +typedef bool (*RzCorePluginCallback)(RzCore *core); + +typedef struct rz_core_plugin_t { + const char *name; + const char *desc; + const char *license; + const char *author; + const char *version; + RzCorePluginCallback init; ///< Is called when the plugin is loaded by rizin + RzCorePluginCallback fini; ///< Is called when the plugin is unloaded by rizin + RzCorePluginCallback analysis; ///< Is called when automatic analysis is performed. +} RzCorePlugin; + +typedef struct rz_core_rtr_host_t RzCoreRtrHost; + +typedef enum { + AUTOCOMPLETE_DEFAULT, + AUTOCOMPLETE_MS +} RAutocompleteType; + +/** + * Represent an entry in the seek history. + * This is the "full state" of that point in time. + */ +typedef struct rz_core_seek_undo_t { + ut64 offset; ///< Value of core->offset at the given time in history + int cursor; ///< Position of the cursor at the given time in history + bool is_current; ///< True if this is the current seek value + int idx; ///< Position of the item relative to the current seek item (0 current seek, < 0 for undos, > 0 for redos) +} RzCoreSeekItem; + +typedef struct rz_core_file_t { + struct rz_core_t *core; + int dbg; + int fd; + RzPVector /**/ binfiles; ///< all bin files that have been created for this core file + RzPVector /**/ extra_files; ///< additional files opened during mapping, for example for zeroed maps + RzPVector /**/ maps; ///< all maps that have been created as a result of loading this file +} RzCoreFile; + +/** + * Data to be stored inside RzIOMap.user to track back to its origin + */ +typedef struct rz_core_io_map_info_t { + RzCoreFile *cf; + + /** + * Original perms as specified for example by the RzBinMap. + * + * This may be different from the RzIOMap's perms because io will disable writing if the + * file has been opened read-only. If one needs the info whether a e.g. the segment causing + * this map is writeable, this is the place to look for. + * Used by rz-ghidra for example. + */ + int perm_orig; +} RzCoreIOMapInfo; + +typedef struct rz_core_times_t { + ut64 loadlibs_init_time; + ut64 loadlibs_time; + ut64 file_open_time; +} RzCoreTimes; + +#define RZ_CORE_ASMQJMPS_NUM 10 +#define RZ_CORE_ASMQJMPS_LETTERS 26 +#define RZ_CORE_ASMQJMPS_MAX_LETTERS (26 * 26 * 26 * 26 * 26) +#define RZ_CORE_ASMQJMPS_LEN_LETTERS 5 + +typedef enum rz_core_autocomplete_types_t { + RZ_CORE_AUTOCMPLT_DFLT = 0, + RZ_CORE_AUTOCMPLT_FLAG, + RZ_CORE_AUTOCMPLT_FLSP, + RZ_CORE_AUTOCMPLT_SEEK, + RZ_CORE_AUTOCMPLT_FCN, + RZ_CORE_AUTOCMPLT_EVAL, + RZ_CORE_AUTOCMPLT_MINS, + RZ_CORE_AUTOCMPLT_BRKP, + RZ_CORE_AUTOCMPLT_MACR, + RZ_CORE_AUTOCMPLT_FILE, + RZ_CORE_AUTOCMPLT_THME, + RZ_CORE_AUTOCMPLT_OPTN, + RZ_CORE_AUTOCMPLT_MS, + RZ_CORE_AUTOCMPLT_SDB, + // --- left as last always + RZ_CORE_AUTOCMPLT_END, +} RzCoreAutocompleteType; + +typedef struct rz_core_autocomplete_t { + const char *cmd; + int length; + int n_subcmds; + bool locked; + int type; + struct rz_core_autocomplete_t **subcmds; +} RzCoreAutocomplete; + +typedef struct { + int x; + int y; + int w; + int h; + char *cmd; +} RzCoreGadget; + +/** + * \brief Options for controlling address description output. + * + * This structure contains flags that control how addresses are described + * and formatted. It can be passed to rz_core_addr_describe() and related + * functions to customize the output. + */ +typedef struct rz_core_addr_options_t { + bool show_offset; ///< Show the address offset if no name is found + bool prefer_function; ///< Prefer function names over flag names + bool show_flag; ///< Include flag names in the description + bool use_decimal; ///< Use decimal instead of hexadecimal for offsets + bool show_color; ///< Include color codes in the output + bool show_source_info; ///< Include source file/line information + bool use_realnames; ///< Use realnames for flags instead of names + st64 max_flag_delta; ///< Maximum delta from flag offset to show (0 = unlimited, negative = use default 8192) + bool use_spaces_around_delta; ///< Use spaces around +/- in delta format (e.g., "sym + 10" vs "sym+10") +} RzCoreAddrOptions; + +/** + * \brief Description of an address with human-readable information + * + * This structure contains comprehensive information about an address, + * including its relation to functions, flags, and source code. + */ +typedef struct rz_core_addr_t { + ut64 addr; ///< The address being described + + char *name; ///< Combined name (deprecated, use fcn_name or flag_name) + + char *fcn_name; ///< Name of the function containing the address + ut64 fcn_addr; ///< Address of the function + st64 fcn_delta; ///< Delta from function start (addr - fcn_addr) + + char *flag_name; ///< Name of the flag at or before the address + ut64 flag_offset; ///< Offset of the flag + st64 flag_delta; ///< Delta from flag (addr - flag_offset) + + char *source_file; ///< Source file name (if debug info available) + ut32 source_line; ///< Source line number (0 if unknown) + ut32 source_column; ///< Source column number (0 if unknown) +} RzCoreAddr; + +typedef struct rz_core_task_t RzCoreTask; + +/** + * Scheduler-wide callback to switch any necessary context from cur to next. + */ +typedef void (*RzCoreTaskContextSwitch)(RzCoreTask *next, void *user); + +/** + * Scheduler-wide callback for breaking a task. + */ +typedef void (*RzCoreTaskBreak)(RzCoreTask *task, void *user); + +typedef struct rz_core_tasks_t { + RzCoreTaskContextSwitch ctx_switch; + void *ctx_switch_user; + RzCoreTaskBreak break_cb; + void *break_cb_user; + int task_id_next; + RzList /**/ *tasks; + RzList /**/ *tasks_queue; + RzList /**/ *oneshot_queue; + int oneshots_enqueued; + struct rz_core_task_t *current_task; + struct rz_core_task_t *main_task; + RzThreadLock *lock; + int tasks_running; + bool oneshot_running; +} RzCoreTaskScheduler; + +/** + * Keep track of the seek history, by allowing undo/redo behaviour. Each seek + * is saved in the undos stack (unless cfg.seek.silent is set), so you can go + * back to where you previously were. Once an undo is done, the previously set + * address is put in the redos stack, so it is possible to go back and forth. + * Once a new seek is performed, all redos are lost. + */ +typedef struct rz_core_seek_history_t { + RzVector /**/ undos; ///< Stack of RzCoreSeekItems, allowing to "go back in time" + RzVector /**/ redos; ///< Stack of RzCoreSeekItems, allowing to re-do an action that was undone. + bool saved_set; ///< When true, the \p saved field is set + RzCoreSeekItem saved_item; ///< Position to save in history +} RzCoreSeekHistory; + +struct rz_core_t { + RzAsm *rasm; + ut8 ptr_alignment_I; + RzAnalysis *analysis; + ut8 ptr_alignment_II; + RzBin *bin; + ut8 ptr_alignment_III; + // NOTE: Do not change the order of fields above! + // They are used in pointer passing hacks in rz_types.h. + RzIO *io; + HtSP /**/ *plugins; ///< List of registered core plugins + RzConfig *config; + HtSP /**/ *plugin_configs; ///< Pointers to plugin configurations. Indexed by plugin name + ut64 offset; // current seek + ut64 prompt_offset; // temporarily set to offset to have $$ in expressions always stay the same during temp seeks + ut32 blocksize; + ut32 blocksize_max; + ut8 *block; + RzBuffer *yank_buf; + ut64 yank_addr; + bool tmpseek; + bool vmode; + int interrupted; // XXX IS THIS DUPPED SOMEWHERE? + /* files */ + RzCons *cons; + RzCoreFile *file; + RzList /**/ *files; + RzNum *num; + ut64 rc; // command's return code .. related to num->value; + RzLib *lib; + RzCmd *rcmd; + RzCmdDescriptor root_cmd_descriptor; + RzList /**/ *cmd_descriptors; + /* ^^ */ + RzCoreTimes *times; + RzParse *parser; + RzPrint *print; + RzLang *lang; + RzDebug *dbg; + RzFlag *flags; + RzMark *marks; + char *lastsearch; ///< Legacy search. Will be removed + RzSearch *search; ///< Legacy search. Will be removed + RzEgg *egg; + RzCrypto *crypto; + RzAGraph *graph; + char *cmdqueue; + char *lastcmd; + bool is_lastcmd; + bool is_pipe; + char *cmdlog; + int cmdrepeat; // cmd.repeat + const char *cmdtimes; // cmd.times + RZ_DEPRECATE bool cmd_in_backticks; // whether currently executing a cmd out of backticks + int rtr_n; + RzCoreRtrHost *rtr_host; // array of RzCoreRtrHost + ut64 *asmqjmps; + int asmqjmps_count; + int asmqjmps_size; + bool is_asmqjmps_letter; + bool keep_asmqjmps; + /* TODO: Remove this from RzCore */ + void *visual; /* RzCoreVisual */ + int http_up; + int gdbserver_up; + char *stkcmd; + bool in_search; + RzList /**/ *watchers; + RzList /**/ *scriptstack; + RzCoreTaskScheduler tasks; + int max_cmd_depth; + ut8 switch_file_view; + Sdb *sdb; + int incomment; + /* TODO: Move this to RzCoreVisual instead */ + int curtab; // current tab + int seltab; // selected tab + char *cmdremote; + char *cmdfilter; + char *curtheme; + bool break_loop; + bool binat; + bool fixedbits; // will be true when using @b: + bool fixedarch; // will be true when using @a: + bool fixedblock; + char *table_query; + struct rz_core_t *c2; + RzCoreAutocomplete *autocomplete; + int autocomplete_type; + int maxtab; + RzEvent *ev; + RzList /**/ *gadgets; + bool scr_gadgets; + bool log_events; // core.c:cb_event_handler : log actions from events if cfg.log.events is set + RzList /**/ *ropchain; + RzCoreSeekHistory seek_history; + RzHash *hash; + RzList /**/ *warnings_after; + RzPath *sys_path; ///< pointer to RzPath, contains path prefix of the system + + bool vmarks_init; + ut64 vmarks[UT8_MAX + 1]; + + RzMainCallback rz_main_rizin; + // int (*rz_main_rizin)(int argc, char **argv); + int (*rz_main_rz_find)(int argc, const char **argv); + int (*rz_main_rz_diff)(int argc, const char **argv); + int (*rz_main_rz_bin)(int argc, const char **argv); + int (*rz_main_rz_run)(int argc, const char **argv); + int (*rz_main_rz_gg)(int argc, const char **argv); + int (*rz_main_rz_asm)(int argc, const char **argv); + int (*rz_main_rz_ax)(int argc, const char **argv); +}; + +// maybe move into RzAnalysis +typedef struct rz_core_item_t { + const char *type; + ut64 addr; + ut64 next; + ut64 prev; + int size; + int perm; + char *data; + char *comment; + char *sectname; + char *fcnname; +} RzCoreItem; + +typedef int (*RzCoreSearchCallback)(RzCore *core, ut64 from, ut8 *buf, int len); + +/** + * \brief Store some display name from RzBinSymbol + * \see rz_core_sym_name_init + * \see rz_core_sym_name_fini + */ +typedef struct rz_bin_sym_names_t { + const char *pfx; ///< prefix for flags + char *name; ///< raw symbol name + char *symbolname; ///< display symbol name + char *libname; ///< name of the lib this symbol is specific to, if any + char *nameflag; ///< flag name for symbol + char *demname; ///< demangled raw symbol name + char *demflag; ///< flag name for demangled symbol + char *classname; ///< classname + char *classflag; ///< flag for classname + char *methname; ///< methods [class]::[method] + char *methflag; ///< methods flag sym.[class].[method] +} RzBinSymNames; + +/** + * \brief Message for `pdJ` + */ +typedef struct rz_analysis_disasm_text_t { + ut64 offset; + ut64 arrow; ///< In general, arrow = UT64_MAX, if there is a jump(jmp, ...), arrow = dst offset + char *text; +} RzAnalysisDisasmText; + +#ifdef RZ_API +RZ_API int rz_core_bind(RzCore *core, RzCoreBind *bnd); + +RZ_API void rz_core_notify_begin(RZ_NONNULL RzCore *core, RZ_NONNULL const char *format, ...) RZ_PRINTF_CHECK(2, 3); +RZ_API void rz_core_notify_done(RZ_NONNULL RzCore *core, RZ_NONNULL const char *format, ...) RZ_PRINTF_CHECK(2, 3); +RZ_API void rz_core_notify_error(RZ_NONNULL RzCore *core, RZ_NONNULL const char *format, ...) RZ_PRINTF_CHECK(2, 3); + +RZ_API void rz_core_notify_begin_str(RZ_NONNULL RzCore *core, RZ_NONNULL const char *text); +RZ_API void rz_core_notify_done_str(RZ_NONNULL RzCore *core, RZ_NONNULL const char *text); +RZ_API void rz_core_notify_error_str(RZ_NONNULL RzCore *core, RZ_NONNULL const char *text); + +RZ_API void rz_core_log_after(RZ_NONNULL RzCore *core, const char *funcname, const char *filename, + ut32 lineno, RzLogLevel level, const char *fmtstr, ...) RZ_PRINTF_CHECK(6, 7); + +#define RZ_LOG_WARN_AFTER(core, fmtstr, ...) rz_core_log_after(core, MACRO_LOG_FUNC, __FILE__, \ + __LINE__, RZ_LOGLVL_WARN, fmtstr, ##__VA_ARGS__); + +RZ_API bool rz_core_plugin_init(RzCore *core); +RZ_API bool rz_core_plugin_add(RzCore *core, RZ_NONNULL RzCorePlugin *plugin); +RZ_API bool rz_core_plugin_del(RzCore *core, RZ_NONNULL RzCorePlugin *plugin); +RZ_API bool rz_core_plugin_fini(RzCore *core); + +// #define rz_core_ncast(x) (RzCore*)(size_t)(x) +RZ_API RZ_OWN RzPVector /**/ *rz_core_get_themes(RZ_NONNULL RzCore *core); +RZ_API char *rz_core_theme_get(RzCore *core); +RZ_API bool rz_core_theme_load(RzCore *core, const char *name); +RZ_API void rz_core_theme_nextpal(RzCore *core, RzConsPalSeekMode mode); +RZ_API RZ_OWN char *rz_core_get_section_name(RzCore *core, ut64 addr); +RZ_API RzCons *rz_core_get_cons(RzCore *core); +RZ_API RzBin *rz_core_get_bin(RzCore *core); +RZ_API RzConfig *rz_core_get_config(RzCore *core); +RZ_API bool rz_core_init(RzCore *core); +RZ_API void rz_core_bind_cons(RzCore *core); // to restore pointers in cons +RZ_API RzCore *rz_core_new(void); +RZ_API void rz_core_free(RzCore *core); +RZ_API void rz_core_fini(RzCore *c); +RZ_API void rz_core_wait(RzCore *core); +RZ_API RzCore *rz_core_ncast(ut64 p); +RZ_API RzCore *rz_core_cast(void *p); +RZ_API bool rz_core_bin_load_structs(RZ_NONNULL RzCore *core, RZ_NONNULL const char *file); +RZ_API int rz_core_config_init(RzCore *core); +RZ_API void rz_core_config_print_all(RzConfig *cfg, const char *str, RzCmdStateOutput *state); +RZ_API void rz_core_parse_rizinrc(RzCore *r); +RZ_API RZ_OWN RzList /**/ *rz_core_config_in_space(RZ_NONNULL RzCore *core, RZ_NULLABLE const char *space); +RZ_API int rz_core_prompt(RzCore *core, int sync); +RZ_API int rz_core_prompt_exec(RzCore *core); +RZ_API void rz_core_prompt_loop(RzCore *core); +RZ_API ut64 rz_core_pava(RzCore *core, ut64 addr); +RZ_API int rz_core_cmd(RzCore *core, const char *cmd, int log); +RZ_API RzCmdStatus rz_core_cmd_rzshell(RzCore *core, const char *cmd, int log); +RZ_API RZ_OWN char *rz_core_editor(const RzCore *core, RZ_NULLABLE const char *file, RZ_NULLABLE const char *str); +RZ_API int rz_core_fgets(char *buf, int len, void *user); +RZ_API RzFlagItem *rz_core_flag_get_by_spaces(RzFlag *f, ut64 off); +RZ_API int rz_core_flush(RzCore *core, const char *cmd); +RZ_API void rz_core_cmd_init(RzCore *core); +RZ_API char *rz_core_cmd_str(RzCore *core, const char *cmd); +RZ_API ut8 *rz_core_cmd_raw(RzCore *core, const char *cmd, int *length); +RZ_API char *rz_core_cmd_strf(RzCore *core, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); +RZ_API char *rz_core_cmd_str_pipe(RzCore *core, const char *cmd); +RZ_API int rz_core_cmd_file(RzCore *core, const char *file); +RZ_API int rz_core_cmd_lines(RzCore *core, const char *lines); +RZ_API RzCmdStatus rz_core_cmd_lines_rzshell(RzCore *core, const char *lines); +RZ_API int rz_core_cmd_command(RzCore *core, const char *command); +RZ_API bool rz_core_run_script(RzCore *core, RZ_NONNULL const char *file); +RZ_API void rz_core_seek_item_free(RzCoreSeekItem *item); +RZ_API bool rz_core_seek(RzCore *core, ut64 addr, bool rb); +RZ_API bool rz_core_seek_and_save(RzCore *core, ut64 addr, bool rb); +RZ_API bool rz_core_seek_opt(RzCore *core, ut64 addr, bool read_block, bool save); +RZ_API bool rz_core_seek_mark(RzCore *core); +RZ_API bool rz_core_seek_save(RzCore *core); +RZ_API bool rz_core_seek_undo(RzCore *core); +RZ_API bool rz_core_seek_redo(RzCore *core); +RZ_API void rz_core_seek_reset(RzCore *core); +RZ_API void rz_core_seek_free(RzCore *core); +RZ_API RzList /**/ *rz_core_seek_list(RzCore *core); +RZ_API RzCoreSeekItem *rz_core_seek_peek(RzCore *core, int idx); +RZ_API int rz_core_seek_base(RzCore *core, const char *hex, bool save); +RZ_API bool rz_core_seek_prev(RzCore *core, const char *type, bool save); +RZ_API bool rz_core_seek_next(RzCore *core, const char *type, bool save); +RZ_API bool rz_core_seek_align(RzCore *core, ut64 align, bool save); +RZ_API bool rz_core_seek_delta(RzCore *core, st64 delta, bool save); +RZ_API bool rz_core_seek_analysis_bb(RzCore *core, ut64 addr, bool save); +RZ_API void rz_core_arch_bits_at(RzCore *core, ut64 addr, RZ_OUT RZ_NULLABLE int *bits, RZ_OUT RZ_BORROW RZ_NULLABLE const char **arch); +RZ_API void rz_core_seek_arch_bits(RzCore *core, ut64 addr); +RZ_API int rz_core_block_read(RzCore *core); +RZ_API bool rz_core_block_size(RzCore *core, ut32 bsize); +RZ_API int rz_core_is_valid_offset(RZ_NONNULL RzCore *core, ut64 offset); +RZ_API int rz_core_write_hexpair(RzCore *core, ut64 addr, const char *pairs); +RZ_API int rz_core_write_assembly(RzCore *core, ut64 addr, RZ_NONNULL const char *instructions); +RZ_API int rz_core_write_assembly_fill(RzCore *core, ut64 addr, RZ_NONNULL const char *instructions); +RZ_API bool rz_core_write_block(RzCore *core, ut64 addr, ut8 *data, size_t len); +RZ_API bool rz_core_write_seq_at(RzCore *core, ut64 addr, ut64 from, ut64 to, ut64 step, int value_size); +RZ_API bool rz_core_shift_block(RzCore *core, ut64 addr, ut64 b_size, st64 dist); +RZ_API RzLineNSCompletionResult *rz_core_autocomplete_rzshell(RzCore *core, RzLineBuffer *buf, RzLinePromptType prompt_type); +RZ_DEPRECATE RZ_API void rz_core_help_vars_print(RzCore *core); +RZ_API bool rz_core_prevop_addr(RzCore *core, ut64 start_addr, int numinstrs, RZ_OUT RZ_BORROW RZ_NONNULL ut64 *prev_addr); +RZ_API ut64 rz_core_prevop_addr_force(RzCore *core, ut64 start_addr, int numinstrs); +RZ_API RzBinReloc *rz_core_getreloc(RzCore *core, ut64 addr, int size); +RZ_API RzBinReloc *rz_core_get_reloc_to(RzCore *core, ut64 addr); +RZ_API ut64 rz_core_get_asmqjmps(RzCore *core, const char *str); +RZ_API void rz_core_set_asmqjmps(RzCore *core, char *str, size_t len, int i); +RZ_API char *rz_core_add_asmqjmp(RzCore *core, ut64 addr); + +RZ_API void rz_core_analysis_type_init(RzCore *core); +RZ_API char *rz_core_analysis_hasrefs_to_depth(RzCore *core, ut64 value, PJ *pj, int depth); +RZ_API void rz_core_global_vars_propagate_types(RzCore *core, RzAnalysisFunction *fcn); +RZ_API bool rz_core_analysis_objc_refs(RzCore *core, bool auto_analysis); +RZ_API void rz_core_analysis_objc_stubs(RzCore *core); +RZ_API void rz_core_analysis_cc_init_by_path(RzCore *core, RZ_NULLABLE const char *path, RZ_NULLABLE const char *homepath); +RZ_API void rz_core_analysis_cc_init(RzCore *core); +RZ_API void rz_core_analysis_paths(RzCore *core, ut64 from, ut64 to, bool followCalls, int followDepth, bool is_json); +RZ_API RZ_OWN char *rz_core_types_as_c(RZ_NONNULL RzCore *core, RZ_NONNULL const char *name, bool multiline); +RZ_API RZ_OWN char *rz_core_types_as_c_all(RZ_NONNULL RzCore *core, bool multiline); + +RZ_API bool rz_core_analysis_esil_trace_start(RzCore *core); +RZ_API bool rz_core_analysis_esil_trace_stop(RzCore *core); + +RZ_API int rz_core_search_cb(RzCore *core, ut64 from, ut64 to, RzCoreSearchCallback cb); +RZ_API bool rz_core_file_reopen(RzCore *core, const char *args, int perm, int binload); +RZ_API void rz_core_file_reopen_in_malloc(RzCore *core); +RZ_API void rz_core_file_reopen_debug(RzCore *core, const char *args); +RZ_API void rz_core_file_reopen_remote_debug(RzCore *core, const char *uri, ut64 addr); +RZ_API bool rz_core_file_resize(RzCore *core, ut64 newsize); +RZ_API bool rz_core_file_resize_delta(RzCore *core, st64 delta); +RZ_API RzCoreFile *rz_core_file_find_by_fd(RzCore *core, ut64 fd); +RZ_API RzCoreFile *rz_core_file_find_by_name(RzCore *core, const char *name); +RZ_API RzCoreFile *rz_core_file_cur(RzCore *r); +RZ_API int rz_core_file_set_by_fd(RzCore *core, ut64 fd); +RZ_API int rz_core_file_set_by_name(RzCore *core, const char *name); +RZ_API int rz_core_file_set_by_file(RzCore *core, RzCoreFile *cf); +RZ_API int rz_core_setup_debugger(RzCore *r, const char *debugbackend, bool attach); + +RZ_API bool rz_core_file_open_load(RZ_NONNULL RzCore *core, RZ_NONNULL const char *filepath, ut64 addr, int perms, bool write_mode); +RZ_API RZ_BORROW RzCoreFile *rz_core_file_open(RZ_NONNULL RzCore *core, RZ_NONNULL const char *file, int flags, ut64 loadaddr); +RZ_API RZ_BORROW RzCoreFile *rz_core_file_open_many(RZ_NONNULL RzCore *r, RZ_NULLABLE const char *file, int perm, ut64 loadaddr); +RZ_API bool rz_core_file_malloc_copy_chunk(RzCore *core, size_t len, ut64 offset); +RZ_API RzCoreFile *rz_core_file_get_by_fd(RzCore *core, int fd); +RZ_API void rz_core_file_close(RzCoreFile *fh); +RZ_API bool rz_core_file_close_fd(RzCore *core, int fd); +RZ_API bool rz_core_file_close_all_but(RzCore *core); +RZ_API bool rz_core_raw_file_print(RzCore *core); +RZ_API bool rz_core_file_print(RzCore *core, RzOutputMode mode); +RZ_API int rz_core_file_binlist(RzCore *core); +RZ_API bool rz_core_file_bin_raise(RzCore *core, ut32 num); +RZ_API void rz_core_io_file_open(RZ_NONNULL RzCore *core, int fd); +RZ_API void rz_core_io_file_reopen(RZ_NONNULL RzCore *core, int fd, int perms); +RZ_API bool rz_core_extend_at(RzCore *core, ut64 addr, ut64 size); +RZ_API bool rz_core_write_at(RzCore *core, ut64 addr, const ut8 *buf, int size); +RZ_API bool rz_core_write_value_at(RzCore *core, ut64 addr, ut64 value, int sz); +RZ_API bool rz_core_write_value_inc_at(RzCore *core, ut64 addr, st64 value, int sz); +RZ_API bool rz_core_write_string_at(RzCore *core, ut64 addr, RZ_NONNULL const char *s); +RZ_API bool rz_core_write_string_zero_at(RzCore *core, ut64 addr, const char *s); +RZ_API bool rz_core_write_string_wide_at(RzCore *core, ut64 addr, const char *s); +RZ_API bool rz_core_write_length_string_at(RzCore *core, ut64 addr, const char *s); +RZ_API bool rz_core_write_base64d_at(RzCore *core, ut64 addr, RZ_NONNULL const char *s); +RZ_API bool rz_core_write_base64_at(RzCore *core, ut64 addr, RZ_NONNULL const char *s); +RZ_API bool rz_core_write_random_at(RzCore *core, ut64 addr, size_t len); +RZ_API bool rz_core_write_block_op_at(RzCore *core, ut64 addr, RzCoreWriteOp op, RZ_NULLABLE ut8 *hex, size_t hexlen); +RZ_API bool rz_core_write_duplicate_at(RzCore *core, ut64 addr, ut64 from, int len); +RZ_API RZ_OWN ut8 *rz_core_transform_op(RzCore *core, ut64 addr, RzCoreWriteOp op, RZ_NULLABLE ut8 *hex, size_t hexlen, size_t *buflen); +RZ_API ut32 rz_core_file_cur_fd(RzCore *core); +RZ_API RzCmdStatus rz_core_io_cache_print(RzCore *core, RzCmdStateOutput *state); +RZ_API RzCmdStatus rz_core_io_pcache_print(RzCore *core, RzIODesc *desc, RzCmdStateOutput *state); + +/* creg.c */ +RZ_API RzReg *rz_core_reg_default(RzCore *core); +RZ_API ut64 rz_core_reg_getv_by_role_or_name(RzCore *core, const char *name); +RZ_API bool rz_core_reg_set_by_role_or_name(RzCore *core, const char *name, ut64 num); +RZ_API void rz_core_reg_update_flags(RzCore *core); + +/* cdebug.c */ +RZ_API bool rz_core_is_debug(RzCore *core); +RZ_API bool rz_core_debug_step_one(RzCore *core, int times); +RZ_API bool rz_core_debug_continue_until(RzCore *core, ut64 addr); +RZ_API void rz_core_debug_bp_add_noreturn_func(RzCore *core); +RZ_API void rz_core_debug_breakpoint_toggle(RZ_NONNULL RzCore *core, ut64 addr); + +RZ_API void rz_core_debug_set_register_flags(RzCore *core); +RZ_API void rz_core_debug_clear_register_flags(RzCore *core); + +RZ_API bool rz_core_debug_process_close(RzCore *core); +RZ_API bool rz_core_debug_step_until_frame(RzCore *core); +RZ_API bool rz_core_debug_step_back(RzCore *core, int steps); +RZ_API bool rz_core_debug_step_over(RzCore *core, int steps); +RZ_API bool rz_core_debug_step_skip(RzCore *core, int times); +RZ_API void rz_core_dbg_follow_seek_register(RzCore *core); + +RZ_API RZ_OWN RzList /**/ *rz_core_debug_backtraces(RzCore *core); +RZ_API void rz_backtrace_free(RZ_NULLABLE RzBacktrace *bt); + +RZ_API RzCmdStatus rz_core_debug_plugins_print(RZ_NONNULL RZ_BORROW RzCore *core, RZ_OUT RzCmdStateOutput *state); +RZ_API void rz_core_debug_map_update_flags(RzCore *core); +RZ_API void rz_core_debug_map_print(RzCore *core, ut64 addr, RzCmdStateOutput *state); + +/** + * \defgroup caddr Address Description API + * \brief Unified API for describing addresses in human-readable formats + * + * This API provides functions to generate human-readable descriptions of memory + * addresses, combining information from flags, functions, and debug symbols. + * It supports various output formats including name+offset notation (e.g., "main+0x10"), + * source file information, and JSON output. + * + * Example usage: + * \code + * char *desc = rz_core_addr_get_name_delta(core, 0x401010); + * // Returns "main+16" or "0x401010" if no symbol found + * rz_cons_printf("Address: %s\n", desc); + * free(desc); + * \endcode + * + */ + +RZ_API RZ_OWN RzCoreAddrOptions *rz_core_addr_options_new(void); +RZ_API void rz_core_addr_options_free(RZ_NULLABLE RzCoreAddrOptions *opts); +RZ_API void rz_core_addr_free(RZ_NULLABLE RzCoreAddr *desc); +RZ_API RZ_OWN RzCoreAddr *rz_core_addr_describe(RZ_NONNULL RzCore *core, ut64 addr, RZ_NULLABLE const RzCoreAddrOptions *opts); +RZ_API RZ_OWN char *rz_core_addr_to_string(RZ_NONNULL const RzCoreAddr *desc, RZ_NULLABLE const RzCoreAddrOptions *opts); +RZ_API RZ_OWN char *rz_core_addr_describe_string(RZ_NONNULL RzCore *core, ut64 addr, RZ_NULLABLE const RzCoreAddrOptions *opts); +RZ_API RZ_OWN char *rz_core_addr_get_name_delta(RZ_NONNULL RzCore *core, ut64 addr); +RZ_API RZ_OWN RzCoreAddr *rz_core_addr_describe_with_function(RZ_NONNULL RzCore *core, ut64 addr); +RZ_API RZ_OWN RzCoreAddr *rz_core_addr_describe_with_source(RZ_NONNULL RzCore *core, ut64 addr); +RZ_API RZ_OWN char *rz_core_addr_format_for_display(RZ_NULLABLE RzPrint *print, ut64 addr, RZ_NULLABLE const RzCoreAddrOptions *opts); +RZ_API void rz_core_addr_to_pj(RZ_NONNULL PJ *pj, RZ_NONNULL const RzCoreAddr *desc, RZ_NULLABLE const RzCoreAddrOptions *opts); +RZ_API void rz_core_addr_describe_pj(RZ_NONNULL RzCore *core, RZ_NONNULL PJ *pj, ut64 addr, RZ_NULLABLE const RzCoreAddrOptions *opts); +RZ_API bool rz_core_addr_get_reloff_info(RZ_NONNULL RzCore *core, ut64 addr, bool prefer_function, bool use_flags, RZ_OUT RZ_NULLABLE char **out_name, RZ_OUT RZ_NULLABLE st64 *out_delta); +RZ_API RZ_OWN char *rz_core_addr_get_function_offset(RZ_NONNULL RzCore *core, ut64 addr); +RZ_API RZ_OWN char *rz_core_addr_get_flag_offset(RZ_NONNULL RzFlag *flags, ut64 addr); +RZ_API RZ_OWN char *rz_core_addr_get_flag_offset_prompt(RZ_NONNULL RzFlag *flags, ut64 addr); + +/* chash.c */ +RZ_API RzCmdStatus rz_core_hash_plugins_print(RZ_NONNULL RZ_BORROW RzHash *hash, RZ_OUT RzCmdStateOutput *state); + +/* ccrypto.c */ +RZ_API RzCmdStatus rz_core_crypto_plugins_print(RzCrypto *cry, RzCmdStateOutput *state); + +/* cio.c */ +RZ_API RzCmdStatus rz_core_io_plugins_print(RZ_NONNULL RZ_BORROW RzIO *io, RzCmdStateOutput *state); + +/* cio.c */ +RZ_API RzCmdStatus rz_core_parser_plugins_print(RzParse *parser, RzCmdStateOutput *state); + +/* fortune */ +RZ_API void rz_core_fortune_list_types(void); +RZ_API void rz_core_fortune_list(RzCore *core); +RZ_API RZ_OWN char *rz_core_fortune_get_random(RzCore *core); +RZ_API void rz_core_fortune_print_random(RzCore *core); + +#define RZ_CORE_FOREIGN_ADDR -1 +RZ_API RZ_OWN char *rz_core_yank_as_string(RzCore *core, ut64 pos); +RZ_API bool rz_core_yank(RzCore *core, ut64 addr, ut64 len); +RZ_API bool rz_core_yank_string(RzCore *core, ut64 addr, ut64 maxlen); +RZ_API bool rz_core_yank_hexpair(RzCore *core, const char *str); +RZ_API bool rz_core_yank_paste(RzCore *core, ut64 addr, ut64 len); +RZ_API bool rz_core_yank_set(RzCore *core, ut64 addr, RZ_NONNULL const ut8 *buf, ut64 len); +RZ_API bool rz_core_yank_set_str(RzCore *core, ut64 addr, RZ_NONNULL const char *str); +RZ_API bool rz_core_yank_to(RzCore *core, ut64 len, ut64 addr); +RZ_API bool rz_core_yank_dump(RzCore *core, ut64 pos, RzCmdStateOutput *state); +RZ_API bool rz_core_yank_print_hexdump(RzCore *core, ut64 pos); +RZ_API bool rz_core_yank_print(RzCore *core, ut64 pos); +RZ_API bool rz_core_yank_print_string(RzCore *core, ut64 pos); +RZ_API bool rz_core_yank_hud_file(RzCore *core, const char *input); +RZ_API bool rz_core_yank_hud_path(RzCore *core, const char *input, int dir); +RZ_API bool rz_core_yank_file(RzCore *core, ut64 len, ut64 addr, const char *filename); +RZ_API bool rz_core_yank_file_all(RzCore *core, const char *filename); + +#define RZ_CORE_LOADLIBS_ENV (1 << 0) +#define RZ_CORE_LOADLIBS_HOME (1 << 1) +#define RZ_CORE_LOADLIBS_SYSTEM (1 << 2) +#define RZ_CORE_LOADLIBS_CONFIG (1 << 3) +#define RZ_CORE_LOADLIBS_EXTRA (1 << 4) +#define RZ_CORE_LOADLIBS_ALL UT32_MAX + +RZ_API void rz_core_loadlibs_init(RzCore *core); +RZ_API int rz_core_loadlibs(RzCore *core, int where); +RZ_API RzCmd *rz_core_cmd_new(RzCore *core, bool has_cons); +RZ_API int rz_core_cmd_buffer(RzCore *core, const char *buf); +RZ_API int rz_core_cmdf(RzCore *core, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); +RZ_API int rz_core_cmd0(RzCore *core, const char *cmd); +RZ_API RzCmdStatus rz_core_cmd0_rzshell(RzCore *core, const char *cmd); +RZ_API char *rz_core_op_str(RzCore *core, ut64 addr); +RZ_API RzAnalysisOp *rz_core_op_analysis(RzCore *core, ut64 addr, RzAnalysisOpMask mask); +RZ_API char *rz_core_disassemble_instr(RzCore *core, ut64 addr, int l); +RZ_API char *rz_core_disassemble_bytes(RzCore *core, ut64 addr, int b); + +/* carg.c */ +RZ_DEPRECATE RZ_API ut64 rz_core_arg_get(RzCore *core, const char *cc, int num); +RZ_API RZ_OWN RzList /**/ *rz_core_get_func_args(RzCore *core, const char *func_name); +RZ_API void rz_core_print_func_args(RzCore *core); +RZ_API char *resolve_fcn_name(RzAnalysis *analysis, const char *func_name); + +/* clang.c */ +RZ_API RzCmdStatus rz_core_lang_plugins_print(RzLang *lang, RzCmdStateOutput *state); + +/* ccore.c */ +RZ_API RzCmdStatus rz_core_core_plugins_print(RzCore *core, RzCmdStateOutput *state); + +/* cil.c */ +RZ_API void rz_core_analysis_esil(RzCore *core, ut64 addr, ut64 size, RZ_NULLABLE RzAnalysisFunction *fcn); +RZ_API bool rz_core_esil_cmd(RzAnalysisEsil *esil, const char *cmd, ut64 a1, ut64 a2); +RZ_API int rz_core_esil_step(RzCore *core, ut64 until_addr, const char *until_expr, ut64 *prev_addr, bool stepOver); +RZ_API int rz_core_esil_step_back(RzCore *core); +RZ_API bool rz_core_esil_dumpstack(RzAnalysisEsil *esil); +RZ_API bool rz_core_esil_continue_back(RZ_NONNULL RzCore *core); +RZ_API void rz_core_analysis_esil_step_over(RZ_NONNULL RzCore *core); +RZ_API void rz_core_analysis_esil_reinit(RZ_NONNULL RzCore *core); +RZ_API void rz_core_analysis_esil_deinit(RZ_NONNULL RzCore *core); +RZ_API void rz_core_analysis_esil_init_mem(RZ_NONNULL RzCore *core, RZ_NULLABLE const char *name, ut64 addr, ut32 size); +RZ_API void rz_core_analysis_esil_init_mem_del(RZ_NONNULL RzCore *core, RZ_NULLABLE const char *name, ut64 addr, ut32 size); +RZ_API void rz_core_analysis_esil_init_regs(RZ_NONNULL RzCore *core); + +RZ_API void rz_core_analysis_il_reinit(RZ_NONNULL RzCore *core); +RZ_API bool rz_core_il_step(RZ_NONNULL RzCore *core, ut64 n); +RZ_API bool rz_core_il_step_until(RZ_NONNULL RzCore *core, ut64 until); +RZ_API bool rz_core_il_step_until_with_events(RZ_NONNULL RzCore *core, ut64 until); + +/* canalysis.c */ +typedef enum rz_core_analysis_name_type { + RZ_CORE_ANALYSIS_NAME_TYPE_VAR = 0, + RZ_CORE_ANALYSIS_NAME_TYPE_FUNCTION, + RZ_CORE_ANALYSIS_NAME_TYPE_FLAG, + RZ_CORE_ANALYSIS_NAME_TYPE_ADDRESS, +} RzCoreAnalysisNameType; + +typedef struct rz_core_analysis_name_t { + char *name; + char *realname; + RzCoreAnalysisNameType type; + ut64 offset; +} RzCoreAnalysisName; + +/** + * Defines the level of analysis performed by + * `rz_core_perform_auto_analysis` + * */ +typedef enum { + RZ_CORE_ANALYSIS_SIMPLE, ///< aa + RZ_CORE_ANALYSIS_DEEP, ///< aaa + RZ_CORE_ANALYSIS_EXPERIMENTAL, ///< aaaa +} RzCoreAnalysisType; + +RZ_API RzAnalysisOp *rz_core_analysis_op(RzCore *core, ut64 addr, int mask); +RZ_API void rz_core_analysis_fcn_merge(RzCore *core, ut64 addr, ut64 addr2); +RZ_API const char *rz_core_analysis_optype_colorfor(RzCore *core, ut64 addr, bool verbose); +RZ_API ut64 rz_core_analysis_address(RzCore *core, ut64 addr); +RZ_API void rz_core_analysis_undefine(RzCore *core, ut64 off); +RZ_API void rz_core_analysis_hint_print(RzAnalysis *a, ut64 addr, RzCmdStateOutput *state); +RZ_API void rz_core_analysis_hint_list_print(RzAnalysis *a, RzCmdStateOutput *state); +RZ_API int rz_core_analysis_search(RzCore *core, ut64 from, ut64 to, ut64 ref, int mode); +RZ_API int rz_core_analysis_search_xrefs(RZ_NONNULL RzCore *core, ut64 from, ut64 to); +RZ_API void rz_core_analysis_data(RZ_NONNULL RzCore *core, ut64 addr, ut32 count, ut32 depth, ut32 wordsize); +RZ_API void rz_core_analysis_resolve_jumps(RZ_NONNULL RzCore *core); +RZ_API bool rz_core_analysis_refs(RZ_NONNULL RzCore *core, size_t nbytes); +RZ_API void rz_core_analysis_flag_every_function(RzCore *core); +RZ_API bool rz_core_analysis_function_rename(RzCore *core, ut64 addr, const char *_name); +RZ_API bool rz_core_analysis_function_add(RzCore *core, const char *name, ut64 addr, bool analyze_recursively); +RZ_API int rz_core_analysis_fcn(RzCore *core, ut64 at, ut64 from, int reftype, int depth); +RZ_API RZ_OWN char *rz_core_analysis_function_autoname(RZ_NONNULL RzCore *core, RZ_NONNULL RzAnalysisFunction *fcn); +RZ_API void rz_core_analysis_function_strings_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzAnalysisFunction *fcn, RZ_NULLABLE PJ *pj); +RZ_API void rz_core_analysis_autoname_all_fcns(RzCore *core); +RZ_API bool rz_core_analysis_recover_golang_functions(RzCore *core); +RZ_API void rz_core_analysis_resolve_golang_strings(RzCore *core); +RZ_API int rz_core_analysis_fcn_clean(RzCore *core, ut64 addr); +RZ_API RzList /**/ *rz_core_analysis_graph_to(RzCore *core, ut64 addr, int n); +RZ_API int rz_core_analysis_all(RzCore *core); +RZ_API bool rz_core_analysis_everything(RzCore *core, bool experimental, char *dh_orig); +RZ_API RZ_OWN RzList /**/ *rz_core_analysis_sigdb_list(RZ_NONNULL RzCore *core, bool with_details); +RZ_API bool rz_core_analysis_sigdb_apply(RZ_NONNULL RzCore *core, RZ_NULLABLE int *n_applied, RZ_NULLABLE const char *filter); +RZ_API void rz_core_analysis_sigdb_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzTable *table); +RZ_API RzList /**/ *rz_core_analysis_cycles(RzCore *core, int ccl); +RZ_API RZ_OWN RzList /**/ *rz_core_analysis_fcn_get_calls(RzCore *core, RzAnalysisFunction *fcn); // get all calls from a function +RZ_API void rz_core_analysis_calls(RZ_NONNULL RzCore *core, bool imports_only); +RZ_API int rz_core_get_stacksz(RzCore *core, ut64 from, ut64 to); +RZ_API bool rz_core_analysis_hint_set_offset(RZ_NONNULL RzCore *core, RZ_NONNULL const char *struct_member); +RZ_API bool rz_core_analysis_continue_until_syscall(RZ_NONNULL RzCore *core); +RZ_API bool rz_core_analysis_continue_until_call(RZ_NONNULL RzCore *core); + +RZ_API bool rz_core_is_debugging(RZ_NONNULL RzCore *core); +RZ_API void rz_core_perform_auto_analysis(RZ_NONNULL RzCore *core, RzCoreAnalysisType type); + +RZ_API size_t rz_core_analysis_coverage_count(RZ_NONNULL RzCore *core); +RZ_API size_t rz_core_analysis_code_count(RZ_NONNULL RzCore *core); +RZ_API size_t rz_core_analysis_calls_count(RZ_NONNULL RzCore *core); + +RZ_API RZ_BORROW const char *rz_core_analysis_name_type_to_str(RzCoreAnalysisNameType typ); +RZ_API void rz_core_analysis_name_free(RZ_NULLABLE RzCoreAnalysisName *p); +RZ_API RZ_OWN RzCoreAnalysisName *rz_core_analysis_name(RZ_NONNULL RzCore *core, ut64 addr); +RZ_API bool rz_core_analysis_rename(RZ_NONNULL RzCore *core, RZ_NONNULL const char *name, ut64 addr); + +RZ_API void rz_analysis_bytes_free(RZ_NULLABLE void *ptr); +RZ_API RZ_OWN RzIterator *rz_core_analysis_bytes(RZ_NONNULL RzCore *core, ut64 start_addr, RZ_NONNULL const ut8 *buf, ut64 len, ut64 nops); +RZ_API RZ_OWN RzIterator *rz_core_analysis_op_chunk_iter(RZ_NONNULL RzCore *core, ut64 offset, ut64 len, ut64 nops, RzAnalysisOpMask mask); +RZ_API RZ_OWN RzIterator *rz_core_analysis_op_function_iter(RZ_NONNULL RzCore *core, RZ_NONNULL RZ_BORROW RzAnalysisFunction *fcn, RzAnalysisOpMask mask); +RZ_API ut64 rz_core_analysis_ops_size(RZ_NONNULL RzCore *core, ut64 start_addr, RZ_NONNULL const ut8 *buf, ut64 len, ut64 nops); + +/* cgraph.c */ +/** + * \brief RzGraph format for print/convert + */ +typedef enum { + RZ_CORE_GRAPH_FORMAT_VISUAL = 0, + RZ_CORE_GRAPH_FORMAT_SDB, + RZ_CORE_GRAPH_FORMAT_GML, + RZ_CORE_GRAPH_FORMAT_DOT, + RZ_CORE_GRAPH_FORMAT_JSON, + RZ_CORE_GRAPH_FORMAT_JSON_DISASM, + RZ_CORE_GRAPH_FORMAT_CMD, + RZ_CORE_GRAPH_FORMAT_ASCII_ART, + RZ_CORE_GRAPH_FORMAT_UNK, +} RzCoreGraphFormat; + +/** + * \brief RzGraph type + */ +typedef enum { + RZ_CORE_GRAPH_TYPE_DATAREF = 0, ///< Data reference graph + RZ_CORE_GRAPH_TYPE_FUNCALL, ///< Function callgraph + RZ_CORE_GRAPH_TYPE_DIFF, ///< Diff graph + RZ_CORE_GRAPH_TYPE_BLOCK_FUN, ///< Basic blocks function graph + RZ_CORE_GRAPH_TYPE_IMPORT, ///< Imports graph + RZ_CORE_GRAPH_TYPE_REF, ///< References graph + RZ_CORE_GRAPH_TYPE_LINE, ///< Line graph + RZ_CORE_GRAPH_TYPE_XREF, ///< Cross-references graph + RZ_CORE_GRAPH_TYPE_CUSTOM, ///< Custom graph + RZ_CORE_GRAPH_TYPE_NORMAL, ///< Normal graph + RZ_CORE_GRAPH_TYPE_IL, ///< RzIL graph + RZ_CORE_GRAPH_TYPE_ICFG, ///< Inter-procedual control flow graph + RZ_CORE_GRAPH_TYPE_CFG, ///< control flow graph (without calls) + RZ_CORE_GRAPH_TYPE_UNK ///< Unknown graph +} RzCoreGraphType; + +RZ_API RZ_OWN RzGraph /**/ *rz_core_graph_datarefs(RZ_NONNULL RzCore *core, ut64 addr); +RZ_API RZ_OWN RzGraph /**/ *rz_core_graph_coderefs(RZ_NONNULL RzCore *core, ut64 addr); +RZ_API RZ_OWN RzGraph /**/ *rz_core_graph_codexrefs(RZ_NONNULL RzCore *core, ut64 addr); +RZ_API RZ_OWN RzGraph /**/ *rz_core_graph_importxrefs(RZ_NONNULL RzCore *core); +RZ_API RZ_OWN RzGraph /**/ *rz_core_graph_callgraph(RZ_NONNULL RzCore *core, ut64 addr); +RZ_API RZ_OWN RzGraph /**/ *rz_core_graph_function(RzCore *core, ut64 addr); +RZ_API RZ_OWN RzGraph /**/ *rz_core_graph_line(RzCore *core, ut64 addr); +RZ_API RZ_OWN RzGraph /**/ *rz_core_graph_il(RZ_NONNULL RzCore *core, ut64 addr); +RZ_API RZ_OWN RzGraph /**/ *rz_core_graph(RzCore *core, RzCoreGraphType type, ut64 addr); +RZ_API RZ_OWN RzGraph /**/ *rz_core_graph_icfg(RZ_NONNULL RzCore *core); +RZ_API RZ_OWN RzGraph /**/ *rz_core_graph_cfg(RZ_NONNULL RzCore *core, ut64 addr); + +RZ_API RzCoreGraphFormat rz_core_graph_format_from_string(RZ_NULLABLE const char *x); +RZ_API RzCoreGraphType rz_core_graph_type_from_string(RZ_NULLABLE const char *x); +RZ_API bool rz_core_graph_write_graph(RZ_NONNULL RzCore *core, RZ_NONNULL RzGraph /**/ *graph, RZ_NONNULL const char *filename); +RZ_API bool rz_core_graph_write(RZ_NONNULL RzCore *core, ut64 addr, RzCoreGraphType type, RZ_NONNULL const char *path); +RZ_API RZ_OWN char *rz_core_graph_to_dot_str(RZ_NONNULL RzCore *core, RZ_NONNULL RzGraph /**/ *graph); +RZ_API RZ_OWN char *rz_core_graph_to_sdb_str(RZ_NONNULL RzCore *core, RZ_NONNULL RzGraph /**/ *graph); + +/*tp.c*/ +RZ_API void rz_core_analysis_type_match(RzCore *core, RzAnalysisFunction *fcn, HtUU *addr_loop_table); + +/* asm.c */ +#define RZ_MIDFLAGS_HIDE 0 +#define RZ_MIDFLAGS_SHOW 1 +#define RZ_MIDFLAGS_REALIGN 2 +#define RZ_MIDFLAGS_SYMALIGN 3 + +typedef struct rz_core_asm_hit { + char *code; + int len; + ut64 addr; + ut8 valid; +} RzCoreAsmHit; + +/** + * \brief Disassemble Options, just for rz_core_print_disasm + */ +typedef struct rz_core_disasm_options { + int invbreak; + int cbytes; ///< set false to ignore the constraint of \p len and print \p nlines instructions in rz_core_print_disasm + RzAnalysisFunction *function; ///< Disassemble a function + RzPVector /**/ *vec; ///< Not print, but append as RzPVector +} RzCoreDisasmOptions; + +#define RZ_CORE_MAX_DISASM (1024 * 1024 * 8) + +RZ_API RzBuffer *rz_core_syscall(RzCore *core, const char *name, const char *args); +RZ_API RzBuffer *rz_core_syscallf(RzCore *core, const char *name, const char *fmt, ...) RZ_PRINTF_CHECK(3, 4); +RZ_API RzCoreAsmHit *rz_core_asm_hit_new(void); +RZ_API RzList /**/ *rz_core_asm_hit_list_new(void); +RZ_API void rz_core_asm_hit_free(void *_hit); +RZ_API void rz_core_set_asm_configs(RzCore *core, char *arch, ut32 bits, int segoff); +RZ_API char *rz_core_asm_search(RzCore *core, const char *input); +RZ_API RzCmdStatus rz_core_asm_plugins_print(RZ_NONNULL RZ_BORROW RzCore *core, RZ_OUT RzCmdStateOutput *state, RZ_NULLABLE const char *flags); +RZ_API RzCmdStatus rz_core_asm_cpu_plugin_print(RZ_NONNULL RZ_BORROW RzCore *core, RZ_OUT RzCmdStateOutput *state, RZ_NULLABLE const char *arch_name); +RZ_API RzCmdStatus rz_core_cpu_descs_print(RZ_NONNULL RzCore *core, RZ_NONNULL const char *plugin); +RZ_API RzList /**/ *rz_core_asm_strsearch(RzCore *core, const char *input, ut64 from, ut64 to, int maxhits, int regexp, int everyByte, int mode); +RZ_API RzList /**/ *rz_core_asm_bwdisassemble(RzCore *core, ut64 addr, int n, int len); +RZ_API RzList /**/ *rz_core_asm_back_disassemble_instr(RzCore *core, ut64 addr, int len, ut32 hit_count, ut32 extra_padding); +RZ_API RzList /**/ *rz_core_asm_back_disassemble_byte(RzCore *core, ut64 addr, int len, ut32 hit_count, ut32 extra_padding); +RZ_API ut32 rz_core_asm_bwdis_len(RzCore *core, int *len, ut64 *start_addr, ut32 l); +RZ_API int rz_core_print_disasm(RZ_NONNULL RzCore *core, ut64 addr, RZ_NONNULL ut8 *buf, int len, int nlines, RZ_NULLABLE RzCmdStateOutput *state, RZ_NULLABLE RzCoreDisasmOptions *options); +RZ_API int rz_core_print_disasm_json(RzCore *core, ut64 addr, ut8 *buf, int len, int lines, PJ *pj); +RZ_API int rz_core_print_disasm_instructions_with_buf(RzCore *core, ut64 address, ut8 *buf, int nb_bytes, int nb_opcodes); +RZ_API int rz_core_print_disasm_instructions(RzCore *core, int nb_bytes, int nb_opcodes); +RZ_API int rz_core_disasm_pdi_with_buf(RzCore *core, ut64 address, ut8 *buf, ut32 nb_opcodes, ut32 nb_bytes, int fmt); +RZ_API int rz_core_disasm_pdi(RzCore *core, int nb_opcodes, int nb_bytes, int fmt); +RZ_API int rz_core_disasm_pde(RzCore *core, int nb_opcodes, RzCmdStateOutput *state); +RZ_API RZ_OWN char *rz_core_disasm_instruction(RzCore *core, ut64 addr, ut64 reladdr, RZ_NULLABLE RzAnalysisFunction *fcn, bool color); +RZ_API bool rz_core_print_function_disasm_json(RzCore *core, RzAnalysisFunction *fcn, PJ *pj); +RZ_API int rz_core_flag_in_middle(RzCore *core, ut64 at, int oplen, int *midflags); +RZ_API int rz_core_bb_starts_in_middle(RzCore *core, ut64 at, int oplen); +RZ_API void rz_analysis_disasm_text_free(RzAnalysisDisasmText *t); + +/** + * \brief Use RzAsmOp if it is sufficient + */ +typedef struct { + ut64 offset; + ut64 size; + char *hex; + char *assembly; + char *assembly_colored; +} RzCoreDisasmOp; + +RZ_API void rz_core_disasm_op_free(RzCoreDisasmOp *x); +RZ_API RZ_OWN RzPVector /**/ *rz_core_disasm_all_possible_opcodes(RZ_NONNULL RzCore *core, RZ_NONNULL ut8 *buffer, ut64 addr, ut64 n_bytes); + +/* cbin.c */ +RZ_API bool rz_core_bin_raise(RzCore *core, ut32 bfid); +RZ_API bool rz_core_bin_set_cur(RZ_NONNULL RzCore *core, RZ_NULLABLE RzBinFile *binfile); +RZ_API RZ_BORROW const char *rz_core_bin_get_compile_time(RZ_NONNULL RzBinFile *bf); +RZ_API void rz_core_bin_options_init(RzCore *core, RZ_OUT RzBinOptions *opts, int fd, ut64 baseaddr, ut64 loadaddr); +RZ_API bool rz_core_bin_apply_strings(RzCore *r, RzBinFile *binfile); +RZ_API bool rz_core_bin_apply_config(RzCore *r, RzBinFile *binfile); +RZ_API bool rz_core_bin_apply_maps(RzCore *core, RzBinFile *binfile, bool va); +RZ_API bool rz_core_bin_apply_main(RzCore *r, RzBinFile *binfile, bool va); +RZ_API bool rz_core_bin_apply_dwarf(RzCore *core, RzBinFile *binfile); +RZ_API bool rz_core_bin_apply_entry(RzCore *core, RzBinFile *binfile, bool va); +RZ_API bool rz_core_bin_apply_sections(RzCore *core, RzBinFile *binfile, bool va); +RZ_API bool rz_core_bin_apply_relocs(RzCore *core, RzBinFile *binfile, bool va); +RZ_API bool rz_core_bin_apply_imports(RzCore *core, RzBinFile *binfile, bool va); +RZ_API bool rz_core_bin_apply_symbols(RzCore *core, RzBinFile *binfile, bool va); +RZ_API bool rz_core_bin_apply_classes(RzCore *core, RzBinFile *binfile); +RZ_API bool rz_core_bin_apply_resources(RzCore *core, RzBinFile *binfile); +RZ_API bool rz_core_bin_apply_info(RzCore *r, RzBinFile *binfile, ut32 mask); +RZ_API bool rz_core_bin_apply_all_info(RzCore *r, RzBinFile *binfile); +RZ_API int rz_core_bin_set_by_fd(RzCore *core, ut64 bin_fd); +RZ_API int rz_core_bin_set_by_name(RzCore *core, const char *name); +RZ_API bool rz_core_bin_load(RZ_NONNULL RzCore *core, RZ_NULLABLE const char *file_uri, ut64 base_addr); +RZ_API void rz_core_bin_export_info(RzCore *core, int mode); +RZ_API bool rz_core_binfiles_print(RzCore *core, RzCmdStateOutput *state); +RZ_API bool rz_core_binfiles_delete(RzCore *core, RzBinFile *bf); +RZ_API RZ_OWN HtSS *rz_core_bin_create_digests(RzCore *core, ut64 paddr, ut64 size, RzList /**/ *digests); + +RZ_API void rz_core_bin_print_source_line_sample(RzCore *core, const RzBinSourceLineSample *s, RzCmdStateOutput *state); +RZ_API void rz_core_bin_print_source_line_info(RzCore *core, const RzBinSourceLineInfo *li, RzCmdStateOutput *state); + +RZ_API bool rz_core_sym_is_export(RZ_NONNULL RzBinSymbol *s); + +RZ_API void rz_core_sysenv_begin(RzCore *core); +RZ_API void rz_core_sysenv_end(RzCore *core); + +RZ_API void rz_core_recover_vars(RzCore *core, RzAnalysisFunction *fcn, bool argonly); + +/* cmd_linux_heap_glibc.c */ +RZ_API RzList /**/ *rz_heap_chunks_list(RzCore *core, ut64 m_arena); +RZ_API RzList /**/ *rz_heap_arenas_list(RzCore *core); +RZ_API RzHeapChunkSimple *rz_heap_chunk(RzCore *core, ut64 addr); +RZ_API RzHeapBin *rz_heap_bin_content(RzCore *core, MallocState *arena, int bin_num, ut64 m_arena); +RZ_API RzHeapBin *rz_heap_fastbin_content(RzCore *core, MallocState *arena, int bin_num); +RZ_API MallocState *rz_heap_get_arena(RzCore *core, ut64 m_state); +RZ_API RzList /**/ *rz_heap_tcache_content(RzCore *core, ut64 arena_base); +RZ_API bool rz_heap_write_chunk(RzCore *core, RzHeapChunkSimple *chunk_simple); + +/* cmd_windows_heap.c */ +RZ_API RZ_OWN RzList /**/ *rz_heap_windows_blocks_list(RzCore *core); +RZ_API RZ_OWN RzList /**/ *rz_heap_windows_heap_list(RzCore *core); + +// XXX dupe from rz_bin.h +/* bin.c */ +#define RZ_CORE_BIN_ACC_STRINGS 0x001 +#define RZ_CORE_BIN_ACC_INFO 0x002 +#define RZ_CORE_BIN_ACC_MAIN 0x004 +#define RZ_CORE_BIN_ACC_ENTRIES 0x008 +#define RZ_CORE_BIN_ACC_RELOCS 0x010 +#define RZ_CORE_BIN_ACC_IMPORTS 0x020 +#define RZ_CORE_BIN_ACC_SYMBOLS 0x040 +#define RZ_CORE_BIN_ACC_SECTIONS 0x080 +#define RZ_CORE_BIN_ACC_FIELDS 0x100 +#define RZ_CORE_BIN_ACC_LIBS 0x200 +#define RZ_CORE_BIN_ACC_CLASSES 0x400 +#define RZ_CORE_BIN_ACC_DWARF 0x800 +#define RZ_CORE_BIN_ACC_SIZE 0x1000 +#define RZ_CORE_BIN_ACC_PDB 0x2000 +#define RZ_CORE_BIN_ACC_MEM 0x4000 +#define RZ_CORE_BIN_ACC_EXPORTS 0x8000 +#define RZ_CORE_BIN_ACC_VERSIONINFO 0x10000 +#define RZ_CORE_BIN_ACC_SIGNATURE 0x20000 +#define RZ_CORE_BIN_ACC_RAW_STRINGS 0x40000 +#define RZ_CORE_BIN_ACC_HEADER 0x80000 +#define RZ_CORE_BIN_ACC_RESOURCES 0x100000 +#define RZ_CORE_BIN_ACC_INITFINI 0x200000 +#define RZ_CORE_BIN_ACC_SEGMENTS 0x400000 +#define RZ_CORE_BIN_ACC_BASEFIND 0x800000 +#define RZ_CORE_BIN_ACC_TRYCATCH 0x20000000 +#define RZ_CORE_BIN_ACC_SECTIONS_MAPPING 0x40000000 +#define RZ_CORE_BIN_ACC_MAPS 0x80000000 +#define RZ_CORE_BIN_ACC_ALL 0x80504FFF + +#define RZ_CORE_PRJ_FLAGS 0x0001 +#define RZ_CORE_PRJ_EVAL 0x0002 +#define RZ_CORE_PRJ_IO_MAPS 0x0004 +#define RZ_CORE_PRJ_SECTIONS 0x0008 +#define RZ_CORE_PRJ_META 0x0010 +#define RZ_CORE_PRJ_XREFS 0x0020 +#define RZ_CORE_PRJ_FCNS 0x0040 +#define RZ_CORE_PRJ_ANALYSIS_HINTS 0x0080 +#define RZ_CORE_PRJ_ANALYSIS_TYPES 0x0100 +#define RZ_CORE_PRJ_ANALYSIS_MACROS 0x0200 +#define RZ_CORE_PRJ_ANALYSIS_SEEK 0x0400 +#define RZ_CORE_PRJ_DBG_BREAK 0x0800 +#define RZ_CORE_PRJ_ALL 0xFFFF + +typedef struct rz_core_bin_filter_t { + ut64 offset; + const char *name; +} RzCoreBinFilter; + +RZ_API bool rz_core_bin_set_arch_bits(RZ_NONNULL RzCore *r, RZ_NULLABLE const char *filename, RZ_NULLABLE const char *arch, ut16 bits); +RZ_API int rz_core_bin_update_arch_bits(RzCore *r); +RZ_API RZ_OWN char *rz_core_bin_class_build_flag_name(RZ_NONNULL RzBinClass *cls); +RZ_API RZ_OWN char *rz_core_bin_super_build_flag_name(RZ_NONNULL RzBinClass *cls); +RZ_API RZ_OWN char *rz_core_bin_method_build_flag_name(RZ_NONNULL RzBinClass *cls, RZ_NONNULL RzBinSymbol *meth); +RZ_API RZ_OWN char *rz_core_bin_field_build_flag_name(RZ_NONNULL RzBinClass *cls, RZ_NONNULL RzBinClassField *field); +RZ_API char *rz_core_bin_method_flags_str(ut64 flags, int mode); +RZ_API RZ_OWN char *rz_core_bin_pdb_get_filename(RZ_NONNULL RzCore *core); +RZ_API bool rz_core_bin_pdb_load(RZ_NONNULL RzCore *core, RZ_NONNULL const char *filename); +RZ_API RzPdb *rz_core_pdb_load_info(RZ_NONNULL RzCore *core, RZ_NONNULL const char *file); +RZ_API void rz_core_pdb_info_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzTypeDB *db, RZ_NONNULL RzPdb *pdb, RZ_NONNULL RzCmdStateOutput *state); +RZ_API char *rz_core_bin_pdb_gvars_as_string(RZ_NONNULL RzPdb *pdb, const ut64 img_base, RzCmdStateOutput *state); +RZ_API RzCmdStatus rz_core_bin_plugins_print(RzBin *bin, RzCmdStateOutput *state); + +RZ_API bool rz_core_bin_archs_print(RZ_NONNULL RzBin *bin, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_entries_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_initfini_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_exports_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state, RzCoreBinFilter *filter); +RZ_API bool rz_core_bin_cur_export_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_symbols_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state, RzCoreBinFilter *filter); +RZ_API bool rz_core_bin_cur_symbol_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_imports_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state, RzCoreBinFilter *filter); +RZ_API bool rz_core_bin_libs_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_main_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_relocs_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_sections_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state, RzCoreBinFilter *filter, RzList /**/ *hashes); +RZ_API bool rz_core_bin_cur_section_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state, RzList /**/ *hashes); +RZ_API bool rz_core_bin_cur_segment_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state, RzList /**/ *hashes); +RZ_API bool rz_core_bin_segments_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state, RzCoreBinFilter *filter, RzList /**/ *hashes); +RZ_API bool rz_core_bin_strings_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API RZ_OWN RzPVector /**/ *rz_core_bin_whole_strings(RZ_NONNULL RzCore *core, RZ_NULLABLE RzBinFile *bf); +RZ_API bool rz_core_bin_whole_strings_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_xrefs_strings_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_file_info_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_info_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_classes_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_class_as_source_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, const char *class_name); +RZ_API bool rz_core_bin_class_fields_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state, const char *class_name); +RZ_API bool rz_core_bin_class_methods_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state, const char *class_name); +RZ_API bool rz_core_bin_signatures_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_fields_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_structured_data_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RzOutputMode mode); +RZ_API bool rz_core_bin_dwarf_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_memory_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_resources_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state, RZ_NULLABLE RzList /**/ *hashes); +RZ_API bool rz_core_bin_versions_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_trycatch_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_size_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_sections_mapping_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzCmdStateOutput *state); +RZ_API bool rz_core_bin_print(RzCore *core, RZ_NONNULL RzBinFile *bf, ut32 mask, RzCoreBinFilter *filter, RzCmdStateOutput *state, RzList /**/ *hashes); +RZ_API bool rz_core_bin_basefind_print(RzCore *core, ut32 pointer_size, RzCmdStateOutput *state); + +// cmeta.c +RZ_API bool rz_core_meta_string_add(RzCore *core, ut64 addr, ut64 size, RzStrEnc encoding, RZ_NULLABLE const char *name); +RZ_API bool rz_core_meta_pascal_string_add(RzCore *core, ut64 addr, RzStrEnc encoding, RZ_NULLABLE const char *name); + +// cprint.c +typedef enum { + RZ_CORE_PRINT_FORMAT_TYPE_OCTAL = 0, + RZ_CORE_PRINT_FORMAT_TYPE_INTEGER, + RZ_CORE_PRINT_FORMAT_TYPE_HEXADECIMAL, + RZ_CORE_PRINT_FORMAT_TYPE_INVALID, +} RzCorePrintFormatType; + +RZ_API RZ_OWN char *rz_core_print_string_c_cpp(RzCore *core); +RZ_API RZ_OWN char *rz_core_hex_of_assembly(RzCore *core, const char *assembly); +RZ_API RZ_OWN char *rz_core_esil_of_assembly(RzCore *core, const char *assembly); +RZ_API RZ_OWN char *rz_core_assembly_of_hex(RzCore *core, ut8 *hex, int len); +RZ_API RZ_OWN char *rz_core_esil_of_hex(RzCore *core, ut8 *hex, int len); + +RZ_API RZ_OWN char *rz_core_print_hexdump_diff_str(RZ_NONNULL RzCore *core, ut64 aa, ut64 ba, ut64 len); +RZ_API RZ_OWN char *rz_core_print_dump_str(RZ_NONNULL RzCore *core, RzOutputMode mode, ut64 addr, ut8 n, int len, RzCorePrintFormatType format); +RZ_API RZ_OWN char *rz_core_print_hexdump_or_hexdiff_str(RZ_NONNULL RzCore *core, RzOutputMode mode, ut64 addr, int len, bool use_comment); +RZ_API RZ_OWN char *rz_core_print_hexdump_byline_str(RZ_NONNULL RzCore *core, bool hex_offset, ut64 addr, int len, ut8 size); +RZ_API RZ_OWN char *rz_core_print_bytes_with_inst(RZ_NONNULL RzCore *core, RZ_NONNULL const ut8 *buf, ut64 addr, int len); + +typedef enum { + RZ_CORE_DISASM_STRINGS_MODE_BYTES = 0, + RZ_CORE_DISASM_STRINGS_MODE_INST, + RZ_CORE_DISASM_STRINGS_MODE_BLOCK, + RZ_CORE_DISASM_STRINGS_MODE_FUNCTION, +} RzCorePrintDisasmStringsMode; +RZ_API RZ_OWN char *rz_core_print_disasm_strings(RZ_NONNULL RzCore *core, RzCorePrintDisasmStringsMode mode, ut64 n_bytes, RZ_NULLABLE RzAnalysisFunction *fcn); + +/* rtr */ +RZ_API bool rz_core_rtr_init(RZ_NONNULL RzCore *core); +RZ_API void rz_core_rtr_cmds(RzCore *core, const char *port); +RZ_API char *rz_core_rtr_cmds_query(RzCore *core, const char *host, const char *port, const char *cmd); +RZ_API void rz_core_rtr_pushout(RzCore *core, const char *input); +RZ_API void rz_core_rtr_list(RzCore *core); +RZ_API void rz_core_rtr_add(RzCore *core, const char *input); +RZ_API void rz_core_rtr_remove(RzCore *core, const char *input); +RZ_API void rz_core_rtr_session(RzCore *core, const char *input); +RZ_API void rz_core_rtr_cmd(RzCore *core, const char *input); +RZ_API bool rz_core_rtr_http(RzCore *core, bool open_browser); +RZ_API bool rz_core_rtr_gdb(RzCore *core, ut32 port, const char *file_path, RZ_NULLABLE const char *gdb_args, bool debug_msg); + +/// Legacy search +RZ_API int rz_core_search_preludes(RzCore *core, bool log); +RZ_API int rz_core_search_prelude(RzCore *core, ut64 from, ut64 to, const ut8 *buf, int blen, const ut8 *mask, int mlen); + +#define RZ_CORE_BOUNDARIES_PERMS_ANY 0 +#define RZ_CORE_BOUNDARIES_MASK_NONE 0 +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_raw(RZ_NONNULL RzCore *core, const RzInterval interval); +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_block(RZ_NONNULL RzCore *core, const RzInterval interval); +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_current_function(RZ_NONNULL RzCore *core, const RzInterval interval); +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_current_function_bb(RZ_NONNULL RzCore *core, const RzInterval interval); +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_current_io_map(RZ_NONNULL RzCore *core, const RzInterval interval); +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_current_bin_section(RZ_NONNULL RzCore *core, const RzInterval interval); +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_current_bin_segment(RZ_NONNULL RzCore *core, const RzInterval interval); +#define rz_core_get_boundaries_range rz_core_get_boundaries_all_io_maps +#define rz_core_get_boundaries_all_io_maps(core, interval) \ + rz_core_get_boundaries_io_maps(core, interval, RZ_CORE_BOUNDARIES_PERMS_ANY, RZ_CORE_BOUNDARIES_MASK_NONE) +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_io_maps(RZ_NONNULL RzCore *core, const RzInterval interval, int perms, int perms_mask); +#define rz_core_get_boundaries_all_io_skyline(core, interval) \ + rz_core_get_boundaries_io_skyline(core, interval, RZ_CORE_BOUNDARIES_PERMS_ANY, RZ_CORE_BOUNDARIES_MASK_NONE) +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_io_skyline(RZ_NONNULL RzCore *core, const RzInterval interval, int perms, int perms_mask); +#define rz_core_get_boundaries_all_bin_segments(core, interval) \ + rz_core_get_boundaries_bin_segments(core, interval, RZ_CORE_BOUNDARIES_PERMS_ANY, RZ_CORE_BOUNDARIES_MASK_NONE) +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_bin_segments(RZ_NONNULL RzCore *core, const RzInterval interval, int perms, int perms_mask); +#define rz_core_get_boundaries_all_bin_sections(core, interval) \ + rz_core_get_boundaries_bin_sections(core, interval, RZ_CORE_BOUNDARIES_PERMS_ANY, RZ_CORE_BOUNDARIES_MASK_NONE) +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_bin_sections(RZ_NONNULL RzCore *core, const RzInterval interval, int perms, int perms_mask); +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_code_only(RZ_NONNULL RzCore *core, const RzInterval interval); +#define rz_core_get_boundaries_current_debug_map(core, interval) \ + rz_core_get_boundaries_debug_maps(core, interval, RZ_CORE_BOUNDARIES_PERMS_ANY, RZ_CORE_BOUNDARIES_MASK_NONE, true) +#define rz_core_get_boundaries_all_debug_maps(core, interval) \ + rz_core_get_boundaries_debug_maps(core, interval, RZ_CORE_BOUNDARIES_PERMS_ANY, RZ_CORE_BOUNDARIES_MASK_NONE, false) +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_debug_maps(RZ_NONNULL RzCore *core, const RzInterval interval, int perms, int perms_mask, bool current); +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_debug_heap(RZ_NONNULL RzCore *core, const RzInterval interval); +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_debug_stack(RZ_NONNULL RzCore *core, const RzInterval interval); +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_debug_program(RZ_NONNULL RzCore *core, const RzInterval interval); +RZ_API RZ_OWN RzList /**/ *rz_core_get_boundaries_select(RZ_NONNULL RzCore *core, RZ_NONNULL const char *from_key, RZ_NONNULL const char *to_key, RZ_NONNULL const char *in_key); + +RZ_API bool rz_core_hack(RzCore *core, const char *op); +RZ_API bool rz_core_dump(RzCore *core, const char *file, ut64 addr, ut64 size, int append); +RZ_API RZ_OWN char *rz_core_clippy(RZ_NONNULL RzCore *core, RZ_NONNULL const char *msg); + +// TODO MOVE SOMEWHERE ELSE +typedef char *(*PrintItemCallback)(void *user, void *p, bool selected); +RZ_API char *rz_str_widget_list(void *user, RzList /**/ *list, int rows, int cur, PrintItemCallback cb); +/* help */ +RZ_API void rz_core_cmd_help(const RzCore *core, const char *help[]); +RZ_DEPRECATE RZ_API const char **rz_core_help_vars_get(RzCore *core); + +/* analysis stats */ + +/** + * Single sub-range of statistics as part of an entire RzCoreAnalysisStats. + * + * The range that this covers is given by rz_core_analysis_stats_get_block_from()/to(). + */ +typedef struct { + ut32 youarehere; + ut32 flags; + ut32 comments; + ut32 functions; + ut32 blocks; + ut32 in_functions; + ut32 symbols; + ut32 strings; + ut32 perm; +} RzCoreAnalysisStatsItem; + +/** + * Statistics for a range of memory, split up into smaller blocks. + */ +typedef struct { + ut64 from; + ut64 to; + ut64 step; + RzVector /**/ blocks; +} RzCoreAnalysisStats; + +RZ_API char *rz_core_analysis_hasrefs(RzCore *core, ut64 value, RzOutputMode mode); +RZ_API char *rz_core_analysis_get_comments(RzCore *core, ut64 addr); +RZ_API RZ_OWN RzCoreAnalysisStats *rz_core_analysis_get_stats(RZ_NONNULL RzCore *a, ut64 from, ut64 to, ut64 step); +RZ_API void rz_core_analysis_stats_free(RzCoreAnalysisStats *s); +RZ_API ut64 rz_core_analysis_stats_get_block_from(RZ_NONNULL const RzCoreAnalysisStats *s, size_t i); +RZ_API ut64 rz_core_analysis_stats_get_block_to(RZ_NONNULL const RzCoreAnalysisStats *s, size_t i); + +RZ_API RZ_OWN char *rz_core_syscall_as_string(RzCore *core, st64 num, ut64 addr); + +/* tasks */ + +typedef enum { + RZ_CORE_TASK_STATE_BEFORE_START, + RZ_CORE_TASK_STATE_RUNNING, + RZ_CORE_TASK_STATE_SLEEPING, + RZ_CORE_TASK_STATE_DONE +} RzTaskState; + +typedef enum { + RZ_CORE_TASK_JOIN_ERR_SUCCESS = 0, ///< Join success! + RZ_CORE_TASK_JOIN_ERR_CURRENT, ///< Join on current task + RZ_CORE_TASK_JOIN_ERR_NO_TASK, ///< No task has given id + RZ_CORE_TASK_JOIN_ERR_ONE_NO_SEM, ///< No join semaphore when joining on one task + RZ_CORE_TASK_JOIN_ERR_ALL_NO_SEM ///< No join semaphore when joining on all tasks +} RzCoreTaskJoinErr; + +/** + * Main payload of a task, the function that should be executed asynchronously. + */ +typedef void (*RzCoreTaskRunner)(RzCoreTaskScheduler *sched, void *user); + +/** + * Task-specific callback to free/cleanup any runner-specific data. + */ +typedef void (*RzCoreTaskRunnerFree)(void *user); + +struct rz_core_task_t { + RzCoreTaskScheduler *sched; + int id; + RzTaskState state; + bool transient; // delete when finished + int refcount; + RzThreadSemaphore *running_sem; + bool dispatched; + RzThreadCond *dispatch_cond; + RzThreadLock *dispatch_lock; + RzThread *thread; + bool breaked; + + RzCoreTaskRunner runner; // will be NULL for main task + RzCoreTaskRunnerFree runner_free; + void *runner_user; +}; + +typedef void (*RzCoreTaskOneShot)(void *); + +RZ_API RzTable *rz_core_table(RzCore *core); + +RZ_API void rz_core_task_scheduler_init(RzCoreTaskScheduler *sched, + RzCoreTaskContextSwitch ctx_switch, void *ctx_switch_user, + RzCoreTaskBreak break_cb, void *break_cb_user); +RZ_API void rz_core_task_scheduler_fini(RzCoreTaskScheduler *tasks); +RZ_API RzCoreTask *rz_core_task_get_incref(RzCoreTaskScheduler *scheduler, int id); +RZ_API int rz_core_task_running_tasks_count(RzCoreTaskScheduler *scheduler); +RZ_API RzCoreTask *rz_core_task_new(RzCoreTaskScheduler *sched, RzCoreTaskRunner runner, RzCoreTaskRunnerFree runner_free, void *runner_user); +RZ_API void rz_core_task_incref(RzCoreTask *task); +RZ_API void rz_core_task_decref(RzCoreTask *task); +RZ_API void rz_core_task_enqueue(RzCoreTaskScheduler *scheduler, RzCoreTask *task); +RZ_API void rz_core_task_enqueue_oneshot(RzCoreTaskScheduler *scheduler, RzCoreTaskOneShot func, void *user); +RZ_API int rz_core_task_run_sync(RzCoreTaskScheduler *scheduler, RzCoreTask *task); +RZ_API void rz_core_task_sync_begin(RzCoreTaskScheduler *scheduler); +RZ_API void rz_core_task_sync_end(RzCoreTaskScheduler *scheduler); +RZ_API void rz_core_task_yield(RzCoreTaskScheduler *scheduler); +RZ_API void rz_core_task_sleep_begin(RzCoreTask *task); +RZ_API void rz_core_task_sleep_end(RzCoreTask *task); +RZ_API void rz_core_task_break(RzCoreTaskScheduler *scheduler, int id); +RZ_API void rz_core_task_break_all(RzCoreTaskScheduler *scheduler); +RZ_API int rz_core_task_del(RzCoreTaskScheduler *scheduler, int id); +RZ_API RzCoreTask *rz_core_task_self(RzCoreTaskScheduler *scheduler); +RZ_API RzCoreTaskJoinErr rz_core_task_join(RzCoreTaskScheduler *scheduler, RzCoreTask *current, int id); +typedef void (*inRangeCb)(RzCore *core, ut64 from, ut64 to, int vsize, void *cb_user); +RZ_API int rz_core_search_value_in_range(RzCore *core, RzInterval search_itv, + ut64 vmin, ut64 vmax, int vsize, inRangeCb cb, void *cb_user); + +// core-specific tasks +typedef void (*RzCoreCmdTaskFinished)(const char *res, void *user); +RZ_API RzCoreTask *rz_core_cmd_task_new(RzCore *core, const char *cmd, RzCoreCmdTaskFinished finished_cb, void *finished_cb_user); +RZ_API const char *rz_core_cmd_task_get_result(RzCoreTask *task); +typedef void *(*RzCoreTaskFunction)(RzCore *core, void *user); +RZ_API RzCoreTask *rz_core_function_task_new(RzCore *core, RzCoreTaskFunction fcn, void *fcn_user); +RZ_API void *rz_core_function_task_get_result(RzCoreTask *task); +RZ_API const char *rz_core_task_status(RzCoreTask *task); +RZ_API bool rz_core_task_is_cmd(RzCore *core, int id); +RZ_API void rz_core_task_del_all_done(RzCore *core); + +RZ_API void rz_core_analysis_propagate_noreturn(RzCore *core, ut64 addr); + +RZ_API bool rz_core_flirt_dump_file(RZ_NONNULL const char *flirt_file); +RZ_API bool rz_core_flirt_create_file(RZ_NONNULL RzCore *core, RZ_NONNULL const char *output_file, RZ_NULLABLE ut32 *written_nodes); +RZ_API bool rz_core_flirt_convert_file(RZ_NONNULL RzCore *core, RZ_NONNULL const char *input_file, RZ_NONNULL const char *ouput_file); +RZ_API const char *rz_core_flirt_arch_from_id(ut8 arch); +RZ_API ut8 rz_core_flirt_arch_from_name(RZ_NONNULL const char *arch); +RZ_API ut32 rz_core_flirt_file_from_option_list(RZ_NONNULL const char *file_list); +RZ_API ut16 rz_core_flirt_os_from_option_list(RZ_NONNULL const char *os_list); +RZ_API ut16 rz_core_flirt_app_from_option_list(RZ_NONNULL const char *app_list); + +/* DECOMPILER PRINTING FUNCTIONS */ +/** + * @brief Prints the data contained in the specified RzAnnotatedCode in JSON format. + * + * The function will print the output in console using the function rz_cons_printf(); + * + * @param code Pointer to a RzAnnotatedCode. + */ +RZ_API void rz_core_annotated_code_print_json(RzAnnotatedCode *code); +/** + * @brief Prints the decompiled code from the specified RzAnnotatedCode. + * + * This function is used for printing the output of commands pdg and pdgo. + * It can print the decompiled code with or without offsets. If line_offsets is a null pointer, + * the output will be printed without offsets (pdg), otherwise, the output will be + * printed with offsets. + * This function will print the output in console using the function rz_cons_printf(); + * + * @param code Pointer to a RzAnnotatedCode. + * @param line_offsets Pointer to a @ref RzVector that contains offsets for the decompiled code. + */ +RZ_API void rz_core_annotated_code_print(RzAnnotatedCode *code, RzVector /**/ *line_offsets); +/** + * @brief Prints the decompiled code as comments + * + * This function is used for the output of command pdg* + * Output will be printed in console using the function rz_cons_printf(); + * + * @param code Pointer to a RzAnnotatedCode. + */ +RZ_API void rz_core_annotated_code_print_comment_cmds(RzAnnotatedCode *code); + +/* serialize */ + +/** + * @param prj_file filename of the project that db will be saved to later. This is only used to re-locate the loaded RIO descs, the project file itself is not touched by this function. + */ +RZ_API void rz_serialize_core_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzCore *core, RZ_NULLABLE const char *prj_file); + +/** + * @param load_bin_io whether to also load the underlying RIO and RBin state from the project. If false, the current state will be kept and the project loaded on top. + * @param prj_file filename of the project that db comes from. This is only used to re-locate the loaded RIO descs, the project file itself is not touched by this function. + */ +RZ_API bool rz_serialize_core_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzCore *core, bool load_bin_io, + RZ_NULLABLE const char *prj_file, RZ_NULLABLE RzSerializeResultInfo *res); + +RZ_API void rz_serialize_core_seek_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzCore *core); + +RZ_API bool rz_serialize_core_seek_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzCore *core, RZ_NULLABLE RzSerializeResultInfo *res); + +/** + * \brief Load a project and print info and errors + */ +RZ_API bool rz_core_project_load_for_cli(RzCore *core, const char *file, bool load_bin_io); + +RZ_API bool rz_platform_index_add_flags_comments(RzCore *core); + +/* regs */ +/// Callback for synchronizing register state in commands (only relevant for debug, not for analysis) +typedef bool (*RzCmdRegSync)(RzCore *core, RzRegisterType type, bool write); +RZ_API bool rz_core_reg_assign_sync(RZ_NONNULL RzCore *core, RZ_NONNULL RzReg *reg, RzCmdRegSync sync_cb, RZ_NONNULL const char *name, ut64 val); +RZ_API RZ_OWN RzList /**/ *rz_core_reg_filter_items_sync(RZ_NONNULL RzCore *core, RZ_NONNULL RzReg *reg, RzCmdRegSync sync_cb, RZ_NULLABLE const char *filter); + +RZ_API void rz_core_rtr_enable(RZ_NONNULL RzCore *core, const char *cmdremote); + +RZ_API RZ_OWN char *rz_core_analysis_var_to_string(RZ_NONNULL RzCore *core, RZ_NONNULL RzAnalysisVar *var); +RZ_API RZ_OWN char *rz_core_analysis_var_display(RZ_NONNULL RzCore *core, RZ_NONNULL RzAnalysisVar *var, bool add_name); + +RZ_API ut64 rz_core_analysis_var_addr(RZ_NONNULL RzCore *core, RZ_NONNULL RzAnalysisVar *var); + +RZ_API RZ_BORROW const RzBinSourceLineSample *rz_analysis_function_sourceline_information(RZ_NONNULL RzCore *core, RZ_NONNULL RzAnalysisFunction *fcn); +RZ_API RZ_BORROW const RzBinSourceLineSample *rz_analysis_var_global_sourceline_information(RZ_NONNULL RzCore *core, RZ_NONNULL RzAnalysisVarGlobal *glb); + +RZ_API void rz_core_sym_name_init(RZ_NONNULL RZ_OUT RzBinSymNames *names, RZ_NONNULL RzBinSymbol *symbol, bool demangle); +RZ_API void rz_core_sym_name_fini(RZ_NULLABLE RzBinSymNames *names); + +RZ_API void rz_core_analysis_bytes_il(RZ_NONNULL RzCore *core, ut64 len, ut64 num_ops, bool pretty); +RZ_API bool rz_core_disasm_until_ret(RZ_NONNULL RzCore *core, ut64 addr, int limit, RzOutputMode mode, + bool ret_val, RZ_NULLABLE RZ_OUT RzStrBuf *buf); + +RZ_API RZ_OWN RzList /**/ *rz_core_setup_io_search_parameters(RzCore *core, RZ_NULLABLE RZ_OUT RzSearchOpt *search_opts); +RZ_API RZ_OWN RzSearchFindOpt *rz_core_setup_default_search_find_opts(RzCore *core); + +RZ_API RZ_OWN RzList /**/ *rz_core_search_bytes(RZ_NONNULL RzCore *core, RZ_BORROW RZ_NULLABLE RzSearchOpt *user_opts, RZ_NONNULL RZ_OWN RzSearchBytesPattern *pattern); +RZ_API RZ_OWN RzList /**/ *rz_core_search_values(RZ_NONNULL RzCore *core, RZ_BORROW RZ_NULLABLE RzSearchOpt *user_opts, RZ_NONNULL RZ_OWN RzVector /**/ *vranges); +RZ_API RZ_OWN RzList /**/ *rz_core_search_string(RZ_NONNULL RzCore *core, RZ_BORROW RZ_NONNULL RzSearchOpt *user_opts, RZ_NONNULL const char *string, size_t string_len, RzRegexFlags flags, RzStrEnc expected); +RZ_API RZ_OWN RzList /**/ *rz_core_search_cryptographic_material(RZ_NONNULL RzCore *core, RZ_BORROW RZ_NULLABLE RzSearchOpt *user_opts, RzSearchCollectionCryptographicType type); +RZ_API RZ_OWN RzList /**/ *rz_core_search_hash(RZ_NONNULL RzCore *core, RZ_BORROW RZ_NULLABLE RzSearchOpt *user_opts, RZ_NONNULL const char *algo_name, RZ_NONNULL const char *expected_digits, ut64 block_size); +RZ_API RZ_OWN RzList /**/ *rz_core_search_entropy(RZ_NONNULL RzCore *core, RZ_BORROW RZ_NULLABLE RzSearchOpt *user_opts, bool fractional, double min_inclusive_limit, double max_inclusive_limit, ut64 block_size); +RZ_API RZ_OWN RzList /**/ *rz_core_search_magic(RZ_NONNULL RzCore *core, RZ_BORROW RZ_NULLABLE RzSearchOpt *user_opts, RZ_NULLABLE const char *magic_dir); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_crypto.h b/dest/include/librz/rz_crypto.h new file mode 100644 index 00000000000..1e548d74e83 --- /dev/null +++ b/dest/include/librz/rz_crypto.h @@ -0,0 +1,121 @@ +#ifndef RZ_CRYPTO_H +#define RZ_CRYPTO_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_crypto); + +enum { + RZ_CRYPTO_MODE_ECB, + RZ_CRYPTO_MODE_CBC, + RZ_CRYPTO_MODE_OFB, + RZ_CRYPTO_MODE_CFB, +}; + +/* Defines in which direction the set_key methods needs to run */ +enum { + RZ_CRYPTO_DIR_ENCRYPT = 0, + RZ_CRYPTO_DIR_DECRYPT, +}; + +typedef struct rz_crypto_t { + struct rz_crypto_plugin_t *h; + ut8 *key; + ut8 *iv; + int key_len; + ut8 *output; + int output_len; + int output_size; + int dir; + void *user; + HtSP /**/ *plugins; +} RzCrypto; + +typedef struct rz_crypto_plugin_t { + const char *name; + const char *license; + const char *author; + const char *description; + int (*get_key_size)(RzCrypto *cry); + bool (*set_iv)(RzCrypto *cry, const ut8 *iv, int ivlen); + bool (*set_key)(RzCrypto *cry, const ut8 *key, int keylen, int mode, int direction); + bool (*update)(RzCrypto *cry, const ut8 *buf, int len); + bool (*final)(RzCrypto *cry, const ut8 *buf, int len); + bool (*use)(const char *algo); + bool (*init)(RzCrypto *cry); + bool (*fini)(RzCrypto *cry); +} RzCryptoPlugin; + +typedef ut64 RzCryptoSelector; + +/** + * \brief Compare plugins by name (via strcmp). + */ +static inline int rz_crypto_plugin_cmp(RZ_NULLABLE const RzCryptoPlugin *a, RZ_NULLABLE const RzCryptoPlugin *b) { + if (!a && !b) { + return 0; + } else if (!a) { + return -1; + } else if (!b) { + return 1; + } + return rz_str_cmp(a->name, b->name, -1); +} + +#ifdef RZ_API +RZ_API bool rz_crypto_plugin_add(RZ_NONNULL RzCrypto *cry, RZ_NONNULL RzCryptoPlugin *h); +RZ_API bool rz_crypto_plugin_del(RZ_NONNULL RzCrypto *cry, RZ_NONNULL RzCryptoPlugin *h); +RZ_API RZ_OWN RzCrypto *rz_crypto_new(void); +RZ_API void rz_crypto_free(RZ_NULLABLE RzCrypto *cry); +RZ_API void rz_crypto_reset(RZ_NONNULL RzCrypto *cry); +RZ_API bool rz_crypto_use(RZ_NONNULL RzCrypto *cry, RZ_NONNULL const char *algo); +RZ_API bool rz_crypto_set_key(RZ_NULLABLE RzCrypto *cry, RZ_NULLABLE const ut8 *key, int keylen, int mode, int direction); +RZ_API bool rz_crypto_set_iv(RZ_NULLABLE RzCrypto *cry, RZ_NULLABLE const ut8 *iv, int ivlen); +RZ_API int rz_crypto_update(RZ_NULLABLE RzCrypto *cry, RZ_NULLABLE const ut8 *buf, int len); +RZ_API int rz_crypto_final(RZ_NULLABLE RzCrypto *cry, RZ_NULLABLE const ut8 *buf, int len); +RZ_API int rz_crypto_append(RZ_NONNULL RzCrypto *cry, RZ_NONNULL const ut8 *buf, int len); +RZ_API RZ_BORROW const ut8 *rz_crypto_get_output(RZ_NONNULL RzCrypto *cry, RZ_NULLABLE int *size); +RZ_API RZ_BORROW const char *rz_crypto_name(const RzCryptoSelector bit); +RZ_API RZ_BORROW const char *rz_crypto_codec_name(const RzCryptoSelector bit); +RZ_API RZ_BORROW const RzCryptoPlugin *rz_crypto_plugin_by_index(RZ_NONNULL RzCrypto *cry, size_t index); +#endif + +#define RZ_CRYPTO_NONE 0ULL +#define RZ_CRYPTO_RC2 1ULL +#define RZ_CRYPTO_RC4 1ULL << 1 +#define RZ_CRYPTO_RC6 1ULL << 2 +#define RZ_CRYPTO_AES_ECB 1ULL << 3 +#define RZ_CRYPTO_AES_CBC 1ULL << 4 +#define RZ_CRYPTO_ROR 1ULL << 5 +#define RZ_CRYPTO_ROL 1ULL << 6 +#define RZ_CRYPTO_ROT 1ULL << 7 +#define RZ_CRYPTO_BLOWFISH 1ULL << 8 +#define RZ_CRYPTO_CPS2 1ULL << 9 +#define RZ_CRYPTO_DES_ECB 1ULL << 10 +#define RZ_CRYPTO_XOR 1ULL << 11 +#define RZ_CRYPTO_SERPENT 1ULL << 12 +#define RZ_CRYPTO_SM4_ECB 1ULL << 13 +#define RZ_CRYPTO_ALL 0xFFFF + +#define RZ_CODEC_NONE 0ULL +#define RZ_CODEC_B64 1ULL +#define RZ_CODEC_B91 1ULL << 1 +#define RZ_CODEC_PUNYCODE 1ULL << 2 +#define RZ_CODEC_B85 1ULL << 3 +#define RZ_CODEC_B36 1ULL << 4 +#define RZ_CODEC_B32 1ULL << 5 +#define RZ_CODEC_B16 1ULL << 6 +#define RZ_CODEC_ALL 0xFFFF + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_crypto/rz_aes.h b/dest/include/librz/rz_crypto/rz_aes.h new file mode 100644 index 00000000000..bf3bf77e99c --- /dev/null +++ b/dest/include/librz/rz_crypto/rz_aes.h @@ -0,0 +1,64 @@ +#ifndef RZ_AES_H +#define RZ_AES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +static const ut8 RZ_AES_SBOX[256] = { // forward s-box + 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, + 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, + 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, + 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, + 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, + 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, + 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, + 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, + 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, + 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, + 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, + 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, + 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, + 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, + 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, + 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, + 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, + 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, + 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, + 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, + 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, + 0xb0, 0x54, 0xbb, 0x16 +}; + +static const ut8 RZ_AES_INV_SBOX[256] = { // inverse s-box + 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, + 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, + 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, + 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, + 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, + 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, + 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, + 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, + 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, + 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, + 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, + 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, + 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, + 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, + 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, + 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, + 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, + 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, + 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, + 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, + 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, + 0x55, 0x21, 0x0c, 0x7d +}; + +#ifdef __cplusplus +} +#endif + +#endif // RZ_AES_H diff --git a/dest/include/librz/rz_crypto/rz_des.h b/dest/include/librz/rz_crypto/rz_des.h new file mode 100644 index 00000000000..73c4f65f157 --- /dev/null +++ b/dest/include/librz/rz_crypto/rz_des.h @@ -0,0 +1,26 @@ +#ifndef RZ_DES_H +#define RZ_DES_H + +#include + +#define DES_KEY_SIZE 8 +#define DES_BLOCK_SIZE 8 + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API void rz_des_permute_key(ut32 *keylo, ut32 *keyhi); +RZ_API void rz_des_permute_key_inv(ut32 *keylo, ut32 *keyhi); +RZ_API void rz_des_permute_block0(ut32 *blocklo, ut32 *blockhi); +RZ_API void rz_des_permute_block1(ut32 *blocklo, ut32 *blockhi); +RZ_API void rz_des_shift_key(int i, bool decrypt, ut32 *deskeylo, ut32 *deskeyhi); +RZ_API void rz_des_pc2(RZ_OUT ut32 *keylo, RZ_OUT ut32 *keyhi, RZ_IN ut32 deslo, RZ_IN ut32 deshi); +RZ_API void rz_des_round_key(int i, ut32 *keylo, ut32 *keyhi, ut32 *deskeylo, ut32 *deskeyhi); +RZ_API void rz_des_round(ut32 *buflo, ut32 *bufhi, ut32 *roundkeylo, ut32 *roundkeyhi); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_DES_H diff --git a/dest/include/librz/rz_crypto/rz_sm4.h b/dest/include/librz/rz_crypto/rz_sm4.h new file mode 100644 index 00000000000..481b1901aa3 --- /dev/null +++ b/dest/include/librz/rz_crypto/rz_sm4.h @@ -0,0 +1,19 @@ +#ifndef RZ_SM4_H +#define RZ_SM4_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RZ_SM4_KEY_SIZE 16 + +RZ_API void rz_sm4_extract_master_key(const ut32 word[4], ut8 key_out[RZ_SM4_KEY_SIZE]); +RZ_API ut32 rz_sm4_round_key(ut32 val); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_SM4_H diff --git a/dest/include/librz/rz_debug.h b/dest/include/librz/rz_debug.h new file mode 100644 index 00000000000..227cd4a351f --- /dev/null +++ b/dest/include/librz/rz_debug.h @@ -0,0 +1,642 @@ +#ifndef RZ_DEBUG_H +#define RZ_DEBUG_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_debug); + +/* hack to fix compilation of debugger on BSD systems */ +/* This needs some testing (netbsd, freebsd, openbsd, kfreebsd) */ +#if __BSD__ +#include + +/* hakish hack to hack the openbsd/sparc64 hack */ +#undef reg +#undef fpreg +#undef fpstate +#undef trapframe +#undef rwindow + +#ifdef PTRACE_SYSCALL +/* on freebsd does not have the same meaning */ +#undef PTRACE_SYSCALL +#endif + +#define PTRACE_PEEKTEXT PT_READ_I +#define PTRACE_POKETEXT PT_WRITE_I +#define PTRACE_PEEKDATA PT_READ_D +#define PTRACE_POKEDATA PT_WRITE_D +#define PTRACE_ATTACH PT_ATTACH +#define PTRACE_DETACH PT_DETACH +#define PTRACE_SINGLESTEP PT_STEP +#define PTRACE_CONT PT_CONTINUE +#define PTRACE_GETREGS PT_GETREGS +#define PTRACE_SETREGS PT_SETREGS +#define PTRACE_SYSCALL PT_STEP +#endif + +#define SNAP_PAGE_SIZE 4096 +#define CHECK_POINT_LIMIT 0x100000 // TODO: take the benchmark +/* + * states that a process can be in + */ +typedef enum { + RZ_DBG_PROC_STOP = 's', + RZ_DBG_PROC_RUN = 'r', + RZ_DBG_PROC_SLEEP = 'S', + RZ_DBG_PROC_ZOMBIE = 'z', + RZ_DBG_PROC_DEAD = 'd', + RZ_DBG_PROC_RAISED = 'R' // has produced a signal, breakpoint, etc.. +} RzDebugPidState; + +// signal handling must support application and debugger level options +typedef enum { + RZ_DBG_SIGNAL_IGNORE = 0, // ignore signal handler + RZ_DBG_SIGNAL_CONT = 1, // pass signal to chlidren and continue execution + RZ_DBG_SIGNAL_SKIP = 2, // + //.. +} RzDebugSignalMode; + +/* + * when a user wants to resume from a breakpoint, we need to know how they want + * to proceed. these values indicate their intention. + */ +typedef enum { + RZ_DBG_RECOIL_NONE = 0, + RZ_DBG_RECOIL_STEP, + RZ_DBG_RECOIL_CONTINUE +} RzDebugRecoilMode; + +/* + * List of reasons that an inferior might have stopped + */ +typedef enum { + RZ_DEBUG_REASON_DEAD = -1, + RZ_DEBUG_REASON_NONE = 0, + RZ_DEBUG_REASON_SIGNAL, + RZ_DEBUG_REASON_SEGFAULT, + RZ_DEBUG_REASON_BREAKPOINT, + RZ_DEBUG_REASON_TRACEPOINT, + RZ_DEBUG_REASON_COND, + RZ_DEBUG_REASON_READERR, + RZ_DEBUG_REASON_STEP, + RZ_DEBUG_REASON_ABORT, + RZ_DEBUG_REASON_WRITERR, + RZ_DEBUG_REASON_DIVBYZERO, + RZ_DEBUG_REASON_ILLEGAL, + RZ_DEBUG_REASON_UNKNOWN, + RZ_DEBUG_REASON_ERROR, + RZ_DEBUG_REASON_NEW_PID, + RZ_DEBUG_REASON_NEW_TID, + RZ_DEBUG_REASON_NEW_LIB, + RZ_DEBUG_REASON_EXIT_PID, + RZ_DEBUG_REASON_EXIT_TID, + RZ_DEBUG_REASON_EXIT_LIB, + RZ_DEBUG_REASON_TRAP, + RZ_DEBUG_REASON_SWI, + RZ_DEBUG_REASON_INT, + RZ_DEBUG_REASON_FPU, + RZ_DEBUG_REASON_USERSUSP, +} RzDebugReasonType; + +/* TODO: move to rz_analysis */ +typedef struct rz_debug_frame_t { + ut64 addr; + int size; + ut64 sp; + ut64 bp; +} RzDebugFrame; + +typedef struct rz_debug_reason_t { + int /*RzDebugReasonType*/ type; + int tid; + int signum; + ut64 bp_addr; + ut64 timestamp; + ut64 addr; + ut64 ptr; +} RzDebugReason; + +typedef struct rz_debug_map_t { + char *name; + ut64 addr; + ut64 addr_end; + ut64 size; + ut64 offset; + char *file; + int perm; + int user; + bool shared; +} RzDebugMap; + +typedef struct rz_debug_signal_t { + int type; + int num; + ut64 handler; +} RzDebugSignal; + +typedef struct rz_debug_desc_t { + int fd; + char *path; + int perm; + int type; + ut64 off; +} RzDebugDesc; + +typedef struct rz_debug_snap_t { + char *name; + ut64 addr; + ut64 addr_end; + ut32 size; + ut8 *data; + int perm; + int user; + bool shared; +} RzDebugSnap; + +typedef struct { + int cnum; + ut64 data; +} RzDebugChangeReg; + +typedef struct { + int cnum; + ut8 data; +} RzDebugChangeMem; + +typedef struct rz_debug_checkpoint_t { + int cnum; + RzRegArena *arena[RZ_REG_TYPE_LAST]; + RzList /**/ *snaps; +} RzDebugCheckpoint; + +typedef struct rz_debug_session_t { + ut32 cnum; + ut32 maxcnum; + RzDebugCheckpoint *cur_chkpt; + RzVector /**/ *checkpoints; + HtUP *memory; /* RzVector */ + HtUP *registers; /* RzVector */ + int reasontype /*RzDebugReasonType*/; + RzBreakpointItem *bp; +} RzDebugSession; + +/* Session file format */ +typedef struct rz_session_header { + ut64 addr; + ut32 id; + ut32 difflist_len; +} RSessionHeader; + +typedef struct rz_diff_entry { + ut32 base_idx; + ut32 pages_len; +} RzDiffEntry; + +typedef struct rz_snap_entry { + ut64 addr; + ut32 size; + ut64 timestamp; + int perm; +} RSnapEntry; + +typedef struct rz_debug_trace_t { + RzList /**/ *traces; + int count; + int enabled; + int tag; + int dup; + HtSP *ht; +} RzDebugTrace; + +typedef struct rz_debug_tracepoint_t { + ut64 addr; + ut64 tags; // XXX + int tag; // XXX + int size; + int count; + int times; + ut64 stamp; +} RzDebugTracepoint; + +typedef struct rz_debug_t { + char *arch; + RZ_DEPRECATE int bits; ///< bad indicator for the bitness of the debuggee + int hitinfo; + + int main_pid; + int pid; /* selected process id */ + int tid; /* selected thread id */ + int forked_pid; /* last pid created by fork */ + int n_threads; + RzList /**/ *threads; /* NOTE: list contents are platform-specific */ + + char *malloc; /*choose malloc parser: 0 = glibc, 1 = jemalloc*/ + + /* dbg.* config options (see e?dbg) + * NOTE: some settings are checked inline instead of tracked here. + */ + char *btalgo; /* select backtrace algorithm */ + int btdepth; /* backtrace depth */ + int regcols; /* display columns */ + int swstep; /* steps with software traps */ + int stop_all_threads; /* stop all threads at any stop */ + int trace_forks; /* stop on new children */ + int trace_execs; /* stop on new execs */ + int trace_aftersyscall; /* stop after the syscall (before if disabled) */ + int trace_clone; /* stop on new threads */ + int follow_child; /* On fork, trace the child */ + bool create_new_console; /* Create a new console window for the debugee on debug start */ + char *glob_libs; /* stop on lib load */ + char *glob_unlibs; /* stop on lib unload */ + bool consbreak; /* SIGINT handle for attached processes */ + bool continue_all_threads; + + /* tracking debugger state */ + int steps; /* counter of steps done */ + RzDebugReason reason; /* stop reason */ + RzDebugRecoilMode recoil_mode; /* what did the user want to do? */ + ut64 stopaddr; /* stop address */ + + /* tracing vars */ + RzDebugTrace *trace; + HtUP *tracenodes; + RTree *tree; + RzList /**/ *call_frames; + RzReg *reg; + RzBreakpoint *bp; + char *snap_path; + + /* io */ + PrintfCallback cb_printf; + RzIOBind iob; + + struct rz_debug_plugin_t *cur; + void *plugin_data; + HtSP /**/ *plugins; + + bool pc_at_bp; /* after a breakpoint, is the pc at the bp? */ + bool pc_at_bp_set; /* is the pc_at_bp variable set already? */ + + RzEvent *ev; + RzHash *hash; + + RzAnalysis *analysis; + RzList /**/ *maps; + RzList /**/ *maps_user; + + bool trace_continue; + RzAnalysisOp *cur_op; + RzDebugSession *session; + + Sdb *sgnls; + RzCoreBind corebind; + // internal use only + int _mode; + RzNum *num; + RzEgg *egg; + bool verbose; + bool main_arena_resolved; /* is the main_arena resolved already? */ + int glibc_version; + bool is_glibc_resolved; + bool nt_x86_xstate_supported; ///< Track whether X86_FEATURE_XSAVE feature is supported on current kernel + size_t RtlpHpHeapGlobalsOffset; ///< Related to windows heap + size_t RtlpLFHKeyOffset; ///< Related to windows heap +} RzDebug; + +typedef struct rz_debug_desc_plugin_t { + int (*open)(const char *path); + int (*close)(int fd); + int (*read)(int fd, ut64 addr, int len); + int (*write)(int fd, ut64 addr, int len); + int (*seek)(int fd, ut64 addr); + int (*dup)(int fd, int newfd); + RzList /**/ *(*list)(int pid); +} RzDebugDescPlugin; + +typedef struct rz_debug_info_t { + int pid; + int tid; + int uid; + int gid; + char *usr; + char *exe; + char *cmdline; + char *libname; + char *cwd; + int status; // zombie, running, sleeping, ... + int signum; + void *lib; + void *thread; + char *kernel_stack; + // retrieve mem/fd/core limits? + // list of threads ? hasthreads? counter? + // environment? + // /proc/pid/syscall ??? +} RzDebugInfo; + +/* TODO: pass dbg and user data pointer everywhere */ +typedef struct rz_debug_plugin_t { + const char *name; + const char *license; + const char *author; + const char *version; + ut32 bits; + const char *arch; + int canstep; + bool (*init)(RzDebug *dbg, void **user); + void (*fini)(RzDebug *debug, void *user); + /* life */ + RzDebugInfo *(*info)(RzDebug *dbg, const char *arg); + int (*attach)(RzDebug *dbg, int pid); + int (*detach)(RzDebug *dbg, int pid); + int (*select)(RzDebug *dbg, int pid, int tid); + RzList /**/ *(*threads)(RzDebug *dbg, int pid); + RzList /**/ *(*pids)(RzDebug *dbg, int pid); + /* flow */ + int (*stop)(RzDebug *dbg); + bool (*step)(RzDebug *dbg); + bool (*step_over)(RzDebug *dbg); + int (*cont)(RzDebug *dbg, int pid, int tid, int sig); + RzDebugReasonType (*wait)(RzDebug *dbg, int pid); + bool (*gcore)(RzDebug *dbg, char *path, RzBuffer *dest); + bool (*kill)(RzDebug *dbg, int pid, int tid, int sig); + RzList /**/ *(*kill_list)(RzDebug *dbg); + int (*contsc)(RzDebug *dbg, int pid, int sc); + RzList /**/ *(*frames)(RzDebug *dbg, ut64 at); + RzBreakpointCallback breakpoint; /// Callback to be used for RzBreakpoint. When called, RzBreakpoint.user points to the RzDebug. + // XXX: specify, pid, tid, or RzDebug ? + int (*reg_read)(RzDebug *dbg, int type, ut8 *buf, int size); + int (*reg_write)(RzDebug *dbg, int type, const ut8 *buf, int size); // XXX struct rz_regset_t regs); + bool (*sync_registers)(RzDebug *dbg, RzReg *reg, bool to_debugger); + RZ_OWN char *(*reg_profile)(RzDebug *dbg); + int (*set_reg_profile)(RzDebug *dbg, const char *str); + /* memory */ + RzList /**/ *(*map_get)(RzDebug *dbg); + RzList /**/ *(*modules_get)(RzDebug *dbg); + RzDebugMap *(*map_alloc)(RzDebug *dbg, ut64 addr, int size, bool thp); + int (*map_dealloc)(RzDebug *dbg, ut64 addr, int size); + int (*map_protect)(RzDebug *dbg, ut64 addr, int size, int perms); + int (*drx)(RzDebug *dbg, int n, ut64 addr, int size, int rwx, int g, int api_type); + RzDebugDescPlugin desc; + // TODO: use RzList here +} RzDebugPlugin; + +// TODO: rename to rz_debug_process_t ? maybe a thread too ? +typedef struct rz_debug_pid_t { + int pid; + int ppid; + char status; /* stopped, running, zombie, sleeping ,... */ + int runnable; /* when using 'run', 'continue', .. this proc will be runnable */ + bool signalled; + char *path; + int uid; + int gid; + ut64 pc; + ut64 tls; ///< Thread local storage base (used for accessing thread specific variables) +} RzDebugPid; + +typedef struct rz_backtrace_t { + RzDebugFrame *frame; + RzAnalysisFunction *fcn; + char *desc; + char *pcstr; + char *spstr; + char *flagdesc; + char *flagdesc2; +} RzBacktrace; + +typedef struct rz_debug_esil_watchpoint_t { + int rwx; + int dev; + char *expr; +} RzDebugEsilWatchpoint; + +typedef struct { + char *name; ///< Name of the information + RzInterval pitv; ///< Offset interval + RzInterval vitv; ///< Virtual address interval + int perm; ///< Permissions + char *extra; ///< Extra printable information +} RzDbgListInfo; + +#ifdef RZ_API + +/** + * \brief Compare plugins by name (via strcmp). + */ +static inline int rz_debug_plugin_cmp(RZ_NULLABLE const RzDebugPlugin *a, RZ_NULLABLE const RzDebugPlugin *b) { + if (!a && !b) { + return 0; + } else if (!a) { + return -1; + } else if (!b) { + return 1; + } + return rz_str_cmp(a->name, b->name, -1); +} + +RZ_API RZ_OWN RzDebug *rz_debug_new(RZ_BORROW RZ_NONNULL RzBreakpointContext *bp_ctx); +RZ_API void rz_debug_free(RzDebug *dbg); + +RZ_API int rz_debug_attach(RzDebug *dbg, int pid); +RZ_API int rz_debug_detach(RzDebug *dbg, int pid); + +/* reason we stopped */ +RZ_API RzDebugReasonType rz_debug_stop_reason(RzDebug *dbg); +RZ_API const char *rz_debug_reason_to_string(int type); + +/* wait for another event */ +RZ_API RzDebugReasonType rz_debug_wait(RzDebug *dbg, RzBreakpointItem **bp); + +/* continuations */ +RZ_API int rz_debug_step(RzDebug *dbg, int steps); +RZ_API int rz_debug_step_over(RzDebug *dbg, int steps); +RZ_API int rz_debug_continue_until(RzDebug *dbg, ut64 addr); +RZ_API int rz_debug_continue_until_nonblock(RzDebug *dbg, ut64 addr); +RZ_API int rz_debug_continue_until_optype(RzDebug *dbg, int type, int over); +RZ_API int rz_debug_continue_until_nontraced(RzDebug *dbg); +RZ_API int rz_debug_continue_syscall(RzDebug *dbg, int sc); +RZ_API int rz_debug_continue_syscalls(RzDebug *dbg, int *sc, int n_sc); +RZ_API int rz_debug_continue(RzDebug *dbg); +RZ_API int rz_debug_continue_kill(RzDebug *dbg, int signal); +RZ_API int rz_debug_continue_pass_exception(RzDebug *dbg); + +/* process/thread handling */ +RZ_API bool rz_debug_select(RzDebug *dbg, int pid, int tid); +RZ_API RzDebugPid *rz_debug_pid_new(const char *path, int pid, int uid, char status, ut64 pc); +RZ_API RzDebugPid *rz_debug_pid_free(RzDebugPid *pid); +RZ_API RzList /**/ *rz_debug_pids(RzDebug *dbg, int pid); +RZ_API RzDebugPid *rz_debug_get_thread(RzList /**/ *th_list, int tid); +RZ_API RZ_OWN RzList /**/ *rz_debug_native_threads(RzDebug *dbg, int pid); +RZ_API ut64 rz_debug_get_tls(RZ_NONNULL RzDebug *dbg, int tid); + +RZ_API bool rz_debug_set_arch(RzDebug *dbg, const char *arch, int bits); +RZ_API bool rz_debug_use(RzDebug *dbg, const char *str); + +RZ_API RzDebugInfo *rz_debug_info(RzDebug *dbg, const char *arg); +RZ_API void rz_debug_info_free(RzDebugInfo *rdi); + +RZ_API ut64 rz_debug_get_baddr(RzDebug *dbg, const char *file); + +RZ_API void rz_debug_switch_to_first_thread(RZ_NONNULL RzDebug *debug); + +/* send signals */ +RZ_API void rz_debug_signal_init(RzDebug *dbg); +RZ_API int rz_debug_signal_send(RzDebug *dbg, int num); +RZ_API int rz_debug_signal_what(RzDebug *dbg, int num); +RZ_API void rz_debug_signal_setup(RzDebug *dbg, int num, int opt); +RZ_API int rz_debug_signal_set(RzDebug *dbg, int num, ut64 addr); +RZ_API bool rz_debug_can_kill(RzDebug *dbg); +RZ_API int rz_debug_kill(RzDebug *dbg, int pid, int tid, int sig); +RZ_API RzList /**/ *rz_debug_kill_list(RzDebug *dbg); + +/* handle.c */ +RZ_API void rz_debug_plugin_init(RzDebug *dbg); +RZ_API bool rz_debug_plugin_add(RzDebug *dbg, RZ_NONNULL RzDebugPlugin *plugin); +RZ_API bool rz_debug_plugin_del(RzDebug *dbg, RZ_NONNULL RzDebugPlugin *plugin); +RZ_API bool rz_debug_plugin_set_reg_profile(RzDebug *dbg, const char *str); + +/* memory */ +RZ_API RzList /**/ *rz_debug_modules_list(RzDebug *); +RZ_API RzDebugMap *rz_debug_map_alloc(RzDebug *dbg, ut64 addr, int size, bool thp); +RZ_API int rz_debug_map_dealloc(RzDebug *dbg, RzDebugMap *map); +RZ_API RzList /**/ *rz_debug_map_list_new(void); +RZ_API RzDebugMap *rz_debug_map_get(RzDebug *dbg, ut64 addr); +RZ_API RZ_OWN RzDebugMap *rz_debug_map_new(RZ_NULLABLE char *name, ut64 begin, ut64 end, int perm, int user); +RZ_API void rz_debug_map_free(RZ_NULLABLE RzDebugMap *map); +RZ_API void rz_debug_map_list_visual(RzDebug *dbg, ut64 addr, const char *input, int colors); +RZ_API RZ_BORROW RzList /**/ *rz_debug_map_list(RzDebug *dbg, bool user_map); + +/* descriptors */ +RZ_API RzDebugDesc *rz_debug_desc_new(int fd, char *path, int perm, int type, int off); +RZ_API void rz_debug_desc_free(RzDebugDesc *p); +RZ_API int rz_debug_desc_open(RzDebug *dbg, const char *path); +RZ_API int rz_debug_desc_close(RzDebug *dbg, int fd); +RZ_API int rz_debug_desc_dup(RzDebug *dbg, int fd, int newfd); +RZ_API int rz_debug_desc_read(RzDebug *dbg, int fd, ut64 addr, int len); +RZ_API int rz_debug_desc_seek(RzDebug *dbg, int fd, ut64 addr); // TODO: whence? +RZ_API int rz_debug_desc_write(RzDebug *dbg, int fd, ut64 addr, int len); + +/* registers */ +RZ_API bool rz_debug_reg_profile_sync(RzDebug *dbg); +RZ_API int rz_debug_reg_sync(RzDebug *dbg, int type, int write); +RZ_API int rz_debug_reg_set(RzDebug *dbg, const char *name, ut64 num); +RZ_API ut64 rz_debug_reg_get(RzDebug *dbg, const char *name); + +RZ_API ut64 rz_debug_execute(RzDebug *dbg, const ut8 *buf, int len, int restore); +RZ_API bool rz_debug_map_sync(RzDebug *dbg); + +RZ_API int rz_debug_stop(RzDebug *dbg); + +/* backtrace */ +RZ_API RzList /**/ *rz_debug_frames(RzDebug *dbg, ut64 at); + +RZ_API bool rz_debug_is_dead(RzDebug *dbg); +RZ_API int rz_debug_map_protect(RzDebug *dbg, ut64 addr, int size, int perms); + +/* breakpoints (most in rz_bp, this calls those) */ +RZ_API RZ_BORROW RzBreakpointItem *rz_debug_bp_add(RZ_NONNULL RzDebug *dbg, ut64 addr, ut64 size, bool hw, bool watch, int perm, RZ_NULLABLE const char *module, st64 m_delta); +RZ_API void rz_debug_bp_rebase(RzDebug *dbg, ut64 old_base, ut64 new_base); +RZ_API void rz_debug_bp_update(RzDebug *dbg); + +/* pid */ +RZ_API void rz_debug_tracenodes_reset(RzDebug *dbg); + +RZ_API void rz_debug_trace_reset(RzDebug *dbg); +RZ_API int rz_debug_trace_pc(RzDebug *dbg, ut64 pc); +RZ_API void rz_debug_trace_op(RzDebug *dbg, RzAnalysisOp *op); +RZ_API RzDebugTracepoint *rz_debug_trace_get(RzDebug *dbg, ut64 addr); +RZ_API void rz_debug_trace_print(RzDebug *dbg, RzCmdStateOutput *state, ut64 offset); +RZ_API RZ_OWN RzList /**/ *rz_debug_traces_info(RzDebug *dbg, ut64 offset); +RZ_API void rz_debug_traces_ascii(RzDebug *dbg, ut64 offset); +RZ_API RzDebugTracepoint *rz_debug_trace_add(RzDebug *dbg, ut64 addr, int size); +RZ_API RzDebugTrace *rz_debug_trace_new(void); +RZ_API void rz_debug_trace_free(RzDebugTrace *dbg); +RZ_API int rz_debug_trace_tag(RzDebug *dbg, int tag); +RZ_API int rz_debug_child_fork(RzDebug *dbg); +RZ_API int rz_debug_child_clone(RzDebug *dbg); + +RZ_API void rz_debug_drx_list(RzDebug *dbg); +RZ_API int rz_debug_drx_set(RzDebug *dbg, int idx, ut64 addr, int len, int rwx, int g); +RZ_API int rz_debug_drx_unset(RzDebug *dbg, int idx); + +/* esil */ +RZ_API ut64 rz_debug_num_callback(RzNum *userptr, const char *str, int *ok); +RZ_API int rz_debug_esil_stepi(RzDebug *dbg); +RZ_API ut64 rz_debug_esil_step(RzDebug *dbg, ut32 count); +RZ_API ut64 rz_debug_esil_continue(RzDebug *dbg); +RZ_API void rz_debug_esil_watch(RzDebug *dbg, int rwx, int dev, const char *expr); +RZ_API void rz_debug_esil_watch_reset(RzDebug *dbg); +RZ_API RZ_BORROW RzList /**/ *rz_debug_esil_watch_list(RzDebug *dbg); +RZ_API int rz_debug_esil_watch_empty(RzDebug *dbg); +RZ_API void rz_debug_esil_prestep(RzDebug *d, int p); + +/* record & replay */ +RZ_API bool rz_debug_add_checkpoint(RzDebug *dbg); +RZ_API bool rz_debug_session_add_reg_change(RzDebugSession *session, int arena, ut64 offset, ut64 data); +RZ_API bool rz_debug_session_add_mem_change(RzDebugSession *session, ut64 addr, ut8 data); +RZ_API void rz_debug_session_restore_reg_mem(RzDebug *dbg, ut32 cnum); +RZ_API void rz_debug_session_list_memory(RzDebug *dbg); +RZ_API void rz_debug_session_serialize(RzDebugSession *session, Sdb *db); +RZ_API void rz_debug_session_deserialize(RzDebugSession *session, Sdb *db); +RZ_API bool rz_debug_session_save(RzDebugSession *session, const char *file); +RZ_API bool rz_debug_session_load(RzDebug *dbg, const char *file); +RZ_API bool rz_debug_trace_ins_before(RzDebug *dbg); +RZ_API bool rz_debug_trace_ins_after(RZ_NONNULL RzDebug *dbg); + +RZ_API RzDebugSession *rz_debug_session_new(void); +RZ_API void rz_debug_session_free(RzDebugSession *session); + +RZ_API RzDebugSnap *rz_debug_snap_map(RzDebug *dbg, RzDebugMap *map); +RZ_API bool rz_debug_snap_contains(RzDebugSnap *snap, ut64 addr); +RZ_API ut8 *rz_debug_snap_get_hash(RzDebug *dbg, RzDebugSnap *snap, RzHashSize *size); +RZ_API bool rz_debug_snap_is_equal(RzDebug *dbg, RzDebugSnap *a, RzDebugSnap *b); +RZ_API void rz_debug_snap_free(RzDebugSnap *snap); + +RZ_API int rz_debug_step_back(RzDebug *dbg, int steps); +RZ_API bool rz_debug_goto_cnum(RzDebug *dbg, ut32 cnum); +RZ_API int rz_debug_step_cnum(RzDebug *dbg, int steps); +RZ_API bool rz_debug_continue_back(RzDebug *dbg); + +RZ_API RZ_OWN RzDbgListInfo *rz_debug_listinfo_new(RZ_NULLABLE const char *name, RzInterval pitv, RzInterval vitv, int perm, RZ_NULLABLE const char *extra); +RZ_API void rz_debug_listinfo_free(RZ_NULLABLE RzDbgListInfo *info); + +/* serialize */ +RZ_API void rz_serialize_debug_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzDebug *dbg); +RZ_API bool rz_serialize_debug_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzDebug *dbg, RZ_NULLABLE RzSerializeResultInfo *res); + +/* ptrace */ +#if HAVE_PTRACE +static inline long rz_debug_ptrace(RzDebug *dbg, rz_ptrace_request_t request, pid_t pid, void *addr, rz_ptrace_data_t data) { + return dbg->iob.ptrace(dbg->iob.io, request, pid, addr, data); +} + +static inline void *rz_debug_ptrace_func(RzDebug *dbg, void *(*func)(void *), void *user) { + return dbg->iob.ptrace_func(dbg->iob.io, func, user); +} +#endif + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_demangler.h b/dest/include/librz/rz_demangler.h new file mode 100644 index 00000000000..f69d9c1a5a5 --- /dev/null +++ b/dest/include/librz/rz_demangler.h @@ -0,0 +1,61 @@ +// SPDX-FileCopyrightText: 2021 RizinOrg +// SPDX-FileCopyrightText: 2021 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_DEMANGLER_H +#define RZ_DEMANGLER_H +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_demangler); + +typedef enum { + RZ_DEMANGLER_FLAG_BASE = 0, + RZ_DEMANGLER_FLAG_SIMPLIFY = (1 << 0), + RZ_DEMANGLER_FLAG_ENABLE_ALL = (RZ_DEMANGLER_FLAG_BASE | RZ_DEMANGLER_FLAG_SIMPLIFY), +} RzDemanglerFlag; + +typedef RZ_OWN char *(*RzDemanglerPluginCb)(RZ_NONNULL const char *symbol, RzDemanglerFlag flags); + +typedef struct rz_demangler_plugin_t { + const char *language; ///< demangler language + const char *author; ///< demangler author + const char *license; ///< demangler license + RzDemanglerPluginCb demangle; ///< demangler method to resolve the mangled symbol +} RzDemanglerPlugin; + +typedef struct rz_demangler_t { + RzDemanglerFlag flags; + RzList /**/ *plugins; +} RzDemangler; + +typedef bool (*RzDemanglerIter)(const RzDemanglerPlugin *plugin, RzDemanglerFlag flags, void *data); + +#define rz_demangler_plugin_demangle(x, y, o) ((x) && RZ_STR_ISNOTEMPTY(y) ? (x)->demangle(y, o) : NULL) + +RZ_API RZ_OWN char *rz_demangler_java(RZ_NULLABLE const char *symbol, RzDemanglerFlag flags); +RZ_API RZ_OWN char *rz_demangler_cxx(RZ_NONNULL const char *symbol, RzDemanglerFlag flags); +RZ_API RZ_OWN char *rz_demangler_objc(RZ_NONNULL const char *symbol, RzDemanglerFlag flags); +RZ_API RZ_OWN char *rz_demangler_pascal(RZ_NONNULL const char *symbol, RzDemanglerFlag flags); +RZ_API RZ_OWN char *rz_demangler_rust(RZ_NONNULL const char *symbol, RzDemanglerFlag flags); +RZ_API RZ_OWN char *rz_demangler_msvc(RZ_NONNULL const char *symbol, RzDemanglerFlag flags); + +RZ_API RZ_OWN RzDemangler *rz_demangler_new(void); +RZ_API void rz_demangler_free(RZ_NULLABLE RzDemangler *demangler); +RZ_API void rz_demangler_set_flags(RZ_NONNULL RzDemangler *demangler, RzDemanglerFlag flags); +RZ_API RzDemanglerFlag rz_demangler_get_flags(RZ_NONNULL RzDemangler *demangler); +RZ_API void rz_demangler_plugin_iterate(RZ_NONNULL RzDemangler *demangler, RZ_NONNULL RzDemanglerIter iter, RZ_NULLABLE void *data); +RZ_API bool rz_demangler_plugin_add(RZ_NONNULL RzDemangler *demangler, RZ_NONNULL RzDemanglerPlugin *plugin); +RZ_API bool rz_demangler_plugin_del(RZ_NONNULL RzDemangler *demangler, RZ_NONNULL RzDemanglerPlugin *plugin); +RZ_API RZ_BORROW const RzDemanglerPlugin *rz_demangler_plugin_get(RZ_NONNULL RzDemangler *demangler, RZ_NONNULL const char *language); +RZ_API bool rz_demangler_resolve(RZ_NONNULL RzDemangler *demangler, RZ_NULLABLE const char *symbol, RZ_NONNULL const char *language, RZ_NONNULL RZ_OWN char **output); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_DEMANGLER_H */ diff --git a/dest/include/librz/rz_diff.h b/dest/include/librz/rz_diff.h new file mode 100644 index 00000000000..06b249012f6 --- /dev/null +++ b/dest/include/librz/rz_diff.h @@ -0,0 +1,104 @@ +// SPDX-FileCopyrightText: 2021 RizinOrg +// SPDX-FileCopyrightText: 2021 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_DIFF_H +#define RZ_DIFF_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_diff); + +typedef enum rz_diff_op_type_t { + RZ_DIFF_OP_INVALID = 0, + RZ_DIFF_OP_DELETE, + RZ_DIFF_OP_EQUAL, + RZ_DIFF_OP_INSERT, + RZ_DIFF_OP_REPLACE, +} RzDiffOpType; + +/** + * This interface allows to analyze any data using the same algorithm + * elem_at(array, index) [required] must return the an element of the array at position 'index' + * elem_hash(elem) [required] must return the hash value of the element (use rz_diff_hash_data) + * compare(a_elem, b_elem) [required] must return true if the two elements are the same + * stringify(elem, sb) [required] appends into sb the stringified element of the array + * ignore(elem) [optional] must return true if the element matches the user define + * rule (if set to NULL, it will be considered as always false) + */ +typedef const void *(*RzDiffMethodElemAt)(RZ_BORROW const void *array, ut32 index); +typedef ut32 (*RzDiffMethodElemHash)(RZ_BORROW const void *elem); +typedef int (*RzDiffMethodCompare)(RZ_BORROW const void *a_elem, RZ_BORROW const void *b_elem); +typedef bool (*RzDiffMethodIgnore)(RZ_BORROW const void *elem); +typedef void (*RzDiffMethodStringify)(RZ_BORROW const void *elem, RZ_BORROW RzStrBuf *sb); +typedef struct rz_diff_methods_t { + RzDiffMethodElemAt elem_at; ///< can be either be an element of A or B + RzDiffMethodElemHash elem_hash; ///< can be either be an element of A or B + RzDiffMethodCompare compare; ///< elements from A and B + RzDiffMethodStringify stringify; ///< elements from A and B + RzDiffMethodIgnore ignore; ///< elements from A and B +} RzDiffMethods; + +typedef struct rz_diff_op_t { + RzDiffOpType type; + st32 a_beg; + st32 a_end; + st32 b_beg; + st32 b_end; +} RzDiffOp; + +#define RZ_DIFF_OP_SIZE_A(op) (((op)->a_end) - ((op)->a_beg)) +#define RZ_DIFF_OP_SIZE_B(op) (((op)->b_end) - ((op)->b_beg)) +#define RZ_DIFF_DEFAULT_N_GROUPS 3 + +typedef struct match_p_t { + ut32 a; + ut32 b; + ut32 size; +} RzDiffMatch; + +typedef bool (*RzDiffIgnoreByte)(const ut64 byte); +typedef bool (*RzDiffIgnoreLine)(RZ_BORROW const char *line); + +typedef struct rz_diff_t RzDiff; + +#ifdef RZ_API + +/* To calculate the hash of a complex structure made of + * various values, xor the results before returning the final value. */ +RZ_API ut32 rz_diff_hash_data(RZ_NULLABLE const ut8 *buffer, ut32 size); + +RZ_API RZ_OWN RzDiff *rz_diff_bytes_new(RZ_BORROW const ut8 *a, ut32 a_size, RZ_BORROW const ut8 *b, ut32 b_size, RZ_NULLABLE RzDiffIgnoreByte ignore); +RZ_API RZ_OWN RzDiff *rz_diff_lines_new(RZ_BORROW const char *a, RZ_BORROW const char *b, RZ_NULLABLE RzDiffIgnoreLine ignore); +RZ_API RZ_OWN RzDiff *rz_diff_generic_new(RZ_BORROW const void *a, ut32 a_size, RZ_BORROW const void *b, ut32 b_size, RZ_NONNULL RzDiffMethods *methods); +RZ_API void rz_diff_free(RZ_NULLABLE RzDiff *diff); +RZ_API RZ_BORROW const void *rz_diff_get_a(RZ_NONNULL RzDiff *diff); +RZ_API RZ_BORROW const void *rz_diff_get_b(RZ_NONNULL RzDiff *diff); + +RZ_API RZ_OWN RzList /**/ *rz_diff_matches_new(RZ_NONNULL RzDiff *diff); +RZ_API RZ_OWN RzList /**/ *rz_diff_opcodes_new(RZ_NONNULL RzDiff *diff); +RZ_API RZ_OWN RzList /* *>*/ *rz_diff_opcodes_grouped_new(RZ_NONNULL RzDiff *diff, ut32 n_groups); +RZ_API bool rz_diff_ratio(RZ_NONNULL RzDiff *diff, RZ_NONNULL double *result); +RZ_API bool rz_diff_sizes_ratio(RZ_NONNULL RzDiff *diff, RZ_NONNULL double *result); + +RZ_API RZ_OWN char *rz_diff_unified_text(RZ_NONNULL RzDiff *diff, RZ_NULLABLE const char *from, RZ_NULLABLE const char *to, bool show_time, bool color); +RZ_API RZ_OWN PJ *rz_diff_unified_json(RZ_NONNULL RzDiff *diff, RZ_NULLABLE const char *from, RZ_NULLABLE const char *to, bool show_time); + +/* Distances algorithms */ +RZ_API bool rz_diff_myers_distance(RZ_NONNULL const ut8 *a, ut32 size_a, RZ_NONNULL const ut8 *b, ut32 size_b, RZ_NULLABLE ut32 *distance, RZ_NULLABLE double *similarity); +RZ_API bool rz_diff_levenshtein_distance(RZ_NONNULL const ut8 *a, ut32 size_a, RZ_NONNULL const ut8 *b, ut32 size_b, RZ_NULLABLE ut32 *distance, RZ_NULLABLE double *similarity); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_DIFF_H */ diff --git a/dest/include/librz/rz_egg.h b/dest/include/librz/rz_egg.h new file mode 100644 index 00000000000..b255b2a8831 --- /dev/null +++ b/dest/include/librz/rz_egg.h @@ -0,0 +1,242 @@ +#ifndef RZ_EGG_H +#define RZ_EGG_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_egg); + +#define RZ_EGG_INCDIR_ENV "EGG_INCDIR" +#define RZ_EGG_INCDIR_PATH "/lib/rizin/" RZ_VERSION "/egg" + +// rename to RzEggShellcode +#define RZ_EGG_PLUGIN_SHELLCODE 0 +#define RZ_EGG_PLUGIN_ENCODER 1 + +typedef struct rz_egg_plugin_t { + const char *name; + const char *desc; + int type; + RzBuffer *(*build)(void *egg); +} RzEggPlugin; + +typedef struct rz_egg_lang_t { + int pushargs; + int nalias; + int nsyscalls; + char *conditionstr; + char *syscallbody; + char *includefile; + char *setenviron; + char *mathline; + // used for confusing mathop + int commentmode; + int varsize; + int varxs; + int lastctxdelta; + int nargs; + int docall; + int nfunctions; + int nbrackets; + int slurpin; + int slurp; + int line; + char elem[1024]; + int attsyntax; + int elem_n; + char *callname; + char *endframe; + char *ctxpush[32]; + char *file; + char *dstvar; + char *dstval; + char *includedir; + char *ifelse_table[32][32]; + // used to solve if-else problem in a not so ugly way + int ndstval; + int skipline; // BOOL + int quoteline; + int quotelinevar; + int stackframe; + int stackfixed; + int oc; + int mode; + int inlinectr; + struct { + char *name; + char *body; + // int fastcall; /* TODO: NOT YET USED */ + } inlines[256]; + int ninlines; + struct { + char *name; + char *arg; + } syscalls[256]; + struct { + char *name; + char *content; + } aliases[256]; + char *nested[32]; + char *nested_callname[32]; + // char *nestede[32] = {0}; + // seems nestede are not used any more + // (only one place that gives nestede[] value, where could be replaced) + int nestedi[32]; +} RzEggLang; + +typedef struct rz_egg_t { + RzBuffer *src; + RzBuffer *buf; + RzBuffer *bin; + // RzList *shellcodes; // XXX is plugins nao? + RzAsm *rasm; + RzSyscall *syscall; + RzEggLang lang; + Sdb *db; + HtSP /**/ *plugins; + RzList /**/ *patches; // + RzPath *sys_path; ///< pointer to RzPath, contains path prefix of the system + struct rz_egg_emit_t *remit; + int arch; + int endian; + int bits; + ut32 os; + int context; +} RzEgg; + +#define RZ_EGG_OS_LINUX 0x5ca62a43 +#define RZ_EGG_OS_OSX 0x0ad593a1 +#define RZ_EGG_OS_DARWIN 0xd86d1ae2 +#define RZ_EGG_OS_WATCHOS 0x14945c70 +#define RZ_EGG_OS_IOS 0x0ad58830 +#define RZ_EGG_OS_MACOS 0x5cb23c16 +#define RZ_EGG_OS_W32 0x0ad5fbb3 +#define RZ_EGG_OS_WINDOWS 0x05b7de9a +#define RZ_EGG_OS_BEOS 0x506108be +#define RZ_EGG_OS_FREEBSD 0x73a72944 + +#if __APPLE__ +#define RZ_EGG_OS_DEFAULT RZ_EGG_OS_OSX +#define RZ_EGG_OS_NAME "darwin" +#define RZ_EGG_FORMAT_DEFAULT "mach0" +#elif __WINDOWS__ +#define RZ_EGG_OS_DEFAULT RZ_EGG_OS_W32 +#define RZ_EGG_OS_NAME "windows" +#define RZ_EGG_FORMAT_DEFAULT "pe" +#else +#define RZ_EGG_OS_DEFAULT RZ_EGG_OS_LINUX +#define RZ_EGG_OS_NAME "linux" +#define RZ_EGG_FORMAT_DEFAULT "elf" +#endif + +typedef struct rz_egg_emit_t RzEggEmit; +struct rz_egg_emit_t { + const char *arch; + int size; /* in bytes.. 32bit arch is 4, 64bit is 8 .. */ + const char *retvar; + // const char *syscall_body; + const char *(*regs)(RzEgg *egg, int idx); + void (*init)(RzEgg *egg); + void (*begin)(RzEgg *egg); + void (*fini)(RzEggEmit *egg_emit); + void (*call)(RzEgg *egg, const char *addr, int ptr); + void (*jmp)(RzEgg *egg, const char *addr, int ptr); + // void (*sc)(int num); + void (*frame)(RzEgg *egg, int sz); + char *(*syscall)(RzEgg *egg, int num); + void (*trap)(RzEgg *egg); + void (*frame_end)(RzEgg *egg, int sz, int ctx); + void (*comment)(RzEgg *egg, const char *fmt, ...); + void (*push_arg)(RzEgg *egg, int xs, int num, const char *str); + void (*set_string)(RzEgg *egg, const char *dstvar, const char *str, int j); + void (*equ)(RzEgg *egg, const char *key, const char *value); + void (*get_result)(RzEgg *egg, const char *ocn); + void (*restore_stack)(RzEgg *egg, int size); + void (*syscall_args)(RzEgg *egg, int nargs); + void (*get_var)(RzEgg *egg, int type, char *out, int idx); + void (*get_ar)(RzEgg *egg, char *out, int idx); + void (*while_end)(RzEgg *egg, const char *label); + void (*load)(RzEgg *egg, const char *str, int sz); + void (*load_ptr)(RzEgg *egg, const char *str); + void (*branch)(RzEgg *egg, char *b, char *g, char *e, char *n, int sz, const char *dst); + void (*mathop)(RzEgg *egg, int ch, int sz, int type, const char *eq, const char *p); + void (*get_while_end)(RzEgg *egg, char *out, const char *ctxpush, const char *label); + void *emit_context; ///< May holds the context data of each emit type +}; + +/** + * \brief Compare plugins by name (via strcmp). + */ +static inline int rz_egg_plugin_cmp(RZ_NULLABLE const RzEggPlugin *a, RZ_NULLABLE const RzEggPlugin *b) { + if (!a && !b) { + return 0; + } else if (!a) { + return -1; + } else if (!b) { + return 1; + } + return rz_str_cmp(a->name, b->name, -1); +} + +#ifdef RZ_API + +/* egg.c */ +RZ_API RzEgg *rz_egg_new(void); +RZ_API const char *rz_egg_os_as_string(int os); +RZ_API char *rz_egg_to_string(RzEgg *egg); +RZ_API void rz_egg_free(RzEgg *egg); +RZ_API bool rz_egg_plugin_add(RzEgg *a, RZ_NONNULL RzEggPlugin *plugin); +RZ_API bool rz_egg_plugin_del(RzEgg *a, RZ_NONNULL RzEggPlugin *plugin); +RZ_API void rz_egg_reset(RzEgg *egg); +RZ_API bool rz_egg_setup(RzEgg *egg, const char *arch, int bits, int endian, const char *os); +RZ_API int rz_egg_include(RzEgg *egg, const char *file, int format); +RZ_API void rz_egg_load(RzEgg *egg, const char *code, int format); +RZ_API bool rz_egg_load_file(RzEgg *egg, const char *file); +RZ_API void rz_egg_syscall(RzEgg *egg, const char *arg, ...) RZ_PRINTF_CHECK(2, 3); +RZ_API void rz_egg_label(RzEgg *egg, const char *name); +RZ_API int rz_egg_raw(RzEgg *egg, const ut8 *b, int len); +RZ_API int rz_egg_encode(RZ_NONNULL RZ_BORROW RzEgg *egg, const char *name); +RZ_API int rz_egg_shellcode(RZ_NONNULL RZ_BORROW RzEgg *egg, const char *name); +#define rz_egg_get_shellcodes(x) x->plugins +RZ_API void rz_egg_option_set(RzEgg *egg, const char *k, const char *v); +RZ_API char *rz_egg_option_get(RzEgg *egg, const char *k); +RZ_API void rz_egg_printf(RzEgg *egg, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); +RZ_API int rz_egg_compile(RzEgg *egg); +RZ_API int rz_egg_padding(RzEgg *egg, const char *pad); +RZ_API bool rz_egg_assemble(RzEgg *egg); +RZ_API bool rz_egg_assemble_asm(RzEgg *egg, char **asm_list); +RZ_API bool rz_egg_pattern(RzEgg *egg, int size); +RZ_API char *rz_egg_get_source(RzEgg *egg); +RZ_API RzBuffer *rz_egg_get_bin(RzEgg *egg); +RZ_API char *rz_egg_get_assembly(RzEgg *egg); +RZ_API void rz_egg_append(RzEgg *egg, const char *src); +RZ_API int rz_egg_run(RzEgg *egg); +RZ_API int rz_egg_run_rop(RzEgg *egg); +RZ_API int rz_egg_patch(RzEgg *egg, int off, const ut8 *b, int l); +RZ_API bool rz_egg_patch_num(RzEgg *egg, int off, ut64 val, ut32 bits); +RZ_API void rz_egg_finalize(RzEgg *egg); + +/* egg_c_compile.c */ +RZ_API RZ_OWN char *rz_egg_compile_c_source(RZ_NONNULL const char *source_file, RZ_NONNULL const char *arch, RZ_NONNULL const char *os, int bits, RZ_BORROW RZ_NONNULL RzPath *sys_path); + +/* egg_lang.c */ +RZ_API void rz_egg_lang_init(RzEgg *egg); +RZ_API void rz_egg_lang_free(RzEgg *egg); +RZ_API char *rz_egg_lang_mkvar(RzEgg *egg, char *out, const char *_str, int delta); +RZ_API int rz_egg_lang_parsechar(RzEgg *egg, char c); +RZ_API void rz_egg_lang_include_path(RzEgg *egg, const char *path); +RZ_API void rz_egg_lang_include_init(RzEgg *egg); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_endian.h b/dest/include/librz/rz_endian.h new file mode 100644 index 00000000000..73dfb65aa06 --- /dev/null +++ b/dest/include/librz/rz_endian.h @@ -0,0 +1,2210 @@ +/** \internal + * \file + * \brief Utilities for values represented in various endian orders. + */ +#ifndef RZ_ENDIAN_H +#define RZ_ENDIAN_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Endian agnostic functions working on single byte. */ + +/** + * \brief Read the first byte from \p src. + * \param src The pointer from which a byte is read. + * \return The read byte value. + * \attention If \p src is \c NULL then \c UT8_MAX is returned. + */ +static inline ut8 rz_read_ble8(const void *src) { + if (!src) { + return UT8_MAX; + } + return *(const ut8 *)src; +} + +/** + * \brief Read the first byte from \p src at \p offset. + * \param src The pointer from which a byte is read. + * \param offset The offset at which the byte is read. + * \return The read byte value. + * \attention If \p src is \c NULL then \c UT8_MAX is returned. + */ +static inline ut8 rz_read_at_ble8(const void *src, size_t offset) { + if (!src) { + return UT8_MAX; + } + return rz_read_ble8(((const ut8 *)src) + offset); +} + +/** + * \brief Write a byte to \p dest. + * \param[out] dest The pointer to which a byte is written. + * \param val The written byte value. + */ +static inline void rz_write_ble8(void *dest, ut8 val) { + *(ut8 *)dest = val; +} + +/** + * \brief Write a byte to \p dest at \p offset. + * \param[out] dest The pointer to which a byte is written. + * \param val The written byte value. + * \param offset The offset at which the byte is written. + */ +static inline void rz_write_at_ble8(void *dest, ut8 val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_ble8(d, val); +} + +/* Big Endian functions. */ + +/** + * \brief Read the first byte from \p src. + * \param src The pointer from which a byte is read. + * \return The read byte value. + * \attention If \p src is \c NULL then \c UT8_MAX is returned. + */ +static inline ut8 rz_read_be8(const void *src) { + return rz_read_ble8(src); +} + +/** + * \brief Read the first byte from \p src at \p offset. + * \param src The pointer from which a byte is read. + * \param offset The offset at which the byte is read. + * \return The read byte value. + * \attention If \p src is \c NULL then \c UT8_MAX is returned. + */ +static inline ut8 rz_read_at_be8(const void *src, size_t offset) { + return rz_read_at_ble8(src, offset); +} + +/** + * \brief Write a byte to \p dest. + * \param[out] dest The pointer to which a byte is written. + * \param val The written byte value. + */ +static inline void rz_write_be8(void *dest, ut8 val) { + rz_write_ble8(dest, val); +} + +/** + * \brief Write a byte to \p dest at \p offset. + * \param[out] dest The pointer to which a byte is written. + * \param val The written byte value. + * \param offset The offset at which the byte is written. + */ +static inline void rz_write_at_be8(void *dest, ut8 val, size_t offset) { + rz_write_at_ble8(dest, val, offset); +} + +/** + * \brief Read a 16-bit value from \p src in big-endian order. + * \param src The pointer from which the value is read. + * \return The read 16-bit value. + * \attention If \p src is \c NULL then \c UT16_MAX is returned. + */ +static inline ut16 rz_read_be16(const void *src) { + if (!src) { + return UT16_MAX; + } + const ut8 *s = (const ut8 *)src; + return (((ut16)s[0]) << 8) | (((ut16)s[1]) << 0); +} + +/** + * \brief Read a 16-bit value from \p src at \p offset in big-endian order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \return The read 16-bit value. + * \attention If \p src is \c NULL then \c UT16_MAX is returned. + */ +static inline ut16 rz_read_at_be16(const void *src, size_t offset) { + if (!src) { + return UT16_MAX; + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_be16(s); +} + +/** + * \brief Write a 16-bit value to \p dest in big-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 16-bit value. + */ +static inline void rz_write_be16(void *dest, ut16 val) { + rz_write_be8(dest, val >> 8); + rz_write_at_be8(dest, (ut8)val, sizeof(ut8)); +} + +/** + * \brief Write a 16-bit value to \p dest in big-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 16-bit value. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_be16(void *dest, ut16 val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_be16(d, val); +} + +/** + * \brief Read a 24-bit value from \p src in big-endian order. + * \param src The pointer from which the value is read. + * \return The read 24-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + */ +static inline ut32 rz_read_be24(const void *src) { + if (!src) { + return UT32_MAX; + } + return rz_read_be8(src) << 16 | rz_read_be8((const ut8 *)src + 1) << 8 | + rz_read_be8((const ut8 *)src + 2); +} + +/** + * \brief Read a 24-bit value from \p src at \p offset in big-endian order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \return The read 24-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + */ +static inline ut32 rz_read_at_be24(const void *src, size_t offset) { + if (!src) { + return UT32_MAX; + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_be24(s); +} + +/** + * \brief Write a 24-bit value to \p dest in big-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 24-bit value. + */ +static inline void rz_write_be24(void *dest, ut32 val) { + ut8 *_dest = (ut8 *)dest; + rz_write_be8(_dest++, val >> 16); + rz_write_be8(_dest++, val >> 8); + rz_write_be8(_dest, val); +} + +/** + * \brief Write a 24-bit value to \p dest in big-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 24-bit value. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_be24(void *dest, ut32 val, size_t offset) { + ut8 *_dest = (ut8 *)dest + offset; + rz_write_be24(_dest, val); +} + +/** + * \brief Read a 32-bit value from \p src in big-endian order. + * \param src The pointer from which the value is read. + * \return The read 32-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + */ +static inline ut32 rz_read_be32(const void *src) { + if (!src) { + return UT32_MAX; + } +#if RZ_HOST_IS_BIG_ENDIAN + ut32 val = 0; + memcpy(&val, src, sizeof(val)); + return val; +#else + const ut8 *s = (const ut8 *)src; + return (((ut32)s[0]) << 24) | (((ut32)s[1]) << 16) | + (((ut32)s[2]) << 8) | (((ut32)s[3]) << 0); +#endif +} + +/** + * \brief Read a 32-bit value from \p src at \p offset in big-endian order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \return The read 32-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + */ +static inline ut32 rz_read_at_be32(const void *src, size_t offset) { + if (!src) { + return UT32_MAX; + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_be32(s); +} + +/** + * \brief Write a 32-bit value to \p dest in big-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 32-bit value. + */ +static inline void rz_write_be32(void *dest, ut32 val) { +#if RZ_HOST_IS_BIG_ENDIAN + memcpy(dest, &val, sizeof(val)); +#else + rz_write_be16(dest, val >> 16); + rz_write_at_be16(dest, val, sizeof(ut16)); +#endif +} + +/** + * \brief Write a 32-bit value to \p dest in big-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 32-bit value. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_be32(void *dest, ut32 val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_be32(d, val); +} + +/** + * \brief Read a 64-bit value from \p src in big-endian order. + * \param src The pointer from which the value is read. + * \return The read 64-bit value. + * \attention If \p src is \c NULL then \c UT64_MAX is returned. + */ +static inline ut64 rz_read_be64(const void *src) { + if (!src) { + return UT64_MAX; + } +#if RZ_HOST_IS_BIG_ENDIAN + ut64 val = 0; + memcpy(&val, src, sizeof(val)); + return val; +#else + ut64 val = ((ut64)(rz_read_be32(src))) << 32; + val |= rz_read_at_be32(src, sizeof(ut32)); + return val; +#endif +} + +/** + * \brief Read a 64-bit value from \p src at \p offset in big-endian order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \return The read 64-bit value. + * \attention If \p src is \c NULL then \c UT64_MAX is returned. + */ +static inline ut64 rz_read_at_be64(const void *src, size_t offset) { + if (!src) { + return UT64_MAX; + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_be64(s); +} + +/** + * \brief Write a 64-bit value to \p dest in big-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 64-bit value. + */ +static inline void rz_write_be64(void *dest, ut64 val) { +#if RZ_HOST_IS_BIG_ENDIAN + memcpy(dest, &val, sizeof(val)); +#else + rz_write_be32(dest, val >> 32); + rz_write_at_be32(dest, (ut32)val, sizeof(ut32)); +#endif +} + +/** + * \brief Write a 64-bit value to \p dest in big-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 64-bit value. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_be64(void *dest, ut64 val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_be64(d, val); +} + +/** + * \brief Read a 128-bit value from \p src in big-endian order. + * \param src The pointer from which the value is read. + * \return The read 128-bit value. + * \attention If \p src is \c NULL then the maximum 128-bit value is + * returned. + */ +static inline ut128 rz_read_be128(const void *src) { + ut128 val; + if (!src) { + val.High = UT64_MAX; + val.Low = UT64_MAX; + return val; + } + val.High = rz_read_be64(src); + val.Low = rz_read_at_be64(src, sizeof(ut64)); + return val; +} + +/** + * \brief Read a 128-bit value from \p src at \p offset in big-endian order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \return The read 128-bit value. + * \attention If \p src is \c NULL then the maximum 128-bit value is + * returned. + */ +static inline ut128 rz_read_at_be128(const void *src, size_t offset) { + if (!src) { + ut128 val; + val.High = UT64_MAX; + val.Low = UT64_MAX; + return val; + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_be128(s); +} + +/** + * \brief Write a 128-bit value to \p dest in big-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 128-bit value. + */ +static inline void rz_write_be128(void *dest, ut128 val) { + rz_write_be64(dest, val.High); + rz_write_at_be64(dest, val.Low, sizeof(ut64)); +} + +/** + * \brief Write a 128-bit value to \p dest in big-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 128-bit value. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_be128(void *dest, ut128 val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_be128(d, val); +} + +/** + * \brief Interpret a 32-bit value read in big-endian order as floating-point. + * \param src The buffer to read the unsigned integer in big-endian order from. + * \return The floating-point value with representation equal to that + * of the unsigned 32-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + */ +static inline float rz_read_be_float(const void *src) { + union { + ut32 bits; + float flt; + } p; + p.bits = rz_read_be32(src); + return p.flt; +} + +/** + * \brief Interpret a 32-bit value read in big-endian order as floating-point. + * \param src The buffer to read the unsigned integer in big-endian order from. + * \param offset The offset at which the value is read. + * \return The floating-point value with representation equal to that + * of the unsigned 32-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + */ +static inline float rz_read_at_be_float(const void *src, size_t offset) { + if (!src) { + return rz_read_be_float(NULL); + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_be_float(s); +} + +/** + * \brief Write a 32-bit floating-point to \p dest in big-endian order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + */ +static inline void rz_write_be_float(void *dest, float val) { + union { + ut32 bits; + float flt; + } p; + p.flt = val; + rz_write_be32(dest, p.bits); +} + +/** + * \brief Write a 32-bit floating-point to \p dest in big-endian order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_be_float(void *dest, float val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_be_float(d, val); +} + +/** + * \brief Interpret a 64-bit value read in big-endian order as floating-point. + * \param src The buffer to read the unsigned integer in big-endian order from. + * \return The floating-point value with representation equal to that + * of the unsigned 64-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + */ +static inline double rz_read_be_double(const void *src) { + union { + ut64 bits; + double dbl; + } p; + p.bits = rz_read_be64(src); + return p.dbl; +} + +/** + * \brief Interpret a 64-bit value read in big-endian order as floating-point. + * \param src The buffer to read the unsigned integer in big-endian order from. + * \param offset The offset at which the value is read. + * \return The floating-point value with representation equal to that + * of the unsigned 64-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + */ +static inline double rz_read_at_be_double(const void *src, size_t offset) { + if (!src) { + return rz_read_be_double(NULL); + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_be_double(s); +} + +/** + * \brief Write a 64-bit floating-point to \p dest in big-endian order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + */ +static inline void rz_write_be_double(void *dest, double val) { + union { + ut64 bits; + double dbl; + } p; + p.dbl = val; + rz_write_be64(dest, p.bits); +} + +/** + * \brief Write a 64-bit floating-point to \p dest in big-endian order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_be_double(void *dest, double val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_be_double(d, val); +} + +/* Little Endian functions. */ + +/** + * \brief Read the first byte from \p src. + * \param src The pointer from which a byte is read. + * \return The read byte value. + * \attention If \p src is \c NULL then \c UT8_MAX is returned. + */ +static inline ut8 rz_read_le8(const void *src) { + return rz_read_ble8(src); +} + +/** + * \brief Read the first byte from \p src at \p offset. + * \param src The pointer from which a byte is read. + * \param offset The offset at which the byte is read. + * \return The read byte value. + * \attention If \p src is \c NULL then \c UT8_MAX is returned. + */ +static inline ut8 rz_read_at_le8(const void *src, size_t offset) { + return rz_read_at_ble8(src, offset); +} + +/** + * \brief Write a byte to \p dest. + * \param[out] dest The pointer to which a byte is written. + * \param val The written byte value. + */ +static inline void rz_write_le8(void *dest, ut8 val) { + rz_write_ble8(dest, val); +} + +/** + * \brief Write a byte to \p dest at \p offset. + * \param[out] dest The pointer to which a byte is written. + * \param val The written byte value. + * \param offset The offset at which the byte is written. + */ +static inline void rz_write_at_le8(void *dest, ut8 val, size_t offset) { + rz_write_at_ble8(dest, val, offset); +} + +/** + * \brief Read a 16-bit value from \p src in little-endian order. + * \param src The pointer from which the value is read. + * \return The read 16-bit value. + * \attention If \p src is \c NULL then \c UT16_MAX is returned. + */ +static inline ut16 rz_read_le16(const void *src) { + if (!src) { + return UT16_MAX; + } + const ut8 *s = (const ut8 *)src; + return (((ut16)s[1]) << 8) | (((ut16)s[0]) << 0); +} + +/** + * \brief Read a 16-bit value from \p src at \p offset in little-endian order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \return The read 16-bit value. + * \attention If \p src is \c NULL then \c UT16_MAX is returned. + */ +static inline ut16 rz_read_at_le16(const void *src, size_t offset) { + if (!src) { + return UT16_MAX; + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_le16(s); +} + +/** + * \brief Write a 16-bit value to \p dest in little-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 16-bit value. + */ +static inline void rz_write_le16(void *dest, ut16 val) { + rz_write_le8(dest, (ut8)val); + rz_write_at_le8(dest, val >> 8, sizeof(ut8)); +} + +/** + * \brief Write a 16-bit value to \p dest in little-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 16-bit value. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_le16(void *dest, ut16 val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_le16(d, val); +} + +/** + * \brief Read a 24-bit value from \p src in little-endian order. + * \param src The pointer from which the value is read. + * \return The read 24-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + */ +static inline ut32 rz_read_le24(const void *src) { + if (!src) { + return UT32_MAX; + } + return rz_read_at_le8(src, 0) | rz_read_at_le8(src, 1) << 8 | + rz_read_at_le8(src, 2) << 16; +} + +/** + * \brief Read a 24-bit value from \p src at \p offset in little-endian order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \return The read 24-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + */ +static inline ut32 rz_read_at_le24(const void *src, size_t offset) { + if (!src) { + return UT32_MAX; + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_le24(s); +} + +/** + * \brief Write a 24-bit value to \p dest in little-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 24-bit value. + */ +static inline void rz_write_le24(void *dest, ut32 val) { + ut8 *_dest = (ut8 *)dest; + rz_write_le8(_dest++, val); + rz_write_le8(_dest++, val >> 8); + rz_write_le8(_dest, val >> 16); +} + +/** + * \brief Write a 24-bit value to \p dest in little-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 24-bit value. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_le24(void *dest, ut32 val, size_t offset) { + ut8 *_dest = (ut8 *)dest + offset; + rz_write_le24(_dest, val); +} + +/** + * \brief Read a 32-bit value from \p src in little-endian order. + * \param src The pointer from which the value is read. + * \return The read 32-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + */ +static inline ut32 rz_read_le32(const void *src) { + if (!src) { + return UT32_MAX; + } +#if RZ_HOST_IS_LITTLE_ENDIAN + ut32 val = 0; + memcpy(&val, src, sizeof(val)); + return val; +#else + const ut8 *s = (const ut8 *)src; + return (((ut32)s[3]) << 24) | (((ut32)s[2]) << 16) | + (((ut32)s[1]) << 8) | (((ut32)s[0]) << 0); +#endif +} + +/** + * \brief Read a 32-bit value from \p src at \p offset in little-endian order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \return The read 32-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + */ +static inline ut32 rz_read_at_le32(const void *src, size_t offset) { + if (!src) { + return UT32_MAX; + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_le32(s); +} + +/** + * \brief Write a 32-bit value to \p dest in little-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 32-bit value. + */ +static inline void rz_write_le32(void *dest, ut32 val) { +#if RZ_HOST_IS_LITTLE_ENDIAN + memcpy(dest, &val, sizeof(val)); +#else + rz_write_le16(dest, val); + rz_write_at_le16(dest, val >> 16, sizeof(ut16)); +#endif +} + +/** + * \brief Write a 32-bit value to \p dest in little-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 32-bit value. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_le32(void *dest, ut32 val, size_t offset) { + ut8 *d = ((ut8 *)dest) + offset; + rz_write_le32(d, val); +} + +/** + * \brief Read a 64-bit value from \p src in little-endian order. + * \param src The pointer from which the value is read. + * \return The read 64-bit value. + * \attention If \p src is \c NULL then \c UT64_MAX is returned. + */ +static inline ut64 rz_read_le64(const void *src) { + if (!src) { + return UT64_MAX; + } +#if RZ_HOST_IS_LITTLE_ENDIAN + ut64 val = 0; + memcpy(&val, src, sizeof(val)); + return val; +#else + ut64 val = ((ut64)(rz_read_at_le32(src, sizeof(ut32)))) << 32; + val |= rz_read_le32(src); + return val; +#endif +} + +/** + * \brief Read a 64-bit value from \p src at \p offset in little-endian order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \return The read 64-bit value. + * \attention If \p src is \c NULL then \c UT64_MAX is returned. + */ +static inline ut64 rz_read_at_le64(const void *src, size_t offset) { + if (!src) { + return UT64_MAX; + } + const ut8 *s = ((const ut8 *)src) + offset; + return rz_read_le64(s); +} + +/** + * \brief Write a 64-bit value to \p dest in little-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 64-bit value. + */ +static inline void rz_write_le64(void *dest, ut64 val) { +#if RZ_HOST_IS_LITTLE_ENDIAN + memcpy(dest, &val, sizeof(val)); +#else + rz_write_le32(dest, (ut32)val); + rz_write_at_le32(dest, val >> 32, sizeof(ut32)); +#endif +} + +/** + * \brief Write a 64-bit value to \p dest in little-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 64-bit value. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_le64(void *dest, ut64 val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_le64(d, val); +} + +/** + * \brief Read a 128-bit value from \p src in little-endian order. + * \param src The pointer from which the value is read. + * \return The read 128-bit value. + * \attention If \p src is \c NULL then the maximum 128-bit value is + * returned. + */ +static inline ut128 rz_read_le128(const void *src) { + ut128 val; + if (!src) { + val.High = UT64_MAX; + val.Low = UT64_MAX; + return val; + } +#if RZ_HOST_IS_LITTLE_ENDIAN + memcpy(&val, src, sizeof(val)); + return val; +#else + val.High = rz_read_at_le64(src, sizeof(ut64)); + val.Low = rz_read_le64(src); + return val; +#endif +} + +/** + * \brief Read a 128-bit value from \p src at \p offset in little-endian order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \return The read 128-bit value. + * \attention If \p src is \c NULL then the maximum 128-bit value is + * returned. + */ +static inline ut128 rz_read_at_le128(const void *src, size_t offset) { + if (!src) { + ut128 val; + val.High = UT64_MAX; + val.Low = UT64_MAX; + return val; + } + const ut8 *s = ((const ut8 *)src) + offset; + return rz_read_le128(s); +} + +/** + * \brief Write a 128-bit value to \p dest in little-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 128-bit value. + */ +static inline void rz_write_le128(void *dest, ut128 val) { +#if RZ_HOST_IS_LITTLE_ENDIAN + memcpy(dest, &val, sizeof(val)); +#else + rz_write_le64(dest, val.Low); + rz_write_at_le64(dest, val.High, sizeof(ut64)); +#endif +} + +/** + * \brief Write a 128-bit value to \p dest in little-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 128-bit value. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_le128(void *dest, ut128 val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_le128(d, val); +} + +/** + * \brief Interpret a 32-bit value read in little-endian order as floating-point. + * \param src The buffer to read the unsigned integer in little-endian order from. + * \return The floating-point value with representation equal to that + * of the unsigned 32-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + */ +static inline float rz_read_le_float(const void *src) { + union { + ut32 bits; + float flt; + } p; + p.bits = rz_read_le32(src); + return p.flt; +} + +/** + * \brief Interpret a 32-bit value read in little-endian order as floating-point. + * \param src The buffer to read the unsigned integer in little-endian order from. + * \param offset The offset at which the value is read. + * \return The floating-point value with representation equal to that + * of the unsigned 32-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + */ +static inline float rz_read_at_le_float(const void *src, size_t offset) { + if (!src) { + return rz_read_le_float(NULL); + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_le_float(s); +} + +/** + * \brief Write a 32-bit floating-point to \p dest in little-endian order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + */ +static inline void rz_write_le_float(void *dest, float val) { + union { + ut32 bits; + float flt; + } p; + p.flt = val; + rz_write_le32(dest, p.bits); +} + +/** + * \brief Write a 32-bit floating-point to \p dest in little-endian order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_le_float(void *dest, float val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_le_float(d, val); +} + +/** + * \brief Interpret a 64-bit value read in little-endian order as floating-point. + * \param src The buffer to read the unsigned integer in little-endian order from. + * \return The floating-point value with representation equal to that + * of the unsigned 64-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + */ +static inline double rz_read_le_double(const void *src) { + union { + ut64 bits; + double dbl; + } p; + p.bits = rz_read_le64(src); + return p.dbl; +} + +/** + * \brief Interpret a 64-bit value read in little-endian order as floating-point. + * \param src The buffer to read the unsigned integer in little-endian order from. + * \param offset The offset at which the value is read. + * \return The floating-point value with representation equal to that + * of the unsigned 64-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + */ +static inline double rz_read_at_le_double(const void *src, size_t offset) { + if (!src) { + return rz_read_le_double(NULL); + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_le_double(s); +} + +/** + * \brief Write a 64-bit floating-point to \p dest in little-endian order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + */ +static inline void rz_write_le_double(void *dest, double val) { + union { + ut64 bits; + double dbl; + } p; + p.dbl = val; + rz_write_le64(dest, p.bits); +} + +/** + * \brief Write a 64-bit floating-point to \p dest in little-endian order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_le_double(void *dest, double val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_le_double(d, val); +} + +/* Middle Endian functions. */ + +/** + * \brief Read the first byte from \p src. + * \param src The pointer from which a byte is read. + * \return The read byte value. + * \attention If \p src is \c NULL then \c UT8_MAX is returned. + */ +static inline ut8 rz_read_me8(const void *src) { + return rz_read_ble8(src); +} + +/** + * \brief Read the first byte from \p src at \p offset. + * \param src The pointer from which a byte is read. + * \param offset The offset at which the byte is read. + * \return The read byte value. + * \attention If \p src is \c NULL then \c UT8_MAX is returned. + */ +static inline ut8 rz_read_at_me8(const void *src, size_t offset) { + return rz_read_at_ble8(src, offset); +} + +/** + * \brief Write a byte to \p dest. + * \param[out] dest The pointer to which a byte is written. + * \param val The written byte value. + */ +static inline void rz_write_me8(void *dest, ut8 val) { + rz_write_ble8(dest, val); +} + +/** + * \brief Write a byte to \p dest at \p offset. + * \param[out] dest The pointer to which a byte is written. + * \param val The written byte value. + * \param offset The offset at which the byte is written. + */ +static inline void rz_write_at_me8(void *dest, ut8 val, size_t offset) { + rz_write_at_ble8(dest, val, offset); +} + +/** + * \brief Read a 16-bit value from \p src in middle-endian order. + * \param src The pointer from which the value is read. + * \return The read 16-bit value. + * \attention If \p src is \c NULL then \c UT16_MAX is returned. + */ +static inline ut16 rz_read_me16(const void *src) { + if (!src) { + return UT16_MAX; + } + const ut8 *s = (const ut8 *)src; + return (((ut16)s[0]) << 8) | (((ut16)s[1]) << 0); +} + +/** + * \brief Read a 16-bit value from \p src at \p offset in middle-endian order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \return The read 16-bit value. + * \attention If \p src is \c NULL then \c UT16_MAX is returned. + */ +static inline ut16 rz_read_at_me16(const void *src, size_t offset) { + if (!src) { + return UT16_MAX; + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_me16(s); +} + +/** + * \brief Write a 16-bit value to \p dest in middle-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 16-bit value. + */ +static inline void rz_write_me16(void *dest, ut16 val) { + rz_write_me8(dest, val >> 8); + rz_write_at_me8(dest, (ut8)val, sizeof(ut8)); +} + +/** + * \brief Write a 16-bit value to \p dest in middle-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 16-bit value. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_me16(void *dest, ut16 val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_me16(d, val); +} + +/** + * \brief Read a 32-bit value from \p src in middle-endian order. + * \param src The pointer from which the value is read. + * \return The read 32-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + */ +static inline ut32 rz_read_me32(const void *src) { + if (!src) { + return UT32_MAX; + } + const ut8 *s = (const ut8 *)src; + return (((ut32)s[2]) << 24) | (((ut32)s[3]) << 16) | + (((ut32)s[0]) << 8) | (((ut32)s[1]) << 0); +} + +/** + * \brief Read a 32-bit value from \p src at \p offset in middle-endian order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \return The read 32-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + */ +static inline ut32 rz_read_at_me32(const void *src, size_t offset) { + if (!src) { + return UT32_MAX; + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_me32(s); +} + +/** + * \brief Write a 32-bit value to \p dest in middle-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 32-bit value. + */ +static inline void rz_write_me32(void *dest, ut32 val) { + rz_write_me16(dest, val); + rz_write_at_me16(dest, val >> 16, sizeof(ut16)); +} + +/** + * \brief Write a 32-bit value to \p dest in middle-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 32-bit value. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_me32(void *dest, ut32 val, size_t offset) { + ut8 *d = ((ut8 *)dest) + offset; + rz_write_me32(d, val); +} + +/** + * \brief Read a 64-bit value from \p src in middle-endian order. + * \param src The pointer from which the value is read. + * \return The read 64-bit value. + * \attention If \p src is \c NULL then \c UT64_MAX is returned. + */ +static inline ut64 rz_read_me64(const void *src) { + if (!src) { + return UT64_MAX; + } + ut64 val = ((ut64)(rz_read_at_me32(src, sizeof(ut32)))) << 32; + val |= rz_read_me32(src); + return val; +} + +/** + * \brief Read a 64-bit value from \p src at \p offset in middle-endian order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \return The read 64-bit value. + * \attention If \p src is \c NULL then \c UT64_MAX is returned. + */ +static inline ut64 rz_read_at_me64(const void *src, size_t offset) { + if (!src) { + return UT64_MAX; + } + const ut8 *s = ((const ut8 *)src) + offset; + return rz_read_me64(s); +} + +/** + * \brief Write a 64-bit value to \p dest in middle-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 64-bit value. + */ +static inline void rz_write_me64(void *dest, ut64 val) { + rz_write_me32(dest, (ut32)val); + rz_write_at_me32(dest, val >> 32, sizeof(ut32)); +} + +/** + * \brief Write a 64-bit value to \p dest in middle-endian order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 64-bit value. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_me64(void *dest, ut64 val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_me64(d, val); +} + +/** + * \brief Interpret a 32-bit value read in middle-endian order as floating-point. + * \param src The buffer to read the unsigned integer in middle-endian order from. + * \return The floating-point value with representation equal to that + * of the unsigned 32-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + */ +static inline float rz_read_me_float(const void *src) { + union { + ut32 bits; + float flt; + } p; + p.bits = rz_read_me32(src); + return p.flt; +} + +/** + * \brief Interpret a 32-bit value read in middle-endian order as floating-point. + * \param src The buffer to read the unsigned integer in middle-endian order from. + * \param offset The offset at which the value is read. + * \return The floating-point value with representation equal to that + * of the unsigned 32-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + */ +static inline float rz_read_at_me_float(const void *src, size_t offset) { + if (!src) { + return rz_read_me_float(NULL); + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_me_float(s); +} + +/** + * \brief Write a 32-bit floating-point to \p dest in middle-endian order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + */ +static inline void rz_write_me_float(void *dest, float val) { + union { + ut32 bits; + float flt; + } p; + p.flt = val; + rz_write_me32(dest, p.bits); +} + +/** + * \brief Write a 32-bit floating-point to \p dest in middle-endian order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_me_float(void *dest, float val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_me_float(d, val); +} + +/** + * \brief Interpret a 64-bit value read in middle-endian order as floating-point. + * \param src The buffer to read the unsigned integer in middle-endian order from. + * \return The floating-point value with representation equal to that + * of the unsigned 64-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + */ +static inline double rz_read_me_double(const void *src) { + union { + ut64 bits; + double dbl; + } p; + p.bits = rz_read_me64(src); + return p.dbl; +} + +/** + * \brief Interpret a 64-bit value read in middle-endian order as floating-point. + * \param src The buffer to read the unsigned integer in middle-endian order from. + * \param offset The offset at which the value is read. + * \return The floating-point value with representation equal to that + * of the unsigned 64-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + */ +static inline double rz_read_at_me_double(const void *src, size_t offset) { + if (!src) { + return rz_read_me_double(NULL); + } + const ut8 *s = (const ut8 *)src + offset; + return rz_read_me_double(s); +} + +/** + * \brief Write a 64-bit floating-point to \p dest in middle-endian order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + */ +static inline void rz_write_me_double(void *dest, double val) { + union { + ut64 bits; + double dbl; + } p; + p.dbl = val; + rz_write_me64(dest, p.bits); +} + +/** + * \brief Write a 64-bit floating-point to \p dest in middle-endian order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + * \param offset The offset at which the value is written. + */ +static inline void rz_write_at_me_double(void *dest, double val, size_t offset) { + ut8 *d = (ut8 *)dest + offset; + rz_write_me_double(d, val); +} + +/* Helper functions */ + +/** + * \brief Read a 16-bit value from \p src in specified order. + * \param src The pointer from which the value is read. + * \param big_endian The choice of endianness. + * \return The read 16-bit value. + * \attention If \p src is \c NULL then \c UT16_MAX is returned. + * + * The value is read according to \p big_endian. If \p big_endian is + * \c true, then an integer in big-endian order is read. Otherwise, if + * \p big_endian is \c false, an integer in little-endian order is + * read. + */ +static inline ut16 rz_read_ble16(const void *src, bool big_endian) { + return big_endian ? rz_read_be16(src) : rz_read_le16(src); +} + +/** + * \brief Read a 24-bit value from \p src in specified order. + * \param src The pointer from which the value is read. + * \param big_endian The choice of endianness. + * \return The read 24-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + * + * The value is read according to \p big_endian. If \p big_endian is + * \c true, then an integer in big-endian order is read. Otherwise, if + * \p big_endian is \c false, an integer in little-endian order is + * read. + */ +static inline ut32 rz_read_ble24(const void *src, bool big_endian) { + return big_endian ? rz_read_be24(src) : rz_read_le24(src); +} + +/** + * \brief Read a 32-bit value from \p src in specified order. + * \param src The pointer from which the value is read. + * \param big_endian The choice of endianness. + * \return The read 32-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + * + * The value is read according to \p big_endian. If \p big_endian is + * \c true, then an integer in big-endian order is read. Otherwise, if + * \p big_endian is \c false, an integer in little-endian order is + * read. + */ +static inline ut32 rz_read_ble32(const void *src, bool big_endian) { + return big_endian ? rz_read_be32(src) : rz_read_le32(src); +} + +/** + * \brief Read a 64-bit value from \p src in specified order. + * \param src The pointer from which the value is read. + * \param big_endian The choice of endianness. + * \return The read 64-bit value. + * \attention If \p src is \c NULL then \c UT64_MAX is returned. + * + * The value is read according to \p big_endian. If \p big_endian is + * \c true, then an integer in big-endian order is read. Otherwise, if + * \p big_endian is \c false, an integer in little-endian order is + * read. + */ +static inline ut64 rz_read_ble64(const void *src, bool big_endian) { + return big_endian ? rz_read_be64(src) : rz_read_le64(src); +} + +/** + * \brief Read a 128-bit value from \p src in specified order. + * \param src The pointer from which the value is read. + * \param big_endian The choice of endianness. + * \return The read 128-bit value. + * \attention If \p src is \c NULL then the maximum 128-bit value is + * returned. + * + * The value is read according to \p big_endian. If \p big_endian is + * \c true, then an integer in big-endian order is read. Otherwise, if + * \p big_endian is \c false, an integer in little-endian order is + * read. + */ +static inline ut128 rz_read_ble128(const void *src, bool big_endian) { + return big_endian ? rz_read_be128(src) : rz_read_le128(src); +} + +/** + * \brief Interpret a 32-bit value read in specified order as floating-point. + * \param src The buffer to read the unsigned integer in specified order from. + * \param big_endian The choice of endianness. + * \return The floating-point value with representation equal to that + * of the unsigned 32-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + * + * The value is read according to \p big_endian. If \p big_endian is + * \c true, then a floating-point value in big-endian order is + * read. Otherwise, if \p big_endian is \c false, an floating-point + * value in little-endian order is read. + */ +static inline float rz_read_ble_float(const void *src, bool big_endian) { + return big_endian ? rz_read_be_float(src) : rz_read_le_float(src); +} + +/** + * \brief Interpret a 64-bit value read in specified order as floating-point. + * \param src The buffer to read the unsigned integer in specified order from. + * \param big_endian The choice of endianness. + * \return The floating-point value with representation equal to that + * of the unsigned 64-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + * + * The value is read according to \p big_endian. If \p big_endian is + * \c true, then a floating-point value in big-endian order is + * read. Otherwise, if \p big_endian is \c false, an floating-point + * value in little-endian order is read. + */ +static inline double rz_read_ble_double(const void *src, bool big_endian) { + return big_endian ? rz_read_be_double(src) : rz_read_le_double(src); +} + +/** + * \brief Read a 16-bit value from \p src at \p offset in specified order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \param big_endian The choice of endianness. + * \return The read 16-bit value. + * \attention If \p src is \c NULL then \c UT16_MAX is returned. + */ +static inline ut16 rz_read_at_ble16(const void *src, size_t offset, bool big_endian) { + return big_endian ? rz_read_at_be16(src, offset) : rz_read_at_le16(src, offset); +} + +/** + * \brief Read a 24-bit value from \p src at \p offset in specified order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \param big_endian The choice of endianness. + * \return The read 24-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + */ +static inline ut32 rz_read_at_ble24(const void *src, size_t offset, bool big_endian) { + return big_endian ? rz_read_at_be24(src, offset) : rz_read_at_le24(src, offset); +} + +/** + * \brief Read a 32-bit value from \p src at \p offset in specified order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \param big_endian The choice of endianness. + * \return The read 32-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + */ +static inline ut32 rz_read_at_ble32(const void *src, size_t offset, bool big_endian) { + return big_endian ? rz_read_at_be32(src, offset) : rz_read_at_le32(src, offset); +} + +/** + * \brief Read a 64-bit value from \p src at \p offset in specified order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \param big_endian The choice of endianness. + * \return The read 64-bit value. + * \attention If \p src is \c NULL then \c UT32_MAX is returned. + */ +static inline ut64 rz_read_at_ble64(const void *src, size_t offset, bool big_endian) { + return big_endian ? rz_read_at_be64(src, offset) : rz_read_at_le64(src, offset); +} + +/** + * \brief Read a 128-bit value from \p src at \p offset in specified order. + * \param src The pointer from which the value is read. + * \param offset The offset at which the value is read. + * \param big_endian The choice of endianness. + * \return The read 128-bit value. + * \attention If \p src is \c NULL then \c UT128_MAX is returned. + */ +static inline ut128 rz_read_at_ble128(const void *src, size_t offset, bool big_endian) { + return big_endian ? rz_read_at_be128(src, offset) : rz_read_at_le128(src, offset); +} + +/** + * \brief Interpret a 32-bit value read in specified order as floating-point. + * \param src The buffer to read the unsigned integer in specified order from. + * \param big_endian The choice of endianness. + * \param offset The offset at which the value is read. + * \return The floating-point value with representation equal to that + * of the unsigned 32-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * + * The value is read according to \p big_endian. If \p big_endian is + * \c true, then a floating-point value in big-endian order is + * read. Otherwise, if \p big_endian is \c false, an floating-point + * value in little-endian order is read. + */ +static inline float rz_read_at_ble_float(const void *src, size_t offset, bool big_endian) { + return big_endian ? rz_read_at_be_float(src, offset) : rz_read_at_le_float(src, offset); +} + +/** + * \brief Interpret a 64-bit value read in specified order as floating-point. + * \param src The buffer to read the unsigned integer in specified order from. + * \param big_endian The choice of endianness. + * \param offset The offset at which the value is read. + * \return The floating-point value with representation equal to that + * of the unsigned 64-bit value read from \p src. + * \attention \c NaN payloads might not be preserved. + * \attention If \p src is \c NULL then \c NaN is returned. + * + * The value is read according to \p big_endian. If \p big_endian is + * \c true, then a floating-point value in big-endian order is + * read. Otherwise, if \p big_endian is \c false, an floating-point + * value in little-endian order is read. + */ +static inline double rz_read_at_ble_double(const void *src, size_t offset, bool big_endian) { + return big_endian ? rz_read_at_be_double(src, offset) : rz_read_at_le_double(src, offset); +} + +/** + * \brief Read an integer value from \p src in specified order. + * \param src The pointer from which the value is read. + * \param big_endian The choice of endianness. + * \param size The size of the representation in bits. + * \return The read integer value. + * \retval UT64_MAX If the \p size parameter is not 8, 16, 32, or 64. + * \attention If \p src is \c NULL and \p size is a valid size, the + * appropriate maximum unsigned integer value for that size is + * returned. + * + * The value is read according to \p big_endian. If \p big_endian is + * \c true, then an integer in big-endian order is read. Otherwise, if + * \p big_endian is \c false, an integer in little-endian order is + * read. + * + * The number of bits read is according to \p size. The valid choices + * are \c 8, \c 16, \c 32, or \c 64. + */ +static inline ut64 rz_read_ble(const void *src, bool big_endian, int size) { + switch (size) { + case 8: + return rz_read_ble8(src); + case 16: + return rz_read_ble16(src, big_endian); + case 32: + return rz_read_ble32(src, big_endian); + case 64: + return rz_read_ble64(src, big_endian); + default: + return UT64_MAX; + } +} + +/** + * \brief Write a 16-bit value to \p dest in specified order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 16-bit value. + * \param big_endian The choice of endianness. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then an integer in big-endian order is + * written. Otherwise, if \p big_endian is \c false, an integer in + * little-endian order is written. + */ +static inline void rz_write_ble16(void *dest, ut16 val, bool big_endian) { + big_endian ? rz_write_be16(dest, val) : rz_write_le16(dest, val); +} + +/** + * \brief Write a 24-bit value to \p dest in specified order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 24-bit value. + * \param big_endian The choice of endianness. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then an integer in big-endian order is + * written. Otherwise, if \p big_endian is \c false, an integer in + * little-endian order is written. + */ +static inline void rz_write_ble24(void *dest, ut32 val, bool big_endian) { + big_endian ? rz_write_be24(dest, val) : rz_write_le24(dest, val); +} + +/** + * \brief Write a 32-bit value to \p dest in specified order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 32-bit value. + * \param big_endian The choice of endianness. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then an integer in big-endian order is + * written. Otherwise, if \p big_endian is \c false, an integer in + * little-endian order is written. + */ +static inline void rz_write_ble32(void *dest, ut32 val, bool big_endian) { + big_endian ? rz_write_be32(dest, val) : rz_write_le32(dest, val); +} + +/** + * \brief Write a 64-bit value to \p dest in specified order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 64-bit value. + * \param big_endian The choice of endianness. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then an integer in big-endian order is + * written. Otherwise, if \p big_endian is \c false, an integer in + * little-endian order is written. + */ +static inline void rz_write_ble64(void *dest, ut64 val, bool big_endian) { + big_endian ? rz_write_be64(dest, val) : rz_write_le64(dest, val); +} + +/** + * \brief Write a 128-bit value to \p dest in specified order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 128-bit value. + * \param big_endian The choice of endianness. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then an integer in big-endian order is + * written. Otherwise, if \p big_endian is \c false, an integer in + * little-endian order is written. + */ +static inline void rz_write_ble128(void *dest, ut128 val, bool big_endian) { + big_endian ? rz_write_be128(dest, val) : rz_write_le128(dest, val); +} + +/** + * \brief Write an integer value to \p dest in specified order. + * \param[out] dest The pointer to which the value is written. + * \param val The written integer value. + * \param big_endian The choice of endianness. + * \param size The size of the representation in bits. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then an integer in big-endian order is + * written. Otherwise, if \p big_endian is \c false, an integer in + * little-endian order is written. + * + * The number of bits written is according to \p size. The valid choices + * are \c 8, \c 16, \c 32, or \c 64. No action is taken otherwise. + */ +static inline void rz_write_ble(void *dst, ut64 val, bool big_endian, int size) { + switch (size) { + case 8: + ((ut8 *)dst)[0] = (ut8)val; + break; + case 16: + rz_write_ble16(dst, (ut16)val, big_endian); + break; + case 24: + rz_write_ble24(dst, (ut32)val, big_endian); + break; + case 32: + rz_write_ble32(dst, (ut32)val, big_endian); + break; + case 64: + rz_write_ble64(dst, val, big_endian); + break; + default: + break; + } +} + +/** + * \brief Write a 32-bit floating-point to \p dest in specified order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + * \param big_endian The choice of endianness. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then a floating-point value in big-endian order is + * written. Otherwise, if \p big_endian is \c false, a floating-point + * value in little-endian order is written. + */ +static inline void rz_write_ble_float(void *src, float val, bool big_endian) { + big_endian ? rz_write_be_float(src, val) : rz_write_le_float(src, val); +} + +/** + * \brief Write a 64-bit floating-point to \p dest in specified order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + * \param big_endian The choice of endianness. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then a floating-point value in big-endian order is + * written. Otherwise, if \p big_endian is \c false, a floating-point + * value in little-endian order is written. + */ +static inline void rz_write_ble_double(void *src, double val, bool big_endian) { + big_endian ? rz_write_be_double(src, val) : rz_write_le_double(src, val); +} + +/** + * \brief Write a 16-bit value to \p dest in specified order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 16-bit value. + * \param big_endian The choice of endianness. + * \param offset The offset at which the value is written. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then an integer in big-endian order is + * written. Otherwise, if \p big_endian is \c false, an integer in + * little-endian order is written. + */ +static inline void rz_write_at_ble16(void *dest, ut16 val, bool big_endian, size_t offset) { + if (big_endian) { + rz_write_at_be16(dest, val, offset); + } else { + rz_write_at_le16(dest, val, offset); + } +} + +/** + * \brief Write a 24-bit value to \p dest in specified order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 24-bit value. + * \param big_endian The choice of endianness. + * \param offset The offset at which the value is written. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then an integer in big-endian order is + * written. Otherwise, if \p big_endian is \c false, an integer in + * little-endian order is written. + */ +static inline void rz_write_at_ble24(void *dest, ut32 val, bool big_endian, size_t offset) { + if (big_endian) { + rz_write_at_be24(dest, val, offset); + } else { + rz_write_at_le24(dest, val, offset); + } +} + +/** + * \brief Write a 32-bit value to \p dest in specified order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 32-bit value. + * \param big_endian The choice of endianness. + * \param offset The offset at which the value is written. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then an integer in big-endian order is + * written. Otherwise, if \p big_endian is \c false, an integer in + * little-endian order is written. + */ +static inline void rz_write_at_ble32(void *dest, ut32 val, bool big_endian, size_t offset) { + if (big_endian) { + rz_write_at_be32(dest, val, offset); + } else { + rz_write_at_le32(dest, val, offset); + } +} + +/** + * \brief Write a 64-bit value to \p dest in specified order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 64-bit value. + * \param big_endian The choice of endianness. + * \param offset The offset at which the value is written. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then an integer in big-endian order is + * written. Otherwise, if \p big_endian is \c false, an integer in + * little-endian order is written. + */ +static inline void rz_write_at_ble64(void *dest, ut64 val, bool big_endian, size_t offset) { + if (big_endian) { + rz_write_at_be64(dest, val, offset); + } else { + rz_write_at_le64(dest, val, offset); + } +} + +/** + * \brief Write a 128-bit value to \p dest in specified order. + * \param[out] dest The pointer to which the value is written. + * \param val The written 128-bit value. + * \param big_endian The choice of endianness. + * \param offset The offset at which the value is written. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then an integer in big-endian order is + * written. Otherwise, if \p big_endian is \c false, an integer in + * little-endian order is written. + */ +static inline void rz_write_at_ble128(void *dest, ut128 val, bool big_endian, size_t offset) { + if (big_endian) { + rz_write_at_be128(dest, val, offset); + } else { + rz_write_at_le128(dest, val, offset); + } +} + +/** + * \brief Write a 32-bit floating-point to \p dest in specified order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + * \param big_endian The choice of endianness. + * \param offset The offset at which the value is written. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then a floating-point value in big-endian order is + * written. Otherwise, if \p big_endian is \c false, a floating-point + * value in little-endian order is written. + */ +static inline void rz_write_at_ble_float(void *src, float val, bool big_endian) { + big_endian ? rz_write_be_float(src, val) : rz_write_le_float(src, val); +} + +/** + * \brief Write a 64-bit floating-point to \p dest in specified order. + * \param[out] dest The pointer to which the floating-point value is written. + * \param val The floating-point value to be written. + * \param big_endian The choice of endianness. + * \param offset The offset at which the value is written. + * + * The value is written according to \p big_endian. If \p big_endian + * is \c true, then a floating-point value in big-endian order is + * written. Otherwise, if \p big_endian is \c false, a floating-point + * value in little-endian order is written. + */ +static inline void rz_write_at_ble_double(void *src, double val, bool big_endian) { + big_endian ? rz_write_be_double(src, val) : rz_write_le_double(src, val); +} + +/*swap*/ + +/* Use compiler intrinsics if present */ + +/** + * \def rz_swap_ut16 + * \brief Reverse the order of bytes of the 16-bit representation. + * \parameter x The 16-bit value to operate upon. + * + * # Example + * + * \code{.c} + * ut16 x = 0xAABB; + * ut16 result = 0xBBAA; + * assert(rz_swap_ut16(x) == result); + * \endcode + */ +#if HAVE___BUILTIN_BSWAP16 +#define rz_swap_ut16 __builtin_bswap16 +#else +static inline ut16 rz_swap_ut16(ut16 val) { + return (val << 8) | (val >> 8); +} +#endif + +/** + * \def rz_swap_ut32 + * \brief Reverse the order of bytes of the 32-bit representation. + * \parameter x The 32-bit value to operate upon. + * + * # Example + * + * \code{.c} + * ut32 x = 0xAABBCCDD; + * ut32 result = 0xDDCCBBAA; + * assert(rz_swap_ut32(x) == result); + * \endcode + */ +#if HAVE___BUILTIN_BSWAP32 +#define rz_swap_ut32 __builtin_bswap32 +#else +static inline ut32 rz_swap_ut32(ut32 val) { + val = ((val << 8) & 0xFF00FF00) | ((val >> 8) & 0xFF00FF); + return (val << 16) | (val >> 16); +} +#endif + +/** + * \def rz_swap_ut64 + * \brief Reverse the order of bytes of the 64-bit representation. + * \parameter x The 64-bit value to operate upon. + * + * # Example + * + * \code{.c} + * ut64 x = 0xAABBCCDD11223344; + * ut64 result = 0x44332211DDCCBBAA; + * assert(rz_swap_ut64(x) == result); + * \endcode + */ +#if HAVE___BUILTIN_BSWAP64 +#define rz_swap_ut64 __builtin_bswap64 +#else +static inline ut64 rz_swap_ut64(ut64 val) { + val = ((val << 8) & 0xFF00FF00FF00FF00ULL) | ((val >> 8) & 0x00FF00FF00FF00FFULL); + val = ((val << 16) & 0xFFFF0000FFFF0000ULL) | ((val >> 16) & 0x0000FFFF0000FFFFULL); + return (val << 32) | (val >> 32); +} +#endif + +/** + * \def rz_swap_2b_ut64 + * \brief Swaps pairs of 2 bytes in a 64bit value + * + * # Example + * + * \code{.c} + * ut32 x = 0x8899AABBCCDDEEFF; + * ut32 result = 0x9988BBAADDCCFFEE; + * assert(rz_swap_2b_ut64(x) == result); + * \endcode + */ +static inline ut64 rz_swap_2b_ut64(ut64 val) { + val = ((val & 0xff00ff00ff00ff00) >> 8) | ((val & 0x00ff00ff00ff00ff) << 8); + return val; +} + +/** + * \def rz_swap_4b_ut64 + * \brief Swaps pairs of 4 bytes in a 64bit value + * + * # Example + * + * \code{.c} + * ut32 x = 0x8899AABBCCDDEEFF; + * ut32 result = 0xBBAA9988FFEEDDCC; + * assert(rz_swap_4b_ut64(x) == result); + * \endcode + */ +static inline ut64 rz_swap_4b_ut64(ut64 val) { + val = ((val & 0xff000000ff000000) >> 24) | + ((val & 0x00ff000000ff0000) >> 8) | + ((val & 0x0000ff000000ff00) << 8) | + ((val & 0x000000ff000000ff) << 24); + return val; +} + +/** + * \def rz_swap_2b_ut32 + * \brief Swaps pairs of 2 bytes in a 32bit value + * + * # Example + * + * \code{.c} + * ut32 x = 0xCCDDEEFF; + * ut32 result = 0xDDCCFFEE; + * assert(rz_swap_2b_ut32(x) == result); + * \endcode + */ +static inline ut32 rz_swap_2b_ut32(ut32 val) { + val = ((val & 0xff00ff00) >> 8) | ((val & 0x00ff00ff) << 8); + return val; +} + +/* Some "secured" functions, to do basic operation (mul, sub, add...) on integers */ + +/** + * \brief Add two 64-bit unsigned integers unless the result overflows. + * \param[out] r The result of addition or \c 0 if overflow. + * \param a, b The unsigned integers to add. + * \return Return 0 if the addition would result in overflow or 1 + * otherwise. + * \attention If \p r is \c NULL then it is ignored, but the return + * value is still useful for detecting overflow. + */ +static inline int UT64_ADD(ut64 *r, ut64 a, ut64 b) { + if (UT64_MAX - a < b) { + return 0; + } + if (r) { + *r = a + b; + } + return 1; +} + +/** + * \brief Multiply two 64-bit unsigned integers unless the result overflows. + * \param[out] r The result of multiplication or \c 0 if overflow. + * \param a, b The unsigned integers to multiply. + * \return Return 0 if the multiplication would result in overflow or 1 + * otherwise. + * \attention If \p r is \c NULL then it is ignored, but the return + * value is still useful for detecting overflow. + * \attention The return value of \c 0 signifies overflow if and only + * if both \p a and \p b are non-zero. Otherwise, it is the result of + * multiplication, and no overflow has occurred. + */ +static inline int UT64_MUL(ut64 *r, ut64 a, ut64 b) { + if (a && UT64_MAX / a < b) { + return 0; + } + if (r) { + *r = a * b; + } + return 1; +} + +/** + * \brief Subtract two 64-bit unsigned integers unless the result underflows. + * \param[out] r The difference or \c 0 if underflow. + * \param a The subtrahend. + * \param b The minuend. + * \return Return 0 if the subtraction would result in underflow or 1 + * otherwise. + * \attention If \p r is \c NULL then it is ignored, but the return + * value is still useful for detecting underflow. + */ +static inline int UT64_SUB(ut64 *r, ut64 a, ut64 b) { + if (b > a) { + return 0; + } + if (r) { + *r = a - b; + } + return 1; +} + +/** + * \brief Add two 32-bit unsigned integers unless the result overflows. + * \param[out] r The result of addition or \c 0 if overflow. + * \param a, b The unsigned integers to add. + * \return Return 0 if the addition would result in overflow or 1 + * otherwise. + * \attention If \p r is \c NULL then it is ignored, but the return + * value is still useful for detecting overflow. + */ +static inline int UT32_ADD(ut32 *r, ut32 a, ut32 b) { + if (UT32_MAX - a < b) { + return 0; + } + if (r) { + *r = a + b; + } + return 1; +} + +/** + * \brief Multiply two 32-bit unsigned integers unless the result overflows. + * \param[out] r The result of multiplication or \c 0 if overflow. + * \param a, b The unsigned integers to multiply. + * \return Return 0 if the multiplication would result in overflow or 1 + * otherwise. + * \attention If \p r is \c NULL then it is ignored, but the return + * value is still useful for detecting overflow. + * \attention The return value of \c 0 signifies overflow if and only + * if both \p a and \p b are non-zero. Otherwise, it is the result of + * multiplication, and no overflow has occurred. + */ +static inline int UT32_MUL(ut32 *r, ut32 a, ut32 b) { + if (a && UT32_MAX / a < b) { + return 0; + } + if (r) { + *r = a * b; + } + return 1; +} + +/** + * \brief Subtract two 32-bit unsigned integers unless the result underflows. + * \param[out] r The difference or \c 0 if underflow. + * \param a The subtrahend. + * \param b The minuend. + * \return Return 0 if the subtraction would result in underflow or 1 + * otherwise. + * \attention If \p r is \c NULL then it is ignored, but the return + * value is still useful for detecting underflow. + */ +static inline int UT32_SUB(ut32 *r, ut32 a, ut32 b) { + if (b > a) { + return 0; + } + if (r) { + *r = a - b; + } + return 1; +} + +/** + * \brief Add two 16-bit unsigned integers unless the result overflows. + * \param[out] r The result of addition or \c 0 if overflow. + * \param a, b The unsigned integers to add. + * \return Return 0 if the addition would result in overflow or 1 + * otherwise. + * \attention If \p r is \c NULL then it is ignored, but the return + * value is still useful for detecting overflow. + */ +static inline int UT16_ADD(ut16 *r, ut16 a, ut16 b) { + if (UT16_MAX - a < b) { + return 0; + } + if (r) { + *r = a + b; + } + return 1; +} + +/** + * \brief Multiply two 16-bit unsigned integers unless the result overflows. + * \param[out] r The result of multiplication or \c 0 if overflow. + * \param a, b The unsigned integers to multiply. + * \return Return 0 if the multiplication would result in overflow or 1 + * otherwise. + * \attention If \p r is \c NULL then it is ignored, but the return + * value is still useful for detecting overflow. + * \attention The return value of \c 0 signifies overflow if and only + * if both \p a and \p b are non-zero. Otherwise, it is the result of + * multiplication, and no overflow has occurred. + */ +static inline int UT16_MUL(ut16 *r, ut16 a, ut16 b) { + if (a && UT16_MAX / a < b) { + return 0; + } + if (r) { + *r = a * b; + } + return 1; +} + +/** + * \brief Subtract two 16-bit unsigned integers unless the result underflows. + * \param[out] r The difference or \c 0 if underflow. + * \param a The subtrahend. + * \param b The minuend. + * \return Return 0 if the subtraction would result in underflow or 1 + * otherwise. + * \attention If \p r is \c NULL then it is ignored, but the return + * value is still useful for detecting underflow. + */ +static inline int UT16_SUB(ut16 *r, ut16 a, ut16 b) { + if (b > a) { + return 0; + } + if (r) { + *r = a - b; + } + return 1; +} + +/** + * \brief Add two 8-bit unsigned integers unless the result overflows. + * \param[out] r The result of addition or \c 0 if overflow. + * \param a, b The unsigned integers to add. + * \return Return 0 if the addition would result in overflow or 1 + * otherwise. + * \attention If \p r is \c NULL then it is ignored, but the return + * value is still useful for detecting overflow. + */ +static inline int UT8_ADD(ut8 *r, ut8 a, ut8 b) { + if (UT8_MAX - a < b) { + return 0; + } + if (r) { + *r = a + b; + } + return 1; +} + +/** + * \brief Multiply two 8-bit unsigned integers unless the result overflows. + * \param[out] r The result of multiplication or \c 0 if overflow. + * \param a, b The unsigned integers to multiply. + * \return Return 0 if the multiplication would result in overflow or 1 + * otherwise. + * \attention If \p r is \c NULL then it is ignored, but the return + * value is still useful for detecting overflow. + * \attention The return value of \c 0 signifies overflow if and only + * if both \p a and \p b are non-zero. Otherwise, it is the result of + * multiplication, and no overflow has occurred. + */ +static inline int UT8_MUL(ut8 *r, ut8 a, ut8 b) { + if (a && UT8_MAX / a < b) { + return 0; + } + if (r) { + *r = a * b; + } + return 1; +} + +/** + * \brief Subtract two 8-bit unsigned integers unless the result underflows. + * \param[out] r The difference or \c 0 if underflow. + * \param a The subtrahend. + * \param b The minuend. + * \return Return 0 if the subtraction would result in underflow or 1 + * otherwise. + * \attention If \p r is \c NULL then it is ignored, but the return + * value is still useful for detecting underflow. + */ +static inline int UT8_SUB(ut8 *r, ut8 a, ut8 b) { + if (b > a) { + return 0; + } + if (r) { + *r = a - b; + } + return 1; +} + +#define DEFINE_RZ_READ_OFFSET_BLE(size) \ + static inline ut##size rz_read_be##size##_offset(RZ_NONNULL const void *src, RZ_NONNULL RZ_INOUT size_t *offset) { \ + const ut8 *s = (const ut8 *)src + *offset; \ + ut##size ret = rz_read_be##size(s); \ + *offset += sizeof(ret); \ + return ret; \ + } \ + static inline ut##size rz_read_le##size##_offset(RZ_NONNULL const void *src, RZ_NONNULL RZ_INOUT size_t *offset) { \ + const ut8 *s = (const ut8 *)src + *offset; \ + ut##size ret = rz_read_le##size(s); \ + *offset += sizeof(ret); \ + return ret; \ + } + +/** + * \brief Read a ut8 at the specified offset in the buffer and shifts the offset. + * \param src The pointer from which the value is read. + * \param offset The pointer to offset at which the value is read. + * \return Return the value of the operation. + * \attention If \p src is \c NULL then \c UT16_MAX is returned. + */ +static inline ut8 rz_read_le8_offset(RZ_NONNULL const void *src, RZ_NONNULL RZ_INOUT size_t *offset) { + ut8 ret = rz_read_at_le8(src, *offset); + *offset += sizeof(ret); + return ret; +} + +/** + * \brief Read a big endian or little endian (ut16, ut32, ut64, ut128) at the specified offset in the buffer and shifts the offset. + * \param src The pointer from which the value is read. + * \param offset The pointer to offset at which the value is read. + * \return Return the value of the operation. + * \attention If \p src is \c NULL then \c UT16_MAX is returned. + */ +DEFINE_RZ_READ_OFFSET_BLE(16) +DEFINE_RZ_READ_OFFSET_BLE(32) +DEFINE_RZ_READ_OFFSET_BLE(64) +DEFINE_RZ_READ_OFFSET_BLE(128) + +#define rz_read8_offset(b, offset) rz_read_le8_offset(b, offset) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_flag.h b/dest/include/librz/rz_flag.h new file mode 100644 index 00000000000..a6cb9f2ca3e --- /dev/null +++ b/dest/include/librz/rz_flag.h @@ -0,0 +1,207 @@ +#ifndef RZ_FLAGS_H +#define RZ_FLAGS_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// TODO: rename to rz_flag_XXX api +RZ_LIB_VERSION_HEADER(rz_flag); + +#define RZ_FLAG_NAME_SIZE 512 + +/* zones.c */ + +typedef struct rz_flag_zone_item_t { + ut64 from; + ut64 to; + char *name; +} RzFlagZoneItem; + +/* flag.c */ + +typedef struct rz_flags_at_offset_t { + ut64 off; + RzList /**/ *flags; /* list of RzFlagItem at offset */ +} RzFlagsAtOffset; + +typedef struct rz_flag_item_t { + char *name; /* unique name, escaped to avoid issues with rizin shell */ + char *realname; /* real name, without any escaping */ + bool demangled; /* real name from demangling? */ + ut64 offset; /* offset flagged by this item */ + ut64 size; /* size of the flag item */ + RzSpace *space; /* flag space this item belongs to */ + char *color; /* item color */ + char *comment; /* item comment */ + char *alias; /* used to define a flag based on a math expression (e.g. foo + 3) */ +} RzFlagItem; + +typedef struct rz_flag_t { + RzSpaces spaces; /* handle flag spaces */ + bool realnames; + Sdb *tags; + RzNum *num; + RzSkipList *by_off; /* flags sorted by offset, value=RzFlagsAtOffset */ + HtSP *ht_name; /* hashmap key=item name, value=RzFlagItem * */ + RzList /**/ *zones; +} RzFlag; + +/* compile time dependency */ + +typedef bool (*RzFlagExistAt)(RzFlag *f, const char *flag_prefix, ut16 fp_size, ut64 off); +typedef RzFlagItem *(*RzFlagGet)(RzFlag *f, const char *name); +typedef RzFlagItem *(*RzFlagGetAtAddr)(RzFlag *f, ut64); +typedef RzFlagItem *(*RzFlagGetAt)(RzFlag *f, ut64 addr, bool closest); +typedef RzFlagItem *(*RzFlagGetAtBySpaces)(RzFlag *f, ut64 off, ...); +typedef const RzList /**/ *(*RzFlagGetList)(RzFlag *f, ut64 addr); +typedef RzFlagItem *(*RzFlagSet)(RzFlag *f, const char *name, ut64 addr, ut32 size); +typedef bool (*RzFlagUnset)(RzFlag *f, RzFlagItem *item); +typedef bool (*RzFlagUnsetName)(RzFlag *f, const char *name); +typedef bool (*RzFlagUnsetOff)(RzFlag *f, ut64 addr); +typedef RzSpace *(*RzFlagSetSpace)(RzFlag *f, const char *name); +typedef bool (*RzFlagPopSpace)(RzFlag *f); +typedef bool (*RzFlagPushSpace)(RzFlag *f, const char *name); +typedef int (*RzFlagRename)(RzFlag *f, RzFlagItem *item, const char *name); + +typedef bool (*RzFlagItemCb)(RzFlagItem *fi, void *user); + +typedef struct rz_flag_bind_t { + int init; + RzFlag *f; + RzFlagExistAt exist_at; + RzFlagGet get; + RzFlagGetAt get_at; + RzFlagGetAtBySpaces get_at_by_spaces; + RzFlagGetList get_list; + RzFlagSet set; + RzFlagUnset unset; + RzFlagUnsetName unset_name; + RzFlagUnsetOff unset_off; + RzFlagSetSpace set_fs; + RzFlagPushSpace push_fs; + RzFlagPopSpace pop_fs; + RzFlagRename rename; +} RzFlagBind; + +#define rz_flag_bind_init(x) memset(&x, 0, sizeof(x)) +RZ_API void rz_flag_bind(RzFlag *io, RzFlagBind *bnd); + +#ifdef RZ_API +RZ_API RzFlag *rz_flag_new(void); +RZ_API RzFlag *rz_flag_free(RzFlag *f); +RZ_API bool rz_flag_exist_at(RzFlag *f, const char *flag_prefix, ut16 fp_size, ut64 off); +RZ_API RzFlagItem *rz_flag_get(RzFlag *f, const char *name); +RZ_API RzFlagItem *rz_flag_get_i(RzFlag *f, ut64 off); +RZ_API RzFlagItem *rz_flag_get_by_spaces(RzFlag *f, ut64 off, ...); +RZ_API RzFlagItem *rz_flag_get_at(RzFlag *f, ut64 off, bool closest); +RZ_API RZ_BORROW RzFlagItem *rz_flag_get_at_by_spaces(RZ_NONNULL RzFlag *f, bool closest, ut64 off, ...); +RZ_API RzList /**/ *rz_flag_all_list(RzFlag *f, bool by_space); +RZ_API const RzList /**/ *rz_flag_get_list(RzFlag *f, ut64 off); +RZ_API bool rz_flag_reset_obj_flags(RZ_NONNULL RZ_BORROW RzFlag *flags, RZ_NULLABLE const char *backup_filename); +RZ_API char *rz_flag_get_liststr(RzFlag *f, ut64 off); +RZ_API bool rz_flag_unset(RzFlag *f, RzFlagItem *item); +RZ_API bool rz_flag_unset_name(RzFlag *f, const char *name); +RZ_API bool rz_flag_unset_off(RzFlag *f, ut64 addr); +RZ_API bool rz_flag_unset_all_off(RzFlag *f, ut64 off); +RZ_API void rz_flag_unset_all(RzFlag *f); +RZ_API void rz_flag_unset_all_in_space(RzFlag *f, const char *space_name); +RZ_API RzFlagItem *rz_flag_set(RzFlag *fo, const char *name, ut64 addr, ut32 size); +RZ_API RzFlagItem *rz_flag_set_next(RzFlag *fo, const char *name, ut64 addr, ut32 size); +RZ_API void rz_flag_item_set_alias(RzFlagItem *item, const char *alias); +RZ_API void rz_flag_item_free(RzFlagItem *item); +RZ_API void rz_flag_item_set_comment(RzFlagItem *item, const char *comment); +RZ_API void rz_flag_item_set_realname(RzFlagItem *item, const char *realname); +RZ_API const char *rz_flag_item_set_color(RzFlagItem *item, const char *color); +RZ_API RzFlagItem *rz_flag_item_clone(RzFlagItem *item); +RZ_API int rz_flag_unset_glob(RzFlag *f, const char *name); +RZ_API int rz_flag_rename(RzFlag *f, RzFlagItem *item, const char *name); +RZ_API int rz_flag_relocate(RzFlag *f, ut64 off, ut64 off_mask, ut64 to); +RZ_API bool rz_flag_move(RzFlag *f, ut64 at, ut64 to); +RZ_API int rz_flag_count(RzFlag *f, const char *glob); +RZ_API void rz_flag_foreach(RzFlag *f, RzFlagItemCb cb, void *user); +RZ_API void rz_flag_foreach_prefix(RzFlag *f, const char *pfx, int pfx_len, RzFlagItemCb cb, void *user); +RZ_API void rz_flag_foreach_range(RZ_NONNULL RzFlag *f, ut64 from, ut64 to, RzFlagItemCb cb, void *user); +RZ_API void rz_flag_foreach_glob(RzFlag *f, const char *glob, RzFlagItemCb cb, void *user); +RZ_API void rz_flag_foreach_space(RzFlag *f, const RzSpace *space, RzFlagItemCb cb, void *user); +RZ_API void rz_flag_foreach_space_glob(RzFlag *f, const char *glob, const RzSpace *space, RzFlagItemCb cb, void *user); + +/* spaces */ +static inline RzSpace *rz_flag_space_get(RzFlag *f, const char *name) { + return rz_spaces_get(&f->spaces, name); +} + +static inline RzSpace *rz_flag_space_cur(RzFlag *f) { + return rz_spaces_current(&f->spaces); +} + +static inline const char *rz_flag_space_cur_name(RzFlag *f) { + return rz_spaces_current_name(&f->spaces); +} + +static inline RzSpace *rz_flag_space_set(RzFlag *f, const char *name) { + return rz_spaces_set(&f->spaces, name); +} + +static inline bool rz_flag_space_unset(RzFlag *f, const char *name) { + return rz_spaces_unset(&f->spaces, name); +} + +static inline bool rz_flag_space_rename(RzFlag *f, const char *oname, const char *nname) { + return rz_spaces_rename(&f->spaces, oname, nname); +} + +static inline bool rz_flag_space_push(RzFlag *f, const char *name) { + return rz_spaces_push(&f->spaces, name); +} + +static inline bool rz_flag_space_pop(RzFlag *f) { + return rz_spaces_pop(&f->spaces); +} + +static inline int rz_flag_space_count(RzFlag *f, const char *name) { + return rz_spaces_count(&f->spaces, name); +} + +static inline bool rz_flag_space_is_empty(RzFlag *f) { + return rz_spaces_is_empty(&f->spaces); +} + +#define rz_flag_space_foreach(f, it, s) rz_spaces_foreach(&(f)->spaces, (it), (s)) + +/* tags */ +RZ_API RZ_OWN RzList /**/ *rz_flag_tags_list(RzFlag *f); +RZ_API void rz_flag_tags_set(RzFlag *f, const char *name, const char *words); +RZ_API void rz_flag_tags_reset(RzFlag *f, const char *name); +RZ_API RzList /**/ *rz_flag_tags_get(RzFlag *f, const char *name); + +/* zones */ + +RZ_API void rz_flag_zone_item_free(void *a); +RZ_API bool rz_flag_zone_add(RzFlag *fz, const char *name, ut64 addr); +RZ_API bool rz_flag_zone_del(RzFlag *fz, const char *name); +RZ_API bool rz_flag_zone_around(RzFlag *fz, ut64 addr, const char **prev, const char **next); +RZ_API bool rz_flag_zone_reset(RzFlag *f); +RZ_API RzList /**/ *rz_flag_zone_barlist(RzFlag *f, ut64 from, ut64 bsize, int rows); + +/* serialize */ + +RZ_API void rz_serialize_flag_zones_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzList /**/ *zones); +RZ_API bool rz_serialize_flag_zones_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzList /**/ *zones, RZ_NULLABLE RzSerializeResultInfo *res); +RZ_API void rz_serialize_flag_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzFlag *flag); +RZ_API bool rz_serialize_flag_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzFlag *flag, RZ_NULLABLE RzSerializeResultInfo *res); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_flirt.h b/dest/include/librz/rz_flirt.h new file mode 100644 index 00000000000..70fcce6ab70 --- /dev/null +++ b/dest/include/librz/rz_flirt.h @@ -0,0 +1,269 @@ +// SPDX-FileCopyrightText: 2021-2022 RizinOrg +// SPDX-FileCopyrightText: 2021-2022 deroad +// SPDX-FileCopyrightText: 2014-2016 jfrankowski +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_FLIRT_H +#define RZ_FLIRT_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RZ_FLIRT_NAME_MAX 1024 +#define RZ_FLIRT_LIBRARY_NAME_MAX 0xFF +#define RZ_FLIRT_LIBRARY_NAME_DFL "Built with rizin " RZ_VERSION +#define RZ_FLIRT_MAX_PRELUDE_SIZE (32) // this value is choosen as the default for FLIRT, but it can go between 1 and 64 + +/* supported architectures */ +enum rz_flirt_sig_arch_t { + RZ_FLIRT_SIG_ARCH_386 = 0, // Intel 80x86 + RZ_FLIRT_SIG_ARCH_Z80, // 8085, Z80 + RZ_FLIRT_SIG_ARCH_I860, // Intel 860 + RZ_FLIRT_SIG_ARCH_8051, // 8051 + RZ_FLIRT_SIG_ARCH_TMS, // Texas Instruments TMS320C5x + RZ_FLIRT_SIG_ARCH_6502, // 6502 + RZ_FLIRT_SIG_ARCH_PDP, // PDP11 + RZ_FLIRT_SIG_ARCH_68K, // Motoroal 680x0 + RZ_FLIRT_SIG_ARCH_JAVA, // Java + RZ_FLIRT_SIG_ARCH_6800, // Motorola 68xx + RZ_FLIRT_SIG_ARCH_ST7, // SGS-Thomson ST7 + RZ_FLIRT_SIG_ARCH_MC6812, // Motorola 68HC12 + RZ_FLIRT_SIG_ARCH_MIPS, // MIPS + RZ_FLIRT_SIG_ARCH_ARM, // Advanced RISC Machines + RZ_FLIRT_SIG_ARCH_TMSC6, // Texas Instruments TMS320C6x + RZ_FLIRT_SIG_ARCH_PPC, // PowerPC + RZ_FLIRT_SIG_ARCH_80196, // Intel 80196 + RZ_FLIRT_SIG_ARCH_Z8, // Z8 + RZ_FLIRT_SIG_ARCH_SH, // Renesas (formerly Hitachi) SuperH + RZ_FLIRT_SIG_ARCH_NET, // Microsoft Visual Studio.Net + RZ_FLIRT_SIG_ARCH_AVR, // Atmel 8-bit RISC processor(s) + RZ_FLIRT_SIG_ARCH_H8, // Hitachi H8/300, H8/2000 + RZ_FLIRT_SIG_ARCH_PIC, // Microchip's PIC + RZ_FLIRT_SIG_ARCH_SPARC, // SPARC + RZ_FLIRT_SIG_ARCH_ALPHA, // DEC Alpha + RZ_FLIRT_SIG_ARCH_HPPA, // Hewlett-Packard PA-RISC + RZ_FLIRT_SIG_ARCH_H8500, // Renesas (formerly Hitachi) H8/500 + RZ_FLIRT_SIG_ARCH_TRICORE, // Tricore + RZ_FLIRT_SIG_ARCH_DSP56K, // Motorola DSP5600x + RZ_FLIRT_SIG_ARCH_C166, // Siemens C166 family + RZ_FLIRT_SIG_ARCH_ST20, // SGS-Thomson ST20 + RZ_FLIRT_SIG_ARCH_IA64, // Intel Itanium IA64 + RZ_FLIRT_SIG_ARCH_I960, // Intel 960 + RZ_FLIRT_SIG_ARCH_F2MC, // Fujitsu F2MC-16 + RZ_FLIRT_SIG_ARCH_TMS320C54, // Texas Instruments TMS320C54xx + RZ_FLIRT_SIG_ARCH_TMS320C55, // Texas Instruments TMS320C55xx + RZ_FLIRT_SIG_ARCH_TRIMEDIA, // Trimedia + RZ_FLIRT_SIG_ARCH_M32R, // Mitsubishi 32bit RISC + RZ_FLIRT_SIG_ARCH_NEC_78K0, // NEC 78K0 + RZ_FLIRT_SIG_ARCH_NEC_78K0S, // NEC 78K0S + RZ_FLIRT_SIG_ARCH_M740, // Mitsubishi 8bit + RZ_FLIRT_SIG_ARCH_M7700, // Mitsubishi 16bit + RZ_FLIRT_SIG_ARCH_ST9, // ST9+ + RZ_FLIRT_SIG_ARCH_FR, // Fujitsu FR Family + RZ_FLIRT_SIG_ARCH_MC6816, // Motorola 68HC16 + RZ_FLIRT_SIG_ARCH_M7900, // Mitsubishi 7900 + RZ_FLIRT_SIG_ARCH_TMS320C3, // Texas Instruments TMS320C3 + RZ_FLIRT_SIG_ARCH_KR1878, // Angstrem KR1878 + RZ_FLIRT_SIG_ARCH_AD218X, // Analog Devices ADSP 218X + RZ_FLIRT_SIG_ARCH_OAKDSP, // Atmel OAK DSP + RZ_FLIRT_SIG_ARCH_TLCS900, // Toshiba TLCS-900 + RZ_FLIRT_SIG_ARCH_C39, // Rockwell C39 + RZ_FLIRT_SIG_ARCH_CR16, // NSC CR16 + RZ_FLIRT_SIG_ARCH_MN102L00, // Panasonic MN10200 + RZ_FLIRT_SIG_ARCH_TMS320C1X, // Texas Instruments TMS320C1x + RZ_FLIRT_SIG_ARCH_NEC_V850X, // NEC V850 and V850ES/E1/E2 + RZ_FLIRT_SIG_ARCH_SCR_ADPT, // Processor module adapter for processor modules written in scripting languages + RZ_FLIRT_SIG_ARCH_EBC, // EFI Bytecode + RZ_FLIRT_SIG_ARCH_MSP430, // Texas Instruments MSP430 + RZ_FLIRT_SIG_ARCH_SPU, // Cell Broadband Engine Synergistic Processor Unit + RZ_FLIRT_SIG_ARCH_DALVIK, // Android Dalvik Virtual Machine + RZ_FLIRT_SIG_ARCH_65C816, // 65802/65816 + RZ_FLIRT_SIG_ARCH_M16C, // Renesas M16C + RZ_FLIRT_SIG_ARCH_ARC, // Argonaut RISC Core + RZ_FLIRT_SIG_ARCH_UNSP, // SunPlus unSP + RZ_FLIRT_SIG_ARCH_TMS320C28, // Texas Instruments TMS320C28x + RZ_FLIRT_SIG_ARCH_DSP96K, // Motorola DSP96000 + RZ_FLIRT_SIG_ARCH_SPC700, // Sony SPC700 + RZ_FLIRT_SIG_ARCH_AD2106X, // Analog Devices ADSP 2106X + RZ_FLIRT_SIG_ARCH_PIC16, // Microchip 16-bit PIC + RZ_FLIRT_SIG_ARCH_S390, // IBM's S390 + RZ_FLIRT_SIG_ARCH_XTENSA, // Tensilica Xtensa + RZ_FLIRT_SIG_ARCH_RISCV, // RISC-V + RZ_FLIRT_SIG_ARCH_RL78, // Renesas RL78. + RZ_FLIRT_SIG_ARCH_RX, // Renesas RX. + RZ_FLIRT_SIG_ARCH_WASM, // WebAssembly. + RZ_FLIRT_SIG_ARCH_ANY, +}; + +/* supported file types */ +#define RZ_FLIRT_SIG_FILE_DOS_EXE_OLD 0x00000001 +#define RZ_FLIRT_SIG_FILE_DOS_COM_OLD 0x00000002 +#define RZ_FLIRT_SIG_FILE_BIN 0x00000004 +#define RZ_FLIRT_SIG_FILE_DOSDRV 0x00000008 +#define RZ_FLIRT_SIG_FILE_NE 0x00000010 +#define RZ_FLIRT_SIG_FILE_INTELHEX 0x00000020 +#define RZ_FLIRT_SIG_FILE_MOSHEX 0x00000040 +#define RZ_FLIRT_SIG_FILE_LX 0x00000080 +#define RZ_FLIRT_SIG_FILE_LE 0x00000100 +#define RZ_FLIRT_SIG_FILE_NLM 0x00000200 +#define RZ_FLIRT_SIG_FILE_COFF 0x00000400 +#define RZ_FLIRT_SIG_FILE_PE 0x00000800 +#define RZ_FLIRT_SIG_FILE_OMF 0x00001000 +#define RZ_FLIRT_SIG_FILE_SREC 0x00002000 +#define RZ_FLIRT_SIG_FILE_ZIP 0x00004000 +#define RZ_FLIRT_SIG_FILE_OMFLIB 0x00008000 +#define RZ_FLIRT_SIG_FILE_AR 0x00010000 +#define RZ_FLIRT_SIG_FILE_LOADER 0x00020000 +#define RZ_FLIRT_SIG_FILE_ELF 0x00040000 +#define RZ_FLIRT_SIG_FILE_W32RUN 0x00080000 +#define RZ_FLIRT_SIG_FILE_AOUT 0x00100000 +#define RZ_FLIRT_SIG_FILE_PILOT 0x00200000 +#define RZ_FLIRT_SIG_FILE_DOS_EXE 0x00400000 +#define RZ_FLIRT_SIG_FILE_DOS_COM 0x00800000 +#define RZ_FLIRT_SIG_FILE_AIXAR 0x01000000 +#define RZ_FLIRT_SIG_FILE_ALL 0xFFFFFFFF + +/* supported os types */ +#define RZ_FLIRT_SIG_OS_MSDOS 0x0001 +#define RZ_FLIRT_SIG_OS_WIN 0x0002 +#define RZ_FLIRT_SIG_OS_OS2 0x0004 +#define RZ_FLIRT_SIG_OS_NETWARE 0x0008 +#define RZ_FLIRT_SIG_OS_UNIX 0x0010 +#define RZ_FLIRT_SIG_OS_OTHER 0x0020 +#define RZ_FLIRT_SIG_OS_ALL 0xFFFF + +/* supported app types */ +#define RZ_FLIRT_SIG_APP_CONSOLE 0x0001 +#define RZ_FLIRT_SIG_APP_GRAPHICS 0x0002 +#define RZ_FLIRT_SIG_APP_EXE 0x0004 +#define RZ_FLIRT_SIG_APP_DLL 0x0008 +#define RZ_FLIRT_SIG_APP_DRV 0x0010 +#define RZ_FLIRT_SIG_APP_SINGLE_THREADED 0x0020 +#define RZ_FLIRT_SIG_APP_MULTI_THREADED 0x0040 +#define RZ_FLIRT_SIG_APP_16_BIT 0x0080 +#define RZ_FLIRT_SIG_APP_32_BIT 0x0100 +#define RZ_FLIRT_SIG_APP_64_BIT 0x0200 +#define RZ_FLIRT_SIG_APP_ALL 0xFFFF + +typedef struct rz_flirt_tail_byte_t { + ut16 offset; // from pattern_size + crc_length + ut8 value; +} RzFlirtTailByte; + +typedef struct rz_flirt_function_t { + char name[RZ_FLIRT_NAME_MAX]; + ut32 offset; // function offset from the module start + bool negative_offset; // true if offset is negative, for referenced functions + bool is_local; // true if function is static + bool is_collision; // true if was an unresolved collision +} RzFlirtFunction; + +typedef struct rz_flirt_module_t { + ut32 crc_length; + ut32 crc16; // crc16 of the module after the pattern bytes + // until but not including the first variant byte + // this is a custom crc16 + ut32 length; // total length of the module + RzList /**/ *public_functions; + RzList /**/ *tail_bytes; + RzList /**/ *referenced_functions; +} RzFlirtModule; + +typedef struct rz_flirt_node_t { + RzList /**/ *child_list; + RzList /**/ *module_list; + ut32 length; // length of the pattern + ut64 variant_mask; // this is the mask that will define variant bytes in ut8 *pattern_bytes + ut8 *pattern_bytes; // holds the pattern bytes of the signature + ut8 *pattern_mask; // bool array, if true, byte in pattern_bytes is a variant byte +} RzFlirtNode; + +enum rz_flirt_node_optimization_t { + RZ_FLIRT_NODE_OPTIMIZE_NONE = 0, ///< 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 +}; + +typedef enum rz_flirt_file_type_t { + RZ_FLIRT_FILE_TYPE_UNKNOWN = 0, ///< unknown type + RZ_FLIRT_FILE_TYPE_SIG, ///< `.sig` compressed pattern file + RZ_FLIRT_FILE_TYPE_PAT, ///< `.pat` text format pattern file +} RzFlirtFileType; + +typedef struct rz_flirt_sig_info_t { + ut8 version; ///< FLIRT sig version + ut8 architecture; ///< FLIRT sig architecture/processor id + ut32 n_modules; ///< FLIRT sig total number of modules/signatures contained + char *name; ///< FLIRT sig name +} RzFlirtSigInfo; + +typedef struct rz_flirt_pat_info_t { + ut32 n_modules; ///< FLIRT pat total number of modules/signatures contained +} RzFlirtPatInfo; + +typedef struct rz_flirt_info_t { + RzFlirtFileType type; ///< Flirt file type + union { + RzFlirtSigInfo sig; ///< Sig info + RzFlirtPatInfo pat; ///< Pat info + } u; +} RzFlirtInfo; + +RZ_API ut32 rz_sign_flirt_node_count_nodes(RZ_NONNULL const RzFlirtNode *node); +RZ_API RZ_OWN RzFlirtNode *rz_sign_flirt_node_new(RZ_NONNULL RzAnalysis *analysis, ut32 optimization, bool ignore_unknown); +RZ_API RZ_OWN RzFlirtNode *rz_sign_flirt_node_from_function(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *func, bool tail_bytes); +RZ_API void rz_sign_flirt_node_free(RZ_NULLABLE RzFlirtNode *node); +RZ_API void rz_sign_flirt_info_fini(RZ_NULLABLE RzFlirtInfo *info); + +RZ_API bool rz_sign_flirt_apply(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL const char *flirt_file, ut8 expected_arch); + +typedef struct rz_flirt_compressed_options_t { + ut8 version; ///< FLIRT version (supported only from v5 to v10) + ut8 arch; ///< FLIRT arch type (RZ_FLIRT_SIG_ARCH_*) + ut32 file; ///< FLIRT file type (RZ_FLIRT_SIG_FILE_*) + ut16 os; ///< FLIRT os type (RZ_FLIRT_SIG_OS_*) + ut16 app; ///< FLIRT app type (RZ_FLIRT_SIG_APP_*) + bool deflate; + const char *libname; +} RzFlirtCompressedOptions; + +RZ_API RZ_OWN bool rz_sign_flirt_parse_header_compressed_pattern_from_buffer(RZ_NONNULL RzBuffer *flirt_buf, RZ_NONNULL RzFlirtInfo *info); +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); +RZ_API bool rz_sign_flirt_write_compressed_pattern_to_buffer(RZ_NONNULL const RzFlirtNode *node, RZ_NONNULL RzBuffer *buffer, RzFlirtCompressedOptions *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); +RZ_API bool rz_sign_flirt_write_string_pattern_to_buffer(RZ_NONNULL const RzFlirtNode *node, RZ_NONNULL RzBuffer *buffer); + +typedef struct rz_signature_database_entry_t { + char *bin_name; ///< RzBinPlugin name (elf64 and pe64 are named as elf and pe) + char *arch_name; ///< RzAsmPlugin name + ut32 arch_bits; ///< Architecture bits + 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 + char *details; ///< signature name / description (only for .sig files) + ut32 n_modules; ///< signature number of modules +} RzSigDBEntry; + +typedef struct rz_signature_db_t { + HtPU *entries; +} RzSigDb; + +RZ_API void rz_sign_sigdb_signature_free(RZ_NULLABLE RzSigDBEntry *entry); +RZ_API RZ_OWN RzSigDb *rz_sign_sigdb_new(void); +RZ_API void rz_sign_sigdb_free(RzSigDb *db); +RZ_API RZ_OWN RzSigDb *rz_sign_sigdb_load_database(RZ_NONNULL const char *sigdb_path, bool with_details); +RZ_API bool rz_sign_sigdb_add_entry(RZ_NONNULL RzSigDb *db, RZ_NONNULL const RzSigDBEntry *entry); +RZ_API bool rz_sign_sigdb_merge(RZ_NONNULL RzSigDb *db, RZ_NONNULL RzSigDb *db2); +RZ_API RZ_OWN RzList /**/ *rz_sign_sigdb_list(RZ_NONNULL const RzSigDb *db); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_FLIRT_H */ diff --git a/dest/include/librz/rz_getopt.h b/dest/include/librz/rz_getopt.h new file mode 100644 index 00000000000..44c5b417848 --- /dev/null +++ b/dest/include/librz/rz_getopt.h @@ -0,0 +1,29 @@ +#ifndef RZ_GETOPT_H +#define RZ_GETOPT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rz_getopt_t { + int err; + int ind; + int opt; + int reset; + const char *arg; + // ... + int argc; + const char **argv; + const char *ostr; +} RzGetopt; + +RZ_API void rz_getopt_init(RzGetopt *go, int argc, const char **argv, const char *ostr); +RZ_API int rz_getopt_next(RzGetopt *opt); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_hash.h b/dest/include/librz/rz_hash.h new file mode 100644 index 00000000000..f9f313173c1 --- /dev/null +++ b/dest/include/librz/rz_hash.h @@ -0,0 +1,182 @@ +// SPDX-FileCopyrightText: 2021 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_MSG_DIGEST_H +#define RZ_MSG_DIGEST_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_hash); + +typedef enum { + RZ_MSG_DIGEST_STATUS_ALLOC = 0, + RZ_MSG_DIGEST_STATUS_INIT, + RZ_MSG_DIGEST_STATUS_UPDATE, + RZ_MSG_DIGEST_STATUS_FINAL, +} RzHashStatus; + +typedef ut32 RzHashSize; + +typedef struct rz_hash_plugin_t { + const char *name; + const char *license; + const char *author; + const char *description; + bool support_hmac; + void *(*context_new)(); + void (*context_free)(void *context); + RzHashSize (*digest_size)(void *context); + RzHashSize (*block_size)(void *context); + bool (*init)(void *context); + bool (*update)(void *context, const ut8 *data, ut64 size); + bool (*final)(void *context, ut8 *digest); + bool (*small_block)(const ut8 *data, ut64 size, ut8 **digest, RzHashSize *digest_size); +} RzHashPlugin; + +typedef struct rz_hash_t { + HtSP /**/ *plugins; +} RzHash; + +typedef struct rz_hash_cfg_t { + RzList /**/ *configurations; + RzHashStatus status; + const RzHash *hash; ///< Immutable RzHash instance. +} RzHashCfg; + +/** + * \brief Compare plugins by name (via strcmp). + */ +static inline int rz_hash_plugin_cmp(RZ_NULLABLE const RzHashPlugin *a, RZ_NULLABLE const RzHashPlugin *b) { + if (!a && !b) { + return 0; + } else if (!a) { + return -1; + } else if (!b) { + return 1; + } + return rz_str_cmp(a->name, b->name, -1); +} + +#ifdef RZ_API + +RZ_API RzHash *rz_hash_new(void); +RZ_API void rz_hash_free(RZ_NULLABLE RzHash *rh); +RZ_API bool rz_hash_plugin_add(RZ_NONNULL RzHash *rh, RZ_NONNULL RZ_OWN RzHashPlugin *plugin); +RZ_API bool rz_hash_plugin_del(RZ_NONNULL RzHash *rh, RZ_NONNULL RzHashPlugin *plugin); +RZ_API RZ_BORROW const RzHashPlugin *rz_hash_plugin_by_name(const RZ_NONNULL RzHash *rh, RZ_NONNULL const char *name); + +RZ_API RZ_OWN RzHashCfg *rz_hash_cfg_new(const RZ_NONNULL RzHash *rh); +RZ_API RZ_OWN RzHashCfg *rz_hash_cfg_new_with_algo(const RZ_NONNULL RzHash *rh, RZ_NONNULL const char *name, RZ_NULLABLE const ut8 *key, ut64 key_size); +#define rz_hash_cfg_new_with_algo2(rh, name) rz_hash_cfg_new_with_algo(rh, name, NULL, 0); +RZ_API void rz_hash_cfg_free(RZ_NONNULL RzHashCfg *md); + +RZ_API bool rz_hash_cfg_configure(RZ_NONNULL RzHashCfg *md, RZ_NONNULL const char *name); +RZ_API bool rz_hash_cfg_hmac(RZ_NONNULL RzHashCfg *md, RZ_NONNULL const ut8 *key, ut64 key_size); +RZ_API bool rz_hash_cfg_init(RZ_NONNULL RzHashCfg *md); +RZ_API bool rz_hash_cfg_update(RZ_NONNULL RzHashCfg *md, RZ_NONNULL const ut8 *data, ut64 size); +RZ_API bool rz_hash_cfg_final(RZ_NONNULL RzHashCfg *md); +RZ_API bool rz_hash_cfg_iterate(RZ_NONNULL RzHashCfg *md, size_t iterate); +RZ_API RZ_BORROW const ut8 *rz_hash_cfg_get_result(RZ_NONNULL RzHashCfg *md, RZ_NONNULL const char *name, RZ_NULLABLE RzHashSize *size); +RZ_API RZ_OWN char *rz_hash_cfg_get_result_string(RZ_NONNULL RzHashCfg *md, RZ_NONNULL const char *name, RZ_NULLABLE ut32 *size, bool invert); +RZ_API RzHashSize rz_hash_cfg_size(RZ_NONNULL RzHashCfg *md, RZ_NONNULL const char *name); +RZ_API RZ_OWN ut8 *rz_hash_cfg_calculate_small_block(RZ_NONNULL RzHash *rh, RZ_NONNULL const char *name, RZ_NONNULL const ut8 *buffer, ut64 bsize, RZ_NONNULL RzHashSize *osize); +RZ_API RZ_OWN char *rz_hash_cfg_calculate_small_block_string(RZ_NONNULL RzHash *rh, RZ_NONNULL const char *name, RZ_NONNULL const ut8 *buffer, ut64 bsize, RZ_NULLABLE ut32 *size, bool invert); +RZ_API RZ_OWN char *rz_hash_cfg_randomart(RZ_NONNULL const ut8 *buffer, ut32 length, ut64 address); + +RZ_API double rz_hash_ssdeep_compare(RZ_NONNULL const char *hash1, RZ_NONNULL const char *hash2); +RZ_API RZ_OWN char *rz_hash_ssdeep(RZ_NONNULL const ut8 *input, size_t size); +RZ_API ut32 rz_hash_xxhash(RZ_NONNULL const ut8 *input, size_t size); +RZ_API double rz_hash_entropy(RZ_NONNULL const ut8 *data, ut64 len); +RZ_API double rz_hash_entropy_fraction(RZ_NONNULL const ut8 *data, ut64 len); + +#endif + +/* importing all message digest plugins */ +extern RzHashPlugin rz_hash_plugin_md2; +extern RzHashPlugin rz_hash_plugin_md4; +extern RzHashPlugin rz_hash_plugin_md5; +extern RzHashPlugin rz_hash_plugin_sha1; +extern RzHashPlugin rz_hash_plugin_sha256; +extern RzHashPlugin rz_hash_plugin_sha384; +extern RzHashPlugin rz_hash_plugin_sha512; +extern RzHashPlugin rz_hash_plugin_fletcher8; +extern RzHashPlugin rz_hash_plugin_fletcher16; +extern RzHashPlugin rz_hash_plugin_fletcher32; +extern RzHashPlugin rz_hash_plugin_fletcher64; +extern RzHashPlugin rz_hash_plugin_adler32; +extern RzHashPlugin rz_hash_plugin_mod255; +extern RzHashPlugin rz_hash_plugin_crca_crc8smbus; +extern RzHashPlugin rz_hash_plugin_crca_crc8cdma2000; +extern RzHashPlugin rz_hash_plugin_crca_crc8darc; +extern RzHashPlugin rz_hash_plugin_crca_crc8dvbs2; +extern RzHashPlugin rz_hash_plugin_crca_crc8ebu; +extern RzHashPlugin rz_hash_plugin_crca_crc8icode; +extern RzHashPlugin rz_hash_plugin_crca_crc8itu; +extern RzHashPlugin rz_hash_plugin_crca_crc8maxim; +extern RzHashPlugin rz_hash_plugin_crca_crc8rohc; +extern RzHashPlugin rz_hash_plugin_crca_crc8wcdma; +extern RzHashPlugin rz_hash_plugin_crca_crc15can; +extern RzHashPlugin rz_hash_plugin_crca_crc16; +extern RzHashPlugin rz_hash_plugin_crca_crc16citt; +extern RzHashPlugin rz_hash_plugin_crca_crc16usb; +extern RzHashPlugin rz_hash_plugin_crca_crc16hdlc; +extern RzHashPlugin rz_hash_plugin_crca_crc16augccitt; +extern RzHashPlugin rz_hash_plugin_crca_crc16buypass; +extern RzHashPlugin rz_hash_plugin_crca_crc16cdma2000; +extern RzHashPlugin rz_hash_plugin_crca_crc16dds110; +extern RzHashPlugin rz_hash_plugin_crca_crc16dectr; +extern RzHashPlugin rz_hash_plugin_crca_crc16dectx; +extern RzHashPlugin rz_hash_plugin_crca_crc16dnp; +extern RzHashPlugin rz_hash_plugin_crca_crc16en13757; +extern RzHashPlugin rz_hash_plugin_crca_crc16genibus; +extern RzHashPlugin rz_hash_plugin_crca_crc16maxim; +extern RzHashPlugin rz_hash_plugin_crca_crc16mcrf4xx; +extern RzHashPlugin rz_hash_plugin_crca_crc16riello; +extern RzHashPlugin rz_hash_plugin_crca_crc16t10dif; +extern RzHashPlugin rz_hash_plugin_crca_crc16teledisk; +extern RzHashPlugin rz_hash_plugin_crca_crc16tms37157; +extern RzHashPlugin rz_hash_plugin_crca_crca; +extern RzHashPlugin rz_hash_plugin_crca_crc16kermit; +extern RzHashPlugin rz_hash_plugin_crca_crc16modbus; +extern RzHashPlugin rz_hash_plugin_crca_crc16x25; +extern RzHashPlugin rz_hash_plugin_crca_crc16xmodem; +extern RzHashPlugin rz_hash_plugin_crca_crc24; +extern RzHashPlugin rz_hash_plugin_crca_crc32; +extern RzHashPlugin rz_hash_plugin_crca_crc32ecma267; +extern RzHashPlugin rz_hash_plugin_crca_crc32c; +extern RzHashPlugin rz_hash_plugin_crca_crc32bzip2; +extern RzHashPlugin rz_hash_plugin_crca_crc32d; +extern RzHashPlugin rz_hash_plugin_crca_crc32mpeg2; +extern RzHashPlugin rz_hash_plugin_crca_crc32posix; +extern RzHashPlugin rz_hash_plugin_crca_crc32q; +extern RzHashPlugin rz_hash_plugin_crca_crc32jamcrc; +extern RzHashPlugin rz_hash_plugin_crca_crc32xfer; +extern RzHashPlugin rz_hash_plugin_crca_crc64; +extern RzHashPlugin rz_hash_plugin_crca_crc64ecma182; +extern RzHashPlugin rz_hash_plugin_crca_crc64we; +extern RzHashPlugin rz_hash_plugin_crca_crc64xz; +extern RzHashPlugin rz_hash_plugin_crca_crc64iso; +extern RzHashPlugin rz_hash_plugin_xor8; +extern RzHashPlugin rz_hash_plugin_xor16; +extern RzHashPlugin rz_hash_plugin_xxhash32; +extern RzHashPlugin rz_hash_plugin_parity; +extern RzHashPlugin rz_hash_plugin_entropy; +extern RzHashPlugin rz_hash_plugin_entropy_fract; +extern RzHashPlugin rz_hash_plugin_blake3; +extern RzHashPlugin rz_hash_plugin_ssdeep; +extern RzHashPlugin rz_hash_plugin_sm3; +extern RzHashPlugin rz_hash_plugin_temperature; + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_MSG_DIGEST_H */ diff --git a/dest/include/librz/rz_heap_glibc.h b/dest/include/librz/rz_heap_glibc.h new file mode 100644 index 00000000000..84419963cd8 --- /dev/null +++ b/dest/include/librz/rz_heap_glibc.h @@ -0,0 +1,371 @@ +#ifndef RZ_HEAP_GLIBC_H +#define RZ_HEAP_GLIBC_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_heap_glibc); + +#define PRINTF_A(color, fmt, ...) rz_cons_printf("%s" fmt "%s", \ + rz_config_get_i(core->config, "scr.color") > 0 ? color : "", \ + __VA_ARGS__, \ + rz_config_get_i(core->config, "scr.color") > 0 ? Color_RESET : "") +#define PRINTF_YA(fmt, ...) PRINTF_A(pal->offset, fmt, __VA_ARGS__) +#define PRINTF_GA(fmt, ...) PRINTF_A(pal->args, fmt, __VA_ARGS__) +#define PRINTF_BA(fmt, ...) PRINTF_A(pal->num, fmt, __VA_ARGS__) +#define PRINTF_RA(fmt, ...) PRINTF_A(pal->invalid, fmt, __VA_ARGS__) + +#define PRINT_A(color, msg) rz_cons_printf("%s%s%s", \ + rz_config_get_i(core->config, "scr.color") > 0 ? color : "", \ + msg, \ + rz_config_get_i(core->config, "scr.color") > 0 ? Color_RESET : "") +#define PRINT_YA(msg) PRINT_A(pal->offset, msg) +#define PRINT_GA(msg) PRINT_A(pal->args, msg) +#define PRINT_BA(msg) PRINT_A(pal->num, msg) +#define PRINT_RA(msg) PRINT_A(pal->invalid, msg) + +#define PREV_INUSE 0x1 +#define IS_MMAPPED 0x2 +#define NON_MAIN_ARENA 0x4 + +#define NBINS 128 +#define NSMALLBINS 64 +#define NFASTBINS 10 +#define BINMAPSHIFT 5 +#define SZ core->dbg->bits +#define FASTBIN_IDX_TO_SIZE(i) ((SZ * 4) + (SZ * 2) * (i - 1)) +#define BITSPERMAP (1U << BINMAPSHIFT) +#define BINMAPSIZE (NBINS / BITSPERMAP) +#define NPAD -6 +#define TCACHE_MAX_BINS 64 +#define TCACHE_FILL_COUNT 7 +#define TCACHE_NEW_VERSION 230 + +#define MMAP_ALIGN_32 0x14 +#define MMAP_ALIGN_64 0x18 +#define MMAP_OFFSET 0x8 + +#define HDR_SZ_32 0x8 +#define HDR_SZ_64 0x10 +#define TC_HDR_SZ 0x10 +#define TC_SZ_32 0x0 +#define TC_SZ_64 0x10 +#define HEAP_PAGE_SIZE 0x21000 +#define HEAP_PAGE_SIZE_X86 0x22000 + +// Introduced with glibc 2.32 + +#define largebin_index_32(size) \ + (((((ut32)(size)) >> 6) <= 38) ? 56 + (((ut32)(size)) >> 6) : ((((ut32)(size)) >> 9) <= 20) ? 91 + (((ut32)(size)) >> 9) \ + : ((((ut32)(size)) >> 12) <= 10) ? 110 + (((ut32)(size)) >> 12) \ + : ((((ut32)(size)) >> 15) <= 4) ? 119 + (((ut32)(size)) >> 15) \ + : ((((ut32)(size)) >> 18) <= 2) ? 124 + (((ut32)(size)) >> 18) \ + : 126) +#define largebin_index_32_big(size) \ + (((((ut32)(size)) >> 6) <= 45) ? 49 + (((ut32)(size)) >> 6) : ((((ut32)(size)) >> 9) <= 20) ? 91 + (((ut32)(size)) >> 9) \ + : ((((ut32)(size)) >> 12) <= 10) ? 110 + (((ut32)(size)) >> 12) \ + : ((((ut32)(size)) >> 15) <= 4) ? 119 + (((ut32)(size)) >> 15) \ + : ((((ut32)(size)) >> 18) <= 2) ? 124 + (((ut32)(size)) >> 18) \ + : 126) +#define largebin_index_64(size) \ + (((((ut32)(size)) >> 6) <= 48) ? 48 + (((ut32)(size)) >> 6) : ((((ut32)(size)) >> 9) <= 20) ? 91 + (((ut32)(size)) >> 9) \ + : ((((ut32)(size)) >> 12) <= 10) ? 110 + (((ut32)(size)) >> 12) \ + : ((((ut32)(size)) >> 15) <= 4) ? 119 + (((ut32)(size)) >> 15) \ + : ((((ut32)(size)) >> 18) <= 2) ? 124 + (((ut32)(size)) >> 18) \ + : 126) + +#define largebin_index(size) \ + (SZ == 8 ? largebin_index_64(size) : largebin_index_32(size)) + +#define fastbin_index(size) \ + (SZ == 8 ? (size >> 4) - 2 : (size >> 3) - 2) +/* Not works 32 bit on 64 emulation +#define largebin_index(size) \ + (SZ == 8 ? largebin_index_64 (size) \ + : MALLOC_ALIGNMENT == 16 ? largebin_index_32_big (size) \ + : largebin_index_32 (size)) +*/ + +typedef struct rz_malloc_chunk_64 { + ut64 prev_size; /* Size of previous chunk (if free). */ + ut64 size; /* Size in bytes, including overhead. */ + + ut64 fd; /* double links -- used only if free. */ + ut64 bk; + + /* Only used for large blocks: pointer to next larger size. */ + ut64 fd_nextsize; /* double links -- used only if free. */ + ut64 bk_nextsize; +} RzHeapChunk_64; + +typedef struct rz_malloc_chunk_32 { + ut32 prev_size; /* Size of previous chunk (if free). */ + ut32 size; /* Size in bytes, including overhead. */ + + ut32 fd; /* double links -- used only if free. */ + ut32 bk; + + /* Only used for large blocks: pointer to next larger size. */ + ut32 fd_nextsize; /* double links -- used only if free. */ + ut32 bk_nextsize; +} RzHeapChunk_32; + +/* +typedef RzHeapChunk64 *mfastbinptr64; +typedef RzHeapChunk64 *mchunkptr64; + +typedef RzHeapChunk32 *mfastbinptr32; +typedef RzHeapChunk32 *mchunkptr32; +*/ + +typedef struct rz_malloc_state_32 { + int mutex; /* serialized access */ + int flags; /* flags */ + int have_fastchunks; /* new free blocks in fastbin chunks? */ + ut32 fastbinsY[NFASTBINS]; /* array of fastchunks */ + ut32 top; /* top chunk's base addr */ + ut32 last_remainder; /* remainder top chunk's addr */ + ut32 bins[NBINS * 2 - 2]; /* array of remainder free chunks */ + unsigned int binmap[BINMAPSIZE]; /* bitmap of bins */ + ut32 next; /* double linked list of chunks */ + ut32 next_free; /* double linked list of free chunks */ + unsigned int attached_threads; /* threads attached */ + ut32 system_mem; /* current allocated memory of current arena */ + ut32 max_system_mem; /* maximum system memory */ +} RzHeap_MallocState_32; + +typedef struct rz_malloc_state_64 { + int mutex; /* serialized access */ + int flags; /* flags */ + int have_fastchunks; /* new free blocks in fastbin chunks? */ + ut64 fastbinsY[NFASTBINS]; /* array of fastchunks */ + ut64 top; /* top chunk's base addr */ + ut64 last_remainder; /* remainder top chunk's addr */ + ut64 bins[NBINS * 2 - 2]; /* array of remainder free chunks */ + unsigned int binmap[BINMAPSIZE]; /* bitmap of bins */ + ut64 next; /* double linked list of chunks */ + ut64 next_free; /* double linked list of free chunks */ + unsigned int attached_threads; /* threads attached */ + ut64 system_mem; /* current allocated memory of current arena */ + ut64 max_system_mem; /* maximum system memory */ +} RzHeap_MallocState_64; + +typedef struct rz_tcache_perthread_struct_32 { + ut16 counts[TCACHE_MAX_BINS]; + ut32 entries[TCACHE_MAX_BINS]; +} RzHeapTcache_32; + +typedef struct rz_tcache_perthread_struct_64 { + ut16 counts[TCACHE_MAX_BINS]; + ut64 entries[TCACHE_MAX_BINS]; +} RzHeapTcache_64; + +typedef struct rz_tcache_perthread_struct_pre_230_32 { + ut8 counts[TCACHE_MAX_BINS]; + ut32 entries[TCACHE_MAX_BINS]; +} RzHeapTcachePre230_32; + +typedef struct rz_tcache_perthread_struct_pre_230_64 { + ut8 counts[TCACHE_MAX_BINS]; + ut64 entries[TCACHE_MAX_BINS]; +} RzHeapTcachePre230_64; + +typedef enum { NEW, + OLD } tcache_type; + +typedef struct { + tcache_type type; + union { + RzHeapTcache_64 *heap_tcache; + RzHeapTcachePre230_64 *heap_tcache_pre_230; + } RzHeapTcache; +} RTcache_64; + +typedef struct { + tcache_type type; + union { + RzHeapTcache_32 *heap_tcache; + RzHeapTcachePre230_32 *heap_tcache_pre_230; + } RzHeapTcache; +} RTcache_32; + +typedef struct rz_malloc_state_tcache_32 { + int mutex; /* serialized access */ + int flags; /* flags */ + int have_fast_chunks; /* have fast chunks */ + ut32 fastbinsY[NFASTBINS + 1]; /* array of fastchunks */ + ut32 top; /* top chunk's base addr */ + ut32 last_remainder; /* remainder top chunk's addr */ + ut32 bins[NBINS * 2 - 2]; /* array of remainder free chunks */ + unsigned int binmap[BINMAPSIZE]; /* bitmap of bins */ + ut32 next; /* double linked list of chunks */ + ut32 next_free; /* double linked list of free chunks */ + unsigned int attached_threads; /* threads attached */ + ut32 system_mem; /* current allocated memory of current arena */ + ut32 max_system_mem; /* maximum system memory */ +} RzHeap_MallocState_tcache_32; + +typedef struct rz_malloc_state_tcache_64 { + int mutex; /* serialized access */ + int flags; /* flags */ + int have_fast_chunks; /* have fast chunks */ + ut64 fastbinsY[NFASTBINS]; /* array of fastchunks */ + ut64 top; /* top chunk's base addr */ + ut64 last_remainder; /* remainder top chunk's addr */ + ut64 bins[NBINS * 2 - 2]; /* array of remainder free chunks */ + unsigned int binmap[BINMAPSIZE]; /* bitmap of bins */ + ut64 next; /* double linked list of chunks */ + ut64 next_free; /* double linked list of free chunks */ + unsigned int attached_threads; /* threads attached */ + ut64 system_mem; /* current allocated memory of current arena */ + ut64 max_system_mem; /* maximum system memory */ +} RzHeap_MallocState_tcache_64; + +typedef struct rz_malloc_state { + int mutex; /* serialized access */ + int flags; /* flags */ + unsigned int binmap[BINMAPSIZE]; /* bitmap of bins */ + + /*tcache*/ + int have_fast_chunks; /* have fast chunks */ + unsigned int attached_threads; /* threads attached */ + + /*64 bits members */ + ut64 fastbinsY[NFASTBINS]; /* array of fastchunks */ + ut64 top; /* top chunk's base addr */ + ut64 last_remainder; /* remainder top chunk's addr */ + ut64 bins[NBINS * 2 - 2]; /* array of remainder free chunks */ + ut64 next; /* double linked list of chunks */ + ut64 next_free; /* double linked list of free chunks */ + ut64 system_mem; /* current allocated memory of current arena */ + ut64 max_system_mem; /* maximum system memory */ +} MallocState; + +typedef struct rz_heap_info_32 { + ut32 ar_ptr; /* Arena for this heap. */ + ut32 prev; /* Previous heap. */ + ut32 size; /* Current size in bytes. */ + ut32 mprotect_size; /* Size in bytes that has been mprotected PROT_READ|PROT_WRITE. */ + + /* Make sure the following data is properly aligned, particularly + that sizeof (heap_info) + 2 * SZ is a multiple of + MALLOC_ALIGNMENT. */ + /* char pad[NPAD * SZ & MALLOC_ALIGN_MASK]; */ +} RzHeapInfo_32; + +typedef struct rz_heap_info_64 { + ut64 ar_ptr; /* Arena for this heap. */ + ut64 prev; /* Previous heap. */ + ut64 size; /* Current size in bytes. */ + ut64 mprotect_size; /* Size in bytes that has been mprotected PROT_READ|PROT_WRITE. */ + + /* Make sure the following data is properly aligned, particularly + that sizeof (heap_info) + 2 * SZ is a multiple of + MALLOC_ALIGNMENT. */ + /* char pad[NPAD * SZ & MALLOC_ALIGN_MASK]; */ +} RzHeapInfo_64; + +typedef enum rz_heap_bin_type { + RZ_HEAP_BIN_ANY, + RZ_HEAP_BIN_TCACHE, + RZ_HEAP_BIN_FAST, + RZ_HEAP_BIN_UNSORTED, + RZ_HEAP_BIN_SMALL, + RZ_HEAP_BIN_LARGE +} RzHeapBinType; + +typedef struct rz_heap_chunk_list_item { + ut64 addr; /* Base addr of the chunk */ + ut64 size; /* Size of the chunk */ + char *status; /* Status of the chunk, allocated/free/corrupted */ +} RzHeapChunkListItem; + +typedef struct rz_arena_list_item { + ut64 addr; /* Base addr of the arena */ + char *type; /* Type of arena, main/thread */ + MallocState *arena; /* The MallocState for the arena */ +} RzArenaListItem; + +typedef struct rz_heap_chunk_simple { + ut64 addr; /* Base addr of the chunk*/ + ut64 prev_size; /* size of prev_chunk*/ + ut64 size; /* size of chunk */ + bool non_main_arena; /* flag for NON_MAIN_ARENA */ + bool prev_inuse; /* flag for PREV_INUSE*/ + bool is_mmapped; /* flag for IS_MMAPPED*/ + ut64 fd; /* fd pointer, only if free */ + ut64 bk; /* bk pointer, only if free */ + ut64 fd_nextsize; /* fd nextsize pointer, only if free */ + ut64 bk_nextsize; /* bk nextsize pointer, only if free */ +} RzHeapChunkSimple; + +typedef struct rz_heap_bin { + ut64 addr; + ut64 size; + ut64 fd; + ut64 bk; + int bin_num; + char *type; + RzList /**/ *chunks; /* list of chunks in the bins */ + char *message; /* indicating the list is corrupted or double free*/ +} RzHeapBin; + +RZ_API RzHeapChunkSimple *rz_heap_chunk_wrapper_32(RzCore *core, ut32 addr); +RZ_API RzHeapChunkSimple *rz_heap_chunk_wrapper_64(RzCore *core, ut64 addr); + +RZ_API RzHeapChunk_64 *rz_heap_get_chunk_at_addr_64(RzCore *core, ut64 addr); +RZ_API RzHeapChunk_32 *rz_heap_get_chunk_at_addr_32(RzCore *core, ut32 addr); + +RZ_API RzList /**/ *rz_heap_arenas_list_64(RzCore *core, ut64 m_arena, MallocState *main_arena); +RZ_API RzList /**/ *rz_heap_arenas_list_32(RzCore *core, ut32 m_arena, MallocState *main_arena); + +RZ_API RzList /**/ *rz_heap_chunks_list_64(RzCore *core, MallocState *main_arena, ut64 m_arena, ut64 m_state, bool top_chunk); +RZ_API RzList /**/ *rz_heap_chunks_list_32(RzCore *core, MallocState *main_arena, ut32 m_arena, ut32 m_state, bool top_chunk); + +RZ_API bool rz_heap_resolve_main_arena_64(RzCore *core, ut64 *m_arena); +RZ_API bool rz_heap_resolve_main_arena_32(RzCore *core, ut32 *m_arena); +RZ_API double rz_get_glibc_version_64(RzCore *core, const char *libc_path, ut8 *banner); +RZ_API double rz_get_glibc_version_32(RzCore *core, const char *libc_path, ut8 *banner); + +RZ_API bool rz_heap_update_main_arena_64(RzCore *core, ut64 m_arena, MallocState *main_arena); +RZ_API bool rz_heap_update_main_arena_32(RzCore *core, ut32 m_arena, MallocState *main_arena); + +RZ_API bool rz_heap_write_heap_chunk_64(RzCore *core, RzHeapChunkSimple *chunk_simple); +RZ_API bool rz_heap_write_heap_chunk_32(RzCore *core, RzHeapChunkSimple *chunk_simple); + +RZ_API RzList /**/ *rz_heap_tcache_content_64(RzCore *core, ut64 arena_base); +RZ_API RzList /**/ *rz_heap_tcache_content_32(RzCore *core, ut32 arena_base); + +RZ_API MallocState *rz_heap_get_arena_64(RzCore *core, ut64 m_state); +RZ_API MallocState *rz_heap_get_arena_32(RzCore *core, ut32 m_state); + +RZ_API RzHeapBin *rz_heap_fastbin_content_64(RzCore *core, MallocState *main_arena, int bin_num); +RZ_API RzHeapBin *rz_heap_fastbin_content_32(RzCore *core, MallocState *main_arena, int bin_num); + +RZ_API RzHeapBin *rz_heap_bin_content_64(RzCore *core, MallocState *main_arena, int bin_num, ut64 m_arena); +RZ_API RzHeapBin *rz_heap_bin_content_32(RzCore *core, MallocState *main_arena, int bin_num, ut32 m_arena); + +RZ_API RzList /**/ *rz_heap_chunks_list_wrapper_64(RzCore *core, ut64 m_state); +RZ_API RzList /**/ *rz_heap_chunks_list_wrapper_32(RzCore *core, ut64 m_state); + +RZ_API RzList /**/ *rz_heap_arena_list_wrapper_64(RzCore *core); +RZ_API RzList /**/ *rz_heap_arena_list_wrapper_32(RzCore *core); + +RZ_IPI RzCmdStatus rz_cmd_heap_fastbins_print_handler_64(void *data, const char *input); +RZ_IPI RzCmdStatus rz_cmd_heap_fastbins_print_handler_32(void *data, const char *input); + +RZ_IPI RzCmdStatus rz_cmd_heap_bins_list_print_handler_64(RzCore *core, const char *input, RzOutputMode mode); +RZ_IPI RzCmdStatus rz_cmd_heap_bins_list_print_handler_32(RzCore *core, const char *input, RzOutputMode mode); + +RZ_API void rz_heap_bin_free_64(RzHeapBin *bin); +RZ_API void rz_heap_bin_free_32(RzHeapBin *bin); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/dest/include/librz/rz_heap_jemalloc.h b/dest/include/librz/rz_heap_jemalloc.h new file mode 100644 index 00000000000..f6a1c705f12 --- /dev/null +++ b/dest/include/librz/rz_heap_jemalloc.h @@ -0,0 +1,87 @@ +// SPDX-FileCopyrightText: 2026 bubblepipe + +// Allow re-entry for 32-bit pass +#if !defined(RZ_HEAP_JEMALLOC_H_TYPES) || defined(INC_HEAP32) + +#ifndef INC_HEAP32 +// First pass: 64-bit +#define GH(x) x##_64 +typedef ut64 RZ_ALIGNED(8) GHT_64; +typedef st64 RZ_ALIGNED(8) GHST_64; +#define GHT GHT_64 +#define GHT_MAX UT64_MAX +#define GHST GHST_64 +#define GH_IS_64 1 +#else +// Second pass: 32-bit +#undef GH +#undef GHT +#undef GHT_MAX +#undef GHST +#undef GH_IS_64 +#define GH(x) x##_32 +typedef ut32 RZ_ALIGNED(4) GHT_32; +typedef st32 RZ_ALIGNED(4) GHST_32; +#define GHT GHT_32 +#define GHT_MAX UT32_MAX +#define GHST GHST_32 +#endif + +#include + +#ifndef INC_HEAP32 +#undef JEMALLOC_INTERNAL_H +#define INC_HEAP32 1 +#include "rz_heap_jemalloc.h" +#undef INC_HEAP32 +#define RZ_HEAP_JEMALLOC_H_TYPES +#endif + +#endif // RZ_HEAP_JEMALLOC_H_TYPES + +#ifndef RZ_HEAP_JEMALLOC_H +#define RZ_HEAP_JEMALLOC_H + +#undef PRINTF_A +#undef PRINTF_YA +#undef PRINTF_GA +#undef PRINTF_BA +#undef PRINTF_RA + +#define PRINTF_A(color, fmt, ...) \ + do { \ + if ((color) && rz_config_get_i(core->config, "scr.color") > 0) { \ + rz_cons_print(color); \ + } \ + rz_cons_printf(fmt, __VA_ARGS__); \ + if ((color) && rz_config_get_i(core->config, "scr.color") > 0) { \ + rz_cons_print(Color_RESET); \ + } \ + } while (0) +#define PRINTF_YA(fmt, ...) PRINTF_A(pal->offset, fmt, __VA_ARGS__) +#define PRINTF_GA(fmt, ...) PRINTF_A(pal->args, fmt, __VA_ARGS__) +#define PRINTF_BA(fmt, ...) PRINTF_A(pal->num, fmt, __VA_ARGS__) +#define PRINTF_RA(fmt, ...) PRINTF_A(pal->invalid, fmt, __VA_ARGS__) + +#undef PRINT_A +#undef PRINT_YA +#undef PRINT_GA +#undef PRINT_BA +#undef PRINT_RA + +#define PRINT_A(color, msg) \ + do { \ + if ((color) && rz_config_get_i(core->config, "scr.color") > 0) { \ + rz_cons_print(color); \ + } \ + rz_cons_print(msg); \ + if ((color) && rz_config_get_i(core->config, "scr.color") > 0) { \ + rz_cons_print(Color_RESET); \ + } \ + } while (0) +#define PRINT_YA(msg) PRINT_A(pal->offset, msg) +#define PRINT_GA(msg) PRINT_A(pal->args, msg) +#define PRINT_BA(msg) PRINT_A(pal->num, msg) +#define PRINT_RA(msg) PRINT_A(pal->invalid, msg) + +#endif diff --git a/dest/include/librz/rz_il.h b/dest/include/librz/rz_il.h new file mode 100644 index 00000000000..2352fe2946b --- /dev/null +++ b/dest/include/librz/rz_il.h @@ -0,0 +1,9 @@ +#ifndef RZ_IL_H +#define RZ_IL_H + +#include +#include +#include +#include + +#endif // RZ_IL_H diff --git a/dest/include/librz/rz_il/definitions/bool.h b/dest/include/librz/rz_il/definitions/bool.h new file mode 100644 index 00000000000..50d6c9adadb --- /dev/null +++ b/dest/include/librz/rz_il/definitions/bool.h @@ -0,0 +1,29 @@ +// SPDX-FileCopyrightText: 2021 heersin +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_IL_BOOL_H +#define RZ_IL_BOOL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rz_il_bool_t { + bool b; +} RzILBool; + +RZ_API RzILBool *rz_il_bool_new(bool true_or_false); +RZ_API RzILBool *rz_il_bool_and(RZ_NONNULL RzILBool *a, RZ_NONNULL RzILBool *b); +RZ_API RzILBool *rz_il_bool_or(RZ_NONNULL RzILBool *a, RZ_NONNULL RzILBool *b); +RZ_API RzILBool *rz_il_bool_xor(RZ_NONNULL RzILBool *a, RZ_NONNULL RzILBool *b); +RZ_API RzILBool *rz_il_bool_not(RZ_NONNULL RzILBool *a); +RZ_API void rz_il_bool_free(RzILBool *bool_var); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_IL_BOOL_H diff --git a/dest/include/librz/rz_il/definitions/definitions.h b/dest/include/librz/rz_il/definitions/definitions.h new file mode 100644 index 00000000000..985af5e93f1 --- /dev/null +++ b/dest/include/librz/rz_il/definitions/definitions.h @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: 2021 heersin +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_IL_DEFINITIONS_H +#define RZ_IL_DEFINITIONS_H + +#include +#include +#include +#include +#include +#include +#include + +#endif // RZ_IL_DEFINITIONS_H diff --git a/dest/include/librz/rz_il/definitions/float.h b/dest/include/librz/rz_il/definitions/float.h new file mode 100644 index 00000000000..2445ea658fb --- /dev/null +++ b/dest/include/librz/rz_il/definitions/float.h @@ -0,0 +1,22 @@ +#ifndef RZ_IL_FLOAT_H +#define RZ_IL_FLOAT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API RZ_OWN RzFloat *rz_il_float_new(RZ_NONNULL RzFloatFormat format, RZ_NONNULL RzBitVector *bv); + +// return const string for il_export +RZ_API const char *rz_il_float_stringify_rmode(RzFloatRMode mode); +RZ_API const char *rz_il_float_stringify_exception(RzFloatException e); +RZ_API const char *rz_il_float_stringify_format(RzFloatFormat format); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_IL_FLOAT_H diff --git a/dest/include/librz/rz_il/definitions/label.h b/dest/include/librz/rz_il/definitions/label.h new file mode 100644 index 00000000000..e2db9871a42 --- /dev/null +++ b/dest/include/librz/rz_il/definitions/label.h @@ -0,0 +1,41 @@ +// SPDX-FileCopyrightText: 2021 heersin +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_IL_EFFECT_H +#define RZ_IL_EFFECT_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + EFFECT_LABEL_ADDR, + EFFECT_LABEL_SYSCALL, + EFFECT_LABEL_HOOK + // more +} RzILEffectLabelType; + +typedef struct rz_il_effect_label_t { + char *label_id; ///< Label name + union { + RzBitVector *addr; ///< RzBitVector address if EFFECT_LABEL_ADDR + void *hook; ///< Function pointer if EFFECT_LABEL_SYSCALL / EFFECT_LABEL_HOOK + }; + RzILEffectLabelType type; ///< type of label +} RzILEffectLabel; + +RZ_API RzILEffectLabel *rz_il_effect_label_new(RZ_NONNULL const char *name, RzILEffectLabelType type); +RZ_API void rz_il_effect_label_free(RzILEffectLabel *lbl); +RZ_API RzILEffectLabel *rz_il_effect_label_dup(RZ_NONNULL RzILEffectLabel *lbl); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_IL_EFFECT_H diff --git a/dest/include/librz/rz_il/definitions/mem.h b/dest/include/librz/rz_il/definitions/mem.h new file mode 100644 index 00000000000..6f043c9c621 --- /dev/null +++ b/dest/include/librz/rz_il/definitions/mem.h @@ -0,0 +1,44 @@ +// SPDX-FileCopyrightText: 2021 Florian Märkl +// SPDX-FileCopyrightText: 2021 heersin +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_IL_MEM_H +#define RZ_IL_MEM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef ut32 RzILMemIndex; + +/** + * \brief A single memory as part of the RzIL VM. + * + * This can be seen as an array of bitvectors, indexed by bitvector keys, covering a + * certain address space. It corresponds to `('a, 'b) mem` in bap where 'a and 'b + * statically determine the size of all keys and values, respectively. + * Because currently our memory can only bind to an RzBuffer, the key size is limited to + * a maximum of 64bits and the value size is always 8, but this can be extended in + * the future if necessary. + */ +typedef struct rz_il_mem_t { + RzBuffer *buf; + ut32 key_len; +} RzILMem; + +RZ_API RZ_OWN RzILMem *rz_il_mem_new(RZ_NONNULL RZ_BORROW RzBuffer *buf, ut32 key_len); +RZ_API void rz_il_mem_free(RzILMem *mem); +RZ_API ut32 rz_il_mem_key_len(RzILMem *mem); +RZ_API ut32 rz_il_mem_value_len(RzILMem *mem); +RZ_API RzBitVector *rz_il_mem_load(RzILMem *mem, RzBitVector *key); +RZ_API bool rz_il_mem_store(RzILMem *mem, RzBitVector *key, RzBitVector *value); +RZ_API RzBitVector *rz_il_mem_loadw(RzILMem *mem, RzBitVector *key, ut32 n_bits, bool big_endian); +RZ_API bool rz_il_mem_storew(RzILMem *mem, RzBitVector *key, RzBitVector *value, bool big_endian); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_IL_MEM_H diff --git a/dest/include/librz/rz_il/definitions/sort.h b/dest/include/librz/rz_il/definitions/sort.h new file mode 100644 index 00000000000..61ba23e393c --- /dev/null +++ b/dest/include/librz/rz_il/definitions/sort.h @@ -0,0 +1,93 @@ +// SPDX-FileCopyrightText: 2022 Florian Märkl +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_IL_SORT_H +#define RZ_IL_SORT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file + * \brief Type and Sort identifiers for values in the IL + * + * Our notion: + * * Types only tell which kind of value something is. E.g. whether it is a bitvector or boolean, but no other info. + * They can generally be expressed sufficiently as an enum. + * * Sorts carry any additional info that makes up the structure of a value, in particular bitvector sorts specify a concrete bit count. + */ + +typedef enum { + RZ_IL_TYPE_PURE_BOOL, + RZ_IL_TYPE_PURE_BITVECTOR, + RZ_IL_TYPE_PURE_FLOAT, +} RzILTypePure; + +typedef struct rz_il_sort_pure_t { + RzILTypePure type; + union { + struct { + ut32 length; + } bv; + struct { + RzFloatFormat format; + } f; + } props; +} RzILSortPure; + +static inline bool rz_il_sort_pure_eq(RzILSortPure a, RzILSortPure b) { + if (a.type != b.type) { + return false; + } + if (a.type == RZ_IL_TYPE_PURE_BITVECTOR && a.props.bv.length != b.props.bv.length) { + return false; + } + if (a.type == RZ_IL_TYPE_PURE_FLOAT && a.props.f.format != b.props.f.format) { + return false; + } + return true; +} + +static inline RzILSortPure rz_il_sort_pure_bool() { + RzILSortPure r = { + RZ_IL_TYPE_PURE_BOOL, + { { 0 } }, + }; + return r; +} + +static inline RzILSortPure rz_il_sort_pure_bv(ut32 length) { + RzILSortPure r = { + RZ_IL_TYPE_PURE_BITVECTOR, + { { 0 } }, + }; + r.props.bv.length = length; + return r; +} + +static inline RzILSortPure rz_il_sort_pure_float(RzFloatFormat format) { + RzILSortPure r = { + RZ_IL_TYPE_PURE_FLOAT, + { { 0 } }, + }; + r.props.f.format = format; + return r; +} + +RZ_API RZ_OWN char *rz_il_sort_pure_stringify(RzILSortPure sort); + +typedef enum { + RZ_IL_TYPE_EFFECT_NONE = 0, ///< nop + RZ_IL_TYPE_EFFECT_DATA = (1 << 0), ///< mutating mems, vars, etc. + RZ_IL_TYPE_EFFECT_CTRL = (1 << 1) ///< jmp/goto +} RzILTypeEffect; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_il/definitions/value.h b/dest/include/librz/rz_il/definitions/value.h new file mode 100644 index 00000000000..7ea81f18461 --- /dev/null +++ b/dest/include/librz/rz_il/definitions/value.h @@ -0,0 +1,46 @@ +// SPDX-FileCopyrightText: 2021 RizinOrg +// SPDX-FileCopyrightText: 2021 deroad +// SPDX-FileCopyrightText: 2021 heersin +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_IL_VALUE_H +#define RZ_IL_VALUE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef union { + RzBitVector *bv; + RzILBool *b; + RzFloat *f; +} RzValUnion; + +/** + * A concrete value of `'a pure`. Either a bitvector or boolean. + */ +typedef struct rz_il_val_t { + RzILTypePure type; ///< type of value + RzValUnion data; ///< data pointer +} RzILVal; + +RZ_API RZ_OWN RzILVal *rz_il_value_new_bitv(RZ_OWN RZ_NONNULL RzBitVector *bv); +RZ_API RZ_OWN RzILVal *rz_il_value_new_bool(RZ_OWN RZ_NONNULL RzILBool *b); +RZ_API RZ_OWN RzILVal *rz_il_value_new_float(RZ_OWN RZ_NONNULL RzFloat *f); +RZ_API RZ_OWN RzILVal *rz_il_value_new_zero_of(RzILSortPure sort); +RZ_API RZ_OWN RzILVal *rz_il_value_dup(RZ_NONNULL const RzILVal *val); +RZ_API void rz_il_value_free(RZ_NULLABLE RzILVal *val); +RZ_API RzILSortPure rz_il_value_get_sort(RZ_NONNULL RzILVal *val); +RZ_API RZ_OWN RzBitVector *rz_il_value_to_bv(RZ_NONNULL const RzILVal *val); +RZ_API bool rz_il_value_eq(RZ_NONNULL const RzILVal *a, RZ_NONNULL const RzILVal *b); + +RZ_API char *rz_il_value_stringify(RZ_NONNULL const RzILVal *val); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_IL_VALUE_H diff --git a/dest/include/librz/rz_il/definitions/variable.h b/dest/include/librz/rz_il/definitions/variable.h new file mode 100644 index 00000000000..19f5c40651f --- /dev/null +++ b/dest/include/librz/rz_il/definitions/variable.h @@ -0,0 +1,59 @@ +// SPDX-FileCopyrightText: 2021 RizinOrg +// SPDX-FileCopyrightText: 2021 deroad +// SPDX-FileCopyrightText: 2021 heersin +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_IL_VARIABLE_H +#define RZ_IL_VARIABLE_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Definition of a variable inside the vm + */ +typedef struct rz_il_var_t { + char *name; + RzILSortPure sort; ///< "type" of the variable +} RzILVar; + +RZ_API RZ_OWN RzILVar *rz_il_variable_new(RZ_NONNULL const char *name, RzILSortPure sort); +RZ_API void rz_il_variable_free(RZ_NULLABLE RzILVar *var); + +/** + * \brief Holds a set of variable definitions and their current contents + * This is meant only as a low-level container to be used in RzILVM. + */ +typedef struct rz_il_var_set_t { + HtSP /**/ *vars; + HtSP /**/ *contents; +} RzILVarSet; + +RZ_API bool rz_il_var_set_init(RzILVarSet *vs); +RZ_API void rz_il_var_set_fini(RzILVarSet *vs); +RZ_API void rz_il_var_set_reset(RzILVarSet *vs); +RZ_API RZ_BORROW RzILVar *rz_il_var_set_create_var(RzILVarSet *vs, const char *name, RzILSortPure sort); +RZ_API RZ_OWN RZ_NULLABLE RzILVal *rz_il_var_set_remove_var(RzILVarSet *vs, const char *name); +RZ_API bool rz_il_var_set_bind(RzILVarSet *vs, const char *name, RZ_OWN RzILVal *val); +RZ_API RZ_BORROW RzILVar *rz_il_var_set_get(RzILVarSet *vs, const char *name); +RZ_API RZ_OWN RzPVector /**/ *rz_il_var_set_get_all(RzILVarSet *vs); +RZ_API RZ_BORROW RzILVal *rz_il_var_set_get_value(RzILVarSet *vs, const char *name); + +typedef enum { + RZ_IL_VAR_KIND_GLOBAL, ///< global var, usually bound to a physical representation like a register. + RZ_IL_VAR_KIND_LOCAL, ///< local var, defined and assigned by set ops, mutable and useable across effects. + RZ_IL_VAR_KIND_LOCAL_PURE ///< local pure var, bound only by let expressions, scope is limited to the let's pure body, thus it's immutable. +} RzILVarKind; + +RZ_API const char *rz_il_var_kind_name(RzILVarKind kind); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_IL_VARIABLE_H diff --git a/dest/include/librz/rz_il/rz_il_events.h b/dest/include/librz/rz_il/rz_il_events.h new file mode 100644 index 00000000000..fb6773e2080 --- /dev/null +++ b/dest/include/librz/rz_il/rz_il_events.h @@ -0,0 +1,98 @@ +// SPDX-FileCopyrightText: 2021 RizinOrg +// SPDX-FileCopyrightText: 2021 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_IL_VM_EVENTS_H +#define RZ_IL_VM_EVENTS_H + +#include "rz_il_opcodes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file + * \brief list of types of events that can happen on the VM + */ + +typedef enum rz_il_event_id_t { + RZ_IL_EVENT_EXCEPTION = 0, + RZ_IL_EVENT_PC_WRITE, + RZ_IL_EVENT_MEM_READ, + RZ_IL_EVENT_VAR_READ, + RZ_IL_EVENT_MEM_WRITE, + RZ_IL_EVENT_VAR_WRITE, +} RzILEventId; + +typedef enum { + RZ_IL_EVENT_EXC_NONE = 0, + RZ_IL_EVENT_EXC_DIV_ZERO = 1 << 1, + RZ_IL_EVENT_EXC_FP_INVALID_OP = 1 << 2, + RZ_IL_EVENT_EXC_FP_DIV_ZERO = 1 << 3, + RZ_IL_EVENT_EXC_FP_OVERFLOW = 1 << 4, + RZ_IL_EVENT_EXC_FP_UNDERFLOW = 1 << 5, + RZ_IL_EVENT_EXC_FP_INEXACT = 1 << 6, +} RzILEventException; + +typedef struct rz_il_vm_event_mem_read_t { + RzILMemIndex index; + RZ_NONNULL RzBitVector *address; + RZ_NONNULL RzBitVector *value; +} RzILEventMemRead; + +typedef struct rz_il_vm_event_var_read_t { + RZ_NONNULL char *variable; + RZ_NONNULL RzILVal *value; +} RzILEventVarRead; + +typedef struct rz_il_vm_event_pc_write_t { + RzBitVector *old_pc; + RzBitVector *new_pc; +} RzILEventPCWrite; + +typedef struct rz_il_vm_event_mem_write_t { + RzILMemIndex index; + RZ_NONNULL RzBitVector *address; + RZ_NONNULL RzBitVector *old_value; + RZ_NONNULL RzBitVector *new_value; +} RzILEventMemWrite; + +typedef struct rz_il_vm_event_var_write_t { + RZ_NONNULL char *variable; + RZ_NONNULL RzILVal *old_value; + RZ_NONNULL RzILVal *new_value; +} RzILEventVarWrite; + +typedef struct rz_il_vm_event_t { + RzILEventId type; + union { + RzILEventException exception; + RzILEventPCWrite pc_write; + RzILEventMemRead mem_read; + RzILEventMemWrite mem_write; + RzILEventVarRead var_read; + RzILEventVarWrite var_write; + } data; +} RzILEvent; + +RZ_API RZ_OWN RzILEvent *rz_il_event_exception_new(RzILEventException type); +RZ_API RZ_OWN RzILEvent *rz_il_event_pc_write_new(RZ_NONNULL const RzBitVector *old_pc, RZ_NONNULL const RzBitVector *new_pc); +RZ_API RZ_OWN RzILEvent *rz_il_event_mem_read_new(RzILMemIndex index, RZ_NONNULL const RzBitVector *addr, RZ_NULLABLE const RzBitVector *value); +RZ_API RZ_OWN RzILEvent *rz_il_event_var_read_new(RZ_NONNULL const char *name, RZ_NULLABLE const RzILVal *value); +RZ_API RZ_OWN RzILEvent *rz_il_event_mem_write_new(RzILMemIndex index, RZ_NONNULL const RzBitVector *addr, RZ_NONNULL const RzBitVector *old_v, RZ_NONNULL const RzBitVector *new_v); +RZ_API RZ_OWN RzILEvent *rz_il_event_var_write_new(RZ_NONNULL const char *name, RZ_NULLABLE const RzILVal *old_v, RZ_NONNULL const RzILVal *new_v); +RZ_API void rz_il_event_free(RZ_NULLABLE RzILEvent *evt); +RZ_API const char *rz_il_event_exception_msg(const RzILEventException id); + +// Printing/Export +RZ_API void rz_il_event_stringify(RZ_NONNULL const RzILEvent *evt, RZ_NONNULL RzStrBuf *sb); +RZ_API void rz_il_event_json(RZ_NONNULL RzILEvent *evt, RZ_NONNULL PJ *pj); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_IL_VM_EVENTS_H diff --git a/dest/include/librz/rz_il/rz_il_opbuilder_begin.h b/dest/include/librz/rz_il/rz_il_opbuilder_begin.h new file mode 100644 index 00000000000..cc7156215be --- /dev/null +++ b/dest/include/librz/rz_il/rz_il_opbuilder_begin.h @@ -0,0 +1,198 @@ +// SPDX-FileCopyrightText: 2021 Florian Märkl +// SPDX-License-Identifier: LGPL-3.0-only + +/** + * \file + * \brief Syntax Macros for RzIL Lifting + * + * This header introduces a number of short macros for conveniently building RzIL + * expressions without having to type out `rz_il_op_new_...`. + * + * It is intended to be used like this, for example when lifting IL from an architecture: + * + * #include + * + * RzILOpEffect *lift_my_op() { + * return SEQ3( + * SETG("a", U8(42)), + * SETG("x", U8(123)), + * STORE(0xcafe, VARG("a"))); + * } + * + * #include + * + * Because of their short nature, these macros may conflict with other code. As such, + * it should never be included in any public headers, and should be closed by an + * `#include ` when not needed anymore, which `#undef`s + * everything again. + * + * Consequently, when editing this file, always make sure to keep `rz_il_opbuilder_end.h` + * in sync! + */ + +#ifndef RZ_IL_OPBUILDER_BEGIN_H +#define RZ_IL_OPBUILDER_BEGIN_H + +#include + +#define DUP(op) rz_il_op_pure_dup(op) + +#define ITE(c, t, f) rz_il_op_new_ite(c, t, f) + +#define UN(l, val) rz_il_op_new_bitv_from_ut64(l, val) +#define U8(val) UN(8, val) +#define U16(val) UN(16, val) +#define U32(val) UN(32, val) +#define U48(val) UN(48, val) +#define U64(val) UN(64, val) +#define CAST(l, f, v) rz_il_op_new_cast(l, f, v) +#define BOOL_TO_BV(b, l) ITE(b, UN(l, 1), UN(l, 0)) + +#define SN(l, val) rz_il_op_new_bitv_from_st64(l, val) +#define S8(val) SN(8, val) +#define S16(val) SN(16, val) +#define S32(val) SN(32, val) +#define S64(val) SN(64, val) + +#define BV2F(fmt, bv) rz_il_op_new_float(fmt, bv) +#define F32(f32) rz_il_op_new_float_from_f32(f32) +#define F64(f64) rz_il_op_new_float_from_f64(f64) +#define F80(f80) rz_il_op_new_float_from_f80(f80) +#define F2BV(fl) rz_il_op_new_fbits(fl) +#define IS_FINITE(fl) rz_il_op_new_is_finite(fl) +#define IS_FNAN(fl) rz_il_op_new_is_nan(fl) +#define IS_FINF(fl) rz_il_op_new_is_inf(fl) +#define IS_FZERO(fl) rz_il_op_new_is_fzero(fl) +#define IS_FNEG(fl) rz_il_op_new_is_fneg(fl) +#define IS_FPOS(fl) rz_il_op_new_is_fpos(fl) +#define FNEG(fl) rz_il_op_new_fneg(fl) +#define FABS(fl) rz_il_op_new_fabs(fl) +#define F2INT(l, rmode, fl) rz_il_op_new_fcast_int(l, rmode, fl) +#define F2SINT(l, rmode, fl) rz_il_op_new_fcast_sint(l, rmode, fl) +#define INT2F(fmt, rmode, bv) rz_il_op_new_fcast_float(fmt, rmode, bv) +#define SINT2F(fmt, rmode, bv) rz_il_op_new_fcast_sfloat(fmt, rmode, bv) +#define FCONVERT(fmt, rmode, fl) rz_il_op_new_fconvert(fmt, rmode, fl) +#define FLOATV16(bv) rz_il_op_new_float(RZ_FLOAT_IEEE754_BIN_16, bv) +#define FLOATV32(bv) rz_il_op_new_float(RZ_FLOAT_IEEE754_BIN_32, bv) +#define FLOATV64(bv) rz_il_op_new_float(RZ_FLOAT_IEEE754_BIN_64, bv) +#define FLOATV128(bv) rz_il_op_new_float(RZ_FLOAT_IEEE754_BIN_128, bv) +#define FSUCC(fl) rz_il_op_new_fsucc(fl) +#define FPRED(fl) rz_il_op_new_fpred(fl) +#define FORDER(flx, fly) rz_il_op_new_forder(flx, fly) +#define FROUND(rmode, fl) rz_il_op_new_fround(rmode, fl) +#define FSQRT(rmode, fl) rz_il_op_new_fsqrt(rmode, fl) +#define FRSQRT(rmode, fl) rz_il_op_new_frsqrt(rmode, fl) +#define FEXCEPT(e, fl) rz_il_op_new_fexcept(e, fl) +#define FADD(rmode, flx, fly) rz_il_op_new_fadd(rmode, flx, fly) +#define FSUB(rmode, flx, fly) rz_il_op_new_fsub(rmode, flx, fly) +#define FMUL(rmode, flx, fly) rz_il_op_new_fmul(rmode, flx, fly) +#define FDIV(rmode, flx, fly) rz_il_op_new_fdiv(rmode, flx, fly) +#define FMOD(rmode, flx, fly) rz_il_op_new_fdiv(rmode, flx, fly) +#define FPOW(rmode, flx, fly) rz_il_op_new_fpow(rmode, flx, fly) +#define FMAD(rmode, flx, fly, flz) rz_il_op_new_fmad(rmode, flx, fly, flz) + +#define IL_FQNAN(f) rz_il_op_new_float_from_rz_float(rz_float_new_qnan(f)) +#define IL_FSNAN(f) rz_il_op_new_float_from_rz_float(rz_float_new_snan(f)) + +// TODO: add `feq` as prime operator in fbasic +// https://smtlib.cs.uiowa.edu/theories-FloatingPoint.shtml + +#define IL_FALSE rz_il_op_new_b0() +#define IL_TRUE rz_il_op_new_b1() +#define INV(x) rz_il_op_new_bool_inv(x) +#define XOR(x, y) rz_il_op_new_bool_xor(x, y) +#define AND(x, y) rz_il_op_new_bool_and(x, y) +#define OR(x, y) rz_il_op_new_bool_or(x, y) + +#define FNE(flx, fly) rz_il_op_new_fneq(flx, fly) +#define FEQ(flx, fly) rz_il_op_new_feq(flx, fly) +#define FLT(flx, fly) rz_il_op_new_flt(flx, fly) +#define FLE(flx, fly) rz_il_op_new_fle(flx, fly) +#define FGT(flx, fly) rz_il_op_new_fgt(flx, fly) +#define FGE(flx, fly) rz_il_op_new_fge(flx, fly) + +#define UNSIGNED(n, x) rz_il_op_new_unsigned(n, x) +#define SIGNED(n, x) rz_il_op_new_signed(n, x) +#define APPEND(high, low) rz_il_op_new_append(high, low) + +#define ADD(x, y) rz_il_op_new_add(x, y) +#define SUB(x, y) rz_il_op_new_sub(x, y) +#define MUL(x, y) rz_il_op_new_mul(x, y) +#define DIV(x, y) rz_il_op_new_div(x, y) +#define SDIV(x, y) rz_il_op_new_sdiv(x, y) +#define MOD(x, y) rz_il_op_new_mod(x, y) +#define SMOD(x, y) rz_il_op_new_smod(x, y) +#define SHIFTL(f, v, dist) rz_il_op_new_shiftl(f, v, dist) +#define SHIFTR(f, v, dist) rz_il_op_new_shiftr(f, v, dist) +#define SHIFTL0(v, dist) SHIFTL(IL_FALSE, v, dist) +#define SHIFTR0(v, dist) SHIFTR(IL_FALSE, v, dist) +#define SHIFTRA(v, dist) rz_il_op_new_shiftr_arith(v, dist) +#define LOGAND(x, y) rz_il_op_new_log_and(x, y) +#define LOGOR(x, y) rz_il_op_new_log_or(x, y) +#define LOGXOR(x, y) rz_il_op_new_log_xor(x, y) +#define LOGNOT(x) rz_il_op_new_log_not(x) +#define NEG(x) rz_il_op_new_neg(x) + +#define NON_ZERO(x) rz_il_op_new_non_zero(x) +#define IS_ZERO(x) rz_il_op_new_is_zero(x) +#define MSB(x) rz_il_op_new_msb(x) +#define LSB(x) rz_il_op_new_lsb(x) +#define EQ(x, y) rz_il_op_new_eq(x, y) +#define NE(x, y) rz_il_op_new_ne(x, y) +#define ULT(x, y) rz_il_op_new_ult(x, y) +#define ULE(x, y) rz_il_op_new_ule(x, y) +#define UGT(x, y) rz_il_op_new_ugt(x, y) +#define UGE(x, y) rz_il_op_new_uge(x, y) +#define SLT(x, y) rz_il_op_new_slt(x, y) +#define SLE(x, y) rz_il_op_new_sle(x, y) +#define SGT(x, y) rz_il_op_new_sgt(x, y) +#define SGE(x, y) rz_il_op_new_sge(x, y) + +#define LOAD(addr) rz_il_op_new_load(0, addr) +#define LOADW(n, addr) rz_il_op_new_loadw(0, addr, n) +#define LOADWI(i, n, addr) rz_il_op_new_loadw(i, addr, n) +#define STORE(addr, val) rz_il_op_new_store(0, addr, val) +#define STOREW(addr, val) rz_il_op_new_storew(0, addr, val) +#define STOREWI(i, addr, val) rz_il_op_new_storew(i, addr, val) + +#define VARG(name) rz_il_op_new_var(name, RZ_IL_VAR_KIND_GLOBAL) +#define VARL(name) rz_il_op_new_var(name, RZ_IL_VAR_KIND_LOCAL) +#define VARLP(name) rz_il_op_new_var(name, RZ_IL_VAR_KIND_LOCAL_PURE) +#define SETG(name, v) rz_il_op_new_set(name, false, v) +#define SETL(name, v) rz_il_op_new_set(name, true, v) +#define LET(name, v, body) rz_il_op_new_let(name, v, body) + +#define SEQ2(e0, e1) rz_il_op_new_seq(e0, e1) +#define SEQ3(e0, e1, e2) rz_il_op_new_seqn(3, e0, e1, e2) +#define SEQ4(e0, e1, e2, e3) rz_il_op_new_seqn(4, e0, e1, e2, e3) +#define SEQ5(e0, e1, e2, e3, e4) rz_il_op_new_seqn(5, e0, e1, e2, e3, e4) +#define SEQ6(e0, e1, e2, e3, e4, e5) rz_il_op_new_seqn(6, e0, e1, e2, e3, e4, e5) +#define SEQ7(e0, e1, e2, e3, e4, e5, e6) rz_il_op_new_seqn(7, e0, e1, e2, e3, e4, e5, e6) +#define SEQ8(e0, e1, e2, e3, e4, e5, e6, e7) rz_il_op_new_seqn(8, e0, e1, e2, e3, e4, e5, e6, e7) +#define SEQ9(e0, e1, e2, e3, e4, e5, e6, e7, e8) rz_il_op_new_seqn(9, e0, e1, e2, e3, e4, e5, e6, e7, e8) +#define SEQN(n, ...) rz_il_op_new_seqn(n, __VA_ARGS__) + +#define EMPTY() rz_il_op_new_empty() +#define NOP() rz_il_op_new_nop() +#define BRANCH(c, t, f) rz_il_op_new_branch(c, t, f) +#define REPEAT(c, b) rz_il_op_new_repeat(c, b) +#define JMP(tgt) rz_il_op_new_jmp(tgt) +#define GOTO(lbl) rz_il_op_new_goto(lbl) + +#define NOT_IMPLEMENTED \ + do { \ + RZ_LOG_INFO("IL instruction not implemented.\n"); \ + return NULL; \ + } while (0) + +#define EXTRACT32(value, start, length) rz_il_extract32(value, start, length) +#define EXTRACT64(value, start, length) rz_il_extract64(value, start, length) +#define SEXTRACT32(value, start, length) rz_il_sextract32(value, start, length) +#define SEXTRACT64(value, start, length) rz_il_sextract64(value, start, length) +#define DEPOSIT32(value, start, length, fieldval) rz_il_deposit32(value, start, length, fieldval) +#define DEPOSIT64(value, start, length, fieldval) rz_il_deposit64(value, start, length, fieldval) +#define BSWAP16(t) rz_il_bswap16(t) +#define BSWAP32(t) rz_il_bswap32(t) +#define BSWAP64(t) rz_il_bswap64(t) + +#endif diff --git a/dest/include/librz/rz_il/rz_il_opbuilder_end.h b/dest/include/librz/rz_il/rz_il_opbuilder_end.h new file mode 100644 index 00000000000..c88d4501efd --- /dev/null +++ b/dest/include/librz/rz_il/rz_il_opbuilder_end.h @@ -0,0 +1,152 @@ + +#ifndef RZ_IL_OPBUILDER_BEGIN_H +#error rz_il_opbuilder_end.h included without rz_il_opbuilder_begin.h before +#endif + +#undef DUP +#undef ITE + +#undef UN +#undef U8 +#undef U16 +#undef U32 +#undef U48 +#undef U64 +#undef CAST +#undef BOOL_TO_BV + +#undef SN +#undef S8 +#undef S16 +#undef S32 +#undef S64 + +#undef BV2F +#undef F32 +#undef F64 +#undef F80 +#undef F2BV +#undef IS_FINITE +#undef IS_FNAN +#undef IS_FINF +#undef IS_FZERO +#undef IS_FNEG +#undef IS_FPOS +#undef FNEG +#undef FABS +#undef F2INT +#undef F2SINT +#undef INT2F +#undef SINT2F +#undef FCONVERT +#undef FLOATV16 +#undef FLOATV32 +#undef FLOATV64 +#undef FLOATV128 +#undef FSUCC +#undef FPRED +#undef FORDER +#undef FROUND +#undef FSQRT +#undef FADD +#undef FSUB +#undef FMUL +#undef FDIV +#undef FMOD +#undef FPOW +#undef FMAD +#undef FNE +#undef FEQ +#undef FLT +#undef FLE +#undef FGE +#undef FGT + +#undef IL_FALSE +#undef IL_TRUE +#undef INV +#undef XOR +#undef AND + +#undef UNSIGNED +#undef SIGNED +#undef APPEND + +#undef ADD +#undef SUB +#undef MUL +#undef DIV +#undef SDIV +#undef MOD +#undef SMOD +#undef SHIFTL +#undef SHIFTR +#undef SHIFTL0 +#undef SHIFTR0 +#undef SHIFTRA +#undef LOGAND +#undef LOGOR +#undef LOGXOR +#undef LOGNOT +#undef NEG + +#undef NON_ZERO +#undef IS_ZERO +#undef MSB +#undef LSB +#undef EQ +#undef NE +#undef UGT +#undef ULT +#undef ULE +#undef UGT +#undef UGE +#undef SLT +#undef SLE +#undef SGT +#undef SGE + +#undef LOAD +#undef LOADW +#undef LOADWI +#undef STORE +#undef STOREW +#undef STOREWI + +#undef VARG +#undef VARL +#undef VARLP +#undef SETG +#undef SETL +#undef LET + +#undef SEQ2 +#undef SEQ3 +#undef SEQ4 +#undef SEQ5 +#undef SEQ6 +#undef SEQ7 +#undef SEQ8 +#undef SEQ9 +#undef SEQN + +#undef EMPTY +#undef NOP +#undef BRANCH +#undef REPEAT +#undef JMP +#undef GOTO + +#undef NOT_IMPLEMENTED + +#undef EXTRACT32 +#undef EXTRACT64 +#undef SEXTRACT32 +#undef SEXTRACT64 +#undef DEPOSIT32 +#undef DEPOSIT64 +#undef BSWAP16 +#undef BSWAP32 +#undef BSWAP64 + +#undef RZ_IL_OPBUILDER_BEGIN_H diff --git a/dest/include/librz/rz_il/rz_il_opcodes.h b/dest/include/librz/rz_il/rz_il_opcodes.h new file mode 100644 index 00000000000..cb4fc81d3e7 --- /dev/null +++ b/dest/include/librz/rz_il/rz_il_opcodes.h @@ -0,0 +1,872 @@ +// SPDX-FileCopyrightText: 2021 Florian Märkl +// SPDX-FileCopyrightText: 2021 heersin +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_IL_OPCODES_H +#define RZ_IL_OPCODES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file + * \brief signatures of core theory opcodes + * + * Modular Hierarchy of the whole core theory + * (we implement the Minimal part only) + * o Core + * | + * Trans o--------+--------o Float + * | | + * o Basic o FBasic + * | + * o Minimal + * | + * +-------+--------+--------+-------+ + * | | | | | + * o o o o o + * Init RzILBool Bitv Memory Effect + * + * See also the references : + * 0. A gentle introduction to core theory http://binaryanalysisplatform.github.io/bap/api/odoc/bap-core-theory/Bap_core_theory/index.html + * 1. http://binaryanalysisplatform.github.io/bap/api/odoc/bap-core-theory/Bap_core_theory/Theory/index.html + * 2. For core and array theories https://smtlib.cs.uiowa.edu/theories.shtml + */ + +typedef struct rz_il_op_pure_t RzILOpPure; + +typedef RzILOpPure RzILOpBool; +typedef RzILOpPure RzILOpBitVector; +typedef RzILOpPure RzILOpFloat; + +typedef struct rz_il_op_effect_t RzILOpEffect; + +/** + * \brief value is a bitvector constant. + * + * In BAP: `int : 's Bitv.t Value.sort -> word -> 's bitv` + */ +typedef struct rz_il_op_args_bv_t { + RzBitVector *value; ///< value of bitvector +} RzILOpArgsBv; + +/** + * \brief op structure for `'s bitv -> bool` + * [MSB] msb x is the most significant bit of x. + * [LSB] lsb x is the least significant bit of x. + * [IS_ZERO] is_zero x holds if x is a bitvector of all zeros. + */ +struct rz_il_op_args_un_bv_b_t { + RzILOpBitVector *bv; +}; + +typedef struct rz_il_op_args_un_bv_b_t RzILOpArgsMsb; +typedef struct rz_il_op_args_un_bv_b_t RzILOpArgsLsb; +typedef struct rz_il_op_args_un_bv_b_t RzILOpArgsIsZero; + +/** + * op structure for + * `not` ('s bitv -> 's bitv) + * not x is one-complement negation. + * `neg` ('s bitv -> 's bitv) + * neg x is two-complement unary minus + */ +struct rz_il_op_args_bv_unop_t { + RzILOpBitVector *bv; ///< unary operand +}; + +typedef struct rz_il_op_args_bv_unop_t RzILOpArgsLogNot; +typedef struct rz_il_op_args_bv_unop_t RzILOpArgsNeg; + +/** + * \brief op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv) + * + * [ADD] add x y addition modulo 2^'s + * [SUB] sub x y subtraction modulo 2^'s + * [MUL] mul x y multiplication modulo 2^'s + * [DIV] div x y unsigned division modulo 2^'s truncating towards 0. The division by zero is defined to be a vector of all ones of size 's. + * [MOD] modulo x y is the remainder of div x y modulo 2^'s. + * [SDIV] sdiv x y is signed division of x by y modulo 2^'s. + * [SMOD] smodulo x y is the signed remainder of div x y modulo 2^'s. + * [LOGAND] logand x y is a bitwise logical and of x and y. + * [LOGOR] logor x y is a bitwise logical or of x and y. + * [LOGXOR] logxor x y is a bitwise logical xor of x and y. + */ +struct rz_il_op_args_alg_log_operations_t { + RzILOpBitVector *x; ///< left operand + RzILOpBitVector *y; ///< right operand +}; + +typedef struct rz_il_op_args_alg_log_operations_t RzILOpArgsAdd; +typedef struct rz_il_op_args_alg_log_operations_t RzILOpArgsSub; +typedef struct rz_il_op_args_alg_log_operations_t RzILOpArgsMul; +typedef struct rz_il_op_args_alg_log_operations_t RzILOpArgsDiv; +typedef struct rz_il_op_args_alg_log_operations_t RzILOpArgsSdiv; +typedef struct rz_il_op_args_alg_log_operations_t RzILOpArgsMod; +typedef struct rz_il_op_args_alg_log_operations_t RzILOpArgsSmod; +typedef struct rz_il_op_args_alg_log_operations_t RzILOpArgsLogand; +typedef struct rz_il_op_args_alg_log_operations_t RzILOpArgsLogor; +typedef struct rz_il_op_args_alg_log_operations_t RzILOpArgsLogxor; + +/** + * \brief op structure for binary comparison ops ('a bitv -> 'a bitv -> bool) + * + * [EQ] eq x y binary predicate for bitwise equality + * [SLE] sle x y binary predicate for singed less than or equal + * [ULE] ule x y binary predicate for unsigned less than or equal + */ +struct rz_il_op_args_cmp_t { + RzILOpBitVector *x; ///< index of operand 1 + RzILOpBitVector *y; ///< index of operand 2 +}; + +typedef struct rz_il_op_args_cmp_t RzILOpArgsEq; +typedef struct rz_il_op_args_cmp_t RzILOpArgsSle; +typedef struct rz_il_op_args_cmp_t RzILOpArgsUle; + +/** + * \brief op structure for casting bitv + */ +typedef struct rz_il_op_args_cast_t { + ut32 length; ///< new bits length + RzILOpBool *fill; ///< If m = size val - length > 0 then m fill-bits are prepended to the most significant part of the vector. + RzILOpBitVector *val; ///< value to cast +} RzILOpArgsCast; + +/** + * \struct rz_il_op_args_append_t + * \brief op structure for appending 2 bitv: MSB:LSB high:low + */ +typedef struct rz_il_op_args_append_t { + RzILOpBitVector *high; ///< bitvector occupying the most significant bits + RzILOpBitVector *low; ///< bitvector occupying the least significant bits +} RzILOpArgsAppend; + +/** + * \brief op structure for lshift and rshift (bool -> 's bitv -> 'b bitv -> 's bitv) + * + * [LSHIFT] shiftl s x m shifts x left by m bits filling with s. + * [RSHIFT] shiftr s x m shifts x right by m bits filling with s. + */ +struct rz_il_op_args_shift_t { + RzILOpBool *fill_bit; ///< index of fill bit + RzILOpBitVector *x; ///< index of operand 1 + RzILOpBitVector *y; ///< index of operand 2 +}; + +typedef struct rz_il_op_args_shift_t RzILOpArgsShiftLeft; +typedef struct rz_il_op_args_shift_t RzILOpArgsShiftRight; + +/** + * \brief op structure for `set` ('a var -> 'a pure -> data eff) + * + * set v x changes the value stored in v to the value of x. + */ +typedef struct rz_il_op_args_set_t { + const char *v; ///< name of variable, const one + bool is_local; ///< whether a global variable should be set or a local optionally created and set + RzILOpPure *x; ///< value to set the variable to +} RzILOpArgsSet; + +/** + * \brief op structure for `let_ : 'a var -> 'a pure -> 'b pure -> 'b pure` + * + * `let_ v exp body` binds the value of exp to v body. + */ +typedef struct rz_il_op_args_let_t { + const char *name; ///< name of variable + RzILOpPure *exp; ///< value/expression to bind the variable to + RzILOpPure *body; ///< body in which the variable will be bound and that produces the result +} RzILOpArgsLet; + +/** + * \brief op structure for `jmp` (_ bitv -> ctrl eff) + * + * jmp dst passes the control to a program located at dst. + */ +typedef struct rz_il_op_args_jmp_t { + RzILOpBitVector *dst; ///< index of destination address +} RzILOpArgsJmp; + +/** + * \brief op structure for `goto` (label -> ctrl eff) + * + * goto lbl passes the control to a program labeled with lbl. + */ +typedef struct rz_il_op_args_goto_t { + const char *lbl; ///< name of the label, const one +} RzILOpArgsGoto; + +/** + * \brief op structure for `Seq` ('a eff -> 'a eff -> 'a eff) + * + * seq x y performs effect x, after that perform effect y. Pack two effects into one. + */ +typedef struct rz_il_op_args_seq_t { + RzILOpEffect *x; ///< perform this first + RzILOpEffect *y; ///< perform this second +} RzILOpArgsSeq; + +/** + * \brief op structure for `blk` (label -> data eff -> ctrl eff -> unit eff) + * + * blk lbl data ctrl a labeled sequence of effects. + */ +typedef struct rzil_op_blk_t { + const char *label; ///< name of the label, const one + RzILOpEffect *data_eff; ///< index of data_eff + RzILOpEffect *ctrl_eff; ///< index of ctrl_eff +} RzILOpArgsBlk; + +/** + * \brief op structure for `repeat` (bool -> data eff -> data eff) + * + * repeat c data repeats data effects till the condition c holds. + */ +typedef struct rzil_op_repeat_t { + RzILOpBool *condition; ///< index of BOOL condition + RzILOpEffect *data_eff; ///< index of data effect +} RzILOpArgsRepeat; + +/** + * \brief op structure for `branch` (bool -> 'a eff -> 'a eff -> 'a eff) + * + * branch c lhs rhs if c holds then performs lhs else rhs. + */ +typedef struct rz_il_op_args_branch_t { + RzILOpBool *condition; + RZ_NONNULL RzILOpEffect *true_eff; ///< effect for when condition evaluates to true + RZ_NONNULL RzILOpEffect *false_eff; ///< effect for when condition evaluates to false +} RzILOpArgsBranch; + +/** + * \brief op structure for `ite` (bool -> 'a pure -> 'a pure -> 'a pure) + * + * ite c x y is x if c evaluates to b1 else y. + */ +typedef struct rz_il_op_args_ite_t { + RzILOpBool *condition; ///< index of BOOL condition + RzILOpPure *x; ///< index of RzILVal operand 1 + RzILOpPure *y; ///< index of RzILVal operand 2 +} RzILOpArgsIte; + +/** + * \brief op structure for `var` ('a var -> 'a pure) + * + * var v is the value of the variable v. + */ +typedef struct rz_il_op_args_var_t { + const char *v; ///< name of variable, const one + RzILVarKind kind; ///< set of variables to pick from +} RzILOpArgsVar; + +/** + * \brief op structure for `and`, `or` and `xor` (bool -> bool -> bool) + * + * BAP equivalent: + * val and_ : bool -> bool -> bool + * val or_ : bool -> bool -> bool + * and(x, y) is a conjunction of x and y. + * or(x, y) is a conjunction of x or y. + * xor(x, y) is a conjunction of x xor y. + */ +struct rz_il_op_args_bool_operation_t { + RzILOpBool *x; ///< left operand + RzILOpBool *y; ///< right operand +}; + +typedef struct rz_il_op_args_bool_operation_t RzILOpArgsBoolAnd; +typedef struct rz_il_op_args_bool_operation_t RzILOpArgsBoolOr; +typedef struct rz_il_op_args_bool_operation_t RzILOpArgsBoolXor; + +/** + * \brief op structure for `inv` (!bool -> bool) + * + * BAP equivalent: + * val inv : bool -> bool + * inv(x) inverts x (also known as not operation). + */ +struct rz_il_op_args_bool_inv_t { + RzILOpBool *x; ///< single operand +}; + +typedef struct rz_il_op_args_bool_inv_t RzILOpArgsBoolInv; + +/** + * \brief op structure for `load` (('a, 'b) mem -> 'a bitv -> 'b bitv) + * + * load m k is the value associated with the key k in the memory m. + */ +typedef struct rz_il_op_args_load_t { + RzILMemIndex mem; ///< index of the mem inside the vm to use + RzILOpBitVector *key; ///< index of the cell (address) in mem, must have exactly the size of a key in the memory +} RzILOpArgsLoad; + +/** + * \brief op structure for `store` (('a, 'b) mem -> 'a bitv -> 'b bitv -> ('a, 'b) mem) + * + * store m k x a memory m in which the key k is associated with the word x. + */ +typedef struct rz_il_op_args_store_t { + RzILMemIndex mem; ///< index of memory in the vm to use + RzILOpBitVector *key; ///< address where to store to, must have exactly the size of a key in the memory + RzILOpBitVector *value; ///< value to store, must have exactly the size of a memory cell +} RzILOpArgsStore; + +/** + * \brief Load an entire word of arbitrary bit size from a memory + * + * Endianness is determined by the vm + */ +typedef struct rz_il_op_args_loadw_t { + RzILMemIndex mem; ///< index of the mem inside the vm to use + RzILOpBitVector *key; ///< memory index of the RzBitVector key (address) + ut32 n_bits; ///< n of bits to read, and of the resulting bitvector +} RzILOpArgsLoadW; + +/** + * \brief Store an entire word of arbitrary bit size into a memory + * + * Endianness is determined by the vm + */ +typedef struct rz_il_op_args_storew_t { + RzILMemIndex mem; ///< index of memory in the vm to use + RzILOpBitVector *key; ///< address where to store to + RzILOpBitVector *value; ///< value to store, arbitrary size +} RzILOpArgsStoreW; + +/** + * \brief value for a float constant + * `float s x` interprets x as a floating-point number in format s. + * In BAP : `( 'r, 's ) format Float.t Value.sort -> 's bitv -> ( 'r, 's ) format float + */ +typedef struct rz_il_op_args_float_t { + RzFloatFormat r; + RzILOpBitVector *bv; +} RzILOpArgsFloat; + +/** + * \brief op structure for unary without rmode + */ +struct rz_il_op_args_float_unary_t { + RzILOpFloat *f; +}; + +/** + * \brief opstructure for fbits : ( 'r, 's ) format float -> 's bitv + * fbits x is a bitvector representation of the floating-point number x. + */ +typedef struct rz_il_op_args_float_unary_t RzILOpArgsFbits; + +/** + * \brief op structure for 'f float -> bool + * [IS_FINITE] is_finite x holds if x represents a finite number. + * [IS_NAN] is_nan x holds if x represents a not-a-number (NaN). + * [IS_INF] is_inf x holds if x represents an infinite number. + * [IS_FZERO] is_fzero x holds if x represents a zero. + * [IS_FNEG] is_fpos x holds if x represents a positive number. + * [IS_FPOS] is_fneg x hold if x represents a negative number. + */ +typedef struct rz_il_op_args_float_unary_t RzILOpArgsIsFinite; +typedef struct rz_il_op_args_float_unary_t RzILOpArgsIsNan; +typedef struct rz_il_op_args_float_unary_t RzILOpArgsIsInf; +typedef struct rz_il_op_args_float_unary_t RzILOpArgsIsFzero; +typedef struct rz_il_op_args_float_unary_t RzILOpArgsIsFpos; +typedef struct rz_il_op_args_float_unary_t RzILOpArgsIsFneg; + +/** + * op structure for 'f float -> float + * [FNEG] fneg x is -x + * [FABS] fabs x is absolute value of x (|x|) + * [FSUCC] fsucc x is the least floating-point number representable in (sort x) that is greater than x. + * [FPRED] fpred x is the greatest floating-point number representable in (sort x) that is less than x. + */ +typedef struct rz_il_op_args_float_unary_t RzILOpArgsFneg; +typedef struct rz_il_op_args_float_unary_t RzILOpArgsFabs; +typedef struct rz_il_op_args_float_unary_t RzILOpArgsFsucc; +typedef struct rz_il_op_args_float_unary_t RzILOpArgsFpred; + +/** + * \brief op structure for cast to bv from float + * [FCAST_INT] `f_cast_int s rm x` returns an integer closest to x. + * [FCAST_SINT] `f_cast_sint s rm x` returns an integer closest to x. + */ +struct rz_il_op_args_float_cast_int_t { + ut32 length; + RzFloatRMode mode; + RzILOpFloat *f; +}; + +typedef struct rz_il_op_args_float_cast_int_t RzILOpArgsFCastint; +typedef struct rz_il_op_args_float_cast_int_t RzILOpArgsFCastsint; + +/** + * \brief for cast to float from bv + * 'f Float.t Value.sort -> rmode -> 'a bitv -> 'f float + * [FCAST_FLOAT] `cast_float s rm x` is the closest to x floating-point number of sort x. + * note that : The bitvector x is interpreted as an unsigned integer in the two-complement form. + * [FCAST_SFLOAT] `cast_sfloat s rm x` is the closest to x floating-point number of sort x. + * note that : The bitvector x is interpreted as a signed integer in the two-complement form. + */ +struct rz_il_op_args_float_cast_float_t { + RzFloatFormat format; + RzFloatRMode mode; + RzILOpBitVector *bv; +}; + +typedef struct rz_il_op_args_float_cast_float_t RzILOpArgsFCastfloat; +typedef struct rz_il_op_args_float_cast_float_t RzILOpArgsFCastsfloat; + +/** + * \brief convert between different float format + * 'f Float.t Value.sort -> rmode -> _ float -> 'f float + * [FCONVERT] `fconvert f r x` is the closest to x floating number in format f. + */ +struct rz_il_op_args_float_fconvert_t { + RzFloatFormat format; + RzFloatRMode mode; + RzILOpFloat *f; +}; +typedef struct rz_il_op_args_float_fconvert_t RzILOpArgsFconvert; + +/** + * \brief op structure of requal + * rmode -> rmode -> bool + * requal x y holds if rounding modes are equal. + */ +typedef struct rz_il_op_args_float_requal_t { + RzFloatRMode x; + RzFloatRMode y; +} RzILOpArgsFrequal; + +/** + * \brief op structure of binary op without rmode + * ('float -> 'flaat -> bool) + * forder x y holds if floating-point number x is less than y. + */ +typedef struct rz_il_op_args_float_binop_t { + RzILOpFloat *x; + RzILOpFloat *y; +} RzILOpArgsForder; + +/** + * \brief op structure for float operation (unary op with rmode) + * `rmode -> 'f float -> 'f float` + * [FROUND] + * [FSQRT] fsqrt m x returns the closest floating-point number to r, where r is such number that r*r is equal to x. + * [FRSQRT] reverse sqrt, rsqrt m x is the closest floating-point number to 1 / sqrt x. + */ +struct rz_il_op_args_float_alg_unop_t { + RzFloatRMode rmode; + RzILOpFloat *f; +}; +typedef struct rz_il_op_args_float_alg_unop_t RzILOpArgsFround; +typedef struct rz_il_op_args_float_alg_unop_t RzILOpArgsFsqrt; +typedef struct rz_il_op_args_float_alg_unop_t RzILOpArgsFrsqrt; + +typedef struct rz_il_op_args_float_expect_t { + RzFloatException e; + RzILOpFloat *x; +} RzILOpArgsFexcept; + +/** + * \brief op structure for float basic arithmetic operations (binary op with rmode) + * rmode -> 'f float -> 'f float -> 'f float + * [FADD] + */ +struct rz_il_op_args_float_alg_binop_t { + RzFloatRMode rmode; + RzILOpFloat *x; + RzILOpFloat *y; +}; + +typedef struct rz_il_op_args_float_alg_binop_t RzILOpArgsFadd; +typedef struct rz_il_op_args_float_alg_binop_t RzILOpArgsFsub; +typedef struct rz_il_op_args_float_alg_binop_t RzILOpArgsFmul; +typedef struct rz_il_op_args_float_alg_binop_t RzILOpArgsFdiv; +typedef struct rz_il_op_args_float_alg_binop_t RzILOpArgsFmod; +typedef struct rz_il_op_args_float_alg_binop_t RzILOpArgsFhypot; +typedef struct rz_il_op_args_float_alg_binop_t RzILOpArgsFpow; + +/** + * \brief op structure of ternary op in float + * rmode -> 'f float -> 'f float -> 'f float -> 'f float + */ +struct rz_il_op_args_float_alg_terop_t { + RzFloatRMode rmode; + RzILOpFloat *x; + RzILOpFloat *y; + RzILOpFloat *z; +}; +typedef struct rz_il_op_args_float_alg_terop_t RzILOpArgsFmad; + +/** + * \brief op structure for some float binary op requiring `int` + * rmode -> 'f float -> 'a bitv -> 'f float + */ +struct rz_il_op_args_float_alg_hybrid_binop_t { + RzFloatRMode rmode; + RzILOpFloat *f; + RzILOpBitVector *n; +}; + +typedef struct rz_il_op_args_float_alg_hybrid_binop_t RzILOpArgsFrootn; +typedef struct rz_il_op_args_float_alg_hybrid_binop_t RzILOpArgsFpown; +typedef struct rz_il_op_args_float_alg_hybrid_binop_t RzILOpArgsFcompound; + +///////////////////////////// +// Opcodes of type 'a pure // + +typedef enum { + // Init + RZ_IL_OP_VAR, + RZ_IL_OP_ITE, + RZ_IL_OP_LET, + + // RzILBool + RZ_IL_OP_B0, + RZ_IL_OP_B1, + RZ_IL_OP_INV, + RZ_IL_OP_AND, + RZ_IL_OP_OR, + RZ_IL_OP_XOR, + + // RzBitVector + RZ_IL_OP_BITV, + RZ_IL_OP_MSB, + RZ_IL_OP_LSB, + RZ_IL_OP_IS_ZERO, + RZ_IL_OP_NEG, + RZ_IL_OP_LOGNOT, + RZ_IL_OP_ADD, + RZ_IL_OP_SUB, + RZ_IL_OP_MUL, + RZ_IL_OP_DIV, + RZ_IL_OP_SDIV, + RZ_IL_OP_MOD, + RZ_IL_OP_SMOD, + RZ_IL_OP_LOGAND, + RZ_IL_OP_LOGOR, + RZ_IL_OP_LOGXOR, + RZ_IL_OP_SHIFTR, + RZ_IL_OP_SHIFTL, + RZ_IL_OP_EQ, + RZ_IL_OP_SLE, + RZ_IL_OP_ULE, + RZ_IL_OP_CAST, + RZ_IL_OP_APPEND, + + // RzILFloat + RZ_IL_OP_FLOAT, + RZ_IL_OP_FBITS, + RZ_IL_OP_IS_FINITE, + RZ_IL_OP_IS_NAN, + RZ_IL_OP_IS_INF, + RZ_IL_OP_IS_FZERO, + RZ_IL_OP_IS_FNEG, + RZ_IL_OP_IS_FPOS, + RZ_IL_OP_FNEG, + RZ_IL_OP_FABS, + RZ_IL_OP_FCAST_INT, + RZ_IL_OP_FCAST_SINT, + RZ_IL_OP_FCAST_FLOAT, + RZ_IL_OP_FCAST_SFLOAT, + RZ_IL_OP_FCONVERT, + RZ_IL_OP_FREQUAL, + RZ_IL_OP_FSUCC, + RZ_IL_OP_FPRED, + RZ_IL_OP_FORDER, + RZ_IL_OP_FROUND, + RZ_IL_OP_FSQRT, + RZ_IL_OP_FRSQRT, + RZ_IL_OP_FADD, + RZ_IL_OP_FSUB, + RZ_IL_OP_FMUL, + RZ_IL_OP_FDIV, + RZ_IL_OP_FMOD, + RZ_IL_OP_FHYPOT, + RZ_IL_OP_FPOW, + RZ_IL_OP_FMAD, + RZ_IL_OP_FROOTN, + RZ_IL_OP_FPOWN, + RZ_IL_OP_FCOMPOUND, + RZ_IL_OP_FEXCEPT, + // ... + + // Memory + RZ_IL_OP_LOAD, + RZ_IL_OP_LOADW, + + RZ_IL_OP_PURE_MAX +} RzILOpPureCode; + +/** + * \brief An IL op performing a pure computation, 'a pure + * + * BAP uses ocaml's type system for statically differentiating between different + * kinds of pure ops. Some ops however are polymorphic over all pure types, + * such as `ite : bool -> 'a pure -> 'a pure -> 'a pure`, which is not directly possible in C. + * So our pure ops are dynamically typed (only on the level of C, the IL is still fully statically typed) + * and we simply use typedefs like `RzILOpBool` and `RzILOpBitVector` to at least weakly indicate which concrete type is required. + */ +struct rz_il_op_pure_t { + RzILOpPureCode code; + union { + RzILOpArgsIte ite; + RzILOpArgsVar var; + RzILOpArgsLet let; + + RzILOpArgsBoolAnd booland; + RzILOpArgsBoolOr boolor; + RzILOpArgsBoolXor boolxor; + RzILOpArgsBoolInv boolinv; + + RzILOpArgsBv bitv; + RzILOpArgsMsb msb; + RzILOpArgsLsb lsb; + RzILOpArgsIsZero is_zero; + RzILOpArgsEq eq; + RzILOpArgsUle ule; + RzILOpArgsSle sle; + RzILOpArgsCast cast; + RzILOpArgsNeg neg; + RzILOpArgsLogNot lognot; + RzILOpArgsAdd add; + RzILOpArgsSub sub; + RzILOpArgsMul mul; + RzILOpArgsDiv div; + RzILOpArgsSdiv sdiv; + RzILOpArgsSmod smod; + RzILOpArgsMod mod; + RzILOpArgsLogand logand; + RzILOpArgsLogor logor; + RzILOpArgsLogxor logxor; + RzILOpArgsShiftLeft shiftl; + RzILOpArgsShiftRight shiftr; + RzILOpArgsAppend append; + + RzILOpArgsLoad load; + RzILOpArgsLoadW loadw; + + RzILOpArgsFloat float_; + RzILOpArgsFbits fbits; + RzILOpArgsIsFinite is_finite; + RzILOpArgsIsNan is_nan; + RzILOpArgsIsInf is_inf; + RzILOpArgsIsFzero is_fzero; + RzILOpArgsIsFneg is_fneg; + RzILOpArgsIsFpos is_fpos; + RzILOpArgsFneg fneg; + RzILOpArgsFabs fabs; + RzILOpArgsFCastint fcast_int; + RzILOpArgsFCastsint fcast_sint; + RzILOpArgsFCastfloat fcast_float; + RzILOpArgsFCastsfloat fcast_sfloat; + RzILOpArgsFconvert fconvert; + RzILOpArgsFrequal frequal; + RzILOpArgsFsucc fsucc; + RzILOpArgsFpred fpred; + RzILOpArgsForder forder; + RzILOpArgsFround fround; + RzILOpArgsFsqrt fsqrt; + RzILOpArgsFrsqrt frsqrt; + RzILOpArgsFexcept fexcept; + RzILOpArgsFadd fadd; + RzILOpArgsFsub fsub; + RzILOpArgsFmul fmul; + RzILOpArgsFdiv fdiv; + RzILOpArgsFmod fmod; + RzILOpArgsFmad fmad; + RzILOpArgsFpow fpow; + RzILOpArgsFpown fpown; + RzILOpArgsFrootn frootn; + RzILOpArgsFcompound fcompound; + RzILOpArgsFhypot fhypot; + } op; +}; + +typedef RzILOpBool *(rz_il_bool_2args_op)(RzILOpBitVector *, RzILOpBitVector *); +typedef RzILOpBitVector *(rz_il_pure_2args_op)(RzILOpBitVector *, RzILOpBitVector *); +typedef RzILOpBitVector *(rz_il_pure_3args_op)(RzILOpBitVector *, RzILOpBitVector *, RzILOpBitVector *); + +RZ_API void rz_il_op_pure_free(RZ_NULLABLE RzILOpPure *op); +RZ_API RzILOpPure *rz_il_op_pure_dup(RZ_NONNULL RzILOpPure *op); + +RZ_API RZ_OWN RzILOpPure *rz_il_op_new_ite(RZ_NONNULL RzILOpPure *condition, RZ_NULLABLE RzILOpPure *x, RZ_NULLABLE RzILOpPure *y); +RZ_API RZ_OWN RzILOpPure *rz_il_op_new_var(RZ_NONNULL const char *var, RzILVarKind kind); +RZ_API RZ_OWN RzILOpPure *rz_il_op_new_let(RZ_NONNULL const char *name, RZ_NONNULL RzILOpPure *exp, RZ_NONNULL RzILOpPure *body); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_b0(); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_b1(); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_bool_and(RZ_NONNULL RzILOpBool *x, RZ_NONNULL RzILOpBool *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_bool_or(RZ_NONNULL RzILOpBool *x, RZ_NONNULL RzILOpBool *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_bool_xor(RZ_NONNULL RzILOpBool *x, RZ_NONNULL RzILOpBool *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_bool_inv(RZ_NONNULL RzILOpBool *x); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_bitv(RZ_NONNULL RzBitVector *value); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_bitv_from_ut64(ut32 length, ut64 number); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_bitv_from_st64(ut32 length, st64 number); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_bitv_max(ut32 length); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_msb(RZ_NONNULL RzILOpPure *val); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_lsb(RZ_NONNULL RzILOpPure *val); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_is_zero(RZ_NONNULL RzILOpPure *bv); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_non_zero(RZ_NONNULL RzILOpPure *bv); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_eq(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_ule(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_sle(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_ult(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_slt(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_uge(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_sge(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_ugt(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_sgt(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_cast(ut32 length, RZ_NONNULL RzILOpBool *fill, RZ_NONNULL RzILOpBitVector *val); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_unsigned(ut32 length, RZ_NONNULL RzILOpBitVector *val); // "zero extension" +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_signed(ut32 length, RZ_NONNULL RzILOpBitVector *val); // "sign extension" +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_neg(RZ_NONNULL RzILOpBitVector *value); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_log_not(RZ_NONNULL RzILOpBitVector *value); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_add(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_sub(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_mul(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_div(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_sdiv(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_smod(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_mod(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_log_and(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_log_or(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_log_xor(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_shiftl(RZ_NONNULL RzILOpBool *fill_bit, RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *sh); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_shiftr(RZ_NONNULL RzILOpBool *fill_bit, RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *sh); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_shiftr_arith(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_append(RZ_NONNULL RzILOpBitVector *high, RZ_NONNULL RzILOpBitVector *low); + +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_load(RzILMemIndex mem, RZ_NONNULL RzILOpBitVector *key); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_loadw(RzILMemIndex mem, RZ_NONNULL RzILOpBitVector *key, ut32 n_bits); + +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_float_from_rz_float(RZ_NONNULL RZ_OWN RzFloat *fl); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_float(RzFloatFormat format, RZ_NONNULL RzILOpBitVector *bv); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_float_from_f32(float f); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_float_from_f64(double f); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_float_from_f80(long double f); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fbits(RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_is_finite(RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_is_nan(RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_is_inf(RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_is_fzero(RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_is_fneg(RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_is_fpos(RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fneg(RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fabs(RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_int(ut32 length, RzFloatRMode mode, RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_sint(ut32 length, RzFloatRMode mode, RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fcast_float(RzFloatFormat format, RzFloatRMode mode, RZ_NONNULL RzILOpBitVector *bv); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fcast_sfloat(RzFloatFormat format, RzFloatRMode mode, RZ_NONNULL RzILOpBitVector *bv); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fconvert(RzFloatFormat format, RzFloatRMode mode, RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_frequal(RzFloatRMode x, RzFloatRMode y); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fsucc(RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fpred(RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_forder(RZ_NONNULL RzILOpFloat *x, RZ_NONNULL RzILOpFloat *y); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fround(RzFloatRMode rmode, RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fsqrt(RzFloatRMode rmode, RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_frsqrt(RzFloatRMode rmode, RZ_NONNULL RzILOpFloat *f); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_fexcept(RzFloatException e, RZ_NONNULL RzILOpFloat *x); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fadd(RzFloatRMode rmode, RZ_NONNULL RzILOpFloat *x, RZ_NONNULL RzILOpFloat *y); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fsub(RzFloatRMode rmode, RZ_NONNULL RzILOpFloat *x, RZ_NONNULL RzILOpFloat *y); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fmul(RzFloatRMode rmode, RZ_NONNULL RzILOpFloat *x, RZ_NONNULL RzILOpFloat *y); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fdiv(RzFloatRMode rmode, RZ_NONNULL RzILOpFloat *x, RZ_NONNULL RzILOpFloat *y); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fmod(RzFloatRMode rmode, RZ_NONNULL RzILOpFloat *x, RZ_NONNULL RzILOpFloat *y); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fhypot(RzFloatRMode rmode, RZ_NONNULL RzILOpFloat *x, RZ_NONNULL RzILOpFloat *y); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fpow(RzFloatRMode rmode, RZ_NONNULL RzILOpFloat *x, RZ_NONNULL RzILOpFloat *y); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fmad(RzFloatRMode rmode, RZ_NONNULL RzILOpFloat *x, RZ_NONNULL RzILOpFloat *y, RZ_NONNULL RzILOpFloat *z); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_frootn(RzFloatRMode rmode, RZ_NONNULL RzILOpFloat *x, RZ_NONNULL RzILOpBitVector *n); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fpown(RzFloatRMode rmode, RZ_NONNULL RzILOpFloat *x, RZ_NONNULL RzILOpBitVector *n); +RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fcompound(RzFloatRMode rmode, RZ_NONNULL RzILOpFloat *x, RZ_NONNULL RzILOpBitVector *n); + +RZ_API RZ_OWN RzILOpBitVector *rz_il_extract32(RZ_BORROW RzILOpBitVector *value, RZ_BORROW RzILOpBitVector *start, RZ_BORROW RzILOpBitVector *length); +RZ_API RZ_OWN RzILOpBitVector *rz_il_extract64(RZ_BORROW RzILOpBitVector *value, RZ_BORROW RzILOpBitVector *start, RZ_BORROW RzILOpBitVector *length); +RZ_API RZ_OWN RzILOpBitVector *rz_il_sextract32(RZ_BORROW RzILOpBitVector *value, RZ_BORROW RzILOpBitVector *start, RZ_BORROW RzILOpBitVector *length); +RZ_API RZ_OWN RzILOpBitVector *rz_il_sextract64(RZ_BORROW RzILOpBitVector *value, RZ_BORROW RzILOpBitVector *start, RZ_BORROW RzILOpBitVector *length); +RZ_API RZ_OWN RzILOpBitVector *rz_il_deposit64(RZ_BORROW RzILOpBitVector *value, RZ_BORROW RzILOpBitVector *start, RZ_BORROW RzILOpBitVector *length, RZ_BORROW RzILOpBitVector *fieldval); +RZ_API RZ_OWN RzILOpBitVector *rz_il_deposit32(RZ_BORROW RzILOpBitVector *value, RZ_BORROW RzILOpBitVector *start, RZ_BORROW RzILOpBitVector *length, RZ_BORROW RzILOpBitVector *fieldval); +RZ_API RZ_OWN RzILOpBitVector *rz_il_bswap16(RZ_BORROW RzILOpBitVector *t); +RZ_API RZ_OWN RzILOpBitVector *rz_il_bswap32(RZ_BORROW RzILOpBitVector *t); +RZ_API RZ_OWN RzILOpBitVector *rz_il_bswap64(RZ_BORROW RzILOpBitVector *t); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_ne(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_fneq(RZ_NONNULL RZ_OWN RzILOpFloat *x, RZ_NONNULL RZ_OWN RzILOpFloat *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_feq(RZ_NONNULL RZ_OWN RzILOpFloat *x, RZ_NONNULL RZ_OWN RzILOpFloat *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_flt(RZ_NONNULL RZ_OWN RzILOpFloat *x, RZ_NONNULL RZ_OWN RzILOpFloat *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_fle(RZ_NONNULL RZ_OWN RzILOpFloat *x, RZ_NONNULL RZ_OWN RzILOpFloat *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_fgt(RZ_NONNULL RZ_OWN RzILOpFloat *x, RZ_NONNULL RZ_OWN RzILOpFloat *y); +RZ_API RZ_OWN RzILOpBool *rz_il_op_new_fge(RZ_NONNULL RZ_OWN RzILOpFloat *x, RZ_NONNULL RZ_OWN RzILOpFloat *y); + +/////////////////////////////// +// Opcodes of type 'a effect // + +typedef enum { + RZ_IL_OP_STORE, + RZ_IL_OP_STOREW, + + RZ_IL_OP_EMPTY, + RZ_IL_OP_NOP, + RZ_IL_OP_SET, + RZ_IL_OP_JMP, + RZ_IL_OP_GOTO, + RZ_IL_OP_SEQ, + RZ_IL_OP_BLK, + RZ_IL_OP_REPEAT, + RZ_IL_OP_BRANCH, + + RZ_IL_OP_EFFECT_MAX +} RzILOpEffectCode; + +struct rz_il_op_effect_t { + RzILOpEffectCode code; + union { + RzILOpArgsSet set; + RzILOpArgsJmp jmp; + RzILOpArgsGoto goto_; + RzILOpArgsSeq seq; + RzILOpArgsBlk blk; + RzILOpArgsRepeat repeat; + RzILOpArgsBranch branch; + + RzILOpArgsStore store; + RzILOpArgsStoreW storew; + } op; +}; + +RZ_API void rz_il_op_effect_free(RZ_NULLABLE RzILOpEffect *op); + +RZ_API RZ_OWN RzILOpEffect *rz_il_op_new_empty(); +RZ_API RZ_OWN RzILOpEffect *rz_il_op_new_nop(); +RZ_API RZ_OWN RzILOpEffect *rz_il_op_new_set(RZ_NONNULL const char *v, bool is_local, RZ_NONNULL RzILOpPure *x); +RZ_API RZ_OWN RzILOpEffect *rz_il_op_new_jmp(RZ_NONNULL RzILOpBitVector *dst); +RZ_API RZ_OWN RzILOpEffect *rz_il_op_new_goto(RZ_NONNULL const char *label); +RZ_API RZ_OWN RzILOpEffect *rz_il_op_new_seq(RZ_NONNULL RzILOpEffect *x, RZ_NONNULL RzILOpEffect *y); +RZ_API RZ_OWN RzILOpEffect *rz_il_op_new_seqn(ut32 n, ...); +RZ_API RZ_OWN RzILOpEffect *rz_il_op_new_blk(RZ_NONNULL const char *label, RZ_NONNULL RzILOpEffect *data_effect, RZ_NONNULL RzILOpEffect *ctrl_effect); +RZ_API RZ_OWN RzILOpEffect *rz_il_op_new_repeat(RZ_NONNULL RzILOpBool *condition, RZ_NONNULL RzILOpEffect *data_effect); +RZ_API RZ_OWN RzILOpEffect *rz_il_op_new_branch(RZ_NONNULL RzILOpBool *condition, RZ_NULLABLE RzILOpEffect *true_effect, RZ_NULLABLE RzILOpEffect *false_effect); + +RZ_API RZ_OWN RzILOpEffect *rz_il_op_new_store(RzILMemIndex mem, RZ_NONNULL RzILOpBitVector *key, RZ_NONNULL RzILOpBitVector *value); +RZ_API RZ_OWN RzILOpEffect *rz_il_op_new_storew(RzILMemIndex mem, RZ_NONNULL RzILOpBitVector *key, RZ_NONNULL RzILOpBitVector *value); + +// Printing/Export +RZ_API RZ_NONNULL const char *rz_il_op_effect_code_stringify(RzILOpEffectCode code); +RZ_API RZ_NONNULL const char *rz_il_op_pure_code_stringify(RzILOpPureCode code); + +RZ_API RZ_OWN RzGraph /**/ *rz_il_op_pure_graph(RZ_NONNULL RzILOpPure *op, RZ_NULLABLE const char *name); +RZ_API RZ_OWN RzGraph /**/ *rz_il_op_effect_graph(RZ_NONNULL RzILOpEffect *op, RZ_NULLABLE const char *name); + +RZ_API void rz_il_op_pure_stringify(RZ_NONNULL RzILOpPure *op, RZ_NONNULL RzStrBuf *sb, bool pretty); +RZ_API void rz_il_op_effect_stringify(RZ_NONNULL RzILOpEffect *op, RZ_NONNULL RzStrBuf *sb, bool pretty); + +RZ_API void rz_il_op_pure_json(RZ_NONNULL RzILOpPure *op, RZ_NONNULL PJ *pj); +RZ_API void rz_il_op_effect_json(RZ_NONNULL RzILOpEffect *op, RZ_NONNULL PJ *pj); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_IL_OPCODES_H diff --git a/dest/include/librz/rz_il/rz_il_reg.h b/dest/include/librz/rz_il/rz_il_reg.h new file mode 100644 index 00000000000..8255ba00111 --- /dev/null +++ b/dest/include/librz/rz_il/rz_il_reg.h @@ -0,0 +1,41 @@ +// SPDX-FileCopyrightText: 2021 Florian Märkl +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_IL_REG_H +#define RZ_IL_REG_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rz_il_reg_binding_item_t { + char *name; ///< name of both the register and the variable that binds to it + ut32 size; ///< number of bits of the register and variable +} RzILRegBindingItem; + +/** + * An object that describes what registers are bound to variables in an RzILVM. + * Registers of size 1 are bound as boolean variables, others as bitvector ones. + */ +typedef struct rz_il_reg_binding_t { + size_t regs_count; + RzILRegBindingItem *regs; ///< regs_count registers that are bound to variables +} RzILRegBinding; + +struct rz_il_vm_t; + +RZ_API RzILRegBinding *rz_il_reg_binding_derive(RZ_NONNULL RzReg *reg); +RZ_API RzILRegBinding *rz_il_reg_binding_exactly(RZ_NONNULL RzReg *reg, size_t regs_count, RZ_NONNULL RZ_BORROW const char **regs); +RZ_API void rz_il_reg_binding_free(RzILRegBinding *rb); + +RZ_API void rz_il_vm_setup_reg_binding(RZ_NONNULL struct rz_il_vm_t *vm, RZ_NONNULL RZ_BORROW RzILRegBinding *rb); +RZ_API bool rz_il_vm_sync_to_reg(RZ_NONNULL struct rz_il_vm_t *vm, RZ_NONNULL RzILRegBinding *rb, RZ_NONNULL RzReg *reg); +RZ_API void rz_il_vm_sync_from_reg(RZ_NONNULL struct rz_il_vm_t *vm, RZ_NONNULL RzILRegBinding *rb, RZ_NONNULL RzReg *reg); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_il/rz_il_validate.h b/dest/include/librz/rz_il/rz_il_validate.h new file mode 100644 index 00000000000..d200fff7be8 --- /dev/null +++ b/dest/include/librz/rz_il/rz_il_validate.h @@ -0,0 +1,46 @@ +// SPDX-FileCopyrightText: 2022 Florian Märkl +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_IL_VALIDATE_H +#define RZ_IL_VALIDATE_H + +#include + +/** + * \file + * \brief Validation/Type Checking of RzIL Code + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef char *RzILValidateReport; + +/** + * Global context for validation, defining: + * * all global variables with their sorts + * * all mems with their key and value lengths + * Validation can only be performes when this context is known, + * as for example the type of a var op referring to a global var + * depends on this. + */ +typedef struct rz_il_validate_global_context_t RzILValidateGlobalContext; + +RZ_API RzILValidateGlobalContext *rz_il_validate_global_context_new_empty(ut32 pc_len); +RZ_API void rz_il_validate_global_context_add_var(RzILValidateGlobalContext *ctx, RZ_NONNULL const char *name, RzILSortPure sort); +RZ_API void rz_il_validate_global_context_add_mem(RzILValidateGlobalContext *ctx, RzILMemIndex idx, ut32 key_len, ut32 val_len); +RZ_API RzILValidateGlobalContext *rz_il_validate_global_context_new_from_vm(RZ_NONNULL RzILVM *vm); +RZ_API void rz_il_validate_global_context_free(RzILValidateGlobalContext *ctx); +RZ_API bool rz_il_validate_pure(RZ_NULLABLE RzILOpPure *op, RZ_NONNULL RzILValidateGlobalContext *ctx, + RZ_NULLABLE RZ_OUT RzILSortPure *sort_out, RZ_NULLABLE RZ_OUT RzILValidateReport *report_out); +RZ_API bool rz_il_validate_effect(RZ_NULLABLE RzILOpEffect *op, RZ_NONNULL RzILValidateGlobalContext *ctx, + RZ_NULLABLE RZ_OUT HtSP /**/ **local_var_sorts_out, + RZ_NULLABLE RZ_OUT RzILTypeEffect *type_out, + RZ_NULLABLE RZ_OUT RzILValidateReport *report_out); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_IL_VALIDATE_H diff --git a/dest/include/librz/rz_il/rz_il_vm.h b/dest/include/librz/rz_il/rz_il_vm.h new file mode 100644 index 00000000000..83d02a777a9 --- /dev/null +++ b/dest/include/librz/rz_il/rz_il_vm.h @@ -0,0 +1,110 @@ +// SPDX-FileCopyrightText: 2021 Florian Märkl +// SPDX-FileCopyrightText: 2021 heersin +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_IL_VM_H +#define RZ_IL_VM_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rz_il_vm_t RzILVM; + +/** + * \brief Evaluation callback for a single pure opcode + * \param type when returning a non-null value, this must be set to the respective type. + * \return The evaluated value of the type indicated by *type, or NULL if an error occured and the execution should be aborted + */ +typedef void *(*RzILOpPureHandler)(RzILVM *vm, RzILOpPure *op, RZ_NONNULL RZ_OUT RzILTypePure *type); + +/** + * \brief Evaluation (execution) callback for a single effect opcode + * \return false if an error occured and the execution should be aborted + */ +typedef bool (*RzILOpEffectHandler)(RzILVM *vm, RzILOpEffect *op); + +typedef void (*RzILVmHook)(RzILVM *vm, RzILOpEffect *op); + +/** + * \brief Low-level VM to execute raw IL code + */ +struct rz_il_vm_t { + RzILVarSet global_vars; ///< All global variables (usually bound to registers) + RzILVarSet local_vars; ///< All local variables, created by local set ops + RzILVarSet local_pure_vars; ///< All local variables, during execution temporarily bound by let, only usable in pure expressions and immutable + RzPVector /**/ vm_memory; ///< Memories available in the VM, by their index. May be sparse (contain NULLs). + ut32 val_count, lab_count; ///< count for VM predefined things + ut32 addr_size; ///< size of address space + HtSP *vm_global_label_table; ///< Hashtable to maintain the label and address + HtSP *vm_local_label_table; ///< Hashtable to maintain the label and address + RzBitVector *pc; ///< Program Counter of VM + RzILOpPureHandler *op_handler_pure_table; ///< Array of Handler, handler can be indexed by opcode + RzILOpEffectHandler *op_handler_effect_table; ///< Array of Handler, handler can be indexed by opcode + RzPVector /**/ *events; ///< List of events that has happened in the last step + bool big_endian; ///< Sets the endianness of the memory reads/writes operations + RzILEventException halt_exceptions; ///< The exceptions the VM should halt if encountered. + bool halt; ///< If set the VM should halt and notify the user. +}; + +// VM high level operations +RZ_API RzILVM *rz_il_vm_new(ut64 start_addr, ut32 addr_size, bool big_endian, RzILEventException halt_exc); +RZ_API void rz_il_vm_free(RzILVM *vm); +RZ_API bool rz_il_vm_init(RzILVM *vm, ut64 start_addr, ut32 addr_size, bool big_endian, RzILEventException halt_exc); +RZ_API void rz_il_vm_fini(RzILVM *vm); + +RZ_API ut32 rz_il_vm_get_pc_len(RzILVM *vm); + +// VM Event operations +RZ_API void rz_il_vm_event_add(RzILVM *vm, RzILEvent *evt); +RZ_API void rz_il_vm_clear_events(RzILVM *vm); + +// Memory operations +RZ_API void rz_il_vm_add_mem(RzILVM *vm, RzILMemIndex index, RZ_OWN RzILMem *mem); +RZ_API RzILMem *rz_il_vm_get_mem(RzILVM *vm, RzILMemIndex index); + +RZ_API RzBitVector *rz_il_vm_mem_load(RzILVM *vm, RzILMemIndex index, RzBitVector *key); +RZ_API void rz_il_vm_mem_store(RzILVM *vm, RzILMemIndex index, RzBitVector *key, RzBitVector *value); +RZ_API RzBitVector *rz_il_vm_mem_loadw(RzILVM *vm, RzILMemIndex index, RzBitVector *key, ut32 n_bits); +RZ_API void rz_il_vm_mem_storew(RzILVM *vm, RzILMemIndex index, RzBitVector *key, RzBitVector *value); + +// Labels +RZ_API RZ_BORROW RzBitVector *rz_il_hash_find_addr_by_lblname(RZ_NONNULL RzILVM *vm, RZ_NONNULL const char *lbl_name); +RZ_API RZ_BORROW RzILEffectLabel *rz_il_vm_find_label_by_name(RZ_NONNULL RzILVM *vm, RZ_NONNULL const char *lbl_name); +RZ_API void rz_il_vm_add_label(RZ_NONNULL RzILVM *vm, RZ_NONNULL RzILEffectLabel *label); +RZ_API RZ_BORROW RzILEffectLabel *rz_il_vm_create_label(RZ_NONNULL RzILVM *vm, RZ_NONNULL const char *name, RZ_NONNULL RZ_BORROW RzBitVector *addr); +RZ_API RZ_BORROW RzILEffectLabel *rz_il_vm_create_label_lazy(RZ_NONNULL RzILVM *vm, RZ_NONNULL const char *name); +RZ_API RZ_BORROW RzILEffectLabel *rz_il_vm_update_label(RZ_NONNULL RzILVM *vm, RZ_NONNULL char *name, RZ_NONNULL RZ_BORROW RzBitVector *addr); + +// Variables +RZ_API RZ_BORROW RzILVar *rz_il_vm_create_global_var(RZ_NONNULL RzILVM *vm, RZ_NONNULL const char *name, RzILSortPure sort); +RZ_API void rz_il_vm_set_global_var(RZ_NONNULL RzILVM *vm, RZ_NONNULL const char *name, RZ_OWN RzILVal *val); +RZ_API void rz_il_vm_set_local_var(RZ_NONNULL RzILVM *vm, RZ_NONNULL const char *name, RZ_OWN RzILVal *val); +typedef RZ_NULLABLE RzILVal *RzILLocalPurePrev; +RZ_API RzILLocalPurePrev rz_il_vm_push_local_pure_var(RZ_NONNULL RzILVM *vm, RZ_NONNULL const char *name, RzILVal *val); +RZ_API void rz_il_vm_pop_local_pure_var(RZ_NONNULL RzILVM *vm, RZ_NONNULL const char *name, RzILLocalPurePrev prev); +RZ_API RZ_BORROW RzILVar *rz_il_vm_get_var(RZ_NONNULL RzILVM *vm, RzILVarKind kind, const char *name); +RZ_API RZ_OWN RzPVector /**/ *rz_il_vm_get_all_vars(RZ_NONNULL RzILVM *vm, RzILVarKind kind); +RZ_API RZ_BORROW RzILVal *rz_il_vm_get_var_value(RZ_NONNULL RzILVM *vm, RzILVarKind kind, const char *name); + +// Evaluation (Emulation) +RZ_API RZ_NULLABLE RZ_OWN RzBitVector *rz_il_evaluate_bitv(RZ_NONNULL RzILVM *vm, RZ_NONNULL RzILOpBitVector *op); +RZ_API RZ_NULLABLE RZ_OWN RzILBool *rz_il_evaluate_bool(RZ_NONNULL RzILVM *vm, RZ_NONNULL RzILOpBool *op); +RZ_API RZ_NULLABLE RZ_OWN RzFloat *rz_il_evaluate_float(RZ_NONNULL RzILVM *vm, RZ_NONNULL RzILOpPure *op); +RZ_API RZ_NULLABLE RZ_OWN RzILVal *rz_il_evaluate_val(RZ_NONNULL RzILVM *vm, RZ_NONNULL RzILOpPure *op); +RZ_API RZ_NULLABLE RZ_OWN void *rz_il_evaluate_pure(RZ_NONNULL RzILVM *vm, RZ_NONNULL RzILOpPure *op, RZ_NONNULL RzILTypePure *type); +RZ_API bool rz_il_evaluate_effect(RZ_NONNULL RzILVM *vm, RZ_NONNULL RzILOpEffect *op); + +RZ_API bool rz_il_vm_step(RzILVM *vm, RzILOpEffect *op, ut64 fallthrough_addr); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_IL_VM_H diff --git a/dest/include/librz/rz_io.h b/dest/include/librz/rz_io.h new file mode 100644 index 00000000000..30efcf91fdb --- /dev/null +++ b/dest/include/librz/rz_io.h @@ -0,0 +1,471 @@ +// SPDX-FileCopyrightText: 2017-2020 condret +// SPDX-FileCopyrightText: 2017-2020 pancake +// SPDX-FileCopyrightText: 2017-2020 alvaro +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_IO_H +#define RZ_IO_H + +#include "rz_list.h" +#include +#include +#include "rz_vector.h" +#include "rz_skyline.h" + +#define RZ_IO_SEEK_SET 0 +#define RZ_IO_SEEK_CUR 1 +#define RZ_IO_SEEK_END 2 + +#define rz_io_map_get_from(map) map->itv.addr +#define rz_io_map_get_to(map) (rz_itv_size(map->itv) ? rz_itv_end(map->itv) - 1 : 0) + +#if HAVE_PTRACE + +#if __sun +#include +#else +#if DEBUGGER && HAVE_PTRACE +#include +#endif +#endif + +#if (defined(__GLIBC__) && defined(__linux__)) +typedef enum __ptrace_request rz_ptrace_request_t; +typedef void *rz_ptrace_data_t; +#define RZ_PTRACE_NODATA NULL +#else +#if __ANDROID__ +typedef int rz_ptrace_request_t; +typedef void *rz_ptrace_data_t; +#define RZ_PTRACE_NODATA NULL +#elif __APPLE__ || __OpenBSD__ || __NetBSD__ || __FreeBSD__ || __DragonFly__ +typedef int rz_ptrace_request_t; +typedef int rz_ptrace_data_t; +#define RZ_PTRACE_NODATA 0 +#else +typedef int rz_ptrace_request_t; +typedef void *rz_ptrace_data_t; +#define RZ_PTRACE_NODATA NULL +#endif +#endif +#endif + +#if __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_io); + +typedef struct rz_io_t { + struct rz_io_desc_t *desc; // XXX deprecate... we should use only the fd integer, not hold a weak pointer + ut64 off; + int bits; + int va; // all of this config stuff must be in 1 int + int ff; + int Oxff; + size_t addrbytes; + int aslr; + int autofd; + int cached; + bool cachemode; // write in cache all the read operations (EXPERIMENTAL) + int p_cache; + RzIDPool *map_ids; + RzPVector /**/ maps; // from tail backwards maps with higher priority are found + RzSkyline map_skyline; // map parts that are not covered by others + RzIDStorage *files; + RzPVector /**/ cache; + RzSkyline cache_skyline; + ut8 *write_mask; + int write_mask_len; + HtSP /**/ *plugins; + char *runprofile; + char *envprofile; +#if USE_PTRACE_WRAP + struct ptrace_wrap_instance_t *ptrace_wrap; +#endif +#if __WINDOWS__ + struct w32dbg_wrap_instance_t *priv_w32dbg_wrap; ///< Do not access this directly, use rz_io_get_w32dbg_wrap() instead! +#endif + char *args; + RzEvent *event; + PrintfCallback cb_printf; + RzCoreBind corebind; +} RzIO; + +typedef struct rz_io_desc_t { + int fd; + int perm; + char *uri; + char *name; + char *referer; + HtUP /**/ *cache; + void *data; + struct rz_io_plugin_t *plugin; + RzIO *io; +} RzIODesc; + +typedef struct { + ut64 magic; + int pid; + int tid; + void *data; +} RzIODescData; + +typedef struct rz_io_plugin_t { + const char *name; + const char *desc; + const char *version; + const char *author; + const char *license; + void *widget; + const char *uris; + int (*listener)(RzIODesc *io); + bool isdbg; + // int (*is_file_opened)(RzIO *io, RzIODesc *fd, const char *); + char *(*system)(RzIO *io, RzIODesc *fd, const char *); + RzIODesc *(*open)(RzIO *io, const char *, int perm, int mode); + RzList /**/ *(*open_many)(RzIO *io, const char *, int perm, int mode); + int (*read)(RzIO *io, RzIODesc *fd, ut8 *buf, size_t len); + ut64 (*lseek)(RzIO *io, RzIODesc *fd, ut64 offset, int whence); + int (*write)(RzIO *io, RzIODesc *fd, const ut8 *buf, size_t len); + int (*close)(RzIODesc *desc); + bool (*is_blockdevice)(RzIODesc *desc); + bool (*is_chardevice)(RzIODesc *desc); + int (*getpid)(RzIODesc *desc); + int (*gettid)(RzIODesc *desc); + bool (*getbase)(RzIODesc *desc, ut64 *base); + bool (*resize)(RzIO *io, RzIODesc *fd, ut64 size); + bool (*accept)(RzIO *io, RzIODesc *desc, int fd); + int (*create)(RzIO *io, const char *file, int mode, int type); + bool (*check)(RzIO *io, const char *, bool many); + ut8 *(*get_buf)(RzIODesc *desc, ut64 *size); +} RzIOPlugin; + +typedef struct rz_io_map_t { + int fd; + int perm; + ut32 id; + RzInterval itv; + ut64 delta; // paddr = itv.addr + delta + RZ_NULLABLE char *name; + + /** + * @brief Uninterpreted data to be injected from outside + * + * RZ_EVENT_IO_MAP_DEL may be listened to if any freeing is necessary. + * (Hint when part of RzCore: RzCoreIOMapInfo is stored here) + */ + void *user; +} RzIOMap; + +typedef struct rz_io_cache_t { + RzInterval itv; + ut8 *data; + ut8 *odata; + int written; +} RzIOCache; + +#define RZ_IO_DESC_CACHE_SIZE (sizeof(ut64) * 8) +typedef struct rz_io_desc_cache_t { + ut64 cached; + ut8 cdata[RZ_IO_DESC_CACHE_SIZE]; +} RzIODescCache; + +typedef struct rz_event_io_write_t { + ut64 addr; + const ut8 *buf; + size_t len; +} RzEventIOWrite; + +typedef struct rz_event_io_desc_close_t { + RzIODesc *desc; +} RzEventIODescClose; + +typedef struct rz_event_io_map_del_t { + RzIOMap *map; +} RzEventIOMapDel; + +struct rz_io_bind_t; + +typedef int (*RzIOGetCurrentFd)(RzIO *io); +typedef bool (*RzIODescUse)(RzIO *io, int fd); +typedef RzIODesc *(*RzIODescGet)(RzIO *io, int fd); +typedef ut64 (*RzIODescSize)(RzIODesc *desc); +typedef RzIODesc *(*RzIOOpen)(RzIO *io, const char *uri, int flags, int mode); +typedef RzIODesc *(*RzIOOpenAt)(RzIO *io, const char *uri, int flags, int mode, ut64 at, RZ_NULLABLE RZ_OUT RzIOMap **map); +typedef bool (*RzIOClose)(RzIO *io, int fd); +typedef bool (*RzIOReadAt)(RzIO *io, ut64 addr, ut8 *buf, size_t req_len); +typedef bool (*RzIOWriteAt)(RzIO *io, ut64 addr, const ut8 *buf, size_t len); +typedef char *(*RzIOSystem)(RzIO *io, const char *cmd); +typedef int (*RzIOFdOpen)(RzIO *io, const char *uri, int flags, int mode); +typedef bool (*RzIOFdClose)(RzIO *io, int fd); +typedef ut64 (*RzIOFdSeek)(RzIO *io, int fd, ut64 addr, int whence); +typedef ut64 (*RzIOFdSize)(RzIO *io, int fd); +typedef bool (*RzIOFdResize)(RzIO *io, int fd, ut64 newsize); +typedef ut64 (*RzIOP2V)(RzIO *io, ut64 pa); +typedef ut64 (*RzIOV2P)(RzIO *io, ut64 va); +typedef int (*RzIOFdRead)(RzIO *io, int fd, ut8 *buf, size_t len); +typedef int (*RzIOFdWrite)(RzIO *io, int fd, const ut8 *buf, size_t len); +typedef int (*RzIOFdReadAt)(RzIO *io, int fd, ut64 addr, ut8 *buf, size_t len); +typedef int (*RzIOFdWriteAt)(RzIO *io, int fd, ut64 addr, const ut8 *buf, size_t len); +typedef bool (*RzIOFdIsDbg)(RzIO *io, int fd); +typedef const char *(*RzIOFdGetName)(RzIO *io, int fd); +typedef RzList *(*RzIOFdGetMap)(RzIO *io, int fd); +typedef bool (*RzIOFdRemap)(RzIO *io, int fd, ut64 addr); +typedef ut8 *(*RzIOFdGetBuf)(RzIO *io, int fd, ut64 *size); +typedef bool (*RzIOIsValidOff)(RzIO *io, ut64 addr, int hasperm); +typedef RzIOMap *(*RzIOMapGet)(RzIO *io, ut64 addr); +typedef RzIOMap *(*RzIOMapGetPaddr)(RzIO *io, ut64 paddr); +typedef bool (*RzIOAddrIsMapped)(RzIO *io, ut64 addr); +typedef RzIOMap *(*RzIOMapAdd)(RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size); +#if HAVE_PTRACE +typedef long (*RzIOPtraceFn)(RzIO *io, rz_ptrace_request_t request, pid_t pid, void *addr, rz_ptrace_data_t data); +typedef void *(*RzIOPtraceFuncFn)(RzIO *io, void *(*func)(void *), void *user); +#endif +#if __WINDOWS__ +typedef struct w32dbg_wrap_instance_t *(*RzIOGetW32DbgWrap)(RzIO *io); +#endif + +typedef struct rz_io_bind_t { + int init; + RzIO *io; + RzIOGetCurrentFd fd_get_current; + RzIODescUse desc_use; + RzIODescGet desc_get; + RzIODescSize desc_size; + RzIOOpen open; + RzIOOpenAt open_at; + RzIOClose close; + RzIOReadAt read_at; + RzIOWriteAt write_at; + RzIOSystem system; + RzIOFdOpen fd_open; + RzIOFdClose fd_close; + RzIOFdSeek fd_seek; // needed for esil + RzIOFdSize fd_size; + RzIOFdResize fd_resize; + RzIOFdRead fd_read; // needed for esil + RzIOFdWrite fd_write; // needed for esil + RzIOFdReadAt fd_read_at; + RzIOFdWriteAt fd_write_at; + RzIOFdIsDbg fd_is_dbg; + RzIOFdGetName fd_get_name; + RzIOFdGetMap fd_get_map; + RzIOFdRemap fd_remap; + RzIOFdGetBuf fd_getbuf; + RzIOIsValidOff is_valid_offset; + RzIOAddrIsMapped addr_is_mapped; + RzIOMapGet map_get; + RzIOMapGetPaddr map_get_paddr; + RzIOMapAdd map_add; + RzIOV2P v2p; + RzIOP2V p2v; +#if HAVE_PTRACE + RzIOPtraceFn ptrace; + RzIOPtraceFuncFn ptrace_func; +#endif +#if __WINDOWS__ + RzIOGetW32DbgWrap get_w32dbg_wrap; +#endif +} RzIOBind; + +/** + * \brief Compare plugins by name (via strcmp). + */ +static inline int rz_io_plugin_cmp(RZ_NULLABLE const RzIOPlugin *a, RZ_NULLABLE const RzIOPlugin *b) { + if (!a && !b) { + return 0; + } else if (!a) { + return -1; + } else if (!b) { + return 1; + } + return rz_str_cmp(a->name, b->name, -1); +} + +// map.c +RZ_API RzIOMap *rz_io_map_new(RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size); +RZ_API void rz_io_map_init(RzIO *io); +RZ_API bool rz_io_map_remap(RzIO *io, ut32 id, ut64 addr); +RZ_API bool rz_io_map_remap_fd(RzIO *io, int fd, ut64 addr); +RZ_API ut64 rz_io_map_location(RzIO *io, ut64 size); +RZ_API bool rz_io_map_exists(RzIO *io, RzIOMap *map); +RZ_API bool rz_io_map_exists_for_id(RzIO *io, ut32 id); +RZ_API RzIOMap *rz_io_map_resolve(RzIO *io, ut32 id); +RZ_API RzIOMap *rz_io_map_add(RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size); +// same as rz_io_map_add but used when many maps need to be added. Call rz_io_update when all maps have been added. +RZ_API RzIOMap *rz_io_map_add_batch(RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size); +RZ_API RzIOMap *rz_io_map_get(RzIO *io, ut64 addr); // returns the map at vaddr with the highest priority +// update the internal state of RzIO after a series of _batch operations +RZ_API void rz_io_update(RzIO *io); +RZ_API bool rz_io_map_is_mapped(RzIO *io, ut64 addr); +RZ_API RzIOMap *rz_io_map_get_paddr(RzIO *io, ut64 paddr); // returns the map at paddr with the highest priority +RZ_API void rz_io_map_reset(RzIO *io); +RZ_API bool rz_io_map_del(RzIO *io, ut32 id); +RZ_API bool rz_io_map_del_for_fd(RzIO *io, int fd); +RZ_API bool rz_io_map_depriorize(RzIO *io, ut32 id); +RZ_API bool rz_io_map_priorize(RzIO *io, ut32 id); +RZ_API bool rz_io_map_priorize_for_fd(RzIO *io, int fd); +RZ_API void rz_io_map_cleanup(RzIO *io); +RZ_API void rz_io_map_fini(RzIO *io); +RZ_API void rz_io_map_set_name(RzIOMap *map, const char *name); +RZ_API void rz_io_map_del_name(RzIOMap *map); +RZ_API RzList /**/ *rz_io_map_get_for_fd(RzIO *io, int fd); +RZ_API bool rz_io_map_resize(RzIO *io, ut32 id, ut64 newsize); +RZ_API RZ_BORROW RzPVector /**/ *rz_io_maps(RzIO *io); + +// next free address to place a map.. maybe just unify +RZ_API ut64 rz_io_map_next_available(RzIO *io, ut64 addr, ut64 size, ut64 load_align); +RZ_API ut64 rz_io_map_next_address(RzIO *io, ut64 addr); + +// p2v/v2p + +RZ_API ut64 rz_io_p2v(RzIO *io, ut64 pa); +RZ_API ut64 rz_io_v2p(RzIO *io, ut64 va); + +// io.c +RZ_API RzIO *rz_io_new(void); +RZ_API RzIO *rz_io_init(RzIO *io); +RZ_API RzIODesc *rz_io_open_nomap(RzIO *io, const char *uri, int flags, int mode); // should return int +RZ_API RzIODesc *rz_io_open(RzIO *io, const char *uri, int flags, int mode); +RZ_API RzIODesc *rz_io_open_at(RzIO *io, const char *uri, int flags, int mode, ut64 at, RZ_NULLABLE RZ_OUT RzIOMap **map); +RZ_API RzList /**/ *rz_io_open_many(RzIO *io, const char *uri, int flags, int mode); +RZ_API RzIODesc *rz_io_open_buffer(RzIO *io, RzBuffer *b, int flags, int mode); +RZ_API bool rz_io_close(RzIO *io); +RZ_API bool rz_io_reopen(RzIO *io, int fd, int flags, int mode); +RZ_API int rz_io_close_all(RzIO *io); +RZ_API int rz_io_pread_at(RzIO *io, ut64 paddr, ut8 *buf, size_t len); +RZ_API int rz_io_pwrite_at(RzIO *io, ut64 paddr, const ut8 *buf, size_t len); +RZ_API bool rz_io_vread_at_mapped(RzIO *io, ut64 vaddr, ut8 *buf, size_t len); +RZ_API bool rz_io_read_at_mapped(RZ_NONNULL RzIO *io, ut64 addr, RZ_OUT RZ_NONNULL ut8 *buf, size_t len); +RZ_API int rz_io_nread_at(RZ_NONNULL RzIO *io, ut64 addr, RZ_OUT RZ_NONNULL ut8 *buf, size_t len); +RZ_API RZ_OWN RzBuffer *rz_io_nread_at_new_buf(RZ_NONNULL RzIO *io, ut64 addr, size_t len); +RZ_API bool rz_io_write_at(RzIO *io, ut64 addr, const ut8 *buf, size_t len); +RZ_API bool rz_io_read(RzIO *io, ut8 *buf, size_t len); +RZ_API bool rz_io_write(RzIO *io, const ut8 *buf, size_t len); +RZ_API ut64 rz_io_size(RzIO *io); +RZ_API bool rz_io_is_listener(RzIO *io); +RZ_API char *rz_io_system(RzIO *io, const char *cmd); +RZ_API bool rz_io_resize(RZ_NONNULL RzIO *io, ut64 newsize); +RZ_API bool rz_io_extend_at(RzIO *io, ut64 addr, ut64 size); +RZ_API bool rz_io_set_write_mask(RzIO *io, const ut8 *mask, size_t len); +RZ_API void rz_io_bind(RzIO *io, RzIOBind *bnd); +RZ_API bool rz_io_shift(RzIO *io, ut64 start, ut64 end, st64 move); +RZ_API ut64 rz_io_seek(RzIO *io, ut64 offset, int whence); +RZ_API int rz_io_fini(RzIO *io); +RZ_API void rz_io_free(RzIO *io); +#define rz_io_bind_init(x) memset(&x, 0, sizeof(x)) + +RZ_API bool rz_io_plugin_init(RzIO *io); +RZ_API bool rz_io_plugin_add(RzIO *io, RZ_NONNULL RZ_BORROW RzIOPlugin *plugin); +RZ_API bool rz_io_plugin_del(RzIO *io, RZ_NONNULL RZ_BORROW RzIOPlugin *plugin); +RZ_API int rz_io_plugin_read(RzIODesc *desc, ut8 *buf, size_t len); +RZ_API int rz_io_plugin_write(RzIODesc *desc, const ut8 *buf, size_t len); +RZ_API int rz_io_plugin_read_at(RzIODesc *desc, ut64 addr, ut8 *buf, size_t len); +RZ_API int rz_io_plugin_write_at(RzIODesc *desc, ut64 addr, const ut8 *buf, size_t len); +RZ_API RzIOPlugin *rz_io_plugin_resolve(RzIO *io, const char *filename, bool many); +RZ_API RzIOPlugin *rz_io_plugin_get_default(RzIO *io, const char *filename, bool many); + +// desc.c +RZ_API RzIODesc *rz_io_desc_new(RzIO *io, RzIOPlugin *plugin, const char *uri, int flags, void *data); +RZ_API RzIODesc *rz_io_desc_open(RzIO *io, const char *uri, int flags, int mode); +RZ_API RzIODesc *rz_io_desc_open_plugin(RzIO *io, RzIOPlugin *plugin, const char *uri, int flags, int mode); +RZ_API bool rz_io_desc_close(RzIODesc *desc); +RZ_API int rz_io_desc_read(RzIODesc *desc, ut8 *buf, size_t len); +RZ_API int rz_io_desc_write(RzIODesc *desc, const ut8 *buf, size_t len); +RZ_API void rz_io_desc_free(RzIODesc *desc); +RZ_API bool rz_io_desc_add(RzIO *io, RzIODesc *desc); +RZ_API bool rz_io_desc_del(RzIO *io, int fd); +RZ_API RzIODesc *rz_io_desc_get(RzIO *io, int fd); +RZ_API ut64 rz_io_desc_seek(RzIODesc *desc, ut64 offset, int whence); +RZ_API bool rz_io_desc_resize(RzIODesc *desc, ut64 newsize); +RZ_API ut64 rz_io_desc_size(RzIODesc *desc); +RZ_API ut8 *rz_io_desc_get_buf(RzIODesc *desc, RZ_OUT RZ_NONNULL ut64 *size); +RZ_API bool rz_io_desc_is_blockdevice(RzIODesc *desc); +RZ_API bool rz_io_desc_is_chardevice(RzIODesc *desc); +RZ_API bool rz_io_desc_exchange(RzIO *io, int fd, int fdx); // this should get 2 descs +RZ_API bool rz_io_desc_is_dbg(RzIODesc *desc); +RZ_API int rz_io_desc_get_pid(RzIODesc *desc); +RZ_API int rz_io_desc_get_tid(RzIODesc *desc); +RZ_API bool rz_io_desc_get_base(RzIODesc *desc, ut64 *base); +RZ_API int rz_io_desc_read_at(RzIODesc *desc, ut64 addr, ut8 *buf, size_t len); +RZ_API int rz_io_desc_write_at(RzIODesc *desc, ut64 addr, const ut8 *buf, size_t len); + +/* lifecycle */ +RZ_IPI bool rz_io_desc_init(RzIO *io); +RZ_IPI bool rz_io_desc_fini(RzIO *io); + +/* io/cache.c */ +RZ_API int rz_io_cache_invalidate(RzIO *io, ut64 from, ut64 to); +RZ_API bool rz_io_cache_at(RzIO *io, ut64 addr); +RZ_API void rz_io_cache_commit(RzIO *io, ut64 from, ut64 to); +RZ_API void rz_io_cache_init(RzIO *io); +RZ_API void rz_io_cache_fini(RzIO *io); +RZ_API void rz_io_cache_reset(RzIO *io, int set); +RZ_API bool rz_io_cache_write(RzIO *io, ut64 addr, const ut8 *buf, size_t len); +RZ_API bool rz_io_cache_read( + RZ_BORROW RZ_NONNULL RzIO *io, + ut64 addr, + RZ_OUT RZ_NONNULL ut8 *buf, + size_t len, + RZ_OUT RZ_NULLABLE size_t *copied); + +/* io/p_cache.c */ +RZ_API bool rz_io_desc_cache_init(RzIODesc *desc); +RZ_API int rz_io_desc_cache_write(RzIODesc *desc, ut64 paddr, const ut8 *buf, size_t len); +RZ_API int rz_io_desc_cache_read(RzIODesc *desc, ut64 paddr, ut8 *buf, size_t len); +RZ_API bool rz_io_desc_cache_commit(RzIODesc *desc); +RZ_API void rz_io_desc_cache_cleanup(RzIODesc *desc); +RZ_API void rz_io_desc_cache_fini(RzIODesc *desc); +RZ_API void rz_io_desc_cache_fini_all(RzIO *io); +RZ_API RzList /**/ *rz_io_desc_cache_list(RzIODesc *desc); + +/* io/fd.c */ +RZ_API int rz_io_fd_open(RzIO *io, const char *uri, int flags, int mode); +RZ_API bool rz_io_fd_close(RzIO *io, int fd); +RZ_API int rz_io_fd_read(RzIO *io, int fd, ut8 *buf, size_t len); +RZ_API int rz_io_fd_write(RzIO *io, int fd, const ut8 *buf, size_t len); +RZ_API ut64 rz_io_fd_seek(RzIO *io, int fd, ut64 addr, int whence); +RZ_API ut64 rz_io_fd_size(RzIO *io, int fd); +RZ_API ut8 *rz_io_fd_get_buf(RzIO *io, int fd, RZ_OUT RZ_NONNULL ut64 *size); +RZ_API bool rz_io_fd_resize(RzIO *io, int fd, ut64 newsize); +RZ_API bool rz_io_fd_is_blockdevice(RzIO *io, int fd); +RZ_API bool rz_io_fd_is_chardevice(RzIO *io, int fd); +RZ_API int rz_io_fd_read_at(RzIO *io, int fd, ut64 addr, ut8 *buf, size_t len); +RZ_API int rz_io_fd_write_at(RzIO *io, int fd, ut64 addr, const ut8 *buf, size_t len); +RZ_API bool rz_io_fd_is_dbg(RzIO *io, int fd); +RZ_API int rz_io_fd_get_pid(RzIO *io, int fd); +RZ_API int rz_io_fd_get_tid(RzIO *io, int fd); +RZ_API bool rz_io_fd_get_base(RzIO *io, int fd, ut64 *base); +RZ_API const char *rz_io_fd_get_name(RzIO *io, int fd); +RZ_API int rz_io_fd_get_current(RzIO *io); +RZ_API int rz_io_fd_get_next(RzIO *io, int fd); +RZ_API int rz_io_fd_get_prev(RzIO *io, int fd); +RZ_API int rz_io_fd_get_highest(RzIO *io); +RZ_API int rz_io_fd_get_lowest(RzIO *io); +RZ_API bool rz_io_use_fd(RzIO *io, int fd); + +#define rz_io_range_new() RZ_NEW0(RzIORange) +#define rz_io_range_free(x) free(x) + +/* io/ioutils.c */ +RZ_API bool rz_io_is_valid_offset(RzIO *io, ut64 offset, int hasperm); +RZ_API bool rz_io_addr_is_mapped(RzIO *io, ut64 vaddr); +RZ_API bool rz_io_read_i(RzIO *io, ut64 addr, ut64 *val, int size, bool endian); +RZ_API bool rz_io_write_i(RzIO *io, ut64 addr, ut64 *val, int size, bool endian); + +#if HAVE_PTRACE +RZ_API long rz_io_ptrace(RzIO *io, rz_ptrace_request_t request, pid_t pid, void *addr, rz_ptrace_data_t data); +RZ_API pid_t rz_io_ptrace_fork(RzIO *io, void (*child_callback)(void *), void *child_callback_user); +RZ_API void *rz_io_ptrace_func(RzIO *io, void *(*func)(void *), void *user); +#endif + +#if __WINDOWS__ +RZ_API struct w32dbg_wrap_instance_t *rz_io_get_w32dbg_wrap(RzIO *io); +#endif + +#if __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_lang.h b/dest/include/librz/rz_lang.h new file mode 100644 index 00000000000..f7249d6f667 --- /dev/null +++ b/dest/include/librz/rz_lang.h @@ -0,0 +1,77 @@ +#ifndef RZ_LANG_H +#define RZ_LANG_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_lang); + +typedef char *(*RzCoreCmdStrCallback)(void *core, const char *s); +typedef int (*RzCoreCmdfCallback)(void *core, const char *s, ...); + +typedef struct rz_lang_t { + struct rz_lang_plugin_t *cur; + void *user; + RzList /**/ *defs; + RzList /**/ *langs; + PrintfCallback cb_printf; + RzCoreCmdStrCallback cmd_str; + RzCoreCmdfCallback cmdf; + RzPath *sys_path; ///< pointer to RzPath, contains path prefix of the system +} RzLang; + +typedef struct rz_lang_plugin_t { + const char *name; + const char *alias; + const char *desc; + const char *license; + const char **help; + const char *ext; + int (*init)(RzLang *user); + bool (*setup)(RzLang *user); + int (*fini)(RzLang *user); + int (*prompt)(RzLang *user); + int (*run)(RzLang *user, const char *code, int len); + int (*run_file)(RzLang *user, const char *file); + int (*set_argv)(RzLang *user, int argc, char **argv); +} RzLangPlugin; + +typedef struct rz_lang_def_t { + char *name; + char *type; + void *value; +} RzLangDef; + +#ifdef RZ_API +RZ_API RzLang *rz_lang_new(void); +RZ_API void rz_lang_free(RzLang *lang); +RZ_API bool rz_lang_setup(RzLang *lang); +RZ_API bool rz_lang_plugin_add(RzLang *lang, RZ_NONNULL RzLangPlugin *plugin); +RZ_API bool rz_lang_plugin_del(RzLang *lang, RZ_NONNULL RzLangPlugin *plugin); +RZ_API bool rz_lang_use(RzLang *lang, const char *name); +RZ_API int rz_lang_run(RzLang *lang, const char *code, int len); +RZ_API int rz_lang_run_string(RzLang *lang, const char *code); +RZ_API int rz_lang_run_file(RzLang *lang, const char *file); +/* TODO: user_ptr must be deprecated */ +RZ_API void rz_lang_set_user_ptr(RzLang *lang, void *user); +RZ_API bool rz_lang_set_argv(RzLang *lang, int argc, char **argv); +RZ_API int rz_lang_prompt(RzLang *lang); +RZ_API RzLangPlugin *rz_lang_get_by_name(RzLang *lang, const char *name); +RZ_API RzLangPlugin *rz_lang_get_by_extension(RzLang *lang, const char *ext); + +RZ_API bool rz_lang_define(RzLang *lang, const char *type, const char *name, void *value); +RZ_API void rz_lang_undef(RzLang *lang, const char *name); +RZ_API void rz_lang_def_free(RzLangDef *def); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_lib.h b/dest/include/librz/rz_lib.h new file mode 100644 index 00000000000..f652ba80a4a --- /dev/null +++ b/dest/include/librz/rz_lib.h @@ -0,0 +1,122 @@ +#ifndef RZ_LIB_H +#define RZ_LIB_H + +#include "rz_types.h" +#include "rz_list.h" +#include + +#if __UNIX__ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_lib); + +#define RZ_LIB_SYMNAME "rizin_plugin" +#define RZ_LIB_SYMFUNC "rizin_plugin_function" + +#define RZ_LIB_ENV "RZ_LIB_PLUGINS" + +/* TODO: This must depend on HOST_OS, and maybe move into rz_types */ +#if __WINDOWS__ +#define RZ_LIB_EXT "dll" +#elif __APPLE__ +#define RZ_LIB_EXT "dylib" +#else +#define RZ_LIB_EXT "so" +#endif + +/** + * \brief Identify the Plugin type + */ +typedef enum { + RZ_LIB_TYPE_IO, ///< io layer + RZ_LIB_TYPE_DBG, ///< debugger + RZ_LIB_TYPE_LANG, ///< language + RZ_LIB_TYPE_ASM, ///< assembler + RZ_LIB_TYPE_ANALYSIS, ///< analysis + RZ_LIB_TYPE_PARSE, ///< parsers + RZ_LIB_TYPE_BIN, ///< bin headers + RZ_LIB_TYPE_BIN_XTR, ///< bin extractors + RZ_LIB_TYPE_BIN_LDR, ///< DEPRECATED + RZ_LIB_TYPE_BP, ///< breakpoint + RZ_LIB_TYPE_SYSCALL, ///< DEPRECATED + RZ_LIB_TYPE_FASTCALL, ///< DEPRECATED + RZ_LIB_TYPE_CRYPTO, ///< cryptography + RZ_LIB_TYPE_HASH, ///< hashes / message digests + RZ_LIB_TYPE_CORE, ///< RzCore commands + RZ_LIB_TYPE_EGG, ///< rz_egg plugin + RZ_LIB_TYPE_DEMANGLER, ///< demanglers + RZ_LIB_TYPE_ARCH, ///< demanglers + RZ_LIB_TYPE_UNKNOWN +} RzLibType; + +/** + * \brief Represent a single Plugin + */ +typedef struct rz_lib_plugin_t { + RzLibType type; ///< Type of the plugin + char *file; ///< File path + void *data; ///< User pointer + struct rz_lib_handler_t *handler; ///< Handler that handles this plugin + char *author; ///< Author of the plugin + char *version; ///< Version of the plugin + void (*free)(void *data); +} RzLibPlugin; + +typedef bool (*RzLibCallback)(RzLibPlugin *, void *, void *); + +/** + * \brief Identify how a type of plugins should be handled. + */ +typedef struct rz_lib_handler_t { + RzLibType type; ///< Plugin type this handler handles + char desc[128]; ///< Description of the handler + void *user; ///< User pointer + RzLibCallback constructor; ///< Callback to call when a new plugin of the right type is added + RzLibCallback destructor; ///< Callback to call when a plugin of the right type is removed +} RzLibHandler; + +/** + * \brief Represent the content of a plugin + * + * This structure should be pointed by the 'rizin_plugin' symbol found in the + * loaded library (e.g. .so file). + */ +typedef struct rz_lib_struct_t { + RzLibType type; ///< type of the plugin to load + void *data; ///< pointer to data handled by plugin handler (e.g. RzBinPlugin, RzAsmPlugin, etc.) + const char *version; ///< rizin version this plugin was compiled for + void (*free)(void *data); +} RzLibStruct; + +typedef RzLibStruct *(*RzLibStructFunc)(void); + +/** + * \brief Handle all the opened plugins, the plugin-types handlers, etc. + */ +typedef struct rz_lib_t { + char *symname; + char *symnamefunc; + RzList /**/ *plugins; + RzList /**/ *handlers; + HtSU *opened_dirs; ///< Hashtable to keep track of already opened directories +} RzLib; + +#ifdef RZ_API +RZ_API RzLib *rz_lib_new(RZ_NULLABLE const char *symname, RZ_NULLABLE const char *symnamefunc); +RZ_API void rz_lib_free(RzLib *lib); +RZ_API bool rz_lib_open(RzLib *lib, RZ_NONNULL const char *file); +RZ_API bool rz_lib_opendir(RzLib *lib, const char *path, bool force); +RZ_API bool rz_lib_add_handler(RzLib *lib, RzLibType type, RZ_NONNULL const char *desc, RzLibCallback ct, RzLibCallback dt, void *user); +RZ_API bool rz_lib_close(RzLib *lib, const char *file); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_list.h b/dest/include/librz/rz_list.h new file mode 100644 index 00000000000..093fe5d86b5 --- /dev/null +++ b/dest/include/librz/rz_list.h @@ -0,0 +1,117 @@ +#ifndef RZ_LIST_H +#define RZ_LIST_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*RzListFree)(void *ptr); + +typedef struct rz_list_iter_t RzListIter; + +struct rz_list_iter_t { + void *val; + RzListIter *next; + RzListIter *prev; +}; + +typedef struct rz_list_t { + RzListIter *head; + RzListIter *tail; + RzListFree free; + ut32 length; + bool sorted; +} RzList; + +// RzListComparator should return -1, 0, 1 to indicate "value < list_data", "value == list_data", "value > list_data". +typedef int (*RzListComparator)(const void *value, const void *list_data, void *user); + +#ifdef RZ_API + +#define rz_list_foreach(list, it, var) \ + if (list) \ + for (it = list->head; it && (var = it->val, 1); it = it->next) +#define rz_list_foreach_enum(list, it, var, i) \ + if (list) \ + for (it = list->head, i = 0; it && (var = it->val, 1); it = it->next, ++i) +#define rz_list_foreach_iter(iter, it, var) \ + for (it = iter; it && (var = it->val, 1); it = it->next) +/* Safe when calling rz_list_delete() while iterating over the list. */ +#define rz_list_foreach_safe(list, it, tmp, var) \ + if (list) \ + for (it = list->head; it && (var = it->val, tmp = it->next, 1); it = tmp) +#define rz_list_foreach_iter_safe(iter, it, tmp, var) \ + for (it = iter; it && (var = it->val, tmp = it->next, 1); it = tmp) +#define rz_list_foreach_prev(list, it, var) \ + if (list) \ + for (it = list->tail; it && (var = it->val, 1); it = it->prev) +#define rz_list_foreach_prev_safe(list, it, tmp, var) \ + for (it = list->tail; it && (var = it->val, tmp = it->prev, 1); it = tmp) + +#define rz_list_empty(x) (!(x) || !(x)->length) +#define rz_list_head(x) ((x) ? (x)->head : NULL) +#define rz_list_tail(x) ((x) ? (x)->tail : NULL) +#define rz_list_prev(x) ((x)->prev) +#define rz_list_next(x) ((x)->next) + +#define rz_list_iter_get(x) \ + x->val; \ + x = x->next +#define rz_list_iter_has_next(x) (x->next) +#define rz_list_iter_has_prev(x) (x->prev) + +RZ_API RZ_OWN RzList *rz_list_new(void); +RZ_API RZ_OWN RzList *rz_list_newf(RZ_NULLABLE RzListFree f); +RZ_API RZ_OWN RzList *rz_list_new_from_array(const void **arr, size_t arr_size); +RZ_API RZ_OWN RzList *rz_list_new_from_iterator(RZ_BORROW RZ_NONNULL RzIterator *iter); +RZ_API RZ_BORROW void *rz_list_iter_get_prev_data(RZ_NONNULL RzListIter *iter); +RZ_API RZ_BORROW void *rz_list_iter_get_next_data(RZ_NONNULL RzListIter *iter); +RZ_API ut32 rz_list_set_n(RZ_NONNULL RzList *list, ut32 n, RZ_NONNULL void *data); +RZ_API void *rz_list_iter_get_data(RZ_NONNULL RzListIter *iter); +RZ_API bool rz_list_iter_set_data(RZ_NONNULL RzListIter *iter, RZ_NULLABLE void *data); +RZ_API bool rz_list_iter_swap_data(RZ_NONNULL RzListIter *iter0, RZ_NONNULL RzListIter *iter1); +RZ_API RZ_BORROW RzListIter *rz_list_append(RZ_NONNULL RzList *list, RZ_NONNULL void *data); +RZ_API RZ_BORROW RzListIter *rz_list_prepend(RZ_NONNULL RzList *list, RZ_NONNULL void *data); +RZ_API RZ_BORROW RzListIter *rz_list_insert(RZ_NONNULL RzList *list, ut32 n, RZ_NONNULL void *data); +RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list); +RZ_API RZ_BORROW void *rz_list_first_val(RZ_NONNULL const RzList *list); +RZ_API RZ_BORROW void *rz_list_last_val(RZ_NONNULL const RzList *list); +RZ_API RZ_BORROW RzListIter *rz_list_add_sorted(RZ_NONNULL RzList *list, RZ_NONNULL void *data, RZ_NONNULL RzListComparator cmp, void *user); +RZ_API void rz_list_sort(RZ_NONNULL RzList *list, RZ_NONNULL RzListComparator cmp, void *user); +RZ_API void rz_list_merge_sort(RZ_NONNULL RzList *list, RZ_NONNULL RzListComparator cmp, void *user); +RZ_API void rz_list_insertion_sort(RZ_NONNULL RzList *list, RZ_NONNULL RzListComparator cmp, void *user); +RZ_API RZ_OWN RzList *rz_list_uniq(RZ_NONNULL const RzList *list, RZ_NONNULL RzListComparator cmp, void *user); +RZ_API void rz_list_sorted_uniq(RZ_NONNULL RzList *list, RZ_NONNULL RzListComparator cmp, void *user); +RZ_API void rz_list_init(RZ_NONNULL RzList *list); +RZ_API void rz_list_delete(RZ_NONNULL RzList *list, RZ_OWN RZ_NONNULL RzListIter *iter); +RZ_API bool rz_list_delete_val(RZ_NONNULL RzList *list, void *val); +RZ_API void rz_list_purge(RZ_NONNULL RzList *list); +RZ_API void rz_list_free(RZ_NULLABLE RzList *list); +RZ_API RZ_OWN RzListIter *rz_list_item_new(RZ_NULLABLE void *data); +RZ_API bool rz_list_join(RZ_NONNULL RzList *list1, RZ_NONNULL RzList *list2); +RZ_API RZ_BORROW void *rz_list_get_n(RZ_NONNULL const RzList *list, ut32 n); +RZ_API ut32 rz_list_del_n(RZ_NONNULL RzList *list, ut32 n); +RZ_API RZ_BORROW RzListIter *rz_list_iterator(RZ_NONNULL const RzList *list); +RZ_API RZ_BORROW RzListIter *rz_list_push(RZ_NONNULL RzList *list, void *item); +RZ_API RZ_OWN void *rz_list_pop(RZ_NONNULL RzList *list); +RZ_API RZ_OWN void *rz_list_pop_head(RZ_NONNULL RzList *list); +RZ_API void rz_list_reverse(RZ_NONNULL RzList *list); +RZ_API RZ_OWN RzList *rz_list_clone(RZ_NONNULL const RzList *list); +RZ_API RZ_OWN char *rz_list_to_str(RZ_NONNULL RzList *list, char ch); + +/* hashlike api */ +RZ_API RZ_BORROW bool rz_list_contains(RZ_NONNULL const RzList *list, RZ_NONNULL const void *val); +RZ_API RZ_BORROW RzListIter *rz_list_find_val(RZ_NONNULL const RzList *list, RZ_NONNULL const void *val); +RZ_API RZ_BORROW RzListIter *rz_list_find(RZ_NONNULL const RzList *list, const void *val, RZ_NONNULL RzListComparator cmp, void *user); + +RZ_DEPRECATE RZ_API RZ_BORROW RzListIter *rz_list_get_next(RZ_NONNULL RzListIter *iter); + +#ifdef __cplusplus +} +#endif + +#endif +#endif diff --git a/dest/include/librz/rz_magic.h b/dest/include/librz/rz_magic.h new file mode 100644 index 00000000000..845cdd6aab6 --- /dev/null +++ b/dest/include/librz/rz_magic.h @@ -0,0 +1,417 @@ +// SPDX-FileCopyrightText: 2011-2014 pancake +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_MAGIC_H +#define RZ_MAGIC_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_magic); + +#ifndef MAGICFILE +#define MAGICFILE "/etc/magic" +#endif + +#ifdef RZ_API + +#ifdef __EMX__ +#define PATHSEP ';' +#else +#define PATHSEP ':' +#endif + +/* limits */ +#ifndef HOWMANY +#define HOWMANY (256 * 1024) /* how much of the file to look at */ +#endif +#define MAXDESC 64 +#define MAXMAGIS 8192 /* max entries in any one magic file or directory */ +#define MAXstring 32 /* max leng of "string" types */ + +/* define this outside to fix build for g++ */ +union VALUETYPE { + ut8 b; + ut16 h; + ut32 l; + ut64 q; + ut8 hs[2]; /* 2 bytes of a fixed-endian "short" */ + ut8 hl[4]; /* 4 bytes of a fixed-endian "long" */ + ut8 hq[8]; /* 8 bytes of a fixed-endian "quad" */ + char s[MAXstring]; /* the search string or regex pattern */ + float f; + double d; +}; /* either number or string */ + +/** + * \brief Size of the buffer the rz_magic module checks for magics. + */ +#define RZ_MAGIC_BUF_SIZE (HOWMANY * (1 + sizeof(union VALUETYPE))) + +/* constants */ +#define MAGICNO 0xF11E041C +#define VERSIONNO 5 +#define FILE_MAGICSIZE (32 * 6) + +#define FILE_LOAD 0 +#define FILE_CHECK 1 +#define FILE_COMPILE 2 + +struct rz_magic { + /* Word 1 */ + ut16 cont_level; /* level of ">" */ + ut8 flag; + +#define INDIR 0x01 /* if '(...)' appears */ +#define OFFADD 0x02 /* if '>&' or '>...(&' appears */ +#define INDIROFFADD 0x04 /* if '>&(' appears */ +#define UNSIGNED 0x08 /* comparison is unsigned */ +#define NOSPACE 0x10 /* suppress space character before output */ +#define BINTEST 0x20 /* test is for a binary type (set only for top-level tests) */ +#define TEXTTEST 0 /* for passing to file_softmagic */ + + ut8 dummy1; + + /* Word 2 */ + ut8 reln; /* relation (0=eq, '>'=gt, etc) */ + ut8 vallen; /* length of string value, if any */ + ut8 type; /* comparison type (FILE_*) */ + ut8 in_type; /* type of indirection */ +#define FILE_INVALID 0 +#define FILE_BYTE 1 +#define FILE_SHORT 2 +#define FILE_DEFAULT 3 +#define FILE_LONG 4 +#define FILE_STRING 5 +#define FILE_DATE 6 +#define FILE_BESHORT 7 +#define FILE_BELONG 8 +#define FILE_BEDATE 9 +#define FILE_LESHORT 10 +#define FILE_LELONG 11 +#define FILE_LEDATE 12 +#define FILE_PSTRING 13 +#define FILE_LDATE 14 +#define FILE_BELDATE 15 +#define FILE_LELDATE 16 +#define FILE_REGEX 17 +#define FILE_BESTRING16 18 +#define FILE_LESTRING16 19 +#define FILE_SEARCH 20 +#define FILE_MEDATE 21 +#define FILE_MELDATE 22 +#define FILE_MELONG 23 +#define FILE_QUAD 24 +#define FILE_LEQUAD 25 +#define FILE_BEQUAD 26 +#define FILE_QDATE 27 +#define FILE_LEQDATE 28 +#define FILE_BEQDATE 29 +#define FILE_QLDATE 30 +#define FILE_LEQLDATE 31 +#define FILE_BEQLDATE 32 +#define FILE_FLOAT 33 +#define FILE_BEFLOAT 34 +#define FILE_LEFLOAT 35 +#define FILE_DOUBLE 36 +#define FILE_BEDOUBLE 37 +#define FILE_LEDOUBLE 38 +#define FILE_NAMES_SIZE 39 /* size of array to contain all names */ + +#define MAGIC_IS_STRING(t) \ + ((t) == FILE_STRING || \ + (t) == FILE_PSTRING || \ + (t) == FILE_BESTRING16 || \ + (t) == FILE_LESTRING16 || \ + (t) == FILE_REGEX || \ + (t) == FILE_SEARCH || \ + (t) == FILE_DEFAULT) + +#define FILE_FMT_NONE 0 +#define FILE_FMT_NUM 1 /* "cduxXi" */ +#define FILE_FMT_STR 2 /* "s" */ +#define FILE_FMT_QUAD 3 /* "ll" */ +#define FILE_FMT_FLOAT 4 /* "eEfFgG" */ +#define FILE_FMT_DOUBLE 5 /* "eEfFgG" */ + + /* Word 3 */ + ut8 in_op; /* operator for indirection */ + ut8 mask_op; /* operator for mask */ + ut8 cond; /* conditional type */ + ut8 dummy2; + +#define FILE_OPS "&|^+-*/%" +#define FILE_OPAND 0 +#define FILE_OPOR 1 +#define FILE_OPXOR 2 +#define FILE_OPADD 3 +#define FILE_OPMINUS 4 +#define FILE_OPMULTIPLY 5 +#define FILE_OPDIVIDE 6 +#define FILE_OPMODULO 7 +#define FILE_OPS_MASK 0x07 /* mask for above ops */ +#define FILE_UNUSED_1 0x08 +#define FILE_UNUSED_2 0x10 +#define FILE_UNUSED_3 0x20 +#define FILE_OPINVERSE 0x40 +#define FILE_OPINDIRECT 0x80 + +#define COND_NONE 0 +#define COND_IF 1 +#define COND_ELIF 2 +#define COND_ELSE 3 + + /* Word 4 */ + ut32 offset; /* offset to magic number */ + /* Word 5 */ + ut32 in_offset; /* offset from indirection */ + /* Word 6 */ + ut32 lineno; /* line number in magic file */ + /* Word 7,8 */ + union { + ut64 _mask; /* for use with numeric and date types */ + struct { + ut32 _count; /* repeat/line count */ + ut32 _flags; /* modifier flags */ + } _s; /* for use with string types */ + } _u; + +#define num_mask _u._mask +#define str_range _u._s._count +#define str_flags _u._s._flags + + /* Words 9-16 */ + union VALUETYPE value; + /* Words 17..31 */ + char desc[MAXDESC]; /* description */ + /* Words 32..47 */ + char mimetype[MAXDESC]; /* MIME type */ +}; + +#define BIT(A) (1 << (A)) +#define STRING_COMPACT_BLANK BIT(0) +#define STRING_COMPACT_OPTIONAL_BLANK BIT(1) +#define STRING_IGNORE_LOWERCASE BIT(2) +#define STRING_IGNORE_UPPERCASE BIT(3) +#define REGEX_OFFSET_START BIT(4) +#define CHAR_COMPACT_BLANK 'B' +#define CHAR_COMPACT_OPTIONAL_BLANK 'b' +#define CHAR_IGNORE_LOWERCASE 'c' +#define CHAR_IGNORE_UPPERCASE 'C' +#define CHAR_REGEX_OFFSET_START 's' +#define STRING_IGNORE_CASE (STRING_IGNORE_LOWERCASE | STRING_IGNORE_UPPERCASE) +#define STRING_DEFAULT_RANGE 100 + +/* list of magic entries */ +struct mlist { + struct rz_magic *magic; /* array of magic entries */ + ut32 nmagic; /* number of entries in array */ + int mapped; /* allocation type: 0 => apprentice_file + * 1 => apprentice_map + malloc + * 2 => apprentice_map + mmap */ + struct mlist *next, *prev; +}; + +#define MAGIC_STRING_SIZE 31 +#define MAGIC_STRENGTH_MULTIPLIER 10 + +#define MAGIC_TEST_TEXT 0x1 +#define MAGIC_TEST_MIME 0x2 + +/* + * to select alternate encoding format + */ +#define VIS_OCTAL 0x01 /* use octal \ddd format */ +#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropriate */ + +/* + * to alter set of characters encoded (default is to encode all + * non-graphic except space, tab, and newline). + */ +#define VIS_SP 0x04 /* also encode space */ +#define VIS_TAB 0x08 /* also encode tab */ +#define VIS_NL 0x10 /* also encode newline */ +#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL) +#define VIS_SAFE 0x20 /* only encode "unsafe" characters */ +#define VIS_DQ 0x200 /* backslash-escape double quotes */ +#define VIS_ALL 0x400 /* encode all characters */ + +/* + * other + */ +#define VIS_NOSLASH 0x40 /* inhibit printing '\' */ +#define VIS_GLOB 0x100 /* encode glob(3) magics and '#' */ + +enum magic_type { + MAGIC_TYPE_NONE = 0, + MAGIC_TYPE_BYTE, + MAGIC_TYPE_SHORT, + MAGIC_TYPE_LONG, + MAGIC_TYPE_QUAD, + MAGIC_TYPE_UBYTE, + MAGIC_TYPE_USHORT, + MAGIC_TYPE_ULONG, + MAGIC_TYPE_UQUAD, + MAGIC_TYPE_FLOAT, + MAGIC_TYPE_DOUBLE, + MAGIC_TYPE_STRING, + MAGIC_TYPE_PSTRING, + MAGIC_TYPE_DATE, + MAGIC_TYPE_QDATE, + MAGIC_TYPE_LDATE, + MAGIC_TYPE_QLDATE, + MAGIC_TYPE_UDATE, + MAGIC_TYPE_UQDATE, + MAGIC_TYPE_ULDATE, + MAGIC_TYPE_UQLDATE, + MAGIC_TYPE_BESHORT, + MAGIC_TYPE_BELONG, + MAGIC_TYPE_BEQUAD, + MAGIC_TYPE_UBESHORT, + MAGIC_TYPE_UBELONG, + MAGIC_TYPE_UBEQUAD, + MAGIC_TYPE_BEFLOAT, + MAGIC_TYPE_BEDOUBLE, + MAGIC_TYPE_BEDATE, + MAGIC_TYPE_BEQDATE, + MAGIC_TYPE_BELDATE, + MAGIC_TYPE_BEQLDATE, + MAGIC_TYPE_UBEDATE, + MAGIC_TYPE_UBEQDATE, + MAGIC_TYPE_UBELDATE, + MAGIC_TYPE_UBEQLDATE, + MAGIC_TYPE_BESTRING16, + MAGIC_TYPE_LESHORT, + MAGIC_TYPE_LELONG, + MAGIC_TYPE_LEQUAD, + MAGIC_TYPE_ULESHORT, + MAGIC_TYPE_ULELONG, + MAGIC_TYPE_ULEQUAD, + MAGIC_TYPE_LEFLOAT, + MAGIC_TYPE_LEDOUBLE, + MAGIC_TYPE_LEDATE, + MAGIC_TYPE_LEQDATE, + MAGIC_TYPE_LELDATE, + MAGIC_TYPE_LEQLDATE, + MAGIC_TYPE_ULEDATE, + MAGIC_TYPE_ULEQDATE, + MAGIC_TYPE_ULELDATE, + MAGIC_TYPE_ULEQLDATE, + MAGIC_TYPE_LESTRING16, + MAGIC_TYPE_MELONG, + MAGIC_TYPE_MEDATE, + MAGIC_TYPE_MELDATE, + MAGIC_TYPE_REGEX, + MAGIC_TYPE_SEARCH, + MAGIC_TYPE_DEFAULT, + MAGIC_TYPE_CLEAR, + MAGIC_TYPE_NAME, + MAGIC_TYPE_USE, +}; + +typedef struct rz_magic_line_t RzMagicLine; +typedef struct rz_magic_t RzMagic; + +/** + * \brief Represents a single parsed rule from a magic file. + * + * This structure contains all metadata and matching criteria for a single magic + * rule, including its type, operators, matching strength, and any child rules. + */ +struct rz_magic_line_t { + RBNode rb; + RzMagic *root; + ut32 line; + ut32 strength; + RzMagicLine *parent; + + char strength_operator; + ut32 strength_value; + + int text; + + int64_t offset; + int offset_relative; + + char indirect_type; + int indirect_relative; + int64_t indirect_offset; + char indirect_operator; + int64_t indirect_operand; + + char *name; + + enum magic_type type; + char *type_string; + char type_operator; + int64_t type_operand; + + char test_operator; + int test_not; + char *test_string; + size_t test_string_size; + ut64 test_unsigned; + int64_t test_signed; + double test_double; + + int stringify; + char *result; + char *mimetype; + + RzList *children; +}; + +/** + * \brief Container for magic rules and related metadata. + * + * Holds the path to the magic file(s), RBTree indexes for rule storage and lookup, + * and precompiled regex patterns for various data types. + */ +struct rz_magic_t { + char *path; + + RBTree magic_tree; + RBTree magic_named_tree; + + int compiled; + RzRegex *format_short; + RzRegex *format_long; + RzRegex *format_quad; + RzRegex *format_float; + RzRegex *format_string; +}; + +/** + * \brief Represents the state of magic rules processing. + * + * This structure stores details about the data being analyzed. + * It is used during magic rules evaluation. + */ +typedef struct rz_magic_state_t { + char out[4096]; + const char *mimetype; + int text; + const char *base; + size_t size; + size_t offset; + int matched; + size_t start; + int reverse; +} RzMagicState; + +RZ_API RZ_OWN RzMagic *rz_magic_new(); +RZ_API void rz_magic_free(RZ_NULLABLE RZ_OWN RzMagic *); +RZ_API RZ_OWN char *rz_magic_buffer(RZ_NONNULL const RzMagic *, RZ_NONNULL const ut8 *, size_t); +RZ_API bool rz_magic_load(RZ_NONNULL RZ_BORROW RzMagic *, RZ_NONNULL const char *); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_main.h b/dest/include/librz/rz_main.h new file mode 100644 index 00000000000..35cbb1cd47f --- /dev/null +++ b/dest/include/librz/rz_main.h @@ -0,0 +1,48 @@ +// SPDX-FileCopyrightText: 2022 deroad +// SPDX-FileCopyrightText: 2008-2020 pancake +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_MAIN_H +#define RZ_MAIN_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_main); + +#if __WINDOWS__ +#define MAIN_NAME wmain +#define ARGV_TYPE wchar_t +#define ARGV_TYPE_TO_UTF8(argc, argv) rz_sys_utf8_argv_new(argc, argv) +#define FREE_UTF8_ARGV(argc, utf8_argv) rz_sys_utf8_argv_free(argc, utf8_argv) +#else +#define MAIN_NAME main +#define ARGV_TYPE char +#define ARGV_TYPE_TO_UTF8(argc, argv) (char **)argv +#define FREE_UTF8_ARGV(argc, utf8_argv) +#endif + +typedef int (*RzMainCallback)(int argc, const char **argv); + +RZ_API RzMainCallback rz_main_find(const char *name); +RZ_API int rz_main_version_print(RZ_BORROW RZ_NONNULL RzPath *sys_path, const char *program); +RZ_API int rz_main_rz_ax(int argc, const char **argv); +RZ_API int rz_main_rz_run(int argc, const char **argv); +RZ_API int rz_main_rz_hash(int argc, const char **argv); +RZ_API int rz_main_rz_bin(int argc, const char **argv); +RZ_API int rz_main_rizin(int argc, const char **argv); +RZ_API int rz_main_rz_asm(int argc, const char **argv); +RZ_API int rz_main_rz_find(int argc, const char **argv); +RZ_API int rz_main_rz_diff(int argc, const char **argv); +RZ_API int rz_main_rz_gg(int argc, const char **argv); +RZ_API int rz_main_rz_sign(int argc, const char **argv); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_mark.h b/dest/include/librz/rz_mark.h new file mode 100644 index 00000000000..65a2d03e26d --- /dev/null +++ b/dest/include/librz/rz_mark.h @@ -0,0 +1,86 @@ +#ifndef RZ_MARK_H +#define RZ_MARK_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// NOTE: Marks are currently used for the Hex Widget only +// but the API is kept generic in case of future reuse + +RZ_LIB_VERSION_HEADER(rz_mark); + +#define RZ_MARK_NAME_SIZE 512 + +typedef struct rz_mark_item_t { + ut64 from; ///< inclusive starting address of mark + ut64 to; ///< inclusive ending address of mark + char *name; ///< unique name for each mark, escaped to avoid issues with rizin shell + char *realname; ///< real name, without any escaping + char *comment; ///< item comment + char *color; ///< item color +} RzMarkItem; + +typedef struct rz_marks_at_offset_t { + ut64 off; + RzList /**/ *marks; +} RzMarksAtOffset; + +typedef struct rz_mark_t { + HtSP *ht_name; ///< name -> RzBookmarkItem* + RzList /**/ *items; ///< All bookmarks + RzSkipList *by_off; ///< offset -> RzBookmarksAtOffset* +} RzMark; + +typedef bool (*RzMarkItemCb)(RzMarkItem *item, void *user); + +typedef enum { + RZ_MARK_MATCH_CONTAINS, + RZ_MARK_MATCH_START, + RZ_MARK_MATCH_END +} RzMarkMatchMode; + +#ifdef RZ_API +RZ_API RZ_OWN RzMark *rz_mark_new(void); +RZ_API void rz_mark_free(RZ_OWN RzMark *b); +RZ_API RZ_OWN RzMarkItem *rz_mark_set(RZ_NONNULL RzMark *b, RZ_NONNULL const char *name, ut64 from, ut64 to); +RZ_API RZ_BORROW RzMarkItem *rz_mark_get(RZ_NONNULL RzMark *b, RZ_NONNULL const char *name); +RZ_API RZ_BORROW RzMarkItem *rz_mark_get_start(RZ_NONNULL RzMark *b, ut64 off); +RZ_API RZ_BORROW RzMarkItem *rz_mark_get_end(RZ_NONNULL RzMark *b, ut64 off); +RZ_API RZ_BORROW RzMarkItem *rz_mark_get_at(RZ_NONNULL RzMark *b, ut64 off); +RZ_API RZ_OWN RzList /**/ *rz_mark_get_all_off(RZ_NONNULL RzMark *b, ut64 off); +RZ_API RZ_OWN RzList /**/ *rz_mark_all_list(RZ_NONNULL RzMark *b); +RZ_API RZ_BORROW const RzList /**/ *rz_mark_get_list(RZ_NONNULL RzMark *b, ut64 off); +RZ_API void rz_mark_item_free(RZ_OWN RzMarkItem *item); +RZ_API void rz_mark_item_set_comment(RZ_NONNULL RzMarkItem *item, RZ_NULLABLE const char *comment); +RZ_API void rz_mark_item_set_realname(RZ_NONNULL RzMarkItem *item, RZ_NONNULL const char *realname); +RZ_API RZ_NULLABLE const char *rz_mark_item_set_color(RZ_NONNULL RzMarkItem *item, RZ_NONNULL const char *color); +RZ_API int rz_mark_rename(RZ_NONNULL RzMark *b, RZ_NONNULL RzMarkItem *item, RZ_NONNULL const char *name); +RZ_API bool rz_mark_starts_or_ends(RZ_NONNULL RzMark *b, ut64 from, ut64 to); +RZ_API bool rz_mark_unset(RZ_NONNULL RzMark *b, RZ_NONNULL RzMarkItem *item); +RZ_API bool rz_mark_unset_all_off(RZ_NONNULL RzMark *b, ut64 off); +RZ_API void rz_mark_unset_all(RZ_NONNULL RzMark *b); +RZ_API int rz_mark_unset_glob(RZ_NONNULL RzMark *b, RZ_NONNULL const char *glob); +RZ_API int rz_mark_count(RZ_NONNULL RzMark *b, RZ_NONNULL const char *glob); +RZ_API void rz_mark_foreach(RZ_NONNULL RzMark *b, RZ_NONNULL RzMarkItemCb cb, RZ_NULLABLE void *user); +RZ_API void rz_mark_foreach_regex(RZ_NONNULL RzMark *b, RZ_NONNULL const char *glob, RZ_NONNULL RzMarkItemCb cb, RZ_NULLABLE void *user); + +/* serialize */ + +RZ_API void rz_serialize_mark_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzMark *bm); +RZ_API bool rz_serialize_mark_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzMark *bm, RZ_NULLABLE RzSerializeResultInfo *res); + +#endif // RZ_API + +#ifdef __cplusplus +} +#endif + +#endif // RZ_MARK_H diff --git a/dest/include/librz/rz_parse.h b/dest/include/librz/rz_parse.h new file mode 100644 index 00000000000..34d4b9c0e01 --- /dev/null +++ b/dest/include/librz/rz_parse.h @@ -0,0 +1,75 @@ +// SPDX-FileCopyrightText: 2009-2018 pancake +// SPDX-FileCopyrightText: 2009-2018 nibble +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_PARSE_H +#define RZ_PARSE_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rz_parse_t { + void *user; + RzSpace *flagspace; + RzSpace *notin_flagspace; + bool pseudo; + bool subreg; // replace registers with their respective alias/role name (rdi=A0, ...) + bool subrel; // replace rip relative expressions in instruction + bool subtail; // replace any immediate relative to current address with .. prefix syntax + bool localvar_only; // if true use only the local variable name (e.g. [local_10h] instead of [ebp + local10h]) + ut64 subrel_addr; + int maxflagnamelen; + int minval; + char *retleave_asm; + struct rz_parse_plugin_t *cur; + // RzAnalysis *analysis; // weak analysis ref XXX do not use. use analb.anal + RzList /**/ *parsers; + RZ_OWN char *(*var_expr_for_reg_access)(RzAnalysisFunction *fcn, ut64 addr, const char *reg, st64 reg_addend); + RzAnalysisBind analb; + RzFlagGetAtAddr flag_get; // XXX + RzAnalysisLabelAt label_get; +} RzParse; + +typedef struct rz_parse_plugin_t { + char *name; + char *desc; + bool (*init)(RzParse *p, void *user); + int (*fini)(RzParse *p, void *user); + bool (*parse)(RzParse *p, const char *data, RzStrBuf *sb); + bool (*assemble)(RzParse *p, char *data, char *str); + int (*filter)(RzParse *p, ut64 addr, RzFlag *f, char *data, char *str, int len, bool big_endian); + bool (*subvar)(RzParse *p, RzAnalysisFunction *f, RzAnalysisOp *op, char *data, char *str, int len); + int (*replace)(int argc, const char *argv[], char *newstr); +} RzParsePlugin; + +#ifdef RZ_API + +/* lifecycle */ +RZ_API RzParse *rz_parse_new(void); +RZ_API void rz_parse_free(RzParse *p); + +/* plugins */ +RZ_API void rz_parse_set_user_ptr(RzParse *p, void *user); +RZ_API bool rz_parse_plugin_add(RzParse *p, RZ_NONNULL RzParsePlugin *plugin); +RZ_API bool rz_parse_plugin_del(RzParse *p, RZ_NONNULL RzParsePlugin *plugin); +RZ_API bool rz_parse_use(RzParse *p, const char *name); + +/* action */ +RZ_API char *rz_parse_pseudocode(RzParse *p, const char *data); +RZ_API bool rz_parse_assemble(RzParse *p, char *data, char *str); // XXX deprecate, unused and probably useless, related to write-hack +RZ_API bool rz_parse_filter(RzParse *p, ut64 addr, RzFlag *f, RzAnalysisHint *hint, char *data, char *str, int len, bool big_endian); +RZ_API bool rz_parse_subvar(RzParse *p, RZ_NULLABLE RzAnalysisFunction *f, RZ_NONNULL RzAnalysisOp *op, RZ_NONNULL RZ_IN char *data, RZ_BORROW RZ_NONNULL RZ_OUT char *str, int len); +RZ_API char *rz_parse_immtrim(char *opstr); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_pdb.h b/dest/include/librz/rz_pdb.h new file mode 100644 index 00000000000..2f2550fda6d --- /dev/null +++ b/dest/include/librz/rz_pdb.h @@ -0,0 +1,398 @@ +// SPDX-FileCopyrightText: 2021 Basstorm +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_PDB_H +#define RZ_PDB_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CAB_SIGNATURE "MSCF" +#define PDB_SIGNATURE "Microsoft C/C++ MSF 7.00\r\n\x1a\x44\x53\x00\x00\x00" +#define PDB_SIGNATURE_LEN 32 + +#define GET_BF(value, start, len) (((value) >> (start)) & ((1 << len) - 1)) + +// DBI +typedef struct dbi_stream_header_t { + st32 version_signature; + ut32 version_header; + ut32 age; + ut16 global_stream_index; + ut16 build_number; + ut16 public_stream_index; + ut16 pdb_dll_version; + ut16 sym_record_stream; + ut16 pdb_dll_rbld; + ut32 mod_info_size; + ut32 section_contribution_size; + ut32 section_map_size; + ut32 source_info_size; + ut32 type_server_map_size; + ut32 mfc_type_server_index; + ut32 optional_dbg_header_size; + ut32 ec_substream_size; + ut16 flags; + ut16 machine; + ut32 padding; +} RzPdbRzPdbDbiStreamHdr; + +typedef struct { + st16 sn_fpo; + st16 sn_exception; + st16 sn_fixup; + st16 sn_omap_to_src; + st16 sn_omap_from_src; + st16 sn_section_hdr; + st16 sn_token_rid_map; + st16 sn_xdata; + st16 sn_pdata; + st16 sn_new_fpo; + st16 sn_section_hdr_orig; +} RzPdbRzPdbDbiStreamDbgHeader; + +typedef struct dbi_stream_t { + RzPdbRzPdbDbiStreamHdr hdr; + ut64 hdr_size; + RzPVector /**/ *modules; + RzPdbRzPdbDbiStreamDbgHeader dbg_hdr; +} RzPdbDbiStream; + +// GDATA +typedef struct { + RzPVector /**/ *global_symbols; +} RzPdbGDataStream; + +// OMAP +typedef struct +{ + RzList /**/ *entries; + ut64 *froms; +} RzPdbOmapStream; + +// PE Stream +typedef struct { + RzList /**/ *sections_hdrs; +} RzPdbPeStream; + +// TPI +typedef enum { + NEAR_C = 0x00000000, + FAR_C = 0x00000001, + NEAR_PASCAL = 0x00000002, + FAR_PASCAL = 0x00000003, + NEAR_FAST = 0x00000004, + FAR_FAST = 0x00000005, + SKIPPED = 0x00000006, + NEAR_STD = 0x00000007, + FAR_STD = 0x00000008, + NEAR_SYS = 0x00000009, + FAR_SYS = 0x0000000A, + THISCALL = 0x0000000B, + MIPSCALL = 0x0000000C, + GENERIC = 0x0000000D, + ALPHACALL = 0x0000000E, + PPCCALL = 0x0000000F, + SHCALL = 0x00000010, + ARMCALL = 0x00000011, + AM33CALL = 0x00000012, + TRICALL = 0x00000013, + SH5CALL = 0x00000014, + M32RCALL = 0x00000015, + CLRCALL = 0x00000016, + INLINECALL = 0x00000017, + NEAR_VEC = 0X00000018, + RESERVED = 0x00000019, + MAX_CV_CALL +} RzPdbTpiCallingConvention; + +typedef enum { + V40 = 19950410, + V41 = 19951122, + V50 = 19961031, + V70 = 19990903, + V80 = 20040203, +} RzPdbTpiStreamVersion; + +typedef struct tpi_stream_header_t { + RzPdbTpiStreamVersion Version; + ut32 HeaderSize; + ut32 TypeIndexBegin; + ut32 TypeIndexEnd; + ut32 TypeRecordBytes; + + ut16 HashStreamIndex; + ut16 HashAuxStreamIndex; + ut32 HashKeySize; + ut32 NumHashBuckets; + + st32 HashValueBufferOffset; + ut32 HashValueBufferLength; + + st32 IndexOffsetBufferOffset; + ut32 IndexOffsetBufferLength; + + st32 HashAdjBufferOffset; + ut32 HashAdjBufferLength; +} RzPdbTpiStreamHeader; + +typedef enum { + TpiKind_INVALID, + TpiKind_FILEDLIST, + TpiKind_ENUM, + TpiKind_ENUMERATE, + TpiKind_CLASS, + TpiKind_UNION, + TpiKind_BITFIELD, + TpiKind_POINTER, + TpiKind_ARRAY, + TpiKind_MODIFIER, + TpiKind_ARGLIST, + TpiKind_MFUNCTION, + TpiKind_METHODLIST, + TpiKind_PROCEDURE, + TpiKind_VTSHAPE, + TpiKind_VFTABLE, + TpiKind_LABEL, + TpiKind_NESTTYPE, + TpiKind_MEMBER, + TpiKind_METHOD, + TpiKind_ONEMETHOD, + TpiKind_BCLASS, + TpiKind_VFUNCTAB, + TpiKind_STMEMBER, + TpiKind_VBCLASS, + TpiKind_INDEX, + TpiKind_SIMPLE_TYPE, +} RzPDBTpiKind; + +typedef struct tpi_types { + RBNode rb; + ut32 index; + ut16 leaf; + ut16 length; + RzPDBTpiKind kind; + void *data; + bool parsed; +} RzPdbTpiType; + +typedef struct tpi_stream_t { + RzPdbTpiStreamHeader header; + RBTree types; + ut64 type_index_base; + RzList /**/ *print_type; +} RzPdbTpiStream; + +// PDB +typedef enum pdb_stream_index_t { + PDB_STREAM_ROOT = 0, // PDB_ROOT_DIRECTORY + PDB_STREAM_PDB, // PDB STREAM INFO + PDB_STREAM_TPI, // TYPE INFO + PDB_STREAM_DBI, // DEBUG INFO + + PDB_STREAM_GSYM, + PDB_STREAM_SECT_HDR, + PDB_STREAM_SECT__HDR_ORIG, + PDB_STREAM_OMAP_TO_SRC, + PDB_STREAM_OMAP_FROM_SRC, + PDB_STREAM_FPO, + PDB_STREAM_FPO_NEW, + PDB_STREAM_XDATA, + PDB_STREAM_PDATA, + PDB_STREAM_TOKEN_RID_MAP, + PDB_STREAM_MAX +} RzRzPdbStreamIndex; + +enum pdb_stream_version { + VC2 = 19941610, + VC4 = 19950623, + VC41 = 19950814, + VC50 = 19960307, + VC98 = 19970604, + VC70Dep = 19990604, + VC70 = 20000404, + VC80 = 20030901, + VC110 = 20091201, + VC140 = 20140508, +}; + +/** + * Like GUID in windows.h/guiddef.h + */ +typedef struct { + ut32 data1; + ut16 data2; + ut16 data3; + ut8 data4[8]; +} RzPdbGuid; + +typedef struct { + ut32 version; + ut32 signature; + ut32 age; + RzPdbGuid unique_id; +} RzRzPdbStreamHeader; + +typedef struct { + RzRzPdbStreamHeader hdr; + /* Todo: parse named table */ +} RzPdbStream; + +/** + * \brief MSF file format header https://llvm.org/docs/PDB/MsfFile.html#the-superblock + */ +typedef struct { + char file_magic[PDB_SIGNATURE_LEN]; ///< Must be equal to "Microsoft C / C++ MSF 7.00\\r\\n" followed by the bytes 1A 44 53 00 00 00. + ut32 block_size; ///< The block size of the internal file system. + ut32 free_block_map_block; ///< The index of a block within the file, the data within that block is not used. + ut32 num_blocks; ///< The total number of blocks in the file + ut32 num_directory_bytes; ///< The size of the stream directory, in bytes. + ut32 unknown; + ut32 block_map_addr; ///< The index of a block within the MSF file. +} RzPdbMsfSuperBlock; + +typedef struct { + ut32 stream_idx; + ut32 stream_size; + ut32 blocks_num; + RzBuffer *stream_data; +} RzPdbMsfStream; + +typedef struct { + ut32 NumStreams; + ut32 *StreamSizes; + RzBuffer *sd; +} RzPdbMsfStreamDirectory; + +typedef struct { + RzBuffer *stream; + ut32 symbols_size; + ut16 stream_index; + RzPVector /**/ *symbols; +} PDBModuleInfo; + +typedef struct rz_pdb_t { + RzBuffer *buf; // mmap of file + RzPdbMsfSuperBlock *super_block; + RzPdbMsfStreamDirectory *msd; + RzPVector /**/ *streams; + RzPdbStream *s_pdb; + RzPdbDbiStream *s_dbi; + RzPdbTpiStream *s_tpi; + RzPdbGDataStream *s_gdata; + RzPdbOmapStream *s_omap; + RzPdbPeStream *s_pe; + RzPVector /**/ *module_infos; + size_t RtlpHpHeapGlobalsOffset; ///< Related to windows heap + size_t RtlpLFHKeyOffset; ///< Related to windows heap +} RzPdb; + +typedef struct { + ut32 offset; + ut16 section_index; +} PDBSectionOffset; + +typedef ut16 PDBSymbolKind; +typedef ut32 PDBTypeIndex; +typedef ut32 PDBSymbolIndex; + +typedef struct { + bool global : 1; + bool managed : 1; + PDBTypeIndex type_index; + PDBSectionOffset offset; + char *name; +} PDBSData; + +RZ_IPI bool PDBSData_parse(RzBuffer *b, PDBSymbolKind kind, PDBSData *sdata); + +typedef struct { + bool code : 1; + bool function : 1; + bool managed : 1; + bool msil : 1; + PDBSectionOffset offset; + char *name; +} PDBSPublic; + +RZ_IPI bool PDBSPublic_parse(RzBuffer *b, PDBSymbolKind kind, PDBSPublic *s); + +typedef struct { + PDBSymbolIndex index; + PDBSymbolKind raw_kind; + ut16 length; + enum { + PDB_ScopeEnd, /// End of a scope, such as a procedure. + PDB_ObjName, /// Name of the object file of this module. + PDB_RegisterVariable, /// A Register variable. + PDB_Constant, /// A constant value. + PDB_UserDefinedType, /// A user defined type. + PDB_MultiRegisterVariable, /// A Register variable spanning multiple registers. + PDB_Data, /// Static data, such as a global variable. + PDB_Public, /// A public symbol with a mangled name. + PDB_Procedure, /// A procedure, such as a function or method. + PDB_ThreadStorage, /// A thread local variable. + PDB_CompileFlags, /// Flags used to compile a module. + PDB_UsingNamespace, /// A using namespace directive. + PDB_ProcedureReference, /// Reference to a [`ProcedureSymbol`]. + PDB_DataReference, /// Reference to an imported variable. + PDB_AnnotationReference, /// Reference to an annotation. + PDB_Trampoline, /// Trampoline thunk. + PDB_Export, /// An exported symbol. + PDB_Local, /// A local symbol in optimized code. + PDB_BuildInfo, /// Reference to build information. + PDB_InlineSite, /// The callsite of an inlined function. + PDB_InlineSiteEnd, /// End of an inline callsite. + PDB_ProcedureEnd, /// End of a procedure. + PDB_Label, /// A label. + PDB_Block, /// A block. + PDB_RegisterRelative, /// Data allocated relative to a register. + PDB_Thunk, /// A thunk. + PDB_SeparatedCode, /// A block of separated code. + PDB_DefRange, /// A live range of a variable. + PDB_DefRangeSubField, /// A live range of a sub field of a variable. + PDB_DefRangeRegister, /// A live range of a register variable. + PDB_DefRangeFramePointerRelative, /// A live range of a frame pointer-relative variable. + PDB_DefRangeFramePointerRelativeFullScope, /// A frame-pointer variable which is valid in the full scope of the function. + PDB_DefRangeSubFieldRegister, /// A live range of a sub field of a register variable. + PDB_DefRangeRegisterRelative, /// A live range of a variable related to a register. + PDB_BasePointerRelative, /// A base pointer-relative variable. + PDB_FrameProcedure, /// Extra frame and proc information. + PDB_CallSiteInfo, /// Indirect call site information. + } kind; + void *data; +} PDBSymbol; + +// PDB +RZ_API bool rz_bin_pdb_extract_in_folder(RZ_NONNULL const char *file_cab, RZ_NONNULL const char *output_dir); +RZ_API RZ_OWN RzPdb *rz_bin_pdb_parse_from_file(RZ_NONNULL const char *filename); +RZ_API RZ_OWN RzPdb *rz_bin_pdb_parse_from_buf(RZ_NONNULL const RzBuffer *buf); +RZ_API void rz_bin_pdb_free(RzPdb *pdb); +RZ_API bool rz_pdb_all_symbols_foreach( + RZ_BORROW RZ_NONNULL RzPdb *pdb, + RZ_BORROW RZ_NONNULL bool (*f)(RzPdb *, const PDBSymbol *, void *), + RZ_BORROW RZ_NULLABLE void *u); + +// TPI +RZ_API RZ_BORROW RzPdbTpiType *rz_bin_pdb_get_type_by_index(RZ_NONNULL RzPdbTpiStream *stream, ut32 index); +RZ_API RZ_OWN char *rz_bin_pdb_calling_convention_as_string(RZ_NONNULL RzPdbTpiCallingConvention idx); +RZ_API bool rz_bin_pdb_type_is_fwdref(RZ_NONNULL RzPdbTpiType *t); +RZ_API RZ_BORROW RzPVector /**/ *rz_bin_pdb_get_type_members(RZ_NONNULL RzPdbTpiStream *stream, RzPdbTpiType *t); +RZ_API RZ_BORROW char *rz_bin_pdb_get_type_name(RZ_NONNULL RzPdbTpiType *type); +RZ_API ut64 rz_bin_pdb_get_type_val(RZ_NONNULL RzPdbTpiType *type); + +// OMAP +RZ_API ut64 rz_bin_pdb_to_rva( + RZ_BORROW RZ_NONNULL const RzPdb *pdb, + RZ_BORROW RZ_NONNULL const PDBSectionOffset *section_offset); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_platform.h b/dest/include/librz/rz_platform.h new file mode 100644 index 00000000000..9e2b6835aec --- /dev/null +++ b/dest/include/librz/rz_platform.h @@ -0,0 +1,69 @@ +// SPDX-FileCopyrightText: 2021-2022 RizinOrg +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_PLATFORM_H +#define RZ_PLATFORM_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rz_platform_profile_t { + ut64 rom_size; + ut64 ram_size; + ut64 rom_address; + ut64 eeprom_size; + ut64 io_size; + ut64 sram_start; + ut64 sram_size; + ut64 pc; + ut64 page_size; + ut64 interrupt_vector_size; + HtUP /**/ *registers_mmio; + HtUP /**/ *registers_extended; +} RzPlatformProfile; + +typedef struct rz_platform_target_t { + char *cpu; + char *arch; + RzPlatformProfile *profile; +} RzPlatformTarget; + +typedef struct rz_platform_item_t { + char *name; + char *comment; +} RzPlatformItem; + +typedef struct rz_platform_target_index_t { + HtUP /**/ *platforms; + char *path; ///< Path used to load the platforms, used to avoid reloading +} RzPlatformTargetIndex; + +RZ_API RZ_OWN RzPlatformProfile *rz_platform_profile_new(); +RZ_API RZ_OWN RzPlatformTarget *rz_platform_target_new(); +RZ_API void rz_platform_profile_free(RZ_NULLABLE RzPlatformProfile *profile); +RZ_API void rz_platform_target_free(RZ_NULLABLE RzPlatformTarget *target); +RZ_API bool rz_platform_profiles_init(RZ_NULLABLE RzPlatformTarget *c, RZ_NULLABLE const char *cpu, RZ_NULLABLE const char *arch, RZ_NULLABLE const char *cpus_dir); +RZ_API void rz_platform_profile_add_flag_every_io(RZ_NONNULL RzPlatformProfile *profile, RZ_NONNULL RzFlag *flags); +RZ_API bool rz_platform_load_profile_sdb(RZ_NONNULL RzPlatformTarget *t, RZ_NONNULL const char *path); +RZ_API RZ_BORROW const char *rz_platform_profile_resolve_mmio(RZ_NONNULL RzPlatformProfile *profile, ut64 address); +RZ_API RZ_BORROW const char *rz_platform_profile_resolve_extended_register(RZ_NONNULL RzPlatformProfile *profile, ut64 address); + +RZ_API RZ_OWN RzPlatformItem *rz_platform_item_new(RZ_NULLABLE const char *name); +RZ_API RZ_OWN RzPlatformTargetIndex *rz_platform_target_index_new(); +RZ_API void rz_platform_target_index_free(RzPlatformTargetIndex *target); +RZ_API void rz_platform_item_free(RzPlatformItem *item); +RZ_API bool rz_platform_target_index_load_sdb(RZ_NONNULL RzPlatformTargetIndex *t, RZ_NONNULL const char *path); +RZ_API bool rz_platform_target_index_init(RzPlatformTargetIndex *t, RZ_NONNULL const char *arch, RZ_NONNULL const char *cpu, + const char *platform, RZ_NONNULL const char *platforms_dir); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_PLATFORM_H */ diff --git a/dest/include/librz/rz_project.h b/dest/include/librz/rz_project.h new file mode 100644 index 00000000000..52b5a90ceb3 --- /dev/null +++ b/dest/include/librz/rz_project.h @@ -0,0 +1,75 @@ +// SPDX-FileCopyrightText: 2020-2021 Florian Märkl +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_PROJECT_H +#define RZ_PROJECT_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RZ_PROJECT_VERSION 21 + +typedef Sdb RzProject; + +typedef enum rz_project_err { + RZ_PROJECT_ERR_SUCCESS, + RZ_PROJECT_ERR_FILE, + RZ_PROJECT_ERR_INVALID_TYPE, + RZ_PROJECT_ERR_INVALID_VERSION, + RZ_PROJECT_ERR_NEWER_VERSION, + RZ_PROJECT_ERR_INVALID_CONTENTS, + RZ_PROJECT_ERR_MIGRATION_FAILED, + RZ_PROJECT_ERR_COMPRESSION_FAILED, + RZ_PROJECT_ERR_UNKNOWN +} RzProjectErr; + +RZ_API RZ_NONNULL const char *rz_project_err_message(RzProjectErr err); +RZ_API RzProjectErr rz_project_save(RzCore *core, RzProject *prj, const char *file); +RZ_API RzProjectErr rz_project_save_file(RzCore *core, const char *file, bool compress); +RZ_API RzProject *rz_project_load_file_raw(const char *file); +RZ_API void rz_project_free(RzProject *prj); + +/** + * @param load_bin_io whether to also load the underlying RIO and RBin state from the project. If false, the current state will be kept and the project loaded on top. + * @param file filename of the project that db comes from. This is only used to re-locate the loaded RIO descs, the project file itself is not touched by this function. + */ +RZ_API RzProjectErr rz_project_load(RzCore *core, RzProject *prj, bool load_bin_io, RZ_NULLABLE const char *file, RzSerializeResultInfo *res); + +/** + * @param load_bin_io whether to also load the underlying RIO and RBin state from the project. If false, the current state will be kept and the project loaded on top. + * @param file filename of the project to load from + */ +RZ_API RzProjectErr rz_project_load_file(RzCore *core, const char *file, bool load_bin_io, RzSerializeResultInfo *res); + +RZ_API bool rz_project_migrate_v1_v2(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v2_v3(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v3_v4(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v4_v5(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v5_v6(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v6_v7(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v7_v8(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v8_v9(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v9_v10(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v10_v11(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v11_v12(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v12_v13(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v13_v14(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v14_v15(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v15_v16(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v16_v17(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v17_v18(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v18_v19(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v19_v20(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate_v20_v21(RzProject *prj, RzSerializeResultInfo *res); +RZ_API bool rz_project_migrate(RzProject *prj, unsigned long version, RzSerializeResultInfo *res); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_reg.h b/dest/include/librz/rz_reg.h new file mode 100644 index 00000000000..13e55effaaf --- /dev/null +++ b/dest/include/librz/rz_reg.h @@ -0,0 +1,258 @@ +#ifndef RZ_REG_H +#define RZ_REG_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_reg); + +/* + * various CPUs have registers within various types/classes + * this enum aims to cover them all. + */ +typedef enum { + RZ_REG_TYPE_GPR, //< General purpose + RZ_REG_TYPE_DRX, + RZ_REG_TYPE_FPU, //< Floating point + RZ_REG_TYPE_MMX, + RZ_REG_TYPE_XMM, + RZ_REG_TYPE_YMM, + RZ_REG_TYPE_FLG, + RZ_REG_TYPE_SEG, + RZ_REG_TYPE_SYS, //< System + RZ_REG_TYPE_SEC, + RZ_REG_TYPE_VC, //< Vector + RZ_REG_TYPE_VCC, //< Vector control + RZ_REG_TYPE_CTR, //< Control + RZ_REG_TYPE_LAST, + RZ_REG_TYPE_ANY = -1 +} RzRegisterType; + +/* + * pretty much all CPUs share some common registers + * this enum aims to create an abstraction to ease cross-arch handling. + */ +typedef enum { + RZ_REG_NAME_PC, // program counter + RZ_REG_NAME_SP, // stack pointer + RZ_REG_NAME_SR, // status register + RZ_REG_NAME_BP, // base pointer + RZ_REG_NAME_LR, // link register + /* args */ + RZ_REG_NAME_A0, // arguments + RZ_REG_NAME_A1, + RZ_REG_NAME_A2, + RZ_REG_NAME_A3, + RZ_REG_NAME_A4, + RZ_REG_NAME_A5, + RZ_REG_NAME_A6, + RZ_REG_NAME_A7, + RZ_REG_NAME_A8, + RZ_REG_NAME_A9, + /* retval */ + RZ_REG_NAME_R0, // return registers + RZ_REG_NAME_R1, + RZ_REG_NAME_R2, + RZ_REG_NAME_R3, + /* flags */ + RZ_REG_NAME_ZF, + RZ_REG_NAME_SF, + RZ_REG_NAME_CF, + RZ_REG_NAME_OF, + /* syscall number (orig_eax,rax,r0,x0) */ + RZ_REG_NAME_SN, + RZ_REG_NAME_LAST, +} RzRegisterId; + +// TODO: use enum here? +#define RZ_REG_COND_EQ 0 +#define RZ_REG_COND_NE 1 +#define RZ_REG_COND_CF 2 +#define RZ_REG_COND_CARRY 2 +#define RZ_REG_COND_NEG 3 +#define RZ_REG_COND_NEGATIVE 3 +#define RZ_REG_COND_OF 4 +#define RZ_REG_COND_OVERFLOW 4 +// unsigned +#define RZ_REG_COND_HI 5 +#define RZ_REG_COND_HE 6 +#define RZ_REG_COND_LO 7 +#define RZ_REG_COND_LOE 8 +// signed +#define RZ_REG_COND_GE 9 +#define RZ_REG_COND_GT 10 +#define RZ_REG_COND_LT 11 +#define RZ_REG_COND_LE 12 +#define RZ_REG_COND_LAST 13 + +typedef struct { + RzRegisterId role; ///< Register role (PC, Argument etc.) + char *alias; ///< Alias of register. + char *reg_name; ///< Real register name of alias. +} RzRegProfileAlias; + +typedef struct { + RzRegisterType type; ///< Reg type. + RzRegisterType arena_type; ///< The arena the register belongs to (e.g. flags belong to gpr; xmm into fpu). + char *name; ///< Register name. + ut32 size; ///< Register size in bits. + ut32 packed; ///< Packet size of register in tes. + ut32 offset; ///< Offset into profile in bits. + char *comment; ///< Comment about register. + char *flags; ///< String describing the flags of the register. +} RzRegProfileDef; + +typedef struct { + RzList /**/ *alias; + RzList /**/ *defs; +} RzRegProfile; + +typedef struct rz_reg_item_t { + char *name; + RzRegisterType type; ///< Register type. + int size; ///< in bits> 8,16,32,64 ... 128/256 + int offset; ///< Offset into register profile in bits. + int packed_size; ///< 0 means no packed register, 1byte pack, 2b pack... + bool is_float; ///< Flag for float registers. + char *flags; + char *comment; ///< Comment to register. + int index; ///< Index in register profile. + int arena; ///< In which arena is this reg living. Usually equals type. +} RzRegItem; + +typedef struct rz_reg_arena_t { + ut8 *bytes; + int size; +} RzRegArena; + +typedef struct rz_reg_set_t { + RzRegArena *arena; + RzList /**/ *pool; ///< RzRegArena + RzList /**/ *regs; ///< RzRegItem + HtSP *ht_regs; ///< name:RzRegItem + RzListIter /**/ *cur; + ut32 maskregstype; ///< which type of regs has this register set (logic mask with 1 << RZ_REG_TYPE_XXX) +} RzRegSet; + +typedef struct rz_reg_t { + char *profile; + char *reg_profile_cmt; + char *reg_profile_str; + RzRegProfile reg_profile; + char *name[RZ_REG_NAME_LAST]; // aliases + RzRegSet regset[RZ_REG_TYPE_LAST]; + RzList /**/ *allregs; + RzList /**/ *roregs; + int iters; + int arch; + int bits; + int size; + bool is_thumb; + bool big_endian; +} RzReg; + +typedef struct rz_reg_flags_t { + bool s; // sign, negative number (msb) + bool z; // zero + bool a; // half-carry adjust (if carry happens at nibble level) + bool c; // carry + bool o; // overflow + bool p; // parity (lsb) +} RzRegFlags; + +#ifdef RZ_API +RZ_API void rz_reg_free(RzReg *reg); +RZ_API void rz_reg_free_internal(RzReg *reg, bool init); +RZ_API RzReg *rz_reg_new(void); +RZ_API bool rz_reg_set_name(RZ_NONNULL RzReg *reg, RzRegisterId role, RZ_NONNULL const char *name); +RZ_API bool rz_reg_set_profile_string(RZ_NONNULL RzReg *reg, RZ_NONNULL const char *profile); +RZ_API char *rz_reg_profile_to_cc(RzReg *reg); +RZ_API bool rz_reg_set_reg_profile(RZ_BORROW RzReg *reg); +RZ_API bool rz_reg_set_profile(RzReg *reg, const char *profile); +RZ_API char *rz_reg_parse_gdb_profile(const char *profile); +RZ_API bool rz_reg_is_readonly(RzReg *reg, RzRegItem *item); + +RZ_API RzRegSet *rz_reg_regset_get(RzReg *r, int type); +RZ_API ut64 rz_reg_getv(RzReg *reg, const char *name); +RZ_API ut64 rz_reg_getv_by_role_or_name(RzReg *reg, const char *name); +RZ_API ut64 rz_reg_setv(RzReg *reg, const char *name, ut64 val); +RZ_API const char *rz_reg_32_to_64(RzReg *reg, const char *rreg32); +RZ_API bool rz_reg_is_role(const RzReg *reg, const char *name, RzRegisterId id); +RZ_API const char *rz_reg_64_to_32(RzReg *reg, const char *rreg64); +RZ_API const char *rz_reg_get_name_by_type(RzReg *reg, const char *name); +RZ_API const char *rz_reg_get_type(int idx); +RZ_API const char *rz_reg_get_name(const RzReg *reg, int kind); +RZ_API RzRegItem *rz_reg_get_by_role(RzReg *reg, RzRegisterId role); +RZ_API const char *rz_reg_get_role(int role); +RZ_API int rz_reg_role_by_name(RZ_NONNULL const char *str); +RZ_API RzRegItem *rz_reg_get(const RzReg *reg, const char *name, int type); +RZ_API RzRegItem *rz_reg_get_by_role_or_name(RzReg *reg, const char *name); +RZ_API const RzList /**/ *rz_reg_get_list(RzReg *reg, int type); +RZ_API RzRegItem *rz_reg_get_at(RzReg *reg, int type, int regsize, int delta); +RZ_API RzRegItem *rz_reg_next_diff(RzReg *reg, int type, const ut8 *buf, int buflen, RzRegItem *prev_ri, int regsize); + +RZ_API void rz_reg_reindex(RzReg *reg); +RZ_API RzRegItem *rz_reg_index_get(RzReg *reg, int idx); + +/* Item */ +RZ_API void rz_reg_item_free(RzRegItem *item); + +/* XXX: dupped ?? */ +RZ_API int rz_reg_type_by_name(const char *str); +RZ_API int rz_reg_get_name_idx(const char *type); + +RZ_API RzRegItem *rz_reg_cond_get(RzReg *reg, const char *name); +RZ_API void rz_reg_cond_apply(RzReg *r, RzRegFlags *f); +RZ_API bool rz_reg_cond_set(RzReg *reg, const char *name, bool val); +RZ_API int rz_reg_cond_get_value(RzReg *r, const char *name); +RZ_API bool rz_reg_cond_bits_set(RzReg *r, int type, RzRegFlags *f, bool v); +RZ_API int rz_reg_cond_bits(RzReg *r, int type, RzRegFlags *f); +RZ_API RzRegFlags *rz_reg_cond_retrieve(RzReg *r, RzRegFlags *f); +RZ_API int rz_reg_cond(RzReg *r, int type); + +/* bitvector, for everything */ +RZ_API RZ_OWN RzBitVector *rz_reg_get_bv(RZ_NONNULL RzReg *reg, RZ_NONNULL RzRegItem *item); +RZ_API bool rz_reg_set_bv(RZ_NONNULL RzReg *reg, RZ_NONNULL RzRegItem *item, RZ_NONNULL const RzBitVector *bv); + +/* integer value 8-64 bits */ +RZ_API ut64 rz_reg_get_value(RZ_NONNULL RzReg *reg, RZ_NONNULL RzRegItem *item); +RZ_API bool rz_reg_set_value(RZ_NONNULL RzReg *reg, RZ_NONNULL RzRegItem *item, ut64 value); +RZ_API ut64 rz_reg_get_value_by_role(RZ_NONNULL RzReg *reg, RzRegisterId role); +RZ_API bool rz_reg_set_value_by_role(RZ_NONNULL RzReg *reg, RzRegisterId role, ut64 value); + +/* byte arena */ +RZ_API RZ_OWN ut8 *rz_reg_get_bytes(RZ_NONNULL RzReg *reg, int type, RZ_NULLABLE int *size); +RZ_API bool rz_reg_set_bytes(RzReg *reg, int type, const ut8 *buf, const int len); +RZ_API bool rz_reg_read_regs(RzReg *reg, ut8 *buf, const int len); +RZ_API int rz_reg_arena_set_bytes(RzReg *reg, const char *str); +RZ_API RzRegArena *rz_reg_arena_new(size_t size); +RZ_API void rz_reg_arena_free(RzRegArena *ra); +RZ_API int rz_reg_fit_arena(RzReg *reg); +RZ_API void rz_reg_arena_swap(RzReg *reg, int copy); +RZ_API int rz_reg_arena_push(RzReg *reg); +RZ_API void rz_reg_arena_pop(RzReg *reg); +RZ_API void rz_reg_arena_zero(RzReg *reg, RzRegisterType type); + +RZ_API ut8 *rz_reg_arena_peek(RzReg *reg); +RZ_API void rz_reg_arena_poke(RzReg *reg, const ut8 *buf); +RZ_API ut8 *rz_reg_arena_dup(RzReg *reg, const ut8 *source); +RZ_API const char *rz_reg_cond_to_string(int n); +RZ_API int rz_reg_cond_from_string(const char *str); +RZ_API void rz_reg_arena_shrink(RzReg *reg); + +RZ_API RZ_OWN RzList /**/ *rz_reg_filter_items_covered(RZ_BORROW RZ_NONNULL const RzList /**/ *regs); + +#ifdef __cplusplus +} +#endif + +#endif +#endif diff --git a/dest/include/librz/rz_rop.h b/dest/include/librz/rz_rop.h new file mode 100644 index 00000000000..bfb508c7ee8 --- /dev/null +++ b/dest/include/librz/rz_rop.h @@ -0,0 +1,211 @@ +// SPDX-FileCopyrightText: 2024 z3phyr +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_ROP_H +#define RZ_ROP_H + +/** + * \file rz_rop.h + * \brief Return-Oriented Programming (ROP) related APIs and structures.. + * + * This file contains definitions, structures, and function prototypes for handling ROP gadgets and constraints. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Information about a register. + */ +typedef struct rz_rop_reg_info_t { + char *name; + bool is_mem_read; ///< Register involved in Memory read. + bool is_pc_write; ///< PC write flag. + bool is_var_read; ///< Register involved in Variable read. + bool is_var_write; ///< Register involved in Variable write. + bool is_mem_write; ///< Register involved in Memory write. + ut64 init_val; + ut64 new_val; + ut64 bits; ///< Register bits for capturing cast + RzILOpPure *value_transformations; ///< TODO: Captures Value transformations. +} RzRopRegInfo; + +/** + * \brief Information about a ROP gadget. + */ +typedef struct rz_rop_gadget_info_t { + ut64 address; ///< Gadget address. + ut64 stack_change; ///< Stack change. + ut64 curr_pc_val; ///< Current PC value. + ut32 size; ///< Gadget size. + bool is_pc_write; ///< PC write flag. + bool is_syscall; ///< Syscall flag. + RzIterator /*RzAnalysisBytes *>*/ *analysis_cache; ///< Stores \p RzAnalysisBytes for the gadget. + RzPVector /**/ *modified_registers; ///< Modified registers. + RzList /**/ *dependencies; ///< Dependencies. +} RzRopGadgetInfo; + +/** + * \brief Types of IL instructions for ROP constraints. + */ +typedef enum rz_rop_il_instr_type { + MOV_CONST, ///< reg <- const + MOV_REG, ///< reg <- reg + MOV_OP_CONST, ///< reg <- reg OP const + MOV_OP_REG, ///< reg <- reg OP reg + SYSCALL, ///< syscall +} RzRopILInstructionType; + +/** + * \brief Argument types for ROP constraints. + */ +typedef enum { + SRC_REG, + DST_REG, + SRC_CONST, + SRC_REG_SECOND, + OP, + NUM_ARGS +} RzRopArgType; + +/** + * \brief ROP request mask for filtering gadgets. + */ +typedef enum { + RZ_ROP_GADGET_PRINT = 1 << 0, ///< Print ROP gadgets. + RZ_ROP_GADGET_PRINT_DETAIL = 1 << 1, ///< Detailed ROP gadgets. + RZ_ROP_GADGET_ANALYZE = 1 << 2, ///< Detailed ROP gadgets. + RZ_ROP_GADGET_ALL = RZ_ROP_GADGET_PRINT | RZ_ROP_GADGET_PRINT_DETAIL | RZ_ROP_GADGET_ANALYZE ///< All ROP gadgets requests. +} RzRopRequestMask; + +/** + * \brief ROP search mask for filtering gadgets given details. + */ +typedef enum { + RZ_ROP_DETAIL_SEARCH_NON = 0, + RZ_ROP_DETAIL_SEARCH_STACK = 1 << 0, ///< Search ROP gadgets by stack changes. + RZ_ROP_DETAIL_SEARCH_SIZE = 1 << 1, ///< Search ROP gadgets by gadget sizes. + // RZ_ROP_DETAIL_SEARCH_WRITE = 1 << 2, ///< Search ROP gadgets by written registers. + // RZ_ROP_DETAIL_SEARCH_READ = 1 << 3, ///< Search ROP gadgets by read registers. +} RzRopDetailSearchMask; + +/** + * \brief Filter conditions while searching ROP gadgets by stack changes. + */ +typedef enum { + ROP_DETAIL_CMP_EQ = 1, // == + ROP_DETAIL_CMP_GT = 1 << 1, // > + ROP_DETAIL_CMP_GE = ROP_DETAIL_CMP_GT | ROP_DETAIL_CMP_EQ, // >= + ROP_DETAIL_CMP_LT = 1 << 2, // < + ROP_DETAIL_CMP_LE = ROP_DETAIL_CMP_LT | ROP_DETAIL_CMP_EQ, // <= +} RopDetailSearchCmpOp; + +/** + * \brief Pair representing an end gadget with instruction offset and delay size. + */ +typedef struct rz_rop_endlist_pair_t { + int instr_offset; ///< Instruction offset. + int delay_size; ///< Delay size. +} RzRopEndListPair; + +/** + * \brief Structure representing a ROP constraint. + */ +typedef struct rz_rop_constraint_t { + RzRopILInstructionType type; ///< IL instruction type. + char *args[NUM_ARGS]; ///< Arguments. +} RzRopConstraint; + +/** + * \brief Structure representing a ROP search context. + */ +typedef struct rz_rop_search_context_t { + ut8 max_instr; ///< Rop search max length. + ut8 subchain; ///< Display every length gadget from rop.len=X to 2 in /Rl. + ut8 crop; ///< Include conditional jump, calls and returns in ropsearch. + char *greparg; ///< Grep argument string. + const char *arch; ///< Architecture of the binary. + bool regexp; ///< Regular expression argument flag. + bool cache; ///< Cache the search results. + RzRopRequestMask mask; ///< Mask for kind of rop request operation. + RzRopDetailSearchMask detail_mask; ///< Mask for searching gadgets given details. + RzCmdStateOutput *state; ///< Command state output. + int increment; ///< ROP search increment value. + ut64 max_count; ///< Maximum number of hits (0: no limit). + ut64 from; ///< Start address to start rop search. + ut64 to; ///< End address to stop rop search. + RzList /**/ *end_list; ///< List of end gadgets. + HtSU *unique_hitlists; ///< Cache unique ROP hitlists. + bool ret_val; ///< Flag to indicate return the search results. + RzStrBuf *buf; ///< String buffer for storing search results. + RzPVector /**/ *constraints; ///< User constraints for filtering. +} RzRopSearchContext; + +/** + * \brief Enum for different ROP register events. + */ +typedef enum { + RZ_ROP_EVENT_VAR_READ, + RZ_ROP_EVENT_VAR_WRITE, + RZ_ROP_EVENT_MEM_READ, + RZ_ROP_EVENT_MEM_WRITE, + RZ_ROP_EVENT_PC_WRITE, + RZ_ROP_EVENT_COUNT // This should always be the last element +} RzRopEvent; + +/** + * \brief Function pointer type for event check functions. + */ +typedef bool (*rz_rop_event_check_fn)(const RzRopRegInfo *); + +/** + * \brief Array of event check functions. + */ +extern rz_rop_event_check_fn rz_rop_event_functions[RZ_ROP_EVENT_COUNT]; + +// Command APIs +RZ_API RzCmdStatus rz_core_rop_search(RZ_NONNULL RzCore *core, RZ_NONNULL RzRopSearchContext *context); +RZ_API RzCmdStatus rz_core_rop_gadget_info(RZ_NONNULL RzCore *core, RZ_NONNULL RZ_OWN RzRopSearchContext *context); +RZ_API bool rz_core_rop_analyze_constraint(const RZ_NONNULL RzCore *core, const RZ_NONNULL char *str, + RZ_NULLABLE RZ_OUT RzRopConstraint *rop_constraint); +RZ_API RZ_OWN RzPVector /**/ *rop_constraint_map_parse(const RZ_NONNULL RzCore *core, int argc, const char **argv); +RZ_API bool rz_core_handle_rop_request_type(RZ_NONNULL RzCore *core, RZ_NONNULL RzRopSearchContext *context, RZ_NONNULL RzList /**/ *hitlist); +RZ_API RZ_NULLABLE RZ_OWN RzList /**/ *rz_core_rop_handle_grep_args(RZ_NULLABLE const char *greparg, const bool regexp); + +// ROP Search Context APIs +RZ_API RZ_OWN RzRopSearchContext *rz_core_rop_search_context_new(RZ_NONNULL const RzCore *core, RZ_NULLABLE const char *greparg, bool regexp, + RzRopRequestMask mask, RzRopDetailSearchMask detail_mask, RZ_NULLABLE RZ_BORROW RzCmdStateOutput *state); +RZ_API void rz_core_rop_search_context_free(RZ_NULLABLE RzRopSearchContext *context); + +// ROP Constraint APIs +RZ_API void rz_core_rop_constraint_free(RZ_NULLABLE void *data); +RZ_API RZ_OWN RzPVector /**/ *rz_core_rop_constraint_new(void); +RZ_API RZ_OWN RzRopConstraint *rop_constraint_parse_args(const RZ_NONNULL RzCore *core, const RZ_NONNULL char *token); + +// ROP Gadget Info APIs +RZ_API void rz_core_rop_gadget_info_free(RZ_NULLABLE RzRopGadgetInfo *gadget_info); +RZ_API void rz_core_rop_gadget_info_add_register(const RZ_NONNULL RZ_OUT RzRopGadgetInfo *gadget_info, + RZ_NONNULL RzRopRegInfo *reg_info, bool is_dependency); +RZ_API void rz_core_rop_gadget_info_update_register(const RZ_INOUT RzRopGadgetInfo *gadget_info, RZ_INOUT RZ_NONNULL RzRopRegInfo *new_reg_info); +RZ_API RZ_OWN RzRopGadgetInfo *rz_core_rop_gadget_info_new(ut64 address); +RZ_API RZ_OWN RzRopRegInfo *rz_core_rop_reg_info_dup(RZ_BORROW RZ_NONNULL RzRopRegInfo *src); +RZ_API void rz_core_rop_reg_info_free(RZ_NULLABLE RzRopRegInfo *reg_info); +RZ_API RZ_OWN RzRopRegInfo *rz_core_rop_reg_info_new(RZ_NONNULL const RzCore *core, RZ_NONNULL const RzILEvent *evt, + ut64 init_val, ut64 new_val); +RZ_API RZ_BORROW RzRopRegInfo *rz_core_rop_gadget_info_get_modified_register(const RZ_NONNULL RzRopGadgetInfo *gadget_info, + const RZ_NONNULL char *name); +RZ_API bool rz_core_rop_gadget_info_has_register(const RZ_NONNULL RzRopGadgetInfo *gadget_info, const RZ_NONNULL char *name); +RZ_API RZ_OWN RzPVector /**/ *rz_core_rop_gadget_get_reg_info_by_event(const RZ_NONNULL RzRopGadgetInfo *gadget_info, RzRopEvent event); +RZ_API RZ_OWN RzPVector /**/ *rz_core_rop_get_reg_info_by_reg_names(const RZ_NONNULL RzRopGadgetInfo *gadget_info, RZ_NONNULL const RzPVector /**/ *registers); +RZ_API bool rz_core_rop_gadget_reg_info_has_event(const RZ_NONNULL RzRopGadgetInfo *gadget_info, + RzRopEvent event, const RZ_NULLABLE char *reg_name); +RZ_API RZ_OWN RzPVector /**/ *rz_core_rop_reg_info_find(const RZ_NONNULL RzRopGadgetInfo *gadget_info, const RZ_NONNULL char *name); + +#ifdef __cplusplus +} +#endif +#endif // RZ_ROP_H diff --git a/dest/include/librz/rz_search.h b/dest/include/librz/rz_search.h new file mode 100644 index 00000000000..851568e0672 --- /dev/null +++ b/dest/include/librz/rz_search.h @@ -0,0 +1,294 @@ +#ifndef RZ_SEARCH_H +#define RZ_SEARCH_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_search); + +enum { + RZ_SEARCH_KEYWORD, + RZ_SEARCH_REGEXP, + RZ_SEARCH_PATTERN, + RZ_SEARCH_STRING, + RZ_SEARCH_XREFS, + RZ_SEARCH_DELTAKEY, + RZ_SEARCH_MAGIC, + RZ_SEARCH_LAST +}; + +#define RZ_SEARCH_DISTANCE_MAX 10 + +#define RZ_SEARCH_KEYWORD_TYPE_BINARY 'i' +#define RZ_SEARCH_KEYWORD_TYPE_STRING 's' + +typedef struct rz_search_keyword_t { + ut8 *bin_keyword; + ut8 *bin_binmask; + ut32 keyword_length; + ut32 binmask_length; + void *data; + int count; + int kwidx; + int icase; // ignore case + int type; + ut64 last; // last hit hint +} RzSearchKeyword; + +typedef struct { + RzSearchKeyword *kw; + ut64 addr; +} RzSearchLegacyHit; + +typedef int (*RzSearchCallback)(RzSearchKeyword *kw, void *user, ut64 where); + +typedef struct rz_search_t { + int n_kws; // hit${n_kws}_${count} + int mode; + ut32 pattern_size; + ut32 string_min; // max length of strings for RZ_SEARCH_STRING + ut32 string_max; // min length of strings for RZ_SEARCH_STRING + void *data; // data used by search algorithm + void *user; // user data passed to callback + RzSearchCallback callback; + ut64 nhits; + ut64 maxhits; // search.maxhits + RzList /**/ *hits; + int distance; + int inverse; + bool overlap; // whether two matches can overlap + int contiguous; + int align; + int (*update)(struct rz_search_t *s, ut64 from, const ut8 *buf, int len); + RzList /**/ *kws; // TODO: Use rz_search_kw_new () + RzIOBind iob; + int preludecnt; ///< Counts found preludes. +} RzSearch; + +typedef struct rz_search_value_range_t { + RzIntervalBoundedUt64 itv; ///< Search interval with explicit boundaries. + size_t width; ///< Value width in bytes. + bool big_endian; ///< Byte ordering. +} RzSearchValueRange; + +#ifdef RZ_API + +#define RZ_SEARCH_AES_BOX_SIZE 31 + +RZ_API RzSearch *rz_search_new(int mode); +RZ_API int rz_search_set_mode(RzSearch *s, int mode); +RZ_API RzSearch *rz_search_free(RzSearch *s); + +/* keyword management */ +RZ_API RzList /**/ *rz_search_find(RzSearch *s, ut64 addr, const ut8 *buf, int len); +RZ_API int rz_search_update(RzSearch *s, ut64 from, const ut8 *buf, long len); +RZ_API int rz_search_update_i(RzSearch *s, ut64 from, const ut8 *buf, long len); + +RZ_API void rz_search_keyword_free(RzSearchKeyword *kw); +RZ_API RZ_OWN RzSearchKeyword *rz_search_keyword_new(const ut8 *kw_buf, int kw_len, RZ_NULLABLE const ut8 *bm_buf, int bm_buf_len, RZ_NULLABLE const char *data); +RZ_API RzSearchKeyword *rz_search_keyword_new_str(const char *kw, const char *bm, const char *data, int icase); +RZ_API RzSearchKeyword *rz_search_keyword_new_wide(const char *kw, const char *bm, const char *data, int icase); +RZ_API RzSearchKeyword *rz_search_keyword_new_hex(const char *kwstr, const char *bmstr, const char *data); +RZ_API RzSearchKeyword *rz_search_keyword_new_hexmask(const char *kwstr, const char *data); +RZ_API RzSearchKeyword *rz_search_keyword_new_regexp(const char *str, const char *data); + +RZ_API int rz_search_kw_add(RzSearch *s, RzSearchKeyword *kw); +RZ_API void rz_search_reset(RzSearch *s, int mode); +RZ_API void rz_search_kw_reset(RzSearch *s); + +// TODO: is this an internal API? +RZ_API int rz_search_mybinparse_update(RzSearch *s, ut64 from, const ut8 *buf, int len); +RZ_API int rz_search_magic_update(RzSearch *_s, ut64 from, const ut8 *buf, int len); +RZ_API int rz_search_deltakey_update(RzSearch *s, ut64 from, const ut8 *buf, int len); +RZ_API int rz_search_strings_update(RzSearch *s, ut64 from, const ut8 *buf, int len); +RZ_API int rz_search_regexp_update(RzSearch *s, ut64 from, const ut8 *buf, int len); +// Returns 2 if search.maxhits is reached, 0 on error, otherwise 1 +RZ_API int rz_search_legacy_hit_new(RzSearch *s, RzSearchKeyword *kw, ut64 addr); +RZ_API void rz_search_set_distance(RzSearch *s, int dist); +RZ_API int rz_search_set_string_limits(RzSearch *s, ut32 min, ut32 max); // dup again? +// RZ_API int rz_search_set_callback(RzSearch *s, int (*callback)(struct rz_search_kw_t *, void *, ut64), void *user); +RZ_API void rz_search_set_callback(RzSearch *s, RzSearchCallback(callback), void *user); +RZ_API int rz_search_begin(RzSearch *s); + +/* pattern search */ +RZ_API void rz_search_pattern_size(RzSearch *s, int size); +RZ_API bool rz_search_pattern(RzSearch *s, ut64 from, ut64 to); + +#endif // RZ_API + +// +// NEW SEARCH BEGIN +// Everything above is only there to not break the build. +// + +RZ_LIB_VERSION_HEADER(rz_search); + +/** + * \brief Private search options for the search module. Use the rz_search_opt_*() functions to edit it. + */ +typedef struct rz_search_opt_t RzSearchOpt; + +/** + * \brief Options for the find() callback of the different searches. + */ +typedef struct rz_search_find_opt_t RzSearchFindOpt; + +typedef struct rz_search_interval_t RzSearchInterval; + +typedef struct rz_search_collection_t RzSearchCollection; + +typedef enum { + RZ_SEARCH_HIT_DETAIL_STRING = 0, ///< The detail contains a null-terminated string. + RZ_SEARCH_HIT_DETAIL_UNSIGNED, ///< The detail contains a unsigned numeric value. + RZ_SEARCH_HIT_DETAIL_SIGNED, ///< The detail contains a signed numeric value. + RZ_SEARCH_HIT_DETAIL_DOUBLE, ///< The detail contains a double numeric value. + RZ_SEARCH_HIT_DETAIL_BYTES, ///< The detail contains byte array. +} RzSearchHitDetailType; + +typedef struct rz_search_hit_detail_t RzSearchHitDetail; + +RZ_API bool rz_search_hit_detail_get_type(RZ_NULLABLE RzSearchHitDetail *detail, RZ_NONNULL RZ_OUT RzSearchHitDetailType *type); +RZ_API bool rz_search_hit_detail_get_string(RZ_NULLABLE RzSearchHitDetail *detail, RZ_NONNULL RZ_OUT char **string); +RZ_API bool rz_search_hit_detail_get_unsigned(RZ_NULLABLE RzSearchHitDetail *detail, RZ_NONNULL RZ_OUT ut64 *u64); +RZ_API bool rz_search_hit_detail_get_signed(RZ_NULLABLE RzSearchHitDetail *detail, RZ_NONNULL RZ_OUT st64 *s64); +RZ_API bool rz_search_hit_detail_get_double(RZ_NULLABLE RzSearchHitDetail *detail, RZ_NONNULL RZ_OUT double *f64); +RZ_API bool rz_search_hit_detail_get_bytes(RZ_NULLABLE RzSearchHitDetail *detail, RZ_NONNULL RZ_OUT ut8 **bytes, RZ_NONNULL RZ_OUT size_t *length); + +typedef struct rz_search_hit_t { + char *hit_desc; ///< Hit one word description. If set, it is added to the flag name of the hit. Optional, can be NULL. + ut64 address; ///< Address/offset of the matched data. + size_t size; ///< Size of the matched data (can be 0), in bytes. + RzSearchHitDetail *detail; ///< A detail about the hit. Used to set as flag comment. Optional, can be NULL. +} RzSearchHit; + +typedef enum { + RZ_SEARCH_CANCEL_REGULAR_CHECK, ///< Regular cancel check. Repeated every RZ_SEARCH_CANCEL_CHECK_INTERVAL_USEC microseconds. + RZ_SEARCH_CANCEL_SIGINT, ///< Interrupt signal (likely ctrl + c). +} RzSearchCancelReason; + +RZ_API RZ_OWN char *rz_search_hit_flag_name(RZ_NONNULL const RzSearchHit *hit, size_t hit_id, RZ_NULLABLE const char *prefix); +RZ_API RZ_OWN char *rz_search_hit_detail_as_string(RZ_NONNULL const RzSearchHit *hit); +RZ_API void rz_search_hit_detail_as_json(RZ_NONNULL const RzSearchHit *hit, RZ_NONNULL PJ *json); + +typedef struct rz_search_bytes_pattern_t RzSearchBytesPattern; + +RZ_API void rz_search_bytes_pattern_free(RZ_NULLABLE RZ_OWN RzSearchBytesPattern *hp); +RZ_API RZ_OWN RzSearchBytesPattern *rz_search_bytes_pattern_copy(RZ_NONNULL RZ_BORROW RzSearchBytesPattern *hp); +RZ_API RZ_OWN RzSearchBytesPattern *rz_search_bytes_pattern_new(RZ_OWN ut8 *bytes, RZ_NULLABLE RZ_OWN ut8 *mask, size_t length, RZ_NULLABLE const char *pattern_desc, bool compile_regex); +RZ_API RZ_OWN RzSearchBytesPattern *rz_search_parse_byte_pattern(const char *byte_pattern, RZ_NULLABLE const char *pattern_desc); +RZ_API size_t rz_search_bytes_pattern_len(RZ_NONNULL const RzSearchBytesPattern *hp); +RZ_API const char *rz_search_bytes_pattern_desc(RZ_NONNULL const RzSearchBytesPattern *bp); + +/** + * \brief The cancel callback. It is invoked to check, if the search should be stopped. + * + * \param user The private user data. + * \param n_hits Number of hits already found during the search. + * \param invoe_reason The reason it is called. + * + * \return True, if the search should be canceled. + * \return False, if the search should continue. + */ +typedef bool (*RzSearchCancelCallback)(void *user, size_t n_hits, RzSearchCancelReason invoke_reason); + +typedef enum { + RZ_SEARCH_PROGRESS_DISABLED = 0, ///< Don't show any search progress. + RZ_SEARCH_PROGRESS_NUM_HITS, ///< Show running count of hits. + RZ_SEARCH_PROGRESS_INTERVALS, ///< Above + show hits per interval. +} RzSearchProgress; + +RZ_API RZ_OWN RzSearchOpt *rz_search_opt_new(); +RZ_API void rz_search_opt_free(RZ_NULLABLE RzSearchOpt *opt); +RZ_API bool rz_search_opt_set_max_hits(RZ_NONNULL RzSearchOpt *opt, size_t max_hits); +RZ_API bool rz_search_opt_set_chunk_size(RZ_NONNULL RzSearchOpt *opt, ut64 chunk_size); +RZ_API bool rz_search_opt_set_max_threads(RZ_NONNULL RzSearchOpt *opt, RzThreadNCores max_threads); +RZ_API size_t rz_search_opt_get_max_threads(RZ_NONNULL const RzSearchOpt *opt); +RZ_API bool rz_search_opt_set_show_progress_from_str(RZ_NONNULL RzSearchOpt *opt, const char *show_progress); +RZ_API RzSearchProgress rz_search_opt_get_show_progress(RZ_NONNULL RzSearchOpt *opt); +RZ_API bool rz_search_opt_set_cancel_cb(RZ_NONNULL RzSearchOpt *opt, RzSearchCancelCallback callback, void *user); +RZ_API bool rz_search_opt_set_find_options(RZ_NONNULL RzSearchOpt *opt, RZ_OWN RzSearchFindOpt *find_opts); +RZ_API const RzSearchFindOpt *rz_search_opt_get_find_options(RZ_NONNULL const RzSearchOpt *opt); + +RZ_API RZ_OWN RzSearchFindOpt *rz_search_find_opt_new(); +RZ_API void rz_search_find_opt_free(RZ_NULLABLE RzSearchFindOpt *opt); +RZ_API bool rz_search_find_opt_set_overlap_match(RZ_NONNULL RzSearchFindOpt *opt, bool overlap_match); +RZ_API bool rz_search_find_opt_set_alignment(RZ_NONNULL RzSearchFindOpt *opt, size_t alignment); +RZ_API ut16 rz_search_find_opt_get_alignment(RZ_NONNULL const RzSearchFindOpt *opt); + +typedef enum { + RZ_SEARCH_COLLECTION_CRYPTOGRAPHIC_AES_128 = 0, + RZ_SEARCH_COLLECTION_CRYPTOGRAPHIC_AES_192, + RZ_SEARCH_COLLECTION_CRYPTOGRAPHIC_AES_256, + RZ_SEARCH_COLLECTION_CRYPTOGRAPHIC_SM4_BE, + RZ_SEARCH_COLLECTION_CRYPTOGRAPHIC_SM4_LE, + RZ_SEARCH_COLLECTION_CRYPTOGRAPHIC_RSA, + RZ_SEARCH_COLLECTION_CRYPTOGRAPHIC_ECC, + RZ_SEARCH_COLLECTION_CRYPTOGRAPHIC_PKCS8_PRIVKEY, + RZ_SEARCH_COLLECTION_CRYPTOGRAPHIC_X509, + + // Always the last element to define enum size + RZ_SEARCH_COLLECTION_CRYPTOGRAPHIC_ENUM_SIZE, +} RzSearchCollectionCryptographicType; + +#define RZ_SEARCH_COLLECTION_CRYPTOGRAPHIC_ALL RZ_SEARCH_COLLECTION_CRYPTOGRAPHIC_ENUM_SIZE + +RZ_API RZ_OWN RzSearchCollection *rz_search_collection_cryptographic(); +RZ_API bool rz_search_collection_cryptographic_add(RZ_NONNULL RzSearchCollection *col, RzSearchCollectionCryptographicType type); +RZ_API bool rz_search_collection_cryptographic_name_to_type(RZ_NONNULL const char *name, RzSearchCollectionCryptographicType *type); + +RZ_API RZ_OWN RzSearchCollection *rz_search_collection_hash(); +RZ_API bool rz_search_collection_hash_add(RZ_NONNULL RzSearchCollection *col, RZ_NONNULL const RzHash *rz_hash, RZ_NONNULL const char *algo_name, RZ_NONNULL const char *expected_digest, ut64 block_size); +RZ_API bool rz_search_collection_hash_name_to_type(RZ_NONNULL const char *name); +RZ_API ut64 rz_search_hash_get_element_size(RZ_NONNULL RzSearchCollection *collection); + +RZ_API RZ_OWN RzSearchCollection *rz_search_collection_entropy(RZ_NONNULL const RzHash *rz_hash); +RZ_API bool rz_search_collection_entropy_add(RZ_NONNULL RzSearchCollection *col, bool fractional, double min_inclusive_limit, double max_inclusive_limit, ut64 block_size); + +/** + * \brief Maximum value width to search for is currently 64bits/8bytes. + */ +#define RZ_SEARCH_VALUE_SEARCH_MAX_WIDTH 8 + +RZ_API RZ_OWN RzSearchCollection *rz_search_collection_values(); +RZ_API bool rz_search_collection_values_add(RZ_NONNULL RzSearchCollection *col, RZ_NONNULL RZ_OWN RzVector /**/ *vranges); + +RZ_API RZ_OWN RzSearchCollection *rz_search_collection_bytes(); +RZ_API bool rz_search_collection_bytes_add(RZ_NONNULL RzSearchCollection *col, RZ_NULLABLE const char *pattern_desc, RZ_NONNULL const ut8 *bytes, RZ_NULLABLE const ut8 *mask, size_t length); +RZ_API bool rz_search_collection_bytes_add_pattern(RZ_NONNULL RzSearchCollection *col, RZ_NONNULL RZ_OWN RzSearchBytesPattern *bytes_pattern); + +RZ_API RZ_OWN RzSearchCollection *rz_search_collection_strings(RZ_NULLABLE RZ_BORROW RzUtilStrScanOptions *scan_opts, size_t n_threads); +RZ_API bool rz_search_collection_string_add( + RZ_NONNULL RzSearchCollection *col, + RZ_NONNULL const char *regex_pattern, + RzRegexFlags cflags, + size_t match_alignment, + RzStrEnc encoding); +RZ_API bool rz_search_collection_strings_check_config_improvements( + RZ_NULLABLE const RzSearchCollection *col, + RZ_NULLABLE const RzList /**/ *boundaries, + RZ_NULLABLE const RzSearchOpt *search_options, + RZ_NULLABLE const RzUtilStrScanOptions *scan_opt, + bool print_msg); + +RZ_API void rz_search_collection_free(RZ_NULLABLE RzSearchCollection *sc); + +RZ_API RZ_OWN RzSearchCollection *rz_search_collection_magic(RZ_NONNULL const char *magic_dir); + +RZ_API RZ_OWN RzList /**/ *rz_search_on_io(RZ_BORROW RZ_NONNULL RzSearchOpt *opt, RZ_BORROW RZ_NONNULL RzSearchCollection *col, RZ_BORROW RZ_NONNULL RzIO *io, RZ_BORROW RZ_NONNULL RzList /**/ *search_in); +RZ_API RZ_OWN RzList /**/ *rz_search_on_buffer(RZ_BORROW RZ_NONNULL RzSearchOpt *opt, RZ_BORROW RZ_NONNULL RzSearchCollection *col, RZ_BORROW RZ_NONNULL RzBuffer *buffer, RZ_NULLABLE const RzList /**/ *ranges); + +RZ_API bool rz_search_str_enc_needs_scanning(RzStrEnc encoding); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_sign.h b/dest/include/librz/rz_sign.h new file mode 100644 index 00000000000..eb3a272d618 --- /dev/null +++ b/dest/include/librz/rz_sign.h @@ -0,0 +1,17 @@ +#ifndef RZ_SIGN_H +#define RZ_SIGN_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_sign); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_skiplist.h b/dest/include/librz/rz_skiplist.h new file mode 100644 index 00000000000..c5a6fb2a163 --- /dev/null +++ b/dest/include/librz/rz_skiplist.h @@ -0,0 +1,56 @@ +// SPDX-FileCopyrightText: 2016 Jeffrey Crowell +// SPDX-License-Identifier: BSD-3-Clause + +// Skiplists are a probabilistic datastructure than can be used as a k-v store +// with average case O(lg n) lookup time, and worst case O(n). + +// https://en.wikipedia.org/wiki/Skip_list + +#ifndef RZ_SKIP_LIST_H +#define RZ_SKIP_LIST_H + +#include + +typedef struct rz_skiplist_node_t { + void *data; // pointer to the value + struct rz_skiplist_node_t **forward; // forward pointer +} RzSkipListNode; + +typedef struct rz_skiplist_t { + RzSkipListNode *head; // list header + int list_level; // current level of the list. + int size; + RzListFree freefn; + RzListComparator compare; +} RzSkipList; + +RZ_API RzSkipList *rz_skiplist_new(RzListFree freefn, RzListComparator comparefn); +RZ_API void rz_skiplist_free(RzSkipList *list); +RZ_API void rz_skiplist_purge(RzSkipList *list); +RZ_API RzSkipListNode *rz_skiplist_insert(RzSkipList *list, void *data); +RZ_API bool rz_skiplist_delete(RzSkipList *list, void *data); +RZ_API bool rz_skiplist_delete_node(RzSkipList *list, RzSkipListNode *node); +RZ_API RzSkipListNode *rz_skiplist_find(RzSkipList *list, void *data); +RZ_API RzSkipListNode *rz_skiplist_find_geq(RzSkipList *list, void *data); +RZ_API RzSkipListNode *rz_skiplist_find_leq(RzSkipList *list, void *data); +RZ_API void rz_skiplist_join(RzSkipList *l1, RzSkipList *l2); +RZ_API void *rz_skiplist_get_first(RzSkipList *list); +RZ_API void *rz_skiplist_get_n(RzSkipList *list, int n); +RZ_API void *rz_skiplist_get_geq(RzSkipList *list, void *data); +RZ_API void *rz_skiplist_get_leq(RzSkipList *list, void *data); +RZ_API bool rz_skiplist_empty(RzSkipList *list); +RZ_API RzList *rz_skiplist_to_list(RzSkipList *list); + +#define rz_skiplist_islast(list, el) (el->forward[0] == list->head) + +#define rz_skiplist_length(list) (list->size) + +#define rz_skiplist_foreach(list, it, pos) \ + if (list) \ + for (it = list->head->forward[0]; it != list->head && ((pos = it->data) || 1); it = it->forward[0]) + +#define rz_skiplist_foreach_safe(list, it, tmp, pos) \ + if (list) \ + for (it = list->head->forward[0]; it != list->head && ((pos = it->data) || 1) && ((tmp = it->forward[0]) || 1); it = tmp) + +#endif // RZ_SKIP_LIST_H diff --git a/dest/include/librz/rz_skyline.h b/dest/include/librz/rz_skyline.h new file mode 100644 index 00000000000..1fd07b83ed9 --- /dev/null +++ b/dest/include/librz/rz_skyline.h @@ -0,0 +1,56 @@ +#ifndef RZ_SKYLINE_H +#define RZ_SKYLINE_H + +#include "rz_vector.h" +#include "rz_util/rz_itv.h" + +typedef struct rz_skyline_item_t { + RzInterval itv; + void *user; +} RzSkylineItem; + +typedef struct rz_skyline_t { + RzVector /**/ v; +} RzSkyline; + +RZ_API bool rz_skyline_add(RzSkyline *skyline, RzInterval itv, void *user); +RZ_API const RzSkylineItem *rz_skyline_get_item_intersect(RzSkyline *skyline, ut64 addr, ut64 len); + +static inline void rz_skyline_init(RzSkyline *skyline) { + rz_return_if_fail(skyline); + rz_vector_init(&skyline->v, sizeof(RzSkylineItem), NULL, NULL); +} + +static inline void rz_skyline_fini(RzSkyline *skyline) { + rz_return_if_fail(skyline); + rz_vector_fini(&skyline->v); +} + +static inline void rz_skyline_clear(RzSkyline *skyline) { + rz_return_if_fail(skyline); + rz_vector_clear(&skyline->v); +} + +static inline const RzSkylineItem *rz_skyline_get_item(RzSkyline *skyline, ut64 addr) { + rz_return_val_if_fail(skyline, NULL); + return rz_skyline_get_item_intersect(skyline, addr, 1); +} + +static inline void *rz_skyline_get(RzSkyline *skyline, ut64 addr) { + rz_return_val_if_fail(skyline, NULL); + const RzSkylineItem *item = rz_skyline_get_item(skyline, addr); + return item ? item->user : NULL; +} + +static inline void *rz_skyline_get_intersect(RzSkyline *skyline, ut64 addr, ut64 len) { + rz_return_val_if_fail(skyline, NULL); + const RzSkylineItem *item = rz_skyline_get_item_intersect(skyline, addr, len); + return item ? item->user : NULL; +} + +static inline bool rz_skyline_contains(RzSkyline *skyline, ut64 addr) { + rz_return_val_if_fail(skyline, false); + return (bool)rz_skyline_get_item(skyline, addr); +} + +#endif diff --git a/dest/include/librz/rz_socket.h b/dest/include/librz/rz_socket.h new file mode 100644 index 00000000000..819e582096e --- /dev/null +++ b/dest/include/librz/rz_socket.h @@ -0,0 +1,251 @@ +#ifndef RZ_SOCKET_H +#define RZ_SOCKET_H + +#include "rz_types.h" +#include "rz_bind.h" +#include "rz_list.h" + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_socket); + +#if __UNIX__ +#include +#include +#include +#include +#include +#include +#include +#elif __WINDOWS__ +#include +#endif + +#if HAVE_LIB_SSL +#include +#include +#endif + +#if __UNIX__ +#include +#endif + +/* For the Mingw-W64 toolchain */ +#ifndef MSG_DONTWAIT +#define MSG_DONTWAIT 0 +#endif +#ifndef SD_BOTH +#define SD_RECEIVE 0 +#define SD_SEND 1 +#define SD_BOTH 2 +#endif + +#if _MSC_VER +#define RZ_INVALID_SOCKET INVALID_SOCKET +#else +#define RZ_INVALID_SOCKET -1 +#endif + +typedef struct { + int child; +#if __WINDOWS__ + HANDLE pipe; +#else + int input[2]; + int output[2]; +#endif + RzCoreBind coreb; +} RzPipe; + +#ifdef _MSC_VER +typedef SOCKET RzSocketFd; +#else +typedef int RzSocketFd; +#endif + +typedef struct rz_socket_t { + RzSocketFd fd; + bool is_ssl; + int proto; + int local; // TODO: merge ssl with local -> flags/options + int port; + struct sockaddr_in sa; +#if HAVE_LIB_SSL + SSL_CTX *ctx; + SSL *sfd; + BIO *bio; +#endif +} RzSocket; + +typedef struct rz_socket_http_options { + RzList /**/ *authtokens; + bool accept_timeout; + int timeout; + bool httpauth; +} RzSocketHTTPOptions; + +#define RZ_SOCKET_PROTO_TCP IPPROTO_TCP +#define RZ_SOCKET_PROTO_UDP IPPROTO_UDP +#define RZ_SOCKET_PROTO_UNIX 0x1337 +#define RZ_SOCKET_PROTO_NONE 0 +#define RZ_SOCKET_PROTO_DEFAULT RZ_SOCKET_PROTO_TCP + +#ifdef RZ_API +RZ_API RzSocket *rz_socket_new_from_fd(int fd); +RZ_API RzSocket *rz_socket_new(bool is_ssl); +RZ_API bool rz_socket_spawn(RzSocket *s, const char *cmd, unsigned int timeout); +RZ_API bool rz_socket_connect(RzSocket *s, const char *host, const char *port, int proto, unsigned int timeout); +RZ_API int rz_socket_connect_serial(RzSocket *sock, const char *path, int speed, int parity); +#define rz_socket_connect_tcp(a, b, c, d) rz_socket_connect(a, b, c, RZ_SOCKET_PROTO_TCP, d) +#define rz_socket_connect_udp(a, b, c, d) rz_socket_connect(a, b, c, RZ_SOCKET_PROTO_UDP, d) +#if __UNIX__ +#define rz_socket_connect_unix(a, b) rz_socket_connect(a, b, b, RZ_SOCKET_PROTO_UNIX, 0) +#else +#define rz_socket_connect_unix(a, b) (false) +#endif +RZ_API bool rz_socket_listen(RzSocket *s, const char *port, const char *certfile); +RZ_API int rz_socket_port_by_name(const char *name); +RZ_API int rz_socket_close_fd(RzSocket *s); +RZ_API int rz_socket_close(RzSocket *s); +RZ_API int rz_socket_free(RzSocket *s); +RZ_API RzSocket *rz_socket_accept(RzSocket *s); +RZ_API RzSocket *rz_socket_accept_timeout(RzSocket *s, unsigned int timeout); +RZ_API bool rz_socket_block_time(RzSocket *s, bool block, int sec, int usec); +RZ_API int rz_socket_flush(RzSocket *s); +RZ_API int rz_socket_ready(RzSocket *s, int secs, int usecs); +RZ_API char *rz_socket_to_string(RzSocket *s); +RZ_API int rz_socket_write(RzSocket *s, void *buf, int len); +RZ_API int rz_socket_puts(RzSocket *s, char *buf); +RZ_API void rz_socket_printf(RzSocket *s, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); +RZ_API int rz_socket_read(RzSocket *s, ut8 *read, int len); +RZ_API int rz_socket_read_block(RzSocket *s, unsigned char *buf, int len); +RZ_API int rz_socket_gets(RzSocket *s, char *buf, int size); +RZ_API ut8 *rz_socket_slurp(RzSocket *s, int *len); +RZ_API bool rz_socket_is_connected(RzSocket *); + +/** + * Utility to interrupt blocking calls on an RzSocket from e.g. + * other threads or signal handlers. + */ +typedef struct rz_stop_pipe_t RzStopPipe; + +typedef enum { + RZ_STOP_PIPE_ERROR, + RZ_STOP_PIPE_STOPPED, + RZ_STOP_PIPE_SOCKET_READY, + RZ_STOP_PIPE_TIMEOUT +} RzStopPipeSelectResult; + +RZ_API RzStopPipe *rz_stop_pipe_new(void); +RZ_API void rz_stop_pipe_free(RzStopPipe *stop_pipe); +RZ_API void rz_stop_pipe_stop(RzStopPipe *stop_pipe); +RZ_API RzStopPipeSelectResult rz_stop_pipe_select_single(RzStopPipe *stop_pipe, RzSocket *sock, bool sock_write, ut64 timeout_ms); + +/* process */ +typedef struct rz_socket_proc_t { + int fd0[2]; + int fd1[2]; + int pid; +} RzSocketProc; + +RZ_API RzSocketProc *rz_socket_proc_open(char *const argv[]); +RZ_API int rz_socket_proc_close(RzSocketProc *sp); +RZ_API int rz_socket_proc_read(RzSocketProc *sp, unsigned char *buf, int len); +RZ_API int rz_socket_proc_gets(RzSocketProc *sp, char *buf, int size); +RZ_API int rz_socket_proc_write(RzSocketProc *sp, void *buf, int len); +RZ_API void rz_socket_proc_printf(RzSocketProc *sp, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); +RZ_API int rz_socket_proc_ready(RzSocketProc *sp, int secs, int usecs); + +/* HTTP */ +RZ_API char *rz_socket_http_get(const char *url, int *code, int *rlen); +RZ_API char *rz_socket_http_post(const char *url, const char *data, int *code, int *rlen); +RZ_API void rz_socket_http_server_set_breaked(bool *b); + +typedef struct rz_socket_http_request { + RzSocket *s; + char *path; + char *host; + char *agent; + char *method; + char *referer; + ut8 *data; + int data_length; + bool auth; +} RzSocketHTTPRequest; + +RZ_API RzSocketHTTPRequest *rz_socket_http_accept(RzSocket *s, RzSocketHTTPOptions *so); +RZ_API void rz_socket_http_response(RzSocketHTTPRequest *rs, int code, const char *out, int x, const char *headers); +RZ_API void rz_socket_http_close(RzSocketHTTPRequest *rs); +RZ_API ut8 *rz_socket_http_handle_upload(const ut8 *str, int len, int *olen); + +/* run.c */ +#define RZ_RUN_PROFILE_NARGS 512 +typedef struct rz_run_profile_t { + char *_args[RZ_RUN_PROFILE_NARGS]; + int _argc; + bool _daemon; + char *_system; + char *_program; + char *_runlib; + char *_runlib_fcn; + char *_stdio; + char *_stdin; + char *_stdout; + char *_stderr; + char *_chgdir; + char *_chroot; + char *_libpath; + char *_preload; + int _bits; + int _pid; + char *_pidfile; + int _rzpreload; + int _docore; + int _dofork; + int _dodebug; + int _aslr; + int _maxstack; + int _maxproc; + int _maxfd; + int _rzsleep; + int _execve; + char *_setuid; + char *_seteuid; + char *_setgid; + char *_setegid; + char *_input; + char *_connect; + char *_listen; + int _pty; + int _timeout; + int _timeout_sig; + int _nice; +} RzRunProfile; + +RZ_API RzRunProfile *rz_run_new(const char *str); +RZ_API bool rz_run_parse(RzRunProfile *pf, const char *profile); +RZ_API void rz_run_free(RzRunProfile *r); +RZ_API bool rz_run_parseline(RzRunProfile *p, const char *b); +RZ_API int rz_run_config_env(RzRunProfile *p); +RZ_API int rz_run_start(RzRunProfile *p); +RZ_API void rz_run_reset(RzRunProfile *p); +RZ_API bool rz_run_parsefile(RzRunProfile *p, const char *b); +RZ_API char *rz_run_get_environ_profile(char **env); + +RZ_API int rzpipe_write(RzPipe *rzpipe, const char *str); +RZ_API char *rzpipe_read(RzPipe *rzpipe); +RZ_API int rzpipe_close(RzPipe *rzpipe); +RZ_API RzPipe *rzpipe_open_corebind(RzCoreBind *coreb); +RZ_API RzPipe *rzpipe_open(const char *cmd); +RZ_API RzPipe *rzpipe_open_dl(const char *file); +RZ_API char *rzpipe_cmd(RzPipe *rzpipe, const char *str); +RZ_API char *rzpipe_cmdf(RzPipe *rzpipe, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_syscall.h b/dest/include/librz/rz_syscall.h new file mode 100644 index 00000000000..a60d55396db --- /dev/null +++ b/dest/include/librz/rz_syscall.h @@ -0,0 +1,97 @@ +// SPDX-FileCopyrightText: 2009-2021 pancake +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_SYSCALL_H +#define RZ_SYSCALL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +RZ_LIB_VERSION_HEADER(rz_syscall); + +#define RZ_SYSCALL_ARGS 7 + +typedef struct rz_syscall_item_t { + char *name; + int swi; + int num; + int args; + char *sargs; +} RzSyscallItem; + +typedef struct rz_sysreg_item_t { + char *type; + char *name; + char *comment; +} RzSysregItem; + +typedef struct rz_sysreg_db_t { + HtUP /**/ *port; +} RzSysregsDB; + +typedef struct rz_syscall_t { + FILE *fd; + // memoization + char *arch; + char *os; + int bits; + char *cpu; + // database + RzSyscallItem *sysptr; + Sdb *db; + RzSysregsDB *srdb; + int refs; +} RzSyscall; + +#if 0 +// todo: add the ability to describe particular bits +typedef struct rz_sysregs_item_t { + ut64 address; + ut64 size; + int type; + const char *name; + const char *description; +} RSysregsItem; + +typedef struct rz_sysregs_t { + FILE *fd; + char *arch; + char *cpu; + RSysregsItem *sysregs; + Sdb *db; +} RSysregs; +#endif + +#ifdef RZ_API +RZ_API RzSyscallItem *rz_syscall_item_new_from_string(const char *name, const char *s); +RZ_API void rz_syscall_item_free(RzSyscallItem *si); + +RZ_API RzSyscall *rz_syscall_new(void); +RZ_API void rz_sysregs_db_free(RzSysregsDB *sysregdb); +RZ_API void rz_syscall_free(RzSyscall *ctx); +RZ_API RzSyscall *rz_syscall_ref(RzSyscall *sc); +RZ_API bool rz_syscall_setup(RzSyscall *s, RZ_BORROW RZ_NONNULL RzPath *sys_path, const char *arch, int bits, const char *cpu, const char *os); +RZ_API RzSyscallItem *rz_syscall_get(RzSyscall *ctx, int num, int swi); +RZ_API bool rz_syscall_get_num(RZ_NONNULL RZ_BORROW RzSyscall *s, RZ_NONNULL const char *str, RZ_OUT RZ_NULLABLE int *num); +RZ_API const char *rz_syscall_get_i(RzSyscall *ctx, int num, int swi); +RZ_API RzList /**/ *rz_syscall_list(RzSyscall *ctx); +RZ_API int rz_syscall_get_swi(RzSyscall *s); + +RZ_API const char *rz_sysreg_get(RzSyscall *s, const char *type, ut64 num); +RZ_API bool rz_sysreg_set_arch(RzSyscall *s, RZ_NONNULL const char *arch, RZ_NONNULL const char *regs_dir); +RZ_API bool rz_sysreg_load_sdb(RzSysregsDB *sysregdb, const char *path); +RZ_API RzSysregsDB *rz_sysregs_db_new(); +RZ_API RZ_OWN RzSysregItem *rz_sysreg_item_new(RZ_NULLABLE const char *name); +RZ_API void rz_sysreg_item_free(RzSysregItem *sysregitem); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_th.h b/dest/include/librz/rz_th.h new file mode 100644 index 00000000000..b3d7b3db83e --- /dev/null +++ b/dest/include/librz/rz_th.h @@ -0,0 +1,113 @@ +// SPDX-FileCopyrightText: 2020-2023 deroad +// SPDX-FileCopyrightText: 2009-2017 pancake +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_TH_H +#define RZ_TH_H + +#ifdef _GNU_SOURCE +#undef _GNU_SOURCE +#endif +#define _GNU_SOURCE +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + RZ_THREAD_N_CORES_ALL_AVAILABLE = 0, +} RzThreadNCores; + +typedef enum { + RZ_THREAD_QUEUE_UNLIMITED = 0, +} RzThreadQueueSize; + +typedef struct rz_th_sem_t RzThreadSemaphore; +typedef struct rz_th_lock_t RzThreadLock; +typedef struct rz_th_cond_t RzThreadCond; +typedef struct rz_th_t RzThread; +typedef struct rz_th_pool_t RzThreadPool; +typedef struct rz_th_queue_t RzThreadQueue; +typedef void *(*RzThreadFunction)(void *user); + +/** + * This function shall return false to stop the threaded iteration. + */ +typedef bool (*RzThreadIterator)(void *element, void *user); + +typedef struct rz_atomic_bool_t RzAtomicBool; + +#ifdef RZ_API +RZ_API RZ_OWN RzThread *rz_th_new(RZ_NONNULL RzThreadFunction function, RZ_NULLABLE void *user); +RZ_API RZ_OWN void *rz_th_get_user(RZ_NONNULL RzThread *th); +RZ_API RZ_OWN void *rz_th_get_retv(RZ_NONNULL RzThread *th); +RZ_API bool rz_th_terminated(const RZ_NONNULL RzThread *th); +RZ_API bool rz_th_wait(RZ_NONNULL RzThread *th); +RZ_API void rz_th_free(RZ_NULLABLE RzThread *th); +RZ_API bool rz_th_set_name(RZ_NONNULL RzThread *th, RZ_NONNULL const char *name); +RZ_API bool rz_th_get_name(RZ_NONNULL RzThread *th, RZ_NONNULL RZ_OUT char *name, size_t len); +RZ_API bool rz_th_set_affinity(RZ_NONNULL RzThread *th, int cpuid); +RZ_API bool rz_th_yield(void); + +RZ_API RZ_OWN RzThreadSemaphore *rz_th_sem_new(unsigned int initial); +RZ_API void rz_th_sem_free(RZ_NULLABLE RzThreadSemaphore *sem); +RZ_API void rz_th_sem_post(RZ_NONNULL RzThreadSemaphore *sem); +RZ_API void rz_th_sem_wait(RZ_NONNULL RzThreadSemaphore *sem); + +RZ_API RZ_OWN RzThreadLock *rz_th_lock_new(bool recursive); +RZ_API bool rz_th_lock_tryenter(RZ_NONNULL RzThreadLock *thl); +RZ_API void rz_th_lock_enter(RZ_NONNULL RzThreadLock *thl); +RZ_API void rz_th_lock_leave(RZ_NONNULL RzThreadLock *thl); +RZ_API void rz_th_lock_free(RZ_NULLABLE RzThreadLock *thl); + +RZ_API RZ_OWN RzThreadCond *rz_th_cond_new(void); +RZ_API void rz_th_cond_signal(RZ_NONNULL RzThreadCond *cond); +RZ_API void rz_th_cond_signal_all(RZ_NONNULL RzThreadCond *cond); +RZ_API void rz_th_cond_wait(RZ_NONNULL RzThreadCond *cond, RZ_NONNULL RzThreadLock *lock); +RZ_API void rz_th_cond_timed_wait(RZ_NONNULL RzThreadCond *cond, RZ_NONNULL RzThreadLock *lock, size_t timeout_ms); +RZ_API void rz_th_cond_free(RZ_NULLABLE RzThreadCond *cond); + +RZ_API RzThreadNCores rz_th_physical_core_number(); +RZ_API RzThreadNCores rz_th_max_threads(RzThreadNCores requested); + +RZ_API RZ_OWN RzThreadPool *rz_th_pool_new(RzThreadNCores max_threads); +RZ_API void rz_th_pool_free(RZ_NULLABLE RzThreadPool *pool); +RZ_API bool rz_th_pool_add_thread(RZ_NONNULL RzThreadPool *pool, RZ_NONNULL RzThread *thread); +RZ_API RZ_BORROW RzThread *rz_th_pool_get_thread(RZ_NONNULL RzThreadPool *pool, size_t index); +RZ_API bool rz_th_pool_wait(RZ_NONNULL RzThreadPool *pool); +RZ_API size_t rz_th_pool_size(RZ_NONNULL RzThreadPool *pool); + +RZ_API RZ_OWN RzThreadQueue *rz_th_queue_new(RzThreadQueueSize max_size, RZ_NULLABLE RzListFree qfree); +RZ_API RZ_OWN RzThreadQueue *rz_th_queue_from_list(RZ_NONNULL RZ_BORROW RzList /**/ *list, RZ_NULLABLE RzListFree qfree); +RZ_API RZ_OWN RzThreadQueue *rz_th_queue_from_pvector(RZ_NONNULL RZ_BORROW RzPVector /**/ *vector, RZ_NULLABLE RzListFree qfree); +RZ_API void rz_th_queue_free(RZ_NULLABLE RzThreadQueue *queue); +RZ_API bool rz_th_queue_push(RZ_NONNULL RzThreadQueue *queue, RZ_NONNULL void *user, bool tail); +RZ_API bool rz_th_queue_pop(RZ_NONNULL RzThreadQueue *queue, bool tail, RZ_NONNULL RZ_OUT void **data); +RZ_API RZ_OWN RzList /**/ *rz_th_queue_pop_all(RZ_NONNULL RzThreadQueue *queue); +RZ_API bool rz_th_queue_is_empty(RZ_NONNULL RzThreadQueue *queue); +RZ_API bool rz_th_queue_is_full(RZ_NONNULL RzThreadQueue *queue); +RZ_API size_t rz_th_queue_size(RZ_NONNULL RzThreadQueue *queue); +RZ_API void rz_th_queue_close_when_empty(RZ_NONNULL RzThreadQueue *queue); +RZ_API void rz_th_queue_close(RZ_NONNULL RzThreadQueue *queue); +RZ_API bool rz_th_queue_is_closed(RZ_NONNULL RzThreadQueue *queue); + +RZ_API RZ_OWN RzAtomicBool *rz_atomic_bool_new(bool value); +RZ_API void rz_atomic_bool_free(RZ_NULLABLE RzAtomicBool *tbool); +RZ_API bool rz_atomic_bool_get(RZ_NONNULL RzAtomicBool *tbool); +RZ_API void rz_atomic_bool_set(RZ_NONNULL RzAtomicBool *tbool, bool value); + +RZ_API bool rz_th_iterate_list(RZ_NONNULL const RzList /**/ *list, RZ_NONNULL RzThreadIterator iterator, RzThreadNCores max_threads, RZ_NULLABLE void *user); +RZ_API bool rz_th_iterate_pvector(RZ_NONNULL const RzPVector /**/ *pvec, RZ_NONNULL RzThreadIterator iterator, RzThreadNCores max_threads, RZ_NULLABLE void *user); + +#endif /* RZ_API */ + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_TH_H */ diff --git a/dest/include/librz/rz_type.h b/dest/include/librz/rz_type.h new file mode 100644 index 00000000000..7dd976ea438 --- /dev/null +++ b/dest/include/librz/rz_type.h @@ -0,0 +1,484 @@ +// SPDX-FileCopyrightText: 2021 Anton Kochkov +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_TYPE_H +#define RZ_TYPE_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_type); + +typedef struct rz_type_target_t { + char *cpu; + int bits; + int addr_bits; ///< size of a pointer if > 0, otherwise bits is used. + char *os; + bool big_endian; + const char *default_type; +} RzTypeTarget; + +typedef struct rz_type_parser_t RzTypeParser; + +RZ_DEPRECATE typedef struct rz_format_data_internal_t { + int slide; + int oldslide; + int ident; +} RzFormatDataInternal; + +typedef struct rz_type_db_t { + void *user; + HtSP /**/ *types; //< name -> base type + HtSS /**/ *formats; //< name -> `pf` format + HtSP /**/ *callables; //< name -> RzCallable (function type) + RzTypeTarget *target; + RzTypeParser *parser; + RzNum *num; + RzIOBind iob; // for RzIO in formats + RZ_DEPRECATE RzFormatDataInternal *format_internal_data; // for rz_type_format_data_internal state +} RzTypeDB; + +// All types in RzTypeDB module are either concrete, +// "base" types that are types already having the +// concrete size and memory layout +// or the "AST" types that are returned from the parser +// and don't contain the size or memory laoyout + +typedef struct rz_type_t RzType; + +// Base types + +typedef ut64 RzTypeAttribute; + +typedef enum { + // A first group - typeclasses + RZ_TYPE_ATTRIBUTE_TYPECLASS_MASK = 0xF, //< to store typeclasses + // The rest are reserved +} RzTypeAttributeMask; + +// Typeclasses for atomic types +typedef enum { + RZ_TYPE_TYPECLASS_NONE, //< most generic types + RZ_TYPE_TYPECLASS_NUM, //< all numbers + RZ_TYPE_TYPECLASS_INTEGRAL, //< all integer numbers + RZ_TYPE_TYPECLASS_FLOATING, //< all floating point numbers + RZ_TYPE_TYPECLASS_ADDRESS, //< integer types to work with pointers + RZ_TYPE_TYPECLASS_INTEGRAL_SIGNED, //< all signed integral types (subclass of Integral) + RZ_TYPE_TYPECLASS_INTEGRAL_UNSIGNED, //< all unsigned integral types (subclass of Integral) + RZ_TYPE_TYPECLASS_INVALID +} RzTypeTypeclass; + +typedef enum { + RZ_BASE_TYPE_KIND_STRUCT, + RZ_BASE_TYPE_KIND_UNION, + RZ_BASE_TYPE_KIND_ENUM, + RZ_BASE_TYPE_KIND_TYPEDEF, + RZ_BASE_TYPE_KIND_ATOMIC, // For real atomic base types +} RzBaseTypeKind; + +typedef struct rz_type_enum_case_t { + char *name; + st64 val; +} RzTypeEnumCase; + +typedef struct rz_type_struct_member_t { + char *name; + RzType *type; + size_t offset; // in bytes + size_t size; // in bits? +} RzTypeStructMember; + +typedef struct rz_type_union_member_t { + char *name; + RzType *type; + size_t offset; // in bytes + size_t size; // in bits? +} RzTypeUnionMember; + +typedef struct rz_base_type_struct_t { + RzVector /**/ members; +} RzBaseTypeStruct; + +typedef struct rz_base_type_union_t { + RzVector /**/ members; +} RzBaseTypeUnion; + +typedef struct rz_base_type_enum_t { + RzVector /**/ cases; // list of all the enum cases +} RzBaseTypeEnum; + +typedef struct rz_base_type_t { + char *name; + RzType *type; // Used by typedef, atomic type, enum + ut64 size; // size of the whole type in bits + RzBaseTypeKind kind; + RzTypeAttribute attrs; + union { + RzBaseTypeStruct struct_data; + RzBaseTypeEnum enum_data; + RzBaseTypeUnion union_data; + }; +} RzBaseType; + +// AST-level types for C and C++ +// Parses strings like "const char * [0x42] const * [23]" to RzType + +typedef enum { + RZ_TYPE_KIND_IDENTIFIER, + RZ_TYPE_KIND_POINTER, + RZ_TYPE_KIND_ARRAY, + RZ_TYPE_KIND_CALLABLE +} RzTypeKind; + +typedef enum { + RZ_TYPE_IDENTIFIER_KIND_UNSPECIFIED, + RZ_TYPE_IDENTIFIER_KIND_STRUCT, + RZ_TYPE_IDENTIFIER_KIND_UNION, + RZ_TYPE_IDENTIFIER_KIND_ENUM +} RzTypeIdentifierKind; + +typedef struct rz_callable_arg_t { + RZ_NULLABLE char *name; // optional + RzType *type; +} RzCallableArg; + +typedef struct rz_callable_at { + RZ_NULLABLE char *name; // optional + RZ_NULLABLE RzType *ret; /// optional for the time being + RzPVector /**/ *args; + RZ_NULLABLE const char *cc; // optional + bool noret : 1; // Does not return + bool has_unspecified_parameters : 1; +} RzCallable; + +struct rz_type_t { + RzTypeKind kind; + union { + struct { + RzTypeIdentifierKind kind; + char *name; + bool is_const; // const char * + } identifier; + struct { + RzType *type; + bool is_const; // char * const + } pointer; + struct { + RzType *type; + ut64 count; + } array; + RzCallable *callable; + }; +}; + +typedef struct rz_type_path_t { + RzType *typ; ///< type at the leaf + char *path; +} RzTypePath; + +/// A path and the type that the path came from +typedef struct rz_type_path_tuple_t { + RzTypePath *path; + RzType *root; +} RzTypePathTuple; + +/** + * \brief Type Conditions + */ +typedef enum { + RZ_TYPE_COND_AL = 0, ///< Always executed (no condition) + RZ_TYPE_COND_EQ, ///< Equal + RZ_TYPE_COND_NE, ///< Not equal + RZ_TYPE_COND_GE, ///< Greater or equal + RZ_TYPE_COND_GT, ///< Greater than + RZ_TYPE_COND_LE, ///< Less or equal + RZ_TYPE_COND_LT, ///< Less than + RZ_TYPE_COND_NV, ///< Never executed must be a nop? :D + RZ_TYPE_COND_HS, ///< Carry set >, ==, or unordered + RZ_TYPE_COND_LO, ///< Carry clear Less than + RZ_TYPE_COND_MI, ///< Minus, negative Less than + RZ_TYPE_COND_PL, ///< Plus, positive or zero >, ==, or unordered + RZ_TYPE_COND_VS, ///< Overflow Unordered + RZ_TYPE_COND_VC, ///< No overflow Not unordered + RZ_TYPE_COND_HI, ///< Unsigned higher Greater than, or unordered + RZ_TYPE_COND_LS, ///< Unsigned lower or same Less than or equal + RZ_TYPE_COND_HEX_SCL_TRUE, // Hexagon only: Scalar instruction if(Pu) + RZ_TYPE_COND_HEX_SCL_FALSE, // Hexagon only: Scalar instruction if(!Pu) + RZ_TYPE_COND_HEX_VEC_TRUE, // Hexagon only: Vector instruction if(Pu) + RZ_TYPE_COND_HEX_VEC_FALSE, // Hexagon only: Vector instruction if(!Pu) + RZ_TYPE_COND_EXCEPTION, // when the jump is taken only during an exception +} RzTypeCond; + +/** + * \brief type constrained by the type conditions + */ +typedef struct rz_type_constraint_t { + RzTypeCond cond; + ut64 val; +} RzTypeConstraint; + +typedef enum { + RZ_TYPE_PRINT_NO_OPTS = 0, // no options + RZ_TYPE_PRINT_MULTILINE = 1 << 0, // print multiline string (every single type on a single line) + RZ_TYPE_PRINT_UNFOLD_ANON_ONLY = 1 << 1, // only unfold anonymous structs/unions/enums (applies only to inner members, not the root member) + RZ_TYPE_PRINT_UNFOLD_ANON_ONLY_STRICT = 1 << 2, // only unfold anonymous structs/unions/enums + RZ_TYPE_PRINT_ZERO_VLA = 1 << 3, // use [0] to denote VLA instead of (default) [] + RZ_TYPE_PRINT_NO_END_SEMICOLON = 1 << 4, // return a string without a semicolon at end + RZ_TYPE_PRINT_ANONYMOUS = 1 << 5, // use "[struct|union|enum] anonymous" as the typename for anonymous structs/unions/enums + RZ_TYPE_PRINT_END_NEWLINE = 1 << 6, // return a string with a newline at the end + RZ_TYPE_PRINT_SHOW_TYPEDEF = 1 << 7, // show typedefs wherever found + RZ_TYPE_PRINT_ALLOW_NON_EXISTENT_BASE_TYPE = 1 << 8 // print identifiers even if there is no base type of that name in the db (otherwise "unknown_t") +} RzTypePrintOpts; + +/** + * \brief structure to save format name and definition + */ +typedef struct rz_type_format_t { + const char *name; + const char *body; +} RzTypeFormat; + +#ifdef RZ_API + +RZ_API RzTypeDB *rz_type_db_new(); +RZ_API void rz_type_db_free(RzTypeDB *typedb); +RZ_API bool rz_type_db_load_sdb(RzTypeDB *typedb, RZ_NONNULL const char *path); +RZ_API bool rz_type_db_load_sdb_str(RzTypeDB *typedb, RZ_NONNULL const char *str); +RZ_API bool rz_type_db_load_callables_sdb(RzTypeDB *typedb, RZ_NONNULL const char *path); +RZ_API bool rz_type_db_load_callables_sdb_str(RzTypeDB *typedb, RZ_NONNULL const char *str); +RZ_API void rz_type_db_set_bits(RzTypeDB *typedb, int bits); +RZ_API void rz_type_db_set_address_bits(RzTypeDB *typedb, int addr_bits); +RZ_API void rz_type_db_set_os(RzTypeDB *typedb, const char *os); +RZ_API void rz_type_db_set_cpu(RzTypeDB *typedb, const char *cpu); +RZ_API void rz_type_db_set_endian(RzTypeDB *typedb, bool big_endian); + +RZ_API ut8 rz_type_db_pointer_size(const RzTypeDB *typedb); + +RZ_API bool rz_type_db_del(RzTypeDB *typedb, RZ_NONNULL const char *name); + +RZ_API void rz_type_db_init(RzTypeDB *typedb, const char *dir_prefix, const char *arch, int bits, const char *os); +RZ_API void rz_type_db_reload(RzTypeDB *typedb, const char *dir_prefix); +RZ_API void rz_type_db_purge(RzTypeDB *typedb); + +// Base types +RZ_API bool rz_base_type_clone_into( + RZ_NONNULL RZ_BORROW RZ_OUT RzBaseType *dst, + RZ_NONNULL RZ_BORROW RZ_IN RzBaseType *src); +RZ_API RZ_OWN RzBaseType *rz_base_type_clone(RZ_NULLABLE RZ_BORROW RzBaseType *b); +RZ_API void rz_type_base_type_free(RzBaseType *type); +RZ_API RZ_OWN RzBaseType *rz_type_base_type_new(RzBaseTypeKind kind); +RZ_API RZ_BORROW const char *rz_type_base_type_kind_as_string(RzBaseTypeKind kind); + +RZ_API void rz_type_base_enum_case_free(void *e, void *user); +RZ_API void rz_type_base_struct_member_free(void *e, void *user); +RZ_API void rz_type_base_union_member_free(void *e, void *user); + +RZ_API RZ_BORROW RzBaseType *rz_type_db_get_base_type(const RzTypeDB *typedb, RZ_NONNULL const char *name); +RZ_API RZ_BORROW RzBaseType *rz_type_db_get_compound_type(const RzTypeDB *typedb, RZ_NONNULL const char *name); +RZ_API bool rz_type_db_save_base_type(const RzTypeDB *typedb, RzBaseType *type); +RZ_API bool rz_type_db_update_base_type(const RzTypeDB *typedb, RzBaseType *type); +RZ_API bool rz_type_db_delete_base_type(RzTypeDB *typedb, RZ_NONNULL RzBaseType *type); + +RZ_API RZ_OWN RzList /**/ *rz_type_db_get_base_types_of_kind(const RzTypeDB *typedb, RzBaseTypeKind kind); +RZ_API RZ_OWN RzList /**/ *rz_type_db_get_base_types(const RzTypeDB *typedb); + +RZ_API RZ_OWN char *rz_type_db_base_type_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype); +RZ_API RZ_OWN char *rz_type_db_base_type_as_pretty_string(RZ_NONNULL const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype, unsigned int opts, int unfold_level); +RZ_API bool rz_type_db_edit_base_type(RzTypeDB *typedb, RZ_NONNULL const char *name, RZ_NONNULL const char *typestr); +RZ_API RZ_BORROW RzType *rz_type_db_base_type_unwrap_typedef(RZ_NONNULL const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype); + +// Compound types + +RZ_API RZ_OWN RzType *rz_type_clone(RZ_BORROW RZ_NONNULL const RzType *type); +RZ_API RZ_BORROW const char *rz_type_identifier(RZ_NONNULL const RzType *type); +RZ_API bool rz_types_equal(RZ_NONNULL const RzType *type1, RZ_NONNULL const RzType *type2); +RZ_API RZ_OWN char *rz_type_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzType *type); +RZ_API RZ_OWN char *rz_type_declaration_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzType *type); +RZ_API RZ_OWN char *rz_type_identifier_declaration_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzType *type, RZ_NONNULL const char *identifier); +RZ_API RZ_OWN char *rz_type_as_pretty_string(const RzTypeDB *typedb, RZ_NONNULL const RzType *type, RZ_NULLABLE const char *identifier, unsigned int opts, int unfold_level); +RZ_API void rz_type_free(RZ_NULLABLE RzType *type); +RZ_API bool rz_type_exists(RzTypeDB *typedb, RZ_NONNULL const char *name); +RZ_API int rz_type_kind(RzTypeDB *typedb, RZ_NONNULL const char *name); + +// Type classes +RZ_API RZ_BORROW const char *rz_type_typeclass_as_string(RzTypeTypeclass typeclass); +RZ_API RzTypeTypeclass rz_type_typeclass_from_string(RZ_NONNULL const char *typeclass); +RZ_API RzTypeTypeclass rz_base_type_typeclass(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type); +RZ_API RzTypeTypeclass rz_type_typeclass(const RzTypeDB *typedb, RZ_NONNULL const RzType *type); +RZ_API bool rz_base_type_is_num(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type); +RZ_API bool rz_type_is_num(const RzTypeDB *typedb, RZ_NONNULL const RzType *type); +RZ_API bool rz_base_type_is_integral(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type); +RZ_API bool rz_type_is_integral(const RzTypeDB *typedb, RZ_NONNULL const RzType *type); +RZ_API bool rz_base_type_is_floating(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type); +RZ_API bool rz_type_is_floating(const RzTypeDB *typedb, RZ_NONNULL const RzType *type); +RZ_API bool rz_base_type_is_integral_signed(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type); +RZ_API bool rz_type_is_integral_signed(const RzTypeDB *typedb, RZ_NONNULL const RzType *type); +RZ_API bool rz_base_type_is_integral_unsigned(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type); +RZ_API bool rz_type_is_integral_unsigned(const RzTypeDB *typedb, RZ_NONNULL const RzType *type); +RZ_API RZ_OWN RzList /**/ *rz_type_typeclass_get_all(const RzTypeDB *typedb, RzTypeTypeclass typeclass); +RZ_API RZ_OWN RzList /**/ *rz_type_typeclass_get_all_sized(const RzTypeDB *typedb, RzTypeTypeclass typeclass, size_t size); +RZ_API RZ_OWN RzBaseType *rz_type_typeclass_get_default_sized(const RzTypeDB *typedb, RzTypeTypeclass typeclass, size_t size); + +// Type paths +RZ_API RZ_OWN RzTypePath *rz_type_path_new(RZ_BORROW RZ_NONNULL RzType *type, RZ_OWN RZ_NONNULL char *path); +RZ_API void rz_type_path_free(RZ_NULLABLE RzTypePath *tpath); +RZ_API st64 rz_type_offset_by_path(const RzTypeDB *typedb, RZ_NONNULL const char *path); +RZ_API RZ_OWN RzList /**/ *rz_base_type_path_by_offset(const RzTypeDB *typedb, const RzBaseType *btype, ut64 offset, unsigned int max_depth); +RZ_API RZ_OWN RzList /**/ *rz_type_path_by_offset(const RzTypeDB *typedb, const RzType *type, ut64 offset, unsigned int max_depth); +RZ_API RZ_OWN RzList /**/ *rz_type_db_get_by_offset(const RzTypeDB *typedb, ut64 offset); +RZ_API ut64 rz_type_db_struct_member_packed_offset(RZ_NONNULL const RzTypeDB *typedb, RZ_NONNULL const char *name, RZ_NONNULL const char *member); +RZ_API ut64 rz_type_db_struct_member_offset(RZ_NONNULL const RzTypeDB *typedb, RZ_NONNULL const char *name, RZ_NONNULL const char *member); + +// Type parser low-level API + +RZ_API RZ_OWN RzTypeParser *rz_type_parser_new(void); +RZ_API RZ_OWN RzTypeParser *rz_type_parser_init(HtSP *types, HtSP *callables); +RZ_API void rz_type_parser_free(RZ_NONNULL RzTypeParser *parser); +RZ_API void rz_type_parser_free_purge(RZ_NONNULL RzTypeParser *parser); + +RZ_API int rz_type_parse_string_stateless(RzTypeParser *parser, const char *code, char **error_msg); +RZ_API int rz_type_parse_file_stateless(RzTypeParser *parser, const char *path, const char *dir, char **error_msg); +RZ_API RZ_OWN RzType *rz_type_parse_string_single(RzTypeParser *parser, const char *code, char **error_msg); +RZ_API RZ_OWN RzType *rz_type_parse_string_declaration_single(RzTypeParser *parser, const char *code, char **error_msg); + +// Type parser high-level API + +RZ_API int rz_type_parse_string(RzTypeDB *typedb, const char *code, char **error_msg); +RZ_API int rz_type_parse_file(RzTypeDB *typedb, const char *path, const char *dir, char **error_msg); +RZ_API void rz_type_parse_reset(RzTypeDB *typedb); + +// Type-specific APIs + +RZ_API RzBaseType *rz_type_db_get_enum(const RzTypeDB *typedb, RZ_NONNULL const char *name); +RZ_API RzBaseType *rz_type_db_get_union(const RzTypeDB *typedb, RZ_NONNULL const char *name); +RZ_API RzBaseType *rz_type_db_get_struct(const RzTypeDB *typedb, RZ_NONNULL const char *name); +RZ_API RzBaseType *rz_type_db_get_typedef(const RzTypeDB *typedb, RZ_NONNULL const char *name); + +RZ_API int rz_type_db_enum_member_by_name(const RzTypeDB *typedb, RZ_NONNULL const char *name, const char *member); +RZ_API RZ_BORROW const char *rz_type_db_enum_member_by_val(const RzTypeDB *typedb, RZ_NONNULL const char *name, ut64 val); +RZ_API RZ_OWN RzList /**/ *rz_type_db_find_enums_by_val(const RzTypeDB *typedb, ut64 val); +RZ_API RZ_OWN char *rz_type_db_enum_get_bitfield(const RzTypeDB *typedb, RZ_NONNULL const char *name, ut64 val); + +// Type size calculation +RZ_API ut64 rz_type_db_base_get_bitsize(const RzTypeDB *typedb, RZ_NONNULL RzBaseType *btype); +RZ_API ut64 rz_type_db_get_bitsize(const RzTypeDB *typedb, RZ_NONNULL RzType *type); + +// Various type helpers +RZ_API bool rz_type_atomic_eq(const RzTypeDB *typedb, RZ_NONNULL const RzType *typ1, RZ_NONNULL const RzType *typ2); +RZ_API bool rz_type_atomic_str_eq(const RzTypeDB *typedb, RZ_NONNULL const RzType *typ1, RZ_NONNULL const char *name); +RZ_API bool rz_type_atomic_is_void(const RzTypeDB *typedb, RZ_NONNULL const RzType *type); +RZ_API bool rz_type_atomic_is_const(const RzTypeDB *typedb, RZ_NONNULL const RzType *type); +RZ_API bool rz_type_integral_set_sign(const RzTypeDB *typedb, RZ_NONNULL RzType **type, bool sign); + +RZ_API bool rz_type_is_void_ptr(RZ_NONNULL const RzType *type); +RZ_API bool rz_type_is_void_ptr_nested(RZ_NONNULL const RzType *type); +RZ_API bool rz_type_is_char_ptr(RZ_NONNULL const RzType *type); +RZ_API bool rz_type_is_char_ptr_nested(RZ_NONNULL const RzType *type); +RZ_API bool rz_type_is_identifier(RZ_NONNULL const RzType *type); +RZ_API bool rz_type_is_strictly_atomic(const RzTypeDB *typedb, RZ_NONNULL const RzType *type); +RZ_API bool rz_type_is_atomic(const RzTypeDB *typedb, RZ_NONNULL const RzType *type); +RZ_API bool rz_type_is_default(const RzTypeDB *typedb, RZ_NONNULL const RzType *type); +RZ_API RZ_OWN RzType *rz_type_new_default(const RzTypeDB *typedb); + +RZ_API RZ_OWN RzType *rz_type_identifier_of_base_type(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype, bool is_const); +RZ_API RZ_OWN RzType *rz_type_identifier_of_base_type_str(const RzTypeDB *typedb, RZ_NONNULL const char *name); +RZ_API RZ_OWN RzType *rz_type_pointer_of_base_type(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype, bool is_const); +RZ_API RZ_OWN RzType *rz_type_pointer_of_base_type_str(const RzTypeDB *typedb, RZ_NONNULL const char *name, bool is_const); +RZ_API RZ_OWN RzType *rz_type_pointer_of_type(const RzTypeDB *typedb, RZ_NONNULL RzType *type, bool is_const); +RZ_API RZ_OWN RzType *rz_type_array_of_base_type(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype, size_t count); +RZ_API RZ_OWN RzType *rz_type_array_of_base_type_str(const RzTypeDB *typedb, RZ_NONNULL const char *name, size_t count); +RZ_API RZ_OWN RzType *rz_type_array_of_type(const RzTypeDB *typedb, RZ_NONNULL RzType *type, size_t count); +RZ_API RZ_OWN RzType *rz_type_callable(RZ_NONNULL RZ_OWN RzCallable *callable); + +RZ_API RZ_BORROW RzBaseType *rz_type_get_base_type(const RzTypeDB *typedb, RZ_NONNULL const RzType *type); + +// Type formats (`tp` and `pf` commands) +RZ_API const char *rz_type_db_format_get(const RzTypeDB *typedb, const char *name); +RZ_API void rz_type_db_format_set(RzTypeDB *typedb, const char *name, const char *fmt); +RZ_API RZ_OWN RzList /**/ *rz_type_db_format_all(RzTypeDB *typedb); +RZ_API void rz_type_db_format_delete(RzTypeDB *typedb, const char *name); +RZ_API void rz_type_db_format_purge(RzTypeDB *typedb); + +RZ_API RZ_OWN char *rz_base_type_as_format(const RzTypeDB *typedb, RZ_NONNULL RzBaseType *type); +RZ_API RZ_OWN char *rz_type_format(RZ_NONNULL const RzTypeDB *typedb, RZ_NONNULL const char *type); +RZ_API int rz_type_format_struct_size(const RzTypeDB *typedb, const char *f, int mode, int n); +RZ_API RZ_OWN char *rz_type_format_data(RZ_BORROW RzTypeDB *t, RzPrint *p, ut64 seek, const ut8 *b, const int len, + const char *formatname, int mode, const char *setval, char *ofield); +RZ_API RZ_OWN char *rz_type_as_format(const RzTypeDB *typedb, RZ_NONNULL RzType *type); +RZ_API RZ_OWN char *rz_type_as_format_pair(const RzTypeDB *typedb, RZ_NONNULL RzType *type); + +// Function prototypes api +RZ_API RZ_OWN RzCallable *rz_type_callable_new(RZ_NULLABLE const char *name); +RZ_API RZ_OWN RzCallable *rz_type_callable_clone(RZ_BORROW RZ_NONNULL const RzCallable *callable); +RZ_API void rz_type_callable_free(RZ_NONNULL RzCallable *callable); + +RZ_API RZ_OWN RzCallableArg *rz_type_callable_arg_new(RzTypeDB *typedb, RZ_NONNULL const char *name, RZ_OWN RZ_NONNULL RzType *type); +RZ_API RZ_OWN RzCallableArg *rz_type_callable_arg_clone(RZ_BORROW RZ_NONNULL const RzCallableArg *arg); +RZ_API void rz_type_callable_arg_free(RzCallableArg *arg); +RZ_API bool rz_type_callable_arg_add(RZ_NONNULL RzCallable *callable, RZ_OWN RZ_NONNULL RzCallableArg *arg); + +RZ_API RZ_OWN RzCallable *rz_type_func_new(RzTypeDB *typedb, RZ_NONNULL const char *name, RZ_OWN RZ_NULLABLE RzType *type); +RZ_API bool rz_type_func_save(RzTypeDB *typedb, RZ_NONNULL RzCallable *callable); +RZ_API bool rz_type_func_update(RzTypeDB *typedb, RZ_NONNULL RzCallable *callable); +RZ_API RZ_BORROW RzCallable *rz_type_func_get(RzTypeDB *typedb, RZ_NONNULL const char *func_name); +RZ_API bool rz_type_func_delete(RzTypeDB *typedb, RZ_NONNULL const char *func_name); +RZ_API void rz_type_func_delete_all(RzTypeDB *typedb); +RZ_API bool rz_type_func_exist(RzTypeDB *typedb, RZ_NONNULL const char *func_name); + +RZ_API RZ_BORROW RzType *rz_type_func_ret(RzTypeDB *typedb, RZ_NONNULL const char *func_name); +RZ_API bool rz_type_func_ret_set(RzTypeDB *typedb, const char *func_name, RZ_BORROW RZ_NONNULL RzType *type); + +RZ_API RZ_BORROW const char *rz_type_func_cc(RzTypeDB *typedb, RZ_NONNULL const char *func_name); +RZ_API bool rz_type_func_cc_set(RzTypeDB *typedb, const char *name, const char *cc); + +RZ_API int rz_type_func_args_count(RzTypeDB *typedb, RZ_NONNULL const char *func_name); +RZ_API RZ_BORROW RzType *rz_type_func_args_type(RzTypeDB *typedb, RZ_NONNULL const char *func_name, int i); +RZ_API RZ_BORROW const char *rz_type_func_args_name(RzTypeDB *typedb, RZ_NONNULL const char *func_name, int i); +RZ_API bool rz_type_func_arg_add(RzTypeDB *typedb, RZ_NONNULL const char *func_name, RZ_NONNULL const char *arg_name, RZ_OWN RZ_NONNULL RzType *arg_type); + +RZ_API bool rz_type_is_callable(RZ_NONNULL const RzType *type); +RZ_API bool rz_type_is_callable_ptr(RZ_NONNULL const RzType *type); +RZ_API bool rz_type_is_callable_ptr_nested(RZ_NONNULL const RzType *type); +RZ_API RZ_OWN char *rz_type_callable_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzCallable *callable); +RZ_API RZ_OWN char *rz_type_callable_ptr_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzType *type, bool zero_vla); + +RZ_API bool rz_type_func_is_noreturn(RzTypeDB *typedb, RZ_NONNULL const char *name); +RZ_API bool rz_type_func_noreturn_add(RzTypeDB *typedb, RZ_NONNULL const char *name); +RZ_API bool rz_type_func_noreturn_drop(RzTypeDB *typedb, RZ_NONNULL const char *name); + +RZ_API RZ_OWN RzList /**/ *rz_type_function_names(RzTypeDB *typedb); +RZ_API RZ_OWN RzList /**/ *rz_type_noreturn_function_names(RzTypeDB *typedb); + +// Listing API +RZ_API RZ_OWN RzList /**/ *rz_type_db_enum_names(RzTypeDB *typedb); +RZ_API RZ_OWN RzList /**/ *rz_type_db_struct_names(RzTypeDB *typedb); +RZ_API RZ_OWN RzList /**/ *rz_type_db_union_names(RzTypeDB *typedb); +RZ_API RZ_OWN RzList /**/ *rz_type_db_typedef_names(RzTypeDB *typedb); +RZ_API RZ_OWN RzList /**/ *rz_type_db_all(RzTypeDB *typedb); + +// Serialization API +RZ_API void rz_serialize_types_save(RZ_NONNULL Sdb *db, RZ_NONNULL const RzTypeDB *typedb); +RZ_API bool rz_serialize_types_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzTypeDB *typedb, RZ_NULLABLE RzSerializeResultInfo *res); +RZ_API void rz_serialize_callables_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzTypeDB *typedb); +RZ_API bool rz_serialize_callables_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzTypeDB *typedb, RZ_NULLABLE RzSerializeResultInfo *res); + +// Constrained Type +RZ_API RZ_BORROW const char *rz_type_cond_tostring(RzTypeCond cc); +RZ_API RzTypeCond rz_type_cond_invert(RzTypeCond cond); +RZ_API bool rz_type_cond_eval(RzTypeCond cond, st64 arg0, st64 arg1); +RZ_API bool rz_type_cond_eval_single(RzTypeCond cond, st64 arg0); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_types.h b/dest/include/librz/rz_types.h new file mode 100644 index 00000000000..1d3468b7fe3 --- /dev/null +++ b/dest/include/librz/rz_types.h @@ -0,0 +1,767 @@ +#ifndef RZ_TYPES_H +#define RZ_TYPES_H + +#undef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS 64 + +// defines like IS_DIGIT, etc' +#include +#include +#include +#include +#include +#if HAVE_HEADER_INTTYPES_H +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// TODO: fix this to make it crosscompile-friendly: RZ_SYS_OSTYPE ? +/* operating system */ +#undef __BSD__ +#undef __KFBSD__ +#undef __UNIX__ +#undef __WINDOWS__ + +// TODO: these modes should be dropped when oldshell is removed in favour of RzOutputMode. +#define RZ_MODE_PRINT 0x000 +#define RZ_MODE_SET 0x002 +#define RZ_MODE_SIMPLE 0x004 +#define RZ_MODE_JSON 0x008 +#define RZ_MODE_SIMPLEST 0x020 + +#define RZ_IN /* do not use, implicit */ +#define RZ_OUT /* parameter is written, not read */ +#define RZ_INOUT /* parameter is read and written / return value is copy of RZ_INOUT parameter */ + +#ifdef RZ_BINDINGS +#define RZ_OWN __attribute__((annotate("RZ_OWN"))) +#define RZ_BORROW __attribute__((annotate("RZ_BORROW"))) + +#define RZ_NONNULL __attribute__((annotate("RZ_NONNULL"))) +#define RZ_NULLABLE __attribute__((annotate("RZ_NULLABLE"))) +#define RZ_DEPRECATE __attribute__((annotate("RZ_DEPRECATE"))) +#else +#define RZ_OWN /* pointer ownership is transferred */ +#define RZ_BORROW /* pointer ownership is not transferred, it must not be freed by the receiver */ +#define RZ_NONNULL /* pointer can not be null */ +#define RZ_NULLABLE /* pointer can be null */ +#define RZ_DEPRECATE /* should not be used in new code and should/will be removed in the future */ +#endif + +#define RZ_IFNULL(x) /* default value for the pointer when null */ +#ifdef __GNUC__ +#define RZ_UNUSED __attribute__((__unused__)) +#else +#define RZ_UNUSED /* unused */ +#endif + +#ifdef RZ_NEW +#undef RZ_NEW +#endif + +#ifdef RZ_NEW0 +#undef RZ_NEW0 +#endif + +#ifdef RZ_FREE +#undef RZ_FREE +#endif + +#ifdef RZ_NEWCOPY +#undef RZ_NEWCOPY +#endif + +// used in debug, io, bin, analysis, ... +#define RZ_PERM_R 4 +#define RZ_PERM_W 2 +#define RZ_PERM_X 1 +#define RZ_PERM_RW (RZ_PERM_R | RZ_PERM_W) +#define RZ_PERM_RX (RZ_PERM_R | RZ_PERM_X) +#define RZ_PERM_RWX (RZ_PERM_R | RZ_PERM_W | RZ_PERM_X) +#define RZ_PERM_WX (RZ_PERM_W | RZ_PERM_X) +#define RZ_PERM_SHAR 8 +#define RZ_PERM_PRIV 16 +#define RZ_PERM_ACCESS 32 +#define RZ_PERM_CREAT 64 + +#if defined(__powerpc) || defined(__powerpc__) +#undef __POWERPC__ +#define __POWERPC__ 1 +#endif + +#if defined(__OpenBSD__) +#include +#endif + +#ifdef __GNUC__ +#define UNUSED_FUNCTION(x) __attribute__((__unused__)) UNUSED_##x +#else +#define UNUSED_FUNCTION(x) UNUSED_##x +#endif + +#ifdef __EMSCRIPTEN__ +#define __UNIX__ 1 +#endif + +#ifdef __HAIKU__ +#define __UNIX__ 1 +#endif + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#define __KFBSD__ 1 +#else +#define __KFBSD__ 0 +#endif + +#ifdef __MSYS__ +#define __UNIX__ 1 +#endif + +#ifdef _MSC_VER +#define restrict +#define strcasecmp stricmp +#define strncasecmp strnicmp +#define __WINDOWS__ 1 +#endif + +#if defined(EMSCRIPTEN) || defined(__linux__) || defined(__APPLE__) || defined(__GNU__) || defined(__ANDROID__) || defined(__QNX__) || defined(__sun) || defined(__HAIKU__) +#define __BSD__ 0 +#define __UNIX__ 1 +#endif +#if __KFBSD__ || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) +#define __BSD__ 1 +#define __UNIX__ 1 +#endif +#if __WINDOWS__ || _WIN32 +#define __WINDOWS__ 1 +#define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */ +#undef __UNIX__ +#undef __BSD__ +#endif + +#if defined(__APPLE__) && ((__arm__ || __arm64__ || __aarch64__) && IS_IOS) +#define TARGET_OS_IPHONE 1 +#else +#define TARGET_OS_IPHONE 0 +#endif + +#ifdef __GNUC__ +#define FUNC_ATTR_MALLOC __attribute__((malloc)) +#define FUNC_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x))) +#define FUNC_ATTR_ALLOC_SIZE_PROD(x, y) __attribute__((alloc_size(x, y))) +#define FUNC_ATTR_ALLOC_ALIGN(x) __attribute__((alloc_align(x))) +#define FUNC_ATTR_PURE __attribute__((pure)) +#define FUNC_ATTR_CONST __attribute__((const)) +#define FUNC_ATTR_USED __attribute__((used)) +#define FUNC_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#define FUNC_ATTR_ALWAYS_INLINE __attribute__((always_inline)) +#else +#define FUNC_ATTR_MALLOC +#define FUNC_ATTR_ALLOC_SIZE(x) +#define FUNC_ATTR_ALLOC_SIZE_PROD(x, y) +#define FUNC_ATTR_ALLOC_ALIGN(x) +#define FUNC_ATTR_PURE +#define FUNC_ATTR_CONST +#define FUNC_ATTR_USED +#define FUNC_ATTR_WARN_UNUSED_RESULT +#define FUNC_ATTR_ALWAYS_INLINE +#endif + +/* printf format check attributes */ +#if defined(__clang__) || defined(__GNUC__) +#define RZ_PRINTF_CHECK(fmt, dots) __attribute__((format(printf, fmt, dots))) +#else +#define RZ_PRINTF_CHECK(fmt, dots) +#endif + +#include +#include + +#undef _GNU_SOURCE +#define _GNU_SOURCE + +// clang-format off +#if __APPLE__ + #if __i386__ + #define RZ_SYS_BASE ((ut64)0x1000) + #elif __x86_64__ + #define RZ_SYS_BASE ((ut64)0x100000000) + #else + #define RZ_SYS_BASE ((ut64)0x1000) + #endif +#elif __WINDOWS__ + #define RZ_SYS_BASE ((ut64)0x01001000) +#else // linux, bsd, ... + #if __arm__ || __arm64__ + #define RZ_SYS_BASE ((ut64)0x4000) + #else + #define RZ_SYS_BASE ((ut64)0x8048000) + #endif +#endif + +static const ut32 rz_endianness_one = 1; + +#define RZ_SYS_ENDIAN_NONE 0 +#define RZ_SYS_ENDIAN_LITTLE 1 +#define RZ_SYS_ENDIAN_BIG 2 +#define RZ_SYS_ENDIAN_BI 3 + +/* arch */ +#if __i386__ + #define RZ_SYS_ARCH "x86" + #define RZ_SYS_BITS RZ_SYS_BITS_32 + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE +#elif __EMSCRIPTEN__ + #define RZ_SYS_ARCH "wasm" + #define RZ_SYS_BITS (RZ_SYS_BITS_32 | RZ_SYS_BITS_64) + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE +#elif __x86_64__ + #define RZ_SYS_ARCH "x86" + #define RZ_SYS_BITS (RZ_SYS_BITS_32 | RZ_SYS_BITS_64) + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE +#elif __POWERPC__ + #define RZ_SYS_ARCH "ppc" + #ifdef __powerpc64__ + #define RZ_SYS_BITS (RZ_SYS_BITS_32 | RZ_SYS_BITS_64) + #else + #define RZ_SYS_BITS RZ_SYS_BITS_32 + #endif + + #if defined(__BYTE_ORDER__) + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE + #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_BIG + #else + #error "Unsupported endianness" + #endif + #else + #define RZ_SYS_ENDIAN ((*((char *)&(rz_endianness_one)) == 1) ? RZ_SYS_ENDIAN_LITTLE : RZ_SYS_ENDIAN_BIG) + #endif +#elif __arm__ + #define RZ_SYS_ARCH "arm" + #define RZ_SYS_BITS RZ_SYS_BITS_32 + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE +#elif __arm64__ || __aarch64__ + #define RZ_SYS_ARCH "arm" + #define RZ_SYS_BITS (RZ_SYS_BITS_32 | RZ_SYS_BITS_64) + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE +#elif __arc__ + #define RZ_SYS_ARCH "arc" + #define RZ_SYS_BITS RZ_SYS_BITS_32 + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE +#elif __s390x__ + #define RZ_SYS_ARCH "sysz" + #define RZ_SYS_BITS RZ_SYS_BITS_64 + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_BIG +#elif __sparc__ + #define RZ_SYS_ARCH "sparc" + #define RZ_SYS_BITS RZ_SYS_BITS_32 + #if defined(__BYTE_ORDER__) + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE + #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_BIG + #else + #error "Unsupported endianness" + #endif + #else + #define RZ_SYS_ENDIAN ((*((char *)&(rz_endianness_one)) == 1) ? RZ_SYS_ENDIAN_LITTLE : RZ_SYS_ENDIAN_BIG) + #endif +#elif __mips__ + #define RZ_SYS_ARCH "mips" + #define RZ_SYS_BITS RZ_SYS_BITS_32 + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_BIG +#elif __EMSCRIPTEN__ + /* we should default to wasm when ready */ + #define RZ_SYS_ARCH "x86" + #define RZ_SYS_BITS RZ_SYS_BITS_32 +#elif __riscv__ || __riscv + #define RZ_SYS_ARCH "riscv" + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE + #if __riscv_xlen == 32 + #define RZ_SYS_BITS RZ_SYS_BITS_32 + #else + #define RZ_SYS_BITS (RZ_SYS_BITS_32 | RZ_SYS_BITS_64) + #endif +#else + #ifdef _MSC_VER + #if defined(_M_X64) || defined(_M_AMD64) + #define RZ_SYS_ARCH "x86" + #define RZ_SYS_BITS (RZ_SYS_BITS_32 | RZ_SYS_BITS_64) + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE + #define __x86_64__ 1 + #elif defined(_M_IX86) + #define RZ_SYS_ARCH "x86" + #define RZ_SYS_BITS (RZ_SYS_BITS_32) + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE + #define __i386__ 1 + #elif defined(_M_ARM64) + #define RZ_SYS_ARCH "arm" + #define RZ_SYS_BITS (RZ_SYS_BITS_32 | RZ_SYS_BITS_64) + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE + #define __arm64__ 1 + #elif defined(_M_ARM) + #define RZ_SYS_ARCH "arm" + #define RZ_SYS_BITS RZ_SYS_BITS_32 + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE + #define __arm__ 1 + #else + #error "Unhandled Windows architecture." + #endif + #else + #error "Unhandled bits and edianness definitions for this architecture." + #endif +#endif + +#ifndef RZ_SYS_ENDIAN + #error "Endianness for this architecture is not defined. This is no longer valid." +#elif (RZ_SYS_ENDIAN == RZ_SYS_ENDIAN_BI || RZ_SYS_ENDIAN == RZ_SYS_ENDIAN_NONE) + #error "RZ_SYS_ENDIAN_BI or RZ_SYS_ENDIAN_NONE are invalid values for the architecture endianness." +#endif + +// clang-format on + +#define RZ_HOST_IS_LITTLE_ENDIAN (RZ_SYS_ENDIAN == RZ_SYS_ENDIAN_LITTLE) +#define RZ_HOST_IS_BIG_ENDIAN (RZ_SYS_ENDIAN == RZ_SYS_ENDIAN_BIG) + +#include +#include +#include +#include +#include /* for O_RDONLY */ +#include /* needs size_t */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if __WINDOWS__ +#define RZ_SYS_DIR "\\" +#define RZ_SYS_ENVSEP ";" +#define RZ_SYS_HOME "USERPROFILE" +#define RZ_SYS_TMP "TEMP" +#else +#define RZ_SYS_DIR "/" +#define RZ_SYS_ENVSEP ":" +#define RZ_SYS_HOME "HOME" +#define RZ_SYS_TMP "TMPDIR" +#endif + +#define RZ_JOIN_2_PATHS(p1, p2) p1 RZ_SYS_DIR p2 +#define RZ_JOIN_3_PATHS(p1, p2, p3) p1 RZ_SYS_DIR p2 RZ_SYS_DIR p3 +#define RZ_JOIN_4_PATHS(p1, p2, p3, p4) p1 RZ_SYS_DIR p2 RZ_SYS_DIR p3 RZ_SYS_DIR p4 +#define RZ_JOIN_5_PATHS(p1, p2, p3, p4, p5) p1 RZ_SYS_DIR p2 RZ_SYS_DIR p3 RZ_SYS_DIR p4 RZ_SYS_DIR p5 + +#ifndef __packed +#define __packed __attribute__((__packed__)) +#endif + +typedef int (*PrintfCallback)(const char *str, ...) RZ_PRINTF_CHECK(1, 2); + +/* compile-time introspection helpers */ +#define CTO(y, z) ((size_t)&((y *)0)->z) +#define CTA(x, y, z) (x + CTO(y, z)) +#define CTI(x, y, z) (*((size_t *)(CTA(x, y, z)))) +#define CTS(x, y, z, t, v) \ + { \ + t *_ = (t *)CTA(x, y, z); \ + *_ = v; \ + } + +#ifdef RZ_IPI +#undef RZ_IPI +#endif + +#define RZ_IPI + +#ifdef RZ_HEAP +#undef RZ_HEAP +#endif +#define RZ_HEAP + +#ifdef RZ_API +#undef RZ_API +#endif +#ifdef RZ_BINDINGS +#define RZ_API __attribute__((annotate("RZ_API"))) +#else +#if defined(__GNUC__) && __GNUC__ >= 4 +#define RZ_API __attribute__((visibility("default"))) +#elif defined(_MSC_VER) +#define RZ_API __declspec(dllexport) +#else +#define RZ_API +#endif +#endif + +#define RZ_LIB_VERSION_HEADER(x) \ + RZ_API const char *x##_version(void) +#define RZ_LIB_VERSION(x) \ + RZ_API const char *x##_version(void) { \ + return "" RZ_VERSION; \ + } + +#define BITS2BYTES(x) (((x) / 8) + (((x) % 8) ? 1 : 0)) +#define ZERO_FILL(x) memset(&x, 0, sizeof(x)) +#define RZ_NEWS0(x, y) (x *)calloc(y, sizeof(x)) +#define RZ_NEWS(x, y) (x *)malloc(sizeof(x) * (y)) +#define RZ_NEW0(x) (x *)calloc(1, sizeof(x)) +#define RZ_NEW(x) (x *)malloc(sizeof(x)) +#define RZ_NEWCOPY(x, y) (x *)rz_new_copy(sizeof(x), y) + +static inline void *rz_new_copy(int size, const void *data) { + void *a = malloc(size); + if (a) { + memcpy(a, data, size); + } + return a; +} +// TODO: Make RZ_NEW_COPY be 1 arg, not two +#define RZ_NEW_COPY(x, y) \ + x = (void *)malloc(sizeof(y)); \ + memcpy(x, y, sizeof(y)) +#define RZ_MEM_ALIGN(x) ((void *)(size_t)(((ut64)(size_t)x) & 0xfffffffffffff000LL)) +#define RZ_ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#define RZ_PTR_MOVE(d, s) \ + d = s; \ + s = NULL; + +#define RZ_PTR_ALIGN(v, t) \ + ((char *)(((size_t)(v)) & ~(t - 1))) +#define RZ_PTR_ALIGN_NEXT(v, t) \ + ((char *)(((size_t)(v) + (t - 1)) & ~(t - 1))) + +#define RZ_BIT_MASK32(x, y) ((1UL << (x)) - (1UL << (y))) +#define RZ_BIT_MASK64(x, y) ((1ULL << (x)) - (1ULL << (y))) +#define RZ_BIT_SET(x, y) (((ut8 *)x)[y >> 4] |= (1 << (y & 0xf))) +#define RZ_BIT_UNSET(x, y) (((ut8 *)x)[y >> 4] &= ~(1 << (y & 0xf))) +#define RZ_BIT_TOGGLE(x, y) (RZ_BIT_CHK(x, y) ? RZ_BIT_UNSET(x, y) : RZ_BIT_SET(x, y)) + +// #define RZ_BIT_CHK(x,y) ((((const ut8*)x)[y>>4] & (1<<(y&0xf)))) +#define RZ_BIT_CHK(x, y) (*(x) & (1 << (y))) + +/* try for C99, but provide backwards compatibility */ +#if defined(_MSC_VER) && (_MSC_VER <= 1800) +#define __func__ __FUNCTION__ +#endif + +#define PERROR_WITH_FILELINE 0 + +#if PERROR_WITH_FILELINE +/* make error messages useful by prepending file, line, and function name */ +#define _perror(str, file, line, func) \ + { \ + char buf[256]; \ + snprintf(buf, sizeof(buf), "[%s:%d %s] %s", file, line, func, str); \ + rz_sys_perror_str(buf); \ + } +#define perror(x) _perror(x, __FILE__, __LINE__, __func__) +#define rz_sys_perror(x) _perror(x, __FILE__, __LINE__, __func__) +#else +#define rz_sys_perror(x) rz_sys_perror_str(x); +#endif + +#if __UNIX__ +#include +#include +#include +#include +#include +#include +#endif + +#ifndef HAVE_EPRINTF +#define eprintf(...) fprintf(stderr, __VA_ARGS__) +#define HAVE_EPRINTF 1 +#endif + +#ifndef typeof +#define typeof(arg) __typeof__(arg) +#endif + +// There is a bug of using "offsetof()" in the structure +// initialization in GCC < 5.0 versions +#if !(defined(__GNUC__) && __GNUC__ < 5) || defined(__clang__) +#define rz_offsetof(type, member) offsetof(type, member) +#else +#if __WINDOWS__ +#define rz_offsetof(type, member) ((unsigned long)(ut64) & ((type *)0)->member) +#else +#define rz_offsetof(type, member) ((unsigned long)&((type *)0)->member) +#endif +#endif + +#define RZ_FREE(x) \ + { \ + free((void *)x); \ + x = NULL; \ + } + +#define RZ_FREE_CUSTOM(x, y) \ + { \ + y(x); \ + x = NULL; \ + } + +#if __WINDOWS__ +#define PFMT64x "I64x" +#define PFMT64d "I64d" +#define PFMT64u "I64u" +#define PFMT64o "I64o" +#define PFMTSZx "Ix" +#define PFMTSZd "Id" +#define PFMTSZu "Iu" +#define PFMTSZo "Io" +#define LDBLFMTg "g" +#define LDBLFMTf "f" +#define HHXFMT "x" +#else +#define PFMT64x "llx" +#define PFMT64d "lld" +#define PFMT64u "llu" +#define PFMT64o "llo" +#define PFMTSZx "zx" +#define PFMTSZd "zd" +#define PFMTSZu "zu" +#define PFMTSZo "zo" +#define LDBLFMTg "Lg" +#define LDBLFMTf "Lf" +#define HHXFMT "hhx" +#endif + +#define PFMTDPTR "td" + +#define PFMT32x "x" +#define PFMT32d "d" +#define PFMT32u "u" +#define PFMT32o "o" + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +typedef enum { + RZ_SYS_ARCH_NONE = 0, + RZ_SYS_ARCH_X86, + RZ_SYS_ARCH_ARM, + RZ_SYS_ARCH_PPC, + RZ_SYS_ARCH_M68K, + RZ_SYS_ARCH_JAVA, + RZ_SYS_ARCH_MIPS, + RZ_SYS_ARCH_SPARC, + RZ_SYS_ARCH_XAP, + RZ_SYS_ARCH_MSIL, + RZ_SYS_ARCH_OBJD, + RZ_SYS_ARCH_BF, + RZ_SYS_ARCH_SH, + RZ_SYS_ARCH_AVR, + RZ_SYS_ARCH_DALVIK, + RZ_SYS_ARCH_Z80, + RZ_SYS_ARCH_ARC, + RZ_SYS_ARCH_I8080, + RZ_SYS_ARCH_RAR, + RZ_SYS_ARCH_8051, + RZ_SYS_ARCH_TMS320, + RZ_SYS_ARCH_EBC, + RZ_SYS_ARCH_H8300, + RZ_SYS_ARCH_CR16, + RZ_SYS_ARCH_V850, + RZ_SYS_ARCH_SYSZ, + RZ_SYS_ARCH_XCORE, + RZ_SYS_ARCH_PROPELLER, + RZ_SYS_ARCH_MSP430, + RZ_SYS_ARCH_CRIS, + RZ_SYS_ARCH_HPPA, + RZ_SYS_ARCH_V810, + RZ_SYS_ARCH_LM32, + RZ_SYS_ARCH_RISCV, + RZ_SYS_ARCH_TRICORE, +} RzSysArch; + +/* os */ +#if defined(__QNX__) +#define RZ_SYS_OS "qnx" +// #elif TARGET_OS_IPHONE +// #define RZ_SYS_OS "ios" +#elif defined(__APPLE__) +#define RZ_SYS_OS "darwin" +#elif defined(__linux__) +#define RZ_SYS_OS "linux" +#elif defined(__WINDOWS__) +#define RZ_SYS_OS "windows" +#elif defined(__NetBSD__) +#define RZ_SYS_OS "netbsd" +#elif defined(__OpenBSD__) +#define RZ_SYS_OS "openbsd" +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#define RZ_SYS_OS "freebsd" +#elif defined(__HAIKU__) +#define RZ_SYS_OS "haiku" +#else +#define RZ_SYS_OS "unknown" +#endif + +#ifdef __cplusplus +} +#endif + +static inline void rz_run_call1(void *fcn, void *arg1) { + ((void (*)(void *))(fcn))(arg1); +} + +static inline void rz_run_call2(void *fcn, void *arg1, void *arg2) { + ((void (*)(void *, void *))(fcn))(arg1, arg2); +} + +static inline void rz_run_call3(void *fcn, void *arg1, void *arg2, void *arg3) { + ((void (*)(void *, void *, void *))(fcn))(arg1, arg2, arg3); +} + +static inline void rz_run_call4(void *fcn, void *arg1, void *arg2, void *arg3, void *arg4) { + ((void (*)(void *, void *, void *, void *))(fcn))(arg1, arg2, arg3, arg4); +} + +static inline void rz_run_call5(void *fcn, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5) { + ((void (*)(void *, void *, void *, void *, void *))(fcn))(arg1, arg2, arg3, arg4, arg5); +} + +static inline void rz_run_call6(void *fcn, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, + void *arg6) { + ((void (*)(void *, void *, void *, void *, void *, void *))(fcn))(arg1, arg2, arg3, arg4, arg5, arg6); +} + +static inline void rz_run_call7(void *fcn, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, + void *arg6, void *arg7) { + ((void (*)(void *, void *, void *, void *, void *, void *, void *))(fcn))(arg1, arg2, arg3, arg4, arg5, arg6, arg7); +} + +static inline void rz_run_call8(void *fcn, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, + void *arg6, void *arg7, void *arg8) { + ((void (*)(void *, void *, void *, void *, void *, void *, void *, void *))(fcn))(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); +} + +static inline void rz_run_call9(void *fcn, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, + void *arg6, void *arg7, void *arg8, void *arg9) { + ((void (*)(void *, void *, void *, void *, void *, void *, void *, void *, void *))(fcn))(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); +} + +static inline void rz_run_call10(void *fcn, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, + void *arg6, void *arg7, void *arg8, void *arg9, void *arg10) { + ((void (*)(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *))(fcn))(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); +} + +#define RZ_V_NOT(op, fail_ret) \ + if ((op) == (fail_ret)) \ + RZ_LOG_WARN(#op " at %s:%d failed: %s\n", __FILE__, __LINE__, strerror(errno)) +#define rz_xwrite(fd, buf, count) RZ_V_NOT(write(fd, buf, count), -1) +#define rz_xread(fd, buf, count) RZ_V_NOT(read(fd, buf, count), -1) +#define rz_xfreopen(pathname, mode, stream) RZ_V_NOT(freopen(pathname, mode, stream), NULL) + +#ifndef container_of +#ifdef _MSC_VER +#define container_of(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member))) +#else +#define container_of(ptr, type, member) ((type *)((char *)(__typeof__(((type *)0)->member) *){ ptr } - offsetof(type, member))) +#endif +#endif + +// reference counter +typedef int RzRef; + +#define RZ_REF_NAME refcount +#define rz_ref(x) x->RZ_REF_NAME++; +#define rz_ref_init(x) x->RZ_REF_NAME = 1 +#define rz_unref(x, f) \ + { \ + assert(x->RZ_REF_NAME > 0); \ + if (!--(x->RZ_REF_NAME)) { \ + f(x); \ + } \ + } + +#define RZ_REF_TYPE RzRef RZ_REF_NAME +#define RZ_REF_FUNCTIONS(s, n) \ + static inline void n##_ref(s *x) { \ + x->RZ_REF_NAME++; \ + } \ + static inline void n##_unref(s *x) { \ + rz_unref(x, n##_free); \ + } + +typedef struct rz_core_t RzCore; + +// Mimics order in RzCore. +struct dummy_rz_core_t { + void *rasm; + ut8 ptr_alignment_I; + void *analysis; + ut8 ptr_alignment_II; + void *bin; + ut8 ptr_alignment_III; +}; + +// Mimics order in RzAsm. +struct dummy_rz_asm_t { + void *core; + ut8 ptr_alignment_I; + void *plugin_data; + ut8 ptr_alignment_II; +}; + +// Mimics order in RzAnalysis. +struct dummy_rz_analysis_t { + void *core; + ut8 ptr_alignment_I; +}; + +/** + * \brief The hacky way to get the RzAsm pointer from RzAnalysis. + * Will be removed with the RzArch refactor. + */ +static inline void /**/ *rz_analysis_to_rz_asm(RZ_NONNULL void /**/ *rz_analysis) { + assert(rz_analysis && "This function can only be used if RzAnalysis and RzAsm were set up before."); + struct dummy_rz_analysis_t *analysis = (struct dummy_rz_analysis_t *)rz_analysis; + struct dummy_rz_core_t *core = (struct dummy_rz_core_t *)analysis->core; + if (!core) { + return NULL; + } + void *rasm = core->rasm; + assert(rasm && "This function can only be used if RzAnalysis and RzAsm were set up before."); + return rasm; +} + +/** + * \brief The hacky way to get the RzAnalysis pointer from RzAsm. + * Will be removed with the RzArch refactor. + */ +static inline void /**/ *rz_asm_to_rz_analysis(RZ_NONNULL void /**/ *rz_asm) { + assert(rz_asm && "This function can only be used if RzAnalysis and RzAsm were set up before."); + struct dummy_rz_asm_t *rasm = (struct dummy_rz_asm_t *)rz_asm; + struct dummy_rz_core_t *core = (struct dummy_rz_core_t *)rasm->core; + if (!core) { + return NULL; + } + void *analysis = core->analysis; + return analysis; +} + +/** + * \brief The hacky way to get the plugin data from RzAsm via RzAnalysis. + * Will be removed with the RzArch refactor. + */ +static inline void *rz_asm_plugin_data_from_rz_analysis(RZ_NONNULL void /**/ *rz_analysis) { + assert(rz_analysis && "This function can only be used if RzAnalysis and RzAsm were set up before."); + struct dummy_rz_asm_t *rasm = (struct dummy_rz_asm_t *)rz_analysis_to_rz_asm(rz_analysis); + assert(rasm && "This function can only be used if RzAnalysis and RzAsm were set up before."); + return rasm->plugin_data; +} + +#ifdef __cplusplus +} +#endif + +#endif // RZ_TYPES_H diff --git a/dest/include/librz/rz_types_base.h b/dest/include/librz/rz_types_base.h new file mode 100644 index 00000000000..865518945ac --- /dev/null +++ b/dest/include/librz/rz_types_base.h @@ -0,0 +1,234 @@ +#ifndef RZ_TYPES_BASE_H +#define RZ_TYPES_BASE_H + +#include +#include +#include + +#if defined(_MSC_VER) +// required to forbid the declaration +// of __ucrt_int_to_float which is +// included from 10.0.25182.0, where +// `math.h` includes `corecrt_math.h` +#define __midl +#endif +#include +#if defined(_MSC_VER) +// remove __midl +#undef __midl +#endif + +#define cut8 const unsigned char +#define ut64 unsigned long long +#define st64 long long +#define ut32 unsigned int +#define st32 int +#define ut16 unsigned short +#define st16 short +#define ut8 unsigned char +#define st8 signed char +#define utptr uintptr_t +#define boolt int + +#if defined(_MSC_VER) +typedef intptr_t ssize_t; +#endif + +#if defined(_MSC_VER) +#define RZ_ALIGNED(x) __declspec(align(x)) +#else +#define RZ_ALIGNED(x) __attribute__((aligned(x))) +#endif + +typedef struct _ut80 { + ut64 Low; + ut16 High; +} ut80; +typedef struct _ut96 { + ut64 Low; + ut32 High; +} ut96; +typedef struct _ut128 { + ut64 Low; + ut64 High; +} ut128; +typedef struct _ut256 { + ut128 Low; + ut128 High; +} ut256; +typedef struct _utX { + ut80 v80; + ut96 v96; + ut128 v128; + ut256 v256; +} utX; + +#include + +#define RZ_EMPTY \ + { 0 } +#define RZ_EMPTY2 \ + { \ + { 0 } \ + } + +/* limits */ +#undef UT64_MAX +#undef UT64_GT0 +#undef UT64_LT0 +#undef UT64_MIN +#undef UT32_MAX +#undef UT32_MIN +#undef UT16_MIN +#undef UT8_MIN +#define ST64_MAX ((st64)0x7FFFFFFFFFFFFFFFULL) +#define ST64_MIN ((st64)(-ST64_MAX - 1)) +#define UT64_MAX 0xFFFFFFFFFFFFFFFFULL +#define UT64_GT0 0x8000000000000000ULL +#define UT64_LT0 0x7FFFFFFFFFFFFFFFULL +#define UT64_MIN 0ULL +#define UT64_32U 0xFFFFFFFF00000000ULL +#define UT64_16U 0xFFFFFFFFFFFF0000ULL +#define UT64_8U 0xFFFFFFFFFFFFFF00ULL +#define UT32_MIN 0U +#define UT16_MIN 0U +#define UT32_GT0 0x80000000U +#define UT32_LT0 0x7FFFFFFFU +#define ST32_MAX 0x7FFFFFFF +#define ST32_MIN (-ST32_MAX - 1) +#define UT32_MAX 0xFFFFFFFFU +#define ST16_MAX 0x7FFF +#define ST16_MIN (-ST16_MAX - 1) +#define UT16_GT0 0x8000U +#define UT16_MAX 0xFFFFU +#define ST8_MAX 0x7F +#define ST8_MIN (-ST8_MAX - 1) +#define UT8_GT0 0x80U +#define UT8_MAX 0xFFU +#define UT8_MIN 0x00U +#define ASCII_MIN 32 +#define ASCII_MAX 127 + +#if SSIZE_MAX == ST32_MAX +#define SZT_MAX UT32_MAX +#define SZT_MIN UT32_MIN +#define SSZT_MAX ST32_MAX +#define SSZT_MIN ST32_MIN +#else +#define SZT_MAX UT64_MAX +#define SZT_MIN UT64_MIN +#define SSZT_MAX ST64_MAX +#define SSZT_MIN ST64_MIN +#endif + +#define UT64_ALIGN(x) (x + (x - (x % sizeof(ut64)))) +#define UT32_ALIGN(x) (x + (x - (x % sizeof(ut32)))) +#define UT16_ALIGN(x) (x + (x - (x % sizeof(ut16)))) + +#define UT32_LO(x) ((ut32)((x) & UT32_MAX)) +#define UT32_HI(x) ((ut32)(((ut64)(x)) >> 32) & UT32_MAX) + +#define RZ_BETWEEN(x, y, z) (((y) >= (x)) && ((y) <= (z))) +#define RZ_BETWEEN_EXCL(x, y, z) (((y) >= (x)) && ((y) < (z))) +#define RZ_ROUND(x, y) ((x) % (y)) ? (x) + ((y) - ((x) % (y))) : (x) +#define RZ_DIM(x, y, z) (((x) < (y)) ? (y) : ((x) > (z)) ? (z) \ + : (x)) +#ifndef RZ_MAX_DEFINED +#define RZ_MAX(x, y) (((x) > (y)) ? (x) : (y)) +#define RZ_MAX_DEFINED +#endif +#ifndef RZ_MIN_DEFINED +#define RZ_MIN(x, y) (((x) > (y)) ? (y) : (x)) +#define RZ_MIN_DEFINED +#endif +#define RZ_ABS(x) (((x) < 0) ? -(x) : (x)) +#define RZ_BTW(x, y, z) (((x) >= (y)) && ((y) <= (z))) ? y : x + +#include "rz_types_overflow.h" + +/* copied from bithacks.h */ +#define B_IS_SET(x, n) (((x) & (1ULL << (n))) ? 1 : 0) +#define B_SET(x, n) ((x) |= (1ULL << (n))) +#define B_EVEN(x) (((x) & 1) == 0) +#define B_ODD(x) (!B_EVEN((x))) +#define B_UNSET(x, n) ((x) &= ~(1ULL << (n))) +#define B_TOGGLE(x, n) ((x) ^= (1ULL << (n))) + +#define B11111 31 +#define B11110 30 +#define B11101 29 +#define B11100 28 +#define B11011 27 +#define B11010 26 +#define B11001 25 +#define B11000 24 +#define B10111 23 +#define B10110 22 +#define B10101 21 +#define B10100 20 +#define B10011 19 +#define B10010 18 +#define B10001 17 +#define B10000 16 +#define B1111 15 +#define B1110 14 +#define B1101 13 +#define B1100 12 +#define B1011 11 +#define B1010 10 +#define B1001 9 +#define B1000 8 +#define B0111 7 +#define B0110 6 +#define B0101 5 +#define B0100 4 +#define B0011 3 +#define B0010 2 +#define B0001 1 +#define B0000 0 +#undef B +#define B4(a, b, c, d) ((a << 12) | (b << 8) | (c << 4) | (d)) + +/* portable non-c99 inf/nan types */ +#if !defined(INFINITY) +#define INFINITY (1.0f / 0.0f) +#endif + +#if !defined(NAN) +#define NAN (0.0f / 0.0f) +#endif + +/* A workaround against libc headers redefinition of __attribute__: + * Standard include has lines like + * #if (GCC_VERSION < 2007) + * # define __attribute__(x) + * #endif + * So we have do remove this define for TinyCC compiler + */ +#if defined(__TINYC__) && (GCC_VERSION < 2007) +#undef __attribute__ +#endif + +#ifdef _MSC_VER +#define RZ_PACKED(__Declaration__) __pragma(pack(push, 1)) __Declaration__ __pragma(pack(pop)) +#undef INFINITY +#undef NAN +#elif defined(__GNUC__) || defined(__TINYC__) +#define RZ_PACKED(__Declaration__) __Declaration__ __attribute__((__packed__)) +#endif + +#if APPLE_SDK_IPHONESIMULATOR +#undef DEBUGGER +#define DEBUGGER 0 +#endif + +#define HEAPTYPE(x) \ + static x *x##_new(x n) { \ + x *m = malloc(sizeof(x)); \ + return m ? *m = n, m : m; \ + } + +#define RZ_STR_DEF(s) RZ_STR(s) +#define RZ_STR(s) #s + +#endif // RZ_TYPES_BASE_H diff --git a/dest/include/librz/rz_types_overflow.h b/dest/include/librz/rz_types_overflow.h new file mode 100644 index 00000000000..c246d75c83a --- /dev/null +++ b/dest/include/librz/rz_types_overflow.h @@ -0,0 +1,86 @@ +#ifndef RZ_TYPES_OVERFLOW_H +#define RZ_TYPES_OVERFLOW_H + +#include + +// TODO: Use CLANG/GCC builtins if available: __builtin_mul_overflow + +// ADD +// if ((x > 0) && (a > INT_MAX - x)) /* `a + x` would overflow */; +// if ((x < 0) && (a < INT_MIN - x)) /* `a + x` would underflow */; +#define SZT_ADD_OVFCHK(x, y) ((SIZE_MAX - (x)) < (y)) +#define SSZT_ADD_OVFCHK(a, x) ((((x) > 0) && ((a) > SSIZE_MAX - (x))) || (((x) < 0) && (a) < SSIZE_MIN - (x))) +#define UT64_ADD_OVFCHK(x, y) ((UT64_MAX - (x)) < (y)) +#define ST64_ADD_OVFCHK(a, x) ((((x) > 0) && ((a) > ST64_MAX - (x))) || (((x) < 0) && (a) < ST64_MIN - (x))) +#define UT32_ADD_OVFCHK(x, y) ((UT32_MAX - (x)) < (y)) +#define ST32_ADD_OVFCHK(a, x) ((((x) > 0) && ((a) > ST32_MAX - (x))) || (((x) < 0) && (a) < ST32_MIN - (x))) +#define UT16_ADD_OVFCHK(x, y) ((UT16_MAX - (x)) < (y)) +#define ST16_ADD_OVFCHK(a, b) ((((b) > 0) && ((a) > ST16_MAX - (b))) || (((b) < 0) && ((a) < ST16_MIN - (b)))) +#define UT8_ADD_OVFCHK(x, y) ((UT8_MAX - (x)) < (y)) +#define ST8_ADD_OVFCHK(a, x) ((((x) > 0) && ((a) > ST8_MAX - (x))) || ((x) < 0 && (a) < ST8_MIN - (x))) + +// SUB +// if ((x < 0) && (a > INT_MAX + x)) /* `a - x` would overflow */; +// if ((x > 0) && (a < INT_MIN + x)) /* `a - x` would underflow */; +#define SZT_SUB_OVFCHK(a, b) SZT_ADD_OVFCHK(a, -(b)) +#define SSZT_SUB_OVFCHK(a, b) SSZT_ADD_OVFCHK(a, -(b)) +#define UT64_SUB_OVFCHK(a, b) UT64_ADD_OVFCHK(a, -(b)) +#define ST64_SUB_OVFCHK(a, b) ST64_ADD_OVFCHK(a, -(b)) +#define UT32_SUB_OVFCHK(a, b) UT32_ADD_OVFCHK(a, -(b)) +#define ST32_SUB_OVFCHK(a, b) ST32_ADD_OVFCHK(a, -(b)) +#define UT16_SUB_OVFCHK(a, b) UT16_ADD_OVFCHK(a, -(b)) +#define ST16_SUB_OVFCHK(a, b) ST16_ADD_OVFCHK(a, -(b)) +#define UT8_SUB_OVFCHK(a, b) UT8_ADD_OVFCHK(a, -(b)) +#define ST8_SUB_OVFCHK(a, b) ST8_ADD_OVFCHK(a, -(b)) + +// MUL +#define UNSIGNED_MUL_OVERFLOW_CHECK(overflow_name, type_base, type_min, type_max) \ + static inline bool overflow_name(type_base a, type_base b) { \ + return (a > 0 && b > 0 && a > type_max / b); \ + } + +#define SIGNED_MUL_OVERFLOW_CHECK(overflow_name, type_base, type_min, type_max) \ + static inline bool overflow_name(type_base a, type_base b) { \ + if (a > 0) { \ + if (b > 0) { \ + return a > type_max / b; \ + } \ + return b < type_min / a; \ + } \ + if (b > 0) { \ + return a < type_min / b; \ + } \ + return a && b < type_max / a; \ + } + +#define SIGNED_DIV_OVERFLOW_CHECK(overflow_name, type_base, type_mid, type_max) \ + static inline bool overflow_name(type_base a, type_base b) { \ + return (!b || (a == type_mid && b == type_max)); \ + } +#define UNSIGNED_DIV_OVERFLOW_CHECK(overflow_name, type_base, type_min, type_max) \ + static inline bool overflow_name(type_base a, type_base b) { \ + (void)a; \ + return !b; \ + } + +SIGNED_DIV_OVERFLOW_CHECK(ST8_DIV_OVFCHK, ut8, UT8_GT0, UT8_MAX) +SIGNED_DIV_OVERFLOW_CHECK(ST16_DIV_OVFCHK, ut16, UT16_GT0, UT16_MAX) +SIGNED_DIV_OVERFLOW_CHECK(ST32_DIV_OVFCHK, ut32, UT32_GT0, UT32_MAX) +SIGNED_DIV_OVERFLOW_CHECK(ST64_DIV_OVFCHK, ut64, UT64_GT0, UT64_MAX) +UNSIGNED_DIV_OVERFLOW_CHECK(UT8_DIV_OVFCHK, ut8, UT8_MIN, UT8_MAX) +UNSIGNED_DIV_OVERFLOW_CHECK(UT16_DIV_OVFCHK, ut16, UT16_MIN, UT16_MAX) +UNSIGNED_DIV_OVERFLOW_CHECK(UT32_DIV_OVFCHK, ut32, UT32_MIN, UT32_MAX) +UNSIGNED_DIV_OVERFLOW_CHECK(UT64_DIV_OVFCHK, ut64, UT64_MIN, UT64_MAX) +// TODO: Windows doesn't have ssize_t, and we don't need this check yet +// SIGNED_MUL_OVERFLOW_CHECK(SSZT_MUL_OVFCHK, ssize_t, SSZT_MIN, SSZT_MAX) +SIGNED_MUL_OVERFLOW_CHECK(ST8_MUL_OVFCHK, st8, ST8_MIN, ST8_MAX) +SIGNED_MUL_OVERFLOW_CHECK(ST16_MUL_OVFCHK, st16, ST16_MIN, ST16_MAX) +SIGNED_MUL_OVERFLOW_CHECK(ST32_MUL_OVFCHK, st32, ST32_MIN, ST32_MAX) +SIGNED_MUL_OVERFLOW_CHECK(ST64_MUL_OVFCHK, st64, ST64_MIN, ST64_MAX) +UNSIGNED_MUL_OVERFLOW_CHECK(SZT_MUL_OVFCHK, size_t, SZT_MIN, SZT_MAX) +UNSIGNED_MUL_OVERFLOW_CHECK(UT8_MUL_OVFCHK, ut8, UT8_MIN, UT8_MAX) +UNSIGNED_MUL_OVERFLOW_CHECK(UT16_MUL_OVFCHK, ut16, UT16_MIN, UT16_MAX) +UNSIGNED_MUL_OVERFLOW_CHECK(UT32_MUL_OVFCHK, ut32, UT32_MIN, UT32_MAX) +UNSIGNED_MUL_OVERFLOW_CHECK(UT64_MUL_OVFCHK, ut64, UT64_MIN, UT64_MAX) + +#endif diff --git a/dest/include/librz/rz_userconf.h b/dest/include/librz/rz_userconf.h new file mode 100644 index 00000000000..9792d86222a --- /dev/null +++ b/dest/include/librz/rz_userconf.h @@ -0,0 +1,120 @@ +#ifndef RZ_CONFIGURE_H +#define RZ_CONFIGURE_H + +#include "rz_build_version.h" + +// clang-format off +#define RZ_CHECKS_LEVEL 2 +#define DEBUGGER 1 +#define HAVE_THREADS 1 +#define HAVE_PTHREAD 0 +#define HAVE_LZMA 1 +#define HAVE_ZLIB 1 +#define HAVE_DECL_ADDR_NO_RANDOMIZE 0 +#define HAVE_DECL_PROCCTL_ASLR_CTL 0 +#define HAVE_ARC4RANDOM 0 +#define HAVE_ARC4RANDOM_UNIFORM 0 +#define HAVE_EXPLICIT_BZERO 0 +#define HAVE_EXPLICIT_MEMSET 0 +#define HAVE_CLOCK_NANOSLEEP 0 +#define HAVE_SIGACTION 0 +#define HAVE_PIPE 0 +#define HAVE_EXECV 0 +#define HAVE_EXECVE 0 +#define HAVE_EXECVP 0 +#define HAVE_EXECL 0 +#define HAVE_SYSTEM 1 +#define HAVE_REALPATH 0 +#define HAVE_PIPE2 0 +#define HAVE_ENVIRON 1 +#define HAVE_OPENPTY 0 +#define HAVE_FORKPTY 0 +#define HAVE_LOGIN_TTY 0 +#define HAVE_SHM_OPEN 0 +#define HAVE_LIB_MAGIC 0 +#define USE_LIB_MAGIC 0 +#define HAVE_LIB_XXHASH 1 +#define USE_LIB_XXHASH 1 +#define USE_SYS_ZYDIS 0 +#define HAVE_LIB_SSL 0 +#define HAVE_PTRACE 0 +#define USE_PTRACE_WRAP 0 +#define HAVE_FORK 0 +#define HAVE_STRLCPY 0 +#define HAVE_STRLCAT 0 +#define HAVE_STRNLEN 1 +#define WANT_DYLINK 1 +#define WITH_GPL 1 +#define HAVE_JEMALLOC 0 +#define IS_IOS 0 +#define RZ_BUILD_DEBUG 1 +#define N_THREAD_LIMIT 32767 +#define HAVE_COPYFILE 0 +#define HAVE_COPY_FILE_RANGE 0 +#define HAVE_BACKTRACE 0 +#define HAVE___BUILTIN_BSWAP16 0 +#define HAVE___BUILTIN_BSWAP32 0 +#define HAVE___BUILTIN_BSWAP64 0 +#define HAVE___BUILTIN_CLZLL 0 +#define HAVE___BUILTIN_CTZLL 0 +#define HAVE_POSIX_MEMALIGN 0 +#define HAVE__ALIGNED_MALLOC 1 + +#define HAVE_HEADER_LINUX_ASHMEM_H 0 +#define HAVE_HEADER_SYS_SHM_H 0 +#define HAVE_HEADER_SYS_IPC_H 0 +#define HAVE_HEADER_SYS_MMAN_H 0 +#define HAVE_HEADER_INTTYPES_H 1 + +#define RZ_IS_PORTABLE 0 + +#define RZ_BINDIR_DEPTH 1 +// clang-format on + +#define RZ_PREFIX "C:\\Farhan\\rizin\\dest" +#define RZ_BINDIR "bin" +#define RZ_LIBDIR "lib" +#define RZ_INCDIR "include\\librz" +#define RZ_DATDIR "share" + +#define RZ_WWWROOT "share\\www" +#define RZ_PLUGINS "lib\\rizin\\plugins" +#define RZ_DATADIR "share" +#define RZ_SDB "share" +#define RZ_SIGDB "share\\sigdb" +#define RZ_THEMES "share\\cons" +#define RZ_FORTUNES "share\\fortunes" +#define RZ_FLAGS "share\\flag" +#define RZ_HUD "share\\hud" + +#define RZ_SDB_ARCH_PLATFORMS RZ_JOIN_3_PATHS(RZ_SDB, "arch", "platforms") +#define RZ_SDB_ARCH_CPUS RZ_JOIN_3_PATHS(RZ_SDB, "asm", "cpus") +#define RZ_SDB_TYPES RZ_JOIN_2_PATHS(RZ_SDB, "types") +#define RZ_SDB_OPCODES RZ_JOIN_2_PATHS(RZ_SDB, "opcodes") +#define RZ_SDB_REG RZ_JOIN_2_PATHS(RZ_SDB, "reg") +#define RZ_SDB_MAGIC RZ_JOIN_2_PATHS(RZ_SDB, "magic") +#define RZ_SDB_FORMAT RZ_JOIN_2_PATHS(RZ_SDB, "format") +#define RZ_PDB RZ_JOIN_2_PATHS(RZ_DATADIR, "pdb") +#define RZ_PROJECTS RZ_JOIN_2_PATHS(RZ_DATADIR, "projects") +#define RZ_BINRC RZ_JOIN_2_PATHS(RZ_DATADIR, "rc.d") + +#define RZ_HOME_PREFIX ".local" +#define RZ_HOME_CONFIGDIR RZ_JOIN_2_PATHS(".config", "rizin") +#define RZ_HOME_CACHEDIR RZ_JOIN_2_PATHS(".cache", "rizin") + +#define RZ_HOME_HISTORY RZ_JOIN_2_PATHS(RZ_HOME_CACHEDIR, "history") + +#define RZ_HOME_CONFIG_RC RZ_JOIN_2_PATHS(RZ_HOME_CONFIGDIR, "rizinrc") +#define RZ_HOME_CONFIG_RC_DIR RZ_JOIN_2_PATHS(RZ_HOME_CONFIGDIR, "rizinrc.d") +#define RZ_GLOBAL_RC RZ_JOIN_2_PATHS(RZ_DATADIR, "rizinrc") +#define RZ_HOME_RC ".rizinrc" + +// This is an optional extra prefix used to load plugins, sdb files, sdb files, +// etc. It can be outside the default prefix. Used e.g. by Homebrew to load +// plugins from the general /opt/homebrew prefix instead of the version specific +// prefix e.g. /opt/homebrew/Cellar/rizin/0.x.y/ +// clang-format off +#define RZ_EXTRA_PREFIX 0 +// clang-format on + +#endif diff --git a/dest/include/librz/rz_util.h b/dest/include/librz/rz_util.h new file mode 100644 index 00000000000..1e5280f5e84 --- /dev/null +++ b/dest/include/librz/rz_util.h @@ -0,0 +1,98 @@ +// SPDX-FileCopyrightText: 2008-2016 pancake +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_UTIL_H +#define RZ_UTIL_H + +#include +#include +#include +#include // rizin linked list +#include // skiplist +#include +#if !__WINDOWS__ +#include +#include +#endif +#ifdef HAVE_LIB_GMP +#include +#endif +#if HAVE_LIB_SSL +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// requires io, core, ... #include "rz_util/rz_print.h" + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_LIB_VERSION_HEADER(rz_util); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/ht_inc.h b/dest/include/librz/rz_util/ht_inc.h new file mode 100644 index 00000000000..4cdff7bbb2d --- /dev/null +++ b/dest/include/librz/rz_util/ht_inc.h @@ -0,0 +1,222 @@ +// SPDX-FileCopyrightText: 2016-2018 crowell +// SPDX-FileCopyrightText: 2016-2018 pancake +// SPDX-FileCopyrightText: 2016-2018 ret2libc +// SPDX-FileCopyrightText: 2024 pelijah +// SPDX-License-Identifier: BSD-3-Clause + +#include + +#ifndef HT_TYPE +#error HT_TYPE should be defined before including this header +#endif + +#undef HtName_ +#undef Ht_ +#undef HT_ +#undef KEY_TYPE +#undef VALUE_TYPE +#undef KEY_TO_HASH +#undef HT_NULL_VALUE + +#if HT_TYPE == 1 +// Hash table HtPP that has void* as key and void* as value +#define HtName_(name) name##PP +#define Ht_(name) ht_pp_##name +#define HT_(name) HtPP##name +#define KEY_TYPE void * +#define VALUE_TYPE void * +#define KEY_TO_HASH(x) ((ut32)(uintptr_t)(x)) +#define HT_NULL_VALUE NULL +#elif HT_TYPE == 2 +// Hash table HtPU that has void* as key and ut64 as value +#define HtName_(name) name##UP +#define Ht_(name) ht_up_##name +#define HT_(name) HtUP##name +#define KEY_TYPE ut64 +#define VALUE_TYPE void * +#define KEY_TO_HASH(x) ((ut32)(x)) +#define HT_NULL_VALUE 0 +#elif HT_TYPE == 3 +// Hash table HtUU that has ut64 as key and ut64 as value +#define HtName_(name) name##UU +#define Ht_(name) ht_uu_##name +#define HT_(name) HtUU##name +#define KEY_TYPE ut64 +#define VALUE_TYPE ut64 +#define KEY_TO_HASH(x) ((ut32)(x)) +#define HT_NULL_VALUE 0 +#elif HT_TYPE == 4 +// Hash table HtPU that has void* as key and ut64 as value +#define HtName_(name) name##PU +#define Ht_(name) ht_pu_##name +#define HT_(name) HtPU##name +#define KEY_TYPE void * +#define VALUE_TYPE ut64 +#define KEY_TO_HASH(x) ((ut32)(uintptr_t)(x)) +#define HT_NULL_VALUE 0 +#elif HT_TYPE == 5 +// Hash table HtSP that has C-string as key and void* as value +#define HtName_(name) name##SP +#define Ht_(name) ht_sp_##name +#define HT_(name) HtSP##name +#define KEY_TYPE char * +#define VALUE_TYPE void * +#define KEY_TO_HASH(x) ((ut32)(uintptr_t)(x)) +#define HT_NULL_VALUE NULL +#elif HT_TYPE == 6 +// Hash table HtSS that has C-string as key and C-string as value +#define HtName_(name) name##SS +#define Ht_(name) ht_ss_##name +#define HT_(name) HtSS##name +#define KEY_TYPE char * +#define VALUE_TYPE char * +#define KEY_TO_HASH(x) ((ut32)(uintptr_t)(x)) +#define HT_NULL_VALUE NULL +#elif HT_TYPE == 7 +// Hash table HtSU that has C-string as key and ut64 as value +#define HtName_(name) name##SU +#define Ht_(name) ht_su_##name +#define HT_(name) HtSU##name +#define KEY_TYPE char * +#define VALUE_TYPE ut64 +#define KEY_TO_HASH(x) ((ut32)(uintptr_t)(x)) +#define HT_NULL_VALUE 0 +#endif + +#ifndef HT_ENUM_DEFINED +#define HT_ENUM_DEFINED +/** + * Return codes for insert/update methods + * code < 0 <--> code == HT_RC_ERROR + * code >= 0 <--> code != HT_RC_ERROR + * code > 0 <--> code == HT_RC_INSERTED || code == HT_RC_UPDATED + */ +typedef enum { + HT_RC_ERROR = -1, ///< Error (out of memory) + HT_RC_EXISTING = 0, ///< Existing KV prevented an insertion + HT_RC_INSERTED = 1, ///< New KV was inserted during insert/update operation + HT_RC_UPDATED = 2, ///< Existing KV was updated during update operation +} HtRetCode; + +typedef enum { + HT_STR_DUP = 0, ///< String is copied when inserting into HT + HT_STR_OWN, ///< String ownership is transferred when inserting into HT + HT_STR_CONST ///< String is treated as constant and not copied when inserting into HT +} HtStrOption; +#endif + +#include + +/* Kv represents a single key/value element in the hashtable */ +typedef struct Ht_(kv) { + KEY_TYPE key; + VALUE_TYPE value; + ut32 key_len; + ut32 value_len; +} HT_(Kv); + +typedef void (*HT_(FiniKv))(HT_(Kv) *kv, void *user); +typedef KEY_TYPE (*HT_(DupKey))(const KEY_TYPE); +typedef VALUE_TYPE (*HT_(DupValue))(const VALUE_TYPE); +typedef void (*HT_(FreeValue))(VALUE_TYPE val); +typedef ut32 (*HT_(CalcSizeK))(const KEY_TYPE); +typedef ut32 (*HT_(CalcSizeV))(const VALUE_TYPE); +typedef ut32 (*HT_(HashFunction))(const KEY_TYPE); +typedef int (*HT_(Comparator))(const KEY_TYPE, const KEY_TYPE); +typedef bool (*HT_(ForeachCallback))(void *user, const KEY_TYPE, const VALUE_TYPE); + +typedef struct Ht_(bucket_t) { + HT_(Kv) *arr; + ut32 count; +} HT_(Bucket); + +/** + * Options contain all the settings of the hashtable. + */ +typedef struct Ht_(options_t) { + HT_(Comparator) cmp; ///< RZ_NULLABLE. Function for comparing keys. + ///< Returns 0 if keys are equal. + ///< Function is invoked only if == operator applied to keys returns false. + HT_(HashFunction) hashfn; ///< RZ_NULLABLE. Function for hashing items in the hash table. + ///< If NULL KEY_TO_HASH macro is used. + HT_(DupKey) dupkey; ///< RZ_NULLABLE. Function for making a copy of key. + ///< If NULL simple assignment operator is used. + HT_(DupValue) dupvalue; ///< RZ_NULLABLE. Function for making a copy of value. + ///< If NULL simple assignment operator is used. + HT_(CalcSizeK) calcsizeK; ///< RZ_NULLABLE. Function to determine the key's size. + ///< If NULL zero value is used as a size. + ///< Key sizes are checked on equality during keys comparsion as a pre-check. + HT_(CalcSizeV) calcsizeV; ///< RZ_NULLABLE. Function to determine the value's size. + ///< If NULL zero value is used as a size. + ///< Not required for common scenarios. Could be used in subclasses. + HT_(FiniKv) finiKV; ///< RZ_NULLABLE. Function to clean up the key-value store. + void *finiKV_user; ///< RZ_NULLABLE. User data which is passed into finiKV. + size_t elem_size; ///< Size of each HtKv element (useful for subclassing like SdbKv). + ///< Zero value means to use default size of HtKv. +} HT_(Options); + +/* Ht is the hashtable structure */ +typedef struct Ht_(t) { + ut32 size; ///< Size of the hash table in buckets. + ut32 count; ///< Number of stored elements. + HT_(Bucket) *table; ///< Actual table. + ut32 prime_idx; + HT_(Options) opt; +} HtName_(Ht); + +typedef struct Ht_(iter_mut_t) { + HtName_(Ht) *ht; ///< The hash table to iterate over. + ut32 ti; ///< Table index + ut32 bi; ///< Bucket index + HT_(Kv) *kv; ///< Current Key-Value-pair. +} HT_(IterMutState); + +typedef struct Ht_(iter_t) { + const HtName_(Ht) *ht; ///< The hash table to iterate over. + ut32 ti; ///< Table index + ut32 bi; ///< Bucket index + const HT_(Kv) *kv; ///< Current Key-Value-pair. +} HT_(IterState); + +// Create a new Ht with the provided Options +RZ_API RZ_OWN HtName_(Ht) *Ht_(new_opt)(RZ_NONNULL HT_(Options) *opt); +// Create a new Ht with the provided Options and initial size +RZ_API RZ_OWN HtName_(Ht) *Ht_(new_opt_size)(RZ_NONNULL HT_(Options) *opt, ut32 initial_size); +// Destroy a hashtable and all of its entries. +RZ_API void Ht_(free)(RZ_NULLABLE HtName_(Ht) *ht); +// Insert a new Key-Value pair into the hashtable. If the key already exists, returns false. +RZ_API bool Ht_(insert)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, VALUE_TYPE value); +RZ_API HtRetCode Ht_(insert_ex)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, VALUE_TYPE value, RZ_OUT RZ_NULLABLE HT_(Kv) **out_kv); +// Insert a new Key-Value pair into the hashtable, or updates the value if the key already exists. +RZ_API bool Ht_(update)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, VALUE_TYPE value); +RZ_API HtRetCode Ht_(update_ex)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, VALUE_TYPE value, RZ_OUT RZ_NULLABLE HT_(Kv) **out_kv); +// Update the key of an element in the hashtable +RZ_API bool Ht_(update_key)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE old_key, const KEY_TYPE new_key); +// Delete a key from the hashtable. +RZ_API bool Ht_(delete)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key); +// Find the value corresponding to the matching key. +RZ_API VALUE_TYPE Ht_(find)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, RZ_NULLABLE bool *found); +// Iterates over all elements in the hashtable, calling the cb function on each Kv. +// If the cb returns false, the iteration is stopped. +// cb should not modify the hashtable. +// NOTE: cb can delete the current element, but it should be avoided +RZ_API void Ht_(foreach)(RZ_NONNULL HtName_(Ht) *ht, RZ_NONNULL HT_(ForeachCallback) cb, RZ_NULLABLE void *user); + +RZ_API ut32 Ht_(size)(const RZ_NONNULL HtName_(Ht) *ht); + +RZ_API RZ_BORROW HT_(Kv) *Ht_(find_kv)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, RZ_NULLABLE bool *found); +RZ_API bool Ht_(insert_kv)(RZ_NONNULL HtName_(Ht) *ht, RZ_NONNULL HT_(Kv) *kv, bool update); +RZ_API HtRetCode Ht_(insert_kv_ex)(RZ_NONNULL HtName_(Ht) *ht, RZ_NONNULL HT_(Kv) *kv, bool update, RZ_OUT RZ_NULLABLE HT_(Kv) **out_kv); + +RZ_API RZ_OWN HT_(IterMutState) *Ht_(new_iter_mut_state)(RZ_NONNULL HtName_(Ht) *ht); +RZ_API RZ_OWN HT_(IterState) *Ht_(new_iter_state)(const RZ_NONNULL HtName_(Ht) *ht); +RZ_API void Ht_(free_iter_mut_state)(RZ_NULLABLE HT_(IterMutState) *state); +RZ_API void Ht_(free_iter_state)(RZ_NULLABLE HT_(IterState) *state); + +RZ_API RZ_BORROW VALUE_TYPE *Ht_(iter_next_mut)(RzIterator *it); +RZ_API const VALUE_TYPE *Ht_(iter_next)(RzIterator *it); +RZ_API const KEY_TYPE *Ht_(iter_next_key)(RzIterator *it); + +RZ_API RZ_OWN RzIterator /* */ *Ht_(as_iter_mut)(RZ_NONNULL HtName_(Ht) *ht); +RZ_API RZ_OWN RzIterator /* */ *Ht_(as_iter)(const RZ_NONNULL HtName_(Ht) *ht); +RZ_API RZ_OWN RzIterator /* */ *Ht_(as_iter_keys)(const RZ_NONNULL HtName_(Ht) *ht); diff --git a/dest/include/librz/rz_util/ht_pp.h b/dest/include/librz/rz_util/ht_pp.h new file mode 100644 index 00000000000..389b9ad9dae --- /dev/null +++ b/dest/include/librz/rz_util/ht_pp.h @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2016-2018 crowell +// SPDX-FileCopyrightText: 2016-2018 pancake +// SPDX-FileCopyrightText: 2016-2018 ret2libc +// SPDX-License-Identifier: BSD-3-Clause + +#ifndef HT_PP_H +#define HT_PP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** \file + * This header provides an hash table HtPP that has void* as key and void* as value. + * The API functions starts with "ht_pp_" and the types starts with "HtPP". + */ +#define HT_TYPE 1 +#include +#undef HT_TYPE + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/ht_pu.h b/dest/include/librz/rz_util/ht_pu.h new file mode 100644 index 00000000000..d9750870796 --- /dev/null +++ b/dest/include/librz/rz_util/ht_pu.h @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2016-2018 crowell +// SPDX-FileCopyrightText: 2016-2018 pancake +// SPDX-FileCopyrightText: 2016-2018 ret2libc +// SPDX-License-Identifier: BSD-3-Clause + +#ifndef HT_PU_H +#define HT_PU_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** \file + * This header provides an hash table HtPU that has void* as key and ut64 as value. + * The API functions starts with "ht_pu_" and the types starts with "HtPU". + */ +#define HT_TYPE 4 +#include +#undef HT_TYPE + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/ht_sp.h b/dest/include/librz/rz_util/ht_sp.h new file mode 100644 index 00000000000..bea09f2247a --- /dev/null +++ b/dest/include/librz/rz_util/ht_sp.h @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2024 pelijah +// SPDX-License-Identifier: BSD-3-Clause + +#ifndef HT_SP_H +#define HT_SP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** \file + * This header provides an hash table HtSP that has C-string as key and void* as value. + * The API functions starts with "ht_sp_" and the types starts with "HtSP". + */ +#define HT_TYPE 5 +#include + +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(HtStrOption key_opt, RZ_NULLABLE HT_(DupValue) dup_val, RZ_NULLABLE HT_(FreeValue) free_val); +#undef HT_TYPE + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/dest/include/librz/rz_util/ht_ss.h b/dest/include/librz/rz_util/ht_ss.h new file mode 100644 index 00000000000..0ec1c04640c --- /dev/null +++ b/dest/include/librz/rz_util/ht_ss.h @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2024 pelijah +// SPDX-License-Identifier: BSD-3-Clause + +#ifndef HT_SS_H +#define HT_SS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** \file + * This header provides an hash table HtSS that has C-string as key and C-string as value. + * The API functions starts with "ht_ss_" and the types starts with "HtSS". + */ +#define HT_TYPE 6 +#include + +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(HtStrOption key_opt, HtStrOption val_opt); +#undef HT_TYPE + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/dest/include/librz/rz_util/ht_su.h b/dest/include/librz/rz_util/ht_su.h new file mode 100644 index 00000000000..672127a66da --- /dev/null +++ b/dest/include/librz/rz_util/ht_su.h @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2024 pelijah +// SPDX-License-Identifier: BSD-3-Clause + +#ifndef HT_SU_H +#define HT_SU_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** \file + * This header provides an hash table HtSU that has C-string as key and ut64 as value. + * The API functions starts with "ht_su_" and the types starts with "HtSU". + */ +#define HT_TYPE 7 +#include + +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(HtStrOption key_opt); +#undef HT_TYPE + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/dest/include/librz/rz_util/ht_up.h b/dest/include/librz/rz_util/ht_up.h new file mode 100644 index 00000000000..7878ef7d08d --- /dev/null +++ b/dest/include/librz/rz_util/ht_up.h @@ -0,0 +1,29 @@ +// SPDX-FileCopyrightText: 2016-2018 crowell +// SPDX-FileCopyrightText: 2016-2018 pancake +// SPDX-FileCopyrightText: 2016-2018 ret2libc +// SPDX-FileCopyrightText: 2024 pelijah +// SPDX-License-Identifier: BSD-3-Clause + +#ifndef HT_UP_H +#define HT_UP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** \file + * This header provides an hash table HtUP that has ut64 as key and void* as value. + * The API functions starts with "ht_up_" and the types starts with "HtUP". + */ +#define HT_TYPE 2 +#include + +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(RZ_NULLABLE HT_(DupValue) valdup, RZ_NULLABLE HT_(FreeValue) valfree); +RZ_API RZ_OWN HtName_(Ht) *Ht_(new_size)(ut32 initial_size, RZ_NULLABLE HT_(DupValue) valdup, RZ_NULLABLE HT_(FreeValue) valfree); +#undef HT_TYPE + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/ht_uu.h b/dest/include/librz/rz_util/ht_uu.h new file mode 100644 index 00000000000..ca48a85a497 --- /dev/null +++ b/dest/include/librz/rz_util/ht_uu.h @@ -0,0 +1,27 @@ +// SPDX-FileCopyrightText: 2016-2018 crowell +// SPDX-FileCopyrightText: 2016-2018 pancake +// SPDX-FileCopyrightText: 2016-2018 ret2libc +// SPDX-License-Identifier: BSD-3-Clause + +#ifndef HT_UU_H +#define HT_UU_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** \file + * This header provides an hash table HtUU that has ut64 as key and ut64 as value. + * The API functions starts with "ht_uu" and the types starts with "HtUU". + */ +#define HT_TYPE 3 +#include + +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(void); +#undef HT_TYPE + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/rz_alloc.h b/dest/include/librz/rz_util/rz_alloc.h new file mode 100644 index 00000000000..1284c707e76 --- /dev/null +++ b/dest/include/librz/rz_util/rz_alloc.h @@ -0,0 +1,20 @@ +#ifndef RZ_ALLOC_H +#define RZ_ALLOC_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API RZ_OWN void *rz_mem_alloc(size_t sz); +RZ_API void rz_mem_free(void *); +RZ_API RZ_OWN void *rz_malloc_aligned(size_t size, size_t alignment); +RZ_API void rz_free_aligned(void *p); + +#ifdef __cplusplus +} +#endif +#endif // RZ_ALLOC_H diff --git a/dest/include/librz/rz_util/rz_annotated_code.h b/dest/include/librz/rz_util/rz_annotated_code.h new file mode 100644 index 00000000000..6913642fa44 --- /dev/null +++ b/dest/include/librz/rz_util/rz_annotated_code.h @@ -0,0 +1,180 @@ + +#ifndef RZ_ANNOTATEDCODE_H +#define RZ_ANNOTATEDCODE_H + +// #include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum rz_syntax_highlight_type_t { + RZ_SYNTAX_HIGHLIGHT_TYPE_KEYWORD, + RZ_SYNTAX_HIGHLIGHT_TYPE_COMMENT, + RZ_SYNTAX_HIGHLIGHT_TYPE_DATATYPE, + RZ_SYNTAX_HIGHLIGHT_TYPE_FUNCTION_NAME, + RZ_SYNTAX_HIGHLIGHT_TYPE_FUNCTION_PARAMETER, + RZ_SYNTAX_HIGHLIGHT_TYPE_LOCAL_VARIABLE, + RZ_SYNTAX_HIGHLIGHT_TYPE_CONSTANT_VARIABLE, + RZ_SYNTAX_HIGHLIGHT_TYPE_GLOBAL_VARIABLE, +} RSyntaxHighlightType; + +/** Represents the type of annnotation. */ +typedef enum rz_code_annotation_type_t { + RZ_CODE_ANNOTATION_TYPE_OFFSET, /*!< Gives the offset of the specified range in annotation. */ + RZ_CODE_ANNOTATION_TYPE_SYNTAX_HIGHLIGHT, /*!< Represents the kind of data the specified range represents for highlighting purposes. */ + RZ_CODE_ANNOTATION_TYPE_FUNCTION_NAME, /*!< Specified range in annotation represents a function name. */ + RZ_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE, /*!< Specified range in annotation represents a global variable. */ + RZ_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE, /*!< Specified range in annotation represents a constant variable with an address. */ + RZ_CODE_ANNOTATION_TYPE_LOCAL_VARIABLE, /*!< Specified range in annotation represents a local variable. */ + RZ_CODE_ANNOTATION_TYPE_FUNCTION_PARAMETER, /*!< Specified range in annotation represents a function parameter. */ + // ... +} RzCodeAnnotationType; + +/** + * \brief Annotations for the decompiled code are represented using this structure. + */ +typedef struct rz_code_annotation_t { + size_t start; /**< Start of the range in the annotation(inclusive). */ + size_t end; /**< End of the range in the annotation(exclusive). */ + RzCodeAnnotationType type; + union { + /** If the annotation is of type RZ_CODE_ANNOTATION_TYPE_OFFSET, + * offset should be stored in the struct named offset in this union. + */ + struct { + ut64 offset; + } offset; + /** If the annotation is of type RZ_CODE_ANNOTATION_TYPE_SYNTAX_HIGHLIGHT, + * type of the syntax highlight will be stored in the struct named syntax_highlight + * in this union. + */ + struct { + RSyntaxHighlightType type; + } syntax_highlight; + + /** Information in annotations of type RZ_CODE_ANNOTATION_TYPE_FUNCTION_NAME, + * RZ_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE, and RZ_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE + * will be stored in the struct named reference in this union. + */ + struct { + char *name; + ut64 offset; + } reference; + + /** Information in annotations of type RZ_CODE_ANNOTATION_TYPE_LOCAL_VARIABLE + * and RZ_CODE_ANNOTATION_TYPE_FUNCTION_PARAMETER will be stored in the + * struct named variable in this union. + */ + struct { + char *name; + } variable; + }; +} RzCodeAnnotation; +/** + * \brief This structure contains the decompiled code and all the annotations for the decompiled code. + */ +typedef struct rz_annotated_code_t { + char *code; /**< Decompiled code. RzAnnotatedCode owns this string and it must free it. */ + RzVector /**/ annotations; /**< @ref RzVector contains the list of annotations for the decompiled code. */ +} RzAnnotatedCode; + +/** + * @brief Create and initialize a RzAnnotatedCode structure and returns its pointer. + * + * This function creates and initializes a new RzAnnotatedCode + * structure with the specified decompiled code that's passed + * as an argument. Here, the argument code must be a string that can be deallocated. + * This will initialize @ref RzVector annotations as well. + * + * @param code A deallocatable character array. + * @return Pointer to the new RzAnnotatedCode structure created. + */ +RZ_API RzAnnotatedCode *rz_annotated_code_new(char *code); +/** + * @brief Deallocates the dynamically allocated memory for the specified RzAnnotatedCode. + * + * @param code Pointer to a RzAnnotatedCode. + */ +RZ_API void rz_annotated_code_free(RzAnnotatedCode *code); +/** + * @brief Deallocates dynamically allocated memory for the specified annotation. + * + * This function recognizes the type of the specified annotation and + * frees memory that is dynamically allocated for it. + * + * @param e Pointer to the annotation. + * @param user Always NULL for this function. Present here for this function to be of the type @ref RzVectorFree. + */ +RZ_API void rz_annotation_free(void *e, void *user); +/** + * @brief Checks if the specified annotation is a reference. + * + * This function recognizes the type of the specified annotation and returns true if its + * type is any of the following three: RZ_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE, + * RZ_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE, RZ_CODE_ANNOTATION_TYPE_FUNCTION_NAME + * + * @param annotation Pointer to an annotation. + * @return Returns true if the specified annotation is a reference. + */ +RZ_API bool rz_annotation_is_reference(RzCodeAnnotation *annotation); +/** + * @brief Checks if the specified annotation is a function variable. + * + * This function recognizes the type of the specified annotation and returns true if its + * type is any of the following two: RZ_CODE_ANNOTATION_TYPE_LOCAL_VARIABLE, + * RZ_CODE_ANNOTATION_TYPE_FUNCTION_PARAMETER + * + * @param annotation Pointer to an annotation. + * @return Returns true if the specified annotation is a function variable. + */ +RZ_API bool rz_annotation_is_variable(RzCodeAnnotation *annotation); +/** + * @brief Inserts the specified annotation into the list of annotations in the specified RzAnnotatedCode. + * + * @param code Pointer to a RzAnnotatedCode. + * @param annotation Pointer to an annotation. + */ +RZ_API void rz_annotated_code_add_annotation(RzAnnotatedCode *code, RzCodeAnnotation *annotation); +/** + * @brief Returns all annotations with range that contains the given offset. + * + * Creates a @ref RzPVector and inserts the pointers to all annotations in which + * annotation->start <= offset < annotation->end. + * + * @param code Pointer to a RzAnnotatedCode. + * @param offset Offset. + * @return Pointer to the @ref RzPVector created. + */ +RZ_API RzPVector /**/ *rz_annotated_code_annotations_in(RzAnnotatedCode *code, size_t offset); +/** + * @brief Returns all annotations with range that overlap with the specified range. + * + * Creates an @ref RzPVector and inserts the pointers to all annotations whose + * range overlap with range specified. + * + * @param code Pointer to a RzAnnotatedCode. + * @param start Start of the range(inclusive). + * @param end End of the range(exclusive). + * @return Pointer to the @ref RzPVector created. + */ +RZ_API RzPVector /**/ *rz_annotated_code_annotations_range(RzAnnotatedCode *code, size_t start, size_t end); +/** + * @brief Returns the offset for every line of decompiled code in the specified RzAnnotatedCode. + * + * Creates an @ref RzVector and inserts the offsets for every seperate line of decompiled code in + * the specified RzAnnotatedCode. + * If a line of decompiled code doesn't have a unique offset, UT64_MAX is inserted as its offset. + * + * @param code Pointer to a RzAnnotatedCode. + * @return Pointer to the @ref RzVector created. + */ +RZ_API RzVector /**/ *rz_annotated_code_line_offsets(RzAnnotatedCode *code); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_ANNOTATEDCODE_H diff --git a/dest/include/librz/rz_util/rz_ascii_table.h b/dest/include/librz/rz_util/rz_ascii_table.h new file mode 100644 index 00000000000..d05a48ffc53 --- /dev/null +++ b/dest/include/librz/rz_util/rz_ascii_table.h @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2008-2016 pancake +// SPDX-FileCopyrightText: 2008-2016 r00tus3r +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_ASCII_TABLE_H +#define RZ_ASCII_TABLE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API const char *ret_ascii_table(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/rz_asn1.h b/dest/include/librz/rz_util/rz_asn1.h new file mode 100644 index 00000000000..6160a1621a6 --- /dev/null +++ b/dest/include/librz/rz_util/rz_asn1.h @@ -0,0 +1,113 @@ +#ifndef RZ_ASN1_H +#define RZ_ASN1_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RZ_ASN1_JSON_NULL "null" +#define RZ_ASN1_JSON_EMPTY "{}" + +#define RZ_ASN1_OID_LEN 64 + +/* Masks */ +#define RZ_ASN1_CLASS 0xC0 /* Bits 8 and 7 */ +#define RZ_ASN1_FORM 0x20 /* Bit 6 */ +#define RZ_ASN1_TAG 0x1F /* Bits 5 - 1 */ +#define RZ_ASN1_LENLONG 0x80 /* long form */ +#define RZ_ASN1_LENSHORT 0x7F /* Bits 7 - 1 */ + +/* Classes */ +#define RZ_ASN1_CLASS_UNIVERSAL 0x00 /* 0 = Universal (defined by ITU X.680) */ +#define RZ_ASN1_CLASS_APPLICATION 0x40 /* 1 = Application */ +#define RZ_ASN1_CLASS_CONTEXT 0x80 /* 2 = Context-specific */ +#define RZ_ASN1_CLASS_PRIVATE 0xC0 /* 3 = Private */ + +/* Forms */ +#define RZ_ASN1_FORM_PRIMITIVE 0x00 /* 0 = primitive */ +#define RZ_ASN1_FORM_CONSTRUCTED 0x20 /* 1 = constructed */ + +/* Tags */ +#define RZ_ASN1_TAG_EOC 0x00 /* 0: End-of-contents octets */ +#define RZ_ASN1_TAG_BOOLEAN 0x01 /* 1: Boolean */ +#define RZ_ASN1_TAG_INTEGER 0x02 /* 2: Integer */ +#define RZ_ASN1_TAG_BITSTRING 0x03 /* 2: Bit string */ +#define RZ_ASN1_TAG_OCTETSTRING 0x04 /* 4: Byte string */ +#define RZ_ASN1_TAG_NULL 0x05 /* 5: NULL */ +#define RZ_ASN1_TAG_OID 0x06 /* 6: Object Identifier */ +#define RZ_ASN1_TAG_OBJDESCRIPTOR 0x07 /* 7: Object Descriptor */ +#define RZ_ASN1_TAG_EXTERNAL 0x08 /* 8: External */ +#define RZ_ASN1_TAG_REAL 0x09 /* 9: Real */ +#define RZ_ASN1_TAG_ENUMERATED 0x0A /* 10: Enumerated */ +#define RZ_ASN1_TAG_EMBEDDED_PDV 0x0B /* 11: Embedded Presentation Data Value */ +#define RZ_ASN1_TAG_UTF8STRING 0x0C /* 12: UTF8 string */ +#define RZ_ASN1_TAG_SEQUENCE 0x10 /* 16: Sequence/sequence of */ +#define RZ_ASN1_TAG_SET 0x11 /* 17: Set/set of */ +#define RZ_ASN1_TAG_NUMERICSTRING 0x12 /* 18: Numeric string */ +#define RZ_ASN1_TAG_PRINTABLESTRING 0x13 /* 19: Printable string (ASCII subset) */ +#define RZ_ASN1_TAG_T61STRING 0x14 /* 20: T61/Teletex string */ +#define RZ_ASN1_TAG_VIDEOTEXSTRING 0x15 /* 21: Videotex string */ +#define RZ_ASN1_TAG_IA5STRING 0x16 /* 22: IA5/ASCII string */ +#define RZ_ASN1_TAG_UTCTIME 0x17 /* 23: UTC time */ +#define RZ_ASN1_TAG_GENERALIZEDTIME 0x18 /* 24: Generalized time */ +#define RZ_ASN1_TAG_GRAPHICSTRING 0x19 /* 25: Graphic string */ +#define RZ_ASN1_TAG_VISIBLESTRING 0x1A /* 26: Visible string (ASCII subset) */ +#define RZ_ASN1_TAG_GENERALSTRING 0x1B /* 27: General string */ +#define RZ_ASN1_TAG_UNIVERSALSTRING 0x1C /* 28: Universal string */ +#define RZ_ASN1_TAG_BMPSTRING 0x1E /* 30: Basic Multilingual Plane/Unicode string */ + +typedef struct rz_asn1_string_t { + ut32 length; + const char *string; + bool allocated; +} RzASN1String; + +typedef struct rz_asn1_list_t { + ut32 length; + struct rz_asn1_object_t **objects; +} RzASN1List; + +typedef struct rz_asn1_bin_t { + ut32 length; + ut8 *binary; +} RzASN1Binary; + +typedef struct rz_asn1_object_t { + ut8 klass; /* class type */ + ut8 form; /* defines if contains data or objects */ + ut8 tag; /* tag type */ + const ut8 *sector; /* Sector containing data */ + ut32 length; /* Sector Length */ + ut64 offset; /* Object offset */ + ut64 total_size; /* Object size (including header) */ + RzASN1List list; /* List of objects contained in the sector */ +} RzASN1Object; + +RZ_API RZ_OWN RzASN1Object *rz_asn1_object_parse(RZ_NONNULL const ut8 *buffer, ut32 length); +RZ_API RZ_OWN RzASN1Object *rz_asn1_object_parse_header(RZ_NONNULL const ut8 *buffer, ut32 length); +RZ_API RZ_OWN RzASN1Binary *rz_asn1_binary_parse(RZ_NULLABLE const ut8 *buffer, ut32 length); +RZ_API RZ_OWN RzASN1String *rz_asn1_string_parse(RZ_NULLABLE const char *string, bool allocated, ut32 length); +RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_bits(RZ_NULLABLE const ut8 *buffer, ut32 length); +RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_utctime(RZ_NULLABLE const ut8 *buffer, ut32 length); +RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_time(RZ_NULLABLE const ut8 *buffer, ut32 length); +RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_integer(RZ_NULLABLE const ut8 *buffer, ut32 length); +RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_string(RZ_NULLABLE const ut8 *buffer, ut32 length); +RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_bytes(RZ_NULLABLE const ut8 *buffer, ut32 length); +RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_boolean(RZ_NULLABLE const ut8 *buffer, ut32 length); +RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_oid(RZ_NULLABLE const ut8 *buffer, ut32 length); + +RZ_API void rz_asn1_object_free(RZ_NULLABLE RzASN1Object *object); +RZ_API RZ_OWN char *rz_asn1_to_string(RZ_NULLABLE RzASN1Object *object); +RZ_API RZ_OWN RzStructuredData *rz_asn1_to_structure(RZ_NULLABLE RzASN1Object *object, bool simplified); +RZ_API void rz_asn1_string_free(RZ_NULLABLE RzASN1String *string); +RZ_API void rz_asn1_binary_free(RZ_NULLABLE RzASN1Binary *string); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_ASN1_H */ diff --git a/dest/include/librz/rz_util/rz_assert.h b/dest/include/librz/rz_util/rz_assert.h new file mode 100644 index 00000000000..de135047a9d --- /dev/null +++ b/dest/include/librz/rz_util/rz_assert.h @@ -0,0 +1,235 @@ +#ifndef RZ_ASSERT_H +#define RZ_ASSERT_H + +#include "rz_log.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define RZ_STATIC_ASSERT(x) \ + switch (0) { \ + case 0: \ + case (x):; \ + } + +RZ_API void rz_assert_log(RzLogLevel level, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); + +#if defined(__GNUC__) && defined(__cplusplus) +#define RZ_FUNCTION ((const char *)(__PRETTY_FUNCTION__)) +#elif defined(__STDC__) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define RZ_FUNCTION ((const char *)(__func__)) +#elif defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER > 1300)) +#define RZ_FUNCTION ((const char *)(__FUNCTION__)) +#else +#warning Do not know how to get function name in this setup +#define RZ_FUNCTION ((const char *)("???")) +#endif + +#define rz_warn_if_fail(expr) \ + do { \ + if (!(expr)) { \ + rz_assert_log(RZ_LOGLVL_WARN, "(%s:%d):%s%s runtime check failed: (%s)\n", \ + __FILE__, __LINE__, RZ_FUNCTION, RZ_FUNCTION[0] ? ":" : "", #expr); \ + } \ + } while (0) + +#define rz_warn_if_reached() \ + do { \ + rz_assert_log(RZ_LOGLVL_WARN, "(%s:%d):%s%s code should not be reached\n", \ + __FILE__, __LINE__, RZ_FUNCTION, RZ_FUNCTION[0] ? ":" : ""); \ + } while (0) + +/* + * RZ_CHECKS_LEVEL determines the behaviour of the rz_return/goto/break_* set of functions. + * + * 0: completely disable every function and make them like no-operation + * 1: silently enable checks. Check expressions and do return, but do not log anything + * 2: enable checks and logging (DEFAULT) + * 3: transform them into real assertion + */ +#ifndef RZ_CHECKS_LEVEL +#define RZ_CHECKS_LEVEL 2 +#endif + +#if RZ_CHECKS_LEVEL == 0 + +#define rz_return_if_fail(expr) \ + do { \ + ; \ + } while (0) +#define rz_return_val_if_fail(expr, val) \ + do { \ + ; \ + } while (0) +#define rz_return_if_reached() \ + do { \ + return; \ + } while (0) +#define rz_return_val_if_reached(val) \ + do { \ + return (val); \ + } while (0) + +#define rz_goto_if_fail(expr, where) \ + do { \ + ; \ + } while (0) +#define rz_goto_if_reached(where) \ + do { \ + goto where; \ + } while (0) + +#define rz_break_if_fail(expr) \ + do { \ + ; \ + } while (0) +#define rz_break_if_reached() \ + { \ + break; \ + } + +#elif RZ_CHECKS_LEVEL == 1 || RZ_CHECKS_LEVEL == 2 // RZ_CHECKS_LEVEL + +#if RZ_CHECKS_LEVEL == 1 +#define H_LOG_(loglevel, fmt, ...) +#else +#define H_LOG_(loglevel, fmt, ...) rz_assert_log(loglevel, fmt, __VA_ARGS__) +#endif + +/** + * rz_return_if_fail: + * @expr: the expression to check + * + * Verifies that the expression @expr, usually representing a precondition, + * evaluates to `true`. If the function returns a value, use + * rz_return_val_if_fail() instead. + * + * If @expr evaluates to %FALSE, the current function should be considered to + * have undefined behaviour (a programmer error). The only correct solution + * to such an error is to change the module that is calling the current + * function, so that it avoids this incorrect call. + * + * To make this undefined behaviour visible, if @expr evaluates to %FALSE, + * the result is usually that a critical message is logged and the current + * function returns. + * + */ +#define rz_return_if_fail(expr) \ + do { \ + if (!(expr)) { \ + H_LOG_(RZ_LOGLVL_WARN, "%s: assertion '%s' failed (line %d); exiting function\n", RZ_FUNCTION, #expr, __LINE__); \ + return; \ + } \ + } while (0) + +#define rz_return_val_if_fail(expr, val) \ + do { \ + if (!(expr)) { \ + H_LOG_(RZ_LOGLVL_WARN, "%s: assertion '%s' failed (line %d); returning %s\n", RZ_FUNCTION, #expr, __LINE__, #val); \ + return (val); \ + } \ + } while (0) + +#define rz_return_if_reached() \ + do { \ + H_LOG_(RZ_LOGLVL_ERROR, "file %s: line %d (%s): should not be reached; exiting function\n", __FILE__, __LINE__, RZ_FUNCTION); \ + return; \ + } while (0) + +#define rz_return_val_if_reached(val) \ + do { \ + H_LOG_(RZ_LOGLVL_ERROR, "file %s: line %d (%s): should not be reached; returning %s\n", __FILE__, __LINE__, RZ_FUNCTION, #val); \ + return (val); \ + } while (0) + +#define rz_goto_if_fail(expr, where) \ + do { \ + if (!(expr)) { \ + H_LOG_(RZ_LOGLVL_WARN, "%s: assertion '%s' failed (line %d); jumping to %s\n", RZ_FUNCTION, #expr, __LINE__, #where); \ + goto where; \ + } \ + } while (0) + +#define rz_goto_if_reached(where) \ + do { \ + H_LOG_(RZ_LOGLVL_ERROR, "file %s: line %d (%s): should not be reached; jumping to %s\n", __FILE__, __LINE__, RZ_FUNCTION, #where); \ + goto where; \ + } while (0) + +#define rz_break_if_fail(expr) \ + { \ + if (!(expr)) { \ + H_LOG_(RZ_LOGLVL_WARN, "%s: assertion '%s' failed (line %d); exiting loop\n", RZ_FUNCTION, #expr, __LINE__); \ + break; \ + } \ + } + +#define rz_break_if_reached() \ + { \ + H_LOG_(RZ_LOGLVL_ERROR, "file %s: line %d (%s): should not be reached; exiting loop\n", __FILE__, __LINE__, RZ_FUNCTION); \ + break; \ + } + +#else // RZ_CHECKS_LEVEL + +#include + +#define rz_return_if_fail(expr) \ + do { \ + assert(expr); \ + if (!(expr)) { \ + return; \ + } \ + } while (0) +#define rz_return_val_if_fail(expr, val) \ + do { \ + assert(expr); \ + if (!(expr)) { \ + return (val); \ + } \ + } while (0) +#define rz_return_if_reached() \ + do { \ + assert(false); \ + return; \ + } while (0) +#define rz_return_val_if_reached(val) \ + do { \ + assert(false); \ + return (val); \ + } while (0) + +#define rz_goto_if_fail(expr, where) \ + do { \ + assert(expr); \ + if (!(expr)) { \ + goto where; \ + } \ + } while (0) +#define rz_goto_if_reached(where) \ + do { \ + assert(false); \ + goto where; \ + } while (0) + +#define rz_break_if_fail(expr) \ + { \ + assert(expr); \ + if (!(expr)) { \ + break; \ + } \ + } +#define rz_break_if_reached() \ + { \ + assert(false); \ + break; \ + } + +#endif // RZ_CHECKS_LEVEL + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/rz_axml.h b/dest/include/librz/rz_util/rz_axml.h new file mode 100644 index 00000000000..4c9ff0a7804 --- /dev/null +++ b/dest/include/librz/rz_util/rz_axml.h @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2021 keegan +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_AXML_H +#define RZ_AXML_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API RZ_OWN char *rz_axml_decode(RZ_NONNULL const ut8 *buffer, const ut64 size); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_AXML_H diff --git a/dest/include/librz/rz_util/rz_base16.h b/dest/include/librz/rz_util/rz_base16.h new file mode 100644 index 00000000000..278431aac67 --- /dev/null +++ b/dest/include/librz/rz_util/rz_base16.h @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2025 Ahmed Ibrahim +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_BASE16_H +#define RZ_BASE16_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API int rz_base16_encode(RZ_OUT RZ_NONNULL char *bout, RZ_NONNULL const ut8 *bin, size_t sz); +RZ_API int rz_base16_decode(RZ_OUT RZ_NONNULL ut8 *bout, RZ_NONNULL const char *bin); + +RZ_API RZ_OWN char *rz_base16_encode_dyn(RZ_NONNULL const ut8 *bin, size_t sz); +RZ_API RZ_OWN ut8 *rz_base16_decode_dyn(RZ_NONNULL const char *in, st64 len); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_BASE16_H diff --git a/dest/include/librz/rz_util/rz_base32.h b/dest/include/librz/rz_util/rz_base32.h new file mode 100644 index 00000000000..bf9e37f0265 --- /dev/null +++ b/dest/include/librz/rz_util/rz_base32.h @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2025 Ahmed Ibrahim +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_BASE32_H +#define RZ_BASE32_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API size_t rz_base32_encode(RZ_OUT RZ_NONNULL char *bout, RZ_NONNULL const ut8 *bin, size_t sz); +RZ_API st64 rz_base32_decode(RZ_OUT RZ_NONNULL ut8 *bout, RZ_NONNULL const char *bin, st64 len); + +RZ_API RZ_OWN char *rz_base32_encode_dyn(RZ_NONNULL const ut8 *bin, size_t sz); +RZ_API RZ_OWN ut8 *rz_base32_decode_dyn(RZ_NONNULL const char *in, st64 len); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_BASE32_H diff --git a/dest/include/librz/rz_util/rz_base36.h b/dest/include/librz/rz_util/rz_base36.h new file mode 100644 index 00000000000..7f230d6da20 --- /dev/null +++ b/dest/include/librz/rz_util/rz_base36.h @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2025 Ahmed Ibrahim +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_BASE36_H +#define RZ_BASE36_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API size_t rz_base36_encode(RZ_OUT RZ_NONNULL char *bout, ut64 val); +RZ_API RZ_OWN char *rz_base36_encode_dyn(ut64 val); + +RZ_API st64 rz_base36_decode(RZ_OUT RZ_NONNULL ut64 *bout, RZ_NONNULL const char *bin, st64 len); +RZ_API RZ_OWN ut64 *rz_base36_decode_dyn(RZ_NONNULL const char *bin, const size_t len); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_BASE36_H diff --git a/dest/include/librz/rz_util/rz_base64.h b/dest/include/librz/rz_util/rz_base64.h new file mode 100644 index 00000000000..f0676473a76 --- /dev/null +++ b/dest/include/librz/rz_util/rz_base64.h @@ -0,0 +1,18 @@ +#ifndef RZ_BASE64_H +#define RZ_BASE64_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API size_t rz_base64_encode(RZ_OUT RZ_NULLABLE char *bout, RZ_NULLABLE const ut8 *bin, size_t sz); +RZ_API st64 rz_base64_decode(RZ_OUT RZ_NULLABLE ut8 *bout, RZ_NULLABLE const char *bin, st64 len); +RZ_API RZ_OWN ut8 *rz_base64_decode_dyn(RZ_NULLABLE const char *in, st64 len); +RZ_API RZ_OWN char *rz_base64_encode_dyn(RZ_NULLABLE const ut8 *bin, size_t sz); +#ifdef __cplusplus +} +#endif + +#endif // RZ_BASE64_H diff --git a/dest/include/librz/rz_util/rz_base85.h b/dest/include/librz/rz_util/rz_base85.h new file mode 100644 index 00000000000..2e2cd0dc80e --- /dev/null +++ b/dest/include/librz/rz_util/rz_base85.h @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2025 Ahmed Ibrahim +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_BASE85_H +#define RZ_BASE85_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API int rz_base85_encode(RZ_OUT RZ_NONNULL char *dest, RZ_NONNULL const char *src, size_t n, int delims, int wrap, int y_abbr); +RZ_API st64 rz_base85_decode(RZ_OUT RZ_NONNULL char *dest, RZ_NONNULL const char *src, st64 len, int delims, int ignore_garbage); + +RZ_API RZ_OWN char *rz_base85_encode_dyn(RZ_NONNULL const char *src, size_t n, int delims, int wrap, int y_abbr); +RZ_API RZ_OWN char *rz_base85_decode_dyn(RZ_NONNULL const char *src, st64 len, int delims, int ignore_garbage, size_t *out_len); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_BASE85_H diff --git a/dest/include/librz/rz_util/rz_base91.h b/dest/include/librz/rz_util/rz_base91.h new file mode 100644 index 00000000000..c75940caf9c --- /dev/null +++ b/dest/include/librz/rz_util/rz_base91.h @@ -0,0 +1,17 @@ +#ifndef RZ_BASE91_H +#define RZ_BASE91_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API int rz_base91_encode(char *bout, const ut8 *bin, int len); +RZ_API int rz_base91_decode(ut8 *bout, const char *bin, int len); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_BASE91_H diff --git a/dest/include/librz/rz_util/rz_big.h b/dest/include/librz/rz_util/rz_big.h new file mode 100644 index 00000000000..ae6caf3d015 --- /dev/null +++ b/dest/include/librz/rz_util/rz_big.h @@ -0,0 +1,73 @@ +#ifndef RZ_BIG_H +#define RZ_BIG_H + +#include "../rz_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if HAVE_LIB_GMP +/* Use GMP's data struct */ +#define RzNumBig mpz_t +#elif HAVE_LIB_SSL +#define RzNumBig BIGNUM +#else +/* Use default impl */ +#define RZ_BIG_WORD_SIZE 4 +/* Let's support 4096-bit big number */ +#define RZ_BIG_ARRAY_SIZE (512 / RZ_BIG_WORD_SIZE) +/* RZ_BIG_WORD_SIZE == 4, 32 bits long */ +#define RZ_BIG_DTYPE ut32 +#define RZ_BIG_DTYPE_TMP ut64 +#define RZ_BIG_SPRINTF_FORMAT_STR "%.08x" +#define RZ_BIG_FORMAT_STR_LEN 9 +#define RZ_BIG_SSCANF_FORMAT_STR "%8x" +#define RZ_BIG_MAX_VAL (RZ_BIG_DTYPE_TMP) UT32_MAX + +typedef struct rz_num_big_t { + RZ_BIG_DTYPE array[RZ_BIG_ARRAY_SIZE]; + int sign; +} RzNumBig; +#endif + +RZ_API RzNumBig *rz_big_new(void); +RZ_API void rz_big_free(RzNumBig *b); +RZ_API void rz_big_init(RzNumBig *b); +RZ_API void rz_big_fini(RzNumBig *b); + +/* Assignment operations */ +RZ_API void rz_big_from_int(RzNumBig *b, st64 v); +RZ_API st64 rz_big_to_int(RzNumBig *b); +RZ_API void rz_big_from_hexstr(RzNumBig *b, const char *str); +RZ_API char *rz_big_to_hexstr(RzNumBig *b); +RZ_API void rz_big_assign(RzNumBig *dst, RzNumBig *src); + +/* Basic arithmetic operations */ +RZ_API void rz_big_add(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a + b */ +RZ_API void rz_big_sub(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a - b */ +RZ_API void rz_big_mul(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a * b */ +RZ_API void rz_big_div(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a / b */ +RZ_API void rz_big_mod(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a % b */ +RZ_API void rz_big_divmod(RzNumBig *c, RzNumBig *d, RzNumBig *a, RzNumBig *b); /* c = a/b, d = a%b */ + +/* Bitwise operations(for >= 0) */ +RZ_API void rz_big_and(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a & b */ +RZ_API void rz_big_or(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a | b */ +RZ_API void rz_big_xor(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a ^ b */ +RZ_API void rz_big_lshift(RzNumBig *c, RzNumBig *a, size_t nbits); /* c = a << nbits */ +RZ_API void rz_big_rshift(RzNumBig *c, RzNumBig *a, size_t nbits); /* c = a >> nbits */ + +/* Special operators and comparison */ +RZ_API int rz_big_cmp(RzNumBig *a, RzNumBig *b); /* Return 1 if a>b, -1 if a 1024 */ +RZ_API void rz_big_isqrt(RzNumBig *c, RzNumBig *a); /* Integer square root -- e.g. isqrt(5) => 2*/ + +#ifdef __cplusplus +} +#endif + +#endif // RZ_BIG_H diff --git a/dest/include/librz/rz_util/rz_bits.h b/dest/include/librz/rz_util/rz_bits.h new file mode 100644 index 00000000000..3062f64ee5c --- /dev/null +++ b/dest/include/librz/rz_util/rz_bits.h @@ -0,0 +1,186 @@ +// SPDX-FileCopyrightText: 2023 billow +// SPDX-License-Identifier: LGPL-3.0-only// + +#ifndef RIZIN_RZ_BITS_H +#define RIZIN_RZ_BITS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** + * \brief Count number of 1s in the given value. + * Reference: https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel + * + * \param v The value to count the set bits in. + * + * \return Number of set bits in \p v. + */ +#define DEFINE_COUNT_ONES(T) \ + static inline size_t rz_bits_count_ones_##T(T v) { \ + v = v - ((v >> 1) & (T) ~(T)0 / 3); \ + v = (v & (T) ~(T)0 / 15 * 3) + ((v >> 2) & (T) ~(T)0 / 15 * 3); \ + v = (v + (v >> 4)) & (T) ~(T)0 / 255 * 15; \ + size_t c = (T)(v * ((T) ~(T)0 / 255)) >> (sizeof(T) - 1) * CHAR_BIT; \ + return c; \ + } + +DEFINE_COUNT_ONES(ut64); +DEFINE_COUNT_ONES(ut32); +DEFINE_COUNT_ONES(ut16); +DEFINE_COUNT_ONES(ut8); + +/** + * \brief Count trailing zeros of \p v. + * If v == 0 it returns 64. + * + * \param v The value to count the trailing zeros for. + * + * \return The number of trailing zeros. + */ +static inline size_t rz_bits_trailing_zeros(ut64 v) { + if (v == 0) { + return 64; + } +#if HAVE___BUILTIN_CTZLL + return __builtin_ctzll(v); +#else + // src: https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch + size_t c; + if (v & 0x1) { + // special case for odd v (assumed to happen half of the time) + return 0; + } + c = 1; + if ((v & 0xffffffff) == 0) { + v >>= 32; + c += 32; + } + if ((v & 0xffff) == 0) { + v >>= 16; + c += 16; + } + if ((v & 0xff) == 0) { + v >>= 8; + c += 8; + } + if ((v & 0xf) == 0) { + v >>= 4; + c += 4; + } + if ((v & 0x3) == 0) { + v >>= 2; + c += 2; + } + c -= v & 0x1; + return c; +#endif +} + +/** + * \brief Get the number of leading zeros of a 64-bit integer in binary representation. + * \param x the 64-bit integer + * \return the number of leading zeros + */ +static inline int rz_bits_leading_zeros(ut64 x) { + if (x == 0) { + return 64; + } +#if HAVE___BUILTIN_CLZLL + return __builtin_clzll(x); +#else + int n = 0; + if (x == 0) + return 64; + + if (x <= 0x00000000FFFFFFFFULL) { + n = n + 32; + x = x << 32; + } + if (x <= 0x0000FFFFFFFFFFFFULL) { + n = n + 16; + x = x << 16; + } + if (x <= 0x00FFFFFFFFFFFFFFULL) { + n = n + 8; + x = x << 8; + } + if (x <= 0x0FFFFFFFFFFFFFFFULL) { + n = n + 4; + x = x << 4; + } + if (x <= 0x3FFFFFFFFFFFFFFFULL) { + n = n + 2; + x = x << 2; + } + if (x <= 0x7FFFFFFFFFFFFFFFULL) { + n = n + 1; + } + + return n; +#endif +} + +/** + * \brief Copies a bit range from \p src to \p dst at specified positions + * \param src 64-bit unsigned integer to copy bits from + * \param src_pos bit position related to \p src + * \param dst 64-bit unsigned integer to copy bits to + * \param dst_pos bit position related to \p dst + * \param size number of bits to copy (needs to be <= 64) + * \return a new 64-bit unsigned integer with the specified bit range replaced + */ +static inline ut64 rz_bits_copy_ut64(ut64 src, ut8 src_pos, ut64 dst, ut8 dst_pos, ut8 size) { + if (size >= 64) { + return src; + } + + ut64 mask = ((1ull) << size) - 1; + return (dst & ~(mask << dst_pos)) | (src >> src_pos & mask) << dst_pos; +} + +/** + * \brief Similar to rz_bits_copy_ut64() but for 8-bit unsigned integers + */ +static inline ut8 rz_bits_copy_ut8(ut8 src, ut8 src_pos, ut8 dst, ut8 dst_pos, ut8 size) { + if (size >= 8) { + return src; + } + + ut8 mask = ((1u) << size) - 1; + return (dst & ~(mask << dst_pos)) | (src >> src_pos & mask) << dst_pos; +} + +/** + * \brief Sign-extends a value from a specified bit-width to full width of type. + * + * This macro defines an inline function that performs sign extension on an + * unsigned integer value of `bits` significant bits, extending it to a signed + * integer of full bit-width `B`. It works for 8, 16, 32, and 64-bit integers. + * + * The function shifts the value left to discard higher bits, then arithmetically + * shifts it back right, preserving the sign. + * + * \param value The input unsigned integer of type ut##B. + * \param bits The number of significant bits in `value` (must be less than or equal to B). + * \return The sign-extended signed integer of type st##B. + */ +#define SIGN_EXT_IMPL(B) \ + static inline st##B rz_bits_sign_ext##B(ut##B value, ut##B bits) { \ + return (st##B)(value << (B - bits)) >> (B - bits); \ + } + +SIGN_EXT_IMPL(8); +SIGN_EXT_IMPL(16); +SIGN_EXT_IMPL(32); +SIGN_EXT_IMPL(64); + +RZ_API ut64 rz_bits_spread(const ut64 mask, const ut64 value); + +#ifdef __cplusplus +} +#endif +#endif // RIZIN_RZ_BITS_H diff --git a/dest/include/librz/rz_util/rz_bitvector.h b/dest/include/librz/rz_util/rz_bitvector.h new file mode 100644 index 00000000000..7af3fa0ce60 --- /dev/null +++ b/dest/include/librz/rz_util/rz_bitvector.h @@ -0,0 +1,157 @@ +// SPDX-FileCopyrightText: 2021 heersin +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_BITVECTOR_H +#define RZ_BITVECTOR_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \struct bitvector_t + * \brief structure for bitvector + * + * Ref : https://web.cs.dal.ca/~jamie/UWO/BitVectors/README.html + */ +typedef struct bitvector_t { + struct { + ut8 *large_a; ///< little endian array of bytes for bitvectors > 64 bits whose size is defined in _elem_len + ut64 small_u; ///< value of the bitvector when the size is <= 64 bits + } bits; + /** + * \brief This flag is set if the bit vector is allocated on the stack. + * This means large_a must not be reallocated or freed. + */ + bool stack_alloc; + /** + * \brief length of ut8 array (bits.large_a) -- real / physical + * NOTE: It is possible that a bits.large_a is larger than required for the + * bit vector length. + */ + ut32 _elem_len; + ut32 len; ///< number of bits -- virtual / logical +} RzBitVector; + +// init +RZ_API bool rz_bv_init(RZ_NONNULL RzBitVector *bv, ut32 length); +RZ_API RZ_OWN RzBitVector *rz_bv_new(ut32 length); +RZ_API RZ_OWN RzBitVector *rz_bv_dup(const RZ_NONNULL RzBitVector *bv); +RZ_API RZ_OWN RzBitVector *rz_bv_append(RZ_NONNULL RzBitVector *bv1, RZ_NONNULL RzBitVector *bv2); +RZ_API ut32 rz_bv_copy(RZ_NONNULL RzBitVector *dst, RZ_NONNULL const RzBitVector *src); +RZ_API ut32 rz_bv_copy_nbits( + RZ_NONNULL RzBitVector *dst, ut32 dst_start_pos, + RZ_NONNULL const RzBitVector *src, ut32 src_start_pos, + ut32 nbit); +RZ_API void rz_bv_fini(RZ_NONNULL RzBitVector *bv); +RZ_API void rz_bv_free(RZ_NULLABLE RzBitVector *bv); +// read and write to a bit +RZ_API bool rz_bv_set(RZ_NONNULL RzBitVector *bv, ut32 pos, bool b); +RZ_API bool rz_bv_set_all(RZ_NONNULL RzBitVector *bv, bool b); +RZ_API bool rz_bv_set_range(RZ_NONNULL RzBitVector *bv, ut32 pos_start, ut32 pos_end, bool b); +RZ_API bool rz_bv_toggle(RZ_NONNULL RzBitVector *bv, ut32 pos); +RZ_API bool rz_bv_toggle_all(RZ_NONNULL RzBitVector *bv); +RZ_API RZ_OWN RzBitVector *rz_bv_append_zero(RZ_NONNULL RzBitVector *bv, ut32 delta_len); +RZ_API RZ_OWN RzBitVector *rz_bv_prepend_zero(RZ_NONNULL RzBitVector *bv, ut32 delta_len); +RZ_API RZ_OWN RzBitVector *rz_bv_cut_head(RZ_NONNULL RzBitVector *bv, ut32 delta_len); +RZ_API RZ_OWN RzBitVector *rz_bv_cut_tail(RZ_NONNULL RzBitVector *bv, ut32 delta_len); +RZ_API bool rz_bv_get(RZ_NONNULL const RzBitVector *bv, ut32 pos); +// logic operations +RZ_API bool rz_bv_lshift(RZ_NONNULL RzBitVector *bv, ut32 size); +RZ_API bool rz_bv_rshift(RZ_NONNULL RzBitVector *bv, ut32 size); +RZ_API bool rz_bv_lshift_fill(RZ_NONNULL RzBitVector *bv, ut32 size, bool fill_bit); +RZ_API bool rz_bv_rshift_fill(RZ_NONNULL RzBitVector *bv, ut32 size, bool fill_bit); +RZ_API RZ_OWN RzBitVector *rz_bv_and(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API bool rz_bv_and_inplace(RZ_INOUT RZ_NONNULL RzBitVector *x, RZ_NONNULL const RzBitVector *y); +RZ_API RZ_OWN RzBitVector *rz_bv_or(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API bool rz_bv_or_inplace(RZ_INOUT RZ_NONNULL RzBitVector *x, RZ_NONNULL const RzBitVector *y); +RZ_API RZ_OWN RzBitVector *rz_bv_xor(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API bool rz_bv_xor_inplace(RZ_INOUT RZ_NONNULL RzBitVector *x, RZ_NONNULL const RzBitVector *y); +#define rz_bv_neg rz_bv_complement_2 +#define rz_bv_neg_inplace rz_bv_complement_2_inplace +#define rz_bv_not rz_bv_complement_1 +#define rz_bv_not_inplace rz_bv_complement_1_inplace +RZ_API RZ_OWN RzBitVector *rz_bv_complement_1(RZ_NONNULL RzBitVector *bv); +RZ_API bool rz_bv_complement_1_inplace(RZ_INOUT RZ_NONNULL RzBitVector *bv); +RZ_API RZ_OWN RzBitVector *rz_bv_complement_2(RZ_NONNULL RzBitVector *bv); +RZ_API bool rz_bv_complement_2_inplace(RZ_INOUT RZ_NONNULL RzBitVector *bv); + +// Module 2 arithmetic operations +RZ_API RZ_OWN RzBitVector *rz_bv_add(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y, RZ_NULLABLE bool *carry); +RZ_API bool rz_bv_add_inplace(RZ_INOUT RZ_NONNULL RZ_BORROW RzBitVector *x, const RZ_NONNULL RzBitVector *y, RZ_NULLABLE bool *carry); +RZ_API RZ_OWN RzBitVector *rz_bv_sub(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y, RZ_NULLABLE bool *borrow); +RZ_API bool rz_bv_sub_inplace(RZ_INOUT RZ_NONNULL RzBitVector *x, RZ_INOUT RZ_NONNULL RzBitVector *y, RZ_NULLABLE bool *borrow); +RZ_API RZ_OWN RzBitVector *rz_bv_mul(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API bool rz_bv_mul_inplace(RZ_NONNULL RZ_INOUT RzBitVector *x, const RZ_NONNULL RzBitVector *y); +RZ_API RZ_OWN RzBitVector *rz_bv_div(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API bool rz_bv_div_inplace(RZ_NONNULL RZ_INOUT RzBitVector *x, const RZ_NONNULL RzBitVector *y); +RZ_API RZ_OWN RzBitVector *rz_bv_mod(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API bool rz_bv_mod_inplace(RZ_NONNULL RZ_INOUT RzBitVector *x, const RZ_NONNULL RzBitVector *y); +RZ_API RZ_OWN RzBitVector *rz_bv_sdiv(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API RZ_OWN RzBitVector *rz_bv_smod(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); + +RZ_API bool rz_bv_msb(RZ_NONNULL const RzBitVector *bv); +RZ_API bool rz_bv_lsb(RZ_NONNULL const RzBitVector *bv); +RZ_API bool rz_bv_eq(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API bool rz_bv_ule(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API bool rz_bv_sle(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); + +RZ_API ut32 rz_bv_clz(RZ_NONNULL RzBitVector *bv); +RZ_API ut32 rz_bv_ctz(RZ_NONNULL RzBitVector *bv); + +RZ_API bool rz_bv_cast_inplace(RZ_INOUT RZ_NONNULL RzBitVector *bv, ut32 to_size, bool fill_bit); +RZ_API RzBitVector *rz_bv_cast(RZ_NONNULL RzBitVector *bv, ut32 to_size, bool fill_bit); + +// some convert functions +RZ_API ut8 rz_bv_to_ut8(RZ_NONNULL const RzBitVector *x); +RZ_API ut16 rz_bv_to_ut16(RZ_NONNULL const RzBitVector *x); +RZ_API ut32 rz_bv_to_ut32(RZ_NONNULL const RzBitVector *x); +RZ_API ut64 rz_bv_to_ut64(RZ_NONNULL const RzBitVector *x); +// misc +RZ_API bool rz_bv_is_zero_vector(RZ_NONNULL const RzBitVector *x); +RZ_API bool rz_bv_is_all_one(RZ_NONNULL const RzBitVector *x); +RZ_API RZ_OWN RzBitVector *rz_bv_new_from_ut64(ut32 length, ut64 value); +RZ_API RZ_OWN RzBitVector *rz_bv_new_from_st64(ut32 length, st64 value); +RZ_API RZ_OWN RzBitVector *rz_bv_new_from_bytes_le(RZ_IN RZ_NONNULL const ut8 *buf, ut32 bit_offset, ut32 size); +RZ_API RZ_OWN RzBitVector *rz_bv_new_from_bytes_be(RZ_IN RZ_NONNULL const ut8 *buf, ut32 bit_offset, ut32 size); +RZ_API bool rz_bv_set_from_ut64(RZ_NONNULL RzBitVector *bv, ut64 value); +RZ_API bool rz_bv_set_from_st64(RZ_NONNULL RzBitVector *bv, st64 value); +RZ_API void rz_bv_set_from_bytes_ble(RZ_NONNULL RzBitVector *bv, RZ_IN RZ_NONNULL const ut8 *buf, ut32 bit_offset, ut32 size, bool big_endian); +RZ_API void rz_bv_set_from_bytes_le(RZ_NONNULL RzBitVector *bv, RZ_IN RZ_NONNULL const ut8 *buf, ut32 bit_offset, ut32 size); +RZ_API void rz_bv_set_from_bytes_be(RZ_NONNULL RzBitVector *bv, RZ_IN RZ_NONNULL const ut8 *buf, ut32 bit_offset, ut32 size); +RZ_API void rz_bv_set_to_bytes_ble(RZ_NONNULL const RzBitVector *bv, RZ_OUT RZ_NONNULL ut8 *buf, bool big_endian); +RZ_API void rz_bv_set_to_bytes_le(RZ_NONNULL const RzBitVector *bv, RZ_OUT RZ_NONNULL ut8 *buf); +RZ_API void rz_bv_set_to_bytes_be(RZ_NONNULL const RzBitVector *bv, RZ_OUT RZ_NONNULL ut8 *buf); +RZ_API RZ_OWN char *rz_bv_as_string(RZ_NONNULL const RzBitVector *bv); +RZ_API RZ_OWN char *rz_bv_as_hex_string(RZ_NONNULL const RzBitVector *bv, bool pad); + +RZ_API ut32 rz_bv_len(RZ_NONNULL const RzBitVector *bv); +RZ_API ut32 rz_bv_len_bytes(RZ_NONNULL const RzBitVector *bv); +RZ_API bool rz_bv_cmp(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API ut32 rz_bv_hash(RZ_NULLABLE RzBitVector *x); +#define rz_bv_new_zero(l) rz_bv_new(l) +#define rz_bv_new_one(l) rz_bv_new_from_ut64(l, 1) +#define rz_bv_new_two(l) rz_bv_new_from_ut64(l, 2) +#define rz_bv_new_minus_one(l) rz_bv_new_from_st64(l, -1) + +// extra added to basic +RZ_API RZ_OWN RzBitVector *rz_bv_pred(RZ_NONNULL RzBitVector *bv); +RZ_API RZ_OWN RzBitVector *rz_bv_succ(RZ_NONNULL RzBitVector *bv); +RZ_API bool rz_bv_arshift(RZ_NONNULL RzBitVector *bv, ut32 dist); +RZ_API RZ_OWN RzBitVector *rz_bv_signed_cast(RZ_NONNULL RzBitVector *bv, ut32 to_size); +RZ_API RZ_OWN RzBitVector *rz_bv_unsigned_cast(RZ_NONNULL RzBitVector *bv, ut32 to_size); + +RZ_API bool rz_bv_slt(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API bool rz_bv_ult(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API bool rz_bv_sgt(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API bool rz_bv_ugt(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API bool rz_bv_sge(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); +RZ_API bool rz_bv_uge(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_IL_BITVECTOR_H diff --git a/dest/include/librz/rz_util/rz_buf.h b/dest/include/librz/rz_util/rz_buf.h new file mode 100644 index 00000000000..e232e570634 --- /dev/null +++ b/dest/include/librz/rz_util/rz_buf.h @@ -0,0 +1,410 @@ +#ifndef RZ_BUF_H +#define RZ_BUF_H +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// TODO: choose whether the _at operations should preserve the current seek or not + +#define RZ_BUF_SET 0 +#define RZ_BUF_CUR 1 +#define RZ_BUF_END 2 + +typedef struct rz_buf_t RzBuffer; + +typedef bool (*RzBufferInit)(RzBuffer *b, const void *user); +typedef bool (*RzBufferFini)(RzBuffer *b); +typedef st64 (*RzBufferRead)(RZ_BORROW RzBuffer *b, RZ_OUT ut8 *buf, ut64 len); +typedef st64 (*RzBufferWrite)(RzBuffer *b, const ut8 *buf, ut64 len); +typedef ut64 (*RzBufferGetSize)(RzBuffer *b); +typedef bool (*RzBufferResize)(RzBuffer *b, ut64 newsize); +typedef st64 (*RzBufferSeek)(RzBuffer *b, st64 addr, int whence); +typedef ut8 *(*RzBufferGetWholeBuf)(RzBuffer *b, ut64 *sz); +typedef void (*RzBufferFreeWholeBuf)(RzBuffer *b); +typedef RzList *(*RzBufferNonEmptyList)(RzBuffer *b); + +typedef struct rz_buffer_methods_t { + RzBufferInit init; + RzBufferFini fini; + RzBufferRead read; ///< The buffer read() method. It should behave as rz_buf_read() documents. + RzBufferWrite write; + RzBufferGetSize get_size; + RzBufferResize resize; + RzBufferSeek seek; + RzBufferGetWholeBuf get_whole_buf; + RzBufferFreeWholeBuf free_whole_buf; +} RzBufferMethods; + +typedef enum { + RZ_BUFFER_INVALID = 0, + RZ_BUFFER_FILE, + RZ_BUFFER_IO_FD, + RZ_BUFFER_IO, ///< A buffer over RzIO. + RZ_BUFFER_BYTES, ///< A buffer over raw bytes. + RZ_BUFFER_MMAP, + RZ_BUFFER_SPARSE, + RZ_BUFFER_REF, + RZ_BUFFER_CUSTOM, ///< A buffer with custom methods. +} RzBufferType; + +struct rz_buf_t { + RzBufferType type; + const RzBufferMethods *methods; + void *priv; + ut8 *whole_buf; + bool readonly; + ut8 Oxff_priv; + int refctr; + int fd; +}; + +typedef struct rz_buf_sparse_chunk_t { + ut64 from; ///< inclusive + ut64 to; ///< inclusive, there can't be chunks with size == 0 + ut8 *data; ///< size == to - from + 1 +} RzBufferSparseChunk; + +typedef enum { + RZ_BUF_SPARSE_WRITE_MODE_SPARSE, ///< all writes are performed in the sparse overlay + RZ_BUF_SPARSE_WRITE_MODE_THROUGH ///< all writes are performed in the underlying base buffer +} RzBufferSparseWriteMode; + +/* utils */ + +/// change cur according to addr and whence (RZ_BUF_SET/RZ_BUF_CUR/RZ_BUF_END) +static inline st64 rz_seek_offset(ut64 cur, ut64 length, st64 addr, int whence) { + switch (whence) { + case RZ_BUF_CUR: + if (ST64_ADD_OVFCHK((st64)cur, addr)) { + return -1; + } + return cur + addr; + case RZ_BUF_SET: + if ((st64)addr < 0) { + return -1; + } + return addr; + case RZ_BUF_END: + if (ST64_ADD_OVFCHK((st64)length, addr)) { + return -1; + } + return length + addr; + default: + rz_warn_if_reached(); + return -1; + } +} + +/* constructors */ +RZ_API RZ_OWN RzBuffer *rz_buf_new_empty(ut64 len); +RZ_API RZ_OWN RzBuffer *rz_buf_new_file(const char *file, int perm, int mode); +RZ_API RZ_OWN RzBuffer *rz_buf_new_mmap(const char *file, int flags, int mode); +RZ_API RZ_OWN RzBuffer *rz_buf_new_slice(RzBuffer *b, ut64 offset, ut64 size); +RZ_API RZ_OWN RzBuffer *rz_buf_new_slurp(const char *file); +RZ_API RZ_OWN RzBuffer *rz_buf_new_sparse(ut8 Oxff); +RZ_API RZ_OWN RzBuffer *rz_buf_new_sparse_overlay(RzBuffer *b, RzBufferSparseWriteMode write_mode); +RZ_API RZ_OWN RzBuffer *rz_buf_new_with_buf(RzBuffer *b); +RZ_API RZ_OWN RzBuffer *rz_buf_new_with_bytes(RZ_NULLABLE RZ_BORROW const ut8 *bytes, ut64 len); +RZ_API RZ_OWN RzBuffer *rz_buf_new_from_bytes(RZ_NULLABLE RZ_OWN ut8 *bytes, ut64 len); +RZ_API RZ_OWN RzBuffer *rz_buf_new_with_io_fd(RZ_NONNULL void /* RzIOBind */ *iob, int fd); +RZ_API RZ_OWN RzBuffer *rz_buf_new_with_io(RZ_NONNULL void /* RzIOBind */ *iob); +RZ_API RZ_OWN RzBuffer *rz_buf_new_with_methods(RZ_NONNULL const RzBufferMethods *methods, void *init_user, RzBufferType type); +RZ_API RZ_OWN RzBuffer *rz_buf_new_with_pointers(const ut8 *bytes, ut64 len, bool steal); +RZ_API RZ_OWN RzBuffer *rz_buf_new_with_string(RZ_NONNULL const char *msg); + +/* methods */ + +RZ_API RZ_OWN char *rz_buf_get_nstring(RZ_NONNULL RzBuffer *b, ut64 addr, size_t size); +RZ_API RZ_OWN char *rz_buf_get_string(RZ_NONNULL RzBuffer *b, ut64 addr); +RZ_API ut64 rz_buf_read_string(RZ_NONNULL RzBuffer *b, RZ_BORROW RZ_NULLABLE char **s); +RZ_API RZ_OWN char *rz_buf_to_string(RZ_NONNULL RzBuffer *b); +RZ_API RzBuffer *rz_buf_ref(RzBuffer *b); +RZ_API bool rz_buf_append_buf(RZ_NONNULL RzBuffer *b, RZ_NONNULL RzBuffer *a); +RZ_API bool rz_buf_append_buf_slice(RZ_NONNULL RzBuffer *b, RZ_NONNULL RzBuffer *a, ut64 offset, ut64 size); +RZ_API bool rz_buf_append_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len); +RZ_API bool rz_buf_append_nbytes(RZ_NONNULL RzBuffer *b, ut64 len); +RZ_API bool rz_buf_append_ut16(RZ_NONNULL RzBuffer *b, ut16 n); +RZ_API bool rz_buf_append_ut32(RZ_NONNULL RzBuffer *b, ut32 n); +RZ_API bool rz_buf_append_ut64(RZ_NONNULL RzBuffer *b, ut64 n); +RZ_API bool rz_buf_dump(RZ_NONNULL RzBuffer *buf, RZ_NONNULL const char *file); +RZ_API bool rz_buf_fini(RzBuffer *b); +RZ_API bool rz_buf_prepend_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len); +RZ_API bool rz_buf_read8(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut8 *result); +RZ_API bool rz_buf_read8_at(RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *result); +RZ_API bool rz_buf_resize(RZ_NONNULL RzBuffer *b, ut64 newsize); +RZ_API bool rz_buf_set_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len); +RZ_API bool rz_buf_write8(RZ_NONNULL RzBuffer *b, ut8 value); +RZ_API bool rz_buf_write8_at(RZ_NONNULL RzBuffer *b, ut64 addr, ut8 value); +RZ_API st64 rz_buf_append_string(RZ_NONNULL RzBuffer *b, RZ_NONNULL const char *str); +RZ_API st64 rz_buf_fread(RZ_NONNULL RzBuffer *b, RZ_NONNULL ut8 *buf, RZ_NONNULL const char *fmt, int n); +RZ_API st64 rz_buf_fread_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL ut8 *buf, RZ_NONNULL const char *fmt, int n); +RZ_API st64 rz_buf_fwrite(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, RZ_NONNULL const char *fmt, int n); +RZ_API st64 rz_buf_fwrite_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL const ut8 *buf, RZ_NONNULL const char *fmt, int n); +RZ_API st64 rz_buf_insert_bytes(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL const ut8 *buf, ut64 len); +RZ_API st64 rz_buf_read(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len); +RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len); +RZ_API st64 rz_buf_seek(RZ_NONNULL RzBuffer *b, st64 addr, int whence); +RZ_API st64 rz_buf_write(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len); +RZ_API st64 rz_buf_write_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL const ut8 *buf, ut64 len); +RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b); +RZ_API ut64 rz_buf_tell(RZ_NONNULL RzBuffer *b); +RZ_API void rz_buf_free(RzBuffer *b); +RZ_API void rz_buf_set_overflow_byte(RZ_NONNULL RzBuffer *b, ut8 Oxff); +RZ_API bool rz_buf_is_bytes_buf(const RzBuffer *b); +RZ_DEPRECATE RZ_API RZ_BORROW ut8 *rz_buf_data(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut64 *size); +RZ_API RZ_BORROW const ut8 *rz_buf_get_whole_hot_paths(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut64 *sz); +RZ_API RzBufferType rz_buf_type(RZ_NONNULL const RzBuffer *b); + +/** + * \brief Callback to be used with rz_buf_fwd_scan(). + * + * \param buf Buffer it can read. + * \param len Length of buffer to read. + * \param user User data. + * + * \return The number of bytes read. + */ +typedef ut64 (*RzBufferFwdScan)(RZ_BORROW RZ_NONNULL const ut8 *buf, ut64 len, RZ_NULLABLE void *user); +RZ_API ut64 rz_buf_fwd_scan(RZ_NONNULL RzBuffer *b, ut64 start, ut64 amount, RZ_NONNULL RzBufferFwdScan fwd_scan, RZ_NULLABLE void *user); + +RZ_API st64 rz_buf_uleb128(RZ_NONNULL RzBuffer *buffer, RZ_NONNULL ut64 *value); +RZ_API st64 rz_buf_sleb128(RZ_NONNULL RzBuffer *buffer, RZ_NONNULL st64 *value); + +static inline st64 rz_buf_uleb128_at(RzBuffer *b, ut64 addr, ut64 *v) { + rz_buf_seek(b, addr, RZ_BUF_SET); + return rz_buf_uleb128(b, v); +} +static inline st64 rz_buf_sleb128_at(RzBuffer *b, ut64 addr, st64 *v) { + rz_buf_seek(b, addr, RZ_BUF_SET); + return rz_buf_sleb128(b, v); +} + +/* generated methods */ + +#define DEFINE_RZ_BUF_READ_BLE(size) \ + static inline bool rz_buf_read_ble##size(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut##size *result, bool big_endian) { \ + rz_return_val_if_fail(b && result, false); \ +\ + ut8 tmp[sizeof(ut##size)]; \ + if (rz_buf_read(b, tmp, sizeof(tmp)) != sizeof(tmp)) { \ + return false; \ + } \ +\ + *result = rz_read_ble##size(tmp, big_endian); \ + return true; \ + } \ +\ + static inline bool rz_buf_read_ble##size##_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut##size *result, bool big_endian) { \ + rz_return_val_if_fail(b && result, false); \ +\ + ut8 tmp[sizeof(ut##size)]; \ + if (rz_buf_read_at(b, addr, tmp, sizeof(tmp)) != sizeof(tmp)) { \ + return false; \ + } \ +\ + *result = rz_read_ble##size(tmp, big_endian); \ + return true; \ + } + +#define DEFINE_RZ_BUF_WRITE_BLE(size) \ + static inline bool rz_buf_write_ble##size(RZ_NONNULL RzBuffer *b, ut##size value, bool big_endian) { \ + ut8 tmp[sizeof(ut##size)]; \ + rz_write_ble##size(tmp, value, big_endian); \ +\ + return rz_buf_write(b, tmp, sizeof(tmp)) == sizeof(tmp); \ + } \ +\ + static inline bool rz_buf_write_ble##size##_at(RZ_NONNULL RzBuffer *b, ut64 addr, ut##size value, bool big_endian) { \ + ut8 tmp[sizeof(ut##size)]; \ + rz_write_ble##size(tmp, value, big_endian); \ +\ + return rz_buf_write_at(b, addr, tmp, sizeof(tmp)) == sizeof(tmp); \ + } + +/** + * \brief Read a big endian or little endian (ut16, ut32, ut64) at the specified address or cursor in the buffer. + * \param b ... + * \param addr (optional) + * \param result ... + * \param big_endian ... + * \return Return the status of the operation. + */ +DEFINE_RZ_BUF_READ_BLE(16) +DEFINE_RZ_BUF_READ_BLE(32) +DEFINE_RZ_BUF_READ_BLE(64) +DEFINE_RZ_BUF_READ_BLE(128) + +/** + * \brief Write a big endian or little endian ut16 at the specified address or cursor in the buffer. + * \param b ... + * \param addr (optional) + * \param result ... + * \param big_endian ... + * \return Return the status of the operation. + */ +DEFINE_RZ_BUF_WRITE_BLE(16) +DEFINE_RZ_BUF_WRITE_BLE(32) +DEFINE_RZ_BUF_WRITE_BLE(64) +DEFINE_RZ_BUF_WRITE_BLE(128) + +#define DEFINE_RZ_BUF_READ_OFFSET_BLE(size) \ + static inline bool rz_buf_read_ble##size##_offset(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT ut##size *result, bool big_endian) { \ + rz_return_val_if_fail(b && offset && result, false); \ + if (!rz_buf_read_ble##size##_at(b, *offset, result, big_endian)) { \ + return false; \ + } \ + *offset += sizeof(*result); \ + return true; \ + } + +static inline bool rz_buf_read_offset(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT ut8 *result, size_t size) { + rz_return_val_if_fail(b && offset && result, false); + if (rz_buf_read_at(b, *offset, result, size) != (st64)size) { + return false; + } + *offset += size; + return true; +} + +#define DEFINE_RZ_BUF_WRITE_OFFSET_BLE(size) \ + static inline bool rz_buf_write_ble##size##_offset(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_INOUT ut64 *offset, ut##size value, bool big_endian) { \ + rz_return_val_if_fail(b && offset, false); \ + if (!rz_buf_write_ble##size##_at(b, *offset, value, big_endian)) { \ + return false; \ + } \ + *offset += sizeof(value); \ + return true; \ + } + +static inline bool rz_buf_write_offset(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL ut8 *result, size_t size) { + rz_return_val_if_fail(b && offset && result, false); + if (rz_buf_write_at(b, *offset, result, size) != (st64)size) { + return false; + } + *offset += size; + return true; +} + +#define rz_buf_read_ble8_at(b, addr, result, endian) ((void)endian, rz_buf_read8_at(b, addr, result)) +#define rz_buf_write_ble8_at(b, addr, value, endian) ((void)endian, rz_buf_write8_at(b, addr, value)) + +/** + * \brief Read a big endian or little endian (ut16, ut32, ut64) at the specified offset in the buffer and shifts the offset. + * \param b ... + * \param offset ... + * \param result ... + * \param big_endian ... + * \return Return the status of the operation. + */ +DEFINE_RZ_BUF_READ_OFFSET_BLE(8) +DEFINE_RZ_BUF_READ_OFFSET_BLE(16) +DEFINE_RZ_BUF_READ_OFFSET_BLE(32) +DEFINE_RZ_BUF_READ_OFFSET_BLE(64) + +/** + * \brief Write a big endian or little endian ut16 at the specified address or cursor in the buffer and shifts the offset. + * \param b ... + * \param addr (optional) + * \param result ... + * \param big_endian ... + * \return Return the status of the operation. + */ +DEFINE_RZ_BUF_WRITE_OFFSET_BLE(8) +DEFINE_RZ_BUF_WRITE_OFFSET_BLE(16) +DEFINE_RZ_BUF_WRITE_OFFSET_BLE(32) +DEFINE_RZ_BUF_WRITE_OFFSET_BLE(64) + +#define rz_buf_read_le16(b, result) rz_buf_read_ble16(b, result, false) +#define rz_buf_read_le32(b, result) rz_buf_read_ble32(b, result, false) +#define rz_buf_read_le64(b, result) rz_buf_read_ble64(b, result, false) + +#define rz_buf_read_le16_at(b, addr, result) rz_buf_read_ble16_at(b, addr, result, false) +#define rz_buf_read_le32_at(b, addr, result) rz_buf_read_ble32_at(b, addr, result, false) +#define rz_buf_read_le64_at(b, addr, result) rz_buf_read_ble64_at(b, addr, result, false) + +#define rz_buf_read8_offset(b, offset, result) rz_buf_read_ble8_offset(b, offset, result, false) + +#define rz_buf_read_le16_offset(b, offset, result) rz_buf_read_ble16_offset(b, offset, result, false) +#define rz_buf_read_le32_offset(b, offset, result) rz_buf_read_ble32_offset(b, offset, result, false) +#define rz_buf_read_le64_offset(b, offset, result) rz_buf_read_ble64_offset(b, offset, result, false) + +#define rz_buf_read_be16(b, result) rz_buf_read_ble16(b, result, true) +#define rz_buf_read_be32(b, result) rz_buf_read_ble32(b, result, true) +#define rz_buf_read_be64(b, result) rz_buf_read_ble64(b, result, true) + +#define rz_buf_read_be16_at(b, addr, result) rz_buf_read_ble16_at(b, addr, result, true) +#define rz_buf_read_be32_at(b, addr, result) rz_buf_read_ble32_at(b, addr, result, true) +#define rz_buf_read_be64_at(b, addr, result) rz_buf_read_ble64_at(b, addr, result, true) + +#define rz_buf_read_be16_offset(b, offset, result) rz_buf_read_ble16_offset(b, offset, result, true) +#define rz_buf_read_be32_offset(b, offset, result) rz_buf_read_ble32_offset(b, offset, result, true) +#define rz_buf_read_be64_offset(b, offset, result) rz_buf_read_ble64_offset(b, offset, result, true) + +#define rz_buf_write_le16(b, value) rz_buf_write_ble16(b, value, false) +#define rz_buf_write_le32(b, value) rz_buf_write_ble32(b, value, false) +#define rz_buf_write_le64(b, value) rz_buf_write_ble64(b, value, false) + +#define rz_buf_write_le16_at(b, addr, value) rz_buf_write_ble16_at(b, addr, value, false) +#define rz_buf_write_le32_at(b, addr, value) rz_buf_write_ble32_at(b, addr, value, false) +#define rz_buf_write_le64_at(b, addr, value) rz_buf_write_ble64_at(b, addr, value, false) + +#define rz_buf_write8_offset(b, offset, value) rz_buf_write_ble8_offset(b, offset, value, false) + +#define rz_buf_write_le16_offset(b, offset, value) rz_buf_write_ble16_offset(b, offset, value, false) +#define rz_buf_write_le32_offset(b, offset, value) rz_buf_write_ble32_offset(b, offset, value, false) +#define rz_buf_write_le64_offset(b, offset, value) rz_buf_write_ble64_offset(b, offset, value, false) + +#define rz_buf_write_be16(b, value) rz_buf_write_ble16(b, value, true) +#define rz_buf_write_be32(b, value) rz_buf_write_ble32(b, value, true) +#define rz_buf_write_be64(b, value) rz_buf_write_ble64(b, value, true) + +#define rz_buf_write_be16_at(b, addr, value) rz_buf_write_ble16_at(b, addr, value, true) +#define rz_buf_write_be32_at(b, addr, value) rz_buf_write_ble32_at(b, addr, value, true) +#define rz_buf_write_be64_at(b, addr, value) rz_buf_write_ble64_at(b, addr, value, true) + +#define rz_buf_write_be16_offset(b, offset, value) rz_buf_write_ble16_offset(b, offset, value, true) +#define rz_buf_write_be32_offset(b, offset, value) rz_buf_write_ble32_offset(b, offset, value, true) +#define rz_buf_write_be64_offset(b, offset, value) rz_buf_write_ble64_offset(b, offset, value, true) + +#undef DEFINE_RZ_BUF_READ_BLE +#undef DEFINE_RZ_BUF_WRITE_BLE +#undef DEFINE_RZ_BUF_READ_OFFSET_BLE +#undef DEFINE_RZ_BUF_WRITE_OFFSET_BLE + +/** + * \brief Peeks at the next byte in the buffer without modify the buffer position. + * + * It assumes that the buffer contains at least one byte beyond the current position. + * otherwise, the behavior of the function is undefined. + * \param b The buffer + * \return The byte value + */ +static inline ut8 rz_buf_peek(RZ_NONNULL RzBuffer *b) { + ut8 x = 0; + rz_buf_read8_at(b, rz_buf_tell(b), &x); + return x; +} + +// sparse-specific + +RZ_API const RzBufferSparseChunk *rz_buf_sparse_get_chunks(RzBuffer *b, RZ_NONNULL size_t *count); +RZ_API void rz_buf_sparse_set_write_mode(RzBuffer *b, RzBufferSparseWriteMode mode); +RZ_API bool rz_buf_sparse_populated_in(RzBuffer *b, ut64 from, ut64 to); + +RZ_API bool rz_deflatew_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed, int wbits); +RZ_API bool rz_deflate_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed); +RZ_API bool rz_inflatew_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed, int wbits); +RZ_API bool rz_inflate_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed); +RZ_API bool rz_lzma_dec_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed); +RZ_API bool rz_lzma_enc_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_BUF_H diff --git a/dest/include/librz/rz_util/rz_debruijn.h b/dest/include/librz/rz_util/rz_debruijn.h new file mode 100644 index 00000000000..5fd24698428 --- /dev/null +++ b/dest/include/librz/rz_util/rz_debruijn.h @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2014 crowell +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_DEBRUIJN_H +#define RZ_DEBRUIJN_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// For information about the algorithm, see Joe Sawada and Frank Ruskey, "An +// Efficient Algorithm for Generating Necklaces with Fixed Density" + +RZ_API RZ_OWN char *rz_debruijn_pattern(int size, int start, const char *charset); +RZ_API int rz_debruijn_offset(int start, const char *charset, ut64 value, bool is_big_endian); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_DEBRUIJN_H diff --git a/dest/include/librz/rz_util/rz_event.h b/dest/include/librz/rz_util/rz_event.h new file mode 100644 index 00000000000..4ec71c3c94e --- /dev/null +++ b/dest/include/librz/rz_util/rz_event.h @@ -0,0 +1,94 @@ +// SPDX-FileCopyrightText: 2018 pancake +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_EVENT_H +#define RZ_EVENT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +typedef struct rz_event_t { + void *user; + bool incall; + HtUP *callbacks; + RzVector /**/ all_callbacks; + RzVector /**/ pending_unhook; ///< while inside of a call and a handle is unhooked, the unhook is deferred and saved here + int next_handle; +} RzEvent; + +typedef struct rz_event_callback_handle_t { + int handle; + int type; +} RzEventCallbackHandle; + +typedef void (*RzEventCallback)(RzEvent *ev, int type, void *user, void *data); + +typedef enum { + RZ_EVENT_ALL = 0, + RZ_EVENT_META_SET, // RzEventMeta + RZ_EVENT_META_DEL, // RzEventMeta + RZ_EVENT_META_CLEAR, // RzEventMeta + RZ_EVENT_CLASS_NEW, // RzEventClass + RZ_EVENT_CLASS_DEL, // RzEventClass + RZ_EVENT_CLASS_RENAME, // RzEventClassRename + RZ_EVENT_CLASS_ATTR_SET, // RzEventClassAttr + RZ_EVENT_CLASS_ATTR_DEL, // RzEventClassAttrSet + RZ_EVENT_CLASS_ATTR_RENAME, // RzEventClassAttrRename + RZ_EVENT_DEBUG_PROCESS_FINISHED, // RzEventDebugProcessFinished + RZ_EVENT_IO_WRITE, // RzEventIOWrite + RZ_EVENT_IO_DESC_CLOSE, // RzEventIODescClose + RZ_EVENT_IO_MAP_DEL, // RzEventIOMapDel + RZ_EVENT_BIN_FILE_DEL, // RzEventBinFileDel + RZ_EVENT_MAX, +} RzEventType; + +typedef struct rz_event_meta_t { + int type; + ut64 addr; + const char *string; +} RzEventMeta; + +typedef struct rz_event_class_t { + const char *name; +} RzEventClass; + +typedef struct rz_event_class_rename_t { + const char *name_old; + const char *name_new; +} RzEventClassRename; + +typedef struct rz_event_class_attr_t { + const char *class_name; + int attr_type; // RzAnalysisClassAttrType + const char *attr_id; +} RzEventClassAttr; + +typedef struct rz_event_class_attr_set_t { + RzEventClassAttr attr; + const char *content; +} RzEventClassAttrSet; + +typedef struct rz_event_class_attr_rename_t { + RzEventClassAttr attr; + const char *attr_id_new; +} RzEventClassAttrRename; + +typedef struct rz_event_debug_process_finished_t { + int pid; +} RzEventDebugProcessFinished; + +RZ_API RzEvent *rz_event_new(void *user); +RZ_API void rz_event_free(RzEvent *ev); +RZ_API RzEventCallbackHandle rz_event_hook(RzEvent *ev, int type, RzEventCallback cb, void *user); +RZ_API void rz_event_unhook(RzEvent *ev, RzEventCallbackHandle handle); +RZ_API void rz_event_send(RzEvent *ev, int type, void *data); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/rz_file.h b/dest/include/librz/rz_util/rz_file.h new file mode 100644 index 00000000000..33e53c4a8f1 --- /dev/null +++ b/dest/include/librz/rz_util/rz_file.h @@ -0,0 +1,83 @@ +#ifndef RZ_FILE_H +#define RZ_FILE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rz_mmap_t { + ut8 *buf; + ut64 base; + ut64 len; + int perm; + int mode; + char *filename; + int fd; +#if __WINDOWS__ + void *fm; +#endif +} RzMmap; + +/* is */ +RZ_API bool rz_file_is_abspath(const char *file); +RZ_API bool rz_file_is_c(const char *file); +RZ_API bool rz_file_is_directory(RZ_NULLABLE const char *str); +RZ_API bool rz_file_is_regular(const char *str); + +RZ_API bool rz_file_truncate(const char *filename, ut64 newsize); +RZ_API ut64 rz_file_size(const char *str); +RZ_API char *rz_file_root(const char *root, const char *path); +RZ_API RzMmap *rz_file_mmap(const char *file, int perm, int mode, ut64 base); +RZ_API void *rz_file_mmap_resize(RzMmap *m, ut64 newsize); +RZ_API void rz_file_mmap_free(RzMmap *m); +RZ_API bool rz_file_chmod(const char *file, const char *mod, int recursive); +RZ_API char *rz_file_temp(const char *prefix); +RZ_API char *rz_file_path(const char *bin); +RZ_API RZ_OWN char *rz_file_path_join(RZ_NONNULL const char *s1, RZ_NULLABLE const char *s2); +RZ_API const char *rz_file_basename(const char *path); +RZ_API const char *rz_file_dos_basename(RZ_BORROW RZ_NONNULL const char *path); +RZ_API char *rz_file_dirname(const char *path); +RZ_API RZ_OWN char *rz_file_abspath_rel(const char *cwd, const char *file); +RZ_API RZ_OWN char *rz_file_abspath(const char *file); +// make path relative to base +RZ_API char *rz_file_relpath(const char *base, const char *path); +RZ_API char *rz_file_path_local_to_unix(const char *path); +RZ_API char *rz_file_path_unix_to_local(const char *path); +RZ_API char *rz_file_binsh(void); +RZ_API ut8 *rz_inflatew(RZ_NONNULL const ut8 *src, int srcLen, int *srcConsumed, int *dstLen, int wbits); +RZ_API ut8 *rz_inflate(RZ_NONNULL const ut8 *src, int srcLen, int *srcConsumed, int *dstLen); +RZ_API ut8 *rz_inflate_ignore_header(RZ_NONNULL const ut8 *src, int srcLen, int *srcConsumed, int *dstLen); +RZ_API ut8 *rz_deflatew(RZ_NONNULL const ut8 *src, int srcLen, int *srcConsumed, int *dstLen, int wbits); +RZ_API ut8 *rz_deflate(RZ_NONNULL const ut8 *src, int srcLen, int *srcConsumed, int *dstLen); +RZ_API ut8 *rz_file_gzslurp(const char *str, int *outlen, int origonfail); +RZ_API char *rz_stdin_slurp(int *sz); +RZ_API RZ_OWN char *rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz); +RZ_API RZ_OWN char *rz_file_slurp_range(RZ_NONNULL const char *str, ut64 off, int sz, RZ_OUT RZ_NULLABLE int *osz); +RZ_API char *rz_file_slurp_random_line(const char *file); +RZ_API char *rz_file_slurp_random_line_count(const char *file, int *linecount); +RZ_API ut8 *rz_file_slurp_hexpairs(const char *str, int *usz); +RZ_API bool rz_file_dump(const char *file, const ut8 *buf, int len, bool append); +RZ_API bool rz_file_touch(const char *file); +RZ_API bool rz_file_hexdump(const char *file, const ut8 *buf, int len, int append); +RZ_API bool rz_file_rm(const char *file); +RZ_API bool rz_file_exists(RZ_NULLABLE const char *str); +RZ_API bool rz_file_fexists(const char *fmt, ...) RZ_PRINTF_CHECK(1, 2); +RZ_API char *rz_file_slurp_line(const char *file, int line, int context); +RZ_API char *rz_file_slurp_lines(const char *file, int line, int count); +RZ_API RZ_OWN char *rz_file_slurp_lines_from_bottom(const char *file, int line); +RZ_API int rz_file_mkstemp(RZ_NULLABLE const char *prefix, char **oname); +RZ_API char *rz_file_tmpdir(void); +RZ_API char *rz_file_readlink(const char *path); +RZ_API bool rz_file_copy(const char *src, const char *dst); +RZ_API RzList /**/ *rz_file_globsearch(const char *globbed_path, int maxdepth); +RZ_API bool rz_file_deflate(RZ_NONNULL const char *src, RZ_NONNULL const char *dst); +RZ_API bool rz_file_inflate(RZ_NONNULL const char *src, RZ_NONNULL const char *dst); +RZ_API bool rz_file_is_deflated(RZ_NONNULL const char *src); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_FILE_H diff --git a/dest/include/librz/rz_util/rz_float.h b/dest/include/librz/rz_util/rz_float.h new file mode 100644 index 00000000000..146bc2f4ada --- /dev/null +++ b/dest/include/librz/rz_util/rz_float.h @@ -0,0 +1,207 @@ +/** + * \file rz_float.h + * rizin's float representation based on bitvector + * current design targets the IEEE-754 float format implementation + * take berkeley softfloat algorithm as a ref + * ref : http://www.jhauser.us/arithmetic/SoftFloat.html + */ + +#ifndef RZ_FLOAT_H +#define RZ_FLOAT_H +#include +#include + +/** + * + * Portable float nums in C + */ +RZ_API float rz_types_gen_f32_nan(void); +RZ_API float rz_types_gen_f32_inf(void); +RZ_API double rz_types_gen_f64_nan(void); +RZ_API double rz_types_gen_f64_inf(void); +RZ_API long double rz_types_gen_f128_nan(void); +RZ_API long double rz_types_gen_f128_inf(void); + +#define F32_NAN (rz_types_gen_f32_nan()) +#define F32_PINF (rz_types_gen_f32_inf()) +#define F32_NINF (-rz_types_gen_f32_inf()) +#define F64_NAN (rz_types_gen_f64_nan()) +#define F64_PINF (rz_types_gen_f64_inf()) +#define F64_NINF (-rz_types_gen_f64_inf()) +#define F80_NAN (rz_types_gen_f128_nan()) +#define F80_PINF (rz_types_gen_f128_inf()) +#define F80_NINF (-rz_types_gen_f128_inf()) +#define F128_NAN (rz_types_gen_f128_nan()) +#define F128_PINF (rz_types_gen_f128_inf()) +#define F128_NINF (-rz_types_gen_f128_inf()) + +typedef enum rz_float_format_enum { + /// basic IEEE 754 float format enums + /// ref : https://en.wikipedia.org/wiki/IEEE_754#Basic_and_interchange_formats + /// 1. IEEE binary representations, use binary digits to represent float. machine-friendly + RZ_FLOAT_IEEE754_BIN_32, ///< IEEE-754 binary 32 format (single) + RZ_FLOAT_IEEE754_BIN_64, ///< IEEE-754 binary64 format (double) + RZ_FLOAT_IEEE754_BIN_80, ///< IEEE-754 binary80 format + RZ_FLOAT_IEEE754_BIN_128, ///< IEEE-754 binary128 format + RZ_FLOAT_IEEE754_BIN_16, ///< half precision + + /// 2. IEEE decimal representations, use decimal digits to represent float precisely + /// the standard doesn't give an encoding to store decimal digits in binary. + /// two encoding ways in real-world : Binary integer decimal (BID) and Densely packed decimal (DPD) + RZ_FLOAT_IEEE754_DEC_64, ///< IEEE-754 decimal64 format, not implemented + RZ_FLOAT_IEEE754_DEC_128, ///< IEEE-754 decimal128 format, not implemented + + /// may add others in the future + RZ_FLOAT_UNK ///< End of enums +} RzFloatFormat; + +typedef enum rz_float_format_info { + RZ_FLOAT_INFO_BASE, ///< base of float representation, 2 for binary, 10 for decimal representation + RZ_FLOAT_INFO_EXP_LEN, ///< info about width of exponent field, in bits + RZ_FLOAT_INFO_MAN_LEN, ///< info about width of mantissa field, in bits + RZ_FLOAT_INFO_TOTAL_LEN, ///< info of length of format bv + RZ_FLOAT_INFO_BIAS ///< exponent bias +} RzFloatInfo; + +typedef enum rz_float_round_enum { + RZ_FLOAT_RMODE_RNE, ///< rounding to nearest, ties to even + RZ_FLOAT_RMODE_RNA, ///< rounding to nearest, ties away + RZ_FLOAT_RMODE_RTP, ///< rounding towards positive + RZ_FLOAT_RMODE_RTN, ///< rounding towards negative + RZ_FLOAT_RMODE_RTZ, ///< rounding towards zero + RZ_FLOAT_RMODE_UNK ///< end +} RzFloatRMode; ///< Rounding Mode + +typedef enum rz_float_exception_enum { + RZ_FLOAT_E_INVALID_OP = 1, ///< Invalid operation + RZ_FLOAT_E_DIV_ZERO = 2, ///< Divide zero + RZ_FLOAT_E_OVERFLOW = 4, ///< overflow exception + RZ_FLOAT_E_UNDERFLOW = 8, ///< underflow exception + RZ_FLOAT_E_INEXACT = 16 ///< calculated result is inexact +} RzFloatException; + +/** IEEE-754-2008 special num in float (NaN, Infinity) + * A : MSB of the mantissa, represents `is_quiet` flag + * quiet_NaN : A == 1, signaling_NaN : A == 0 + * PA-RISC and MIPS, use A as is_signal flag. Should reverse the case + */ +typedef enum rz_float_speciality_enum { + RZ_FLOAT_SPEC_NOT = 0, ///< not a special num + RZ_FLOAT_SPEC_ZERO = 1, ///< zero float + RZ_FLOAT_SPEC_PINF = 2, ///< positive infinity + RZ_FLOAT_SPEC_NINF = 3, ///< negative infinity + RZ_FLOAT_SPEC_QNAN = 4, ///< Quiet NaN + RZ_FLOAT_SPEC_SNAN = 5, ///< Signaling NaN +} RzFloatSpec; + +typedef struct rz_float_t { + RzFloatFormat r; ///< An interpretation of bitvector + RzBitVector *s; ///< The bitvector of float + RzFloatException exception; ///< exception of float operations +} RzFloat; + +static inline bool rz_float_is_neg_zero_f32(float zero) { + if (zero == 0.0f) { + return 1.0f / zero == F32_NINF; + } + return false; +} + +static inline bool rz_float_is_neg_zero_f64(double zero) { + if (zero == 0.0) { + return 1.0 / zero == F64_NINF; + } + return false; +} + +static inline bool rz_float_is_neg_zero_long_double(long double zero) { + if (zero == 0.0l) { + return 1.0l / zero == F128_NINF; + } + return false; +} + +#define IS_NEG_ZERO32(z) rz_float_is_neg_zero_f32(z) +#define IS_NEG_ZERO64(z) rz_float_is_neg_zero_f64(z) +#define IS_NEG_ZEROLD(z) rz_float_is_neg_zero_long_double(z) + +RZ_API ut32 rz_float_get_format_info(RzFloatFormat format, RzFloatInfo which_info); +RZ_API void rz_float_fini(RZ_NONNULL RzFloat *f); +RZ_API void rz_float_free(RZ_NULLABLE RzFloat *f); +RZ_API bool rz_float_init(RZ_NONNULL RzFloat *f, RzFloatFormat format); +RZ_API RZ_OWN RzFloat *rz_float_new(RzFloatFormat format); +RZ_API RZ_OWN RzFloat *rz_float_dup(RZ_NONNULL RzFloat *f); +RZ_API RZ_OWN RzFloat *rz_float_new_from_f32(float value); +RZ_API RZ_OWN RzFloat *rz_float_new_from_f64(double value); +RZ_API RZ_OWN RzFloat *rz_float_new_from_f80(long double value); +RZ_API RZ_OWN RzFloat *rz_float_new_from_f128(long double value); +RZ_API RZ_OWN RzFloat *rz_float_new_from_bv(RZ_NONNULL const RzBitVector *bv); +RZ_API bool rz_float_set_from_f32(RZ_NONNULL RzFloat *f, float value); +RZ_API bool rz_float_set_from_f64(RZ_NONNULL RzFloat *f, double value); +RZ_API bool rz_float_set_from_f80(RZ_NONNULL RzFloat *f, long double value); +RZ_API bool rz_float_set_from_f128(RZ_NONNULL RzFloat *f, long double value); +RZ_API RZ_OWN RzBitVector *rz_float_get_exponent_squashed(RZ_NONNULL RzFloat *f); +RZ_API RZ_OWN RzBitVector *rz_float_get_mantissa_squashed(RZ_NONNULL RzFloat *f); +RZ_API RZ_OWN RzBitVector *rz_float_get_mantissa_stretched(RZ_NONNULL RzFloat *f); +RZ_API bool rz_float_get_sign(RZ_NONNULL RzFloat *f); +RZ_API bool rz_float_set_sign(RZ_NONNULL RzFloat *f, bool new_sign); +RZ_API RZ_OWN RzBitVector *rz_float_get_exponent(RZ_NONNULL RzFloat *f); +RZ_API RZ_OWN ut32 rz_float_get_exponent_val(RZ_NONNULL RzFloat *f); +RZ_API RZ_OWN st32 rz_float_get_exponent_val_no_bias(RZ_NONNULL RzFloat *f); +RZ_API RZ_OWN RzBitVector *rz_float_get_mantissa(RZ_NONNULL RzFloat *f); +RZ_API bool rz_float_is_negative(RZ_NONNULL RzFloat *f); +RZ_API RzFloatSpec rz_float_detect_spec(RZ_NONNULL RzFloat *f); +RZ_API bool rz_float_is_inf(RZ_NONNULL RzFloat *f); +RZ_API bool rz_float_is_nan(RZ_NONNULL RzFloat *f); +RZ_API bool rz_float_is_zero(RZ_NONNULL RzFloat *f); +RZ_API bool rz_float_is_equal(RZ_NONNULL RzFloat *x, RZ_NONNULL RzFloat *y); +RZ_API RZ_OWN RzFloat *rz_float_neg(RZ_NONNULL RzFloat *f); +RZ_API RZ_OWN RzFloat *rz_float_succ(RZ_NONNULL RzFloat *f); +RZ_API RZ_OWN RzFloat *rz_float_pred(RZ_NONNULL RzFloat *f); +RZ_API RZ_OWN st32 rz_float_cmp(RZ_NONNULL RzFloat *x, RZ_NONNULL RzFloat *y); + +RZ_API RZ_OWN RzFloat *rz_float_add_ieee_bin(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_sub_ieee_bin(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_mul_ieee_bin(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_div_ieee_bin(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_rem_ieee_bin(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_mod_ieee_bin(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_fma_ieee_bin(RZ_NONNULL RzFloat *a, RZ_NONNULL RzFloat *b, RZ_NONNULL RzFloat *c, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_sqrt_ieee_bin(RZ_NONNULL RzFloat *n, RzFloatRMode mode); + +RZ_API RZ_OWN RzFloat *rz_float_add(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_sub(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_mul(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_div(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_rem(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_mod(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_fma(RZ_NONNULL RzFloat *a, RZ_NONNULL RzFloat *b, RZ_NONNULL RzFloat *c, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_sqrt(RZ_NONNULL RzFloat *n, RzFloatRMode mode); + +RZ_API RZ_OWN RzFloat *rz_float_trunc(RZ_NONNULL RzFloat *f); +RZ_API RZ_OWN RzFloat *rz_float_abs(RZ_NONNULL RzFloat *f); +RZ_API RZ_OWN RzFloat *rz_float_round_to_integral(RZ_NONNULL RzFloat *f, RzFloatRMode mode); +RZ_API RZ_OWN RzBitVector *rz_float_round_significant(bool sign, RzBitVector *sig, ut32 precision, RzFloatRMode mode, bool *should_inc); +RZ_API RZ_OWN RzFloat *rz_float_round_bv_and_pack(bool sign, st32 exp, RzBitVector *sig, RzFloatFormat format, RzFloatRMode mode); + +RZ_API RZ_OWN RzFloat *rz_float_new_from_ut64_as_f64(ut64 value); +RZ_API RZ_OWN RzFloat *rz_float_new_from_ut32_as_f32(ut32 value); +RZ_API RZ_OWN char *rz_float_as_string(RZ_NULLABLE RzFloat *f); +RZ_API RZ_OWN char *rz_float_as_dec_string(RZ_NULLABLE RzFloat *f); +RZ_API RZ_OWN char *rz_float_as_bit_string(RZ_NULLABLE RzFloat *f); +RZ_API RZ_OWN char *rz_float_as_hex_string(RZ_NULLABLE RzFloat *f, bool use_pad); +RZ_API bool rz_float_set_from_inf(RZ_NONNULL RzFloat *f, bool is_negative); +RZ_API bool rz_float_set_from_zero(RZ_NONNULL RzFloat *f); +RZ_API bool rz_float_set_from_qnan(RZ_NONNULL RzFloat *f); +RZ_API bool rz_float_set_from_snan(RZ_NONNULL RzFloat *f); +RZ_API RZ_OWN RzFloat *rz_float_new_inf(RzFloatFormat format, bool is_negative); +RZ_API RZ_OWN RzFloat *rz_float_new_zero(RzFloatFormat format, bool negative); +RZ_API RZ_OWN RzFloat *rz_float_new_qnan(RzFloatFormat format); +RZ_API RZ_OWN RzFloat *rz_float_new_snan(RzFloatFormat format); + +RZ_API RZ_OWN RzFloat *rz_float_cast_float(RZ_NONNULL RzBitVector *bv, RzFloatFormat format, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_cast_sfloat(RZ_NONNULL RzBitVector *bv, RzFloatFormat format, RzFloatRMode mode); +RZ_API RZ_OWN RzBitVector *rz_float_cast_int(RZ_NONNULL RzFloat *f, ut32 length, RzFloatRMode mode); +RZ_API RZ_OWN RzBitVector *rz_float_cast_sint(RZ_NONNULL RzFloat *f, ut32 length, RzFloatRMode mode); +RZ_API RZ_OWN RzFloat *rz_float_convert(RZ_NONNULL RzFloat *f, RzFloatFormat format, RzFloatRMode mode); +#endif // RZ_FLOAT_H diff --git a/dest/include/librz/rz_util/rz_graph.h b/dest/include/librz/rz_util/rz_graph.h new file mode 100644 index 00000000000..191493e5cc5 --- /dev/null +++ b/dest/include/librz/rz_util/rz_graph.h @@ -0,0 +1,72 @@ +#ifndef RZ_GRAPH_H +#define RZ_GRAPH_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rz_graph_node_t { + unsigned int idx; + void *data; + RzList *out_nodes; + RzList *in_nodes; + RzList *all_neighbours; + RzListFree free; +} RzGraphNode; + +typedef struct rz_graph_edge_t { + RzGraphNode *from; + RzGraphNode *to; + int nth; +} RzGraphEdge; + +typedef struct rz_graph_t { + unsigned int n_nodes; + unsigned int n_edges; + int last_index; + RzList *nodes; /* RzGraphNode */ +} RzGraph; + +typedef struct rz_graph_visitor_t { + void (*discover_node)(RzGraphNode *n, struct rz_graph_visitor_t *vis); + void (*finish_node)(RzGraphNode *n, struct rz_graph_visitor_t *vis); + void (*tree_edge)(const RzGraphEdge *e, struct rz_graph_visitor_t *vis); + void (*back_edge)(const RzGraphEdge *e, struct rz_graph_visitor_t *vis); + void (*fcross_edge)(const RzGraphEdge *e, struct rz_graph_visitor_t *vis); + void *data; +} RzGraphVisitor; +typedef void (*RzGraphNodeCallback)(RzGraphNode *n, RzGraphVisitor *vis); +typedef void (*RzGraphEdgeCallback)(const RzGraphEdge *e, RzGraphVisitor *vis); + +// Contrructs a new RzGraph, returns heap-allocated graph. +RZ_API RzGraph *rz_graph_new(void); +// Destroys the graph and all nodes. +RZ_API void rz_graph_free(RzGraph *g); +// Gets the data of a node by index. +RZ_API RzGraphNode *rz_graph_get_node(const RzGraph *g, unsigned int idx); +RZ_API RzListIter *rz_graph_node_iter(const RzGraph *g, unsigned int idx); +RZ_API void rz_graph_reset(RzGraph *g); +RZ_API RzGraphNode *rz_graph_add_node(RzGraph *g, void *data); +RZ_API RzGraphNode *rz_graph_add_nodef(RzGraph *g, void *data, RzListFree user_free); +RZ_API void rz_graph_del_node(RzGraph *g, RZ_OWN RzGraphNode *n); +RZ_API void rz_graph_add_edge(RzGraph *g, RzGraphNode *from, RzGraphNode *to); +RZ_API void rz_graph_add_edge_at(RzGraph *g, RzGraphNode *from, RzGraphNode *to, int nth); +RZ_API RzGraphNode *rz_graph_node_split_forward(RzGraph *g, RzGraphNode *split_me, void *data); +RZ_API void rz_graph_del_edge(RzGraph *g, RzGraphNode *from, RzGraphNode *to); +RZ_API const RzList *rz_graph_get_neighbours(const RzGraph *g, const RzGraphNode *n); +RZ_API RzGraphNode *rz_graph_nth_neighbour(const RzGraph *g, const RzGraphNode *n, int nth); +RZ_API const RzList *rz_graph_innodes(const RzGraph *g, const RzGraphNode *n); +RZ_API const RzList *rz_graph_all_neighbours(const RzGraph *g, const RzGraphNode *n); +RZ_API const RzList *rz_graph_get_nodes(const RzGraph *g); +RZ_API bool rz_graph_adjacent(const RzGraph *g, const RzGraphNode *from, const RzGraphNode *to); +RZ_API void rz_graph_dfs_node(RzGraph *g, RzGraphNode *n, RzGraphVisitor *vis); +RZ_API void rz_graph_dfs_node_reverse(RzGraph *g, RzGraphNode *n, RzGraphVisitor *vis); +RZ_API void rz_graph_dfs(RzGraph *g, RzGraphVisitor *vis); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_GRAPH_H diff --git a/dest/include/librz/rz_util/rz_graph_drawable.h b/dest/include/librz/rz_util/rz_graph_drawable.h new file mode 100644 index 00000000000..8d836c24cc2 --- /dev/null +++ b/dest/include/librz/rz_util/rz_graph_drawable.h @@ -0,0 +1,112 @@ +#ifndef RZ_GRAPH_DRAWABLE_H +#define RZ_GRAPH_DRAWABLE_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RZ_GRAPH_NODE_TYPE_GROUP_MASK 0xff000000 + +typedef enum { + RZ_GRAPH_NODE_TYPE_NONE = 0, ///< No type for this node specified. + RZ_GRAPH_NODE_TYPE_DEFAULT, ///< Node contains a title string, a body string and an absract offset value. + RZ_GRAPH_NODE_TYPE_CFG, ///< Node is part of an control flow graph of a procedure. + RZ_GRAPH_NODE_TYPE_ICFG, ///< Node is part of an inter-procedural control flow graph. +} RzGraphNodeType; + +typedef enum { + RZ_GRAPH_NODE_SUBTYPE_NONE = 0, ///< No details given to this node. + RZ_GRAPH_NODE_SUBTYPE_CFG_ENTRY = 1 << 0, ///< Entry node of the procedure CFG. + RZ_GRAPH_NODE_SUBTYPE_CFG_CALL = 1 << 1, ///> A node which calls another procedure. + RZ_GRAPH_NODE_SUBTYPE_CFG_RETURN = 1 << 2, ///< A return node of the procedure. + RZ_GRAPH_NODE_SUBTYPE_CFG_EXIT = 1 << 3, ///< A node which exits the program (precedure does not return). + RZ_GRAPH_NODE_SUBTYPE_CFG_COND = 1 << 4, ///< A conditional instruction node. + RZ_GRAPH_NODE_SUBTYPE_ICFG_MALLOC = 1 << 5, ///< Node represents a memory allocating procedure. +} RzGraphNodeSubType; + +typedef struct { + char *title; + char *body; + /** + * \brief Optional offset for the object corresponding to node. + * + * Interactive output modes can use it to provide actions like seeking to + * this position or modify the object. + */ + ut64 offset; +} RzGraphNodeInfoDataDefault; + +typedef struct { + /** + * \brief Address of the node. + */ + ut64 address; + /** + * \brief Address of called procedure, if node is of type RZ_GRAPH_NODE_TYPE_CFG_CALL. + * It is set to UT64_MAX if invalid. + */ + ut64 call_address; +} RzGraphNodeInfoDataCFG; + +typedef struct { + /** + * \brief Address of the node. + */ + ut64 address; + bool is_malloc; ///< Flag set if this node is a memory allocating function. +} RzGraphNodeInfoDataICFG; + +/** + * \brief Generic drawable graph node. + * + * Provides minimal information to draw something without output format specific details. + */ +typedef struct rz_analysis_graph_node_info_t { + /** + * \brief Optional flags which describe the node further. + */ + RzGraphNodeType type; + RzGraphNodeSubType subtype; + union { + RzGraphNodeInfoDataDefault def; + RzGraphNodeInfoDataCFG cfg; + RzGraphNodeInfoDataICFG icfg; + }; +} RzGraphNodeInfo; + +RZ_API RZ_OWN char *rz_graph_get_node_subtype_annotation(RzGraphNodeSubType subtype, bool utf8); +RZ_API RZ_OWN RzGraphNodeInfo *rz_graph_get_node_info_data(RZ_BORROW void *data); +RZ_API void rz_graph_free_node_info(RZ_NULLABLE void *ptr); +RZ_API RzGraphNodeInfo *rz_graph_create_node_info_default(const char *title, const char *body, ut64 offset); +RZ_API RzGraphNodeInfo *rz_graph_create_node_info_icfg(ut64 address, RzGraphNodeType type, RzGraphNodeSubType subtype); +RZ_API RzGraphNodeInfo *rz_graph_create_node_info_cfg(ut64 address, ut64 call_target_addr, RzGraphNodeType type, RzGraphNodeSubType subtype); +RZ_API RzGraphNode *rz_graph_add_node_info(RzGraph /**/ *graph, const char *title, const char *body, ut64 offset); + +/** + * @brief Convert graph to Graphviz dot format. + * + * @param graph Graph with RzGraphNodeInfo used as node user data + * @param node_properties List node styling attributes. Can be set to NULL. + * @param edge_properties List edge styling attributes. Can be set to NULL. + */ +RZ_API RZ_OWN char *rz_graph_drawable_to_dot(RZ_NONNULL RzGraph /**/ *graph, RZ_NULLABLE const char *node_properties, RZ_NULLABLE const char *edge_properties); +/** + * @brief Convert graph to JSON. + * + * @param[in] graph Graph to convert + * @param[out] pj Json output structure. Can be used to include the resulting JSON value inside bigger JSON. + * @param[in] use_offset Set this to true if graph uses \ref RzGraphNodeInfo::offset offset field. + */ +RZ_API void rz_graph_drawable_to_json(RZ_NONNULL RzGraph /**/ *graph, RZ_NONNULL PJ *pj, bool use_offset); +RZ_API RZ_OWN char *rz_graph_drawable_to_json_str(RZ_NONNULL RzGraph /**/ *graph, bool use_offset); +RZ_API RZ_OWN char *rz_graph_drawable_to_cmd(RZ_NONNULL RzGraph /**/ *graph); +RZ_API RZ_OWN char *rz_graph_drawable_to_gml(RZ_NONNULL RzGraph /**/ *graph); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/dest/include/librz/rz_util/rz_hex.h b/dest/include/librz/rz_util/rz_hex.h new file mode 100644 index 00000000000..a0d39ff6824 --- /dev/null +++ b/dest/include/librz/rz_util/rz_hex.h @@ -0,0 +1,34 @@ +#ifndef RZ_HEX_H +#define RZ_HEX_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API int rz_hex_pair2bin(const char *arg); +RZ_API int rz_hex_str2bin_msb(RZ_NONNULL const char *in, RZ_NONNULL RZ_OUT ut8 *out); +RZ_API size_t rz_hex_str2bin_mask(RZ_NONNULL const char *in, RZ_NONNULL RZ_OUT ut8 *out, RZ_NULLABLE RZ_OUT ut8 *mask, bool lsb_extend); +RZ_API int rz_hex_str2bin(RZ_NONNULL const char *in, RZ_NONNULL RZ_OUT ut8 *out); +RZ_API int rz_hex_bin2str(const ut8 *in, int len, char *out); +RZ_API void rz_hex_ut2st_str(const ut32 in, RZ_INOUT char *out, const int len); +RZ_API char *rz_hex_bin2strdup(const ut8 *in, int len); +RZ_API bool rz_hex_to_byte(ut8 *val, ut8 c); +RZ_API ut8 rz_hex_digit_to_byte(const char c); +RZ_API ut16 rz_hex_digit_pair_to_byte(const char *c); +RZ_API int rz_hex_str_is_valid(const char *s, bool allow_prefix); +RZ_API st64 rz_hex_bin_truncate(ut64 in, int n); +RZ_API char *rz_hex_from_c(const char *code); +RZ_API char *rz_hex_from_py(const char *code); +RZ_API char *rz_hex_from_code(const char *code); +RZ_API char *rz_hex_no_code(const char *code); +RZ_API char *rz_hex_from_py_str(char *out, const char *code); +RZ_API char *rz_hex_from_py_array(char *out, const char *code); +RZ_API char *rz_hex_from_c_str(char *out, const char **code); +RZ_API char *rz_hex_from_c_array(char *out, const char *code); +#ifdef __cplusplus +} +#endif + +#endif // RZ_HEX_H diff --git a/dest/include/librz/rz_util/rz_idpool.h b/dest/include/librz/rz_util/rz_idpool.h new file mode 100644 index 00000000000..1d885557a60 --- /dev/null +++ b/dest/include/librz/rz_util/rz_idpool.h @@ -0,0 +1,84 @@ +// SPDX-FileCopyrightText: 2017-2018 condret +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_ID_STORAGE_H +#define RZ_ID_STORAGE_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rz_id_pool_t { + ut32 start_id; + ut32 last_id; + ut32 next_id; + RzVector *freed_ids; +} RzIDPool; + +RZ_API RzIDPool *rz_id_pool_new(ut32 start_id, ut32 last_id); +RZ_API bool rz_id_pool_grab_id(RzIDPool *pool, ut32 *grabber); +RZ_API bool rz_id_pool_kick_id(RzIDPool *pool, ut32 kick); +RZ_API void rz_id_pool_free(RzIDPool *pool); + +typedef struct rz_id_storage_t { + RzIDPool *pool; + void **data; + ut32 top_id; + ut32 size; +} RzIDStorage; + +typedef bool (*RzIDStorageForeachCb)(void *user, void *data, ut32 id); +typedef bool (*ROIDStorageCompareCb)(void *in, void *incoming, void *user, int *cmp_res); + +RZ_API RzIDStorage *rz_id_storage_new(ut32 start_id, ut32 last_id); +RZ_API bool rz_id_storage_set(RzIDStorage *storage, void *data, ut32 id); +RZ_API bool rz_id_storage_add(RzIDStorage *storage, void *data, ut32 *id); +RZ_API void *rz_id_storage_get(RzIDStorage *storage, ut32 id); +RZ_API bool rz_id_storage_get_next(RzIDStorage *storage, ut32 *id); +RZ_API bool rz_id_storage_get_prev(RzIDStorage *storage, ut32 *id); +RZ_API void rz_id_storage_delete(RzIDStorage *storage, ut32 id); +RZ_API void *rz_id_storage_take(RzIDStorage *storage, ut32 id); +RZ_API bool rz_id_storage_foreach(RzIDStorage *storage, RzIDStorageForeachCb cb, void *user); +RZ_API void rz_id_storage_free(RzIDStorage *storage); +RZ_API RzList *rz_id_storage_list(RzIDStorage *s); +RZ_API bool rz_id_storage_get_lowest(RzIDStorage *storage, ut32 *id); +RZ_API bool rz_id_storage_get_highest(RzIDStorage *storage, ut32 *id); + +typedef struct rz_ordered_id_storage_t { + ut32 *permutation; + ut32 psize; + ut32 ptop; + RzIDStorage *data; + ROIDStorageCompareCb cmp; +} ROIDStorage; + +RZ_API ROIDStorage *rz_oids_new(ut32 start_id, ut32 last_id); +RZ_API void *rz_oids_get(ROIDStorage *storage, ut32 id); +RZ_API void *rz_oids_oget(ROIDStorage *storage, ut32 od); +RZ_API bool rz_oids_get_id(ROIDStorage *storage, ut32 od, ut32 *id); +RZ_API bool rz_oids_get_od(ROIDStorage *storage, ut32 id, ut32 *od); +RZ_API bool rz_oids_to_front(ROIDStorage *storage, const ut32 id); +RZ_API bool rz_oids_to_rear(ROIDStorage *storage, const ut32 id); +RZ_API void rz_oids_delete(ROIDStorage *storage, ut32 id); +RZ_API void rz_oids_odelete(ROIDStorage *st, ut32 od); +RZ_API void rz_oids_free(ROIDStorage *storage); +RZ_API bool rz_oids_add(ROIDStorage *storage, void *data, ut32 *id, ut32 *od); +RZ_API void *rz_oids_take(ROIDStorage *storage, ut32 id); +RZ_API void *rz_oids_otake(ROIDStorage *st, ut32 od); +RZ_API bool rz_oids_foreach(ROIDStorage *storage, RzIDStorageForeachCb cb, void *user); +RZ_API bool rz_oids_foreach_prev(ROIDStorage *storage, RzIDStorageForeachCb cb, void *user); +RZ_API bool rz_oids_insert(ROIDStorage *storage, void *data, ut32 *id, ut32 *od, void *user); +RZ_API bool rz_oids_sort(ROIDStorage *storage, void *user); +RZ_API ut32 rz_oids_find(ROIDStorage *storage, void *incoming, void *user); +RZ_API void *rz_oids_last(ROIDStorage *storage); +RZ_API void *rz_oids_first(ROIDStorage *storage); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/rz_intervaltree.h b/dest/include/librz/rz_util/rz_intervaltree.h new file mode 100644 index 00000000000..72ab5cf5ea7 --- /dev/null +++ b/dest/include/librz/rz_util/rz_intervaltree.h @@ -0,0 +1,111 @@ +// SPDX-FileCopyrightText: 2019 thestr4ng3r +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_INTERVALTREE_H +#define RZ_INTERVALTREE_H + +#include "rz_rbtree.h" +#include "../rz_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * RzIntervalTree is a special RBTree (augmented red-black tree) + * that holds its entries, each associated with a interval, + * ordered by the start of the interval. + * + * It allows efficient lookup for intersections with a given interval or value. + * This is achieved by, at each node, saving the maximum value of the node + * and all of its children. + * + * It can hold multiple entries with the same start or end. + * For multiple entries with the same start, the ordering is undefined. + */ + +typedef struct rz_interval_node_t { + RBNode node; + ut64 start; // inclusive, key of the node + ut64 end; // may be inclusive or exclusive, this is only determined by how they are queried + ut64 max_end; // augmented value, maximum end of this node and all of its children + void *data; +} RzIntervalNode; + +typedef void (*RzIntervalNodeFree)(void *data); + +typedef struct rz_interval_tree_t { + RzIntervalNode *root; + RzIntervalNodeFree free; +} RzIntervalTree; + +RZ_API void rz_interval_tree_init(RzIntervalTree *tree, RzIntervalNodeFree free); +RZ_API void rz_interval_tree_fini(RzIntervalTree *tree); + +// return false if the insertion failed. +RZ_API bool rz_interval_tree_insert(RzIntervalTree *tree, ut64 start, ut64 end, void *data); + +// Removes a given node from the tree. The node will be freed. +// If free is true, the data in the node is freed as well. +// false if the removal failed +// Complexity is O(log(n) + m) if there are m nodes with the same start as the given node. +RZ_API bool rz_interval_tree_delete(RzIntervalTree *tree, RzIntervalNode *node, bool free); + +// Change start/end of a given node. +// It is more efficient if only the end changed. +// The RzIntervalNode pointer is INVALID after this operation! +// Complexity is O(log(n) + m) if there are m nodes with the same start as the given node. +RZ_API bool rz_interval_tree_resize(RzIntervalTree *tree, RzIntervalNode *node, ut64 new_start, ut64 new_end); + +// Returns an iterator that starts at the leftmost node that has the given start +// Iterating over it will yield all nodes with given start, then all with a higher one. +RZ_API RBIter rz_interval_tree_first_at(RzIntervalTree *tree, ut64 start); + +// Returns a node that starts at exactly start or NULL +RZ_API RzIntervalNode *rz_interval_tree_node_at(RzIntervalTree *tree, ut64 start); + +// Returns a node that starts at exactly start and contains data or NULL +RZ_API RzIntervalNode *rz_interval_tree_node_at_data(RzIntervalTree *tree, ut64 start, void *data); + +// Same as rz_interval_tree_node_at, but directly returns the contained value or NULL +static inline void *rz_interval_tree_at(RzIntervalTree *tree, ut64 start) { + RzIntervalNode *node = rz_interval_tree_node_at(tree, start); + return node ? node->data : NULL; +} + +typedef bool (*RzIntervalIterCb)(RzIntervalNode *node, void *user); + +// Call cb for all entries starting at exactly start +RZ_API bool rz_interval_tree_all_at(RzIntervalTree *tree, ut64 start, RzIntervalIterCb cb, void *user); + +// Call cb for all entries whose intervals contain value +// end_inclusive if true, all start/end values are considered inclusive/inclusive, else inclusive/exclusive +RZ_API bool rz_interval_tree_all_in(RzIntervalTree *tree, ut64 value, bool end_inclusive, RzIntervalIterCb cb, void *user); + +// Call cb for all entries whose intervals intersect the given interval (might not contain it completely) +// end_inclusive if true, all start/end values are considered inclusive/inclusive, else inclusive/exclusive +RZ_API bool rz_interval_tree_all_intersect(RzIntervalTree *tree, ut64 start, ut64 end, bool end_inclusive, RzIntervalIterCb cb, void *user); + +typedef RBIter RzIntervalTreeIter; + +static inline RzIntervalNode *rz_interval_tree_iter_get(RzIntervalTreeIter *it) { + return rz_rbtree_iter_get(it, RzIntervalNode, node); +} + +static inline bool rz_interval_tree_empty(RzIntervalTree *tree) { + return tree->root == NULL; +} + +#define rz_interval_tree_foreach(tree, it, dat) \ + if ((tree)->root) \ + for ((it) = rz_rbtree_first(&(tree)->root->node); rz_rbtree_iter_has(&it) && (dat = rz_interval_tree_iter_get(&it)->data); rz_rbtree_iter_next(&(it))) + +#define rz_interval_tree_foreach_prev(tree, it, dat) \ + if ((tree)->root) \ + for ((it) = rz_rbtree_last(&(tree)->root->node); rz_rbtree_iter_has(&it) && (dat = rz_rbtree_iter_get(&it, RzIntervalNode, node)->data); rz_rbtree_iter_prev(&(it))) + +#ifdef __cplusplus +} +#endif + +#endif // RZ_INTERVALTREE_H diff --git a/dest/include/librz/rz_util/rz_iterator.h b/dest/include/librz/rz_util/rz_iterator.h new file mode 100644 index 00000000000..af81bccf87e --- /dev/null +++ b/dest/include/librz/rz_util/rz_iterator.h @@ -0,0 +1,40 @@ +// SPDX-FileCopyrightText: 2024 billow +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_ITERATOR_H +#define RZ_ITERATOR_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct rz_iterator_t; +typedef void *(*rz_iterator_next_cb)(struct rz_iterator_t *); +typedef void (*rz_iterator_free_cb)(void *); + +typedef struct rz_iterator_t { + void *cur; + void *u; + rz_iterator_next_cb next; + rz_iterator_free_cb free; + rz_iterator_free_cb free_u; +} RzIterator; + +#define rz_iterator_foreach(iter, val) \ + for ((val) = rz_iterator_next(iter); (val) != NULL; (val) = rz_iterator_next(iter)) + +RZ_API RZ_OWN RzIterator *rz_iterator_new( + RZ_NONNULL rz_iterator_next_cb next, + RZ_NULLABLE rz_iterator_free_cb free, + RZ_NULLABLE rz_iterator_free_cb free_u, + RZ_NONNULL RZ_OWN void *u); +RZ_API RZ_BORROW void *rz_iterator_next(RZ_NONNULL RZ_BORROW RzIterator *it); +RZ_API void rz_iterator_free(RzIterator *it); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_ITERATOR_H diff --git a/dest/include/librz/rz_util/rz_itv.h b/dest/include/librz/rz_util/rz_itv.h new file mode 100644 index 00000000000..9b6ac35f07d --- /dev/null +++ b/dest/include/librz/rz_util/rz_itv.h @@ -0,0 +1,132 @@ +#ifndef RZ_INTERVAL_H +#define RZ_INTERVAL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief An interval in 64-bit address space which is aware of address space wraparound. + * + * Precondition: 0 <= size < 2**64 and addr + size <= 2**64 + * Interval range is [addr, addr + size) + * e.g. with addr = 10 and size = 5, interval range is [10, 15) where 10 <= x < (10 + 5). + * + * This interval is usually (though not always!) treated as right open interval. + */ +typedef struct rz_interval_t { + ut64 addr; ///< Start address of the interval. + ut64 size; ///< Size of the interval in bytes. +} RzInterval; + +typedef enum { + RZ_INTERVAL_IN = 0, ///< A value is in the interval. + RZ_INTERVAL_OUT, ///< A value is outside of the interval. + RZ_INTERVAL_UNDEF, ///< A value affiliation is not defined for the interval. +} RzIntervalAffiliation; + +typedef enum rz_interval_bound_t { + RZ_INTERVAL_BOUND_CLOSED = 0, ///< A closed interval: `[a, b]`. True if right and left open are NOT set. + RZ_INTERVAL_BOUND_RIGHT_OPEN = 1, ///< A right-open interval: `[a, b)`. This is the assumed default interpretation in Rizin. + RZ_INTERVAL_BOUND_LEFT_OPEN = 2, ///< A left-open interval: `(a, b]`. + RZ_INTERVAL_BOUND_OPEN = 3, ///< An open interval: `(a, b)`. True if right and left open are set. + RZ_INTERVAL_BOUND_UNDEF = 4, ///< Undefined. +} RzIntervalBound; + +/** + * \brief An interval with explicitly defined bounds. + */ +typedef struct { + ut64 a; ///< The left-hand value. + ut64 b; ///< The right-hand value. + RzIntervalBound bound; ///< Interval bound attribute. +} RzIntervalBoundedUt64; + +typedef RzInterval rz_itv_t; + +static inline RzIntervalAffiliation rz_itv_bound_contains_ut64(RzIntervalBoundedUt64 *itv, ut64 value) { + switch (itv->bound) { + default: + return RZ_INTERVAL_UNDEF; + case RZ_INTERVAL_BOUND_RIGHT_OPEN: + return (itv->a <= value && value < itv->b) ? RZ_INTERVAL_IN : RZ_INTERVAL_OUT; + case RZ_INTERVAL_BOUND_LEFT_OPEN: + return (itv->a < value && value <= itv->b) ? RZ_INTERVAL_IN : RZ_INTERVAL_OUT; + case RZ_INTERVAL_BOUND_OPEN: + return (itv->a < value && value < itv->b) ? RZ_INTERVAL_IN : RZ_INTERVAL_OUT; + case RZ_INTERVAL_BOUND_CLOSED: + return (itv->a <= value && value <= itv->b) ? RZ_INTERVAL_IN : RZ_INTERVAL_OUT; + } +} + +static inline RzInterval *rz_itv_new(ut64 addr, ut64 size) { + RzInterval *itv = RZ_NEW(RzInterval); + if (itv) { + itv->addr = addr; + itv->size = size; + } + return itv; +} + +static inline void rz_itv_free(RzInterval *itv) { + free(itv); +} + +static inline ut64 rz_itv_begin(RzInterval itv) { + return itv.addr; +} + +static inline ut64 rz_itv_size(RzInterval itv) { + return itv.size; +} + +static inline ut64 rz_itv_end(RzInterval itv) { + return itv.addr + itv.size; +} + +// Returns true if itv equals itv2 +static inline bool rz_itv_eq(RzInterval itv, RzInterval itv2) { + return itv.addr == itv2.addr && itv.size == itv2.size; +} + +// Returns true if itv contained addr +static inline bool rz_itv_contain(RzInterval itv, ut64 addr) { + const ut64 end = itv.addr + itv.size; + return itv.addr <= addr && (!end || addr < end); +} + +// Returns true if x is a subset of itv +static inline bool rz_itv_include(RzInterval itv, RzInterval x) { + const ut64 end = itv.addr + itv.size; + return itv.addr <= x.addr && (!end || (x.addr + x.size && x.addr + x.size <= end)); +} + +// Returns true if itv and x overlap (implying they are non-empty) +static inline bool rz_itv_overlap(RzInterval itv, RzInterval x) { + const ut64 end = itv.addr + itv.size, end1 = x.addr + x.size; + return (!end1 || itv.addr < end1) && (!end || x.addr < end); +} + +static inline bool rz_itv_overlap2(RzInterval itv, ut64 addr, ut64 size) { + RzInterval rai = { addr, size }; + return rz_itv_overlap(itv, rai); +} + +// Precondition: itv and x overlap +// Returns the intersection of itv and x +static inline RzInterval rz_itv_intersect(RzInterval itv, RzInterval x) { + const ut64 addr = RZ_MAX(itv.addr, x.addr); + const ut64 end = RZ_MIN(itv.addr + itv.size - 1, x.addr + x.size - 1) + 1; + RzInterval rai = { addr, end - addr }; + return rai; +} + +RZ_API bool rz_itv_str_to_bounded_itv_ut64(RZ_NONNULL const char *itv_str, RZ_OUT RzIntervalBoundedUt64 *out_itv); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_INTERVAL_H diff --git a/dest/include/librz/rz_util/rz_json.h b/dest/include/librz/rz_util/rz_json.h new file mode 100644 index 00000000000..2b38a6b7a9d --- /dev/null +++ b/dest/include/librz/rz_util/rz_json.h @@ -0,0 +1,75 @@ +// SPDX-FileCopyrightText: 2020 thestr4ng3r +// SPDX-FileCopyrightText: 2020 Yaroslav Stavnichiy +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_JSON_H +#define RZ_JSON_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * rz_json is a JSON parsing API, + * heavily based on nxjson by Yaroslav Stavnichiy , + * which is available under LGPLv3 or later. + * + * rz_json does NOT format json, it only parses. To format json, see rz_pj.h instead. + * It operates in-place, which means the parsed string will be MODIFIED. + * This means all string values in RzJson point directly into the input string, + * removing the need to copy them. + * + * It also supports both line and block style comments. + */ + +typedef enum rz_json_type_t { + RZ_JSON_NULL, + RZ_JSON_OBJECT, // properties can be found in child nodes + RZ_JSON_ARRAY, // items can be found in child nodes + RZ_JSON_STRING, // value can be found in the str_value field + RZ_JSON_INTEGER, // value can be found in the num.u_value/num.s_value fields + RZ_JSON_DOUBLE, // value can be found in the num.dbl_value field + RZ_JSON_BOOLEAN // value can be found in the num.u_value field +} RzJsonType; + +typedef struct rz_json_t { + RzJsonType type; // type of json node, see above + const char *key; // key of the property; for object's children only + union { + const char *str_value; // text value of STRING node + struct { + union { + ut64 u_value; // the value of INTEGER or BOOLEAN node + st64 s_value; + }; + double dbl_value; // the value of DOUBLE node + } num; + struct { // children of OBJECT or ARRAY + size_t count; + struct rz_json_t *first; + struct rz_json_t *last; + } children; + }; + struct rz_json_t *next; // points to next child +} RzJson; + +RZ_API RzJson *rz_json_parse(char *text); + +RZ_API void rz_json_free(RzJson *js); + +RZ_API const RzJson *rz_json_get(const RzJson *json, const char *key); // get object's property by key +RZ_API const RzJson *rz_json_item(const RzJson *json, size_t idx); // get array element by index +RZ_API const RzJson *rz_json_get_path(const RzJson *json, const char *path); // reach into an object by (simple) JSON path like [0].methods[1].flags[0] +RZ_API void rz_json_to_pj(const RzJson *json, RZ_NONNULL PJ *pj, bool with_key); +RZ_API RZ_OWN char *rz_json_as_string(const RzJson *json, bool with_key); // shows the string representation of RzJson +RZ_API bool rz_json_eq(RZ_NONNULL RZ_BORROW const RzJson *a, RZ_NONNULL RZ_BORROW const RzJson *b); +RZ_API bool rz_json_string_eq(RZ_NONNULL RZ_BORROW const char *sa, RZ_NONNULL RZ_BORROW const char *sb); + +#ifdef __cplusplus +} +#endif + +#endif /* NXJSON_H */ diff --git a/dest/include/librz/rz_util/rz_lang_byte_array.h b/dest/include/librz/rz_util/rz_lang_byte_array.h new file mode 100644 index 00000000000..66f06ec04ec --- /dev/null +++ b/dest/include/librz/rz_util/rz_lang_byte_array.h @@ -0,0 +1,43 @@ +// SPDX-FileCopyrightText: 2022 RizinOrg +// SPDX-FileCopyrightText: 2022 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_LANG_BYTE_ARRAY_H +#define RZ_LANG_BYTE_ARRAY_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum rz_lang_byte_array_type_t { + RZ_LANG_BYTE_ARRAY_RIZIN = 0, + RZ_LANG_BYTE_ARRAY_ASM, + RZ_LANG_BYTE_ARRAY_BASH, + RZ_LANG_BYTE_ARRAY_C_CPP_BYTES, + RZ_LANG_BYTE_ARRAY_C_CPP_HALFWORDS_BE, + RZ_LANG_BYTE_ARRAY_C_CPP_HALFWORDS_LE, + RZ_LANG_BYTE_ARRAY_C_CPP_WORDS_BE, + RZ_LANG_BYTE_ARRAY_C_CPP_WORDS_LE, + RZ_LANG_BYTE_ARRAY_C_CPP_DOUBLEWORDS_BE, + RZ_LANG_BYTE_ARRAY_C_CPP_DOUBLEWORDS_LE, + RZ_LANG_BYTE_ARRAY_GOLANG, + RZ_LANG_BYTE_ARRAY_JAVA, + RZ_LANG_BYTE_ARRAY_JSON, + RZ_LANG_BYTE_ARRAY_KOTLIN, + RZ_LANG_BYTE_ARRAY_NODEJS, + RZ_LANG_BYTE_ARRAY_OBJECTIVE_C, + RZ_LANG_BYTE_ARRAY_PYTHON, + RZ_LANG_BYTE_ARRAY_RUST, + RZ_LANG_BYTE_ARRAY_SWIFT, + RZ_LANG_BYTE_ARRAY_YARA, +} RzLangByteArrayType; + +RZ_API RZ_OWN char *rz_lang_byte_array(RZ_NONNULL const ut8 *buffer, size_t size, RzLangByteArrayType type); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_LANG_BYTE_ARRAY_H */ diff --git a/dest/include/librz/rz_util/rz_log.h b/dest/include/librz/rz_util/rz_log.h new file mode 100644 index 00000000000..8b9e268acf5 --- /dev/null +++ b/dest/include/librz/rz_util/rz_log.h @@ -0,0 +1,91 @@ +#ifndef RZ_LOG_H +#define RZ_LOG_H + +#include +#include + +#if (defined(_WIN32) || defined(_WIN64)) && !defined(__GNUC__) +#define MACRO_LOG_FUNC __FUNCTION__ +// TODO: Windows weak symbols? +#elif defined(__EMSCRIPTEN__) // TODO: test upon Emscripten's version once it supports weak symbols +#define MACRO_LOG_FUNC __func__ +#else +#define MACRO_LOG_FUNC __func__ +#endif + +typedef enum rz_log_level { + RZ_LOGLVL_DEBUG = 0, + RZ_LOGLVL_VERBOSE, + RZ_LOGLVL_INFO, + RZ_LOGLVL_WARN, + RZ_LOGLVL_ERROR, + RZ_LOGLVL_FATAL, ///< This will call rz_sys_breakpoint() and trap the process for debugging! + /* other flags */ + RZ_LOGLVL_SIZE, + RZ_LOGLVL_NONE = 0xFF +} RzLogLevel; + +#define RZ_DEFAULT_LOGLVL RZ_LOGLVL_WARN + +typedef void (*RzLogCallback)(const char *output, const char *funcname, const char *filename, + ut32 lineno, RzLogLevel level, const char *tag, const char *fmtstr, ...) RZ_PRINTF_CHECK(7, 8); + +#define RZ_VLOG(lvl, tag, fmtstr, args) rz_vlog(MACRO_LOG_FUNC, __FILE__, \ + __LINE__, lvl, tag, NULL, fmtstr, args); + +#define RZ_LOG(lvl, tag, fmtstr, ...) rz_log(MACRO_LOG_FUNC, __FILE__, \ + __LINE__, lvl, tag, fmtstr, ##__VA_ARGS__); + +#if RZ_BUILD_DEBUG +#define RZ_DEFAULT_LOGLVL_ABORT RZ_LOGLVL_FATAL +#define RZ_LOG_DEBUG(fmtstr, ...) rz_log(MACRO_LOG_FUNC, __FILE__, \ + __LINE__, RZ_LOGLVL_DEBUG, NULL, fmtstr, ##__VA_ARGS__); +#else +#define RZ_LOG_DEBUG(fmtstr, ...) +#endif + +#define RZ_LOG_VERBOSE(fmtstr, ...) rz_log(MACRO_LOG_FUNC, __FILE__, \ + __LINE__, RZ_LOGLVL_VERBOSE, NULL, fmtstr, ##__VA_ARGS__); +#define RZ_LOG_INFO(fmtstr, ...) rz_log(MACRO_LOG_FUNC, __FILE__, \ + __LINE__, RZ_LOGLVL_INFO, NULL, fmtstr, ##__VA_ARGS__); +#define RZ_LOG_WARN(fmtstr, ...) rz_log(MACRO_LOG_FUNC, __FILE__, \ + __LINE__, RZ_LOGLVL_WARN, NULL, fmtstr, ##__VA_ARGS__); +#define RZ_LOG_ERROR(fmtstr, ...) rz_log(MACRO_LOG_FUNC, __FILE__, \ + __LINE__, RZ_LOGLVL_ERROR, NULL, fmtstr, ##__VA_ARGS__); +#define RZ_LOG_FATAL(fmtstr, ...) rz_log(MACRO_LOG_FUNC, __FILE__, \ + __LINE__, RZ_LOGLVL_FATAL, NULL, fmtstr, ##__VA_ARGS__); + +#ifdef __cplusplus +extern "C" { +#endif + +// Called by rz_core to set the configuration variables +RZ_API void rz_log_set_level(RzLogLevel level); +RZ_API void rz_log_set_abortlevel(RzLogLevel level); +RZ_API bool rz_log_set_file(RZ_NULLABLE const char *filename); +RZ_API void rz_log_set_show_sources(bool show_sources); +RZ_API void rz_log_set_colors(bool show_colors); + +// Functions for adding log callbacks +RZ_API void rz_log_add_callback(RZ_NULLABLE RzLogCallback cbfunc); +RZ_API void rz_log_del_callback(RZ_NULLABLE RzLogCallback cbfunc); +// TODO: rz_log_get_callbacks() + +/* Define rz_log as weak so it can be 'overwritten' externally + This allows another method of output redirection on POSIX (Windows?) + You can override this function to handle all logging logic / output yourself */ +RZ_API void rz_log(const char *funcname, const char *filename, + ut32 lineno, RzLogLevel level, const char *tag, const char *fmtstr, ...) RZ_PRINTF_CHECK(6, 7); + +RZ_API void rz_vlog(const char *funcname, const char *filename, + ut32 lineno, RzLogLevel level, const char *tag, RZ_OWN RZ_NULLABLE const char **out, + const char *fmtstr, va_list args); + +RZ_API void rz_log_str(const char *funcname, const char *filename, + ut32 lineno, RzLogLevel level, const char *tag, const char *msg); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_LOG_H diff --git a/dest/include/librz/rz_util/rz_luhn.h b/dest/include/librz/rz_util/rz_luhn.h new file mode 100644 index 00000000000..52295641cd9 --- /dev/null +++ b/dest/include/librz/rz_util/rz_luhn.h @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2021 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_LUHN_H +#define RZ_LUHN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +RZ_API bool rz_calculate_luhn_value(const char *data, ut64 *result); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_LUHN_H */ diff --git a/dest/include/librz/rz_util/rz_mem.h b/dest/include/librz/rz_util/rz_mem.h new file mode 100644 index 00000000000..19c9a2da28a --- /dev/null +++ b/dest/include/librz/rz_util/rz_mem.h @@ -0,0 +1,64 @@ +#ifndef RZ_MEM_H +#define RZ_MEM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rz_mem_pool_t { + ut8 **nodes; + int ncount; + int npool; + // + int nodesize; + int poolsize; + int poolcount; +} RMemoryPool; + +RZ_API ut64 rz_mem_get_num(const ut8 *b, int size); + +/* MEMORY POOL */ +RZ_API void *rz_mem_dup(const void *s, int l); +RZ_API void rz_mem_memzero(void *, size_t); +RZ_API void rz_mem_reverse(ut8 *b, int l); +RZ_API int rz_mem_protect(void *ptr, int size, const char *prot); +RZ_API int rz_mem_set_num(ut8 *dest, int dest_size, ut64 num); +RZ_API int rz_mem_eq(const ut8 *a, const ut8 *b, int len); +RZ_API bool rz_mem_eq_masked(const ut8 *a, const ut8 *b, const ut8 *mask, size_t size); +RZ_API void rz_mem_copybits(ut8 *dst, const ut8 *src, int bits); +RZ_API void rz_mem_copybits_delta(ut8 *dst, int doff, const ut8 *src, int soff, int bits); +RZ_API void rz_mem_copyloop(ut8 *dest, const ut8 *orig, int dsize, int osize); +RZ_API void *rz_mem_copy(void *dest, size_t dmax, const void *src, size_t smax); +RZ_API const ut8 *rz_mem_mem(const ut8 *haystack, int hlen, const ut8 *needle, int nlen); +RZ_API const ut8 *rz_mem_mem_aligned(const ut8 *haystack, int hlen, const ut8 *needle, int nlen, int align); +RZ_API int rz_mem_count(const ut8 **addr); +RZ_API bool rz_mem_is_printable(const ut8 *a, int la); +RZ_API bool rz_mem_is_zero(const ut8 *b, int l); +RZ_API ut64 rz_mem_align_padding(const ut64 address, ut64 alignment); +RZ_API RZ_OWN ut8 *rz_mem_copy_offset(const ut8 *buf, size_t buf_size, size_t offset); +RZ_API RZ_OWN ut8 *rz_mem_swap_bytes_2(RZ_NONNULL const ut8 *buf, size_t buf_size); +RZ_API RZ_OWN ut8 *rz_mem_swap_bytes_2_inplace(RZ_OUT RZ_NONNULL ut8 *buf, size_t buf_size); +RZ_API RZ_OWN ut8 *rz_mem_swap_bytes_4(RZ_NONNULL const ut8 *buf, size_t buf_size); +RZ_API RZ_OWN ut8 *rz_mem_swap_bytes_4_inplace(RZ_OUT RZ_NONNULL ut8 *buf, size_t buf_size); + +/** + * \brief Returns the alignment of the \p ptr. + * + * \param ptr The pointer to get the alignment for. + * + * \return Returns the pointer alignment or UT64_MAX if \p ptr == NULL or ((utptr) ptr) == 0. + */ +static inline ut64 rz_mem_ptr_alignment(RZ_NONNULL const void *ptr) { + if (ptr == NULL || ((utptr)ptr) == 0) { + return UT64_MAX; + } + return 1ull << rz_bits_trailing_zeros((utptr)ptr); +} + +#ifdef __cplusplus +} +#endif +#endif // RZ_MEM_H diff --git a/dest/include/librz/rz_util/rz_name.h b/dest/include/librz/rz_util/rz_name.h new file mode 100644 index 00000000000..e23f79a030a --- /dev/null +++ b/dest/include/librz/rz_util/rz_name.h @@ -0,0 +1,19 @@ +#ifndef RZ_NAME_H +#define RZ_NAME_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API bool rz_name_check(const char *name, bool strict); +RZ_API bool rz_name_filter(char *name, int len, bool strict); +RZ_API char *rz_name_filter2(const char *name, bool strict); +RZ_API bool rz_name_validate_char(const char ch, bool strict); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_NAME_H diff --git a/dest/include/librz/rz_util/rz_num.h b/dest/include/librz/rz_util/rz_num.h new file mode 100644 index 00000000000..7b1fbfb9d8c --- /dev/null +++ b/dest/include/librz/rz_util/rz_num.h @@ -0,0 +1,178 @@ +#ifndef RZ_NUM_H +#define RZ_NUM_H + +#include + +#define RZ_NUMCALC_STRSZ 1024 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + double d; + ut64 n; +} RzNumCalcValue; + +typedef enum { + RNCNAME, + RNCNUMBER, + RNCEND, + RNCINC, + RNCDEC, + RNCLT, // comparison operator < + RNCGT, // comparison operator > + RNCPLUS = '+', + RNCMINUS = '-', + RNCMUL = '*', + RNCEXP = 'E', + RNCDIV = '/', + RNCMOD = '%', + // RNCXOR='^', RNCOR='|', RNCAND='&', + RNCNEG = '~', + RNCAND = '&', + RNCORR = '|', + RNCXOR = '^', + RNCPRINT = ';', + RNCASSIGN = '=', + RNCLEFTP = '(', + RNCRIGHTP = ')', + RNCSHL = '<', + RNCSHR = '>', + RNCROL = '#', + RNCROR = '$' +} RzNumCalcToken; + +typedef struct rz_num_calc_t { + RzNumCalcToken curr_tok; + RzNumCalcValue number_value; + char string_value[RZ_NUMCALC_STRSZ]; + int errors; + char oc; + const char *calc_err; + int calc_i; + const char *calc_buf; + int calc_len; + bool under_calc; +} RzNumCalc; + +typedef struct rz_num_t { + ut64 (*callback)(struct rz_num_t *userptr, const char *str, int *ok); + const char *(*cb_from_value)(struct rz_num_t *userptr, ut64 value, int *ok); + // RzNumCallback callback; + ut64 value; + double fvalue; + void *userptr; + int dbz; /// division by zero happened + RzNumCalc nc; +} RzNum; + +typedef ut64 (*RzNumCallback)(struct rz_num_t *self, const char *str, int *ok); +typedef const char *(*RzNumCallback2)(struct rz_num_t *self, ut64, int *ok); + +RZ_API RzNum *rz_num_new(RzNumCallback cb, RzNumCallback2 cb2, void *ptr); +RZ_API void rz_num_free(RzNum *num); +RZ_API char *rz_num_units(char *buf, size_t len, ut64 number); +RZ_API int rz_num_conditional(RzNum *num, const char *str); +RZ_API ut64 rz_num_calc(RzNum *num, const char *str, const char **err); +RZ_API const char *rz_num_calc_index(RzNum *num, const char *p); +RZ_API int rz_num_is_valid_input(RzNum *num, const char *input_value); +RZ_API ut64 rz_num_get_input_value(RzNum *num, const char *input_value); +RZ_API char *rz_num_as_string(RzNum *___, ut64 n, bool printable_only); +RZ_API ut64 rz_num_tail(RzNum *num, ut64 addr, const char *hex); +RZ_API ut64 rz_num_tail_base(RzNum *num, ut64 addr, ut64 off); +RZ_API void rz_num_minmax_swap(ut64 *a, ut64 *b); +RZ_API void rz_num_minmax_swap_i(int *a, int *b); // XXX this can be a cpp macro :?? +RZ_API ut64 rz_num_math(RzNum *num, const char *str); +RZ_API ut64 rz_num_get(RZ_NULLABLE RzNum *num, RZ_NULLABLE const char *str); +RZ_API int rz_num_to_bits(char *out, ut64 num); +RZ_API int rz_num_to_trits(char *out, ut64 num); // Rename this please +RZ_API ut32 rz_num_rand32(ut32 max); +RZ_API ut64 rz_num_rand64(ut64 max); +RZ_API void rz_num_irand(void); +RZ_API ut64 rz_get_input_num_value(RzNum *num, const char *input_value); +RZ_API bool rz_is_valid_input_num_value(RzNum *num, const char *input_value); +RZ_API int rz_num_between(RzNum *num, const char *input_value); +RZ_API int rz_num_str_len(const char *str); +RZ_API int rz_num_str_split(char *str); +RZ_API RzList /**/ *rz_num_str_split_list(char *str); +RZ_API void *rz_num_dup(ut64 n); +RZ_API size_t rz_num_base_of_string(RzNum *num, RZ_NONNULL const char *str); +RZ_API double rz_num_get_float(RzNum *num, const char *str); +RZ_API bool rz_num_is_hex_prefix(const char *p); + +/** + * \brief Absolute value of a 64-bit number. Store result in `ut64` + * \return unsigned 64-bit number + */ +static inline ut64 rz_num_abs(st64 num) { + if (num == ST64_MIN) { + return UT64_GT0; + } + return num < 0 ? -num : num; +} + +/** + * \brief Padding to align v to the next alignment-boundary. + * \return the least `d` such that `(v + d) % alignment == 0`. + */ +static inline ut64 rz_num_align_delta(ut64 v, ut64 alignment) { + if (!alignment) { + return 0; + } + ut64 excess = v % alignment; + if (!excess) { + return 0; + } + return alignment - excess; +} + +/** + * \brief Get the 64-bit value that has exactly its \p width lowest bits set to 1. + * e.g. + * rz_num_bitmask(2) == 0b11 + * rz_num_bitmask(3) == 0b111 + * ... + */ +static inline ut64 rz_num_bitmask(ut8 width) { + if (width >= 64) { + return 0xffffffffffffffffull; + } + return (1ull << (ut64)width) - 1; +} + +#define CONVERT_TO_TWO_COMPLEMENT(x) \ + static inline st##x convert_to_two_complement_##x(ut##x value) { \ + if (value <= ST##x##_MAX) { \ + return (st##x)value; \ + } \ +\ + value = ~value + 1; \ + return -(st##x)value; \ + } + +CONVERT_TO_TWO_COMPLEMENT(8) +CONVERT_TO_TWO_COMPLEMENT(16) +CONVERT_TO_TWO_COMPLEMENT(32) +CONVERT_TO_TWO_COMPLEMENT(64) + +/// Typical comparison (1/0/-1) for two numbers of arbitrary types, including unsigned +#define RZ_NUM_CMP(a, b) ((a) > (b) ? 1 : ((b) > (a) ? -1 : 0)) + +/** + * Divide 2^64 by the given divisor + * + * Idea: https://stackoverflow.com/a/55584872 + * Proof: https://git.sr.ht/~thestr4ng3r/isa-bit-twiddling/tree/808253ab4d262f9e7dd7b87d0396f1afd7c5804b/item/Bit_Twiddling.thy#L26-43 + * + * \param divisor must be non-zero + */ +static inline ut64 rz_num_2_pow_64_div(ut64 divisor) { + return (-(st64)divisor) / divisor + 1; +} + +#ifdef __cplusplus +} +#endif + +#endif // RZ_NUM_H diff --git a/dest/include/librz/rz_util/rz_panels.h b/dest/include/librz/rz_util/rz_panels.h new file mode 100644 index 00000000000..20d8aaf3d5d --- /dev/null +++ b/dest/include/librz/rz_util/rz_panels.h @@ -0,0 +1,83 @@ +#ifndef RZ_PANELS_H +#define RZ_PANELS_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + VERTICAL, + HORIZONTAL, + NONE +} RzPanelLayout; + +typedef enum { + PANEL_TYPE_DEFAULT = 0, + PANEL_TYPE_MENU = 1 +} RzPanelType; + +typedef enum { + PANEL_EDGE_NONE = 0, + PANEL_EDGE_BOTTOM, + PANEL_EDGE_RIGHT +} RzPanelEdge; + +typedef void (*RzPanelMenuUpdateCallback)(void *user, const char *parent); +typedef void (*RzPanelDirectionCallback)(void *user, int direction); +typedef void (*RzPanelRotateCallback)(void *user, bool rev); +typedef void (*RzPanelPrintCallback)(void *user, void *p); + +typedef struct rz_panel_pos_t { + int x; + int y; + int w; + int h; +} RzPanelPos; + +typedef struct rz_panel_model_t { + RzPanelDirectionCallback directionCb; + RzPanelRotateCallback rotateCb; + RzPanelPrintCallback print_cb; + RzPanelType type; + char *cmd; + char *title; + ut64 baseAddr; + ut64 addr; + bool cache; + char *cmdStrCache; + char *readOnly; + char *funcName; + RzPVector /**/ filter; + int n_filter; + int rotate; +} RzPanelModel; + +typedef struct rz_panel_view_t { + RzPanelPos pos; + RzPanelPos prevPos; + int sx; + int sy; + int curpos; + bool refresh; + int edge; +} RzPanelView; + +typedef struct rz_panel_t { + RzPanelModel *model; + RzPanelView *view; +} RzPanel; + +typedef void (*RzPanelAlmightyCallback)(void *user, RzPanel *panel, const RzPanelLayout dir, RZ_NULLABLE const char *title); + +RZ_IPI void rz_panel_free(RZ_NULLABLE RzPanel *panel); +RZ_IPI void rz_save_panels_layout(RzCore *core, const char *_name); +RZ_IPI bool rz_load_panels_layout(RzCore *core, const char *_name); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_PANELS_H diff --git a/dest/include/librz/rz_util/rz_path.h b/dest/include/librz/rz_util/rz_path.h new file mode 100644 index 00000000000..4d85498de0a --- /dev/null +++ b/dest/include/librz/rz_util/rz_path.h @@ -0,0 +1,59 @@ +#ifndef RZ_UTIL_PATH_H_ +#define RZ_UTIL_PATH_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Holds Rizin's path prefix and synchronization utilities. + * + * This structure stores the computed prefix of Rizin's path, along with a flag + * indicating whether the prefix has already been computed to avoid redundant work. + * It also includes a mutex to ensure thread-safe access when computing or accessing the prefix. + */ +typedef struct rz_path_t { + char *prefix; ///< the computed path prefix. + bool prefix_searched; ///< flag indicating if the prefix has already been computed. + RzThreadLock *prefix_mutex; ///< mutex to protect access to the prefix in multithreaded contexts. +} RzPath; + +#ifdef RZ_API + +RZ_API void rz_path_set_prefix(RZ_BORROW RZ_NONNULL RzPath *sys_path, RZ_NONNULL const char *path); +RZ_API const char *rz_path_prefix(RZ_BORROW RZ_NONNULL RzPath *sys_path); +RZ_API RZ_OWN char *rz_path_incdir(RZ_BORROW RZ_NULLABLE RzPath *sys_path); +RZ_API RZ_OWN char *rz_path_bindir(RZ_BORROW RZ_NULLABLE RzPath *sys_path); +RZ_API RZ_OWN char *rz_path_libdir(RZ_BORROW RZ_NULLABLE RzPath *sys_path); + +RZ_API RZ_OWN char *rz_path_system(RZ_BORROW RZ_NULLABLE RzPath *sys_path, RZ_NULLABLE const char *path); +RZ_API RZ_OWN char *rz_path_extra(RZ_NULLABLE const char *path); +RZ_API RZ_OWN char *rz_path_home_prefix(RZ_NULLABLE const char *path); +RZ_API RZ_OWN char *rz_path_home(RZ_NULLABLE const char *path); + +RZ_API RZ_OWN char *rz_path_system_rc(RZ_BORROW RZ_NULLABLE RzPath *sys_path); +RZ_API RZ_OWN char *rz_path_home_rc(void); +RZ_API RZ_OWN char *rz_path_home_config_rc(void); +RZ_API RZ_OWN char *rz_path_home_config_rcdir(void); +RZ_API RZ_OWN char *rz_path_home_config(void); +RZ_API RZ_OWN char *rz_path_home_cache(void); +RZ_API RZ_OWN char *rz_path_home_history(void); +RZ_API RZ_OWN char *rz_path_normalize_expand(char *usr_input, size_t len); + +RZ_API RZ_OWN char *rz_path_home_expand(RZ_NULLABLE const char *path); + +RZ_API RZ_OWN char *rz_path_realpath(RZ_NULLABLE const char *path); + +RZ_API RZ_OWN RzPath *rz_path_new(void); +RZ_API void rz_path_free(RZ_OWN RZ_NULLABLE RzPath *p); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/rz_pj.h b/dest/include/librz/rz_util/rz_pj.h new file mode 100644 index 00000000000..2e3f9eceb18 --- /dev/null +++ b/dest/include/librz/rz_util/rz_pj.h @@ -0,0 +1,90 @@ +#ifndef RZ_PJ_H +#define RZ_PJ_H + +#define RZ_PRINT_JSON_DEPTH_LIMIT 128 + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct pj_t { + RzStrBuf sb; + bool is_first; + bool is_key; + char braces[RZ_PRINT_JSON_DEPTH_LIMIT]; + int level; +} PJ; + +/* lifecycle */ +RZ_API PJ *pj_new(void); +RZ_API void pj_free(PJ *j); +RZ_API void pj_reset(PJ *j); // clear the pj contents, but keep the buffer allocated to re-use it +RZ_API char *pj_drain(PJ *j); +/* encode the pj data as a string */ +RZ_API const char *pj_string(PJ *pj); +// RZ_API void pj_print(PJ *j, PrintfCallback cb); +RZ_API void pj_raw(PJ *j, const char *k); + +/* nesting */ +// RZ_API PJ *pj_begin(char type, PrintfCallback cb); +/* close the current json list or array */ +RZ_API PJ *pj_end(PJ *j); +/* object, array */ +/* open new json list { */ +RZ_API PJ *pj_o(PJ *j); +/* open new array [ */ +RZ_API PJ *pj_a(PJ *j); +/* keys, values */ +/* new key with no value "name": */ +RZ_API PJ *pj_k(PJ *j, const char *k); +/* "name":"null" */ +RZ_API PJ *pj_knull(PJ *j, const char *k); +/* unsigned "name":n */ +RZ_API PJ *pj_kn(PJ *j, const char *k, ut64 n); +/* signed "name":n */ +RZ_API PJ *pj_kN(PJ *j, const char *k, st64 n); +/* literal key "name":"key" */ +RZ_API PJ *pj_ks(PJ *j, const char *k, const char *v); + +/* begin named array entry: "name": [...] */ +RZ_API PJ *pj_ka(PJ *j, const char *k); +/* begin named json entry: "name": {...} */ +RZ_API PJ *pj_ko(PJ *j, const char *k); + +/* named entry for primitive types */ +RZ_API PJ *pj_ki(PJ *j, const char *k, int d); +RZ_API PJ *pj_kd(PJ *j, const char *k, double d); +RZ_API PJ *pj_kf(PJ *j, const char *k, float d); +RZ_API PJ *pj_kb(PJ *j, const char *k, bool v); + +/* named "null" */ +RZ_API PJ *pj_null(PJ *j); + +/* array with first v_len bytes of v */ +RZ_API PJ *pj_r(PJ *j, const ut8 *v, size_t v_len); + +/* named entry with pj_r */ +RZ_API PJ *pj_kr(PJ *j, const char *k, const ut8 *v, size_t v_len); + +/* string, escaped for json */ +RZ_API PJ *pj_s(PJ *j, const char *k); +/* string, escaped for json without quotes */ +RZ_API PJ *pj_S(PJ *j, const char *k); +/* string, raw */ +RZ_API PJ *pj_j(PJ *j, const char *k); + +/* formatted primitive types */ +RZ_API PJ *pj_n(PJ *j, ut64 n); +RZ_API PJ *pj_N(PJ *j, st64 n); +RZ_API PJ *pj_i(PJ *j, int d); +RZ_API PJ *pj_d(PJ *j, double d); +RZ_API PJ *pj_f(PJ *j, float d); +RZ_API PJ *pj_b(PJ *j, bool v); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/rz_pkcs7.h b/dest/include/librz/rz_util/rz_pkcs7.h new file mode 100644 index 00000000000..2de9e611146 --- /dev/null +++ b/dest/include/librz/rz_util/rz_pkcs7.h @@ -0,0 +1,100 @@ +#ifndef RZ_PKCS7_H +#define RZ_PKCS7_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rz_pkcs7_certificaterevocationlists_t { + ut32 length; + RzX509CertificateRevocationList **elements; +} RzPKCS7CertificateRevocationLists; + +typedef struct rz_pkcs7_extendedcertificatesandcertificates_t { + ut32 length; + RzX509Certificate **elements; +} RzPKCS7ExtendedCertificatesAndCertificates; + +typedef struct rz_pkcs7_digestalgorithmidentifiers_t { + ut32 length; + RzX509AlgorithmIdentifier **elements; +} RzPKCS7DigestAlgorithmIdentifiers; + +typedef struct rz_pkcs7_contentinfo_t { + RzASN1String *contentType; // OID + RzASN1Binary *content; // optional. oid structure definition +} RzPKCS7ContentInfo; + +typedef struct rz_pkcs7_issuerandserialnumber_t { + RzX509Name issuer; + RzASN1Binary *serialNumber; +} RzPKCS7IssuerAndSerialNumber; + +typedef struct rz_pkcs7_attribute_t { + RzASN1String *oid; // OID + RzASN1Binary *data; // optional. oid structure definition +} RzPKCS7Attribute; + +typedef struct rz_pkcs7_attributes_t { + ut32 length; + RzPKCS7Attribute **elements; +} RzPKCS7Attributes; + +typedef struct rz_pkcs7_signerinfo_t { + ut32 version; + RzPKCS7IssuerAndSerialNumber issuerAndSerialNumber; + RzX509AlgorithmIdentifier digestAlgorithm; + RzPKCS7Attributes authenticatedAttributes; // Optional + RzX509AlgorithmIdentifier digestEncryptionAlgorithm; + RzASN1Binary *encryptedDigest; + RzPKCS7Attributes unauthenticatedAttributes; // Optional +} RzPKCS7SignerInfo; + +typedef struct rz_pkcs7_signerinfos_t { + ut32 length; + RzPKCS7SignerInfo **elements; +} RzPKCS7SignerInfos; + +typedef struct rz_pkcs7_signeddata_t { + ut32 version; + RzPKCS7DigestAlgorithmIdentifiers digestAlgorithms; + RzPKCS7ContentInfo contentInfo; + RzPKCS7ExtendedCertificatesAndCertificates certificates; // Optional + RzPKCS7CertificateRevocationLists crls; // Optional + RzPKCS7SignerInfos signerinfos; +} RzPKCS7SignedData; + +typedef struct rz_pkcs7_container_t { + RzASN1String *contentType; + RzPKCS7SignedData signedData; +} RzCMS; + +typedef struct rz_cms_attribute_type_optional_value_t { + RzASN1String *type; // OID + RzASN1Binary *data; // optional. +} RzSpcAttributeTypeAndOptionalValue; + +typedef struct rz_cms_digest_info_t { + RzX509AlgorithmIdentifier digestAlgorithm; + RzASN1Binary *digest; +} RzSpcDigestInfo; + +typedef struct rz_cms_indirect_data_content_t { + RzSpcAttributeTypeAndOptionalValue data; + RzSpcDigestInfo messageDigest; +} RzSpcIndirectDataContent; + +RZ_API RZ_OWN RzCMS *rz_pkcs7_cms_parse(RZ_NULLABLE const ut8 *buffer, ut32 length); +RZ_API void rz_pkcs7_cms_free(RZ_NULLABLE RzCMS *container); +RZ_API RZ_OWN RzStructuredData *rz_pkcs7_cms_to_structure(RZ_NULLABLE RzCMS *container); +RZ_API RZ_OWN RzSpcIndirectDataContent *rz_pkcs7_spcinfo_parse(RZ_NONNULL RzCMS *cms); +RZ_API void rz_pkcs7_spcinfo_free(RZ_NULLABLE RzSpcIndirectDataContent *spcinfo); +RZ_API RZ_OWN RzStructuredData *rz_pkcs7_spcinfo_to_structure(RZ_NULLABLE RzSpcIndirectDataContent *spcinfo); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_PKCS7_H */ diff --git a/dest/include/librz/rz_util/rz_pkcs8.h b/dest/include/librz/rz_util/rz_pkcs8.h new file mode 100644 index 00000000000..4701c4989ee --- /dev/null +++ b/dest/include/librz/rz_util/rz_pkcs8.h @@ -0,0 +1,35 @@ +#ifndef RZ_PKCS8_H +#define RZ_PKCS8_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RZ_PKCS8_VERSION_1 0 +#define RZ_PKCS8_VERSION_2 1 + +typedef struct pkcs8_private_key_algorithm_t { + RzASN1String *algorithm; ///< OBJECT IDENTIFIER + RzASN1Binary *parameters; ///< ANY +} RzPKCS8PrivateKeyAlgorithm; + +typedef struct private_key_info_t { + ut32 version; + RzPKCS8PrivateKeyAlgorithm private_key_algorithm; ///< OBJECT IDENTIFIER + RzASN1Binary *private_key; ///< OCTET STRING + RzASN1Binary *public_key; ///< BIT STRING +} RzPrivateKeyInfo; + +RZ_API RZ_OWN RzPrivateKeyInfo *rz_pkcs8_private_key_info_parse(RZ_NULLABLE const ut8 *buffer, ut32 length); +RZ_API void rz_pkcs8_private_key_info_free(RZ_NULLABLE RzPrivateKeyInfo *pki); +RZ_API RZ_OWN char *rz_pkcs8_private_key_algorithm(RZ_NONNULL const RzPrivateKeyInfo *pki); +RZ_API RZ_OWN RzStructuredData *rz_pkcs8_private_key_info_to_structure(RZ_NULLABLE const RzPrivateKeyInfo *pki); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_PKCS8_H */ diff --git a/dest/include/librz/rz_util/rz_print.h b/dest/include/librz/rz_util/rz_print.h new file mode 100644 index 00000000000..761458ad493 --- /dev/null +++ b/dest/include/librz/rz_util/rz_print.h @@ -0,0 +1,245 @@ +#ifndef RZ_PRINT_H +#define RZ_PRINT_H + +#include "rz_types.h" +#include "rz_cons.h" +#include "rz_bind.h" +#include "rz_io.h" +#include "rz_reg.h" +#include "rz_cmd.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define RZ_PRINT_FLAGS_COLOR 0x00000001 +#define RZ_PRINT_FLAGS_CURSOR 0x00000004 +#define RZ_PRINT_FLAGS_HEADER 0x00000008 +#define RZ_PRINT_FLAGS_SPARSE 0x00000010 +#define RZ_PRINT_FLAGS_SEGOFF 0x00000020 +#define RZ_PRINT_FLAGS_OFFSET 0x00000040 +#define RZ_PRINT_FLAGS_REFS 0x00000080 +#define RZ_PRINT_FLAGS_DIFFOUT 0x00000100 /* only show different rows in `cc` hexdiffing */ +#define RZ_PRINT_FLAGS_ADDRDEC 0x00000200 +#define RZ_PRINT_FLAGS_COMMENT 0x00000400 +#define RZ_PRINT_FLAGS_COMPACT 0x00000800 +#define RZ_PRINT_FLAGS_NONHEX 0x00001000 +#define RZ_PRINT_FLAGS_SECSUB 0x00002000 +#define RZ_PRINT_FLAGS_HDROFF 0x00008000 +#define RZ_PRINT_FLAGS_STYLE 0x00010000 +#define RZ_PRINT_FLAGS_NONASCII 0x00020000 +#define RZ_PRINT_FLAGS_ALIGN 0x00040000 +#define RZ_PRINT_FLAGS_UNALLOC 0x00080000 +#define RZ_PRINT_FLAGS_BGFILL 0x00100000 +#define RZ_PRINT_FLAGS_SECTION 0x00200000 +#define RZ_PRINT_FLAGS_NODOT 0x00400000 /* hide the dot before printable characters */ + +typedef const char *(*RzPrintNameCallback)(void *user, ut64 addr); +typedef int (*RzPrintSizeCallback)(void *user, ut64 addr); +typedef char *(*RzPrintCommentCallback)(void *user, ut64 addr); +typedef const char *(*RzPrintSectionGet)(void *user, ut64 addr); +typedef const char *(*RzPrintColorFor)(void *user, ut64 addr, bool verbose); +typedef char *(*RzPrintHasRefs)(void *user, ut64 addr, RzOutputMode mode); + +typedef enum { + RZ_ASM_TOKEN_UNKNOWN = 0, ///< Does not fit to any token below. + RZ_ASM_TOKEN_MNEMONIC, ///< Asm mnemonics like: mov, push, lea... + RZ_ASM_TOKEN_OPERATOR, ///< Arithmetic operators: +,-,<< etc. + RZ_ASM_TOKEN_NUMBER, ///< Numbers + RZ_ASM_TOKEN_REGISTER, ///< Registers + RZ_ASM_TOKEN_SEPARATOR, ///< Brackets, comma etc. + RZ_ASM_TOKEN_META, ///< Meta information (e.g Hexagon packet prefix, ARM & Hexagon number prefix). + + RZ_ASM_TOKEN_LAST, +} RzAsmTokenType; + +/** + * \brief A token of an asm string holding meta data. + */ +typedef struct { + size_t start; ///< byte-offset into `str` where this token starts. Must be exactly at a utf-8 codepoint boundary. + size_t len; ///< `str` length of token in bytes. + RzAsmTokenType type; + union { + ut64 number; ///< Number of RZ_ASM_TOKEN_NUMBER + } val; +} RzAsmToken; + +/** + * \brief A tokenized asm string. + */ +typedef struct { + ut32 op_type; ///< RzAnalysisOpType. Mnemonic color depends on this. + RzStrBuf *str; ///< Contains the raw asm string + RzPVector /**/ *tokens; ///< Contains only the tokenization meta-info without strings, ordered by start for log2(n) access +} RzAsmTokenString; + +typedef struct { + const RzRegSet *reg_sets; ///< Array of reg sets used to lookup register names during parsing. + ut32 ana_op_type; ///< Analysis op type (see: _RzAnalysisOpType) of the token string to parse. +} RzAsmParseParam; + +/** + * \brief Pattern for a asm string token. + */ +typedef struct { + RzAsmTokenType type; ///< Asm token type. + char *pattern; ///< The regex pattern describing the tokens. + RzRegex *regex; ///< Compiled regex pattern. +} RzAsmTokenPattern; + +/** + * \brief Holds certain options to alter the colorizing of asm strings. + * + */ +typedef struct { + bool reset_bg; ///< Reset the background color? + ut64 hl_addr; ///< Address which should be highlighted. Usually the function address. +} RzPrintAsmColorOpts; + +typedef struct rz_print_zoom_t { + ut8 *buf; + ut64 from; + ut64 to; + int size; + int mode; +} RzPrintZoom; + +typedef struct rz_print_t { + void *user; + RzIOBind iob; + bool pava; + RzCoreBind coreb; + const char *cfmt; + char datefmt[32]; + int datezone; + int (*write)(const unsigned char *buf, int len); + PrintfCallback cb_printf; + char *(*cb_color)(int idx, int last, bool bg); + bool scr_prompt; + int (*disasm)(void *p, ut64 addr); + PrintfCallback oprintf; + int big_endian; + int width; + int limit; + int bits; + bool histblock; + // true if the cursor is enabled, false otherwise + bool cur_enabled; + // offset of the selected byte from the first displayed one + int cur; + // offset of the selected byte from the first displayed one, when a + // range of bytes is selected. -1 is used if no bytes are selected. + int ocur; + int cols; + int flags; + int seggrn; + bool use_comments; + int col; + int stride; + int bytespace; + int pairs; + bool resetbg; + RzPrintZoom *zoom; + RzPrintNameCallback offname; + RzPrintSizeCallback offsize; + RzPrintColorFor colorfor; + RzPrintHasRefs hasrefs; + RzPrintCommentCallback get_comments; + RzPrintSectionGet get_section_name; + Sdb *sdb_types; + RzCons *cons; + RzConsBind consbind; + RzNum *num; + RzReg *reg; + RzRegItem *(*get_register)(const RzReg *reg, const char *name, int type); + ut64 (*get_register_value)(RzReg *reg, RzRegItem *item); + bool (*exists_var)(struct rz_print_t *print, ut64 func_addr, char *str); + bool esc_bslash; + bool wide_offsets; + const char *strconv_mode; + char io_unalloc_ch; + bool show_offset; + + // when true it uses row_offsets + bool calc_row_offsets; + // offset of the first byte of each printed row. + // Last elements is marked with a UT32_MAX. + ut32 *row_offsets; + // size of row_offsets + int row_offsets_sz; + // when true it makes visual mode flush the buffer to screen + bool vflush; + // represents the first not-visible offset on the screen + // (only when in visual disasm mode) + ut64 screen_bounds; + // Memoized current row number to calculate screen_bounds + int rows; + RzPrintAsmColorOpts colorize_opts; ///< Coloize options for asm strings. +} RzPrint; + +#ifdef RZ_API + +/* RzConsBreak handlers */ +typedef bool (*RzPrintIsInterruptedCallback)(); + +RZ_API bool rz_print_is_interrupted(void); +RZ_API void rz_print_set_is_interrupted_cb(RzPrintIsInterruptedCallback cb); + +/* ... */ +RZ_API char *rz_print_hexpair(RzPrint *p, const char *str, int idx); +RZ_API RzPrint *rz_print_new(void); +RZ_API RzPrint *rz_print_free(RzPrint *p); +RZ_API void rz_print_set_flags(RzPrint *p, int _flags); +RZ_API void rz_print_addr(RzPrint *p, ut64 addr); +RZ_API char *rz_print_section_str(RzPrint *p, ut64 at); +RZ_API void rz_print_hexii(RzPrint *p, ut64 addr, const ut8 *buf, int len, int step); +RZ_API RZ_OWN char *rz_print_hexdump_str(RZ_NONNULL RzPrint *p, ut64 addr, RZ_NONNULL const ut8 *buf, int len, int base, int step, size_t zoomsz); +RZ_API RZ_OWN char *rz_print_jsondump_str(RZ_NONNULL RzPrint *p, RZ_NONNULL const ut8 *buf, int len, int wordsize); +RZ_API RZ_OWN char *rz_print_hexdiff_str(RZ_NONNULL RzPrint *p, ut64 aa, RZ_NONNULL const ut8 *_a, ut64 ba, RZ_NONNULL const ut8 *_b, int len, int scndcol); +RZ_API void rz_print_bytes(RzPrint *p, const ut8 *buf, int len, const char *fmt); +RZ_API void rz_print_byte(RzPrint *p, const char *fmt, int idx, ut8 ch); +RZ_API const char *rz_print_byte_color(RzPrint *p, int ch); +RZ_API void rz_print_raw(RzPrint *p, ut64 addr, const ut8 *buf, int len); +RZ_API bool rz_print_have_cursor(RzPrint *p, int cur, int len); +RZ_API bool rz_print_cursor_pointer(RzPrint *p, int cur, int len); +RZ_API int rz_print_get_cursor(RzPrint *p); +RZ_API void rz_print_set_cursor(RzPrint *p, int curset, int ocursor, int cursor); +#define SEEFLAG -2 +#define JSONOUTPUT -3 + +/* mode values for rz_print_format_* API */ +#define RZ_PRINT_MUSTSEE (1) // enable printing of data in specified fmt +#define RZ_PRINT_ISFIELD (1 << 1) +#define RZ_PRINT_SEEFLAGS (1 << 2) +#define RZ_PRINT_JSON (1 << 3) +#define RZ_PRINT_MUSTSET (1 << 4) +#define RZ_PRINT_UNIONMODE (1 << 5) +#define RZ_PRINT_VALUE (1 << 6) +#define RZ_PRINT_DOT (1 << 7) +#define RZ_PRINT_QUIET (1 << 8) +#define RZ_PRINT_STRUCT (1 << 9) + +RZ_API void rz_print_offset(RzPrint *p, ut64 off, int invert, int opt, int dec, int delta, const char *label); +RZ_API void rz_print_offset_sg(RzPrint *p, ut64 off, int invert, int offseg, int seggrn, int offdec, int delta, const char *label); +RZ_API const char *rz_print_color_op_type(RZ_NONNULL RzPrint *p, ut32 /* RzAnalaysisOpType */ analysis_type); +RZ_API void rz_print_init_rowoffsets(RzPrint *p); +RZ_API ut32 rz_print_rowoff(RzPrint *p, int i); +RZ_API void rz_print_set_rowoff(RzPrint *p, int i, ut32 offset, bool overwrite); +RZ_API int rz_print_row_at_off(RzPrint *p, ut32 offset); + +// WIP +RZ_API void rz_print_set_screenbounds(RzPrint *p, ut64 addr); +RZ_API RZ_OWN char *rz_print_json_indent(RZ_NULLABLE const char *s, bool color, const char *tab, RZ_NULLABLE const char **palette); +RZ_API char *rz_print_json_human(const char *s); + +RZ_API RZ_OWN RzStrBuf *rz_print_colorize_asm_str(RZ_BORROW RzPrint *p, const RzAsmTokenString *toks); +RZ_API void rz_print_colored_help(const char **options, size_t options_len, bool have_examples); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/rz_protobuf.h b/dest/include/librz/rz_util/rz_protobuf.h new file mode 100644 index 00000000000..22a8b55e2fa --- /dev/null +++ b/dest/include/librz/rz_util/rz_protobuf.h @@ -0,0 +1,16 @@ +#ifndef RZ_PROTOBUF_H +#define RZ_PROTOBUF_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API RZ_OWN char *rz_protobuf_decode(RZ_NULLABLE const ut8 *buffer, const ut64 size, bool debug); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_PROTOBUF_H */ diff --git a/dest/include/librz/rz_util/rz_punycode.h b/dest/include/librz/rz_util/rz_punycode.h new file mode 100644 index 00000000000..315acf96d2e --- /dev/null +++ b/dest/include/librz/rz_util/rz_punycode.h @@ -0,0 +1,17 @@ +#ifndef RZ_PUNYCODE_H +#define RZ_PUNYCODE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API char *rz_punycode_encode(const ut8 *src, int srclen, int *dstlen); +RZ_API char *rz_punycode_decode(const char *src, int srclen, int *dstlen); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_PUNYCODE_H diff --git a/dest/include/librz/rz_util/rz_range.h b/dest/include/librz/rz_util/rz_range.h new file mode 100644 index 00000000000..38d5fbe2ca6 --- /dev/null +++ b/dest/include/librz/rz_util/rz_range.h @@ -0,0 +1,46 @@ +#ifndef RZ_RANGE_H +#define RZ_RANGE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* range.c */ + +typedef struct rz_range_item_t { + ut64 fr; + ut64 to; + ut8 *data; + int datalen; +} RRangeItem; + +typedef struct rz_range_t { + int count; + int changed; + RzList /**/ *ranges; +} RRange; + +RZ_API RRange *rz_range_new(void); +RZ_API RRange *rz_range_new_from_string(const char *string); +RZ_API RRange *rz_range_free(RRange *r); +RZ_API RRangeItem *rz_range_item_get(RRange *r, ut64 addr); +RZ_API ut64 rz_range_size(RRange *r); +RZ_API int rz_range_add_from_string(RRange *rgs, const char *string); +RZ_API RRangeItem *rz_range_add(RRange *rgs, ut64 from, ut64 to, int rw); +RZ_API int rz_range_sub(RRange *rgs, ut64 from, ut64 to); +RZ_API int rz_range_contains(RRange *rgs, ut64 addr); +RZ_API int rz_range_sort(RRange *rgs); +RZ_API void rz_range_percent(RRange *rgs); +RZ_API int rz_range_list(RRange *rgs, int rad); +RZ_API int rz_range_get_n(RRange *rgs, int n, ut64 *from, ut64 *to); +RZ_API RRange *rz_range_inverse(RRange *rgs, ut64 from, ut64 to, int flags); +RZ_API int rz_range_overlap(ut64 a0, ut64 a1, ut64 b0, ut64 b1, int *d); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_RANGE_H diff --git a/dest/include/librz/rz_util/rz_rbtree.h b/dest/include/librz/rz_util/rz_rbtree.h new file mode 100644 index 00000000000..499b27139db --- /dev/null +++ b/dest/include/librz/rz_util/rz_rbtree.h @@ -0,0 +1,125 @@ +#ifndef RZ_RBTREE_H +#define RZ_RBTREE_H + +#include +#include +#include + +#include "rz_list.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// max height <= 2 * floor(log2(n + 1)) +// We use `int` for size, so <= 2 * 31 +#define RZ_RBTREE_MAX_HEIGHT 62 + +// Singleton can be zero initialized +typedef struct rz_rb_node_t { + struct rz_rb_node_t *child[2]; + bool red; +} RBNode; + +typedef RBNode *RBTree; + +// incoming < in_tree => return < 0 +// incoming == in_tree => return == 0 +// incoming > in_tree => return > 0 +typedef int (*RBComparator)(const void *incoming, const RBNode *in_tree, void *user); + +typedef void (*RBNodeFree)(RBNode *node, void *user); +typedef void (*RBNodeSum)(RBNode *node); + +typedef struct rz_rb_iter_t { + // current depth + // if len == 0, the iterator is at the end/empty + // else path[len-1] is the current node + int len; + + // current path from root to the current node + // excluding nodes into whose right (or left, for reverse iteration) branch the iterator has descended + // (these nodes are before the current) + RBNode *path[RZ_RBTREE_MAX_HEIGHT]; +} RBIter; + +typedef int (*RContRBCmp)(void *incoming, void *in, void *user); +typedef void (*RContRBFree)(void *); +typedef struct rz_containing_rb_node_t { + RBNode node; + void *data; +} RContRBNode; + +typedef struct rz_containing_rb_tree_t { + RContRBNode *root; + RContRBFree free; +} RContRBTree; + +// Routines for augmented red-black trees. The user should provide an aggregation (monoid sum) callback `sum` +// to calculate extra information such as size, sum, ... +RZ_API bool rz_rbtree_aug_delete(RBNode **root, void *data, RBComparator cmp, void *cmp_user, RBNodeFree freefn, void *free_user, RBNodeSum sum); +RZ_API bool rz_rbtree_aug_insert(RBNode **root, void *data, RBNode *node, RBComparator cmp, void *cmp_user, RBNodeSum sum); +RZ_API bool rz_rbtree_aug_update_sum(RBNode *root, void *data, RBNode *node, RBComparator cmp, void *cmp_user, RBNodeSum sum); + +RZ_API bool rz_rbtree_delete(RBNode **root, void *data, RBComparator cmp, void *cmp_user, RBNodeFree freefn, void *free_user); +RZ_API RBNode *rz_rbtree_find(RBNode *root, void *data, RBComparator cmp, void *user); +RZ_API void rz_rbtree_free(RZ_NULLABLE RBNode *root, RBNodeFree freefn, void *user); +RZ_API bool rz_rbtree_insert(RBNode **root, void *data, RBNode *node, RBComparator cmp, void *user); +// Return the smallest node that is greater than or equal to `data` +RZ_API RBNode *rz_rbtree_lower_bound(RBNode *root, void *data, RBComparator cmp, void *user); +// Return the greatest node that is less than or equal to `data` +RZ_API RBNode *rz_rbtree_upper_bound(RBNode *root, void *data, RBComparator cmp, void *user); + +// Create a forward iterator starting from the leftmost node +RZ_API RBIter rz_rbtree_first(RBNode *root); +// Create a backward iterator starting from the rightmost node +RZ_API RBIter rz_rbtree_last(RBNode *root); + +// Iterate [lower_bound, end] forward, used with rz_rbtree_iter_next +RZ_API RBIter rz_rbtree_lower_bound_forward(RBNode *root, void *data, RBComparator cmp, void *user); +// Iterate [begin, upper_bound] backward, used with rz_rbtree_iter_prev +RZ_API RBIter rz_rbtree_upper_bound_backward(RBNode *root, void *data, RBComparator cmp, void *user); + +// struct Node { int key; RBNode rb; }; +// rz_rbtree_iter_get (it, struct Node, rb) +#define rz_rbtree_iter_get(it, struc, rb) (container_of((it)->path[(it)->len - 1], struc, rb)) +// If the iterator still contains elements, including the current +#define rz_rbtree_iter_has(it) ((it)->len) +// Move forward +RZ_API void rz_rbtree_iter_next(RBIter *it); +// Move backward +RZ_API void rz_rbtree_iter_prev(RBIter *it); + +// Iterate all elements of the forward iterator +#define rz_rbtree_iter_while(it, data, struc, rb) \ + for (; rz_rbtree_iter_has(&it) && (data = rz_rbtree_iter_get(&it, struc, rb)); rz_rbtree_iter_next(&(it))) + +// Iterate all elements of the backward iterator +#define rz_rbtree_iter_while_prev(it, data, struc, rb) \ + for (; rz_rbtree_iter_has(&it) && (data = rz_rbtree_iter_get(&it, struc, rb)); rz_rbtree_iter_prev(&(it))) + +#define rz_rbtree_foreach(root, it, data, struc, rb) \ + for ((it) = rz_rbtree_first(root); rz_rbtree_iter_has(&it) && (data = rz_rbtree_iter_get(&it, struc, rb)); rz_rbtree_iter_next(&(it))) + +#define rz_rbtree_foreach_prev(root, it, data, struc, rb) \ + for ((it) = rz_rbtree_last(root); rz_rbtree_iter_has(&it) && (data = rz_rbtree_iter_get(&it, struc, rb)); rz_rbtree_iter_prev(&(it))) + +RZ_API RZ_OWN RContRBTree *rz_rbtree_cont_new(void); +RZ_API RZ_OWN RContRBTree *rz_rbtree_cont_newf(RContRBFree f); +RZ_API bool rz_rbtree_cont_insert(RContRBTree *tree, void *data, RContRBCmp cmp, void *user); +RZ_API bool rz_rbtree_cont_delete(RContRBTree *tree, void *data, RContRBCmp cmp, void *user); +RZ_API void *rz_rbtree_cont_find(RContRBTree *tree, void *data, RContRBCmp cmp, void *user); + +#define rz_rbtree_cont_foreach(tree, it, dat) \ + for ((it) = rz_rbtree_first((tree)->root ? &(tree)->root->node : NULL); rz_rbtree_iter_has(&it) && (dat = rz_rbtree_iter_get(&it, RContRBNode, node)->data); rz_rbtree_iter_next(&(it))) + +#define rz_rbtree_cont_foreach_prev(tree, it, dat) \ + for ((it) = rz_rbtree_last((tree)->root ? &(tree)->root->node : NULL); rz_rbtree_iter_has(&it) && (dat = rz_rbtree_iter_get(&it, RContRBNode, node)->data); rz_rbtree_iter_prev(&(it))) + +RZ_API void rz_rbtree_cont_free(RContRBTree *tree); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/rz_regex.h b/dest/include/librz/rz_util/rz_regex.h new file mode 100644 index 00000000000..e87080e557d --- /dev/null +++ b/dest/include/librz/rz_util/rz_regex.h @@ -0,0 +1,212 @@ +// SPDX-FileCopyrightText: 2023 Rot127 +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_REGEX_H +#define RZ_REGEX_H + +#include +#include +#include +#include +#include + +#define RZ_REGEX_SIZE size_t + +// Some basic PCRE2 macros. There are way more defined +// and should be added here if needed. +#define RZ_REGEX_ERROR_NOMATCH (-1) /* PCRE2_ERROR_NOMATCH */ +#define RZ_REGEX_ERROR_PARTIAL (-2) /* PCRE2_ERROR_PARTIAL */ + +/** + * \brief Regex compilation flags. They are only used for rz_regex_new() + * C alters what is compiled by rz_regex_new() + * J alters what is compiled by rz_regex_new() (with JIT enabled). + * M is inspected during rz_regex_match() execution + * D is inspected during pcre2_dfa_match() execution (not used). + */ +#define RZ_REGEX_DEFAULT 0 +#define RZ_REGEX_LITERAL 0x02000000u /* PCRE2_LITERAL - C */ +#define RZ_REGEX_CASELESS 0x00000008u /* PCRE2_CASELESS - C */ +/** + * \brief If RZ_REGEX_EXTENDED is passed to rz_regex_new_16() or rz_regex_new_32() + * spaces in the pattern **will** be skipped! You need to replace them with \s. + * This is in accordance with the PCRE2 documentation. + * + * If RZ_REGEX_EXTENDED is passed to rz_regex_new() (the UTF-8 regular expressions) + * the spaces **will not** be skipped but interally be replaced with '\s'. + * This was done to keep our interal regex matching stable. + * + * Values can be passed as cflags. + */ +#define RZ_REGEX_EXTENDED 0x00000080u /* PCRE2_EXTENDED - C */ +#define RZ_REGEX_EXTENDED_MORE 0x01000000u /* PCRE2_EXTENDED_MORE - C */ +#define RZ_REGEX_MULTILINE 0x00000400u /* PCRE2_MULTILINE - C */ +#define RZ_REGEX_DOTALL 0x00000020u /* PCRE2_DOTALL - C */ + +// Can be passed as jflags +#define RZ_REGEX_JIT_PARTIAL_SOFT 0x00000002u /* PCRE2_JIT_PARTIAL_SOFT */ +#define RZ_REGEX_JIT_PARTIAL_HARD 0x00000004u /* PCRE2_JIT_PARTIAL_HARD */ + +// Can be passed for mflags +#define RZ_REGEX_PARTIAL_SOFT 0x00000010u /* PCRE2_PARTIAL_SOFT */ +#define RZ_REGEX_PARTIAL_HARD 0x00000020u /* PCRE2_PARTIAL_HARD */ + +#define RZ_REGEX_UNSET (~(RZ_REGEX_SIZE)0) /* PCRE2_UNSET */ +#define RZ_REGEX_ZERO_TERMINATED (~(RZ_REGEX_SIZE)0) /* PCRE2_ZERO_TERMINATED */ + +typedef int RzRegexStatus; ///< An status number returned by the regex API. +typedef size_t RzRegexSize; ///< Size of a text or regex. This is the size measured in code width. For UTF-8: bytes. +typedef ut32 RzRegexFlags; ///< Regex flag bits. +typedef uint8_t *RzRegexPattern; ///< A regex pattern string. +typedef void RzRegex; ///< A regex expression for UTF-8 strings. +typedef void RzRegexCompContext; ///< A PCRE2 compile context for UTF-8 strings. +typedef void RzRegex16; ///< A regex expression for UTF-16 strings (host endianess). +typedef void RzRegexCompContext16; ///< A PCRE2 compile context for UTF-16 strings (host endianess). +typedef void RzRegex32; ///< A regex expression for UTF-32 strings (host endianess). +typedef void RzRegexCompContext32; ///< A PCRE2 compile context for UTF-32 strings (host endianess). + +typedef enum { + RZ_REGEX_UTF8, + RZ_REGEX_UTF16, + RZ_REGEX_UTF32, +} RzRegexType; + +typedef struct { + RzRegexType re_type; + RzRegexFlags compile_flags_jit; + union { + RzRegex *re8; + RzRegex16 *re16; + RzRegex32 *re32; + }; + void *jit_stack; ///< The JIT stack for this pattern. Must be used only by one thread at a time. +} RzRegexMulti; + +typedef struct { + RzRegexSize group_idx; ///< Index of the group. Used to determine name if any was given. + /** + * \brief Start offset into the text where the match starts. + * The offset is in code units, not in characters! + * One code unit is 1 byte for UTF-8, 2 bytes for UTF-16, and 4 bytes for UTF-32. + */ + RzRegexSize start; + /** + * \brief The length of the match in number of code units. + * One code unit is 1 byte for UTF-8, 2 bytes for UTF-16, and 4 bytes for UTF-32. + */ + RzRegexSize len; ///< Length of match in bytes. +} RzRegexMatch; + +typedef void RzRegexMatchData; ///< PCRE2 internal match data type + +RZ_API RZ_OWN RzRegex *rz_regex_new(RZ_NONNULL const char *pattern, RzRegexFlags cflags, RzRegexFlags jflags, + RzRegexCompContext *ccontext); +RZ_API RZ_OWN RzRegex16 *rz_regex_new_16(RZ_NONNULL const char *pattern, RzRegexFlags cflags, RzRegexFlags jflags, + RzRegexCompContext *ccontext); +RZ_API RZ_OWN RzRegex32 *rz_regex_new_32(RZ_NONNULL const char *pattern, RzRegexFlags cflags, RzRegexFlags jflags, + RzRegexCompContext *ccontext); +RZ_API RZ_OWN RzRegexMulti *rz_regex_new_multi(RZ_NONNULL const char *pattern, RzRegexFlags cflags, RzRegexFlags jflags, + RzRegexCompContext *ccontext, RzRegexType type); +RZ_API RZ_OWN RzRegex *rz_regex_new_bytes(RZ_NONNULL const ut8 *pattern, size_t pattern_len, RzRegexFlags cflags, RzRegexFlags jflags, + RzRegexCompContext *ccontext); +RZ_API void rz_regex_free(RZ_OWN RzRegex *regex); +RZ_API void rz_regex_free_16(RZ_OWN RzRegex16 *regex); +RZ_API void rz_regex_free_32(RZ_OWN RzRegex32 *regex); +RZ_API void rz_regex_free_multi(RZ_NULLABLE RZ_OWN RzRegexMulti *regex); +RZ_API RZ_OWN RzRegexMulti *rz_regex_multi_clone(RZ_NONNULL RzRegexMulti *regex, bool clone_jit); +RZ_API void rz_regex_free_multi_clone(RZ_NULLABLE RZ_OWN RzRegexMulti *regex); +RZ_API void rz_regex_error_msg(RzRegexStatus errcode, RZ_OUT char *errbuf, RzRegexSize errbuf_size); +RZ_API const ut8 *rz_regex_get_match_name(RZ_NONNULL const RzRegex *regex, ut32 name_idx); +RZ_API st32 rz_regex_get_group_idx_by_name(RZ_NONNULL const RzRegex *regex, const char *group); +RZ_API RzRegexStatus rz_regex_match(RZ_NONNULL const RzRegex *regex, RZ_NONNULL const char *text, + RzRegexSize text_size, + RzRegexSize text_offset, + RzRegexFlags mflags); +RZ_API RZ_OWN RzPVector /**/ *rz_regex_match_all_not_grouped( + RZ_NONNULL const RzRegex *regex, + RZ_NONNULL const char *text, + RzRegexSize text_size, + RzRegexSize text_offset, + RzRegexFlags mflags); +RZ_API RZ_OWN RzPVector /**/ *rz_regex_match_first( + RZ_NONNULL const RzRegex *regex, + RZ_NONNULL const char *text, + RzRegexSize text_size, + RzRegexSize text_offset, + RzRegexFlags mflags); +RZ_API RZ_OWN RzPVector /**/ *rz_regex_match_first_16( + RZ_NONNULL const RzRegex16 *regex, + RZ_NONNULL const ut16 *text, + RzRegexSize text_size, + RzRegexSize text_offset, + RzRegexFlags mflags); +RZ_API RZ_OWN RzPVector /**/ *rz_regex_match_first_32( + RZ_NONNULL const RzRegex32 *regex, + RZ_NONNULL const ut32 *text, + RzRegexSize text_size, + RzRegexSize text_offset, + RzRegexFlags mflags); +RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all( + RZ_NONNULL const RzRegex *regex, + RZ_NONNULL const char *text, + RzRegexSize text_size, + RzRegexSize text_offset, + RzRegexFlags mflags); +RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all_overlap( + RZ_NONNULL const RzRegex *regex, + RZ_NONNULL const char *text, + RzRegexSize text_size, + RzRegexSize text_offset, + RzRegexFlags mflags); +RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all_16( + RZ_NONNULL const RzRegex16 *regex, + RZ_NONNULL const ut16 *text, + RzRegexSize text_size, + RzRegexSize text_offset, + RzRegexFlags mflags); +RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all_overlap_16( + RZ_NONNULL const RzRegex16 *regex, + RZ_NONNULL const ut16 *text, + RzRegexSize text_size, + RzRegexSize text_offset, + RzRegexFlags mflags); +RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all_32( + RZ_NONNULL const RzRegex32 *regex, + RZ_NONNULL const ut32 *text, + RzRegexSize text_size, + RzRegexSize text_offset, + RzRegexFlags mflags); +RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all_overlap_32( + RZ_NONNULL const RzRegex32 *regex, + RZ_NONNULL const ut32 *text, + RzRegexSize text_size, + RzRegexSize text_offset, + RzRegexFlags mflags); +RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all_multi( + RZ_NONNULL const RzRegexMulti *regex, + RZ_NONNULL const ut8 *text, + RzRegexSize text_size, + RzRegexSize text_offset, + RzRegexFlags mflags); +RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all_overlap_multi( + RZ_NONNULL const RzRegexMulti *regex, + RZ_NONNULL const ut8 *text, + RzRegexSize text_size, + RzRegexSize text_offset, + RzRegexFlags mflags); +RZ_API bool rz_regex_contains(RZ_NONNULL const char *pattern, RZ_NONNULL const char *text, + RzRegexSize text_size, + RzRegexFlags cflags, RzRegexFlags mflags); +RZ_API RzRegexSize rz_regex_find(RZ_NONNULL const char *pattern, RZ_NONNULL RZ_BORROW char *text, + RzRegexSize text_size, RzRegexSize text_offset, + RzRegexFlags cflags, RzRegexFlags mflags); +RZ_API RZ_OWN RzStrBuf *rz_regex_full_match_str(RZ_NONNULL const char *pattern, RZ_NONNULL const char *text, + RzRegexSize text_size, + RzRegexFlags cflags, RzRegexFlags mflags, RZ_NONNULL const char *separator); +RZ_API RZ_OWN RzRegexCompContext *rz_regex_compile_context_new(); +RZ_API void rz_regex_compile_context_free(RzRegexCompContext *ccontext); +RZ_API void rz_regex_set_nul_as_newline(RZ_NONNULL RzRegexCompContext *ccontext); +RZ_API RzRegexFlags rz_regex_parse_flag_desc(RZ_NULLABLE const char *re_flags_desc); +RZ_API RZ_OWN char *rz_regex_create_wildcard_pattern(size_t min_len, size_t max_len); + +#endif /* RZ_REGEX_H */ diff --git a/dest/include/librz/rz_util/rz_serialize.h b/dest/include/librz/rz_util/rz_serialize.h new file mode 100644 index 00000000000..6410f92d473 --- /dev/null +++ b/dest/include/librz/rz_util/rz_serialize.h @@ -0,0 +1,138 @@ +// SPDX-FileCopyrightText: Florian Märkl +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_SERIALIZE_H +#define RZ_SERIALIZE_H + +#include +#include +#include + +/** + * \brief Detailed info about a (de)serialization result + * + * This is currently just a list of strings which may be warnings + * or detailed error messages. + */ +typedef RzList RzSerializeResultInfo; + +static inline RzSerializeResultInfo *rz_serialize_result_info_new(void) { + return rz_list_newf(free); +} + +static inline void rz_serialize_result_info_free(RzSerializeResultInfo *info) { + rz_list_free(info); +} + +// Common helpers for writing (de)serialization code + +/** + * \brief Push an error to the local RzSerializeResultInfo + * \res RzSerializeInfoResult * + * \param ... printf-style arguments to be pushed as the error to res + */ +#define RZ_SERIALIZE_ERR(res, ...) \ + do { \ + if (res) { \ + rz_list_push(res, rz_str_newf(__VA_ARGS__)); \ + } \ + } while (0) + +/** + * \brief Hashtable-based key parser to prevent strcmp chains + * + * This enables string values to be used in a switch/case-like + * fashion. + */ +typedef HtSP RzKeyParser; + +static inline RzKeyParser *rz_key_parser_new(void) { + return ht_sp_new(HT_STR_DUP, NULL, NULL); +} + +static inline void rz_key_parser_free(RzKeyParser *parser) { + ht_sp_free(parser); +} + +static inline void rz_key_parser_add(RzKeyParser *parser, const char *key, int val) { + ht_sp_insert(parser, key, (void *)(size_t)val); +} + +#define RZ_KEY_PARSER_UNKNOWN -1 + +/** + * \brief switch-like macro over RzKeyParser values + * \param parser RzKeyParser * + * \param key const char * + */ +#define RZ_KEY_PARSER_SWITCH(parser, key) \ + bool key_parser_found = false; \ + int key_parser_v = (int)(size_t)ht_sp_find(parser, key, &key_parser_found); \ + if (!key_parser_found) { \ + key_parser_v = RZ_KEY_PARSER_UNKNOWN; \ + } \ + switch (key_parser_v) + +/** + * \brief Iterate over all keys in a json object and call RZ_KEY_PARSER_SWITCH on each + * \param parser RzKeyParser * + * \param json RzJson * + * \param child var name for the `RzJson *child` + * \param body code block with cases + */ +#define RZ_KEY_PARSER_JSON(parser, json, child, body) \ + if (json->type == RZ_JSON_OBJECT) { \ + for (RzJson *child = json->children.first; child; child = child->next) { \ + RZ_KEY_PARSER_SWITCH(parser, child->key) { \ + body \ + } \ + } \ + } + +/** + * \brief Get an sdb sub-namespace or fail + * \param db Sdb * the Sdb from which to take the sub-namespace + * \param subdb Sdb * where to put the sub-namespace + * \param res RzSerializeResult * where to push an error on failure + * \param ns const char * + * \param rip code to execute if the function failed + * + * Example: + * + * Sdb *subdb; + * RZ_SERIALIZE_SUB(db, subdb, res, "files", return false;) + * // do something with subdb + * + */ +#define RZ_SERIALIZE_SUB(db, subdb, res, ns, rip) \ + do { \ + subdb = sdb_ns(db, ns, false); \ + if (!subdb) { \ + RZ_SERIALIZE_ERR(res, "missing " ns " namespace"); \ + rip \ + } \ + } while (0) + +/** + * \brief Get an sdb sub-namespace and evaluate `call` or fail + * \param db Sdb * the Sdb from which to take the sub-namespace + * \param subdb Sdb * where to put the sub-namespace + * \param res RzSerializeResult * where to push an error on failure + * \param ns const char * + * \param call function call + * \param rip code to execute if the function failed + * + * Example: + * + * Sdb *subdb; + * RZ_SERIALIZE_SUB_DO(db, subdb, res, "files", + * rz_serialize_io_files_load(subdb, io, res), return false;) + * + */ +#define RZ_SERIALIZE_SUB_DO(db, subdb, res, ns, call, rip) \ + RZ_SERIALIZE_SUB(db, subdb, res, ns, rip); \ + if (!(call)) { \ + rip \ + } + +#endif // RZ_SERIALIZE_H diff --git a/dest/include/librz/rz_util/rz_set.h b/dest/include/librz/rz_util/rz_set.h new file mode 100644 index 00000000000..9a8a4076390 --- /dev/null +++ b/dest/include/librz/rz_util/rz_set.h @@ -0,0 +1,41 @@ +// SPDX-FileCopyrightText: pancake +// SPDX-FileCopyrightText: 2024 pelijah +// SPDX-License-Identifier: MIT + +#ifndef RZ_SET_H +#define RZ_SET_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef HtSP RzSetS; + +RZ_API RZ_OWN RzSetS *rz_set_s_new(HtStrOption opt); +RZ_API void rz_set_s_free(RZ_NULLABLE RzSetS *set); +RZ_API void rz_set_s_add(RZ_NONNULL RzSetS *set, const char *str); +RZ_API bool rz_set_s_contains(RZ_NONNULL RzSetS *set, const char *str); +RZ_API void rz_set_s_delete(RZ_NONNULL RzSetS *set, const char *str); +RZ_API ut32 rz_set_s_size(const RZ_NONNULL RzSetS *set); +RZ_API RZ_OWN RzPVector /**/ *rz_set_s_to_vector(RZ_NONNULL RzSetS *set); +RZ_API RzIterator /* */ *rz_set_s_as_iter(const RZ_NONNULL RzSetS *set); + +typedef HtUP RzSetU; + +RZ_API RZ_OWN RzSetU *rz_set_u_new(void); +RZ_API void rz_set_u_free(RZ_NULLABLE RzSetU *set); +RZ_API void rz_set_u_add(RZ_NONNULL RzSetU *set, ut64 u); +RZ_API bool rz_set_u_contains(RZ_NONNULL RzSetU *set, ut64 u); +RZ_API void rz_set_u_delete(RZ_NONNULL RzSetU *set, ut64 u); +RZ_API ut32 rz_set_u_size(const RZ_NONNULL RzSetU *set); +RZ_API RzIterator /* */ *rz_set_u_as_iter(const RZ_NONNULL RzSetU *set); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/rz_signal.h b/dest/include/librz/rz_util/rz_signal.h new file mode 100644 index 00000000000..50a41d589b4 --- /dev/null +++ b/dest/include/librz/rz_util/rz_signal.h @@ -0,0 +1,29 @@ +#ifndef RZ_SIGNAL_H +#define RZ_SIGNAL_H + +#include + +#if __UNIX__ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Returns atoi(str) if signal with `str` name not found. */ +RZ_API int rz_signal_from_string(const char *str); + +/* Return NULL if signal with `code` not found. */ +RZ_API const char *rz_signal_to_string(int code); + +// XXX this function should be portable, not-unix specific +#if __UNIX__ +RZ_API void rz_signal_sigmask(int how, const sigset_t *newmask, sigset_t *oldmask); +#endif + +#ifdef __cplusplus +} +#endif + +#endif // RZ_SIGNAL_H diff --git a/dest/include/librz/rz_util/rz_spaces.h b/dest/include/librz/rz_util/rz_spaces.h new file mode 100644 index 00000000000..be0393cf013 --- /dev/null +++ b/dest/include/librz/rz_util/rz_spaces.h @@ -0,0 +1,120 @@ +#ifndef RZ_SPACES_H +#define RZ_SPACES_H + +#define RZ_SPACES_MAX 512 + +#include "rz_util.h" +#include "rz_serialize.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * RzSpaces represents a set of Spaces. + * A Space is used to group similar objects and it can have a name. Name + * "*"/""/NULL is reserved to indicate "all spaces". + * + * You can have groups of "meta" (e.g. bin meta, format meta, etc.), groups of + * flags, etc. + * + * It is possible to hook into the RzSpaces functions by using RzEvent. + * RZ_SPACE_EVENT_COUNT: called when you need to count how many elements there are in a given RzSpace + * RZ_SPACE_EVENT_RENAME: called when renaming a RzSpace with an oldname to a newname + * RZ_SPACE_EVENT_UNSET: called when deleting a RzSpace with a given name + */ + +typedef struct rz_space_t { + char *name; + RBNode rb; +} RzSpace; + +typedef enum { + RZ_SPACE_EVENT_COUNT = 1, + RZ_SPACE_EVENT_RENAME, + RZ_SPACE_EVENT_UNSET, +} RzSpaceEventType; + +typedef struct rz_space_event_t { + union { + struct { + const RzSpace *space; + } count; + struct { + const RzSpace *space; + } unset; + struct { + const RzSpace *space; + const char *oldname; + const char *newname; + } rename; + } data; + int res; +} RzSpaceEvent; + +typedef struct rz_spaces_t { + const char *name; + RzSpace *current; + RBTree spaces; + RzList /**/ *spacestack; + RzEvent *event; +} RzSpaces; + +// Create a new RzSpaces with the given name +RZ_API RzSpaces *rz_spaces_new(const char *name); +// Initialize an existing RzSpaces with the given name +RZ_API bool rz_spaces_init(RzSpaces *sp, const char *name); +// Finalize an existing RzSpaces +RZ_API void rz_spaces_fini(RzSpaces *sp); +// Finalize and free an existing RzSpaces +RZ_API void rz_spaces_free(RzSpaces *sp); +// Delete all spaces +RZ_API void rz_spaces_purge(RzSpaces *sp); +// Get the RzSpace with the given name +RZ_API RzSpace *rz_spaces_get(RzSpaces *sp, const char *name); +// Add a new RzSpace if one does not already exist, otherwise return the existing one +RZ_API RzSpace *rz_spaces_add(RzSpaces *sp, const char *name); +// Add and select a new RzSpace if one does not already exist, otherwise return and select the existing one +RZ_API RzSpace *rz_spaces_set(RzSpaces *sp, const char *name); +// Remove the RzSpace with the given name or all of them if name is NULL +RZ_API bool rz_spaces_unset(RzSpaces *sp, const char *name); +// Change the name of RzSpace with oname to nname +RZ_API bool rz_spaces_rename(RzSpaces *sp, const char *oname, const char *nname); +// Count the elements that belong to the RzSpace with the given name +RZ_API int rz_spaces_count(RzSpaces *sp, const char *name); +// Add/Select the RzSpace with the given name and save the current one in the history +RZ_API bool rz_spaces_push(RzSpaces *sp, const char *name); +// Select the RzSpace that was set before the current one +RZ_API bool rz_spaces_pop(RzSpaces *sp); + +static inline RzSpace *rz_spaces_current(RzSpaces *sp) { + return sp->current; +} + +static inline const char *rz_spaces_current_name(RzSpaces *sp) { + return sp->current ? sp->current->name : "*"; +} + +static inline bool rz_spaces_is_empty(RzSpaces *sp) { + RBIter it = rz_rbtree_first(sp->spaces); + return it.len == 0; +} + +typedef RBIter RzSpaceIter; +#define rz_spaces_foreach(sp, it, s) \ + rz_rbtree_foreach ((sp)->spaces, (it), (s), RzSpace, rb) + +/* serialize */ + +RZ_API void rz_serialize_spaces_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzSpaces *spaces); +/** + * @param load_name whether to overwrite the name in spaces with the value from db + */ +RZ_API bool rz_serialize_spaces_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzSpaces *spaces, bool load_name, RZ_NULLABLE RzSerializeResultInfo *res); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_SPACES_H diff --git a/dest/include/librz/rz_util/rz_stack.h b/dest/include/librz/rz_util/rz_stack.h new file mode 100644 index 00000000000..b0c9aab3bcc --- /dev/null +++ b/dest/include/librz/rz_util/rz_stack.h @@ -0,0 +1,32 @@ +#ifndef RZ_STACK_H +#define RZ_STACK_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*RzStackFree)(void *ptr); + +typedef struct rz_stack_t { + void **elems; + unsigned int n_elems; + int top; + RzStackFree free; +} RzStack; + +RZ_API RzStack *rz_stack_new(ut32 n); +RZ_API void rz_stack_free(RzStack *s); +RZ_API bool rz_stack_is_empty(RzStack *s); +RZ_API RzStack *rz_stack_newf(ut32 n, RzStackFree f); +RZ_API bool rz_stack_push(RzStack *s, void *el); +RZ_API void *rz_stack_pop(RzStack *s); +RZ_API size_t rz_stack_size(RzStack *s); +RZ_API void *rz_stack_peek(RzStack *s); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_STACK_H diff --git a/dest/include/librz/rz_util/rz_str.h b/dest/include/librz/rz_util/rz_str.h new file mode 100644 index 00000000000..4e619cdb738 --- /dev/null +++ b/dest/include/librz/rz_util/rz_str.h @@ -0,0 +1,342 @@ +#ifndef RZ_STR_H +#define RZ_STR_H + +#include +#include "rz_assert.h" +#include "rz_str_util.h" +#include "rz_list.h" +#include "rz_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + RZ_STRING_TYPE_RAW, ///< The raw sequence of bytes without any marker of beginning or end + RZ_STRING_TYPE_ZERO, ///< C-style strings (ASCII or UTF-8) with zero as the end marker + RZ_STRING_TYPE_SIZED, ///< Pascal-style strings with the first byte marking the size of the string +} RzStrType; + +/** + * \brief String character encodings. + */ +typedef enum { + /** + * \brief Unknown 8bit encoding but with ASCII from 0 to 0x7f. + * It is also used everywhere like it is ASCII. + */ + RZ_STRING_ENC_8BIT = 'b', + RZ_STRING_ENC_UTF8 = '8', + /** + * \brief Modified UTF-8 from Android: + * https://source.android.com/docs/core/runtime/dex-format#mutf-8 + */ + RZ_STRING_ENC_MUTF8 = 'm', + RZ_STRING_ENC_UTF16LE = 'u', + RZ_STRING_ENC_UTF32LE = 'U', + RZ_STRING_ENC_UTF16BE = 'n', + RZ_STRING_ENC_UTF32BE = 'N', + RZ_STRING_ENC_IBM037 = 'c', + RZ_STRING_ENC_IBM290 = 'd', + RZ_STRING_ENC_EBCDIC_UK = 'k', + RZ_STRING_ENC_EBCDIC_US = 's', + RZ_STRING_ENC_EBCDIC_ES = 't', + RZ_STRING_ENC_GUESS = 'g', + RZ_STRING_ENC_SETTINGS = 'S', ///< Use str.encoding. +} RzStrEnc; + +/** + * \brief Group together some common options used by string escaping functions + */ +typedef struct { + bool show_asciidot; ///< When true, dots `.` are placed instead of unprintable ASCII characters. + bool esc_bslash; ///< When true, backslashes `\` are quoted with `\\` + bool esc_double_quotes; ///< When true, double quotes `"` are quoted with `\"` + bool dot_nl; ///< When true, \n is converted into the graphiz-compatible newline \l + bool keep_printable; ///< Keep all printable characters (excludes \n, \t etc.). +} RzStrEscOptions; + +/** + * \brief Convenience macro for local temporary strings + * \param buf Target buffer, **must** be an array type, not a pointer. + * + * This eases the common pattern where a stack-allocated string of a fixed + * size is created and filled with `snprintf()` to be used as a temporary string. + * + * Example: + * + * char k[32]; + * char v[32]; + * sdb_set(db, rz_strf(k, "key.%d", 42), rz_strf(v, "val.%d", 123)); + */ +#define rz_strf(buf, ...) ( \ + snprintf(buf, sizeof(buf), __VA_ARGS__) < 0 \ + ? rz_assert_log(RZ_LOGLVL_FATAL, "rz_strf error while using snprintf"), \ + NULL \ + : buf) + +typedef int (*RzStrRangeCallback)(void *, int); + +#define RZ_STR_ISEMPTY(x) (!(x) || !*(x)) +#define RZ_STR_ISNOTEMPTY(x) ((x) && *(x)) +#define RZ_STR_DUP(x) ((x) ? strdup((x)) : NULL) +#define RZ_STR_EQ(x, y) (rz_str_cmp((x), (y), -1) == 0) +#define RZ_STR_NE(x, y) (rz_str_cmp((x), (y), -1) != 0) +#define rz_str_array(x, y) ((y >= 0 && y < (sizeof(x) / sizeof(*x))) ? x[y] : "") +RZ_API const char *rz_str_enc_as_string(RzStrEnc enc); +RZ_API RzStrEnc rz_str_enc_string_as_type(RZ_NULLABLE const char *enc); +RZ_API RZ_OWN char *rz_str_repeat(const char *str, ut16 times); +RZ_API RZ_OWN char *rz_str_pad(const char ch, ssize_t len); +RZ_API const char *rz_str_rstr(const char *base, const char *p); +RZ_API const char *rz_strstr_ansi(RZ_NONNULL const char *a, RZ_NONNULL const char *b, bool icase); +RZ_API const char *rz_str_rchr(const char *base, const char *p, int ch); +RZ_API const char *rz_str_closer_chr(const char *b, const char *s); +RZ_API int rz_str_bounds(const char *str, int *h); +RZ_API char *rz_str_crop(const char *str, unsigned int x, unsigned int y, unsigned int x2, unsigned int y2); +RZ_API char *rz_str_scale(const char *r, int w, int h); +RZ_API bool rz_str_range_in(const char *r, ut64 addr); +RZ_API size_t rz_str_utf8_cols(const char *s); +RZ_API size_t rz_str_utf8_num_ucp(RZ_NONNULL const char *str); +RZ_API size_t rz_str_utf8_get_width_utf16(RZ_NONNULL const char *str); +RZ_API size_t rz_str_utf8_ansi_cols(const char *str); +RZ_API size_t rz_str_len_utf8char(const char *s, int left); +RZ_API size_t rz_str_utf8_charsize(const char *str); +RZ_API size_t rz_str_utf8_charsize_prev(const char *str, int prev_len); +RZ_API size_t rz_str_utf8_charsize_last(const char *str); +RZ_API void rz_str_filter_zeroline(char *str, int len); +RZ_API size_t rz_str_utf8_codepoint(const char *s, size_t left); +RZ_API bool rz_str_char_fullwidth(const char *s, size_t left); +RZ_API int rz_str_write(int fd, const char *b); +RZ_API size_t rz_str_ncpy(char *dst, const char *src, size_t n); +RZ_API size_t rz_str_ncat(RZ_NONNULL RZ_OUT char *dst, RZ_NONNULL const char *src, size_t n); +RZ_API void rz_str_sanitize(char *c); +RZ_API char *rz_str_sanitize_sdb_key(const char *s); +RZ_API const char *rz_str_casestr(const char *a, const char *b); +RZ_API const char *rz_str_firstbut(const char *s, char ch, const char *but); +RZ_API const char *rz_str_lastbut(const char *s, char ch, const char *but); +RZ_API size_t rz_str_split(char *str, char ch); +RZ_API RzList /**/ *rz_str_split_list(char *str, const char *c, int n); +RZ_API RZ_OWN RzList /**/ *rz_str_split_list_regex(RZ_NONNULL char *str, RZ_NONNULL const char *r, int n); +RZ_API RzList /**/ *rz_str_split_duplist(const char *str, const char *c, bool trim); +RZ_API RzList /**/ *rz_str_split_duplist_n(const char *str, const char *c, int n, bool trim); +RZ_API RZ_OWN RzList /**/ *rz_str_split_duplist_n_regex(RZ_NONNULL const char *_str, RZ_NONNULL const char *r, int n, bool trim); +RZ_API size_t *rz_str_split_lines(char *str, size_t *count); +RZ_API RZ_OWN char *rz_str_replace(RZ_OWN char *str, const char *key, const char *val, int g); +RZ_API char *rz_str_replace_icase(char *str, const char *key, const char *val, int g, int keep_case); +RZ_API char *rz_str_replace_in(char *str, ut32 sz, const char *key, const char *val, int g); +#define rz_str_cpy(x, y) memmove((x), (y), strlen(y) + 1); +#define rz_str_cat(x, y) memmove((x) + strlen(x), (y), strlen(y) + 1); +RZ_API int rz_str_bits(char *strout, const ut8 *buf, int len, const char *bitz); +RZ_API int rz_str_bits64(char *strout, ut64 in); +RZ_API ut64 rz_str_bits_from_string(const char *buf, const char *bitz); +RZ_API int rz_str_rwx(const char *str); +RZ_API int rz_str_replace_ch(char *s, char a, char b, bool g); +RZ_API int rz_str_replace_char(char *s, int a, int b); +RZ_API int rz_str_replace_char_once(char *s, int a, int b); +RZ_API void rz_str_remove_char(char *str, char c); +RZ_API const char *rz_str_rwx_i(int rwx); +RZ_API int rz_str_fmtargs(const char *fmt); +RZ_API char *rz_str_arg_escape(const char *arg); +RZ_API int rz_str_arg_unescape(char *arg); +RZ_API char **rz_str_argv(const char *str, int *_argc); +RZ_API void rz_str_argv_free(char **argv); +RZ_API int rz_snprintf(char *string, int len, const char *fmt, ...) RZ_PRINTF_CHECK(3, 4); +RZ_API bool rz_str_is_whitespace(RZ_NONNULL const char *str); +RZ_API bool rz_str_is_ascii(const char *str); +RZ_API bool rz_str_is_utf8(RZ_NONNULL const char *str); +RZ_API char *rz_str_nextword(char *s, char ch); +RZ_API bool rz_str_is_printable(const char *str); +RZ_API bool rz_str_is_printable_limited(RZ_NONNULL const char *str, size_t size); +RZ_API bool rz_str_is_printable_incl_newlines(const char *str); +RZ_API char *rz_str_appendlen(char *ptr, const char *string, int slen); +RZ_API char *rz_str_newf(const char *fmt, ...) RZ_PRINTF_CHECK(1, 2); +RZ_API char *rz_str_newlen(const char *str, int len); +RZ_API const char *rz_str_sysbits(const int v); +RZ_API char *rz_str_trunc_ellipsis(const char *str, int len); +RZ_API const char *rz_str_bool(int b); +RZ_API bool rz_str_is_true(const char *s); +RZ_API bool rz_str_is_false(RZ_NULLABLE const char *s); +RZ_API bool rz_str_is_bool(const char *val); +RZ_API const char *rz_str_ansi_chrn(const char *str, size_t n); +RZ_API size_t rz_str_ansi_len(const char *str); +RZ_API size_t rz_str_ansi_nlen(const char *str, size_t len); +RZ_API int rz_str_ansi_trim(char *str, int str_len, int n); +RZ_API int rz_str_ansi_filter(char *str, char **out, int **cposs, int len); +RZ_API char *rz_str_ansi_crop(const char *str, unsigned int x, unsigned int y, unsigned int x2, unsigned int y2); +RZ_API int rz_str_word_count(const char *string); +RZ_API int rz_str_char_count(const char *string, char ch); +RZ_API char *rz_str_word_get0set(char *stra, int stralen, int idx, const char *newstr, int *newlen); +RZ_API int rz_str_word_set0(char *str); +RZ_API int rz_str_word_set0_stack(char *str); +static inline const char *rz_str_word_get_next0(const char *str) { + return str + strlen(str) + 1; +} +RZ_API const char *rz_str_word_get0(const char *str, int idx); +RZ_API RZ_OWN char *rz_str_skip_separator_chars(RZ_NONNULL const char *string); +RZ_API void rz_str_trim(RZ_NONNULL RZ_INOUT char *str); +RZ_API void rz_str_trim_char(RZ_NONNULL RZ_INOUT char *str, const char c); +RZ_API char *rz_str_trim_dup(const char *str); +RZ_API char *rz_str_trim_lines(char *str); +RZ_API void rz_str_trim_head(RZ_NONNULL RZ_INOUT char *str); +RZ_API void rz_str_trim_head_char(RZ_NONNULL RZ_INOUT char *str, const char c); +RZ_API const char *rz_str_trim_head_ro(RZ_NONNULL const char *str); +RZ_API const char *rz_str_trim_head_wp(RZ_NONNULL const char *str); +RZ_API RZ_INOUT char *rz_str_trim_tail(RZ_NONNULL RZ_INOUT char *str); +RZ_API void rz_str_trim_tail_char(RZ_NONNULL RZ_INOUT char *str, const char c); +RZ_API ut64 rz_str_djb2_hash(const char *str); +RZ_API char *rz_str_trim_nc(char *str); +RZ_API bool rz_str_is2utf8(RZ_NONNULL const char *c); +RZ_API bool rz_str_is3utf8(RZ_NONNULL const char *c); +RZ_API bool rz_str_is4utf8(RZ_NONNULL const char *c); +RZ_API bool rz_str_isXutf8(RZ_NONNULL const char *c, ut8 x); +RZ_API const char *rz_str_strchr(RZ_NONNULL const char *str, RZ_NONNULL const char *c); +RZ_API const char *rz_str_nstr(const char *from, const char *to, int size); +RZ_API const char *rz_str_case_nstr(RZ_NONNULL const char *from, RZ_NONNULL const char *to, int size); +RZ_API const char *rz_str_lchr(const char *str, char chr); +RZ_API const char *rz_sub_str_lchr(RZ_NONNULL const char *str, int start, int end, char chr); +RZ_API const char *rz_sub_str_rchr(RZ_NONNULL const char *str, int start, int end, char chr); +RZ_API RZ_OWN char *rz_sub_str_ptr(RZ_NONNULL const char *str, RZ_NONNULL const char *start, RZ_NONNULL const char *end); +RZ_API char *rz_str_ichr(char *str, char chr); +RZ_API bool rz_str_ccmp(const char *dst, const char *orig, int ch); +RZ_API bool rz_str_cmp_list(const char *list, const char *item, char sep); +RZ_API int rz_str_cmp(RZ_NULLABLE const char *dst, RZ_NULLABLE const char *orig, int len); +RZ_API int rz_str_casecmp(const char *dst, const char *orig); +RZ_API int rz_str_ncasecmp(const char *dst, const char *orig, size_t n); +RZ_API int rz_str_ccpy(char *dst, char *orig, int ch); +static inline const char *rz_str_get(const char *str) { + return str ? str : ""; +} +static inline const char *rz_str_get_null(const char *str) { + return str ? str : "(null)"; +} +RZ_API char *rz_str_ndup(RZ_NULLABLE const char *ptr, int len); +RZ_API RZ_OWN char *rz_str_dup(RZ_NULLABLE const char *str); +RZ_API int rz_str_delta(char *p, char a, char b); +RZ_API void rz_str_filter(char *str); +RZ_API const char *rz_str_tok(const char *str1, const char b, size_t len); +RZ_API const char *rz_str_str_xy(const char *s, const char *word, const char *prev, int *x, int *y); + +typedef void (*str_operation)(char *c); + +RZ_API int rz_str_do_until_token(str_operation op, char *str, const char tok); + +RZ_API void rz_str_reverse(char *str); +RZ_API int rz_str_path_unescape(char *path); +RZ_API char *rz_str_path_escape(const char *path); +RZ_API int rz_str_unescape(char *buf); +RZ_DEPRECATE RZ_API RZ_OWN char *rz_str_escape(RZ_NONNULL const char *buf); +RZ_API char *rz_str_escape_sh(const char *buf); +RZ_API bool rz_str_escape_code_point(ut32 /* RzCodePoint */ cp, size_t ch_bytes, RZ_NONNULL const RzStrEscOptions *opts); +RZ_DEPRECATE RZ_API char *rz_str_escape_dot(const char *buf); +RZ_DEPRECATE RZ_API char *rz_str_escape_8bit(const char *buf, bool colors, RzStrEscOptions *opt); +RZ_API RZ_OWN char *rz_str_escape_utf8(RZ_NONNULL const char *buf, RZ_NONNULL const RzStrEscOptions *opt); +RZ_API RZ_OWN char *rz_str_escape_utf16le(RZ_NONNULL const char *buf, size_t buf_size, RZ_NONNULL const RzStrEscOptions *opt); +RZ_API RZ_OWN char *rz_str_escape_utf32le(RZ_NONNULL const char *buf, size_t buf_size, RZ_NONNULL const RzStrEscOptions *opt); +RZ_API RZ_OWN char *rz_str_escape_utf16be(RZ_NONNULL const char *buf, size_t buf_size, RZ_NONNULL const RzStrEscOptions *opt); +RZ_API RZ_OWN char *rz_str_escape_utf32be(RZ_NONNULL const char *buf, size_t buf_size, RZ_NONNULL const RzStrEscOptions *opt); +RZ_API RZ_OWN char *rz_str_format_msvc_argv(size_t argc, const char **argv); +RZ_API void rz_str_uri_decode(char *buf); +RZ_API char *rz_str_uri_encode(const char *buf); +RZ_API char *rz_str_utf16_decode(const ut8 *s, int len); +RZ_DEPRECATE RZ_API char *rz_str_utf16_encode(const char *s, int len); +RZ_API RZ_OWN ut16 *rz_str_utf8_to_utf16(RZ_NONNULL const char *utf8_str, bool big_endian); +RZ_API RZ_OWN ut32 *rz_str_utf8_to_utf32(RZ_NONNULL const char *utf8_str, bool big_endian); +RZ_API char *rz_str_escape_utf8_for_json(const char *s, int len); +RZ_API char *rz_str_escape_mutf8_for_json(const char *s, int len); +RZ_API char *rz_str_home(const char *str); +RZ_API size_t rz_str_nlen(const char *s, size_t n); +RZ_API size_t rz_str_nlen_w(const char *s, int n); +RZ_API size_t rz_wstr_clen(const char *s); +RZ_API char *rz_str_prepend(char *ptr, const char *string); +RZ_API char *rz_str_prefix_all(const char *s, const char *pfx); +RZ_API RZ_OWN char *rz_str_append(RZ_OWN RZ_NULLABLE char *ptr, const char *string); +RZ_API char *rz_str_append_owned(char *ptr, char *string); +RZ_API RZ_OWN char *rz_str_appendf(RZ_OWN RZ_NULLABLE char *ptr, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); +RZ_API char *rz_str_appendch(char *x, char y); +RZ_API void rz_str_case(char *str, bool up); +RZ_API void rz_str_trim_path(char *s); +RZ_API ut8 rz_str_contains_macro(const char *input_value); +RZ_API void rz_str_truncate_cmd(char *string); +RZ_API char *rz_str_replace_thunked(char *str, char *clean, int *thunk, int clen, + const char *key, const char *val, int g); +RZ_API bool rz_str_glob(const char *str, const char *glob); +RZ_API int rz_str_binstr2bin(const char *str, ut8 *out, int outlen); +RZ_API char *rz_str_between(const char *str, const char *prefix, const char *suffix); +RZ_API bool rz_str_startswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle); +RZ_API bool rz_str_startswith_icase(RZ_NONNULL const char *str, RZ_NONNULL const char *needle); +RZ_API bool rz_str_endswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle); +RZ_API bool rz_str_endswith_icase(RZ_NONNULL const char *str, RZ_NONNULL const char *needle); +RZ_API bool rz_str_isnumber(const char *str); +RZ_API const char *rz_str_last(const char *in, const char *ch); +RZ_API char *rz_str_highlight(char *str, const char *word, const char *color, const char *color_reset); +RZ_API char *rz_str_from_ut64(ut64 val); +RZ_API char *rz_str_list_join(RzList /**/ *str, const char *sep); +RZ_API char *rz_str_array_join(const char **a, size_t n, const char *sep); +RZ_API RzList /**/ *rz_str_wrap(char *str, size_t width); + +RZ_API const char *rz_str_sep(const char *base, const char *sep); +RZ_API const char *rz_str_rsep(const char *base, const char *p, const char *sep); + +typedef struct rz_str_stringify_opt_t { + const ut8 *buffer; ///< String buffer (cannot be NULL). + ut32 length; ///< String buffer length. + RzStrEnc encoding; ///< String encoding type (cannot be RZ_STRING_ENC_GUESS) + ut32 wrap_at; ///< Adds a new line the output when it exceeds this value. + bool escape_nl; ///< When enabled escapes new lines (\n). + bool json; ///< Encodes the output as a JSON string. + bool stop_at_nil; ///< When enabled stops printing when '\0' is found. + bool stop_at_unprintable; ///< When enabled stops printing at first non-printable character. + bool urlencode; ///< Encodes the output following RFC 3986. +} RzStrStringifyOpt; + +RZ_API RzStrEnc rz_str_guess_encoding_from_buffer(RZ_NONNULL const ut8 *buffer, ut32 length); +RZ_API RZ_OWN char *rz_str_stringify_raw_buffer(RzStrStringifyOpt *option, RZ_NULLABLE RZ_OUT ut32 *length); + +RZ_API const char *rz_str_indent(int indent); + +/** + * \brief Returns true if the given encoding has the same byte character width as UTF-8. + * This is only true for UTF-8 and ASCII. + * + * Examples: + * + * ```c + * // IBM290 character width is always one byte, but the equivalent Japanese + * // characters in UTF-8 are 3 bytes. + * assert(rz_string_enc_same_char_width_as_utf8(RZ_STR_ENC_IBM290) == false); + * + * // ASCII character width is always one byte, and the equivalent + * // UTF-8 characters are also always 1 byte. + * assert(rz_string_enc_same_char_width_as_utf8(RZ_STR_ENC_8BIT) == true); + * ``` + */ +static inline bool rz_string_enc_same_char_width_as_utf8(RzStrEnc enc) { + return enc == RZ_STRING_ENC_UTF8 || enc == RZ_STRING_ENC_8BIT; +} + +RZ_API bool rz_string_enc_is_utf(RzStrEnc enc); +RZ_API bool rz_string_enc_is_utf_native_endian(RzStrEnc enc); +RZ_API size_t rz_string_enc_code_point_width(RzStrEnc enc); +RZ_API bool rz_string_enc_requires_scanning(RzStrEnc enc); + +static inline bool rz_string_code_points_align(RzStrEnc enc, size_t memory_alignment) { + rz_return_val_if_fail(memory_alignment, false); + if (rz_string_enc_code_point_width(enc) == memory_alignment) { + return true; + } + switch (enc) { + case RZ_STRING_ENC_SETTINGS: + rz_warn_if_reached(); + return false; + case RZ_STRING_ENC_GUESS: + return false; + default: + return memory_alignment % rz_string_enc_code_point_width(enc) == 0; + } +} + +#ifdef __cplusplus +} +#endif + +#endif // RZ_STR_H diff --git a/dest/include/librz/rz_util/rz_str_constpool.h b/dest/include/librz/rz_util/rz_str_constpool.h new file mode 100644 index 00000000000..68dfee3361a --- /dev/null +++ b/dest/include/librz/rz_util/rz_str_constpool.h @@ -0,0 +1,30 @@ +#ifndef RZ_STR_CONSTPOOL_H +#define RZ_STR_CONSTPOOL_H + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * RzStrConstPool is a pool of constant strings. + * References to strings will be valid as long as the RzStrConstPool is alive. + */ + +typedef struct rz_str_constpool_t { + HtSP *ht; +} RzStrConstPool; + +RZ_API bool rz_str_constpool_init(RzStrConstPool *pool); +RZ_API void rz_str_constpool_fini(RzStrConstPool *pool); +RZ_API const char *rz_str_constpool_get(RzStrConstPool *pool, const char *str); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_STR_CONSTPOOL_H diff --git a/dest/include/librz/rz_util/rz_str_search.h b/dest/include/librz/rz_util/rz_str_search.h new file mode 100644 index 00000000000..59c5ba79b07 --- /dev/null +++ b/dest/include/librz/rz_util/rz_str_search.h @@ -0,0 +1,59 @@ +#ifndef RZ_STR_SEARCH_H +#define RZ_STR_SEARCH_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Represent a detected string. + */ +typedef struct { + char *string; ///< The detected string. Note that this one is always in UTF-8. No matter what the ecoding is in memory. + RzRegexMulti *regex; ///< Regex matching the string. If set, the string member is the pattern. + ut64 addr; ///< Address/offset of the string in the RzBuffer + ut32 size; ///< Size of buffer containing the string in bytes + ut32 length; ///< Length of string in chars + RzStrEnc encoding; ///< String encoding in memory. + size_t alignment; ///< The address alignment a matched string must have. If search.align is set, both must match. + /** + * \brief Maps UTF-8 code point offsets to their memory offset. + * This is necessary if the string's character width in memory doesn't match UTF-8 character width. + * E.g. the in memory string is IBM270 (Japanese) and has a character width of 1 bytes. + * But the decoded string above is always UTF-8 and has a character width of 1-4 bytes. + * + * It is NULL if the string encoding in memory is UTF-8 or ASCII. + */ + ut64 *byte_mem_map; +} RzDetectedString; + +/** + * Defines the search parameters for rz_scan_strings + */ +typedef struct { + size_t max_str_length; ///< Maximum size of a detected string. + size_t min_str_length; ///< Minimum string length + bool prefer_big_endian; ///< True if the preferred endianess for UTF strings is big-endian + bool check_ascii_freq; ///< If true, perform check on ASCII frequencies when looking for false positives +} RzUtilStrScanOptions; + +RZ_API void rz_detected_string_free(RzDetectedString *str); + +RZ_API bool rz_scan_strings_single_raw(RZ_NONNULL const ut8 *buf, ut64 size, RZ_NONNULL const RzUtilStrScanOptions *opt, RzStrEnc type, RZ_NONNULL RzDetectedString **output); +RZ_API int rz_scan_strings_raw(RZ_NONNULL const ut8 *buf, RZ_NONNULL RzList /**/ *list, RZ_NONNULL const RzUtilStrScanOptions *opt, + const ut64 from, const ut64 to, RzStrEnc type); +RZ_API int rz_scan_strings(RZ_NONNULL RzBuffer *buf_to_scan, RZ_NONNULL RzList /**/ *list, RZ_NONNULL const RzUtilStrScanOptions *opt, + const ut64 from, const ut64 to, RzStrEnc type); +RZ_API int rz_scan_strings_whole_buf(RZ_NONNULL const RzBuffer *buf_to_scan, RZ_NONNULL RzList /**/ *list, RZ_NONNULL const RzUtilStrScanOptions *opt, RzStrEnc type); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_STR_SEARCH_H diff --git a/dest/include/librz/rz_util/rz_str_util.h b/dest/include/librz/rz_util/rz_str_util.h new file mode 100644 index 00000000000..b9c3276e092 --- /dev/null +++ b/dest/include/librz/rz_util/rz_str_util.h @@ -0,0 +1,18 @@ +#ifndef RZ_STR_UTIL_H +#define RZ_STR_UTIL_H + +#define IS_NULLSTR(x) (!(x) || !*(x)) +#define IS_WHITECHAR(x) ((x) == ' ' || (x) == '\t' || (x) == '\n' || (x) == '\r') +#define IS_SEPARATOR(x) ((x) == ' ' || (x) == '\t' || (x) == '\n' || (x) == '\r' || (x) == ' ' || \ + (x) == ',' || (x) == ';' || (x) == ':' || (x) == '[' || (x) == ']' || \ + (x) == '(' || (x) == ')' || (x) == '{' || (x) == '}') +#define IS_HEXCHAR(x) (((x) >= '0' && (x) <= '9') || ((x) >= 'a' && (x) <= 'f') || ((x) >= 'A' && (x) <= 'F')) +#define IS_PRINTABLE(x) ((x) >= ' ' && (x) <= '~') +#define IS_DIGIT(x) ((x) >= '0' && (x) <= '9') +#define IS_OCTAL(x) ((x) >= '0' && (x) <= '7') +#define IS_WHITESPACE(x) ((x) == ' ' || (x) == '\t') +#define IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z') +#define IS_LOWER(c) ((c) >= 'a' && (c) <= 'z') +#define IS_ALPHANUM(c) (IS_DIGIT(c) || IS_UPPER(c) || IS_LOWER(c)) + +#endif // RZ_STR_UTIL_H diff --git a/dest/include/librz/rz_util/rz_strbuf.h b/dest/include/librz/rz_util/rz_strbuf.h new file mode 100644 index 00000000000..3e208d2d2f6 --- /dev/null +++ b/dest/include/librz/rz_util/rz_strbuf.h @@ -0,0 +1,47 @@ +#ifndef RZ_STRBUF_H +#define RZ_STRBUF_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + char buf[32]; + size_t len; // string length in chars or binary buffer size + char *ptr; // ptr replacing buf in case strlen > sizeof(buf) + size_t ptrlen; // string length + 1 or binary buffer size +} RzStrBuf; + +#define RZ_STRBUF_SAFEGET(sb) (rz_strbuf_get(sb) ? rz_strbuf_get(sb) : "") +RZ_API RzStrBuf *rz_strbuf_new(const char *s); +RZ_API const char *rz_strbuf_set(RzStrBuf *sb, const char *s); // return = the string or NULL on fail +RZ_API bool rz_strbuf_slice(RZ_NONNULL RzStrBuf *sb, size_t from, size_t len); +RZ_API bool rz_strbuf_setbin(RzStrBuf *sb, const ut8 *s, size_t len); +RZ_API ut8 *rz_strbuf_getbin(RzStrBuf *sb, size_t *len); +RZ_API const char *rz_strbuf_setf(RzStrBuf *sb, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); // return = the string or NULL on fail +RZ_API const char *rz_strbuf_vsetf(RzStrBuf *sb, const char *fmt, va_list ap); // return = the string or NULL on fail +RZ_API bool rz_strbuf_append(RzStrBuf *sb, const char *s); +RZ_API bool rz_strbuf_append_n(RzStrBuf *sb, const char *s, size_t l); +RZ_API bool rz_strbuf_prepend(RzStrBuf *sb, const char *s); +RZ_API bool rz_strbuf_appendf(RzStrBuf *sb, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); +RZ_API bool rz_strbuf_vappendf(RzStrBuf *sb, const char *fmt, va_list ap); +RZ_API char *rz_strbuf_get(RzStrBuf *sb); +RZ_API RZ_OWN char *rz_strbuf_drain(RZ_OWN RZ_NONNULL RzStrBuf *sb); +RZ_API RZ_OWN char *rz_strbuf_drain_nofree(RzStrBuf *sb); +RZ_API size_t rz_strbuf_length(RzStrBuf *sb); +RZ_API void rz_strbuf_free(RzStrBuf *sb); +RZ_API void rz_strbuf_fini(RzStrBuf *sb); +RZ_API void rz_strbuf_init(RzStrBuf *sb); +RZ_API const char *rz_strbuf_initf(RzStrBuf *sb, const char *fmt, ...); // same as init + setf for convenience +RZ_API bool rz_strbuf_copy(RzStrBuf *dst, RzStrBuf *src); +RZ_API bool rz_strbuf_equals(RzStrBuf *sa, RzStrBuf *sb); +RZ_API bool rz_strbuf_reserve(RzStrBuf *sb, size_t len); +RZ_API bool rz_strbuf_is_empty(RzStrBuf *sb); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_STRBUF_H diff --git a/dest/include/librz/rz_util/rz_strpool.h b/dest/include/librz/rz_util/rz_strpool.h new file mode 100644 index 00000000000..4f80ca2f182 --- /dev/null +++ b/dest/include/librz/rz_util/rz_strpool.h @@ -0,0 +1,36 @@ +#ifndef RZ_STRPOOL_H +#define RZ_STRPOOL_H + +#include + +#define RZ_STRPOOL_INC 1024 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + char *str; + int len; + int size; +} RzStrpool; + +RZ_API RzStrpool *rz_strpool_new(int sz); +RZ_API char *rz_strpool_alloc(RzStrpool *p, int l); +RZ_API int rz_strpool_memcat(RzStrpool *p, const char *s, int len); +RZ_API int rz_strpool_ansi_chop(RzStrpool *p, int n); +RZ_API int rz_strpool_append(RzStrpool *p, const char *s); +RZ_API void rz_strpool_free(RzStrpool *p); +RZ_API int rz_strpool_fit(RzStrpool *p); +RZ_API char *rz_strpool_get(RzStrpool *p, int index); +RZ_API char *rz_strpool_get_i(RzStrpool *p, int index); +RZ_API int rz_strpool_get_index(RzStrpool *p, const char *s); +RZ_API char *rz_strpool_next(RzStrpool *p, int index); +RZ_API char *rz_strpool_slice(RzStrpool *p, int index); +RZ_API char *rz_strpool_empty(RzStrpool *p); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_STRPOOL_H diff --git a/dest/include/librz/rz_util/rz_structured_data.h b/dest/include/librz/rz_util/rz_structured_data.h new file mode 100644 index 00000000000..0aadf997418 --- /dev/null +++ b/dest/include/librz/rz_util/rz_structured_data.h @@ -0,0 +1,74 @@ +// SPDX-FileCopyrightText: 2025 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_STRUCTURED_DATA_H +#define RZ_STRUCTURED_DATA_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum rz_structured_data_block_t { + RZ_STRUCTURED_DATA_BLOCK_MAP = 0, + RZ_STRUCTURED_DATA_BLOCK_ARRAY = 1, +} RzStructuredDataBlock; + +typedef struct rz_structured_data_t RzStructuredData; + +typedef void (*RzStructuredDataIteratorNew)(RZ_NULLABLE void *user, RzStructuredDataBlock block, size_t n_elems); +typedef void (*RzStructuredDataIteratorEnd)(RZ_NULLABLE void *user); +typedef void (*RzStructuredDataIteratorKey)(RZ_NULLABLE void *user, RZ_NONNULL const char *key); +typedef void (*RzStructuredDataIteratorValueUnsigned)(RZ_NULLABLE void *user, ut64 n, bool hex); +typedef void (*RzStructuredDataIteratorValueSigned)(RZ_NULLABLE void *user, st64 n); +typedef void (*RzStructuredDataIteratorValueDouble)(RZ_NULLABLE void *user, double d); +typedef void (*RzStructuredDataIteratorValueBool)(RZ_NULLABLE void *user, bool b); +typedef void (*RzStructuredDataIteratorValueString)(RZ_NULLABLE void *user, RZ_NONNULL const char *v); + +typedef struct rz_structured_data_iterator_t { + RzStructuredDataIteratorNew new_struct; ///< Creates a new structure + RzStructuredDataIteratorEnd end_struct; ///< Ends the current structure + RzStructuredDataIteratorKey key; ///< Defines a key, called before a enter() or value_*() + RzStructuredDataIteratorValueUnsigned val_unsigned; ///< Inserts a value of numeric unsigned type + RzStructuredDataIteratorValueSigned val_signed; ///< Inserts a value of numeric signed type + RzStructuredDataIteratorValueDouble val_double; ///< Inserts a value of numeric double type + RzStructuredDataIteratorValueBool val_bool; ///< Inserts a value of boolean type + RzStructuredDataIteratorValueString val_string; ///< Inserts a value of string type +} RzStructuredDataIterator; + +RZ_API RZ_OWN RzStructuredData *rz_structured_data_new_map(); +RZ_API RZ_OWN RzStructuredData *rz_structured_data_new_array(); +RZ_API void rz_structured_data_free(RZ_NULLABLE RzStructuredData *sd); + +/* primitive types for maps */ +RZ_API RZ_BORROW RzStructuredData *rz_structured_data_map_add_map(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key); +RZ_API RZ_BORROW RzStructuredData *rz_structured_data_map_add_array(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key); +RZ_API bool rz_structured_data_map_add(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key, RZ_NONNULL RZ_OWN RzStructuredData *child); +RZ_API bool rz_structured_data_map_add_unsigned(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key, ut64 n, bool hex); +RZ_API bool rz_structured_data_map_add_signed(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key, st64 n); +RZ_API bool rz_structured_data_map_add_double(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key, double d); +RZ_API bool rz_structured_data_map_add_boolean(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key, bool b); +RZ_API bool rz_structured_data_map_add_string(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key, RZ_NONNULL const char *v); + +/* primitive types for arrays */ +RZ_API RZ_BORROW RzStructuredData *rz_structured_data_array_add_map(RZ_NONNULL RzStructuredData *parent); +RZ_API RZ_BORROW RzStructuredData *rz_structured_data_array_add_array(RZ_NONNULL RzStructuredData *parent); +RZ_API bool rz_structured_data_array_add(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL RZ_OWN RzStructuredData *child); +RZ_API bool rz_structured_data_array_add_unsigned(RZ_NONNULL RzStructuredData *parent, ut64 n, bool hex); +RZ_API bool rz_structured_data_array_add_signed(RZ_NONNULL RzStructuredData *parent, st64 n); +RZ_API bool rz_structured_data_array_add_double(RZ_NONNULL RzStructuredData *parent, double d); +RZ_API bool rz_structured_data_array_add_boolean(RZ_NONNULL RzStructuredData *parent, bool b); +RZ_API bool rz_structured_data_array_add_string(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *v); + +RZ_API void rz_structured_data_iterate(RZ_NONNULL const RzStructuredData *sd, RZ_NONNULL const RzStructuredDataIterator *iterator, RZ_NULLABLE void *user); +RZ_API void rz_structured_data_to_pj(RZ_NONNULL const RzStructuredData *sd, RZ_NONNULL PJ *pj); +RZ_API RZ_OWN char *rz_structured_data_to_json(RZ_NONNULL const RzStructuredData *sd); +RZ_API RZ_OWN char *rz_structured_data_to_yaml(RZ_NONNULL const RzStructuredData *sd); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_STRUCTURED_DATA_H */ diff --git a/dest/include/librz/rz_util/rz_subprocess.h b/dest/include/librz/rz_util/rz_subprocess.h new file mode 100644 index 00000000000..74b1232354a --- /dev/null +++ b/dest/include/librz/rz_util/rz_subprocess.h @@ -0,0 +1,124 @@ +// SPDX-FileCopyrightText: Florian Märkl , Riccardo Schirone +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_UTIL_SUBPROCESS_H +#define RZ_UTIL_SUBPROCESS_H + +#include +#include + +/** + * Enum used to determine how pipes should be created, if at all, in the + * subprocess. + */ +typedef enum rz_subprocess_pipe_create_t { + ///< No pipe should be created. It can be used for stdin, stdout and stderr. + RZ_SUBPROCESS_PIPE_NONE, + ///< A new pipe should be created. It can be used for stdin, stdout and stderr. + RZ_SUBPROCESS_PIPE_CREATE, + ///< A new PTY should be created. It can be used for stdin, stdout and stderr. + RZ_SUBPROCESS_PIPE_PTY, + ///< Re-use the same pipe/PTY as stdout. It can be used for stderr only. + RZ_SUBPROCESS_PIPE_STDOUT, +} RzSubprocessPipeCreate; + +/** + * Values passed to rz_subprocess API to mention stdin, stdout, stderr or a combination of those + */ +#define RZ_SUBPROCESS_STDIN (1 << 0) +#define RZ_SUBPROCESS_STDOUT (1 << 1) +#define RZ_SUBPROCESS_STDERR (1 << 2) + +typedef enum rz_process_wait_reason_t { + RZ_SUBPROCESS_DEAD, + RZ_SUBPROCESS_TIMEDOUT, + RZ_SUBPROCESS_BYTESREAD, +} RzSubprocessWaitReason; + +typedef enum rz_subprocess_fork_mode_t { + RZ_SUBPROCESS_FORK, + RZ_SUBPROCESS_FORKPTY, +} RzSubprocessForkMode; + +/** + * Provide results from running a sub-process, like output, return value, etc. + */ +typedef struct rz_process_output_t { + ///< Output generated by the process + ut8 *out; + ///< Number of bytes in the \p out field + int out_len; + ///< Error generated by the process + ut8 *err; + ///< Number of bytes in the \p err field + int err_len; + ///< Return value (exit code) of the sub-process + int ret; + ///< True if the process has exited because of a timeout + bool timeout; +} RzSubprocessOutput; + +typedef struct rz_pty_t { + int master_fd; + int slave_fd; + char *name; +} RzPty; + +/** + * Specify how the new subprocess should be created. + */ +typedef struct rz_subprocess_opt_t { + ///< Name of the executable to run. It is searched also in PATH + const char *file; + ///< Arguments to pass to the subprocess. These are just the arguments and do not include the program name (aka argv[0]) + const char **args; + ///< Number of arguments in \p args array + size_t args_size; + ///< Names of environment variables that subprocess should have differently from parent + const char **envvars; + ///< Values of environment variables that subprocess should have differently from parent + const char **envvals; + ///< Number of elements contained in both \p envvars and \p envvals + size_t env_size; + ///< Specify how to deal with subprocess stdin + RzSubprocessPipeCreate stdin_pipe; + ///< Specify how to deal with subprocess stdout + RzSubprocessPipeCreate stdout_pipe; + ///< Specify how to deal with subprocess stderr + RzSubprocessPipeCreate stderr_pipe; + + /* Both the following fields only matter when using PTY in the pipe options */ + ///< Provide the PTY to use (if NULL, then a new one will be created, if required) + ///< No need to close the PTY once it has been used, you can free it directly + RzPty *pty; + ///< Use raw mode for the created PTY (disable echo, control characters, etc.) + ///< If you don't know what to put here, put true here. + bool make_raw; +} RzSubprocessOpt; + +typedef struct rz_subprocess_t RzSubprocess; + +RZ_API bool rz_subprocess_init(void); +RZ_API void rz_subprocess_fini(void); +RZ_API RzSubprocess *rz_subprocess_start( + const char *file, const char *args[], size_t args_size, + const char *envvars[], const char *envvals[], size_t env_size); +RZ_API RZ_OWN RzSubprocess *rz_subprocess_start_opt(RZ_NONNULL const RzSubprocessOpt *opt); +RZ_API void rz_subprocess_free(RzSubprocess *proc); +RZ_API RzSubprocessWaitReason rz_subprocess_wait(RzSubprocess *proc, ut64 timeout_ms); +RZ_API void rz_subprocess_kill(RzSubprocess *proc); +RZ_API int rz_subprocess_ret(RzSubprocess *proc); +RZ_API ut8 *rz_subprocess_out(RzSubprocess *proc, int *length); +RZ_API ut8 *rz_subprocess_err(RzSubprocess *proc, int *length); +RZ_API ssize_t rz_subprocess_stdin_write(RzSubprocess *proc, const ut8 *buf, size_t buf_size); +RZ_API RzStrBuf *rz_subprocess_stdout_read(RzSubprocess *proc, size_t n, ut64 timeout_ms); +RZ_API RZ_BORROW RzStrBuf *rz_subprocess_stdout_readline(RzSubprocess *proc, ut64 timeout_ms); +RZ_API RzSubprocessOutput *rz_subprocess_drain(RzSubprocess *proc); +RZ_API void rz_subprocess_output_free(RzSubprocessOutput *out); + +RZ_API RZ_OWN RzPty *rz_subprocess_openpty(RZ_BORROW RZ_NULLABLE char *slave_name, RZ_NULLABLE void /* const struct termios */ *term_params, RZ_NULLABLE void /* const struct winsize */ *win_params); +RZ_API void rz_subprocess_close_pty(RZ_BORROW RZ_NONNULL const RzPty *pty); +RZ_API bool rz_subprocess_login_tty(RZ_BORROW RZ_NONNULL const RzPty *pty); +RZ_API void rz_subprocess_pty_free(RZ_OWN RzPty *pty); + +#endif // RZ_UTIL_SUBPROCESS_H diff --git a/dest/include/librz/rz_util/rz_sys.h b/dest/include/librz/rz_util/rz_sys.h new file mode 100644 index 00000000000..f5a35ce6bc0 --- /dev/null +++ b/dest/include/librz/rz_util/rz_sys.h @@ -0,0 +1,213 @@ +#ifndef RZ_SYS_H +#define RZ_SYS_H + +#include +#include + +#if __WINDOWS__ +#define RZ_SYS_DEVNULL "nul" +#else +#define RZ_SYS_DEVNULL "/dev/null" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + RZ_SYS_BITS_8 = 1, + RZ_SYS_BITS_16 = 2, + RZ_SYS_BITS_32 = 4, + RZ_SYS_BITS_64 = 8, +}; + +typedef struct { + char *sysname; + char *nodename; + char *release; + char *version; + char *machine; +} RSysInfo; + +RZ_API RSysInfo *rz_sys_info(void); +RZ_API void rz_sys_info_free(RSysInfo *si); + +RZ_API int rz_sys_sigaction(int *sig, void (*handler)(int)); +RZ_API int rz_sys_signal(int sig, void (*handler)(int)); +RZ_API void rz_sys_env_init(void); +RZ_API char **rz_sys_get_environ(void); +RZ_API void rz_sys_set_environ(char **e); + +RZ_API int rz_sys_fork(void); +RZ_API int rz_sys_kill(int pid, int sig); +// nocleanup = false => exit(); true => _exit() +RZ_API void rz_sys_exit(int status, bool nocleanup); + +/* openpty family of functions */ +RZ_API /* pid_t */ int rz_sys_forkpty(int *amaster, char *name, void /* const struct termios */ *termp, void /* const struct winsize */ *winp); +RZ_API int rz_sys_openpty(int *amaster, int *aslave, char *name, void /* const struct termios */ *termp, void /* const struct winsize */ *winp); +RZ_API int rz_sys_login_tty(int fd); + +RZ_API bool rz_is_heap(void *p); +RZ_API bool rz_sys_stop(void); +RZ_API char *rz_sys_pid_to_path(int pid); +RZ_API int rz_sys_run(const ut8 *buf, int len); +RZ_API int rz_sys_run_rop(const ut8 *buf, int len); +RZ_API int rz_sys_getpid(void); +#if !HAVE_PIPE || (__UNIX__ && HAVE_PIPE) +RZ_API int rz_sys_pipe(int pipefd[2], bool close_on_exec); +RZ_API int rz_sys_pipe_close(int fd); +#else +#define rz_sys_pipe pipe +#define rz_sys_pipe_close close +#endif +#if !HAVE_EXECV || (__UNIX__ && HAVE_EXECV && HAVE_PIPE && !HAVE_PIPE2) +RZ_API int rz_sys_execv(RZ_NONNULL const char *pathname, RZ_NONNULL char *const argv[]); +#else +#define rz_sys_execv execv +#endif +#if !HAVE_EXECVE || (__UNIX__ && HAVE_EXECVE && HAVE_PIPE && !HAVE_PIPE2) +RZ_API int rz_sys_execve(const char *pathname, char *const argv[], char *const envp[]); +#else +#define rz_sys_execve execve +#endif +#if !HAVE_EXECVP || (__UNIX__ && HAVE_EXECVP && HAVE_PIPE && !HAVE_PIPE2) +RZ_API int rz_sys_execvp(const char *file, char *const argv[]); +#else +#define rz_sys_execvp execvp +#endif +#if !HAVE_EXECL || (__UNIX__ && HAVE_EXECL && HAVE_PIPE && !HAVE_PIPE2) +RZ_API int rz_sys_execl(const char *pathname, const char *arg, ...); +#else +#define rz_sys_execl execl +#endif +#if !HAVE_SYSTEM || (__UNIX__ && HAVE_SYSTEM && HAVE_PIPE && !HAVE_PIPE2) +RZ_API int rz_sys_system(const char *command); +#else +#define rz_sys_system system +#endif +#define rz_sys_xsystem(cmd) RZ_V_NOT(rz_sys_system(cmd), -1) + +RZ_API const char *rz_sys_arch_str(int arch); +RZ_API int rz_sys_arch_id(const char *arch); +RZ_API bool rz_sys_arch_match(const char *archstr, const char *arch); +RZ_API RzList /**/ *rz_sys_dir(const char *path); +RZ_API void rz_sys_perror_str(const char *fun); +#define rz_sys_mkdir_failed() (errno != EEXIST) +RZ_API bool rz_sys_mkdir(const char *dir); +RZ_API bool rz_sys_mkdirp(const char *dir); +RZ_API int rz_sys_sleep(int secs); +RZ_API int rz_sys_usleep(int usecs); +RZ_API char *rz_sys_getenv(const char *key); +RZ_API bool rz_sys_getenv_asbool(const char *key); +RZ_API int rz_sys_setenv(const char *key, const char *value); +RZ_API int rz_sys_clearenv(void); +RZ_API char *rz_sys_whoami(char *buf); +RZ_API char *rz_sys_getdir(void); +RZ_API bool rz_sys_chdir(RZ_NONNULL const char *s); +RZ_API bool rz_sys_aslr(bool enable); +RZ_API void *rz_sys_dlopen(RZ_NULLABLE const char *libname); +RZ_API void *rz_sys_dlsym(void *handler, const char *name); +RZ_API int rz_sys_dlclose(void *handler); +RZ_API int rz_sys_cmd_str_full(const char *cmd, const char *input, char **output, int *len, char **sterr); +#if __WINDOWS__ +#if UNICODE +#define W32_TCHAR_FSTR "%S" +#define W32_TCALL(name) name "W" +#define rz_sys_conv_utf8_to_win(buf) rz_utf8_to_utf16(buf) +#define rz_sys_conv_utf8_to_win_l(buf, len) rz_utf8_to_utf16_l(buf, len) +#define rz_sys_conv_win_to_utf8(buf) rz_utf16_to_utf8(buf) +#define rz_sys_conv_win_to_utf8_l(buf, len) rz_utf16_to_utf8_l((wchar_t *)buf, len) +#else +#define W32_TCHAR_FSTR "%s" +#define W32_TCALL(name) name "A" +#define rz_sys_conv_utf8_to_win(buf) rz_utf8_to_acp(buf) +#define rz_sys_conv_utf8_to_win_l(buf, len) rz_utf8_to_acp_l(buf, len) +#define rz_sys_conv_win_to_utf8(buf) rz_acp_to_utf8(buf) +#define rz_sys_conv_win_to_utf8_l(buf, len) rz_acp_to_utf8_l(buf, len) +#endif +typedef void *HANDLE; +RZ_API char *rz_sys_get_src_dir_w32(void); +RZ_API bool rz_sys_create_child_proc_w32(const char *cmdline, HANDLE in, HANDLE out, HANDLE err); +RZ_API char **rz_sys_utf8_argv_new(int argc, const wchar_t **argv); +RZ_API void rz_sys_utf8_argv_free(int argc, char **utf8_argv); +#endif +RZ_API int rz_sys_open_perms(int rizin_perms); +RZ_API int rz_sys_open(const char *path, int perm, int mode); +RZ_API FILE *rz_sys_fopen(const char *path, const char *mode); +RZ_API int rz_sys_truncate_fd(int fd, ut64 length); +RZ_API int rz_sys_truncate(const char *file, int sz); +RZ_API int rz_sys_cmdf(const char *fmt, ...) RZ_PRINTF_CHECK(1, 2); +RZ_API char *rz_sys_cmd_str(const char *cmd, const char *input, int *len); +RZ_API char *rz_sys_cmd_strf(const char *cmd, ...) RZ_PRINTF_CHECK(1, 2); +// #define rz_sys_cmd_str(cmd, input, len) rz_sys_cmd_str_full(cmd, input, len, 0) +RZ_API void rz_sys_backtrace(void); + +#ifndef __has_builtin +#define __has_builtin(n) (0) +#endif + +#if __has_builtin(__builtin_debugtrap) +#define rz_sys_breakpoint() __builtin_debugtrap() +#endif + +#ifndef rz_sys_breakpoint +#if __WINDOWS__ +#define rz_sys_breakpoint() \ + { \ + __debugbreak(); \ + } +#else +#if __GNUC__ +#define rz_sys_breakpoint() __builtin_trap() +#elif __i386__ || __x86_64__ +#define rz_sys_breakpoint() __asm__ volatile("int3"); +#elif __arm64__ || __aarch64__ +#define rz_sys_breakpoint() __asm__ volatile("brk 0"); +// #define rz_sys_breakpoint() __asm__ volatile ("brk #1"); +#elif (__arm__ || __thumb__) +#if __ARM_ARCH > 5 +#define rz_sys_breakpoint() __asm__ volatile("bkpt $0"); +#else +#define rz_sys_breakpoint() __asm__ volatile("svc $1"); +#endif +#elif __mips__ +#define rz_sys_breakpoint() __asm__ volatile("break"); +// # define rz_sys_breakpoint() __asm__ volatile ("teq $0, $0"); +#elif __EMSCRIPTEN__ +// TODO: cannot find a better way to breakpoint in wasm/asm.js +#define rz_sys_breakpoint() \ + { \ + char *a = NULL; \ + *a = 0; \ + } +#else +#warning rz_sys_breakpoint not implemented for this platform +#define rz_sys_trap() __asm__ __volatile__(".word 0"); +#define rz_sys_breakpoint() \ + { \ + char *a = NULL; \ + *a = 0; \ + } +#endif +#endif +#endif + +/* syscmd */ +RZ_API RZ_OWN char *rz_syscmd_cat(RZ_NONNULL const char *file); +RZ_API RZ_OWN char *rz_syscmd_mkdir(RZ_NONNULL const char *dir); +RZ_API RZ_OWN char *rz_syscmd_uniq(RZ_NONNULL const char *file); +RZ_API RZ_OWN char *rz_syscmd_head(RZ_NONNULL const char *file, int count); +RZ_API RZ_OWN char *rz_syscmd_tail(RZ_NONNULL const char *file, int count); +RZ_API RZ_OWN char *rz_syscmd_join(RZ_NONNULL const char *file1, RZ_NONNULL const char *file2); +RZ_API RZ_OWN char *rz_syscmd_sort(RZ_NONNULL const char *file); +RZ_API RZ_OWN char *rz_syscmd_sort_pipe(RZ_NULLABLE const char *input, int *length); +RZ_API RZ_OWN char *rz_syscmd_uniq_pipe(RZ_NULLABLE const char *input, int *length); +RZ_API RZ_OWN char *rz_syscmd_sort_str(RZ_NONNULL const char *input); +RZ_API RZ_OWN char *rz_syscmd_uniq_str(RZ_NONNULL const char *input); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_SYS_H diff --git a/dest/include/librz/rz_util/rz_table.h b/dest/include/librz/rz_util/rz_table.h new file mode 100644 index 00000000000..b8821145cfd --- /dev/null +++ b/dest/include/librz/rz_util/rz_table.h @@ -0,0 +1,97 @@ +#ifndef RZ_UTIL_TABLE_H +#define RZ_UTIL_TABLE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + RZ_TABLE_ALIGN_LEFT = 0, + RZ_TABLE_ALIGN_RIGHT, + RZ_TABLE_ALIGN_CENTER, + // size + RZ_TABLE_ALIGN_ENUM_MAX, +} RzTableAlign; + +typedef enum { + RZ_TABLE_COLUMN_TYPE_STRING = 0, + RZ_TABLE_COLUMN_TYPE_NUMBER, + RZ_TABLE_COLUMN_TYPE_BOOL, + // size + RZ_TABLE_COLUMN_TYPE_ENUM_MAX, +} RzTableColumnType; + +typedef int (*RzTableColumnTypeComparator)(const void *a, const void *b); + +typedef struct { + char *name; ///< Column name + RzTableColumnType type; ///< Inferred type of the data + RzTableColumnTypeComparator type_cmp; ///< Column comparator used for sorting + RzTableAlign align; ///< Column alignment left, right, center + int width; ///< Computed column width + int total; ///< Sum of the rows associated to this column. +} RzTableColumn; + +typedef struct { + RzPVector /**/ *items; +} RzTableRow; + +typedef void (*RzTableSelector)(RzTableRow *acc, RzTableRow *new_row, size_t nth); +typedef const char *(*RzTableColorSelector)(const char *value, const char *column, const size_t column_n, const RzTableColumnType type, void *user); + +typedef enum { + RZ_TABLE_CHAR_MODE_ASCII = 0, + RZ_TABLE_CHAR_MODE_UTF8, + RZ_TABLE_CHAR_MODE_UTF8_CURVY, + // size + RZ_TABLE_CHAR_MODE_ENUM_MAX, +} RzTableCharMode; + +typedef struct { + RzVector /**/ *rows; ///< Rows data + RzVector /**/ *cols; ///< Columns data + size_t totalCols; ///< Total number of columns + bool showHeader; ///< When true, upon call of rz_table_tostring, it will show the header + bool showFancy; ///< When true, upon call of rz_table_tostring, it will use the fancy table output + bool showJSON; ///< When true, upon call of rz_table_tostring, it will return a json structure + bool showCSV; ///< When true, upon call of rz_table_tostring, it will return a csv structure + bool showSum; ///< When true, upon call of rz_table_tostring, it will show the toal sum of each row + RzTableCharMode char_mode; ///< Sets the charset type used for the string output + RzTableColorSelector color; ///< It is used to retrieve a color palette to use in each column data. + void *color_user; ///< Additional data that is passed via RzTableColorSelector() +} RzTable; + +RZ_API RZ_OWN RzTable *rz_table_new(void); +RZ_API void rz_table_free(RZ_NULLABLE RzTable *t); +RZ_API void rz_table_add_column(RZ_NONNULL RzTable *t, const RzTableColumnType type, RZ_NONNULL const char *name); +RZ_API void rz_table_set_columnsf(RZ_NONNULL RzTable *t, RZ_NONNULL const char *fmt, ...); +RZ_API void rz_table_set_vcolumnsf(RZ_NONNULL RzTable *t, RZ_NONNULL const char *fmt, va_list ap); +RZ_API void rz_table_add_row(RZ_NONNULL RzTable *t, RZ_NONNULL const char *name, ...); +RZ_API void rz_table_add_vrowf(RZ_NONNULL RzTable *t, RZ_NONNULL const char *fmt, va_list ap); +RZ_API void rz_table_add_rowf(RZ_NONNULL RzTable *t, RZ_NONNULL const char *fmt, ...); +RZ_API void rz_table_add_row_columnsf(RZ_NONNULL RzTable *t, RZ_NONNULL const char *fmt, ...); +RZ_API void rz_table_add_row_vec(RZ_NONNULL RzTable *t, RZ_NONNULL RZ_OWN RzPVector /**/ *items); +RZ_API RZ_OWN char *rz_table_tofancystring(RZ_NONNULL RzTable *t); +RZ_API RZ_OWN char *rz_table_tosimplestring(RZ_NONNULL RzTable *t); +RZ_API RZ_OWN char *rz_table_tostring(RZ_NONNULL RzTable *t); +RZ_API RZ_OWN char *rz_table_tocsv(RZ_NONNULL RzTable *t); +RZ_API RZ_OWN char *rz_table_tojson(RZ_NONNULL RzTable *t); +RZ_API void rz_table_sort(RZ_NONNULL RzTable *t, size_t nth, bool reverse); +RZ_API void rz_table_sortlen(RZ_NONNULL RzTable *t, size_t nth, bool reverse); +RZ_API void rz_table_uniq(RZ_NONNULL RzTable *t); +RZ_API void rz_table_group(RZ_NONNULL RzTable *t, size_t nth, RZ_NULLABLE RzTableSelector selector); +RZ_API bool rz_table_query(RZ_NONNULL RzTable *t, RZ_NULLABLE const char *q); +RZ_API bool rz_table_align(RZ_NONNULL RzTable *t, size_t nth, RzTableAlign align); +RZ_API RZ_OWN RzTable *rz_table_transpose(RZ_NONNULL RzTable *t); +RZ_API void rz_table_columns_select(RZ_NONNULL RzTable *t, RZ_NONNULL RzList /**/ *col_names); +RZ_API void rz_table_show_header(RZ_NONNULL RzTable *t, bool show_header); +RZ_API void rz_table_set_char_mode(RZ_NONNULL RzTable *t, RzTableCharMode mode); +RZ_API void rz_table_set_color_selector(RZ_NONNULL RzTable *t, RZ_NULLABLE RzTableColorSelector color_cb, void *user); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/rz_th_ht.h b/dest/include/librz/rz_util/rz_th_ht.h new file mode 100644 index 00000000000..23eed7aa55f --- /dev/null +++ b/dest/include/librz/rz_util/rz_th_ht.h @@ -0,0 +1,48 @@ +// SPDX-FileCopyrightText: 2023 RizinOrg +// SPDX-FileCopyrightText: 2023 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_TH_HASH_TABLE_H +#define RZ_TH_HASH_TABLE_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef RZ_API + +#define rz_th_ht_header(name, type, ktype, vtype) \ + typedef struct rz_th_##name##_t RzThread##type; \ + RZ_API void rz_th_##name##_free(RzThread##type *ht); \ + RZ_API RzThread##type *rz_th_##name##_new(type *table); \ + RZ_API bool rz_th_##name##_insert(RzThread##type *ht, const ktype key, vtype value); \ + RZ_API bool rz_th_##name##_update(RzThread##type *ht, const ktype key, vtype value); \ + RZ_API bool rz_th_##name##_delete(RzThread##type *ht, const ktype key); \ + RZ_API vtype rz_th_##name##_find(RzThread##type *ht, const ktype key, bool *found); \ + RZ_API type *rz_th_##name##_move(RzThread##type *ht); \ + RZ_API void rz_th_##name##_foreach(RzThread##type *ht, type##ForeachCallback cb, void *user) + +rz_th_ht_header(ht_pp, HtPP, void *, void *); +rz_th_ht_header(ht_up, HtUP, ut64, void *); +rz_th_ht_header(ht_uu, HtUU, ut64, ut64); +rz_th_ht_header(ht_pu, HtPU, void *, ut64); +rz_th_ht_header(ht_sp, HtSP, char *, void *); +rz_th_ht_header(ht_ss, HtSS, char *, char *); +rz_th_ht_header(ht_su, HtSU, char *, ut64); + +#endif /* RZ_API */ + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_TH_HASH_TABLE_H */ diff --git a/dest/include/librz/rz_util/rz_time.h b/dest/include/librz/rz_util/rz_time.h new file mode 100644 index 00000000000..6cf57fae673 --- /dev/null +++ b/dest/include/librz/rz_util/rz_time.h @@ -0,0 +1,64 @@ +#ifndef RZ_TIME_H +#define RZ_TIME_H + +#include +#include + +#define RZ_NSEC_PER_SEC 1000000000ULL +#define RZ_NSEC_PER_MSEC 1000000ULL +#define RZ_USEC_PER_SEC 1000000ULL +#define RZ_NSEC_PER_USEC 1000ULL +#define RZ_USEC_PER_MSEC 1000ULL + +#define ASCTIME_BUF_MINLEN 26 + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _MSC_VER +struct timeval; +#endif + +RZ_API int rz_time_gettimeofday(struct timeval *p); + +// wall clock time in microseconds +RZ_API ut64 rz_time_now(void); + +// monotonic time in microseconds +RZ_API ut64 rz_time_now_mono(void); + +RZ_API RZ_OWN char *rz_time_stamp_to_str(ut32 timestamp); +RZ_API ut32 rz_time_dos_time_stamp_to_posix(ut32 timestamp); +RZ_API bool rz_time_stamp_is_dos_format(const ut32 certainPosixTimeStamp, const ut32 possiblePosixOrDosTimeStamp); +RZ_API RZ_OWN char *rz_time_date_dos_to_string(ut32 timestamp); +RZ_API RZ_OWN char *rz_time_date_hfs_to_string(ut32 timestamp); +RZ_API RZ_OWN char *rz_time_date_w32_to_string(ut64 timestamp); +#define rz_time_date_unix_to_string rz_time_stamp_to_str +RZ_API RZ_OWN char *rz_time_date_now_to_string(void); + +// Thread-safe cross platform wrappers +RZ_API char *rz_asctime_r(RZ_NONNULL const struct tm *tm, RZ_NONNULL char *buf); +RZ_API char *rz_ctime_r(RZ_NONNULL const time_t *timer, RZ_NONNULL char *buf); +RZ_API struct tm *rz_localtime_r(RZ_NONNULL const time_t *time, RZ_NONNULL struct tm *res); +RZ_API struct tm *rz_gmtime_r(RZ_NONNULL const time_t *time, RZ_NONNULL struct tm *res); + +#define RZ_TIME_PROFILE_ENABLED 0 + +#if RZ_TIME_PROFILE_ENABLED +#define RZ_TIME_PROFILE_BEGIN ut64 __now__ = rz_time_now_mono() +#define RZ_TIME_PROFILE_END eprintf("%s %" PFMT64d "\n", __FUNCTION__, rz_time_now_mono() - __now__) +#else +#define RZ_TIME_PROFILE_BEGIN \ + do { \ + } while (0) +#define RZ_TIME_PROFILE_END \ + do { \ + } while (0) +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_util/rz_tree.h b/dest/include/librz/rz_util/rz_tree.h new file mode 100644 index 00000000000..105c9ffb919 --- /dev/null +++ b/dest/include/librz/rz_util/rz_tree.h @@ -0,0 +1,35 @@ +#ifndef RZ_TREE_H +#define RZ_TREE_H +#include + +struct rz_tree_t; + +typedef struct rz_tree_node_t { + struct rz_tree_node_t *parent; + struct rz_tree_t *tree; + RzList /**/ *children; + unsigned int n_children; + int depth; + RzListFree free; + void *data; +} RTreeNode; + +typedef struct rz_tree_t { + RTreeNode *root; +} RTree; + +typedef struct rz_tree_visitor_t { + void (*pre_visit)(RTreeNode *, struct rz_tree_visitor_t *); + void (*post_visit)(RTreeNode *, struct rz_tree_visitor_t *); + void (*discover_child)(RTreeNode *, struct rz_tree_visitor_t *); + void *data; +} RTreeVisitor; +typedef void (*RTreeNodeVisitCb)(RTreeNode *n, RTreeVisitor *vis); + +RZ_API RTree *rz_tree_new(void); +RZ_API RTreeNode *rz_tree_add_node(RTree *t, RTreeNode *node, void *child_data); +RZ_API void rz_tree_reset(RTree *t); +RZ_API void rz_tree_free(RTree *t); +RZ_API void rz_tree_dfs(RTree *t, RTreeVisitor *vis); +RZ_API void rz_tree_bfs(RTree *t, RTreeVisitor *vis); +#endif // RZ_TREE_H diff --git a/dest/include/librz/rz_util/rz_uleb128.h b/dest/include/librz/rz_util/rz_uleb128.h new file mode 100644 index 00000000000..71f137c62f9 --- /dev/null +++ b/dest/include/librz/rz_util/rz_uleb128.h @@ -0,0 +1,20 @@ +#ifndef RZ_ULEB128_H +#define RZ_ULEB128_H + +#include + +// LEB128 or Little Endian Base 128 is a form of variable-length code +// compression used to store an arbitrarily large integer in a small number of +// bytes. LEB128 is used in the DWARF debug file format. + +RZ_API const ut8 *rz_uleb128(const ut8 *data, int datalen, RZ_NULLABLE ut64 *v, const char **error); +RZ_API const ut8 *rz_uleb128_decode(const ut8 *data, int *datalen, ut64 *v); +RZ_API int rz_uleb128_len(const ut8 *data, int size); +RZ_API ut8 *rz_uleb128_encode(const ut64 s, int *len); +RZ_API const ut8 *rz_leb128(const ut8 *data, int datalen, st64 *v); +RZ_API st64 rz_sleb128(const ut8 **data, const ut8 *end); +RZ_API size_t read_u32_leb128(const ut8 *p, const ut8 *max, ut32 *out_val); +RZ_API size_t read_i32_leb128(const ut8 *p, const ut8 *max, st32 *out_val); +RZ_API size_t read_u64_leb128(const ut8 *p, const ut8 *max, ut64 *out_val); +RZ_API size_t read_i64_leb128(const ut8 *p, const ut8 *max, st64 *out_val); +#endif // RZ_ULEB128_H diff --git a/dest/include/librz/rz_util/rz_unicode.h b/dest/include/librz/rz_util/rz_unicode.h new file mode 100644 index 00000000000..a1361af2374 --- /dev/null +++ b/dest/include/librz/rz_util/rz_unicode.h @@ -0,0 +1,57 @@ +#ifndef RZ_UNICODE_H +#define RZ_UNICODE_H + +#include +#include "rz_str.h" + +#define RZ_UNICODE_NUL 0 +#define RZ_UNICODE_MAX_BYTES_PER_CHAR 4 +#define RZ_UNICODE_VERSION_MAJOR 16 +#define RZ_UNICODE_VERSION_MINOR 0 +#define RZ_UNICODE_VERSION_PATCH 0 +#define RZ_UNICODE_LAST_ASCII 0x7F +#define RZ_UNICODE_FIRST_1BYTE_CODE_POINT 0x0 +#define RZ_UNICODE_FIRST_2BYTE_CODE_POINT 0x80 +#define RZ_UNICODE_FIRST_3BYTE_CODE_POINT 0x0800 +#define RZ_UNICODE_FIRST_4BYTE_CODE_POINT 0x010000 +#define RZ_UNICODE_LAST_CODE_POINT 0x10ffff +/** + * \brief String width of "\U00hhhhhh" + */ +#define RZ_UNICODE_ESCAPED_STR_WIDTH 10 + +struct rz_unicode_range_name_entry_t { + ut32 from; + ut32 to; + const char *name; +}; + +typedef struct rz_unicode_range_name_entry_t RzUnicodeRangeNameTable[]; + +struct rz_unicode_range_entry_t { + ut32 from; + ut32 to; +}; + +typedef struct rz_unicode_range_entry_t RzUnicodeRangeTable[]; + +/** + * \brief An Unicode code point. + * + * NOTE: Be careful when assigning char values to it. On some platforms + * they might get sign extended and the code point is an invalid value. + */ +typedef ut32 RzCodePoint; + +RZ_API bool rz_unicode_code_point_is_printable(const RzCodePoint c); +RZ_API bool rz_unicode_code_point_is_defined(const RzCodePoint c); +RZ_API bool rz_unicode_code_point_is_legal_decode(const RzCodePoint c); +RZ_API bool rz_unicode_code_point_is_control(const RzCodePoint c); +RZ_API bool rz_unicode_code_point_is_surrogate(const RzCodePoint c); +RZ_API bool rz_unicode_code_point_is_private(const RzCodePoint c); +RZ_API bool rz_unicode_code_point_is_format(const RzCodePoint c); +RZ_API RzStrEnc rz_unicode_bom_encoding(const ut8 *ptr, size_t ptrlen); +RZ_API void rz_unicode_code_point_escape(RzCodePoint code_point, RZ_NONNULL RZ_OUT char **dst, RZ_NONNULL const RzStrEscOptions *opt); +RZ_API void rz_unicode_byte_escape(char ch, RZ_NONNULL RZ_OUT char **dst, RZ_NONNULL const RzStrEscOptions *opt); + +#endif // RZ_UNICODE_H diff --git a/dest/include/librz/rz_util/rz_utf16.h b/dest/include/librz/rz_util/rz_utf16.h new file mode 100644 index 00000000000..350203cd728 --- /dev/null +++ b/dest/include/librz/rz_util/rz_utf16.h @@ -0,0 +1,23 @@ +#ifndef RZ_UTF16_H +#define RZ_UTF16_H + +/* For RzCodePoint definition */ +#include "rz_utf8.h" + +/** + * \brief First Unicode code point which needs 4 bytes to be encoded. + */ +#define RZ_UTF16_FIRST_4BYTES_CODE_POINT 0x10000 +/** + * \brief Width of an UTF16 character in bytes. + */ +#define RZ_UTF16_CODE_POINT_WIDTH 2 + +RZ_API size_t rz_utf16_decode(RZ_NONNULL const ut8 *buf, size_t buf_len, RZ_NULLABLE RZ_OUT RzCodePoint *ch, bool check_is_def, bool bigendian); +RZ_API size_t rz_utf16le_decode(RZ_NONNULL const ut8 *buf, size_t buf_len, RZ_NULLABLE RZ_OUT RzCodePoint *ch, bool check_is_def); +RZ_API size_t rz_utf16be_decode(RZ_NONNULL const ut8 *buf, size_t buf_len, RZ_NULLABLE RZ_OUT RzCodePoint *ch, bool check_is_def); +RZ_API size_t rz_utf16_encode(RZ_NONNULL RZ_OUT ut8 *buf, RzCodePoint ch, bool big_endian); +RZ_API bool rz_utf16_is_printable_code_point(RZ_NONNULL const ut8 *buf, size_t buf_len, bool big_endian, size_t lookahead); +RZ_API RZ_OWN ut8 *rz_str_utf16_to_utf8(RZ_NONNULL const ut8 *src, size_t len_src, bool little_endian); + +#endif // RZ_UTF16_H diff --git a/dest/include/librz/rz_util/rz_utf32.h b/dest/include/librz/rz_util/rz_utf32.h new file mode 100644 index 00000000000..aea1ada602e --- /dev/null +++ b/dest/include/librz/rz_util/rz_utf32.h @@ -0,0 +1,27 @@ +#ifndef RZ_UTF32_H +#define RZ_UTF32_H + +/* For RzCodePoint definition */ +#include "rz_utf8.h" + +/** + * \brief Unicode byte order markings (BOM) + * according to https://www.unicode.org/faq/utf_bom.html#BOM + */ +#define RZ_UTF32_UNICODE_BOM_LE 0xFFFE0000 +#define RZ_UTF32_UNICODE_BOM_BE 0x0000FFFE + +/** + * \brief Width of an UTF32 character in bytes. + */ +#define RZ_UTF32_WIDTH_CHAR 4 +#define RZ_UTF32_CODE_POINT_WIDTH 4 + +RZ_API size_t rz_utf32_decode(RZ_NONNULL const ut8 *buf, size_t buf_len, RZ_NULLABLE RZ_OUT RzCodePoint *ch, bool check_is_def, bool big_endian); +RZ_API int rz_utf32le_decode(const ut8 *ptr, int ptrlen, RZ_NULLABLE RZ_OUT RzCodePoint *ch, bool check_validity); +RZ_API int rz_utf32be_decode(const ut8 *ptr, int ptrlen, RZ_NULLABLE RZ_OUT RzCodePoint *ch, bool check_validity); +RZ_API size_t rz_utf32_encode(RZ_NONNULL RZ_OUT ut8 *buf, RzCodePoint ch, bool big_endian); +RZ_API bool rz_utf32_valid_code_point(RZ_NONNULL const ut8 *buf, size_t buf_len, bool big_endian, size_t lookahead); +RZ_API RZ_OWN ut8 *rz_str_utf32_to_utf8(RZ_NONNULL const ut8 *src, size_t len_src, bool little_endian); + +#endif // RZ_UTF32_H diff --git a/dest/include/librz/rz_util/rz_utf8.h b/dest/include/librz/rz_util/rz_utf8.h new file mode 100644 index 00000000000..f764c1e3f93 --- /dev/null +++ b/dest/include/librz/rz_util/rz_utf8.h @@ -0,0 +1,35 @@ +#ifndef RZ_UTF8_H +#define RZ_UTF8_H + +/* For RzStrEnc definition */ +#include "rz_unicode.h" + +/** + * \brief Width of an UTF32 character in bytes. + */ +#define RZ_UTF8_CODE_POINT_WIDTH 1 + +/** + * \brief An Unicode code point. + */ +RZ_API size_t rz_utf8_encode(RZ_OUT RZ_NONNULL ut8 *ptr, const RzCodePoint ch); +RZ_API size_t rz_utf8_decode(RZ_NONNULL const ut8 *buf, size_t buf_len, RZ_NULLABLE RZ_OUT RzCodePoint *cp, bool check_is_def); +RZ_API int rz_mutf8_decode(const ut8 *ptr, int ptrlen, RzCodePoint *ch); +RZ_API int rz_utf8_encode_str(const RzCodePoint *str, ut8 *dst, const int dst_length); +RZ_API int rz_utf8_size(const ut8 *ptr); +RZ_API size_t rz_utf8_strlen(const ut8 *str); +RZ_API const char *rz_utf_block_name(int idx); +RZ_API int rz_utf_block_idx(RzCodePoint ch); +RZ_API int *rz_utf_block_list(const ut8 *str, int len, int **freq_list); +#if __WINDOWS__ +#define rz_utf16_to_utf8(wc) rz_utf16_to_utf8_l((wchar_t *)wc, -1) +#define rz_utf8_to_utf16(cstring) rz_utf8_to_utf16_l((char *)cstring, -1) +RZ_API char *rz_utf16_to_utf8_l(const wchar_t *wc, int len); +RZ_API wchar_t *rz_utf8_to_utf16_l(const char *cstring, int len); +RZ_API char *rz_acp_to_utf8_l(const char *str, int len); +RZ_API char *rz_utf8_to_acp_l(const char *str, int len); +#define rz_acp_to_utf8(str) rz_acp_to_utf8_l((char *)str, -1) +#define rz_utf8_to_acp(cstring) rz_utf8_to_acp_l((char *)cstring, -1) +#endif // __WINDOWS__ + +#endif // RZ_UTF8_H diff --git a/dest/include/librz/rz_util/rz_version.h b/dest/include/librz/rz_util/rz_version.h new file mode 100644 index 00000000000..f99e50643b6 --- /dev/null +++ b/dest/include/librz/rz_util/rz_version.h @@ -0,0 +1,17 @@ +#ifndef RZ_VERSION_H +#define RZ_VERSION_H + +#include "rz_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +RZ_API RZ_OWN char *rz_version_gittip(RZ_BORROW RZ_NONNULL RzPath *sys_path); +RZ_API RZ_OWN char *rz_version_str(RZ_BORROW RZ_NONNULL RzPath *sys_path, RZ_NULLABLE const char *program); + +#ifdef __cplusplus +} +#endif + +#endif // RZ_VERSION_H diff --git a/dest/include/librz/rz_util/rz_x509.h b/dest/include/librz/rz_util/rz_x509.h new file mode 100644 index 00000000000..03fcd402a74 --- /dev/null +++ b/dest/include/librz/rz_util/rz_x509.h @@ -0,0 +1,104 @@ +#ifndef RZ_X509_H +#define RZ_X509_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Following RFC 5280 + */ + +typedef struct rz_x509_validity_t { + RzASN1String *notBefore; + RzASN1String *notAfter; +} RzX509Validity; + +typedef struct rz_x509_name_t { + ut32 length; + RzASN1String **oids; + RzASN1String **names; +} RzX509Name; + +typedef struct rz_x509_algorithmidentifier_t { + RzASN1String *algorithm; // OBJECT IDENTIFIER + RzASN1Binary *parameters; // OPTIONAL +} RzX509AlgorithmIdentifier; + +typedef struct rz_x509_authoritykeyidentifier_t { + RzASN1Binary *keyIdentifier; + RzX509Name authorityCertIssuer; + RzASN1Binary *authorityCertSerialNumber; +} RzX509AuthorityKeyIdentifier; + +typedef struct rz_x509_subjectpublickeyinfo_t { + RzX509AlgorithmIdentifier algorithm; + // This is a bit string, but it encapsulate mod + pubkey + RzASN1Binary *subjectPublicKey; // BIT STRING + // Extracted module and exponent from pubkey + RzASN1Binary *subjectPublicKeyExponent; + RzASN1Binary *subjectPublicKeyModule; +} RzX509SubjectPublicKeyInfo; + +typedef struct rz_x509_extension_t { + RzASN1String *extnID; // OBJECT IDENTIFIER + bool critical; + RzASN1Binary *extnValue; // OCTET STRING +} RzX509Extension; + +typedef struct rz_x509_extensions_t { + ut32 length; + RzX509Extension **extensions; +} RzX509Extensions; + +typedef struct rz_x509_tbscertificate_t { + ut32 version; // INTEGER + RzASN1String *serialNumber; // INTEGER + RzX509AlgorithmIdentifier signature; + RzX509Name issuer; + RzX509Validity validity; + RzX509Name subject; + RzX509SubjectPublicKeyInfo subjectPublicKeyInfo; + RzASN1Binary *issuerUniqueID; // BIT STRING + RzASN1Binary *subjectUniqueID; // BIT STRING + RzX509Extensions extensions; +} RzX509TBSCertificate; + +typedef struct rz_x509_certificate_t { + RzX509TBSCertificate tbsCertificate; + RzX509AlgorithmIdentifier algorithmIdentifier; + RzASN1Binary *signature; // BIT STRING +} RzX509Certificate; + +// RFC 1422 + +typedef struct rz_x509_crlentry { + RzASN1Binary *userCertificate; // INTEGER ? + RzASN1String *revocationDate; // UTCTime +} RzX509CRLEntry; + +typedef struct rz_x509_certificaterevocationlist { + RzX509AlgorithmIdentifier signature; + RzX509Name issuer; + RzASN1String *lastUpdate; // UTCTime + RzASN1String *nextUpdate; // UTCTime + ut32 length; + RzX509CRLEntry **revokedCertificates; +} RzX509CertificateRevocationList; + +RZ_API RZ_OWN RzX509CertificateRevocationList *rz_x509_crl_parse(RZ_NULLABLE RzASN1Object *object); +RZ_API RZ_OWN RzStructuredData *rz_x509_crl_to_structure(RZ_NULLABLE RzX509CertificateRevocationList *crl); + +RZ_API RZ_OWN RzX509Certificate *rz_x509_certificate_parse(RZ_NULLABLE RzASN1Object *object); +RZ_API RZ_OWN RzX509Certificate *rz_x509_certificate_parse2(RZ_NULLABLE const ut8 *buffer, ut32 length); +RZ_API void rz_x509_certificate_free(RZ_NULLABLE RzX509Certificate *certificate); +RZ_API RZ_OWN RzStructuredData *rz_x509_certificate_to_structure(RZ_NULLABLE RzX509Certificate *certificate); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_X509_H */ diff --git a/dest/include/librz/rz_vector.h b/dest/include/librz/rz_vector.h new file mode 100644 index 00000000000..704595e3367 --- /dev/null +++ b/dest/include/librz/rz_vector.h @@ -0,0 +1,491 @@ +#ifndef RZ_VECTOR_H +#define RZ_VECTOR_H + +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +/* + * RzVector can contain arbitrarily sized elements. + * RzPVector uses RzVector internally and always contains void *s + * + * Thus, for storing pointers it is highly encouraged to always use RzPVector + * as it is specifically made for this purpose and is more consistent with RzList, + * while RzVector can be used as, for example, a flat array of a struct. + * + * Notable differences between RzVector and RzPVector: + * ------------------------------------------------- + * When RzVector expects an element to be inserted, for example in rz_vector_push(..., void *x), + * this void * value is interpreted as a pointer to the actual data for the element. + * => If you use RzVector as a dynamic replacement for (struct SomeStruct)[], you will + * pass a struct SomeStruct * to these functions. + * + * Because RzPVector only handles pointers, the given void * is directly interpreted as the + * actual pointer to be inserted. + * => If you use RzPVector as a dynamic replacement for (SomeType *)[], you will pass + * SomeType * directly to these functions. + * + * The same differentiation goes for the free functions: + * - The element parameter in RzVectorFree is a pointer to the element inside the array. + * - The element parameter in RzPVectorFree is the actual pointer stored in the array. + * + * General Hint: + * ------------- + * remove/pop functions do not reduce the capacity. + * Call rz_(p)vector_shrink explicitly if desired. + */ + +// RzPVectorComparator should return negative, 0, positive to indicate "value < vec_data", "value == vec_data", "value > vec_data". +typedef int (*RzPVectorComparator)(const void *value, const void *vec_data, void *user); +typedef int (*RzVectorComparator)(const void *a, const void *b, void *user); +typedef void (*RzVectorFree)(void *e, void *user); +typedef void (*RzPVectorFree)(void *e); + +typedef struct rz_vector_t { + void *a; + size_t len; + size_t capacity; + size_t elem_size; + RzVectorFree free; + void *free_user; +} RzVector; + +// RzPVector directly wraps RzVector for type safety +typedef struct rz_pvector_t { + RzVector v; +} RzPVector; + +// RzVector + +RZ_API void rz_vector_init(RzVector *vec, size_t elem_size, RzVectorFree free, void *free_user); + +RZ_API RzVector *rz_vector_new(size_t elem_size, RzVectorFree free, void *free_user); + +// clears the vector and calls vec->free on every element if set. +RZ_API void rz_vector_fini(RzVector *vec); + +// frees the vector and calls vec->free on every element if set. +RZ_API void rz_vector_free(RzVector *vec); + +typedef void (*RzVectorItemCpyFunc)(void *, void *); +typedef void (*RzPVectorItemCpyFunc)(void *, void *); + +RZ_API bool rz_vector_clone_intof( + RZ_NONNULL RZ_BORROW RZ_OUT RzVector *dst, + RZ_NONNULL RZ_BORROW RZ_IN const RzVector *src, + RZ_NULLABLE const RzVectorItemCpyFunc item_cpy); +RZ_API RZ_OWN RzVector *rz_vector_clonef( + RZ_NONNULL RZ_BORROW RZ_IN const RzVector *vec, + RZ_NULLABLE const RzVectorItemCpyFunc item_cpy); +RZ_API bool rz_vector_clone_into( + RZ_NONNULL RZ_BORROW RZ_OUT RzVector *dst, + RZ_NONNULL RZ_BORROW RZ_IN const RzVector *src); +RZ_API RZ_OWN RzVector *rz_vector_clone( + RZ_NONNULL RZ_BORROW RZ_IN const RzVector *vec); + +static inline bool rz_vector_empty(RZ_NULLABLE const RzVector *vec) { + return vec ? vec->len == 0 : true; +} + +RZ_API void rz_vector_clear(RzVector *vec); + +// returns the length of the vector +static inline size_t rz_vector_len(RZ_NULLABLE const RzVector *vec) { + return vec ? vec->len : 0; +} + +// returns a pointer to the offset inside the array where the element of the index lies. +static inline void *rz_vector_index_ptr(const RzVector *vec, size_t index) { + rz_return_val_if_fail(vec && index < vec->capacity, NULL); + return (char *)vec->a + vec->elem_size * index; +} + +// returns a pointer to the first element of the vector +static inline void *rz_vector_head(const RzVector *vec) { + rz_return_val_if_fail(vec, NULL); + return (void *)vec->a; +} + +// returns a pointer to the last element of the vector +static inline void *rz_vector_tail(RzVector *vec) { + rz_return_val_if_fail(vec, NULL); + if (vec->len < 1) { + return NULL; + } + return (char *)vec->a + vec->elem_size * (vec->len - 1); +} + +// helper function to assign an element of size vec->elem_size from elem to p. +// elem is a pointer to the actual data to assign! +RZ_API void rz_vector_assign(RzVector *vec, void *p, void *elem); + +// assign the value of size vec->elem_size at elem to vec at the given index. +// elem is a pointer to the actual data to assign! +RZ_API void *rz_vector_assign_at(RzVector *vec, size_t index, void *elem); + +// remove the element at the given index and write the content to into. +// It is the caller's responsibility to free potential resources associated with the element. +RZ_API void rz_vector_remove_at(RzVector *vec, size_t index, void *into); + +/** + * remove all elements in the given range and write the contents to into (must be appropriately large). + * It is the caller's responsibility to free potential resources associated with the elements. + */ +RZ_API void rz_vector_remove_range(RzVector *vec, size_t index, size_t count, void *into); + +// insert the value of size vec->elem_size at x at the given index. +// x is a pointer to the actual data to assign! +RZ_API void *rz_vector_insert(RzVector *vec, size_t index, void *x); + +// insert count values of size vec->elem_size into vec starting at the given index. +RZ_API void *rz_vector_insert_range(RzVector *vec, size_t index, RZ_NULLABLE void *first, size_t count); + +// like rz_vector_remove_at for the last element +RZ_API void rz_vector_pop(RzVector *vec, void *into); + +// like rz_vector_remove_at for the first element +RZ_API void rz_vector_pop_front(RzVector *vec, void *into); + +// like rz_vector_insert for the end of vec +RZ_API void *rz_vector_push(RzVector *vec, void *x); + +// like rz_vector_insert for the beginning of vec +RZ_API void *rz_vector_push_front(RzVector *vec, void *x); + +/** + * \brief Swap two elements of the vector + * \param index_a index of the first element to swap + * \param index_b index of the second element to swap + * \return true if the swap succeeded + **/ +RZ_API bool rz_vector_swap(RzVector *vec, size_t index_a, size_t index_b); + +// make sure the capacity is at least capacity. +RZ_API void *rz_vector_reserve(RzVector *vec, size_t capacity); + +// shrink capacity to len. +RZ_API void *rz_vector_shrink(RzVector *vec); + +/** + * \brief Turn the vector into a fixed-size array. + * This will clear the vector and return an array of its original contents whose + * ownership is transferred to the caller. + * This is useful when RzVector is used for its dynamically growing functionality as an + * intermediate step to generate a fixed-size array in the end. + */ +RZ_API void *rz_vector_flush(RzVector *vec); + +// sort vector +RZ_API void rz_vector_sort(RzVector *vec, RzVectorComparator cmp, bool reverse, void *user); + +/* + * example: + * + * RzVector *v = ...; // + * MyStruct *it; + * rz_vector_foreach (v, it) { + * // Do something with it + * } + */ +#define rz_vector_foreach(vec, it) \ + if (!rz_vector_empty(vec)) \ + for (it = (void *)(vec)->a; (char *)it != (char *)(vec)->a + ((vec)->len * (vec)->elem_size); it = (void *)((char *)it + (vec)->elem_size)) + +#define rz_vector_foreach_prev(vec, it) \ + if (!rz_vector_empty(vec)) \ + for (it = (void *)((char *)(vec)->a + (((vec)->len - 1) * (vec)->elem_size)); (char *)it != (char *)(vec)->a - (vec)->elem_size; it = (void *)((char *)it - (vec)->elem_size)) + +#define rz_vector_enumerate(vec, it, i) \ + if (!rz_vector_empty(vec)) \ + for (it = (void *)(vec)->a, i = 0; i < (vec)->len; it = (void *)((char *)it + (vec)->elem_size), i++) + +/* + * example: + * + * RzVector *v = ...; // contains {(st64)0, (st64)2, (st64)4, (st64)6, (st64)8}; + * size_t l; + * #define CMP(x, y) x - (*(st64 *)y) + * rz_vector_lower_bound (v, 3, l, CMP); + * // l == 2 + */ +#define rz_vector_lower_bound(vec, x, i, cmp) \ + do { \ + size_t h = (vec)->len, m; \ + for (i = 0; i < h;) { \ + m = i + ((h - i) >> 1); \ + if ((cmp(x, ((char *)(vec)->a + (vec)->elem_size * m))) > 0) { \ + i = m + 1; \ + } else { \ + h = m; \ + } \ + } \ + } while (0) + +#define rz_vector_upper_bound(vec, x, i, cmp) \ + do { \ + size_t h = (vec)->len, m; \ + for (i = 0; i < h;) { \ + m = i + ((h - i) >> 1); \ + if ((cmp(x, ((char *)(vec)->a + (vec)->elem_size * m))) < 0) { \ + h = m; \ + } else { \ + i = m + 1; \ + } \ + } \ + } while (0) + +// RzPVector + +RZ_API void rz_pvector_init(RzPVector *vec, RzPVectorFree free); +RZ_API void rz_pvector_fini(RzPVector *vec); + +RZ_API RzPVector *rz_pvector_new(RzPVectorFree free); + +RZ_API RzPVector *rz_pvector_new_with_len(RzPVectorFree free, size_t length); + +// clear the vector and call vec->v.free on every element. +RZ_API void rz_pvector_clear(RzPVector *vec); + +// free the vector and call vec->v.free on every element. +RZ_API void rz_pvector_free(RzPVector *vec); + +/// See rz_vector_clone() for detailed semantics +static inline RzPVector *rz_pvector_clone(RzPVector *vec) { + return (RzPVector *)rz_vector_clone(&vec->v); +} + +static inline RzPVector *rz_pvector_clonef(RzPVector *vec, RzPVectorItemCpyFunc item_cpy) { + return (RzPVector *)rz_vector_clonef(&vec->v, item_cpy); +} + +static inline size_t rz_pvector_len(const RzPVector *vec) { + if (!vec) { + return 0; + } + return vec->v.len; +} + +static inline void *rz_pvector_at(const RzPVector *vec, size_t index) { + rz_return_val_if_fail(vec, NULL); + if (index >= vec->v.len) { + return NULL; + } + return ((void **)vec->v.a)[index]; +} + +static inline void rz_pvector_set(RzPVector *vec, size_t index, void *e) { + rz_return_if_fail(vec && index < vec->v.len); + ((void **)vec->v.a)[index] = e; +} + +static inline bool rz_pvector_empty(const RzPVector *vec) { + return rz_pvector_len(vec) == 0; +} + +// same as rz_pvector_index_ptr(, 0) +static inline void **rz_pvector_data(RzPVector *vec) { + rz_return_val_if_fail(vec, NULL); + return (void **)vec->v.a; +} + +// returns the first element of the vector +static inline void *rz_pvector_head(RzPVector *vec) { + rz_return_val_if_fail(vec, NULL); + if (vec->v.len < 1) { + return NULL; + } + return ((void **)vec->v.a)[0]; +} + +// returns the last element of the vector +static inline void *rz_pvector_tail(RzPVector *vec) { + rz_return_val_if_fail(vec, NULL); + if (vec->v.len < 1) { + return NULL; + } + return ((void **)vec->v.a)[vec->v.len - 1]; +} + +// returns the respective pointer inside the vector if x is found or NULL otherwise. +RZ_API void **rz_pvector_contains(RzPVector *vec, const void *x); + +// find the element in the vec based on cmparator +RZ_API RZ_BORROW void **rz_pvector_find(RZ_NONNULL const RzPVector *vec, RZ_NONNULL const void *element, RZ_NONNULL RzPVectorComparator cmp, void *user); + +// find the element index in the vec based on cmparator +RZ_API size_t rz_pvector_find_index(RZ_NONNULL const RzPVector *vec, RZ_NONNULL const void *element, RZ_NONNULL RzPVectorComparator cmp, void *user); + +// join two pvector into one, pvec1 should free the joined element in pvec2 +RZ_API bool rz_pvector_join(RZ_NONNULL RzPVector *pvec1, RZ_NONNULL RzPVector *pvec2); + +RZ_API void *rz_pvector_assign_at(RZ_BORROW RZ_NONNULL RzPVector *vec, size_t index, RZ_OWN RZ_NONNULL void *ptr); + +// removes and returns the pointer at the given index. Does not call free. +RZ_API void *rz_pvector_remove_at(RzPVector *vec, size_t index); + +// removes the element x, if present. Does not call free. +RZ_API void rz_pvector_remove_data(RzPVector *vec, void *x); + +// like rz_vector_insert, but the pointer x is the actual data to be inserted. +static inline void **rz_pvector_insert(RzPVector *vec, size_t index, void *x) { + return (void **)rz_vector_insert(&vec->v, index, &x); +} + +// like rz_vector_insert_range. +static inline void **rz_pvector_insert_range(RzPVector *vec, size_t index, void **first, size_t count) { + return (void **)rz_vector_insert_range(&vec->v, index, first, count); +} + +// like rz_vector_pop, but returns the pointer directly. +RZ_API void *rz_pvector_pop(RzPVector *vec); + +// like rz_vector_pop_front, but returns the pointer directly. +RZ_API void *rz_pvector_pop_front(RzPVector *vec); + +// like rz_vector_push, but the pointer x is the actual data to be inserted. +static inline void **rz_pvector_push(RzPVector *vec, void *x) { + return (void **)rz_vector_push(&vec->v, &x); +} + +// like rz_vector_push_front, but the pointer x is the actual data to be inserted. +static inline void **rz_pvector_push_front(RzPVector *vec, void *x) { + return (void **)rz_vector_push_front(&vec->v, &x); +} + +// sort vec using quick sort. +RZ_API void rz_pvector_sort(RzPVector *vec, RzPVectorComparator cmp, void *user); + +// Returns a new RzPVector which contains only unique values +RZ_API RZ_OWN RzPVector *rz_pvector_uniq(RZ_NONNULL const RzPVector *vec, RZ_NONNULL RzPVectorComparator cmp, void *user); + +static inline void **rz_pvector_reserve(RzPVector *vec, size_t capacity) { + return (void **)rz_vector_reserve(&vec->v, capacity); +} + +static inline void **rz_pvector_shrink(RzPVector *vec) { + return (void **)rz_vector_shrink(&vec->v); +} + +static inline void **rz_pvector_flush(RzPVector *vec) { + return (void **)rz_vector_flush(&vec->v); +} + +/* + * example: + * + * RzPVector *v = ...; + * void **it; + * rz_pvector_foreach (v, it) { + * void *p = *it; + * // Do something with p + * } + */ +#define rz_pvector_foreach(vec, it) \ + if (!rz_pvector_empty(vec)) \ + for (it = (void **)(vec)->v.a; (vec)->v.len && it != (void **)(vec)->v.a + (vec)->v.len; it++) + +// like rz_pvector_foreach() but inverse +#define rz_pvector_foreach_prev(vec, it) \ + if (!rz_pvector_empty(vec)) \ + for (it = ((vec)->v.len == 0 ? NULL : (void **)(vec)->v.a + (vec)->v.len - 1); it && it != (void **)(vec)->v.a - 1; it--) + +/** + * \brief Like rz_pvector_foreach() but with index + */ +#define rz_pvector_enumerate(vec, it, idx) \ + if (!rz_pvector_empty(vec)) \ + for (it = (void **)(vec)->v.a, idx = 0; idx < (vec)->v.len; it++, idx++) + +/* + * \brief Find the index of the least element greater than or equal to the lower bound x using binary search + * example: + * + * st64 a[] = { 0, 2, 4, 6, 8 }; + * size_t index; + * #define CMP(x, y) x - y + * rz_pvector_lower_bound (v, 3, index, CMP); + * // index == 2 (contains value 4) + */ +#define rz_array_lower_bound(array, len, x, i, cmp) \ + do { \ + size_t h = len, m; \ + for (i = 0; i < h;) { \ + m = i + ((h - i) >> 1); \ + if (cmp((x), ((array)[m])) > 0) { \ + i = m + 1; \ + } else { \ + h = m; \ + } \ + } \ + } while (0) + +/* + * \brief Find the index of the least element greater than the upper bound x using binary search + * example: + * + * st64 a[] = { 0, 2, 4, 6, 8 }; + * size_t index; + * #define CMP(x, y) x - y + * rz_pvector_lower_bound (v, 2, index, CMP); + * // index == 2 (contains value 4) + */ +#define rz_array_upper_bound(array, len, x, i, cmp) \ + do { \ + size_t h = len, m; \ + for (i = 0; i < h;) { \ + m = i + ((h - i) >> 1); \ + if (cmp((x), ((array)[m])) < 0) { \ + h = m; \ + } else { \ + i = m + 1; \ + } \ + } \ + } while (0) + +/** + * \brief Find an element elem in the \p array, + * lying within \p start and \p stop index such that \p cmp(x, elem) == 0 + * The index of the element elem is stored in \p itr + * If \p itr == \p stop, then no such element was found + */ +#define rz_array_find(array, x, itr, start, stop, cmp) \ + do { \ + for (itr = start; itr < stop; itr++) { \ + if (cmp((array[itr]), x) == 0) { \ + break; \ + } \ + } \ + return itr; \ + } while (0) + +/* + * example: + * + * RzPVector *v = ...; // contains {(void*)0, (void*)2, (void*)4, (void*)6, (void*)8}; + * size_t index; + * #define CMP(x, y) x - y + * rz_pvector_lower_bound (v, (void *)2, index, CMP); + * // index == 1 + */ +#define rz_pvector_lower_bound(vec, x, i, cmp) \ + rz_array_lower_bound((void **)(vec)->v.a, (vec)->v.len, x, i, cmp) + +/* + * example: + * + * RzPVector *v = ...; // contains {(void*)0, (void*)2, (void*)4, (void*)6, (void*)8}; + * size_t index; + * #define CMP(x, y) x - y + * rz_pvector_upper_bound (v, (void *)2, index, CMP); + * // index == 2 + */ +#define rz_pvector_upper_bound(vec, x, i, cmp) \ + rz_array_upper_bound((void **)(vec)->v.a, (vec)->v.len, x, i, cmp) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/rz_windows.h b/dest/include/librz/rz_windows.h new file mode 100644 index 00000000000..0d90d38d145 --- /dev/null +++ b/dest/include/librz/rz_windows.h @@ -0,0 +1,74 @@ +// SPDX-FileCopyrightText: 2022 GustavoLCR +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_WINDOWS_H +#define RZ_WINDOWS_H +/* + * This file is to be included whenever access to + * Windows APIs and type definitions is necessary. + * You should avoid including this file in often used + * header files as it will slow down compilation. + */ +#if __WINDOWS__ || _WIN32 || _MSC_VER +#include +#ifdef NTDDI_WIN10_TH2 +/* Avoid using Developer Preview and default to Windows 10/Windows Server 2016 */ +#undef _WIN32_WINNT +#undef NTDDI_VERSION +#define _WIN32_WINNT _WIN32_WINNT_WIN10 +#define NTDDI_VERSION NTDDI_WIN10 +#endif +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#define NOGDICAPMASKS // CC_*, LC_*, PC_*, CP_*, TC_*, RC_ +#define NOWINMESSAGES // WM_ *, EM_ *, LB_ *, CB_ * +#define NOWINSTYLES // WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_* +#define NOSYSMETRICS // SM_* +#define NOMENUS // MF_* +#define NOICONS // IDI_* +#define NOKEYSTATES // MK_* +#define NOSYSCOMMANDS // SC_* +#define NORASTEROPS // Binary and Tertiary raster ops +#define NOSHOWWINDOW // SW_* +#define OEMRESOURCE // OEM Resource values +#define NOATOM // Atom Manager routines +#define NOCOLOR // Screen colors +#define NOCTLMGR // Control and Dialog routines +#define NODRAWTEXT // DrawText() and DT_* +#define NOGDI // All GDI defines and routines +#define NOKERNEL // All KERNEL defines and routines +#define NOMB // MB_* and MessageBox() +#define NOMEMMGR // GMEM_*, LMEM_*, GHND, LHND, associated routines +#define NOMETAFILE // typedef METAFILEPICT +#define NOMINMAX // Macros min(a,b) and max(a,b) +#define NOOPENFILE // OpenFile(), OemToAnsi, AnsiToOem, and OF_* +#define NOSCROLL // SB_* and scrolling routines +#define NOSOUND // Sound driver routines +#define NOSYSPARAMSINFO // System Parameter information definitions +#define NOTEXTMETRIC // typedef TEXTMETRIC and associated routines +#define NOWH // SetWindowsHook and WH_* +#define NOCOMM // COMM driver routines +#define NOKANJI // Kanji support stuff. +#define NOHELP // Help engine interface. +#define NOPROFILER // Profiler interface. +#define NODEFERWINDOWPOS // DeferWindowPos routines +#define NOMCX // Modem Configuration Extensions +#define NOIME // Input Method Manager +/* Includes windows.h */ +#include +#include +typedef int socklen_t; +#undef USE_SOCKETS +#define __addr_t_defined +#include +/* Windows <=8 compatibility */ +#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING +#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0 +#endif +#ifndef ENABLE_VIRTUAL_TERMINAL_INPUT +#define ENABLE_VIRTUAL_TERMINAL_INPUT 0 +#endif +#include +#endif +#endif diff --git a/dest/include/librz/rz_windows_heap.h b/dest/include/librz/rz_windows_heap.h new file mode 100644 index 00000000000..1fccf607452 --- /dev/null +++ b/dest/include/librz/rz_windows_heap.h @@ -0,0 +1,30 @@ +#ifndef RZ_WINDOWS_HEAP_H +#define RZ_WINDOWS_HEAP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rz_heap_block { + ut64 userAddress; + ut64 headerAddress; + ut64 granularity; + ut64 unusedBytes; + char type[100]; + ut64 size; +} RzWindowsHeapBlock; + +typedef struct rz_heap_info { + ut64 base; + ut64 blockCount; + ut64 allocated; + ut64 committed; +} RzWindowsHeapInfo; + +#ifdef __cplusplus +} +#endif + +#endif // diff --git a/dest/include/librz/sdb/buffer.h b/dest/include/librz/sdb/buffer.h new file mode 100644 index 00000000000..62d79329a05 --- /dev/null +++ b/dest/include/librz/sdb/buffer.h @@ -0,0 +1,38 @@ +// SPDX-FileCopyrightText: unknown +// SPDX-License-Identifier: CC-PDDC + +#ifndef BUFFER_H +#define BUFFER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The callback which writes to the file descriptor. + * + * Takes the parameters \c fd, \c buf, \c len in this order, and + * returns the number of bytes successfully written. + */ +typedef int (*BufferOp)(int, const char *, int); + +typedef struct buffer { + char *x; ///< The underlying memory buffer. + unsigned int p; ///< Anything between 0 and p is buffered; not yet written out. + unsigned int n; ///< The total size of the memory buffer. + int fd; ///< The file descriptor to write to when the buffer is full. + BufferOp op; ///< The callback which writes to the file descriptor. +} buffer; + +extern void buffer_init(buffer *, BufferOp, int, char *, unsigned int); +extern int buffer_flush(buffer *); +extern int buffer_putalign(buffer *, const char *, unsigned int); +extern int buffer_putflush(buffer *, const char *, unsigned int); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/sdb/cdb.h b/dest/include/librz/sdb/cdb.h new file mode 100644 index 00000000000..ca1a48b3441 --- /dev/null +++ b/dest/include/librz/sdb/cdb.h @@ -0,0 +1,69 @@ +// SPDX-FileCopyrightText: D. J. Bernstein +// SPDX-License-Identifier: CC-PDDC + +/** + * \internal + * \file + * \brief Reading and operating on a \ref cdb structure. + * + * The \ref cdb structure is an associative array mapping strings to + * strings. Originally written by D. J. Bernstein, see + * for a description of the binary format. + */ + +#ifndef CDB_H +#define CDB_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \def KVLSZ + * \brief The size in bytes of the key-value lengths combined. + */ + +#define KVLSZ 4 +#define CDB_MAX_KEY 0xff +#define CDB_MAX_VALUE 0xffffff + +#define CDB_HASHSTART 5381 + +/** \internal + * \brief The \ref cdb structure. + * + * An associative array of strings to strings based on cdb by + * D. J. Bernstein, see . + */ +struct cdb { + char *map; ///< Maps the file in memory. NULL if no map is available. + int fd; ///< The file descriptor from which the cdb structure is read. + ut32 size; ///< Initialized if map is nonzero. + ut32 loop; ///< The search state, number of hash slots searched in a given key. + ut32 khash; ///< Hash of key. Initialized if loop is nonzero. + ut32 kpos; ///< Key position. Initialized if loop is nonzero. + ut32 hpos; ///< Current hash table position. Initialized if loop is nonzero. + ut32 hslots; ///< Number of slots of current hash table. Initialized if loop is nonzero. + ut32 dpos; ///< Data position. Initialized if cdb_findnext() returns 1. + ut32 dlen; ///< Data length. Initialized if cdb_findnext() returns 1. +}; + +/* TODO Remove this! */ +bool cdb_getkvlen(struct cdb *db, ut32 *klen, ut32 *vlen, ut32 pos); +void cdb_free(struct cdb *); +bool cdb_init(struct cdb *, int fd); +void cdb_findstart(struct cdb *); +bool cdb_read(struct cdb *, char *, unsigned int, ut32); +int cdb_findnext(struct cdb *, ut32 u, const char *, ut32); + +#define cdb_datapos(c) ((c)->dpos) +#define cdb_datalen(c) ((c)->dlen) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/sdb/cdb_make.h b/dest/include/librz/sdb/cdb_make.h new file mode 100644 index 00000000000..48273ae38bc --- /dev/null +++ b/dest/include/librz/sdb/cdb_make.h @@ -0,0 +1,52 @@ +// SPDX-FileCopyrightText: D. J. Bernstein +// SPDX-License-Identifier: CC-PDDC + +#ifndef CDB_MAKE_H +#define CDB_MAKE_H + +#include "buffer.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CDB_HPLIST 1000 + +struct cdb_hp { + ut32 h; + ut32 p; +}; + +struct cdb_hplist { + struct cdb_hp hp[CDB_HPLIST]; + struct cdb_hplist *next; + int num; +}; + +struct cdb_make { + char bspace[8192]; + char final[1024]; + ut32 count[256]; + ut32 start[256]; + struct cdb_hplist *head; + struct cdb_hp *split; /* includes space for hash */ + struct cdb_hp *hash; + ut32 numentries; + ut32 memsize; + buffer b; + ut32 pos; + int fd; +}; + +extern int cdb_make_start(struct cdb_make *, int); +extern int cdb_make_addbegin(struct cdb_make *, unsigned int, unsigned int); +extern int cdb_make_addend(struct cdb_make *, unsigned int, unsigned int, ut32); +extern int cdb_make_add(struct cdb_make *, const char *, unsigned int, const char *, unsigned int); +extern int cdb_make_finish(struct cdb_make *); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/sdb/sdb.h b/dest/include/librz/sdb/sdb.h new file mode 100644 index 00000000000..a46675542d6 --- /dev/null +++ b/dest/include/librz/sdb/sdb.h @@ -0,0 +1,331 @@ +// SPDX-FileCopyrightText: pancake +// SPDX-License-Identifier: MIT + +#ifndef SDB_H +#define SDB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include "sdbht.h" +#include "cdb.h" +#include "cdb_make.h" + +/* Key value sizes */ +#define SDB_CDB_MIN_VALUE 1 +#define SDB_CDB_MAX_VALUE CDB_MAX_VALUE +#define SDB_CDB_MIN_KEY 2 +#define SDB_CDB_MAX_KEY CDB_MAX_KEY + +#if __WINDOWS__ && !__CYGWIN__ +#include +#include +#include +#include +#include +#define ftruncate _chsize +#ifndef _MSC_VER +extern __attribute__((dllimport)) void *__cdecl _aligned_malloc(size_t, size_t); +extern __attribute__((dllimport)) void __cdecl _aligned_free(void *memblock); +extern char *strdup(const char *); +#else +#include +#include // for _aligned_malloc +#endif + +// #define SDB_MODE 0 +#define SDB_MODE _S_IWRITE | _S_IREAD +#else +#define SDB_MODE 0644 +// #define SDB_MODE 0600 +#endif + +// #define SDB_RS '\x1e' +#define SDB_RS ',' +#define SDB_SS "," +#define SDB_MAX_PATH 256 +#define SDB_NUM_BASE 16 +#define SDB_NUM_BUFSZ 64 + +#define SDB_OPTION_NONE 0 +#define SDB_OPTION_ALL 0xff +#define SDB_OPTION_SYNC (1 << 0) +#define SDB_OPTION_NOSTAMP (1 << 1) +#define SDB_OPTION_FS (1 << 2) + +#define SDB_LIST_UNSORTED 0 +#define SDB_LIST_SORTED 1 + +typedef bool (*VALUE_EQ_F)(const char *, const char *); + +typedef struct sdb_t { + char *dir; // path+name + char *path; + char *name; + int fd; + int refs; // reference counter + int lock; + struct cdb db; + struct cdb_make m; + HtSS *ht; + ut32 eod; + ut32 pos; + ut32 dump_end_pos; ///< Used in sdb_dump_next() + int fdump; + char *ndump; + int options; + int ns_lock; // TODO: merge into options? + RzList /**/ *ns; + ut32 depth; +} Sdb; + +typedef struct sdb_ns_t { + char *name; + ut32 hash; + Sdb *sdb; +} SdbNs; + +RZ_API RZ_OWN Sdb *sdb_new0(void); +RZ_API RZ_OWN Sdb *sdb_new(const char *path, const char *file, int lock); + +RZ_API int sdb_open(Sdb *s, const char *file); +RZ_API void sdb_close(Sdb *s); + +RZ_API void sdb_config(Sdb *s, int options); +RZ_API bool sdb_free(Sdb *s); +RZ_API void sdb_file(Sdb *s, const char *dir); +RZ_API bool sdb_merge(Sdb *d, Sdb *s); +RZ_API int sdb_count(Sdb *s); +RZ_API void sdb_reset(Sdb *s); +RZ_API void sdb_setup(Sdb *s, int options); +RZ_API void sdb_drain(Sdb *, Sdb *); + +// Copy everything, including namespaces, from src to dst +RZ_API void sdb_copy(Sdb *src, Sdb *dst); + +RZ_API bool sdb_stats(Sdb *s, ut32 *disk, ut32 *mem); + +typedef bool (*SdbForeachCallback)(void *user, const SdbKv *kv); +RZ_API bool sdb_foreach(RZ_NONNULL Sdb *s, RZ_NONNULL SdbForeachCallback cb, RZ_NULLABLE void *user); +RZ_API RZ_OWN RzPVector /**/ *sdb_get_items(RZ_NONNULL Sdb *s, bool sorted); +RZ_API RZ_OWN RzPVector /**/ *sdb_get_items_filter(RZ_NONNULL Sdb *s, RZ_NONNULL SdbForeachCallback filter, RZ_NULLABLE void *user, bool sorted); +RZ_API RZ_OWN RzPVector /**/ *sdb_get_items_match(RZ_NONNULL Sdb *s, RZ_NONNULL const char *expr, bool sorted); + +RZ_API int sdb_query(Sdb *s, const char *cmd); +RZ_API int sdb_queryf(Sdb *s, const char *fmt, ...); +RZ_API int sdb_query_lines(Sdb *s, const char *cmd); +RZ_API char *sdb_querys(Sdb *s, char *buf, size_t len, const char *cmd); +RZ_API char *sdb_querysf(Sdb *s, char *buf, size_t buflen, const char *fmt, ...); +RZ_API int sdb_query_file(Sdb *s, const char *file); +RZ_API bool sdb_exists(Sdb *, const char *key); +RZ_API bool sdb_remove(Sdb *, const char *key); +RZ_API int sdb_unset(Sdb *, const char *key); +RZ_API int sdb_unset_like(Sdb *s, const char *k); + +// diffing +typedef struct sdb_diff_t { + const RzList /**/ *path; + const char *k; + const char *v; // if null, k is a namespace + bool add; +} SdbDiff; + +// Format diff in a readable form into str. str, size and return are like in snprintf. +RZ_API int sdb_diff_format(char *str, int size, const SdbDiff *diff); + +typedef void (*SdbDiffCallback)(const SdbDiff *diff, void *user); + +// Returns true iff the contents of a and b are equal including contained namespaces +// If cb is non-null, it will be called subsequently with differences. +RZ_API bool sdb_diff(Sdb *a, Sdb *b, SdbDiffCallback cb, void *cb_user); + +RZ_API bool sdb_diff_eq(Sdb *a, Sdb *b, VALUE_EQ_F eq, SdbDiffCallback cb, void *cb_user); + +// Gets a pointer to the value associated with `key`. +RZ_API char *sdb_get(Sdb *, const char *key); + +// Gets a pointer to the value associated with `key` and returns in `vlen` the +// length of the value string. +RZ_API char *sdb_get_len(Sdb *, const char *key, int *vlen); + +// Gets a const pointer to the value associated with `key` +RZ_API const char *sdb_const_get(Sdb *, const char *key); + +// Gets a const pointer to the value associated with `key` and returns in +// `vlen` the length of the value string. +RZ_API const char *sdb_const_get_len(Sdb *s, const char *key, int *vlen); +RZ_API bool sdb_set(Sdb *, const char *key, const char *data); +RZ_API bool sdb_set_owned(Sdb *s, const char *key, char *val); +RZ_API bool sdb_concat(Sdb *s, const char *key, const char *value); +RZ_API bool sdb_uncat(Sdb *s, const char *key, const char *value); +RZ_API bool sdb_add(Sdb *s, const char *key, const char *val); +RZ_API bool sdb_sync(Sdb *); +RZ_API void sdbkv_free(RZ_NULLABLE SdbKv *kv); + +/* num.c */ +RZ_API bool sdb_num_exists(Sdb *, const char *key); +RZ_API int sdb_num_base(const char *s); +RZ_API bool sdb_num_set(Sdb *s, const char *key, ut64 v); +RZ_API ut64 sdb_num_get(Sdb *s, const char *key); +RZ_API bool sdb_num_add(Sdb *s, const char *key, ut64 v); +RZ_API ut64 sdb_num_inc(Sdb *s, const char *key, ut64 n); +RZ_API ut64 sdb_num_dec(Sdb *s, const char *key, ut64 n); +RZ_API int sdb_num_min(Sdb *s, const char *key, ut64 v); +RZ_API int sdb_num_max(Sdb *s, const char *key, ut64 v); + +/* create db */ +RZ_API bool sdb_disk_create(Sdb *s); +RZ_API bool sdb_disk_insert(Sdb *s, const char *key, const char *val); +RZ_API bool sdb_disk_finish(Sdb *s); +RZ_API bool sdb_disk_unlink(Sdb *s); + +/* plaintext sdb files */ +RZ_API bool sdb_text_save_fd(Sdb *s, int fd, bool sort); +RZ_API bool sdb_text_save(Sdb *s, const char *file, bool sort); +RZ_API bool sdb_text_load_buf(Sdb *s, char *buf, size_t sz); +RZ_API bool sdb_text_load(Sdb *s, const char *file); + +/* iterate */ +RZ_API void sdb_dump_begin(RZ_NONNULL Sdb *s); +RZ_API bool sdb_dump_next(RZ_NONNULL Sdb *s, RZ_OUT RZ_NONNULL SdbKv *kv); + +/* numeric */ +RZ_API char *sdb_itoa(ut64 n, char *s, int base); +RZ_API ut64 sdb_atoi(const char *s); +RZ_API const char *sdb_itoca(ut64 n); + +/* locking */ +RZ_API bool sdb_lock(const char *s); +RZ_API RZ_OWN char *sdb_lock_file(const char *f); +RZ_API void sdb_unlock(const char *s); +RZ_API bool sdb_unlink(Sdb *s); +RZ_API int sdb_lock_wait(RZ_UNUSED const char *s); + +/* expiration */ +RZ_API ut64 sdb_now(void); +RZ_API ut64 sdb_unow(void); +RZ_API ut32 sdb_hash(const char *key); +RZ_API ut32 sdb_hash_len(const char *key, ut32 *len); +RZ_API ut8 sdb_hash_byte(const char *s); + +// namespace +RZ_API Sdb *sdb_ns(Sdb *s, const char *name, int create); +RZ_API Sdb *sdb_ns_path(Sdb *s, const char *path, int create); +RZ_API void sdb_ns_init(Sdb *s); +RZ_API void sdb_ns_free_all(Sdb *s); +RZ_API void sdb_ns_lock(Sdb *s, int lock, int depth); +RZ_API void sdb_ns_sync(Sdb *s); +RZ_API int sdb_ns_set(Sdb *s, const char *name, Sdb *r); +RZ_API bool sdb_ns_unset(Sdb *s, const char *name, Sdb *r); + +// array +RZ_API bool sdb_array_contains(Sdb *s, const char *key, const char *val); +RZ_API bool sdb_array_contains_num(Sdb *s, const char *key, ut64 val); +RZ_API int sdb_array_indexof(Sdb *s, const char *key, const char *val); +RZ_API bool sdb_array_set(Sdb *s, const char *key, int idx, const char *val); +RZ_API bool sdb_array_set_num(Sdb *s, const char *key, int idx, ut64 val); +RZ_API bool sdb_array_append(Sdb *s, const char *key, const char *val); +RZ_API bool sdb_array_append_num(Sdb *s, const char *key, ut64 val); +RZ_API bool sdb_array_prepend(Sdb *s, const char *key, const char *val); +RZ_API bool sdb_array_prepend_num(Sdb *s, const char *key, ut64 val); +RZ_API char *sdb_array_get(Sdb *s, const char *key, int idx); +RZ_API bool sdb_array_get_num(RZ_NONNULL RZ_BORROW Sdb *s, RZ_NONNULL const char *key, int idx, RZ_OUT RZ_NONNULL ut64 *out_number); +RZ_API int sdb_array_get_idx(Sdb *s, const char *key, const char *val); // agetv +RZ_API bool sdb_array_insert(Sdb *s, const char *key, int idx, const char *val); +RZ_API int sdb_array_insert_num(Sdb *s, const char *key, int idx, ut64 val); +RZ_API int sdb_array_unset(Sdb *s, const char *key, int n); // leaves empty bucket +RZ_API int sdb_array_delete(Sdb *s, const char *key, int n); +RZ_API void sdb_array_sort(Sdb *s, const char *key); +RZ_API void sdb_array_sort_num(Sdb *s, const char *key); +// set + +// Adds string `val` at the end of array `key`. +RZ_API bool sdb_array_add(Sdb *s, const char *key, const char *val); + +// Adds number `val` at the end of array `key`. +RZ_API bool sdb_array_add_num(Sdb *s, const char *key, ut64 val); + +// Adds string `val` in the sorted array `key`. +RZ_API int sdb_array_add_sorted(Sdb *s, const char *key, const char *val); + +// Adds number `val` in the sorted array `key`. +RZ_API bool sdb_array_add_sorted_num(Sdb *s, const char *key, ut64 val); + +// Removes the string `val` from the array `key`. +RZ_API int sdb_array_remove(Sdb *s, const char *key, const char *val); + +// Removes the number `val` from the array `key`. +RZ_API int sdb_array_remove_num(Sdb *s, const char *key, ut64 val); + +// helpers +RZ_API char *sdb_anext(char *str, char **next); +RZ_API const char *sdb_const_anext(const char *str); +RZ_API int sdb_alen(const char *str); +RZ_API int sdb_alen_ignore_empty(const char *str); +RZ_API int sdb_array_size(Sdb *s, const char *key); +RZ_API int sdb_array_length(Sdb *s, const char *key); + +int sdb_array_list(Sdb *s, const char *key); + +// Adds the string `val` to the start of array `key`. +RZ_API bool sdb_array_push(Sdb *s, const char *key, const char *val); + +// Returns the string at the start of array `key` or +// NULL if there are no elements. +RZ_API char *sdb_array_pop(Sdb *s, const char *key); + +// Adds the number `val` to the start of array `key`. +RZ_API int sdb_array_push_num(Sdb *s, const char *key, ut64 num); + +// Returns the number at the start of array `key`. +RZ_API ut64 sdb_array_pop_num(Sdb *s, const char *key); + +RZ_API char *sdb_array_pop_head(Sdb *s, const char *key); +RZ_API char *sdb_array_pop_tail(Sdb *s, const char *key); + +/* Util.c */ +RZ_API int sdb_isnum(const char *s); +RZ_API bool sdb_isempty(Sdb *s); + +RZ_API const char *sdb_type(const char *k); +RZ_API bool sdb_match(const char *str, const char *glob); +RZ_API bool sdb_bool_set(Sdb *db, const char *str, bool v); +RZ_API bool sdb_bool_get(Sdb *db, const char *str); + +// base64 +RZ_API ut8 *sdb_decode(const char *in, int *len); +RZ_API char *sdb_encode(const ut8 *bin, int len); +RZ_API void sdb_encode_raw(char *bout, const ut8 *bin, int len); +RZ_API int sdb_decode_raw(ut8 *bout, const char *bin, int len); + +// binfmt +RZ_API char *sdb_fmt_tostr(void *stru, const char *fmt); +RZ_API char **sdb_fmt_array(const char *list); +RZ_API ut64 *sdb_fmt_array_num(const char *list); + +// raw array helpers +RZ_API char *sdb_array_compact(char *p); +RZ_API char *sdb_aslice(char *out, int from, int to); +#define sdb_aforeach(x, y) \ + { \ + char *next; \ + if (y) \ + for (x = y;;) { \ + x = sdb_anext(x, &next); +#define sdb_aforeach_next(x) \ + if (!next) \ + break; \ + *(next - 1) = ','; \ + x = next; \ + } \ + } + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dest/include/librz/sdb/sdbht.h b/dest/include/librz/sdb/sdbht.h new file mode 100644 index 00000000000..b22f67967d2 --- /dev/null +++ b/dest/include/librz/sdb/sdbht.h @@ -0,0 +1,62 @@ +// SPDX-FileCopyrightText: pancake +// SPDX-License-Identifier: MIT + +#ifndef __SDB_HT_H +#define __SDB_HT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** keyvalue pair **/ +typedef struct sdb_kv { + // sub of HtSSKv so we can cast safely + HtSSKv base; +} SdbKv; + +static inline const char *sdbkv_key(const SdbKv *kv) { + return kv->base.key; +} + +static inline const char *sdbkv_value(const SdbKv *kv) { + return kv->base.value; +} + +static inline ut32 sdbkv_key_len(const SdbKv *kv) { + return kv->base.key_len; +} + +static inline ut32 sdbkv_value_len(const SdbKv *kv) { + return kv->base.value_len; +} + +RZ_API SdbKv *sdbkv_new2(const char *k, int kl, const char *v, int vl); +RZ_API SdbKv *sdbkv_new(const char *k, const char *v); +extern RZ_API void sdbkv_free(RZ_NULLABLE SdbKv *kv); +RZ_API RZ_OWN char *sdbkv_dup_value(RZ_NONNULL const SdbKv *kv); + +extern RZ_API ut32 sdb_hash(const char *key); + +RZ_API HtSS *sdb_ht_new(void); +// Destroy a hashtable and all of its entries. +RZ_API void sdb_ht_free(HtSS *ht); +// Insert a new Key-Value pair into the hashtable. If the key already exists, returns false. +RZ_API bool sdb_ht_insert(HtSS *ht, const char *key, const char *value); +// Insert a new Key-Value pair into the hashtable, or updates the value if the key already exists. +RZ_API bool sdb_ht_insert_kvp(HtSS *ht, SdbKv *kvp, bool update); +// Insert a new Key-Value pair into the hashtable, or updates the value if the key already exists. +RZ_API bool sdb_ht_update(HtSS *ht, const char *key, const char *value); +// Delete a key from the hashtable. +RZ_API bool sdb_ht_delete(HtSS *ht, const char *key); +// Find the value corresponding to the matching key. +RZ_API char *sdb_ht_find(HtSS *ht, const char *key, bool *found); +// Find the KeyValuePair corresponding to the matching key. +RZ_API SdbKv *sdb_ht_find_kvp(HtSS *ht, const char *key, bool *found); + +#ifdef __cplusplus +} +#endif + +#endif // __SDB_HT_H diff --git a/dest/include/librz/sflib/common/sfsocketcall.h b/dest/include/librz/sflib/common/sfsocketcall.h new file mode 100644 index 00000000000..567f85b21f1 --- /dev/null +++ b/dest/include/librz/sflib/common/sfsocketcall.h @@ -0,0 +1,130 @@ +/* + * sfsocketcall.h -- linux socket implementation + * see http://www.secdev.org/projects/shellforge.html + * for more informations + * + * Copyright (C) 2003 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +/* $Id$ */ + +#ifndef SFSOCKETCALL_H +#define SFSOCKETCALL_H + +int socketcall(int call, unsigned long *args); + +#define SYS_socket 1 /* sys_socket(2) */ +#define SYS_bind 2 /* sys_bind(2) */ +#define SYS_connect 3 /* sys_connect(2) */ +#define SYS_listen 4 /* sys_listen(2) */ +#define SYS_accept 5 /* sys_accept(2) */ +#define SYS_getsockname 6 /* sys_getsockname(2) */ +#define SYS_getpeername 7 /* sys_getpeername(2) */ +#define SYS_socketpair 8 /* sys_socketpair(2) */ +#define SYS_send 9 /* sys_send(2) */ +#define SYS_recv 10 /* sys_recv(2) */ +#define SYS_sendto 11 /* sys_sendto(2) */ +#define SYS_recvfrom 12 /* sys_recvfrom(2) */ +#define SYS_shutdown 13 /* sys_shutdown(2) */ +#define SYS_setsockopt 14 /* sys_setsockopt(2) */ +#define SYS_getsockopt 15 /* sys_getsockopt(2) */ +#define SYS_sendmsg 16 /* sys_sendmsg(2) */ +#define SYS_recvmsg 17 /* sys_recvmsg(2) */ + + +#define __sys_socketcall0(type, name) \ +type name(void) \ +{ \ + return socketcall(SYS_##name, 0); \ +} + +#define __sys_socketcall1(type, name, type0, arg0) \ +type name(type0 arg0) \ +{ \ + unsigned long arr[1]; \ + arr[0] = (long)arg0; \ + return socketcall(SYS_##name, arr); \ +} + +#define __sys_socketcall2(type, name, type0,arg0, type1,arg1) \ +type name(type0 arg0, type1 arg1) \ +{ \ + unsigned long arr[2]; \ + arr[0] = (long)arg0; \ + arr[1] = (long)arg1; \ + return socketcall(SYS_##name, arr); \ +} + +#define __sys_socketcall3(type, name, type0,arg0, type1,arg1, type2,arg2) \ +type name(type0 arg0, type1 arg1, type2 arg2) \ +{ \ + unsigned long arr[3]; \ + arr[0] = (long)arg0; \ + arr[1] = (long)arg1; \ + arr[2] = (long)arg2; \ + return socketcall(SYS_##name, arr); \ +} + +#define __sys_socketcall4(type, name, type0,arg0, type1,arg1, type2,arg2, type3,arg3) \ +type name(type0 arg0, type1 arg1, type2 arg2, type3 arg3) \ +{ \ + unsigned long arr[4]; \ + arr[0] = (long)arg0; \ + arr[1] = (long)arg1; \ + arr[2] = (long)arg2; \ + arr[3] = (long)arg3; \ + return socketcall(SYS_##name, arr); \ +} + +#define __sys_socketcall5(type, name, type0,arg0, type1,arg1, type2,arg2, type3,arg3, type4,arg4) \ +type name(type0 arg0, type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ +{ \ + unsigned long arr[5]; \ + arr[0] = (long)arg0; \ + arr[1] = (long)arg1; \ + arr[2] = (long)arg2; \ + arr[3] = (long)arg3; \ + arr[4] = (long)arg4; \ + return socketcall(SYS_##name, arr); \ +} + +#define __sys_socketcall6(type, name, type0,arg0, type1,arg1, type2,arg2, type3,arg3, type4,arg4, type5,arg5) \ +type name(type0 arg0, type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ +{ \ + unsigned long arr[6]; \ + arr[0] = (long)arg0; \ + arr[1] = (long)arg1; \ + arr[2] = (long)arg2; \ + arr[3] = (long)arg3; \ + arr[4] = (long)arg4; \ + arr[5] = (long)arg5; \ + return socketcall(SYS_##name, arr); \ +} + +inline static __sys_socketcall3(int,socket, int,domain, int,type, int,protocol) +inline static __sys_socketcall3(int,bind, int,sockfd, struct sockaddr *,my_addr, socklen_t,addrlen) +inline static __sys_socketcall3(int,connect, int,sockfd, const struct sockaddr *,serv_addr, socklen_t,addrlen) +inline static __sys_socketcall2(int,listen, int,s, int,backlog) +inline static __sys_socketcall3(int,accept, int,s, struct sockaddr *,addr, socklen_t*,addrlen) + +inline static __sys_socketcall4(int,send, int,s, const void *,msg, size_t,len, int,flags) +inline static __sys_socketcall4(ssize_t,recv, int,s, void *,buf, size_t,len, int,flags) + + +inline static __sys_socketcall6(ssize_t,recvfrom, int,s, void *,buf, size_t,len, int,flags, struct sockaddr *,from, socklen_t *,fromlen) +inline static __sys_socketcall3(ssize_t,recvmsg, int,s, struct msghdr *,msg, int,flags) +inline static __sys_socketcall6(ssize_t,sendto, int,s, const void *,buf, size_t,len, int,flags, const struct sockaddr *,to, socklen_t,tolen) +inline static __sys_socketcall3(ssize_t,sendmsg, int,s, const struct msghdr *,msg, int,flags) + + + +#endif /* SFSOCKETCALL_H */ diff --git a/dest/include/librz/sflib/common/sftypes.h b/dest/include/librz/sflib/common/sftypes.h new file mode 100644 index 00000000000..fab3f831055 --- /dev/null +++ b/dest/include/librz/sflib/common/sftypes.h @@ -0,0 +1,3573 @@ +/* + * sftypes.h -- shellforge lib types + * see http://www.cartel-securite.net/pbiondi/shellforge.html + * for more informations + * + * Copyright (C) 2003 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +/* $Id$ */ + +#ifndef SFTYPES_H +#define SFTYPES_H + + +#define NULL ((void*)0) + + +/* XXX this is far from true on every architecture! */ +typedef unsigned long uint64_t; +typedef unsigned int uint32_t; +typedef unsigned short uint16_t; +typedef unsigned char uint8_t; +typedef long int64_t; +typedef int int32_t; +typedef short int16_t; +typedef char int8_t; + + +typedef int pid_t; +typedef int ssize_t; +typedef int size_t; +typedef int off_t; +typedef int mode_t; +typedef int clock_t; +typedef int uid_t; +typedef int gid_t; +typedef void (*sighandler_t)(int); + +struct dirent { + int d_ino; + int d_off; + unsigned short int d_reclen; + char d_name[256]; +}; + +struct tms { + clock_t tms_utime; /* user time */ + clock_t tms_stime; /* system time */ + clock_t tms_cutime; /* user time of children */ + clock_t tms_cstime; /* system time of children */ +}; +typedef int dev_t; +typedef int caddr_t; +typedef int sigset_t; +typedef int cap_user_header_t; +typedef int cap_user_data_t; +typedef int time_t; +struct vm86plus_struct {}; +typedef int ptrdiff_t; +struct utimbuf {}; +struct __sysctl_args {}; +struct timezone {}; +struct sysinfo{}; +struct iovec {}; +struct statfs {}; +struct pollfd {}; +struct kernel_sym {}; +struct module {}; +struct utsname {}; +struct ustat {}; +struct stat {}; +struct sched_param {}; +struct timeval +{ + long tv_sec; /* seconds */ + long tv_usec; /* microseconds */ +}; +struct timespec +{ + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + + + +#define PROT_READ 0x1 /* Page can be read. */ +#define PROT_WRITE 0x2 /* Page can be written. */ +#define PROT_EXEC 0x4 /* Page can be executed. */ +#define PROT_NONE 0x0 /* Page can not be accessed. */ + +/* Sharing types (must choose one and only one of these). */ +#define MAP_SHARED 0x01 /* Share changes. */ +#define MAP_PRIVATE 0x02 /* Changes are private. */ +#define MAP_TYPE 0x0f /* Mask for type of mapping. */ +#define MAP_FIXED 0x10 /* Interpret addr exactly. */ +#define MAP_FILE 0 +#define MAP_ANONYMOUS 0x20 /* Don't use a file. */ +#define MAP_ANON MAP_ANONYMOUS + +/**************** Error codes *****************/ + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Argument list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ + +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + + + +/**************** Select *******************************/ + +typedef long int fd_mask; + +#define FD_SETSIZE 1024 + +#define NFDBITS (8 * sizeof (fd_mask)) +#define __FDELT(d) ((d) / NFDBITS) +#define FDMASK(d) ((fd_mask) 1 << ((d) % NFDBITS)) + +typedef struct + { + fd_mask fds_bits[FD_SETSIZE / NFDBITS]; + } fd_set; + +# define __FDS_BITS(set) ((set)->fds_bits) + + +#define FD_ZERO(set) \ + do { \ + unsigned int __i; \ + fd_set *__arr = (set); \ + for (__i = 0; __i < sizeof (fd_set) / sizeof (fd_mask); ++__i) \ + __FDS_BITS (__arr)[__i] = 0; \ + } while (0) + +#define FD_SET(d, set) (__FDS_BITS (set)[__FDELT (d)] |= FDMASK (d)) +#define FD_CLR(d, set) (__FDS_BITS (set)[__FDELT (d)] &= ~FDMASK (d)) +#define FD_ISSET(d, set) (__FDS_BITS (set)[__FDELT (d)] & FDMASK (d)) + +/**************** Sockets and network *******************/ + + +typedef unsigned int socklen_t; + +/* SOCK_ constants */ +enum __socket_type +{ + SOCK_STREAM = 1, /* Sequenced, reliable, connection-based + byte streams. */ +#define SOCK_STREAM SOCK_STREAM + SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams + of fixed maximum length. */ +#define SOCK_DGRAM SOCK_DGRAM + SOCK_RAW = 3, /* Raw protocol interface. */ +#define SOCK_RAW SOCK_RAW + SOCK_RDM = 4, /* Reliably-delivered messages. */ +#define SOCK_RDM SOCK_RDM + SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based, + datagrams of fixed maximum length. */ +#define SOCK_SEQPACKET SOCK_SEQPACKET + SOCK_PACKET = 10 /* Linux specific way of getting packets + at the dev level. For writing rarp and + other similar things on the user level. */ +#define SOCK_PACKET SOCK_PACKET +}; + +/* Protocol families. */ +#define PF_UNSPEC 0 /* Unspecified. */ +#define PF_LOCAL 1 /* Local to host (pipes and file-domain). */ +#define PF_UNIX PF_LOCAL /* Old BSD name for PF_LOCAL. */ +#define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */ +#define PF_INET 2 /* IP protocol family. */ +#define PF_AX25 3 /* Amateur Radio AX.25. */ +#define PF_IPX 4 /* Novell Internet Protocol. */ +#define PF_APPLETALK 5 /* Appletalk DDP. */ +#define PF_NETROM 6 /* Amateur radio NetROM. */ +#define PF_BRIDGE 7 /* Multiprotocol bridge. */ +#define PF_ATMPVC 8 /* ATM PVCs. */ +#define PF_X25 9 /* Reserved for X.25 project. */ +#if __linux__ +#define PF_INET6 28 /* IP version 6 on linux. */ +#endif + +#if __FreeBSD__ +#define PF_INET6 10 /* IP version 6. */ +#endif + +#define PF_ROSE 11 /* Amateur Radio X.25 PLP. */ +#define PF_DECnet 12 /* Reserved for DECnet project. */ +#define PF_NETBEUI 13 /* Reserved for 802.2LLC project. */ +#define PF_SECURITY 14 /* Security callback pseudo AF. */ +#define PF_KEY 15 /* PF_KEY key management API. */ +#define PF_NETLINK 16 +#define PF_ROUTE PF_NETLINK /* Alias to emulate 4.4BSD. */ +#define PF_PACKET 17 /* Packet family. */ +#define PF_ASH 18 /* Ash. */ +#define PF_ECONET 19 /* Acorn Econet. */ +#define PF_ATMSVC 20 /* ATM SVCs. */ +#define PF_SNA 22 /* Linux SNA Project */ +#define PF_IRDA 23 /* IRDA sockets. */ +#define PF_PPPOX 24 /* PPPoX sockets. */ +#define PF_WANPIPE 25 /* Wanpipe API sockets. */ +#define PF_BLUETOOTH 31 /* Bluetooth sockets. */ +#define PF_MAX 32 /* For now.. */ + + /* Address families. */ +#define AF_UNSPEC PF_UNSPEC +#define AF_LOCAL PF_LOCAL +#define AF_UNIX PF_UNIX +#define AF_FILE PF_FILE +#define AF_INET PF_INET +#define AF_AX25 PF_AX25 +#define AF_IPX PF_IPX +#define AF_APPLETALK PF_APPLETALK +#define AF_NETROM PF_NETROM +#define AF_BRIDGE PF_BRIDGE +#define AF_ATMPVC PF_ATMPVC +#define AF_X25 PF_X25 +#define AF_INET6 PF_INET6 +#define AF_ROSE PF_ROSE +#define AF_DECnet PF_DECnet +#define AF_NETBEUI PF_NETBEUI +#define AF_SECURITY PF_SECURITY +#define AF_KEY PF_KEY +#define AF_NETLINK PF_NETLINK +#define AF_ROUTE PF_ROUTE +#define AF_PACKET PF_PACKET +#define AF_ASH PF_ASH +#define AF_ECONET PF_ECONET +#define AF_ATMSVC PF_ATMSVC +#define AF_SNA PF_SNA +#define AF_IRDA PF_IRDA +#define AF_PPPOX PF_PPPOX +#define AF_WANPIPE PF_WANPIPE +#define AF_BLUETOOTH PF_BLUETOOTH +#define AF_MAX PF_MAX + +#define SOL_RAW 255 +#define SOL_DECNET 261 +#define SOL_X25 262 +#define SOL_PACKET 263 +#define SOL_ATM 264 /* ATM layer (cell level). */ +#define SOL_AAL 265 /* ATM Adaption Layer (packet level). */ +#define SOL_IRDA 266 + +typedef unsigned short int sa_family_t; +#define __SOCKADDR_COMMON(sa_prefix) \ + sa_family_t sa_prefix##family +#define __SOCKADDR_COMMON_SIZE (sizeof (unsigned short int)) + +struct sockaddr + { + __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */ + char sa_data[14]; /* Address data. */ + }; + +typedef unsigned int in_addr_t; +typedef unsigned short in_port_t; +struct in_addr + { + in_addr_t s_addr; + }; + +struct sockaddr_in + { + __SOCKADDR_COMMON (sin_); + in_port_t sin_port; /* Port number. */ + struct in_addr sin_addr; /* Internet address. */ + + /* Pad to size of `struct sockaddr'. */ + unsigned char sin_zero[sizeof (struct sockaddr) - + __SOCKADDR_COMMON_SIZE - + sizeof (in_port_t) - + sizeof (struct in_addr)]; + }; + +struct sockaddr_un +{ + __SOCKADDR_COMMON (sun_); + char sun_path[108]; /* Path name. */ +}; + +struct in6_addr +{ + union + { + uint8_t __u6_addr8[16]; + } __in6_u; +}; + +#define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}} +static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; + +struct sockaddr_in6 +{ + __SOCKADDR_COMMON (sin6_); + in_port_t sin6_port; /* Transport layer port # */ + uint32_t sin6_flowinfo; /* IPv6 flow information */ + struct in6_addr sin6_addr; /* IPv6 address */ + uint32_t sin6_scope_id; /* IPv6 scope-id */ +}; + +/**** Ancillairy messages ****/ + +enum + { + SCM_RIGHTS = 0x01, /* Transfer file descriptors. */ +#define SCM_RIGHTS SCM_RIGHTS +#ifdef __USE_BSD + SCM_CREDENTIALS = 0x02, /* Credentials passing. */ +# define SCM_CREDENTIALS SCM_CREDENTIALS +#endif + __SCM_CONNECT = 0x03 /* Data array is `struct scm_connect'. */ + }; + +struct msghdr + { + void *msg_name; /* Address to send to/receive from. */ + socklen_t msg_namelen; /* Length of address data. */ + + struct iovec *msg_iov; /* Vector of data to send/receive into. */ + size_t msg_iovlen; /* Number of elements in the vector. */ + + void *msg_control; /* Ancillary data (eg BSD filedesc passing). */ + size_t msg_controllen; /* Ancillary data buffer length. */ + + int msg_flags; /* Flags on received message. */ + }; + +/* Structure used for storage of ancillary data object information. */ +struct cmsghdr + { + size_t cmsg_len; /* Length of data in cmsg_data plus length + of cmsghdr structure. */ + int cmsg_level; /* Originating protocol. */ + int cmsg_type; /* Protocol specific type. */ + }; + + +# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1)) +#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg) +#define CMSG_FIRSTHDR(mhdr) \ + ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \ + ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) NULL) +#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \ + & (size_t) ~(sizeof (size_t) - 1)) +#define CMSG_SPACE(len) (CMSG_ALIGN (len) \ + + CMSG_ALIGN (sizeof (struct cmsghdr))) +#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len)) + +#define SOL_SOCKET 1 + +#define SO_DEBUG 1 +#define SO_REUSEADDR 2 +#define SO_TYPE 3 +#define SO_ERROR 4 +#define SO_DONTROUTE 5 +#define SO_BROADCAST 6 +#define SO_SNDBUF 7 +#define SO_RCVBUF 8 +#define SO_KEEPALIVE 9 +#define SO_OOBINLINE 10 +#define SO_NO_CHECK 11 +#define SO_PRIORITY 12 +#define SO_LINGER 13 +#define SO_BSDCOMPAT 14 +/* To add :#define SO_REUSEPORT 15 */ +#define SO_PASSCRED 16 +#define SO_PEERCRED 17 +#define SO_RCVLOWAT 18 +#define SO_SNDLOWAT 19 +#define SO_RCVTIMEO 20 +#define SO_SNDTIMEO 21 + +/* Security levels - as per NRL IPv6 - don't actually do anything */ +#define SO_SECURITY_AUTHENTICATION 22 +#define SO_SECURITY_ENCRYPTION_TRANSPORT 23 +#define SO_SECURITY_ENCRYPTION_NETWORK 24 + +#define SO_BINDTODEVICE 25 + +/* Socket filtering */ +#define SO_ATTACH_FILTER 26 +#define SO_DETACH_FILTER 27 + +#define SO_PEERNAME 28 +#define SO_TIMESTAMP 29 +#define SCM_TIMESTAMP SO_TIMESTAMP + +#define SO_ACCEPTCONN 30 + + + +#ifdef SF_BIGENDIAN +#define IP(t,z,y,x) ((x)|(y)<<8|(z)<<16|(t)<<24) +#define htons(x) (x) +#else +#define IP(x,y,z,t) ((x)|(y)<<8|(z)<<16|(t)<<24) +#define htons(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff)) +#endif + +#define ntohs(x) htons(x) +#define SA_IN(sa, ip, port) do{ (sa).sin_family=PF_INET; \ + (sa).sin_port=(htons(port)); \ + (sa).sin_addr.s_addr=(ip); \ + }while(0) + + +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 0100 /* not fcntl */ +#define O_EXCL 0200 /* not fcntl */ +#define O_NOCTTY 0400 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +#define O_NDELAY O_NONBLOCK +#define O_SYNC 010000 +#define FASYNC 020000 /* fcntl, for BSD compatibility */ +#define O_DIRECT 040000 /* direct disk access hint */ +#define O_LARGEFILE 0100000 +#define O_DIRECTORY 0200000 /* must be a directory */ +#define O_NOFOLLOW 0400000 /* don't follow links */ + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get close_on_exec */ +#define F_SETFD 2 /* set/clear close_on_exec */ +#define F_GETFL 3 /* get file->f_flags */ +#define F_SETFL 4 /* set file->f_flags */ +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 + +#define F_SETOWN 8 /* for sockets. */ +#define F_GETOWN 9 /* for sockets. */ +#define F_SETSIG 10 /* for sockets. */ +#define F_GETSIG 11 /* for sockets. */ + +#define F_GETLK64 12 /* using 'struct flock64' */ +#define F_SETLK64 13 +#define F_SETLKW64 14 + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* for posix fcntl() and lockf() */ +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +/* for old implementation of bsd flock () */ +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ + +/* for leases */ +#define F_INPROGRESS 16 + +/* operations for bsd flock(), also used by the kernel implementation */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +#define LOCK_UN 8 /* remove lock */ + +#define LOCK_MAND 32 /* This is a mandatory flock */ +#define LOCK_READ 64 /* ... Which allows concurrent read operations */ +#define LOCK_WRITE 128 /* ... Which allows concurrent write operations */ +#define LOCK_RW 192 /* ... Which allows concurrent read & write ops */ + + +/**************** from ptrace.h *********/ + + +enum __ptrace_request +{ + /* Indicate that the process making this request should be traced. + All signals received by this process can be intercepted by its + parent, and its parent can use the other `ptrace' requests. */ + PTRACE_TRACEME = 0, +#define PT_TRACE_ME PTRACE_TRACEME + + /* Return the word in the process's text space at address ADDR. */ + PTRACE_PEEKTEXT = 1, +#define PT_READ_I PTRACE_PEEKTEXT + + /* Return the word in the process's data space at address ADDR. */ + PTRACE_PEEKDATA = 2, +#define PT_READ_D PTRACE_PEEKDATA + + /* Return the word in the process's user area at offset ADDR. */ + PTRACE_PEEKUSER = 3, +#define PT_READ_U PTRACE_PEEKUSER + + /* Write the word DATA into the process's text space at address ADDR. */ + PTRACE_POKETEXT = 4, +#define PT_WRITE_I PTRACE_POKETEXT + + /* Write the word DATA into the process's data space at address ADDR. */ + PTRACE_POKEDATA = 5, +#define PT_WRITE_D PTRACE_POKEDATA + + /* Write the word DATA into the process's user area at offset ADDR. */ + PTRACE_POKEUSER = 6, +#define PT_WRITE_U PTRACE_POKEUSER + + /* Continue the process. */ + PTRACE_CONT = 7, +#define PT_CONTINUE PTRACE_CONT + + /* Kill the process. */ + PTRACE_KILL = 8, +#define PT_KILL PTRACE_KILL + + /* Single step the process. + This is not supported on all machines. */ + PTRACE_SINGLESTEP = 9, +#define PT_STEP PTRACE_SINGLESTEP + + /* Get all general purpose registers used by a processes. + This is not supported on all machines. */ + PTRACE_GETREGS = 12, +#define PT_GETREGS PTRACE_GETREGS + + /* Set all general purpose registers used by a processes. + This is not supported on all machines. */ + PTRACE_SETREGS = 13, +#define PT_SETREGS PTRACE_SETREGS + + /* Get all floating point registers used by a processes. + This is not supported on all machines. */ + PTRACE_GETFPREGS = 14, +#define PT_GETFPREGS PTRACE_GETFPREGS + + /* Set all floating point registers used by a processes. + This is not supported on all machines. */ + PTRACE_SETFPREGS = 15, +#define PT_SETFPREGS PTRACE_SETFPREGS + + /* Attach to a process that is already running. */ + PTRACE_ATTACH = 16, +#define PT_ATTACH PTRACE_ATTACH + + /* Detach from a process attached to with PTRACE_ATTACH. */ + PTRACE_DETACH = 17, +#define PT_DETACH PTRACE_DETACH + + /* Get all extended floating point registers used by a processes. + This is not supported on all machines. */ + PTRACE_GETFPXREGS = 18, +#define PT_GETFPXREGS PTRACE_GETFPXREGS + + /* Set all extended floating point registers used by a processes. + This is not supported on all machines. */ + PTRACE_SETFPXREGS = 19, +#define PT_SETFPXREGS PTRACE_SETFPXREGS + + /* Continue and stop at the next (return from) syscall. */ + PTRACE_SYSCALL = 24 +#define PT_SYSCALL PTRACE_SYSCALL +}; + + +/************************ ioctl ******************/ +/* from asm/ioctl.h */ + +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 14 +#define _IOC_DIRBITS 2 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * * Direction bits. + * */ +#define _IOC_NONE 0U +#define _IOC_WRITE 1U +#define _IOC_READ 2U + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +/* provoke compile error for invalid uses of size argument */ +extern unsigned int __invalid_size_argument_for_IOC; +#define _IOC_TYPECHECK(t) \ + ((sizeof(t) == sizeof(t[1]) && \ + sizeof(t) < (1 << _IOC_SIZEBITS)) ? \ + sizeof(t) : __invalid_size_argument_for_IOC) + + /* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + + /* used to decode ioctl numbers.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* ...and for the drivers/sound files... */ + +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +/* from asm/ioctls.h */ + +#define TCGETS 0x5401 +#define TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */ +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define FIONREAD 0x541B +#define TIOCINQ FIONREAD +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +#define FIONBIO 0x5421 +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +/* #define TIOCTTYGSTRUCT 0x5426 - Former debugging-only ioctl */ +#define TIOCSBRK 0x5427 /* BSD compatibility */ +#define TIOCCBRK 0x5428 /* BSD compatibility */ +#define TIOCGSID 0x5429 /* Return the session ID of FD */ +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define FIONCLEX 0x5450 +#define FIOCLEX 0x5451 +#define FIOASYNC 0x5452 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ +#define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ +#define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ +#define FIOQSIZE 0x5460 + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + + + +/********************** termio *******************/ +/* from /usr/include/asm/termios.h */ + +struct winsize { + unsigned short ws_row; + unsigned short ws_col; + unsigned short ws_xpixel; + unsigned short ws_ypixel; +}; + +#define NCC 8 +struct termio { + unsigned short c_iflag; /* input mode flags */ + unsigned short c_oflag; /* output mode flags */ + unsigned short c_cflag; /* control mode flags */ + unsigned short c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG +#define TIOCM_OUT1 0x2000 +#define TIOCM_OUT2 0x4000 +#define TIOCM_LOOP 0x8000 + +/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ + +/* line disciplines */ +#define N_TTY 0 +#define N_SLIP 1 +#define N_MOUSE 2 +#define N_PPP 3 +#define N_STRIP 4 +#define N_AX25 5 +#define N_X25 6 /* X.25 async */ +#define N_6PACK 7 +#define N_MASC 8 /* Reserved for Mobitex module */ +#define N_R3964 9 /* Reserved for Simatic R3964 module */ +#define N_PROFIBUS_FDL 10 /* Reserved for Profibus */ +#define N_IRDA 11 /* Linux IR - http://irda.sourceforge.net/ */ +#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */ +#define N_HDLC 13 /* synchronous HDLC */ +#define N_SYNC_PPP 14 /* synchronous PPP */ +#define N_HCI 15 /* Bluetooth HCI UART */ + +typedef unsigned char cc_t; +typedef unsigned int speed_t; +typedef unsigned int tcflag_t; + +#define NCCS 19 +struct termios { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[NCCS]; /* control characters */ +}; + +/* c_cc characters */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSWTC 7 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 +#define VREPRINT 12 +#define VDISCARD 13 +#define VWERASE 14 +#define VLNEXT 15 +#define VEOL2 16 + +/* c_iflag bits */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 + +/* c_oflag bits */ +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#define NLDLY 0000400 +#define NL0 0000000 +#define NL1 0000400 +#define CRDLY 0003000 +#define CR0 0000000 +#define CR1 0001000 +#define CR2 0002000 +#define CR3 0003000 +#define TABDLY 0014000 +#define TAB0 0000000 +#define TAB1 0004000 +#define TAB2 0010000 +#define TAB3 0014000 +#define XTABS 0014000 +#define BSDLY 0020000 +#define BS0 0000000 +#define BS1 0020000 +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 +#define FFDLY 0100000 +#define FF0 0000000 +#define FF1 0100000 + +/* c_cflag bit meaning */ +#define CBAUD 0010017 +#define B0 0000000 /* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +#define EXTA B19200 +#define EXTB B38400 +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 +#define CBAUDEX 0010000 +#define B57600 0010001 +#define B115200 0010002 +#define B230400 0010003 +#define B460800 0010004 +#define B500000 0010005 +#define B576000 0010006 +#define B921600 0010007 +#define B1000000 0010010 +#define B1152000 0010011 +#define B1500000 0010012 +#define B2000000 0010013 +#define B2500000 0010014 +#define B3000000 0010015 +#define B3500000 0010016 +#define B4000000 0010017 +#define CIBAUD 002003600000 /* input baud rate (not used) */ +#define CMSPAR 010000000000 /* mark or space (stick) parity */ +#define CRTSCTS 020000000000 /* flow control */ + +/* c_lflag bits */ +#define ISIG 0000001 +#define ICANON 0000002 +#define XCASE 0000004 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#define ECHOCTL 0001000 +#define ECHOPRT 0002000 +#define ECHOKE 0004000 +#define FLUSHO 0010000 +#define PENDIN 0040000 +#define IEXTEN 0100000 + +/* tcflow() and TCXONC use these */ +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + +/* tcflush() and TCFLSH use these */ +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +/* tcsetattr uses these */ +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + + + +#endif /* SFTYPES_H */ + +/****************** Elf headers ***************/ +/* From /usr/include/elf.h */ + + + +/* Type for a 16-bit quantity. */ +typedef uint16_t Elf32_Half; +typedef uint16_t Elf64_Half; + +/* Types for signed and unsigned 32-bit quantities. */ +typedef uint32_t Elf32_Word; +typedef int32_t Elf32_Sword; +typedef uint32_t Elf64_Word; +typedef int32_t Elf64_Sword; + +/* Types for signed and unsigned 64-bit quantities. */ +typedef uint64_t Elf32_Xword; +typedef int64_t Elf32_Sxword; +typedef uint64_t Elf64_Xword; +typedef int64_t Elf64_Sxword; + +/* Type of addresses. */ +typedef uint32_t Elf32_Addr; +typedef uint64_t Elf64_Addr; + +/* Type of file offsets. */ +typedef uint32_t Elf32_Off; +typedef uint64_t Elf64_Off; + +/* Type for section indices, which are 16-bit quantities. */ +typedef uint16_t Elf32_Section; +typedef uint16_t Elf64_Section; + +/* Type for version symbol information. */ +typedef Elf32_Half Elf32_Versym; +typedef Elf64_Half Elf64_Versym; + + +/* The ELF file header. This appears at the start of every ELF file. */ + +#define EI_NIDENT (16) + +typedef struct +{ + unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ + Elf32_Half e_type; /* Object file type */ + Elf32_Half e_machine; /* Architecture */ + Elf32_Word e_version; /* Object file version */ + Elf32_Addr e_entry; /* Entry point virtual address */ + Elf32_Off e_phoff; /* Program header table file offset */ + Elf32_Off e_shoff; /* Section header table file offset */ + Elf32_Word e_flags; /* Processor-specific flags */ + Elf32_Half e_ehsize; /* ELF header size in bytes */ + Elf32_Half e_phentsize; /* Program header table entry size */ + Elf32_Half e_phnum; /* Program header table entry count */ + Elf32_Half e_shentsize; /* Section header table entry size */ + Elf32_Half e_shnum; /* Section header table entry count */ + Elf32_Half e_shstrndx; /* Section header string table index */ +} Elf32_Ehdr; + +typedef struct +{ + unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ + Elf64_Half e_type; /* Object file type */ + Elf64_Half e_machine; /* Architecture */ + Elf64_Word e_version; /* Object file version */ + Elf64_Addr e_entry; /* Entry point virtual address */ + Elf64_Off e_phoff; /* Program header table file offset */ + Elf64_Off e_shoff; /* Section header table file offset */ + Elf64_Word e_flags; /* Processor-specific flags */ + Elf64_Half e_ehsize; /* ELF header size in bytes */ + Elf64_Half e_phentsize; /* Program header table entry size */ + Elf64_Half e_phnum; /* Program header table entry count */ + Elf64_Half e_shentsize; /* Section header table entry size */ + Elf64_Half e_shnum; /* Section header table entry count */ + Elf64_Half e_shstrndx; /* Section header string table index */ +} Elf64_Ehdr; + +/* Fields in the e_ident array. The EI_* macros are indices into the + array. The macros under each EI_* macro are the values the byte + may have. */ + +#define EI_MAG0 0 /* File identification byte 0 index */ +#define ELFMAG0 0x7f /* Magic number byte 0 */ + +#define EI_MAG1 1 /* File identification byte 1 index */ +#define ELFMAG1 'E' /* Magic number byte 1 */ + +#define EI_MAG2 2 /* File identification byte 2 index */ +#define ELFMAG2 'L' /* Magic number byte 2 */ + +#define EI_MAG3 3 /* File identification byte 3 index */ +#define ELFMAG3 'F' /* Magic number byte 3 */ + +/* Conglomeration of the identification bytes, for easy testing as a word. */ +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +#define EI_CLASS 4 /* File class byte index */ +#define ELFCLASSNONE 0 /* Invalid class */ +#define ELFCLASS32 1 /* 32-bit objects */ +#define ELFCLASS64 2 /* 64-bit objects */ +#define ELFCLASSNUM 3 + +#define EI_DATA 5 /* Data encoding byte index */ +#define ELFDATANONE 0 /* Invalid data encoding */ +#define ELFDATA2LSB 1 /* 2's complement, little endian */ +#define ELFDATA2MSB 2 /* 2's complement, big endian */ +#define ELFDATANUM 3 + +#define EI_VERSION 6 /* File version byte index */ + /* Value must be EV_CURRENT */ + +#define EI_OSABI 7 /* OS ABI identification */ +#define ELFOSABI_NONE 0 /* UNIX System V ABI */ +#define ELFOSABI_SYSV 0 /* Alias. */ +#define ELFOSABI_HPUX 1 /* HP-UX */ +#define ELFOSABI_NETBSD 2 /* NetBSD. */ +#define ELFOSABI_LINUX 3 /* Linux. */ +#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */ +#define ELFOSABI_AIX 7 /* IBM AIX. */ +#define ELFOSABI_IRIX 8 /* SGI Irix. */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD. */ +#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto. */ +#define ELFOSABI_OPENBSD 12 /* OpenBSD. */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +#define EI_ABIVERSION 8 /* ABI version */ + +#define EI_PAD 9 /* Byte index of padding bytes */ + +/* Legal values for e_type (object file type). */ + +#define ET_NONE 0 /* No file type */ +#define ET_REL 1 /* Relocatable file */ +#define ET_EXEC 2 /* Executable file */ +#define ET_DYN 3 /* Shared object file */ +#define ET_CORE 4 /* Core file */ +#define ET_NUM 5 /* Number of defined types */ +#define ET_LOOS 0xfe00 /* OS-specific range start */ +#define ET_HIOS 0xfeff /* OS-specific range end */ +#define ET_LOPROC 0xff00 /* Processor-specific range start */ +#define ET_HIPROC 0xffff /* Processor-specific range end */ + +/* Legal values for e_machine (architecture). */ + +#define EM_NONE 0 /* No machine */ +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* SUN SPARC */ +#define EM_386 3 /* Intel 80386 */ +#define EM_68K 4 /* Motorola m68k family */ +#define EM_88K 5 /* Motorola m88k family */ +#define EM_860 7 /* Intel 80860 */ +#define EM_MIPS 8 /* MIPS R3000 big-endian */ +#define EM_S370 9 /* IBM System/370 */ +#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ + +#define EM_PARISC 15 /* HPPA */ +#define EM_VPP500 17 /* Fujitsu VPP500 */ +#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ +#define EM_960 19 /* Intel 80960 */ +#define EM_PPC 20 /* PowerPC */ +#define EM_PPC64 21 /* PowerPC 64-bit */ +#define EM_S390 22 /* IBM S390 */ + +#define EM_V800 36 /* NEC V800 series */ +#define EM_FR20 37 /* Fujitsu FR20 */ +#define EM_RH32 38 /* TRW RH-32 */ +#define EM_RCE 39 /* Motorola RCE */ +#define EM_ARM 40 /* ARM */ +#define EM_FAKE_ALPHA 41 /* Digital Alpha */ +#define EM_SH 42 /* Hitachi SH */ +#define EM_SPARCV9 43 /* SPARC v9 64-bit */ +#define EM_TRICORE 44 /* Siemens Tricore */ +#define EM_ARC 45 /* Argonaut RISC Core */ +#define EM_H8_300 46 /* Hitachi H8/300 */ +#define EM_H8_300H 47 /* Hitachi H8/300H */ +#define EM_H8S 48 /* Hitachi H8S */ +#define EM_H8_500 49 /* Hitachi H8/500 */ +#define EM_IA_64 50 /* Intel Merced */ +#define EM_MIPS_X 51 /* Stanford MIPS-X */ +#define EM_COLDFIRE 52 /* Motorola Coldfire */ +#define EM_68HC12 53 /* Motorola M68HC12 */ +#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/ +#define EM_PCP 55 /* Siemens PCP */ +#define EM_NCPU 56 /* Sony nCPU embeeded RISC */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor */ +#define EM_STARCORE 58 /* Motorola Start*Core processor */ +#define EM_ME16 59 /* Toyota ME16 processor */ +#define EM_ST100 60 /* STMicroelectronic ST100 processor */ +#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/ +#define EM_X86_64 62 /* AMD x86-64 architecture */ +#define EM_PDSP 63 /* Sony DSP Processor */ + +#define EM_FX66 66 /* Siemens FX66 microcontroller */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ +#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ +#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ +#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ +#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ +#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ +#define EM_SVX 73 /* Silicon Graphics SVx */ +#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */ +#define EM_VAX 75 /* Digital VAX */ +#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */ +#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ +#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ +#define EM_HUANY 81 /* Harvard University machine-independent object files */ +#define EM_PRISM 82 /* SiTera Prism */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ +#define EM_FR30 84 /* Fujitsu FR30 */ +#define EM_D10V 85 /* Mitsubishi D10V */ +#define EM_D30V 86 /* Mitsubishi D30V */ +#define EM_V850 87 /* NEC v850 */ +#define EM_M32R 88 /* Mitsubishi M32R */ +#define EM_MN10300 89 /* Matsushita MN10300 */ +#define EM_MN10200 90 /* Matsushita MN10200 */ +#define EM_PJ 91 /* picoJava */ +#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ +#define EM_NUM 95 + +/* If it is necessary to assign new unofficial EM_* values, please + pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the + chances of collision with official or non-GNU unofficial values. */ + +#define EM_ALPHA 0x9026 + +/* Legal values for e_version (version). */ + +#define EV_NONE 0 /* Invalid ELF version */ +#define EV_CURRENT 1 /* Current version */ +#define EV_NUM 2 + +/* Section header. */ + +typedef struct +{ + Elf32_Word sh_name; /* Section name (string tbl index) */ + Elf32_Word sh_type; /* Section type */ + Elf32_Word sh_flags; /* Section flags */ + Elf32_Addr sh_addr; /* Section virtual addr at execution */ + Elf32_Off sh_offset; /* Section file offset */ + Elf32_Word sh_size; /* Section size in bytes */ + Elf32_Word sh_link; /* Link to another section */ + Elf32_Word sh_info; /* Additional section information */ + Elf32_Word sh_addralign; /* Section alignment */ + Elf32_Word sh_entsize; /* Entry size if section holds table */ +} Elf32_Shdr; + +typedef struct +{ + Elf64_Word sh_name; /* Section name (string tbl index) */ + Elf64_Word sh_type; /* Section type */ + Elf64_Xword sh_flags; /* Section flags */ + Elf64_Addr sh_addr; /* Section virtual addr at execution */ + Elf64_Off sh_offset; /* Section file offset */ + Elf64_Xword sh_size; /* Section size in bytes */ + Elf64_Word sh_link; /* Link to another section */ + Elf64_Word sh_info; /* Additional section information */ + Elf64_Xword sh_addralign; /* Section alignment */ + Elf64_Xword sh_entsize; /* Entry size if section holds table */ +} Elf64_Shdr; + +/* Special section indices. */ + +#define SHN_UNDEF 0 /* Undefined section */ +#define SHN_LORESERVE 0xff00 /* Start of reserved indices */ +#define SHN_LOPROC 0xff00 /* Start of processor-specific */ +#define SHN_BEFORE 0xff00 /* Order section before all others + (Solaris). */ +#define SHN_AFTER 0xff01 /* Order section after all others + (Solaris). */ +#define SHN_HIPROC 0xff1f /* End of processor-specific */ +#define SHN_LOOS 0xff20 /* Start of OS-specific */ +#define SHN_HIOS 0xff3f /* End of OS-specific */ +#define SHN_ABS 0xfff1 /* Associated symbol is absolute */ +#define SHN_COMMON 0xfff2 /* Associated symbol is common */ +#define SHN_XINDEX 0xffff /* Index is in extra table. */ +#define SHN_HIRESERVE 0xffff /* End of reserved indices */ + +/* Legal values for sh_type (section type). */ + +#define SHT_NULL 0 /* Section header table entry unused */ +#define SHT_PROGBITS 1 /* Program data */ +#define SHT_SYMTAB 2 /* Symbol table */ +#define SHT_STRTAB 3 /* String table */ +#define SHT_RELA 4 /* Relocation entries with addends */ +#define SHT_HASH 5 /* Symbol hash table */ +#define SHT_DYNAMIC 6 /* Dynamic linking information */ +#define SHT_NOTE 7 /* Notes */ +#define SHT_NOBITS 8 /* Program space with no data (bss) */ +#define SHT_REL 9 /* Relocation entries, no addends */ +#define SHT_SHLIB 10 /* Reserved */ +#define SHT_DYNSYM 11 /* Dynamic linker symbol table */ +#define SHT_INIT_ARRAY 14 /* Array of constructors */ +#define SHT_FINI_ARRAY 15 /* Array of destructors */ +#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */ +#define SHT_GROUP 17 /* Section group */ +#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */ +#define SHT_NUM 19 /* Number of defined types. */ +#define SHT_LOOS 0x60000000 /* Start OS-specific */ +#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */ +#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */ +#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */ +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ +#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ +#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ +#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */ +#define SHT_HIOS 0x6fffffff /* End OS-specific type */ +#define SHT_LOPROC 0x70000000 /* Start of processor-specific */ +#define SHT_HIPROC 0x7fffffff /* End of processor-specific */ +#define SHT_LOUSER 0x80000000 /* Start of application-specific */ +#define SHT_HIUSER 0x8fffffff /* End of application-specific */ + +/* Legal values for sh_flags (section flags). */ + +#define SHF_WRITE (1 << 0) /* Writable */ +#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ +#define SHF_EXECINSTR (1 << 2) /* Executable */ +#define SHF_MERGE (1 << 4) /* Might be merged */ +#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */ +#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */ +#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */ +#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling + required */ +#define SHF_GROUP (1 << 9) /* Section is member of a group. */ +#define SHF_TLS (1 << 10) /* Section hold thread-local data. */ +#define SHF_MASKOS 0x0ff00000 /* OS-specific. */ +#define SHF_MASKPROC 0xf0000000 /* Processor-specific */ +#define SHF_ORDERED (1 << 30) /* Special ordering requirement + (Solaris). */ +#define SHF_EXCLUDE (1 << 31) /* Section is excluded unless + referenced or allocated (Solaris).*/ + +/* Section group handling. */ +#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */ + +/* Symbol table entry. */ + +typedef struct +{ + Elf32_Word st_name; /* Symbol name (string tbl index) */ + Elf32_Addr st_value; /* Symbol value */ + Elf32_Word st_size; /* Symbol size */ + unsigned char st_info; /* Symbol type and binding */ + unsigned char st_other; /* Symbol visibility */ + Elf32_Section st_shndx; /* Section index */ +} Elf32_Sym; + +typedef struct +{ + Elf64_Word st_name; /* Symbol name (string tbl index) */ + unsigned char st_info; /* Symbol type and binding */ + unsigned char st_other; /* Symbol visibility */ + Elf64_Section st_shndx; /* Section index */ + Elf64_Addr st_value; /* Symbol value */ + Elf64_Xword st_size; /* Symbol size */ +} Elf64_Sym; + +/* The syminfo section if available contains additional information about + every dynamic symbol. */ + +typedef struct +{ + Elf32_Half si_boundto; /* Direct bindings, symbol bound to */ + Elf32_Half si_flags; /* Per symbol flags */ +} Elf32_Syminfo; + +typedef struct +{ + Elf64_Half si_boundto; /* Direct bindings, symbol bound to */ + Elf64_Half si_flags; /* Per symbol flags */ +} Elf64_Syminfo; + +/* Possible values for si_boundto. */ +#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */ +#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */ +#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */ + +/* Possible bitmasks for si_flags. */ +#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */ +#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */ +#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */ +#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy + loaded */ +/* Syminfo version values. */ +#define SYMINFO_NONE 0 +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + + +/* How to extract and insert information held in the st_info field. */ + +#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) +#define ELF32_ST_TYPE(val) ((val) & 0xf) +#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) + +/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */ +#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) +#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) +#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) + +/* Legal values for ST_BIND subfield of st_info (symbol binding). */ + +#define STB_LOCAL 0 /* Local symbol */ +#define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* Weak symbol */ +#define STB_NUM 3 /* Number of defined types. */ +#define STB_LOOS 10 /* Start of OS-specific */ +#define STB_HIOS 12 /* End of OS-specific */ +#define STB_LOPROC 13 /* Start of processor-specific */ +#define STB_HIPROC 15 /* End of processor-specific */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_NOTYPE 0 /* Symbol type is unspecified */ +#define STT_OBJECT 1 /* Symbol is a data object */ +#define STT_FUNC 2 /* Symbol is a code object */ +#define STT_SECTION 3 /* Symbol associated with a section */ +#define STT_FILE 4 /* Symbol's name is file name */ +#define STT_COMMON 5 /* Symbol is a common data object */ +#define STT_TLS 6 /* Symbol is thread-local data object*/ +#define STT_NUM 7 /* Number of defined types. */ +#define STT_LOOS 10 /* Start of OS-specific */ +#define STT_HIOS 12 /* End of OS-specific */ +#define STT_LOPROC 13 /* Start of processor-specific */ +#define STT_HIPROC 15 /* End of processor-specific */ + + +/* Symbol table indices are found in the hash buckets and chain table + of a symbol hash table section. This special index value indicates + the end of a chain, meaning no further symbols are found in that bucket. */ + +#define STN_UNDEF 0 /* End of a chain. */ + + +/* How to extract and insert information held in the st_other field. */ + +#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) + +/* For ELF64 the definitions are the same. */ +#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) + +/* Symbol visibility specification encoded in the st_other field. */ +#define STV_DEFAULT 0 /* Default symbol visibility rules */ +#define STV_INTERNAL 1 /* Processor specific hidden class */ +#define STV_HIDDEN 2 /* Sym unavailable in other modules */ +#define STV_PROTECTED 3 /* Not preemptible, not exported */ + + +/* Relocation table entry without addend (in section of type SHT_REL). */ + +typedef struct +{ + Elf32_Addr r_offset; /* Address */ + Elf32_Word r_info; /* Relocation type and symbol index */ +} Elf32_Rel; + +/* I have seen two different definitions of the Elf64_Rel and + Elf64_Rela structures, so we'll leave them out until Novell (or + whoever) gets their act together. */ +/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */ + +typedef struct +{ + Elf64_Addr r_offset; /* Address */ + Elf64_Xword r_info; /* Relocation type and symbol index */ +} Elf64_Rel; + +/* Relocation table entry with addend (in section of type SHT_RELA). */ + +typedef struct +{ + Elf32_Addr r_offset; /* Address */ + Elf32_Word r_info; /* Relocation type and symbol index */ + Elf32_Sword r_addend; /* Addend */ +} Elf32_Rela; + +typedef struct +{ + Elf64_Addr r_offset; /* Address */ + Elf64_Xword r_info; /* Relocation type and symbol index */ + Elf64_Sxword r_addend; /* Addend */ +} Elf64_Rela; + +/* How to extract and insert information held in the r_info field. */ + +#define ELF32_R_SYM(val) ((val) >> 8) +#define ELF32_R_TYPE(val) ((val) & 0xff) +#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) + +#define ELF64_R_SYM(i) ((i) >> 32) +#define ELF64_R_TYPE(i) ((i) & 0xffffffff) +#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) + +/* Program segment header. */ + +typedef struct +{ + Elf32_Word p_type; /* Segment type */ + Elf32_Off p_offset; /* Segment file offset */ + Elf32_Addr p_vaddr; /* Segment virtual address */ + Elf32_Addr p_paddr; /* Segment physical address */ + Elf32_Word p_filesz; /* Segment size in file */ + Elf32_Word p_memsz; /* Segment size in memory */ + Elf32_Word p_flags; /* Segment flags */ + Elf32_Word p_align; /* Segment alignment */ +} Elf32_Phdr; + +typedef struct +{ + Elf64_Word p_type; /* Segment type */ + Elf64_Word p_flags; /* Segment flags */ + Elf64_Off p_offset; /* Segment file offset */ + Elf64_Addr p_vaddr; /* Segment virtual address */ + Elf64_Addr p_paddr; /* Segment physical address */ + Elf64_Xword p_filesz; /* Segment size in file */ + Elf64_Xword p_memsz; /* Segment size in memory */ + Elf64_Xword p_align; /* Segment alignment */ +} Elf64_Phdr; + +/* Legal values for p_type (segment type). */ + +#define PT_NULL 0 /* Program header table entry unused */ +#define PT_LOAD 1 /* Loadable program segment */ +#define PT_DYNAMIC 2 /* Dynamic linking information */ +#define PT_INTERP 3 /* Program interpreter */ +#define PT_NOTE 4 /* Auxiliary information */ +#define PT_SHLIB 5 /* Reserved */ +#define PT_PHDR 6 /* Entry for header table itself */ +#define PT_TLS 7 /* Thread-local storage segment */ +#define PT_NUM 8 /* Number of defined types */ +#define PT_LOOS 0x60000000 /* Start of OS-specific */ +#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */ +#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */ +#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */ +#define PT_LOSUNW 0x6ffffffa +#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ +#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */ +#define PT_HISUNW 0x6fffffff +#define PT_HIOS 0x6fffffff /* End of OS-specific */ +#define PT_LOPROC 0x70000000 /* Start of processor-specific */ +#define PT_HIPROC 0x7fffffff /* End of processor-specific */ + +/* Legal values for p_flags (segment flags). */ + +#define PF_X (1 << 0) /* Segment is executable */ +#define PF_W (1 << 1) /* Segment is writable */ +#define PF_R (1 << 2) /* Segment is readable */ +#define PF_MASKOS 0x0ff00000 /* OS-specific */ +#define PF_MASKPROC 0xf0000000 /* Processor-specific */ + +/* Legal values for note segment descriptor types for core files. */ + +#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ +#define NT_FPREGSET 2 /* Contains copy of fpregset struct */ +#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */ +#define NT_PRXREG 4 /* Contains copy of prxregset struct */ +#define NT_TASKSTRUCT 4 /* Contains copy of task structure */ +#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */ +#define NT_AUXV 6 /* Contains copy of auxv array */ +#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */ +#define NT_ASRS 8 /* Contains copy of asrset struct */ +#define NT_PSTATUS 10 /* Contains copy of pstatus struct */ +#define NT_PSINFO 13 /* Contains copy of psinfo struct */ +#define NT_PRCRED 14 /* Contains copy of prcred struct */ +#define NT_UTSNAME 15 /* Contains copy of utsname struct */ +#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */ +#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */ +#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct*/ + +/* Legal values for the note segment descriptor types for object files. */ + +#define NT_VERSION 1 /* Contains a version string. */ + + +/* Dynamic section entry. */ + +typedef struct +{ + Elf32_Sword d_tag; /* Dynamic entry type */ + union + { + Elf32_Word d_val; /* Integer value */ + Elf32_Addr d_ptr; /* Address value */ + } d_un; +} Elf32_Dyn; + +typedef struct +{ + Elf64_Sxword d_tag; /* Dynamic entry type */ + union + { + Elf64_Xword d_val; /* Integer value */ + Elf64_Addr d_ptr; /* Address value */ + } d_un; +} Elf64_Dyn; + +/* Legal values for d_tag (dynamic entry type). */ + +#define DT_NULL 0 /* Marks end of dynamic section */ +#define DT_NEEDED 1 /* Name of needed library */ +#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */ +#define DT_PLTGOT 3 /* Processor defined value */ +#define DT_HASH 4 /* Address of symbol hash table */ +#define DT_STRTAB 5 /* Address of string table */ +#define DT_SYMTAB 6 /* Address of symbol table */ +#define DT_RELA 7 /* Address of Rela relocs */ +#define DT_RELASZ 8 /* Total size of Rela relocs */ +#define DT_RELAENT 9 /* Size of one Rela reloc */ +#define DT_STRSZ 10 /* Size of string table */ +#define DT_SYMENT 11 /* Size of one symbol table entry */ +#define DT_INIT 12 /* Address of init function */ +#define DT_FINI 13 /* Address of termination function */ +#define DT_SONAME 14 /* Name of shared object */ +#define DT_RPATH 15 /* Library search path (deprecated) */ +#define DT_SYMBOLIC 16 /* Start symbol search here */ +#define DT_REL 17 /* Address of Rel relocs */ +#define DT_RELSZ 18 /* Total size of Rel relocs */ +#define DT_RELENT 19 /* Size of one Rel reloc */ +#define DT_PLTREL 20 /* Type of reloc in PLT */ +#define DT_DEBUG 21 /* For debugging; unspecified */ +#define DT_TEXTREL 22 /* Reloc might modify .text */ +#define DT_JMPREL 23 /* Address of PLT relocs */ +#define DT_BIND_NOW 24 /* Process relocations of object */ +#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */ +#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */ +#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */ +#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */ +#define DT_RUNPATH 29 /* Library search path */ +#define DT_FLAGS 30 /* Flags for the object being loaded */ +#define DT_ENCODING 32 /* Start of encoded range */ +#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ +#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ +#define DT_NUM 34 /* Number used */ +#define DT_LOOS 0x6000000d /* Start of OS-specific */ +#define DT_HIOS 0x6ffff000 /* End of OS-specific */ +#define DT_LOPROC 0x70000000 /* Start of processor-specific */ +#define DT_HIPROC 0x7fffffff /* End of processor-specific */ +#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */ + +/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the + Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's + approach. */ +#define DT_VALRNGLO 0x6ffffd00 +#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */ +#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */ +#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */ +#define DT_CHECKSUM 0x6ffffdf8 +#define DT_PLTPADSZ 0x6ffffdf9 +#define DT_MOVEENT 0x6ffffdfa +#define DT_MOVESZ 0x6ffffdfb +#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */ +#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting + the following DT_* entry. */ +#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */ +#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */ +#define DT_VALRNGHI 0x6ffffdff +#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */ +#define DT_VALNUM 12 + +/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the + Dyn.d_un.d_ptr field of the Elf*_Dyn structure. + + If any adjustment is made to the ELF object after it has been + built these entries will need to be adjusted. */ +#define DT_ADDRRNGLO 0x6ffffe00 +#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */ +#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */ +#define DT_CONFIG 0x6ffffefa /* Configuration information. */ +#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */ +#define DT_AUDIT 0x6ffffefc /* Object auditing. */ +#define DT_PLTPAD 0x6ffffefd /* PLT padding. */ +#define DT_MOVETAB 0x6ffffefe /* Move table. */ +#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */ +#define DT_ADDRRNGHI 0x6ffffeff +#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */ +#define DT_ADDRNUM 10 + +/* The versioning entry types. The next are defined as part of the + GNU extension. */ +#define DT_VERSYM 0x6ffffff0 + +#define DT_RELACOUNT 0x6ffffff9 +#define DT_RELCOUNT 0x6ffffffa + +/* These were chosen by Sun. */ +#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */ +#define DT_VERDEF 0x6ffffffc /* Address of version definition + table */ +#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */ +#define DT_VERNEED 0x6ffffffe /* Address of table with needed + versions */ +#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */ +#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ +#define DT_VERSIONTAGNUM 16 + +/* Sun added these machine-independent extensions in the "processor-specific" + range. Be compatible. */ +#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */ +#define DT_FILTER 0x7fffffff /* Shared object to get values from */ +#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) +#define DT_EXTRANUM 3 + +/* Values of `d_un.d_val' in the DT_FLAGS entry. */ +#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */ +#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ +#define DF_TEXTREL 0x00000004 /* Object contains text relocations */ +#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ +#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */ + +/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 + entry in the dynamic section. */ +#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ +#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ +#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ +#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ +#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/ +#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/ +#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ +#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ +#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ +#define DF_1_TRANS 0x00000200 +#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ +#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ +#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */ +#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/ +#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */ +#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */ +#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */ + +/* Flags for the feature selection in DT_FEATURE_1. */ +#define DTF_1_PARINIT 0x00000001 +#define DTF_1_CONFEXP 0x00000002 + +/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */ +#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ +#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not + generally available. */ + +/* Version definition sections. */ + +typedef struct +{ + Elf32_Half vd_version; /* Version revision */ + Elf32_Half vd_flags; /* Version information */ + Elf32_Half vd_ndx; /* Version Index */ + Elf32_Half vd_cnt; /* Number of associated aux entries */ + Elf32_Word vd_hash; /* Version name hash value */ + Elf32_Word vd_aux; /* Offset in bytes to verdaux array */ + Elf32_Word vd_next; /* Offset in bytes to next verdef + entry */ +} Elf32_Verdef; + +typedef struct +{ + Elf64_Half vd_version; /* Version revision */ + Elf64_Half vd_flags; /* Version information */ + Elf64_Half vd_ndx; /* Version Index */ + Elf64_Half vd_cnt; /* Number of associated aux entries */ + Elf64_Word vd_hash; /* Version name hash value */ + Elf64_Word vd_aux; /* Offset in bytes to verdaux array */ + Elf64_Word vd_next; /* Offset in bytes to next verdef + entry */ +} Elf64_Verdef; + + +/* Legal values for vd_version (version revision). */ +#define VER_DEF_NONE 0 /* No version */ +#define VER_DEF_CURRENT 1 /* Current version */ +#define VER_DEF_NUM 2 /* Given version number */ + +/* Legal values for vd_flags (version information flags). */ +#define VER_FLG_BASE 0x1 /* Version definition of file itself */ +#define VER_FLG_WEAK 0x2 /* Weak version identifier */ + +/* Versym symbol index values. */ +#define VER_NDX_LOCAL 0 /* Symbol is local. */ +#define VER_NDX_GLOBAL 1 /* Symbol is global. */ +#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */ +#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */ + +/* Auxialiary version information. */ + +typedef struct +{ + Elf32_Word vda_name; /* Version or dependency names */ + Elf32_Word vda_next; /* Offset in bytes to next verdaux + entry */ +} Elf32_Verdaux; + +typedef struct +{ + Elf64_Word vda_name; /* Version or dependency names */ + Elf64_Word vda_next; /* Offset in bytes to next verdaux + entry */ +} Elf64_Verdaux; + + +/* Version dependency section. */ + +typedef struct +{ + Elf32_Half vn_version; /* Version of structure */ + Elf32_Half vn_cnt; /* Number of associated aux entries */ + Elf32_Word vn_file; /* Offset of filename for this + dependency */ + Elf32_Word vn_aux; /* Offset in bytes to vernaux array */ + Elf32_Word vn_next; /* Offset in bytes to next verneed + entry */ +} Elf32_Verneed; + +typedef struct +{ + Elf64_Half vn_version; /* Version of structure */ + Elf64_Half vn_cnt; /* Number of associated aux entries */ + Elf64_Word vn_file; /* Offset of filename for this + dependency */ + Elf64_Word vn_aux; /* Offset in bytes to vernaux array */ + Elf64_Word vn_next; /* Offset in bytes to next verneed + entry */ +} Elf64_Verneed; + + +/* Legal values for vn_version (version revision). */ +#define VER_NEED_NONE 0 /* No version */ +#define VER_NEED_CURRENT 1 /* Current version */ +#define VER_NEED_NUM 2 /* Given version number */ + +/* Auxiliary needed version information. */ + +typedef struct +{ + Elf32_Word vna_hash; /* Hash value of dependency name */ + Elf32_Half vna_flags; /* Dependency specific information */ + Elf32_Half vna_other; /* Unused */ + Elf32_Word vna_name; /* Dependency name string offset */ + Elf32_Word vna_next; /* Offset in bytes to next vernaux + entry */ +} Elf32_Vernaux; + +typedef struct +{ + Elf64_Word vna_hash; /* Hash value of dependency name */ + Elf64_Half vna_flags; /* Dependency specific information */ + Elf64_Half vna_other; /* Unused */ + Elf64_Word vna_name; /* Dependency name string offset */ + Elf64_Word vna_next; /* Offset in bytes to next vernaux + entry */ +} Elf64_Vernaux; + + +/* Legal values for vna_flags. */ +#define VER_FLG_WEAK 0x2 /* Weak version identifier */ + + +/* Auxiliary vector. */ + +/* This vector is normally only used by the program interpreter. The + usual definition in an ABI supplement uses the name auxv_t. The + vector is not usually defined in a standard file, but it + can't hurt. We rename it to avoid conflicts. The sizes of these + types are an arrangement between the exec server and the program + interpreter, so we don't fully specify them here. */ + +typedef struct +{ + int a_type; /* Entry type */ + union + { + long int a_val; /* Integer value */ + void *a_ptr; /* Pointer value */ + void (*a_fcn) (void); /* Function pointer value */ + } a_un; +} Elf32_auxv_t; + +typedef struct +{ + long int a_type; /* Entry type */ + union + { + long int a_val; /* Integer value */ + void *a_ptr; /* Pointer value */ + void (*a_fcn) (void); /* Function pointer value */ + } a_un; +} Elf64_auxv_t; + +/* Legal values for a_type (entry type). */ + +#define AT_NULL 0 /* End of vector */ +#define AT_IGNORE 1 /* Entry should be ignored */ +#define AT_EXECFD 2 /* File descriptor of program */ +#define AT_PHDR 3 /* Program headers for program */ +#define AT_PHENT 4 /* Size of program header entry */ +#define AT_PHNUM 5 /* Number of program headers */ +#define AT_PAGESZ 6 /* System page size */ +#define AT_BASE 7 /* Base address of interpreter */ +#define AT_FLAGS 8 /* Flags */ +#define AT_ENTRY 9 /* Entry point of program */ +#define AT_NOTELF 10 /* Program is not ELF */ +#define AT_UID 11 /* Real uid */ +#define AT_EUID 12 /* Effective uid */ +#define AT_GID 13 /* Real gid */ +#define AT_EGID 14 /* Effective gid */ +#define AT_CLKTCK 17 /* Frequency of times() */ + +/* Some more special a_type values describing the hardware. */ +#define AT_PLATFORM 15 /* String identifying platform. */ +#define AT_HWCAP 16 /* Machine dependent hints about + processor capabilities. */ + +/* This entry gives some information about the FPU initialization + performed by the kernel. */ +#define AT_FPUCW 18 /* Used FPU control word. */ + +/* Cache block sizes. */ +#define AT_DCACHEBSIZE 19 /* Data cache block size. */ +#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */ +#define AT_UCACHEBSIZE 21 /* Unified cache block size. */ + +/* A special ignored value for PPC, used by the kernel to control the + interpretation of the AUXV. Must be > 16. */ +#define AT_IGNOREPPC 22 /* Entry should be ignored. */ + +#define AT_SECURE 23 /* Boolean, was exec setuid-like? */ + +/* Pointer to the global system page used for system calls and other + nice things. */ +#define AT_SYSINFO 32 +#define AT_SYSINFO_EHDR 33 + +/* Shapes of the caches. Bits 0-3 contains associativity; bits 4-7 contains + log2 of line size; mask those to get cache size. */ +#define AT_L1I_CACHESHAPE 34 +#define AT_L1D_CACHESHAPE 35 +#define AT_L2_CACHESHAPE 36 +#define AT_L3_CACHESHAPE 37 + +/* Note section contents. Each entry in the note section begins with + a header of a fixed form. */ + +typedef struct +{ + Elf32_Word n_namesz; /* Length of the note's name. */ + Elf32_Word n_descsz; /* Length of the note's descriptor. */ + Elf32_Word n_type; /* Type of the note. */ +} Elf32_Nhdr; + +typedef struct +{ + Elf64_Word n_namesz; /* Length of the note's name. */ + Elf64_Word n_descsz; /* Length of the note's descriptor. */ + Elf64_Word n_type; /* Type of the note. */ +} Elf64_Nhdr; + +/* Known names of notes. */ + +/* Solaris entries in the note section have this name. */ +#define ELF_NOTE_SOLARIS "SUNW Solaris" + +/* Note entries for GNU systems have this name. */ +#define ELF_NOTE_GNU "GNU" + + +/* Defined types of notes for Solaris. */ + +/* Value of descriptor (one word) is desired pagesize for the binary. */ +#define ELF_NOTE_PAGESIZE_HINT 1 + + +/* Defined note types for GNU systems. */ + +/* ABI information. The descriptor consists of words: + word 0: OS descriptor + word 1: major version of the ABI + word 2: minor version of the ABI + word 3: subminor version of the ABI +*/ +#define ELF_NOTE_ABI 1 + +/* Known OSes. These value can appear in word 0 of an ELF_NOTE_ABI + note section entry. */ +#define ELF_NOTE_OS_LINUX 0 +#define ELF_NOTE_OS_GNU 1 +#define ELF_NOTE_OS_SOLARIS2 2 +#define ELF_NOTE_OS_FREEBSD 3 + + +/* Move records. */ +typedef struct +{ + Elf32_Xword m_value; /* Symbol value. */ + Elf32_Word m_info; /* Size and index. */ + Elf32_Word m_poffset; /* Symbol offset. */ + Elf32_Half m_repeat; /* Repeat count. */ + Elf32_Half m_stride; /* Stride info. */ +} Elf32_Move; + +typedef struct +{ + Elf64_Xword m_value; /* Symbol value. */ + Elf64_Xword m_info; /* Size and index. */ + Elf64_Xword m_poffset; /* Symbol offset. */ + Elf64_Half m_repeat; /* Repeat count. */ + Elf64_Half m_stride; /* Stride info. */ +} Elf64_Move; + +/* Macro to construct move records. */ +#define ELF32_M_SYM(info) ((info) >> 8) +#define ELF32_M_SIZE(info) ((unsigned char) (info)) +#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size)) + +#define ELF64_M_SYM(info) ELF32_M_SYM (info) +#define ELF64_M_SIZE(info) ELF32_M_SIZE (info) +#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) + + +/* Motorola 68k specific definitions. */ + +/* Values for Elf32_Ehdr.e_flags. */ +#define EF_CPU32 0x00810000 + +/* m68k relocs. */ + +#define R_68K_NONE 0 /* No reloc */ +#define R_68K_32 1 /* Direct 32 bit */ +#define R_68K_16 2 /* Direct 16 bit */ +#define R_68K_8 3 /* Direct 8 bit */ +#define R_68K_PC32 4 /* PC relative 32 bit */ +#define R_68K_PC16 5 /* PC relative 16 bit */ +#define R_68K_PC8 6 /* PC relative 8 bit */ +#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */ +#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */ +#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */ +#define R_68K_GOT32O 10 /* 32 bit GOT offset */ +#define R_68K_GOT16O 11 /* 16 bit GOT offset */ +#define R_68K_GOT8O 12 /* 8 bit GOT offset */ +#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */ +#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */ +#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */ +#define R_68K_PLT32O 16 /* 32 bit PLT offset */ +#define R_68K_PLT16O 17 /* 16 bit PLT offset */ +#define R_68K_PLT8O 18 /* 8 bit PLT offset */ +#define R_68K_COPY 19 /* Copy symbol at runtime */ +#define R_68K_GLOB_DAT 20 /* Create GOT entry */ +#define R_68K_JMP_SLOT 21 /* Create PLT entry */ +#define R_68K_RELATIVE 22 /* Adjust by program base */ +/* Keep this the last entry. */ +#define R_68K_NUM 23 + +/* Intel 80386 specific definitions. */ + +/* i386 relocs. */ + +#define R_386_NONE 0 /* No reloc */ +#define R_386_32 1 /* Direct 32 bit */ +#define R_386_PC32 2 /* PC relative 32 bit */ +#define R_386_GOT32 3 /* 32 bit GOT entry */ +#define R_386_PLT32 4 /* 32 bit PLT address */ +#define R_386_COPY 5 /* Copy symbol at runtime */ +#define R_386_GLOB_DAT 6 /* Create GOT entry */ +#define R_386_JMP_SLOT 7 /* Create PLT entry */ +#define R_386_RELATIVE 8 /* Adjust by program base */ +#define R_386_GOTOFF 9 /* 32 bit offset to GOT */ +#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */ +#define R_386_32PLT 11 +#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */ +#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS + block offset */ +#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block + offset */ +#define R_386_TLS_LE 17 /* Offset relative to static TLS + block */ +#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of + general dynamic thread local data */ +#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of + local dynamic thread local data + in LE code */ +#define R_386_16 20 +#define R_386_PC16 21 +#define R_386_8 22 +#define R_386_PC8 23 +#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic + thread local data */ +#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */ +#define R_386_TLS_GD_CALL 26 /* Relocation for call to + __tls_get_addr() */ +#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */ +#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic + thread local data in LE code */ +#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */ +#define R_386_TLS_LDM_CALL 30 /* Relocation for call to + __tls_get_addr() in LDM code */ +#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */ +#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */ +#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS + block offset */ +#define R_386_TLS_LE_32 34 /* Negated offset relative to static + TLS block */ +#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */ +#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */ +#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */ +/* Keep this the last entry. */ +#define R_386_NUM 38 + +/* SUN SPARC specific definitions. */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_SPARC_REGISTER 13 /* Global register reserved to app. */ + +/* Values for Elf64_Ehdr.e_flags. */ + +#define EF_SPARCV9_MM 3 +#define EF_SPARCV9_TSO 0 +#define EF_SPARCV9_PSO 1 +#define EF_SPARCV9_RMO 2 +#define EF_SPARC_LEDATA 0x800000 /* little endian data */ +#define EF_SPARC_EXT_MASK 0xFFFF00 +#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */ +#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */ +#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */ +#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */ + +/* SPARC relocs. */ + +#define R_SPARC_NONE 0 /* No reloc */ +#define R_SPARC_8 1 /* Direct 8 bit */ +#define R_SPARC_16 2 /* Direct 16 bit */ +#define R_SPARC_32 3 /* Direct 32 bit */ +#define R_SPARC_DISP8 4 /* PC relative 8 bit */ +#define R_SPARC_DISP16 5 /* PC relative 16 bit */ +#define R_SPARC_DISP32 6 /* PC relative 32 bit */ +#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */ +#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */ +#define R_SPARC_HI22 9 /* High 22 bit */ +#define R_SPARC_22 10 /* Direct 22 bit */ +#define R_SPARC_13 11 /* Direct 13 bit */ +#define R_SPARC_LO10 12 /* Truncated 10 bit */ +#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */ +#define R_SPARC_GOT13 14 /* 13 bit GOT entry */ +#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */ +#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */ +#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */ +#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */ +#define R_SPARC_COPY 19 /* Copy symbol at runtime */ +#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */ +#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */ +#define R_SPARC_RELATIVE 22 /* Adjust by program base */ +#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */ + +/* Additional Sparc64 relocs. */ + +#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */ +#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */ +#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */ +#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */ +#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */ +#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */ +#define R_SPARC_10 30 /* Direct 10 bit */ +#define R_SPARC_11 31 /* Direct 11 bit */ +#define R_SPARC_64 32 /* Direct 64 bit */ +#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */ +#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */ +#define R_SPARC_HM10 35 /* High middle 10 bits of ... */ +#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */ +#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */ +#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */ +#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */ +#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */ +#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */ +#define R_SPARC_7 43 /* Direct 7 bit */ +#define R_SPARC_5 44 /* Direct 5 bit */ +#define R_SPARC_6 45 /* Direct 6 bit */ +#define R_SPARC_DISP64 46 /* PC relative 64 bit */ +#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */ +#define R_SPARC_HIX22 48 /* High 22 bit complemented */ +#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */ +#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */ +#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */ +#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */ +#define R_SPARC_REGISTER 53 /* Global register usage */ +#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */ +#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */ +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 +/* Keep this the last entry. */ +#define R_SPARC_NUM 80 + +/* For Sparc64, legal values for d_tag of Elf64_Dyn. */ + +#define DT_SPARC_REGISTER 0x70000001 +#define DT_SPARC_NUM 2 + +/* Bits present in AT_HWCAP, primarily for Sparc32. */ + +#define HWCAP_SPARC_FLUSH 1 /* The cpu supports flush insn. */ +#define HWCAP_SPARC_STBAR 2 +#define HWCAP_SPARC_SWAP 4 +#define HWCAP_SPARC_MULDIV 8 +#define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */ +#define HWCAP_SPARC_ULTRA3 32 + +/* MIPS R3000 specific definitions. */ + +/* Legal values for e_flags field of Elf32_Ehdr. */ + +#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */ +#define EF_MIPS_PIC 2 /* Contains PIC code */ +#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */ +#define EF_MIPS_XGOT 8 +#define EF_MIPS_64BIT_WHIRL 16 +#define EF_MIPS_ABI2 32 +#define EF_MIPS_ABI_ON32 64 +#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */ + +/* Legal values for MIPS architecture level. */ + +#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ +#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ +#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ +#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ +#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ +#define EF_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */ +#define EF_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */ + +/* The following are non-official names and should not be used. */ + +#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ +#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ +#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ +#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ +#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ +#define E_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */ +#define E_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */ + +/* Special section indices. */ + +#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */ +#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */ +#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */ +#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */ +#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */ + +/* Legal values for sh_type field of Elf32_Shdr. */ + +#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */ +#define SHT_MIPS_MSYM 0x70000001 +#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */ +#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */ +#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */ +#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/ +#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */ +#define SHT_MIPS_PACKAGE 0x70000007 +#define SHT_MIPS_PACKSYM 0x70000008 +#define SHT_MIPS_RELD 0x70000009 +#define SHT_MIPS_IFACE 0x7000000b +#define SHT_MIPS_CONTENT 0x7000000c +#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */ +#define SHT_MIPS_SHDR 0x70000010 +#define SHT_MIPS_FDESC 0x70000011 +#define SHT_MIPS_EXTSYM 0x70000012 +#define SHT_MIPS_DENSE 0x70000013 +#define SHT_MIPS_PDESC 0x70000014 +#define SHT_MIPS_LOCSYM 0x70000015 +#define SHT_MIPS_AUXSYM 0x70000016 +#define SHT_MIPS_OPTSYM 0x70000017 +#define SHT_MIPS_LOCSTR 0x70000018 +#define SHT_MIPS_LINE 0x70000019 +#define SHT_MIPS_RFDESC 0x7000001a +#define SHT_MIPS_DELTASYM 0x7000001b +#define SHT_MIPS_DELTAINST 0x7000001c +#define SHT_MIPS_DELTACLASS 0x7000001d +#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */ +#define SHT_MIPS_DELTADECL 0x7000001f +#define SHT_MIPS_SYMBOL_LIB 0x70000020 +#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */ +#define SHT_MIPS_TRANSLATE 0x70000022 +#define SHT_MIPS_PIXIE 0x70000023 +#define SHT_MIPS_XLATE 0x70000024 +#define SHT_MIPS_XLATE_DEBUG 0x70000025 +#define SHT_MIPS_WHIRL 0x70000026 +#define SHT_MIPS_EH_REGION 0x70000027 +#define SHT_MIPS_XLATE_OLD 0x70000028 +#define SHT_MIPS_PDR_EXCEPTION 0x70000029 + +/* Legal values for sh_flags field of Elf32_Shdr. */ + +#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */ +#define SHF_MIPS_MERGE 0x20000000 +#define SHF_MIPS_ADDR 0x40000000 +#define SHF_MIPS_STRINGS 0x80000000 +#define SHF_MIPS_NOSTRIP 0x08000000 +#define SHF_MIPS_LOCAL 0x04000000 +#define SHF_MIPS_NAMES 0x02000000 +#define SHF_MIPS_NODUPE 0x01000000 + + +/* Symbol tables. */ + +/* MIPS specific values for `st_other'. */ +#define STO_MIPS_DEFAULT 0x0 +#define STO_MIPS_INTERNAL 0x1 +#define STO_MIPS_HIDDEN 0x2 +#define STO_MIPS_PROTECTED 0x3 +#define STO_MIPS_SC_ALIGN_UNUSED 0xff + +/* MIPS specific values for `st_info'. */ +#define STB_MIPS_SPLIT_COMMON 13 + +/* Entries found in sections of type SHT_MIPS_GPTAB. */ + +typedef union +{ + struct + { + Elf32_Word gt_current_g_value; /* -G value used for compilation */ + Elf32_Word gt_unused; /* Not used */ + } gt_header; /* First entry in section */ + struct + { + Elf32_Word gt_g_value; /* If this value were used for -G */ + Elf32_Word gt_bytes; /* This many bytes would be used */ + } gt_entry; /* Subsequent entries in section */ +} Elf32_gptab; + +/* Entry found in sections of type SHT_MIPS_REGINFO. */ + +typedef struct +{ + Elf32_Word ri_gprmask; /* General registers used */ + Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */ + Elf32_Sword ri_gp_value; /* $gp register value */ +} Elf32_RegInfo; + +/* Entries found in sections of type SHT_MIPS_OPTIONS. */ + +typedef struct +{ + unsigned char kind; /* Determines interpretation of the + variable part of descriptor. */ + unsigned char size; /* Size of descriptor, including header. */ + Elf32_Section section; /* Section header index of section affected, + 0 for global options. */ + Elf32_Word info; /* Kind-specific information. */ +} Elf_Options; + +/* Values for `kind' field in Elf_Options. */ + +#define ODK_NULL 0 /* Undefined. */ +#define ODK_REGINFO 1 /* Register usage information. */ +#define ODK_EXCEPTIONS 2 /* Exception processing options. */ +#define ODK_PAD 3 /* Section padding options. */ +#define ODK_HWPATCH 4 /* Hardware workarounds performed */ +#define ODK_FILL 5 /* record the fill value used by the linker. */ +#define ODK_TAGS 6 /* reserve space for desktop tools to write. */ +#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */ +#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */ + +/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */ + +#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */ +#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */ +#define OEX_PAGE0 0x10000 /* page zero must be mapped. */ +#define OEX_SMM 0x20000 /* Force sequential memory mode? */ +#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */ +#define OEX_PRECISEFP OEX_FPDBUG +#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */ + +#define OEX_FPU_INVAL 0x10 +#define OEX_FPU_DIV0 0x08 +#define OEX_FPU_OFLO 0x04 +#define OEX_FPU_UFLO 0x02 +#define OEX_FPU_INEX 0x01 + +/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */ + +#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */ +#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */ +#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */ +#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */ + +#define OPAD_PREFIX 0x1 +#define OPAD_POSTFIX 0x2 +#define OPAD_SYMBOL 0x4 + +/* Entry found in `.options' section. */ + +typedef struct +{ + Elf32_Word hwp_flags1; /* Extra flags. */ + Elf32_Word hwp_flags2; /* Extra flags. */ +} Elf_Options_Hw; + +/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */ + +#define OHWA0_R4KEOP_CHECKED 0x00000001 +#define OHWA1_R4KEOP_CLEAN 0x00000002 + +/* MIPS relocs. */ + +#define R_MIPS_NONE 0 /* No reloc */ +#define R_MIPS_16 1 /* Direct 16 bit */ +#define R_MIPS_32 2 /* Direct 32 bit */ +#define R_MIPS_REL32 3 /* PC relative 32 bit */ +#define R_MIPS_26 4 /* Direct 26 bit shifted */ +#define R_MIPS_HI16 5 /* High 16 bit */ +#define R_MIPS_LO16 6 /* Low 16 bit */ +#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ +#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ +#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ +#define R_MIPS_PC16 10 /* PC relative 16 bit */ +#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ +#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ + +#define R_MIPS_SHIFT5 16 +#define R_MIPS_SHIFT6 17 +#define R_MIPS_64 18 +#define R_MIPS_GOT_DISP 19 +#define R_MIPS_GOT_PAGE 20 +#define R_MIPS_GOT_OFST 21 +#define R_MIPS_GOT_HI16 22 +#define R_MIPS_GOT_LO16 23 +#define R_MIPS_SUB 24 +#define R_MIPS_INSERT_A 25 +#define R_MIPS_INSERT_B 26 +#define R_MIPS_DELETE 27 +#define R_MIPS_HIGHER 28 +#define R_MIPS_HIGHEST 29 +#define R_MIPS_CALL_HI16 30 +#define R_MIPS_CALL_LO16 31 +#define R_MIPS_SCN_DISP 32 +#define R_MIPS_REL16 33 +#define R_MIPS_ADD_IMMEDIATE 34 +#define R_MIPS_PJUMP 35 +#define R_MIPS_RELGOT 36 +#define R_MIPS_JALR 37 +/* Keep this the last entry. */ +#define R_MIPS_NUM 38 + +/* Legal values for p_type field of Elf32_Phdr. */ + +#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */ +#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */ +#define PT_MIPS_OPTIONS 0x70000002 + +/* Special program header types. */ + +#define PF_MIPS_LOCAL 0x10000000 + +/* Legal values for d_tag field of Elf32_Dyn. */ + +#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */ +#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */ +#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */ +#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */ +#define DT_MIPS_FLAGS 0x70000005 /* Flags */ +#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */ +#define DT_MIPS_MSYM 0x70000007 +#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */ +#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */ +#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */ +#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */ +#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */ +#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */ +#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */ +#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */ +#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */ +#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */ +#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */ +#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in + DT_MIPS_DELTA_CLASS. */ +#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */ +#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in + DT_MIPS_DELTA_INSTANCE. */ +#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */ +#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in + DT_MIPS_DELTA_RELOC. */ +#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta + relocations refer to. */ +#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in + DT_MIPS_DELTA_SYM. */ +#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the + class declaration. */ +#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in + DT_MIPS_DELTA_CLASSSYM. */ +#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */ +#define DT_MIPS_PIXIE_INIT 0x70000023 +#define DT_MIPS_SYMBOL_LIB 0x70000024 +#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 +#define DT_MIPS_LOCAL_GOTIDX 0x70000026 +#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 +#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 +#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */ +#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */ +#define DT_MIPS_DYNSTR_ALIGN 0x7000002b +#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */ +#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve + function stored in GOT. */ +#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added + by rld on dlopen() calls. */ +#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */ +#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */ +#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */ +#define DT_MIPS_NUM 0x32 + +/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */ + +#define RHF_NONE 0 /* No flags */ +#define RHF_QUICKSTART (1 << 0) /* Use quickstart */ +#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */ +#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */ +#define RHF_NO_MOVE (1 << 3) +#define RHF_SGI_ONLY (1 << 4) +#define RHF_GUARANTEE_INIT (1 << 5) +#define RHF_DELTA_C_PLUS_PLUS (1 << 6) +#define RHF_GUARANTEE_START_INIT (1 << 7) +#define RHF_PIXIE (1 << 8) +#define RHF_DEFAULT_DELAY_LOAD (1 << 9) +#define RHF_REQUICKSTART (1 << 10) +#define RHF_REQUICKSTARTED (1 << 11) +#define RHF_CORD (1 << 12) +#define RHF_NO_UNRES_UNDEF (1 << 13) +#define RHF_RLD_ORDER_SAFE (1 << 14) + +/* Entries found in sections of type SHT_MIPS_LIBLIST. */ + +typedef struct +{ + Elf32_Word l_name; /* Name (string table index) */ + Elf32_Word l_time_stamp; /* Timestamp */ + Elf32_Word l_checksum; /* Checksum */ + Elf32_Word l_version; /* Interface version */ + Elf32_Word l_flags; /* Flags */ +} Elf32_Lib; + +typedef struct +{ + Elf64_Word l_name; /* Name (string table index) */ + Elf64_Word l_time_stamp; /* Timestamp */ + Elf64_Word l_checksum; /* Checksum */ + Elf64_Word l_version; /* Interface version */ + Elf64_Word l_flags; /* Flags */ +} Elf64_Lib; + + +/* Legal values for l_flags. */ + +#define LL_NONE 0 +#define LL_EXACT_MATCH (1 << 0) /* Require exact match */ +#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */ +#define LL_REQUIRE_MINOR (1 << 2) +#define LL_EXPORTS (1 << 3) +#define LL_DELAY_LOAD (1 << 4) +#define LL_DELTA (1 << 5) + +/* Entries found in sections of type SHT_MIPS_CONFLICT. */ + +typedef Elf32_Addr Elf32_Conflict; + + +/* HPPA specific definitions. */ + +/* Legal values for e_flags field of Elf32_Ehdr. */ + +#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */ +#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */ +#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */ +#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */ +#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch + prediction. */ +#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */ +#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */ + +/* Defined values for `e_flags & EF_PARISC_ARCH' are: */ + +#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */ +#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */ +#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */ + +/* Additional section indeces. */ + +#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared + symbols in ANSI C. */ +#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */ + +/* Legal values for sh_type field of Elf32_Shdr. */ + +#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */ +#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */ +#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */ + +/* Legal values for sh_flags field of Elf32_Shdr. */ + +#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */ +#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */ +#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */ + +#define STT_HP_OPAQUE (STT_LOOS + 0x1) +#define STT_HP_STUB (STT_LOOS + 0x2) + +/* HPPA relocs. */ + +#define R_PARISC_NONE 0 /* No reloc. */ +#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */ +#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */ +#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */ +#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */ +#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */ +#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */ +#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */ +#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */ +#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */ +#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */ +#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */ +#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */ +#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */ +#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */ +#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */ +#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */ +#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */ +#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */ +#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */ +#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */ +#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */ +#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */ +#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */ +#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */ +#define R_PARISC_FPTR64 64 /* 64 bits function address. */ +#define R_PARISC_PLABEL32 65 /* 32 bits function address. */ +#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */ +#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */ +#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */ +#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */ +#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */ +#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */ +#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */ +#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */ +#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */ +#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */ +#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */ +#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */ +#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */ +#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */ +#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */ +#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */ +#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */ +#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */ +#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */ +#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */ +#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */ +#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */ +#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */ +#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */ +#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */ +#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */ +#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */ +#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */ +#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */ +#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */ +#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */ +#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */ +#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LORESERVE 128 +#define R_PARISC_COPY 128 /* Copy relocation. */ +#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */ +#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */ +#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */ +#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */ +#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */ +#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */ +#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */ +#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */ +#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */ +#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */ +#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_HIRESERVE 255 + +/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */ + +#define PT_HP_TLS (PT_LOOS + 0x0) +#define PT_HP_CORE_NONE (PT_LOOS + 0x1) +#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) +#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) +#define PT_HP_CORE_COMM (PT_LOOS + 0x4) +#define PT_HP_CORE_PROC (PT_LOOS + 0x5) +#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) +#define PT_HP_CORE_STACK (PT_LOOS + 0x7) +#define PT_HP_CORE_SHM (PT_LOOS + 0x8) +#define PT_HP_CORE_MMF (PT_LOOS + 0x9) +#define PT_HP_PARALLEL (PT_LOOS + 0x10) +#define PT_HP_FASTBIND (PT_LOOS + 0x11) +#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) +#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) +#define PT_HP_STACK (PT_LOOS + 0x14) + +#define PT_PARISC_ARCHEXT 0x70000000 +#define PT_PARISC_UNWIND 0x70000001 + +/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */ + +#define PF_PARISC_SBP 0x08000000 + +#define PF_HP_PAGE_SIZE 0x00100000 +#define PF_HP_FAR_SHARED 0x00200000 +#define PF_HP_NEAR_SHARED 0x00400000 +#define PF_HP_CODE 0x01000000 +#define PF_HP_MODIFY 0x02000000 +#define PF_HP_LAZYSWAP 0x04000000 +#define PF_HP_SBP 0x08000000 + + +/* Alpha specific definitions. */ + +/* Legal values for e_flags field of Elf64_Ehdr. */ + +#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */ +#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */ + +/* Legal values for sh_type field of Elf64_Shdr. */ + +/* These two are primerily concerned with ECOFF debugging info. */ +#define SHT_ALPHA_DEBUG 0x70000001 +#define SHT_ALPHA_REGINFO 0x70000002 + +/* Legal values for sh_flags field of Elf64_Shdr. */ + +#define SHF_ALPHA_GPREL 0x10000000 + +/* Legal values for st_other field of Elf64_Sym. */ +#define STO_ALPHA_NOPV 0x80 /* No PV required. */ +#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */ + +/* Alpha relocs. */ + +#define R_ALPHA_NONE 0 /* No reloc */ +#define R_ALPHA_REFLONG 1 /* Direct 32 bit */ +#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */ +#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */ +#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */ +#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */ +#define R_ALPHA_GPDISP 6 /* Add displacement to GP */ +#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */ +#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */ +#define R_ALPHA_SREL16 9 /* PC relative 16 bit */ +#define R_ALPHA_SREL32 10 /* PC relative 32 bit */ +#define R_ALPHA_SREL64 11 /* PC relative 64 bit */ +#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */ +#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */ +#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */ +#define R_ALPHA_COPY 24 /* Copy symbol at runtime */ +#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */ +#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */ +#define R_ALPHA_RELATIVE 27 /* Adjust by program base */ +#define R_ALPHA_TLS_GD_HI 28 +#define R_ALPHA_TLSGD 29 +#define R_ALPHA_TLS_LDM 30 +#define R_ALPHA_DTPMOD64 31 +#define R_ALPHA_GOTDTPREL 32 +#define R_ALPHA_DTPREL64 33 +#define R_ALPHA_DTPRELHI 34 +#define R_ALPHA_DTPRELLO 35 +#define R_ALPHA_DTPREL16 36 +#define R_ALPHA_GOTTPREL 37 +#define R_ALPHA_TPREL64 38 +#define R_ALPHA_TPRELHI 39 +#define R_ALPHA_TPRELLO 40 +#define R_ALPHA_TPREL16 41 +/* Keep this the last entry. */ +#define R_ALPHA_NUM 46 + +/* Magic values of the LITUSE relocation addend. */ +#define LITUSE_ALPHA_ADDR 0 +#define LITUSE_ALPHA_BASE 1 +#define LITUSE_ALPHA_BYTOFF 2 +#define LITUSE_ALPHA_JSR 3 +#define LITUSE_ALPHA_TLS_GD 4 +#define LITUSE_ALPHA_TLS_LDM 5 + + +/* PowerPC specific declarations */ + +/* Values for Elf32/64_Ehdr.e_flags. */ +#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ + +/* Cygnus local bits below */ +#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/ +#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib + flag */ + +/* PowerPC relocations defined by the ABIs */ +#define R_PPC_NONE 0 +#define R_PPC_ADDR32 1 /* 32bit absolute address */ +#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ +#define R_PPC_ADDR16 3 /* 16bit absolute address */ +#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ +#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ +#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ +#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 /* PC relative 26 bit */ +#define R_PPC_REL14 11 /* PC relative 16 bit */ +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 + +/* PowerPC relocations defined for the TLS access ABI. */ +#define R_PPC_TLS 67 /* none (sym+add)@tls */ +#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */ +#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */ +#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ +#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ +#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ +#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */ +#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */ +#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ +#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ +#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ +#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */ +#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ +#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ +#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ +#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ +#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ +#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ +#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ +#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ +#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */ +#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */ +#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ +#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ +#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */ +#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */ +#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */ +#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */ + +/* Keep this the last entry. */ +#define R_PPC_NUM 95 + +/* The remaining relocs are from the Embedded ELF ABI, and are not + in the SVR4 ELF ABI. */ +#define R_PPC_EMB_NADDR32 101 +#define R_PPC_EMB_NADDR16 102 +#define R_PPC_EMB_NADDR16_LO 103 +#define R_PPC_EMB_NADDR16_HI 104 +#define R_PPC_EMB_NADDR16_HA 105 +#define R_PPC_EMB_SDAI16 106 +#define R_PPC_EMB_SDA2I16 107 +#define R_PPC_EMB_SDA2REL 108 +#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */ +#define R_PPC_EMB_MRKREF 110 +#define R_PPC_EMB_RELSEC16 111 +#define R_PPC_EMB_RELST_LO 112 +#define R_PPC_EMB_RELST_HI 113 +#define R_PPC_EMB_RELST_HA 114 +#define R_PPC_EMB_BIT_FLD 115 +#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */ + +/* Diab tool relocations. */ +#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */ +#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */ +#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */ +#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */ +#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */ +#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */ + +/* This is a phony reloc to handle any old fashioned TOC16 references + that may still be in object files. */ +#define R_PPC_TOC16 255 + + +/* PowerPC64 relocations defined by the ABIs */ +#define R_PPC64_NONE R_PPC_NONE +#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address */ +#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned */ +#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address */ +#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of address */ +#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of address. */ +#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */ +#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned */ +#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN +#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN +#define R_PPC64_REL24 R_PPC_REL24 /* PC-rel. 26 bit, word aligned */ +#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit */ +#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN +#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN +#define R_PPC64_GOT16 R_PPC_GOT16 +#define R_PPC64_GOT16_LO R_PPC_GOT16_LO +#define R_PPC64_GOT16_HI R_PPC_GOT16_HI +#define R_PPC64_GOT16_HA R_PPC_GOT16_HA + +#define R_PPC64_COPY R_PPC_COPY +#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT +#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT +#define R_PPC64_RELATIVE R_PPC_RELATIVE + +#define R_PPC64_UADDR32 R_PPC_UADDR32 +#define R_PPC64_UADDR16 R_PPC_UADDR16 +#define R_PPC64_REL32 R_PPC_REL32 +#define R_PPC64_PLT32 R_PPC_PLT32 +#define R_PPC64_PLTREL32 R_PPC_PLTREL32 +#define R_PPC64_PLT16_LO R_PPC_PLT16_LO +#define R_PPC64_PLT16_HI R_PPC_PLT16_HI +#define R_PPC64_PLT16_HA R_PPC_PLT16_HA + +#define R_PPC64_SECTOFF R_PPC_SECTOFF +#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO +#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI +#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA +#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2 */ +#define R_PPC64_ADDR64 38 /* doubleword64 S + A */ +#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A) */ +#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */ +#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */ +#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A) */ +#define R_PPC64_UADDR64 43 /* doubleword64 S + A */ +#define R_PPC64_REL64 44 /* doubleword64 S + A - P */ +#define R_PPC64_PLT64 45 /* doubleword64 L + A */ +#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P */ +#define R_PPC64_TOC16 47 /* half16* S + A - .TOC */ +#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.) */ +#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.) */ +#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.) */ +#define R_PPC64_TOC 51 /* doubleword64 .TOC */ +#define R_PPC64_PLTGOT16 52 /* half16* M + A */ +#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A) */ +#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A) */ +#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A) */ + +#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2 */ +#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2 */ +#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2 */ +#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2 */ +#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2 */ +#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2 */ +#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2 */ +#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2 */ +#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2 */ +#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2 */ +#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2 */ + +/* PowerPC64 relocations defined for the TLS access ABI. */ +#define R_PPC64_TLS 67 /* none (sym+add)@tls */ +#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */ +#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */ +#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ +#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ +#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ +#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */ +#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */ +#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ +#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ +#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ +#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */ +#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ +#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ +#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ +#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ +#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ +#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ +#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ +#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ +#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */ +#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */ +#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ +#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ +#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */ +#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */ +#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */ +#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */ +#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */ +#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */ +#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */ +#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */ +#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */ +#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */ +#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */ +#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */ +#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */ +#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */ +#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */ +#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */ + +/* Keep this the last entry. */ +#define R_PPC64_NUM 107 + +/* PowerPC64 specific values for the Dyn d_tag field. */ +#define DT_PPC64_GLINK (DT_LOPROC + 0) +#define DT_PPC64_OPD (DT_LOPROC + 1) +#define DT_PPC64_OPDSZ (DT_LOPROC + 2) +#define DT_PPC64_NUM 3 + + +/* ARM specific declarations */ + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_ARM_RELEXEC 0x01 +#define EF_ARM_HASENTRY 0x02 +#define EF_ARM_INTERWORK 0x04 +#define EF_ARM_APCS_26 0x08 +#define EF_ARM_APCS_FLOAT 0x10 +#define EF_ARM_PIC 0x20 +#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */ +#define EF_ARM_NEW_ABI 0x80 +#define EF_ARM_OLD_ABI 0x100 + +/* Other constants defined in the ARM ELF spec. version B-01. */ +/* NB. These conflict with values defined above. */ +#define EF_ARM_SYMSARESORTED 0x04 +#define EF_ARM_DYNSYMSUSESEGIDX 0x08 +#define EF_ARM_MAPSYMSFIRST 0x10 +#define EF_ARM_EABIMASK 0XFF000000 + +#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK) +#define EF_ARM_EABI_UNKNOWN 0x00000000 +#define EF_ARM_EABI_VER1 0x01000000 +#define EF_ARM_EABI_VER2 0x02000000 + +/* Additional symbol types for Thumb */ +#define STT_ARM_TFUNC 0xd + +/* ARM-specific values for sh_flags */ +#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */ +#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined + in the input to a link step */ + +/* ARM-specific program header flags */ +#define PF_ARM_SB 0x10000000 /* Segment contains the location + addressed by the static base */ + +/* ARM relocs. */ +#define R_ARM_NONE 0 /* No reloc */ +#define R_ARM_PC24 1 /* PC relative 26 bit branch */ +#define R_ARM_ABS32 2 /* Direct 32 bit */ +#define R_ARM_REL32 3 /* PC relative 32 bit */ +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 /* Direct 16 bit */ +#define R_ARM_ABS12 6 /* Direct 12 bit */ +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 /* Direct 8 bit */ +#define R_ARM_SBREL32 9 +#define R_ARM_THM_PC22 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_SWI24 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 +#define R_ARM_COPY 20 /* Copy symbol at runtime */ +#define R_ARM_GLOB_DAT 21 /* Create GOT entry */ +#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */ +#define R_ARM_RELATIVE 23 /* Adjust by program base */ +#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */ +#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */ +#define R_ARM_GOT32 26 /* 32 bit GOT entry */ +#define R_ARM_PLT32 27 /* 32 bit PLT address */ +#define R_ARM_ALU_PCREL_7_0 32 +#define R_ARM_ALU_PCREL_15_8 33 +#define R_ARM_ALU_PCREL_23_15 34 +#define R_ARM_LDR_SBREL_11_0 35 +#define R_ARM_ALU_SBREL_19_12 36 +#define R_ARM_ALU_SBREL_27_20 37 +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_THM_PC11 102 /* thumb unconditional branch */ +#define R_ARM_THM_PC9 103 /* thumb conditional branch */ +#define R_ARM_RXPC25 249 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS22 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 +/* Keep this the last entry. */ +#define R_ARM_NUM 256 + +/* IA-64 specific declarations. */ + +/* Processor specific flags for the Ehdr e_flags field. */ +#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */ +#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */ +#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */ + +/* Processor specific values for the Phdr p_type field. */ +#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */ +#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */ +#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12) +#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13) +#define PT_IA_64_HP_STACK (PT_LOOS + 0x14) + +/* Processor specific flags for the Phdr p_flags field. */ +#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */ + +/* Processor specific values for the Shdr sh_type field. */ +#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */ +#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */ + +/* Processor specific flags for the Shdr sh_flags field. */ +#define SHF_IA_64_SHORT 0x10000000 /* section near gp */ +#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */ + +/* Processor specific values for the Dyn d_tag field. */ +#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) +#define DT_IA_64_NUM 1 + +/* IA-64 relocations. */ +#define R_IA64_NONE 0x00 /* none */ +#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */ +#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */ +#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */ +#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */ +#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */ +#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */ +#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */ +#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */ +#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */ +#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */ +#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */ +#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */ +#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */ +#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */ +#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */ +#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */ +#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */ +#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */ +#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */ +#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */ +#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */ +#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */ +#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */ +#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */ +#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */ +#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */ +#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */ +#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */ +#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */ +#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */ +#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */ +#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */ +#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */ +#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */ +#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */ +#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */ +#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */ +#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */ +#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */ +#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */ +#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */ +#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */ +#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */ +#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */ +#define R_IA64_REL32MSB 0x6c /* data 4 + REL */ +#define R_IA64_REL32LSB 0x6d /* data 4 + REL */ +#define R_IA64_REL64MSB 0x6e /* data 8 + REL */ +#define R_IA64_REL64LSB 0x6f /* data 8 + REL */ +#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */ +#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */ +#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */ +#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */ +#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */ +#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */ +#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */ +#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */ +#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */ +#define R_IA64_COPY 0x84 /* copy relocation */ +#define R_IA64_SUB 0x85 /* Addend and symbol difference */ +#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */ +#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */ +#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */ +#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */ +#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */ +#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */ +#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */ +#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */ +#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */ +#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */ +#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */ +#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */ +#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */ +#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */ +#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */ +#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */ +#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */ + +/* SH specific declarations */ + +/* SH relocs. */ +#define R_SH_NONE 0 +#define R_SH_DIR32 1 +#define R_SH_REL32 2 +#define R_SH_DIR8WPN 3 +#define R_SH_IND12W 4 +#define R_SH_DIR8WPL 5 +#define R_SH_DIR8WPZ 6 +#define R_SH_DIR8BP 7 +#define R_SH_DIR8W 8 +#define R_SH_DIR8L 9 +#define R_SH_SWITCH16 25 +#define R_SH_SWITCH32 26 +#define R_SH_USES 27 +#define R_SH_COUNT 28 +#define R_SH_ALIGN 29 +#define R_SH_CODE 30 +#define R_SH_DATA 31 +#define R_SH_LABEL 32 +#define R_SH_SWITCH8 33 +#define R_SH_GNU_VTINHERIT 34 +#define R_SH_GNU_VTENTRY 35 +#define R_SH_TLS_GD_32 144 +#define R_SH_TLS_LD_32 145 +#define R_SH_TLS_LDO_32 146 +#define R_SH_TLS_IE_32 147 +#define R_SH_TLS_LE_32 148 +#define R_SH_TLS_DTPMOD32 149 +#define R_SH_TLS_DTPOFF32 150 +#define R_SH_TLS_TPOFF32 151 +#define R_SH_GOT32 160 +#define R_SH_PLT32 161 +#define R_SH_COPY 162 +#define R_SH_GLOB_DAT 163 +#define R_SH_JMP_SLOT 164 +#define R_SH_RELATIVE 165 +#define R_SH_GOTOFF 166 +#define R_SH_GOTPC 167 +/* Keep this the last entry. */ +#define R_SH_NUM 256 + +/* Additional s390 relocs */ + +#define R_390_NONE 0 /* No reloc. */ +#define R_390_8 1 /* Direct 8 bit. */ +#define R_390_12 2 /* Direct 12 bit. */ +#define R_390_16 3 /* Direct 16 bit. */ +#define R_390_32 4 /* Direct 32 bit. */ +#define R_390_PC32 5 /* PC relative 32 bit. */ +#define R_390_GOT12 6 /* 12 bit GOT offset. */ +#define R_390_GOT32 7 /* 32 bit GOT offset. */ +#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */ +#define R_390_COPY 9 /* Copy symbol at runtime. */ +#define R_390_GLOB_DAT 10 /* Create GOT entry. */ +#define R_390_JMP_SLOT 11 /* Create PLT entry. */ +#define R_390_RELATIVE 12 /* Adjust by program base. */ +#define R_390_GOTOFF32 13 /* 32 bit offset to GOT. */ +#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */ +#define R_390_GOT16 15 /* 16 bit GOT offset. */ +#define R_390_PC16 16 /* PC relative 16 bit. */ +#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */ +#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */ +#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */ +#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */ +#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */ +#define R_390_64 22 /* Direct 64 bit. */ +#define R_390_PC64 23 /* PC relative 64 bit. */ +#define R_390_GOT64 24 /* 64 bit GOT offset. */ +#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */ +#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */ +#define R_390_GOTOFF16 27 /* 16 bit offset to GOT. */ +#define R_390_GOTOFF64 28 /* 64 bit offset to GOT. */ +#define R_390_GOTPLT12 29 /* 12 bit offset to jump slot. */ +#define R_390_GOTPLT16 30 /* 16 bit offset to jump slot. */ +#define R_390_GOTPLT32 31 /* 32 bit offset to jump slot. */ +#define R_390_GOTPLT64 32 /* 64 bit offset to jump slot. */ +#define R_390_GOTPLTENT 33 /* 32 bit rel. offset to jump slot. */ +#define R_390_PLTOFF16 34 /* 16 bit offset from GOT to PLT. */ +#define R_390_PLTOFF32 35 /* 32 bit offset from GOT to PLT. */ +#define R_390_PLTOFF64 36 /* 16 bit offset from GOT to PLT. */ +#define R_390_TLS_LOAD 37 /* Tag for load insn in TLS code. */ +#define R_390_TLS_GDCALL 38 /* Tag for function call in general + dynamic TLS code. */ +#define R_390_TLS_LDCALL 39 /* Tag for function call in local + dynamic TLS code. */ +#define R_390_TLS_GD32 40 /* Direct 32 bit for general dynamic + thread local data. */ +#define R_390_TLS_GD64 41 /* Direct 64 bit for general dynamic + thread local data. */ +#define R_390_TLS_GOTIE12 42 /* 12 bit GOT offset for static TLS + block offset. */ +#define R_390_TLS_GOTIE32 43 /* 32 bit GOT offset for static TLS + block offset. */ +#define R_390_TLS_GOTIE64 44 /* 64 bit GOT offset for static TLS + block offset. */ +#define R_390_TLS_LDM32 45 /* Direct 32 bit for local dynamic + thread local data in LE code. */ +#define R_390_TLS_LDM64 46 /* Direct 64 bit for local dynamic + thread local data in LE code. */ +#define R_390_TLS_IE32 47 /* 32 bit address of GOT entry for + negated static TLS block offset. */ +#define R_390_TLS_IE64 48 /* 64 bit address of GOT entry for + negated static TLS block offset. */ +#define R_390_TLS_IEENT 49 /* 32 bit rel. offset to GOT entry for + negated static TLS block offset. */ +#define R_390_TLS_LE32 50 /* 32 bit negated offset relative to + static TLS block. */ +#define R_390_TLS_LE64 51 /* 64 bit negated offset relative to + static TLS block. */ +#define R_390_TLS_LDO32 52 /* 32 bit offset relative to TLS + block. */ +#define R_390_TLS_LDO64 53 /* 64 bit offset relative to TLS + block. */ +#define R_390_TLS_DTPMOD 54 /* ID of module containing symbol. */ +#define R_390_TLS_DTPOFF 55 /* Offset in TLS block. */ +#define R_390_TLS_TPOFF 56 /* Negated offset in static TLS + block. */ +#define R_390_20 57 /* Direct 20 bit. */ +#define R_390_GOT20 58 /* 20 bit GOT offset. */ +#define R_390_GOTPLT20 59 /* 20 bit offset to jump slot. */ +#define R_390_TLS_GOTIE20 60 /* 20 bit GOT offset for static TLS + block offset. */ +/* Keep this the last entry. */ +#define R_390_NUM 61 + + +/* CRIS relocations. */ +#define R_CRIS_NONE 0 +#define R_CRIS_8 1 +#define R_CRIS_16 2 +#define R_CRIS_32 3 +#define R_CRIS_8_PCREL 4 +#define R_CRIS_16_PCREL 5 +#define R_CRIS_32_PCREL 6 +#define R_CRIS_GNU_VTINHERIT 7 +#define R_CRIS_GNU_VTENTRY 8 +#define R_CRIS_COPY 9 +#define R_CRIS_GLOB_DAT 10 +#define R_CRIS_JUMP_SLOT 11 +#define R_CRIS_RELATIVE 12 +#define R_CRIS_16_GOT 13 +#define R_CRIS_32_GOT 14 +#define R_CRIS_16_GOTPLT 15 +#define R_CRIS_32_GOTPLT 16 +#define R_CRIS_32_GOTREL 17 +#define R_CRIS_32_PLT_GOTREL 18 +#define R_CRIS_32_PLT_PCREL 19 + +#define R_CRIS_NUM 20 + + +/* AMD x86-64 relocations. */ +#define R_X86_64_NONE 0 /* No reloc */ +#define R_X86_64_64 1 /* Direct 64 bit */ +#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ +#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ +#define R_X86_64_PLT32 4 /* 32 bit PLT address */ +#define R_X86_64_COPY 5 /* Copy symbol at runtime */ +#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ +#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ +#define R_X86_64_RELATIVE 8 /* Adjust by program base */ +#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative + offset to GOT */ +#define R_X86_64_32 10 /* Direct 32 bit zero extended */ +#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ +#define R_X86_64_16 12 /* Direct 16 bit zero extended */ +#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ +#define R_X86_64_8 14 /* Direct 8 bit sign extended */ +#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ +#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */ +#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */ +#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */ +#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset + to two GOT entries for GD symbol */ +#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset + to two GOT entries for LD symbol */ +#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */ +#define R_X86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset + to GOT entry for IE symbol */ +#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */ + +#define R_X86_64_NUM 24 + + +/* AM33 relocations. */ +#define R_MN10300_NONE 0 /* No reloc. */ +#define R_MN10300_32 1 /* Direct 32 bit. */ +#define R_MN10300_16 2 /* Direct 16 bit. */ +#define R_MN10300_8 3 /* Direct 8 bit. */ +#define R_MN10300_PCREL32 4 /* PC-relative 32-bit. */ +#define R_MN10300_PCREL16 5 /* PC-relative 16-bit signed. */ +#define R_MN10300_PCREL8 6 /* PC-relative 8-bit signed. */ +#define R_MN10300_GNU_VTINHERIT 7 /* Ancient C++ vtable garbage... */ +#define R_MN10300_GNU_VTENTRY 8 /* ... collection annotation. */ +#define R_MN10300_24 9 /* Direct 24 bit. */ +#define R_MN10300_GOTPC32 10 /* 32-bit PCrel offset to GOT. */ +#define R_MN10300_GOTPC16 11 /* 16-bit PCrel offset to GOT. */ +#define R_MN10300_GOTOFF32 12 /* 32-bit offset from GOT. */ +#define R_MN10300_GOTOFF24 13 /* 24-bit offset from GOT. */ +#define R_MN10300_GOTOFF16 14 /* 16-bit offset from GOT. */ +#define R_MN10300_PLT32 15 /* 32-bit PCrel to PLT entry. */ +#define R_MN10300_PLT16 16 /* 16-bit PCrel to PLT entry. */ +#define R_MN10300_GOT32 17 /* 32-bit offset to GOT entry. */ +#define R_MN10300_GOT24 18 /* 24-bit offset to GOT entry. */ +#define R_MN10300_GOT16 19 /* 16-bit offset to GOT entry. */ +#define R_MN10300_COPY 20 /* Copy symbol at runtime. */ +#define R_MN10300_GLOB_DAT 21 /* Create GOT entry. */ +#define R_MN10300_JMP_SLOT 22 /* Create PLT entry. */ +#define R_MN10300_RELATIVE 23 /* Adjust by program base. */ + +#define R_MN10300_NUM 24 + + +/* M32R relocs. */ +#define R_M32R_NONE 0 /* No reloc. */ +#define R_M32R_16 1 /* Direct 16 bit. */ +#define R_M32R_32 2 /* Direct 32 bit. */ +#define R_M32R_24 3 /* Direct 24 bit. */ +#define R_M32R_10_PCREL 4 /* PC relative 10 bit shifted. */ +#define R_M32R_18_PCREL 5 /* PC relative 18 bit shifted. */ +#define R_M32R_26_PCREL 6 /* PC relative 26 bit shifted. */ +#define R_M32R_HI16_ULO 7 /* High 16 bit with unsigned low. */ +#define R_M32R_HI16_SLO 8 /* High 16 bit with signed low. */ +#define R_M32R_LO16 9 /* Low 16 bit. */ +#define R_M32R_SDA16 10 /* 16 bit offset in SDA. */ +#define R_M32R_GNU_VTINHERIT 11 +#define R_M32R_GNU_VTENTRY 12 +/* M32R relocs use SHT_RELA. */ +#define R_M32R_16_RELA 33 /* Direct 16 bit. */ +#define R_M32R_32_RELA 34 /* Direct 32 bit. */ +#define R_M32R_24_RELA 35 /* Direct 24 bit. */ +#define R_M32R_10_PCREL_RELA 36 /* PC relative 10 bit shifted. */ +#define R_M32R_18_PCREL_RELA 37 /* PC relative 18 bit shifted. */ +#define R_M32R_26_PCREL_RELA 38 /* PC relative 26 bit shifted. */ +#define R_M32R_HI16_ULO_RELA 39 /* High 16 bit with unsigned low */ +#define R_M32R_HI16_SLO_RELA 40 /* High 16 bit with signed low */ +#define R_M32R_LO16_RELA 41 /* Low 16 bit */ +#define R_M32R_SDA16_RELA 42 /* 16 bit offset in SDA */ +#define R_M32R_RELA_GNU_VTINHERIT 43 +#define R_M32R_RELA_GNU_VTENTRY 44 + +#define R_M32R_GOT24 48 /* 24 bit GOT entry */ +#define R_M32R_26_PLTREL 49 /* 26 bit PC relative to PLT shifted */ +#define R_M32R_COPY 50 /* Copy symbol at runtime */ +#define R_M32R_GLOB_DAT 51 /* Create GOT entry */ +#define R_M32R_JMP_SLOT 52 /* Create PLT entry */ +#define R_M32R_RELATIVE 53 /* Adjust by program base */ +#define R_M32R_GOTOFF 54 /* 24 bit offset to GOT */ +#define R_M32R_GOTPC24 55 /* 24 bit PC relative offset to GOT */ +#define R_M32R_GOT16_HI_ULO 56 /* High 16 bit GOT entry with unsigned + low */ +#define R_M32R_GOT16_HI_SLO 57 /* High 16 bit GOT entry with signed + low */ +#define R_M32R_GOT16_LO 58 /* Low 16 bit GOT entry */ +#define R_M32R_GOTPC_HI_ULO 59 /* High 16 bit PC relative offset to + GOT with unsigned low */ +#define R_M32R_GOTPC_HI_SLO 60 /* High 16 bit PC relative offset to + GOT with signed low */ +#define R_M32R_GOTPC_LO 61 /* Low 16 bit PC relative offset to + GOT */ +#define R_M32R_GOTOFF_HI_ULO 62 /* High 16 bit offset to GOT + with unsigned low */ +#define R_M32R_GOTOFF_HI_SLO 63 /* High 16 bit offset to GOT + with signed low */ +#define R_M32R_GOTOFF_LO 64 /* Low 16 bit offset to GOT */ +#define R_M32R_NUM 256 /* Keep this the last entry. */ + + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + long ru_maxrss; /* maximum resident set size */ + long ru_ixrss; /* integral shared memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary context switches */ +}; + +/** OpenBSD only ? for getdirentries **/ + +#define MAXNAMLEN 255 +struct bsd_dirent { + uint32_t d_fileno; + uint16_t d_reclen; + uint8_t d_type; + uint8_t d_namlen; + char d_name[MAXNAMLEN + 1]; +}; + +/* semop system calls takes an array of these. */ +struct sembuf { + unsigned short sem_num; /* semaphore index in array */ + short sem_op; /* semaphore operation */ + short sem_flg; /* operation flags */ +}; + diff --git a/dest/include/librz/sflib/darwin-arm-64/sflib.h b/dest/include/librz/sflib/darwin-arm-64/sflib.h new file mode 100644 index 00000000000..4eccee4257e --- /dev/null +++ b/dest/include/librz/sflib/darwin-arm-64/sflib.h @@ -0,0 +1,213 @@ +// SPDX-FileCopyrightText: 2004 Philippe Biondi +// SPDX-License-Identifier: LGPL-2.1-only + +/* + * sflib.h --- SFLib syscall library for OpenBSD/i386 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +/* + * Automatically generated by gensflib.py + * Fri Nov 25 15:52:34 2011 + */ + +#ifndef SFLIB_H +#define SFLIB_H + +#include "sfsysnr.h" +#include "sfsyscall.h" +#include "../common/sftypes.h" + +// syscall +static inline _sfsyscall1(void, exit, int, status) +static inline _sfsyscall0(pid_t, fork) +static inline _sfsyscall3(ssize_t, read, int, fd, void *, buf, size_t, count) +static inline _sfsyscall3(ssize_t, write, int, fd, const void *, buf, size_t, count) +static inline _sfsyscall3(int, open, const char *, pathname, int, flags, mode_t, mode) +static inline _sfsyscall1(int, close, int, fd) +static inline _sfsyscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, struct rusage *, rusage) +static inline _sfsyscall2(int, link, const char *, oldpath, const char *, newpath) +static inline _sfsyscall1(int, unlink, const char *, pathname) +static inline _sfsyscall1(int, chdir, const char *, path) +// fchdir +static inline _sfsyscall3(int, mknod, const char *, pathname, mode_t, mode, dev_t, dev) +static inline _sfsyscall2(int, chmod, const char *, path, mode_t, mode) +static inline _sfsyscall3(int, chown, const char *, path, uid_t, owner, gid_t, group) +// break +static inline _sfsyscall0(pid_t, getpid) +// mount +// unmount +// setuid +static inline _sfsyscall1(int, setuid, uid_t, uid) +static inline _sfsyscall1(int, setgid, gid_t, gid) +static inline _sfsyscall0(uid_t, getuid) +static inline _sfsyscall0(uid_t, geteuid) +static inline _sfsyscall4(long, ptrace, int, request, pid_t, pid, void *, addr, void *, data) +// recvmsg +// sendmsg +static inline _sfsyscall6(ssize_t, recvfrom, int, s, void *, buf, size_t, len, int, flags, struct sockaddr *, from, socklen_t *, fromlen) +static inline _sfsyscall3(int, accept, int, s, struct sockaddr *, addr, socklen_t *, addrlen); +// getpeername +// getsockname +static inline _sfsyscall2(int, access, const char *, pathname, int, mode) +// chflags +// fchflags +static inline _sfsyscall0(int, sync) +static inline _sfsyscall2(int, kill, pid_t, pid, int, sig) +static inline _sfsyscall0(pid_t, getppid) +static inline _sfsyscall1(int, dup, int, oldfd) +// opipe +static inline _sfsyscall0(gid_t, getegid) +// profil +// ktrace +// sigaction +static inline _sfsyscall0(gid_t, getgid) +// sigprocmask +// getlogin +// setlogin +static inline _sfsyscall1(int, acct, const char *, filename) +static inline _sfsyscall1(int, sigpending, sigset_t *, set) +// sigaltstack +static inline _sfsyscall4(int, ioctl, int, d, int, request, char *, argp, int, len) +// reboot +// revoke +static inline _sfsyscall2(int, symlink, const char *, oldpath, const char *, newpath) +static inline _sfsyscall3(int, readlink, const char *, path, char *, buf, size_t, bufsiz) +static inline _sfsyscall3(int, execve, char *, s, char **, argv, char **, envp) +static inline _sfsyscall1(mode_t, umask, mode_t, mask) +static inline _sfsyscall1(int, chroot, const char *, path) +// omsync +static inline _sfsyscall0(pid_t, vfork) +// sbrk +// sstk +// vadvise +static inline _sfsyscall2(int, munmap, void *, start, size_t, length) +static inline _sfsyscall3(int, mprotect, const void *, addr, size_t, len, int, prot) +// madvise +// mincore +// getgroups +static inline _sfsyscall2(int, setgroups, size_t, size, const gid_t *, list) +static inline _sfsyscall0(pid_t, getpgrp) +static inline _sfsyscall2(int, setpgid, pid_t, pid, pid_t, pgid) +// setitimer +static inline _sfsyscall2(int, swapon, const char *, path, int, swapflags) +// getitimer +static inline _sfsyscall2(int, dup2, int, oldfd, int, newfd) +static inline _sfsyscall3(int, fcntl, int, fd, int, cmd, long, arg) +static inline _sfsyscall5(int, select, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout) +static inline _sfsyscall1(int, fsync, int, fd) +static inline _sfsyscall3(int, setpriority, int, which, int, who, int, prio) +static inline _sfsyscall3(int, socket, int, domain, int, type, int, protocol) +static inline _sfsyscall3(int, connect, int, sockfd, const struct sockaddr *, serv_addr, socklen_t, addrlen) +static inline _sfsyscall2(int, getpriority, int, which, int, who) +static inline _sfsyscall1(int, sigreturn, unsigned long, __unused) +static inline _sfsyscall3(int, bind, int, sockfd, struct sockaddr *, my_addr, socklen_t, addrlen) +static inline _sfsyscall5(int, setsockopt, int, s, int, level, int, optname, void *, optval, socklen_t, optlen) +static inline _sfsyscall2(int, listen, int, s, int, backlog) +static inline _sfsyscall1(int, sigsuspend, const sigset_t *, mask) +static inline _sfsyscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz) +// getrusage +// getsockopt +static inline _sfsyscall3(int, readv, int, fd, const struct iovec *, vector, int, count) +static inline _sfsyscall3(int, writev, int, fd, const struct iovec *, vector, int, count) +// settimeofday +static inline _sfsyscall3(int, fchown, int, fd, uid_t, owner, gid_t, group) +static inline _sfsyscall2(int, fchmod, int, fildes, mode_t, mode) +static inline _sfsyscall2(int, rename, const char *, oldpath, const char *, newpath) +// flock +// mkfifo +static inline _sfsyscall6(ssize_t, sendto, int, s, const void *, msg, size_t, len, int, flags, const struct sockaddr *, to, socklen_t, tolen) +// shutdown +// socketpair +static inline _sfsyscall2(int, mkdir, const char *, pathname, mode_t, mode) +static inline _sfsyscall1(int, rmdir, const char *, pathname) +// utimes +// adjtime +static inline _sfsyscall0(pid_t, setsid) +// quotactl +// nfssvc +// getfh +// sysarch +static inline _sfsyscall4(ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset) +// pwrite +// setgid +// setegid +// seteuid +// lfs_bmapv +// lfs_markv +// lfs_segclean +// lfs_segwait +static inline _sfsyscall2(int, stat, const char *, file_name, struct stat *, buf) +static inline _sfsyscall2(int, fstat, int, filedes, struct stat *, buf) +static inline _sfsyscall2(int, lstat, const char *, file_name, struct stat *, buf) +// pathconf +// fpathconf +// swapctl +// getrlimit +// setrlimit +static inline _sfsyscall4(int, getdirentries, int, fd, void *, buf, int, nbytes, long *, basep) +static inline _sfsyscall6(void *, mmap, void *, start, size_t, length, int, prot, int, flags, int, fd, off_t, offset) +static inline _sfsyscall3(off_t, lseek, int, fildes, off_t, offset, int, whence) +static inline _sfsyscall2(int, truncate, const char *, path, off_t, length) +static inline _sfsyscall2(int, ftruncate, int, fd, off_t, length) +static inline _sfsyscall2(int, mlock, const void *, addr, size_t, len) +static inline _sfsyscall2(int, munlock, const void *, addr, size_t, len) +// undelete +// futimes +static inline _sfsyscall1(pid_t, getpgid, pid_t, pid) +// xfspioctl +static inline _sfsyscall3(int, semget, long, key, int, nsems, int, semflg) +static inline _sfsyscall3(int, semop, int, semid, struct sembuf *, sops, unsigned, nsops) +// msgget +// msgsnd +// msgrcv +static inline _sfsyscall3(void *, shmat, int, shmid, const void *, shmaddr, int, shmflg) +// shmdt +static inline _sfsyscall3(int, shmget, long, key, int, size, int, flags) +// clock_gettime +// clock_settime +// clock_getres +static inline _sfsyscall2(int, nanosleep, const struct timespec *, req, struct timespec *, rem) +// minherit +// rfork +static inline _sfsyscall3(int, poll, struct pollfd *, ufds, unsigned int, nfds, int, timeout) +// issetugid +static inline _sfsyscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group) +static inline _sfsyscall1(pid_t, getsid, pid_t, pid) +static inline _sfsyscall3(int, msync, const void *, start, size_t, length, int, flags) +// shmctl +// msgctl +// getfsstat +static inline _sfsyscall2(int, statfs, const char *, path, struct statfs *, buf) +static inline _sfsyscall2(int, fstatfs, int, fd, struct statfs *, buf) +static inline _sfsyscall1(int, pipe, unsigned long *, filedes) +// fhopen +// fhstat +// fhstatfs +// preadv +// pwritev +// kqueue +// kevent +static inline _sfsyscall1(int, mlockall, int, flags) +static inline _sfsyscall0(int, munlockall) +// getpeereid +// extattrctl +// extattr_set_file +// extattr_get_file +// extattr_delete_file +// extattr_set_fd +// extattr_get_fd +// extattr_delete_fd + +#endif /* SFLIB_H */ \ No newline at end of file diff --git a/dest/include/librz/sflib/darwin-arm-64/sfsyscall.h b/dest/include/librz/sflib/darwin-arm-64/sfsyscall.h new file mode 100644 index 00000000000..50d5189dfd5 --- /dev/null +++ b/dest/include/librz/sflib/darwin-arm-64/sfsyscall.h @@ -0,0 +1,158 @@ +// SPDX-FileCopyrightText: 2004 Philippe Biondi +// SPDX-License-Identifier: LGPL-2.1-only + +// ssed on the registers rdi, rsi, rdx, r10, r8 and r9 +/* + * sfsyscall.h --- SFLib syscall macros for OpenBSD/i386 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +#ifndef SFSYSCALL_H +#define SFSYSCALL_H + +#ifdef SF_USE_ERRNO +/* Remove errno stuff */ +int errno; +#error "SF_USER_ERRNO not supported yet" +#else +#define __sfsyscall_return(type, res) \ + do { \ + return (type)(res); \ + } while (0) +#endif + +/* syscall macros */ +// x16 holds syscallnumber + +#define _sfsyscall0(type, name) \ + type name(void) { \ + long __res; \ + __asm__ volatile( \ + "movz x16, %1\n" \ + "svc 0x80" \ + : "=r"(__res) \ + : "K"(__NR_##name)); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall1(type, name, type1, arg1) \ + type name(type1 arg1) { \ + long __res; \ + __asm__ volatile( \ + "movz x16, %1\n" \ + "ldr x0, %2\n\t" \ + "svc 0x80\n\t" \ + : "=r"(__res) \ + : "g"(__NR_##name), "g"((long)(arg1))); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall2(type, name, type1, arg1, type2, arg2) \ + type name(type1 arg1, type2 arg2) { \ + long __res; \ + __asm__ volatile( \ + "ldr x0, %2\n\t" \ + "ldr x1, %3\n\t" \ + "mov x16, %1\n\t" \ + "svc 0x80\n\t" \ + : "=r"(__res) \ + : "I"(__NR_##name), "g"((long)(arg1)), "g"((long)(arg2))); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall3ipi(type, name, type1, arg1, type2, arg2, type3, arg3) \ + type name(type1 arg1, type2 arg2, type3 arg3) { \ + long __res; \ + __asm__ volatile( \ + "movz x0, %2\n\t" \ + "ldr x1, %3\n\t" \ + "mov x2, %4\n\t" \ + "mov x16, %1\n\t" \ + "svc 0x80\n\t" \ + : "=r"(__res) \ + : "S"(__NR_##name), \ + "r"(arg1), \ + "S"(arg2), \ + "g"((long)(arg3))); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ + type name(type1 arg1, type2 arg2, type3 arg3) { \ + long __res; \ + __asm__ volatile( \ + "movz x0, %2\n\t" \ + "ldr x1, %3\n\t" \ + "movz x2, %4\n\t" \ + "ldr x16, %1\n\t" \ + "svc 0x80\n\t" \ + : "=r"(__res) \ + : "I"(__NR_##name), "g"((long)(arg1)), "g"((long)(arg2)), \ + "g"((long)(arg3))); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall4(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ + long __res; \ + __asm__ volatile( \ + "mov x0, %2\n\t" \ + "mov x1, %3\n\t" \ + "mov x2, %4\n\t" \ + "mov x3, %5\n\t" \ + "mov x16, %1\n\t" \ + "svc 0x80\n\t" \ + : "=r"(__res) \ + : "I"(__NR_##name), "g"((long)(arg1)), "r"((long)(arg2)), \ + "r"((long)(arg3)), "S"((long)(arg4))); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall5(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, \ + type5, arg5) \ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \ + long __res; \ + __asm__ volatile("mov x0, %2\n\t" \ + "mov x1, %3\n\t" \ + "mov x2, %4\n\t" \ + "mov x3, %5\n\t" \ + "mov x4, %6\n\t" \ + "mov x16, %1\n\t" \ + "svc 0x80\n\t" \ + : "=r"(__res) \ + : "I"(__NR_##name), "g"((long)(arg1)), "g"((long)(arg2)), \ + "g"((long)(arg3)), "g"((long)(arg4)), "g"((long)(arg5))); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall6(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, \ + type5, arg5, type6, arg6) \ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) { \ + long __res; \ + __asm__ volatile("mov x0, %2\n\t" \ + "mov x1, %3\n\t" \ + "mov x2, %4\n\t" \ + "mov x3, %5\n\t" \ + "mov x4, %6\n\t" \ + "mov x5, %7\n\t" \ + "mov x16, %1\n\t" \ + "svc 0x80\n\t" \ + : "=r"(__res) \ + : "I"(__NR_##name), "g"((long)(arg1)), "g"((long)(arg2)), \ + "g"((long)(arg3)), "g"((long)(arg4)), "g"((long)(arg5)), \ + "g"((long)(arg6))); \ + __sfsyscall_return(type, __res); \ + } + +#endif /* SFSYSCALL_H */ diff --git a/dest/include/librz/sflib/darwin-arm-64/sfsysnr.h b/dest/include/librz/sflib/darwin-arm-64/sfsysnr.h new file mode 100644 index 00000000000..d79908709b5 --- /dev/null +++ b/dest/include/librz/sflib/darwin-arm-64/sfsysnr.h @@ -0,0 +1,684 @@ +// SPDX-FileCopyrightText: 2004 Philippe Biondi +// SPDX-License-Identifier: LGPL-2.1-only + +/* + * sfsysnr.h --- SFLib syscall numbers for OpenBSD/i386 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +/* + * Automatically generated by gensflib.py + * Fri Nov 25 15:52:34 2011 + */ + +#ifndef SFSYSNR_H +#define SFSYSNR_H + +/* $Id$ */ + +/* + * Modified from /usr/include/sys/syscall.h + * created from OpenBSD: syscalls.master,v 1.50 2002/07/06 19:14:20 nordin Exp + */ + +/* syscall: "syscall" ret: "int" args: "int" "..." */ +#define __NR_syscall 0 + +/* syscall: "exit" ret: "void" args: "int" */ +#define __NR_exit 1 + +/* syscall: "fork" ret: "int" args: */ +#define __NR_fork 2 + +/* syscall: "read" ret: "ssize_t" args: "int" "void *" "size_t" */ +#define __NR_read 3 + +/* syscall: "write" ret: "ssize_t" args: "int" "const void *" "size_t" */ +#define __NR_write 4 + +/* syscall: "open" ret: "int" args: "const char *" "int" "..." */ +#define __NR_open 5 + +/* syscall: "close" ret: "int" args: "int" */ +#define __NR_close 6 + +/* syscall: "wait4" ret: "int" args: "int" "int *" "int" "struct rusage *" */ +#define __NR_wait4 7 + +/* 8 is compat_43 ocreat */ + +/* syscall: "link" ret: "int" args: "const char *" "const char *" */ +#define __NR_link 9 + +/* syscall: "unlink" ret: "int" args: "const char *" */ +#define __NR_unlink 10 + +/* 11 is obsolete execv */ +/* syscall: "chdir" ret: "int" args: "const char *" */ +#define __NR_chdir 12 + +/* syscall: "fchdir" ret: "int" args: "int" */ +#define __NR_fchdir 13 + +/* syscall: "mknod" ret: "int" args: "const char *" "int" "dev_t" */ +#define __NR_mknod 14 + +/* syscall: "chmod" ret: "int" args: "const char *" "int" */ +#define __NR_chmod 15 + +/* syscall: "chown" ret: "int" args: "const char *" "uid_t" "gid_t" */ +#define __NR_chown 16 + +/* syscall: "break" ret: "int" args: "char *" */ +#define __NR_break 17 + +/* 18 is compat_25 ogetfsstat */ + +/* 19 is compat_43 olseek */ + +/* syscall: "getpid" ret: "pid_t" args: */ +#define __NR_getpid 20 + +/* syscall: "mount" ret: "int" args: "const char *" "const char *" "int" "void *" */ +#define __NR_mount 21 + +/* syscall: "unmount" ret: "int" args: "const char *" "int" */ +#define __NR_unmount 22 + +/* syscall: "setuid" ret: "int" args: "uid_t" */ +#define __NR_setuid 23 + +/* syscall: "getuid" ret: "uid_t" args: */ +#define __NR_getuid 24 + +/* syscall: "geteuid" ret: "uid_t" args: */ +#define __NR_geteuid 25 + +/* syscall: "ptrace" ret: "int" args: "int" "pid_t" "caddr_t" "int" */ +#define __NR_ptrace 26 + +/* syscall: "recvmsg" ret: "ssize_t" args: "int" "struct msghdr *" "int" */ +#define __NR_recvmsg 27 + +/* syscall: "sendmsg" ret: "ssize_t" args: "int" "const struct msghdr *" "int" */ +#define __NR_sendmsg 28 + +/* syscall: "recvfrom" ret: "ssize_t" args: "int" "void *" "size_t" "int" "struct sockaddr *" "socklen_t *" */ +#define __NR_recvfrom 29 + +/* syscall: "accept" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ +#define __NR_accept 30 + +/* syscall: "getpeername" ret: "int" args: "int" "struct sockaddr *" "int *" */ +#define __NR_getpeername 31 + +/* syscall: "getsockname" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ +#define __NR_getsockname 32 + +/* syscall: "access" ret: "int" args: "const char *" "int" */ +#define __NR_access 33 + +/* syscall: "chflags" ret: "int" args: "const char *" "u_int" */ +#define __NR_chflags 34 + +/* syscall: "fchflags" ret: "int" args: "int" "u_int" */ +#define __NR_fchflags 35 + +/* syscall: "sync" ret: "void" args: */ +#define __NR_sync 36 + +/* syscall: "kill" ret: "int" args: "int" "int" */ +#define __NR_kill 37 + +/* 38 is compat_43 ostat */ + +/* syscall: "getppid" ret: "pid_t" args: */ +#define __NR_getppid 39 + +/* 40 is compat_43 olstat */ + +/* syscall: "dup" ret: "int" args: "int" */ +#define __NR_dup 41 + +/* syscall: "opipe" ret: "int" args: */ +#define __NR_opipe 42 + +/* syscall: "getegid" ret: "gid_t" args: */ +#define __NR_getegid 43 + +/* syscall: "profil" ret: "int" args: "caddr_t" "size_t" "u_long" "u_int" */ +#define __NR_profil 44 + +/* syscall: "ktrace" ret: "int" args: "const char *" "int" "int" "pid_t" */ +#define __NR_ktrace 45 + +/* syscall: "sigaction" ret: "int" args: "int" "const struct sigaction *" "struct sigaction *" */ +#define __NR_sigaction 46 + +/* syscall: "getgid" ret: "gid_t" args: */ +#define __NR_getgid 47 + +/* syscall: "sigprocmask" ret: "int" args: "int" "sigset_t" */ +#define __NR_sigprocmask 48 + +/* syscall: "getlogin" ret: "int" args: "char *" "u_int" */ +#define __NR_getlogin 49 + +/* syscall: "setlogin" ret: "int" args: "const char *" */ +#define __NR_setlogin 50 + +/* syscall: "acct" ret: "int" args: "const char *" */ +#define __NR_acct 51 + +/* syscall: "sigpending" ret: "int" args: */ +#define __NR_sigpending 52 + +/* syscall: "sigaltstack" ret: "int" args: "const struct sigaltstack *" "struct sigaltstack *" */ +#define __NR_sigaltstack 53 + +/* syscall: "ioctl" ret: "int" args: "int" "u_long" "..." */ +#define __NR_ioctl 54 + +/* syscall: "reboot" ret: "int" args: "int" */ +#define __NR_reboot 55 + +/* syscall: "revoke" ret: "int" args: "const char *" */ +#define __NR_revoke 56 + +/* syscall: "symlink" ret: "int" args: "const char *" "const char *" */ +#define __NR_symlink 57 + +/* syscall: "readlink" ret: "int" args: "const char *" "char *" "size_t" */ +#define __NR_readlink 58 + +/* syscall: "execve" ret: "int" args: "const char *" "char *const *" "char *const *" */ +#define __NR_execve 59 + +/* syscall: "umask" ret: "int" args: "int" */ +#define __NR_umask 60 + +/* syscall: "chroot" ret: "int" args: "const char *" */ +#define __NR_chroot 61 + +/* 62 is compat_43 ofstat */ + +/* 63 is compat_43 ogetkerninfo */ + +/* 64 is compat_43 ogetpagesize */ + +/* syscall: "omsync" ret: "int" args: "caddr_t" "size_t" */ +#define __NR_omsync 65 + +/* syscall: "vfork" ret: "int" args: */ +#define __NR_vfork 66 + +/* 67 is obsolete vread */ +/* 68 is obsolete vwrite */ +/* syscall: "sbrk" ret: "int" args: "int" */ +#define __NR_sbrk 69 + +/* syscall: "sstk" ret: "int" args: "int" */ +#define __NR_sstk 70 + +/* 71 is compat_43 ommap */ + +/* syscall: "vadvise" ret: "int" args: "int" */ +#define __NR_vadvise 72 + +/* syscall: "munmap" ret: "int" args: "void *" "size_t" */ +#define __NR_munmap 73 + +/* syscall: "mprotect" ret: "int" args: "void *" "size_t" "int" */ +#define __NR_mprotect 74 + +/* syscall: "madvise" ret: "int" args: "void *" "size_t" "int" */ +#define __NR_madvise 75 + +/* 76 is obsolete vhangup */ +/* 77 is obsolete vlimit */ +/* syscall: "mincore" ret: "int" args: "void *" "size_t" "char *" */ +#define __NR_mincore 78 + +/* syscall: "getgroups" ret: "int" args: "int" "gid_t *" */ +#define __NR_getgroups 79 + +/* syscall: "setgroups" ret: "int" args: "int" "const gid_t *" */ +#define __NR_setgroups 80 + +/* syscall: "getpgrp" ret: "int" args: */ +#define __NR_getpgrp 81 + +/* syscall: "setpgid" ret: "int" args: "pid_t" "int" */ +#define __NR_setpgid 82 + +/* syscall: "setitimer" ret: "int" args: "int" "const struct itimerval *" "struct itimerval *" */ +#define __NR_setitimer 83 + +/* 84 is compat_43 owait */ + +/* syscall: "swapon" ret: "int" args: "const char *" */ +#define __NR_swapon 85 + +/* syscall: "getitimer" ret: "int" args: "int" "struct itimerval *" */ +#define __NR_getitimer 86 + +/* 87 is compat_43 ogethostname */ + +/* 88 is compat_43 osethostname */ + +/* 89 is compat_43 ogetdtablesize */ + +/* syscall: "dup2" ret: "int" args: "int" "int" */ +#define __NR_dup2 90 + +/* syscall: "fcntl" ret: "int" args: "int" "int" "..." */ +#define __NR_fcntl 92 + +/* syscall: "select" ret: "int" args: "int" "fd_set *" "fd_set *" "fd_set *" "struct timeval *" */ +#define __NR_select 93 + +/* syscall: "fsync" ret: "int" args: "int" */ +#define __NR_fsync 95 + +/* syscall: "setpriority" ret: "int" args: "int" "int" "int" */ +#define __NR_setpriority 96 + +/* syscall: "socket" ret: "int" args: "int" "int" "int" */ +#define __NR_socket 97 + +/* syscall: "connect" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */ +#define __NR_connect 98 + +/* 99 is compat_43 oaccept */ + +/* syscall: "getpriority" ret: "int" args: "int" "int" */ +#define __NR_getpriority 100 + +/* 101 is compat_43 osend */ + +/* 102 is compat_43 orecv */ + +/* syscall: "sigreturn" ret: "int" args: "struct sigcontext *" */ +#define __NR_sigreturn 103 + +/* syscall: "bind" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */ +#define __NR_bind 104 + +/* syscall: "setsockopt" ret: "int" args: "int" "int" "int" "const void *" "socklen_t" */ +#define __NR_setsockopt 105 + +/* syscall: "listen" ret: "int" args: "int" "int" */ +#define __NR_listen 106 + +/* 107 is obsolete vtimes */ +/* 108 is compat_43 osigvec */ + +/* 109 is compat_43 osigblock */ + +/* 110 is compat_43 osigsetmask */ + +/* syscall: "sigsuspend" ret: "int" args: "int" */ +#define __NR_sigsuspend 111 + +/* 112 is compat_43 osigstack */ + +/* 113 is compat_43 orecvmsg */ + +/* 114 is compat_43 osendmsg */ + +/* 115 is obsolete vtrace */ +/* syscall: "gettimeofday" ret: "int" args: "struct timeval *" "struct timezone *" */ +#define __NR_gettimeofday 116 + +/* syscall: "getrusage" ret: "int" args: "int" "struct rusage *" */ +#define __NR_getrusage 117 + +/* syscall: "getsockopt" ret: "int" args: "int" "int" "int" "void *" "socklen_t *" */ +#define __NR_getsockopt 118 + +/* 119 is obsolete resuba */ +/* syscall: "readv" ret: "ssize_t" args: "int" "const struct iovec *" "int" */ +#define __NR_readv 120 + +/* syscall: "writev" ret: "ssize_t" args: "int" "const struct iovec *" "int" */ +#define __NR_writev 121 + +/* syscall: "settimeofday" ret: "int" args: "const struct timeval *" "const struct timezone *" */ +#define __NR_settimeofday 122 + +/* syscall: "fchown" ret: "int" args: "int" "uid_t" "gid_t" */ +#define __NR_fchown 123 + +/* syscall: "fchmod" ret: "int" args: "int" "int" */ +#define __NR_fchmod 124 + +/* 125 is compat_43 orecvfrom */ + +/* 126 is compat_43 osetreuid */ + +/* 127 is compat_43 osetregid */ + +/* syscall: "rename" ret: "int" args: "const char *" "const char *" */ +#define __NR_rename 128 + +/* 129 is compat_43 otruncate */ + +/* 130 is compat_43 oftruncate */ + +/* syscall: "flock" ret: "int" args: "int" "int" */ +#define __NR_flock 131 + +/* syscall: "mkfifo" ret: "int" args: "const char *" "int" */ +#define __NR_mkfifo 132 + +/* syscall: "sendto" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "const struct sockaddr *" "socklen_t" */ +#define __NR_sendto 133 + +/* syscall: "shutdown" ret: "int" args: "int" "int" */ +#define __NR_shutdown 134 + +/* syscall: "socketpair" ret: "int" args: "int" "int" "int" "int *" */ +#define __NR_socketpair 135 + +/* syscall: "mkdir" ret: "int" args: "const char *" "int" */ +#define __NR_mkdir 136 + +/* syscall: "rmdir" ret: "int" args: "const char *" */ +#define __NR_rmdir 137 + +/* syscall: "utimes" ret: "int" args: "const char *" "const struct timeval *" */ +#define __NR_utimes 138 + +/* 139 is obsolete 4.2 sigreturn */ +/* syscall: "adjtime" ret: "int" args: "const struct timeval *" "struct timeval *" */ +#define __NR_adjtime 140 + +/* 141 is compat_43 ogetpeername */ + +/* 142 is compat_43 ogethostid */ + +/* 143 is compat_43 osethostid */ + +/* 144 is compat_43 ogetrlimit */ + +/* 145 is compat_43 osetrlimit */ + +/* 146 is compat_43 okillpg */ + +/* syscall: "setsid" ret: "int" args: */ +#define __NR_setsid 147 + +/* syscall: "quotactl" ret: "int" args: "const char *" "int" "int" "char *" */ +#define __NR_quotactl 148 + +/* 149 is compat_43 oquota */ + +/* 150 is compat_43 ogetsockname */ + +/* syscall: "nfssvc" ret: "int" args: "int" "void *" */ +#define __NR_nfssvc 155 + +/* 156 is compat_43 ogetdirentries */ + +/* 157 is compat_25 ostatfs */ + +/* 158 is compat_25 ostatfs */ + +/* syscall: "getfh" ret: "int" args: "const char *" "fhandle_t *" */ +#define __NR_getfh 161 + +/* 162 is compat_09 ogetdomainname */ + +/* 163 is compat_09 osetdomainname */ + +/* 164 is compat_09 ouname */ + +/* syscall: "sysarch" ret: "int" args: "int" "void *" */ +#define __NR_sysarch 165 + +/* 169 is compat_10 osemsys */ + +/* 170 is compat_10 omsgsys */ + +/* 171 is compat_10 oshmsys */ + +/* syscall: "pread" ret: "ssize_t" args: "int" "void *" "size_t" "int" "off_t" */ +#define __NR_pread 173 + +/* syscall: "pwrite" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "off_t" */ +#define __NR_pwrite 174 + +/* syscall: "setgid" ret: "int" args: "gid_t" */ +#define __NR_setgid 181 + +/* syscall: "setegid" ret: "int" args: "gid_t" */ +#define __NR_setegid 182 + +/* syscall: "seteuid" ret: "int" args: "uid_t" */ +#define __NR_seteuid 183 + +/* syscall: "lfs_bmapv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */ +#define __NR_lfs_bmapv 184 + +/* syscall: "lfs_markv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */ +#define __NR_lfs_markv 185 + +/* syscall: "lfs_segclean" ret: "int" args: "fsid_t *" "u_long" */ +#define __NR_lfs_segclean 186 + +/* syscall: "lfs_segwait" ret: "int" args: "fsid_t *" "struct timeval *" */ +#define __NR_lfs_segwait 187 + +/* syscall: "stat" ret: "int" args: "const char *" "struct stat *" */ +#define __NR_stat 188 + +/* syscall: "fstat" ret: "int" args: "int" "struct stat *" */ +#define __NR_fstat 189 + +/* syscall: "lstat" ret: "int" args: "const char *" "struct stat *" */ +#define __NR_lstat 190 + +/* syscall: "pathconf" ret: "long" args: "const char *" "int" */ +#define __NR_pathconf 191 + +/* syscall: "fpathconf" ret: "long" args: "int" "int" */ +#define __NR_fpathconf 192 + +/* syscall: "swapctl" ret: "int" args: "int" "const void *" "int" */ +#define __NR_swapctl 193 + +/* syscall: "getrlimit" ret: "int" args: "int" "struct rlimit *" */ +#define __NR_getrlimit 194 + +/* syscall: "setrlimit" ret: "int" args: "int" "const struct rlimit *" */ +#define __NR_setrlimit 195 + +/* syscall: "getdirentries" ret: "int" args: "int" "char *" "int" "long *" */ +#define __NR_getdirentries 196 + +/* syscall: "mmap" ret: "void *" args: "void *" "size_t" "int" "int" "int" "long" "off_t" */ +#define __NR_mmap 197 + +/* syscall: "__syscall" ret: "quad_t" args: "quad_t" "..." */ +#define __NR___syscall 198 + +/* syscall: "lseek" ret: "off_t" args: "int" "int" "off_t" "int" */ +#define __NR_lseek 199 + +/* syscall: "truncate" ret: "int" args: "const char *" "int" "off_t" */ +#define __NR_truncate 200 + +/* syscall: "ftruncate" ret: "int" args: "int" "int" "off_t" */ +#define __NR_ftruncate 201 + +/* syscall: "__sysctl" ret: "int" args: "int *" "u_int" "void *" "size_t *" "void *" "size_t" */ +#define __NR___sysctl 202 + +/* syscall: "mlock" ret: "int" args: "const void *" "size_t" */ +#define __NR_mlock 203 + +/* syscall: "munlock" ret: "int" args: "const void *" "size_t" */ +#define __NR_munlock 204 + +/* syscall: "undelete" ret: "int" args: "const char *" */ +#define __NR_undelete 205 + +/* syscall: "futimes" ret: "int" args: "int" "const struct timeval *" */ +#define __NR_futimes 206 + +/* syscall: "getpgid" ret: "pid_t" args: "pid_t" */ +#define __NR_getpgid 207 + +/* syscall: "xfspioctl" ret: "int" args: "int" "char *" "int" "struct ViceIoctl *" "int" */ +#define __NR_xfspioctl 208 + +/* 220 is compat_23 __osemctl */ + +/* syscall: "semget" ret: "int" args: "key_t" "int" "int" */ +#define __NR_semget 221 + +/* syscall: "semop" ret: "int" args: "int" "struct sembuf *" "u_int" */ +#define __NR_semop 222 + +/* 223 is obsolete sys_semconfig */ +/* 224 is compat_23 omsgctl */ + +/* syscall: "msgget" ret: "int" args: "key_t" "int" */ +#define __NR_msgget 225 + +/* syscall: "msgsnd" ret: "int" args: "int" "const void *" "size_t" "int" */ +#define __NR_msgsnd 226 + +/* syscall: "msgrcv" ret: "int" args: "int" "void *" "size_t" "long" "int" */ +#define __NR_msgrcv 227 + +/* syscall: "shmat" ret: "void *" args: "int" "const void *" "int" */ +#define __NR_shmat 228 + +/* 229 is compat_23 oshmctl */ + +/* syscall: "shmdt" ret: "int" args: "const void *" */ +#define __NR_shmdt 230 + +/* syscall: "shmget" ret: "int" args: "key_t" "int" "int" */ +#define __NR_shmget 231 + +/* syscall: "clock_gettime" ret: "int" args: "clockid_t" "struct timespec *" */ +#define __NR_clock_gettime 232 + +/* syscall: "clock_settime" ret: "int" args: "clockid_t" "const struct timespec *" */ +#define __NR_clock_settime 233 + +/* syscall: "clock_getres" ret: "int" args: "clockid_t" "struct timespec *" */ +#define __NR_clock_getres 234 + +/* syscall: "nanosleep" ret: "int" args: "const struct timespec *" "struct timespec *" */ +#define __NR_nanosleep 240 + +/* syscall: "minherit" ret: "int" args: "void *" "size_t" "int" */ +#define __NR_minherit 250 + +/* syscall: "rfork" ret: "int" args: "int" */ +#define __NR_rfork 251 + +/* syscall: "poll" ret: "int" args: "struct pollfd *" "unsigned long" "int" */ +#define __NR_poll 252 + +/* syscall: "issetugid" ret: "int" args: */ +#define __NR_issetugid 253 + +/* syscall: "lchown" ret: "int" args: "const char *" "uid_t" "gid_t" */ +#define __NR_lchown 254 + +/* syscall: "getsid" ret: "pid_t" args: "pid_t" */ +#define __NR_getsid 255 + +/* syscall: "msync" ret: "int" args: "void *" "size_t" "int" */ +#define __NR_msync 256 + +/* syscall: "__semctl" ret: "int" args: "int" "int" "int" "union semun *" */ +#define __NR___semctl 257 + +/* syscall: "shmctl" ret: "int" args: "int" "int" "struct shmid_ds *" */ +#define __NR_shmctl 258 + +/* syscall: "msgctl" ret: "int" args: "int" "int" "struct msqid_ds *" */ +#define __NR_msgctl 259 + +/* syscall: "getfsstat" ret: "int" args: "struct statfs *" "size_t" "int" */ +#define __NR_getfsstat 260 + +/* syscall: "statfs" ret: "int" args: "const char *" "struct statfs *" */ +#define __NR_statfs 261 + +/* syscall: "fstatfs" ret: "int" args: "int" "struct statfs *" */ +#define __NR_fstatfs 262 + +/* syscall: "pipe" ret: "int" args: "int *" */ +#define __NR_pipe 263 + +/* syscall: "fhopen" ret: "int" args: "const fhandle_t *" "int" */ +#define __NR_fhopen 264 + +/* syscall: "fhstat" ret: "int" args: "const fhandle_t *" "struct stat *" */ +#define __NR_fhstat 265 + +/* syscall: "fhstatfs" ret: "int" args: "const fhandle_t *" "struct statfs *" */ +#define __NR_fhstatfs 266 + +/* syscall: "preadv" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */ +#define __NR_preadv 267 + +/* syscall: "pwritev" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */ +#define __NR_pwritev 268 + +/* syscall: "kqueue" ret: "int" args: */ +#define __NR_kqueue 269 + +/* syscall: "kevent" ret: "int" args: "int" "const struct kevent *" "int" "struct kevent *" "int" "const struct timespec *" */ +#define __NR_kevent 270 + +/* syscall: "mlockall" ret: "int" args: "int" */ +#define __NR_mlockall 271 + +/* syscall: "munlockall" ret: "int" args: */ +#define __NR_munlockall 272 + +/* syscall: "getpeereid" ret: "int" args: "int" "uid_t *" "gid_t *" */ +#define __NR_getpeereid 273 + +/* syscall: "extattrctl" ret: "int" args: "const char *" "int" "const char *" "int" "const char *" */ +#define __NR_extattrctl 274 + +/* syscall: "extattr_set_file" ret: "int" args: "const char *" "int" "const char *" "void *" "size_t" */ +#define __NR_extattr_set_file 275 + +/* syscall: "extattr_get_file" ret: "ssize_t" args: "const char *" "int" "const char *" "void *" "size_t" */ +#define __NR_extattr_get_file 276 + +/* syscall: "extattr_delete_file" ret: "int" args: "const char *" "int" "const char *" */ +#define __NR_extattr_delete_file 277 + +/* syscall: "extattr_set_fd" ret: "int" args: "int" "int" "const char *" "void *" "size_t" */ +#define __NR_extattr_set_fd 278 + +/* syscall: "extattr_get_fd" ret: "ssize_t" args: "int" "int" "const char *" "void *" "size_t" */ +#define __NR_extattr_get_fd 279 + +/* syscall: "extattr_delete_fd" ret: "int" args: "int" "int" "const char *" */ +#define __NR_extattr_delete_fd 280 + +#define __NR_MAXSYSCALL 281 + +#endif /* SFSYSNR_H */ \ No newline at end of file diff --git a/dest/include/librz/sflib/darwin-x86-32/sflib.h b/dest/include/librz/sflib/darwin-x86-32/sflib.h new file mode 100644 index 00000000000..76471976878 --- /dev/null +++ b/dest/include/librz/sflib/darwin-x86-32/sflib.h @@ -0,0 +1,210 @@ +/* + * sflib.h --- SFLib syscall library for Darwin/i386 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + + +/* + * Automatically generated by gensflib.py + * Tue Apr 25 20:10:54 2023 + */ + +#ifndef SFLIB_H +#define SFLIB_H + + +#include "sfsysnr.h" +#include "sfsyscall.h" +#include "../common/sftypes.h" + +// syscall +static inline _sfsyscall1(void, exit, int, status) +static inline _sfsyscall0( pid_t, fork ) +static inline _sfsyscall3( ssize_t, read, int, fd, void *, buf, size_t, count ) +static inline _sfsyscall3( ssize_t, write, int, fd, const void *, buf, size_t, count ) +static inline _sfsyscall3( int, open, const char *, pathname, int, flags, mode_t, mode ) +static inline _sfsyscall1( int, close, int, fd ) +static inline _sfsyscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, struct rusage *, rusage) +static inline _sfsyscall2( int, link, const char *, oldpath, const char *, newpath ) +static inline _sfsyscall1( int, unlink, const char *, pathname ) +static inline _sfsyscall1( int, chdir, const char *, path ) +// fchdir +static inline _sfsyscall3( int, mknod, const char *, pathname, mode_t, mode, dev_t, dev ) +static inline _sfsyscall2( int, chmod, const char *, path, mode_t, mode ) +static inline _sfsyscall3( int, chown, const char *, path, uid_t, owner, gid_t, group ) +// break +static inline _sfsyscall0( pid_t, getpid ) +// mount +// unmount +// setuid +static inline _sfsyscall0( uid_t, getuid ) +static inline _sfsyscall0( uid_t, geteuid ) +static inline _sfsyscall4(long, ptrace, int, request, pid_t, pid, void *,addr, void *,data) +// recvmsg +// sendmsg +static inline _sfsyscall6(ssize_t, recvfrom, int, s, void * , buf, size_t, len, int, flags, struct sockaddr * , from, socklen_t * , fromlen) +static inline _sfsyscall3(int, accept, int,s, struct sockaddr *,addr, socklen_t,addrlen); +// getpeername +// getsockname +static inline _sfsyscall2( int, access, const char *, pathname, int, mode ) +// chflags +// fchflags +static inline _sfsyscall0( int, sync ) +static inline _sfsyscall2( int, kill, pid_t, pid, int, sig ) +static inline _sfsyscall0( pid_t, getppid ) +static inline _sfsyscall1( int, dup, int, oldfd ) +// opipe +static inline _sfsyscall0( gid_t, getegid ) +// profil +// ktrace +// sigaction +static inline _sfsyscall0( gid_t, getgid ) +// sigprocmask +// getlogin +// setlogin +static inline _sfsyscall1( int, acct, const char *, filename ) +static inline _sfsyscall1( int, sigpending, sigset_t *, set ) +// sigaltstack +static inline _sfsyscall4(int, ioctl, int,d, int,request, char *,argp, int,len) +// reboot +// revoke +static inline _sfsyscall2( int, symlink, const char *, oldpath, const char *, newpath ) +static inline _sfsyscall3( int, readlink, const char *, path, char *, buf, size_t, bufsiz ) +static inline _sfsyscall3(int, execve, char *, s, char **, argv, char **,envp) +static inline _sfsyscall1( mode_t, umask, mode_t, mask ) +static inline _sfsyscall1( int, chroot, const char *, path ) +// omsync +static inline _sfsyscall0( pid_t, vfork ) +// sbrk +// sstk +// vadvise +static inline _sfsyscall2( int, munmap, void *, start, size_t, length ) +static inline _sfsyscall3( int, mprotect, const void *, addr, size_t, len, int, prot ) +// madvise +// mincore +// getgroups +static inline _sfsyscall2( int, setgroups, size_t, size, const gid_t *, list ) +static inline _sfsyscall0( pid_t, getpgrp ) +static inline _sfsyscall2( int, setpgid, pid_t, pid, pid_t, pgid ) +// setitimer +static inline _sfsyscall2( int, swapon, const char *, path, int, swapflags ) +// getitimer +static inline _sfsyscall2( int, dup2, int, oldfd, int, newfd ) +static inline _sfsyscall3( int, fcntl, int, fd, int, cmd, long, arg ) +static inline _sfsyscall5( int, select, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout) +static inline _sfsyscall1( int, fsync, int, fd ) +static inline _sfsyscall3( int, setpriority, int, which, int, who, int, prio ) +static inline _sfsyscall3(int, socket, int,domain, int,type, int,protocol) +static inline _sfsyscall3(int,connect, int,sockfd, const struct sockaddr *,serv_addr, socklen_t,addrlen) +static inline _sfsyscall2( int, getpriority, int, which, int, who ) +static inline _sfsyscall1( int, sigreturn, unsigned long, __unused ) +static inline _sfsyscall3(int, bind, int,sockfd, struct sockaddr *,my_addr, socklen_t,addrlen) +static inline _sfsyscall5(int, setsockopt, int, s, int, level, int, optname, void *, optval, socklen_t, optlen) +static inline _sfsyscall2(int,listen,int,s, int,backlog) +static inline _sfsyscall1( int, sigsuspend, const sigset_t *, mask ) +static inline _sfsyscall2( int, gettimeofday, struct timeval *, tv, struct timezone *, tz ) +// getrusage +// getsockopt +static inline _sfsyscall3( int, readv, int, fd, const struct iovec *, vector, int, count ) +static inline _sfsyscall3( int, writev, int, fd, const struct iovec *, vector, int, count ) +// settimeofday +static inline _sfsyscall3( int, fchown, int, fd, uid_t, owner, gid_t, group ) +static inline _sfsyscall2( int, fchmod, int, fildes, mode_t, mode ) +static inline _sfsyscall2( int, rename, const char *, oldpath, const char *, newpath ) +// flock +// mkfifo +static inline _sfsyscall6(ssize_t, sendto, int, s, const void *, msg, size_t, len, int, flags, const struct sockaddr *, to, socklen_t, tolen) +// shutdown +// socketpair +static inline _sfsyscall2( int, mkdir, const char *, pathname, mode_t, mode ) +static inline _sfsyscall1( int, rmdir, const char *, pathname ) +// utimes +// adjtime +static inline _sfsyscall0( pid_t, setsid ) +// quotactl +// nfssvc +// getfh +// sysarch +static inline _sfsyscall4( ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset ) +// pwrite +// setgid +// setegid +// seteuid +// lfs_bmapv +// lfs_markv +// lfs_segclean +// lfs_segwait +static inline _sfsyscall2( int, stat, const char *, file_name, struct stat *, buf ) +static inline _sfsyscall2( int, fstat, int, filedes, struct stat *, buf ) +static inline _sfsyscall2( int, lstat, const char *, file_name, struct stat *, buf ) +// pathconf +// fpathconf +// swapctl +// getrlimit +// setrlimit +static inline _sfsyscall4( int,getdirentries, int,fd, void *,buf, int,nbytes, long *,basep) +static inline _sfsyscall6(void *,mmap, void *,start, size_t,length, int,prot , int,flags, int,fd, off_t,offset) +static inline _sfsyscall3( off_t, lseek, int, fildes, off_t, offset, int, whence ) +static inline _sfsyscall2( int, truncate, const char *, path, off_t, length ) +static inline _sfsyscall2( int, ftruncate, int, fd, off_t, length ) +static inline _sfsyscall2( int, mlock, const void *, addr, size_t, len ) +static inline _sfsyscall2( int, munlock, const void *, addr, size_t, len ) +// undelete +// futimes +static inline _sfsyscall1( pid_t, getpgid, pid_t, pid ) +// xfspioctl +static inline _sfsyscall3(int, semget, long, key, int, nsems, int, semflg) +static inline _sfsyscall3(int, semop, int, semid, struct sembuf *, sops, unsigned, nsops) +// msgget +// msgsnd +// msgrcv +static inline _sfsyscall3(void *, shmat, int, shmid, const void *, shmaddr, int, shmflg ) +// shmdt +static inline _sfsyscall3(int, shmget, long, key, int, size, int, flags ) +// clock_gettime +// clock_settime +// clock_getres +static inline _sfsyscall2( int, nanosleep, const struct timespec *, req, struct timespec *, rem ) +// minherit +// rfork +static inline _sfsyscall3( int, poll, struct pollfd *, ufds, unsigned int, nfds, int, timeout ) +// issetugid +static inline _sfsyscall3( int, lchown, const char *, path, uid_t, owner, gid_t, group ) +static inline _sfsyscall1( pid_t, getsid, pid_t, pid ) +static inline _sfsyscall3( int, msync, const void *, start, size_t, length, int, flags ) +// shmctl +// msgctl +// getfsstat +static inline _sfsyscall2( int, statfs, const char *, path, struct statfs *, buf ) +static inline _sfsyscall2( int, fstatfs, int, fd, struct statfs *, buf ) +static inline _sfsyscall1( int, pipe, unsigned long *, filedes) +// fhopen +// fhstat +// fhstatfs +// preadv +// pwritev +// kqueue +// kevent +static inline _sfsyscall1( int, mlockall, int, flags ) +static inline _sfsyscall0( int, munlockall ) +// getpeereid +// extattrctl +// extattr_set_file +// extattr_get_file +// extattr_delete_file +// extattr_set_fd +// extattr_get_fd +// extattr_delete_fd + +#endif /* SFLIB_H */ diff --git a/dest/include/librz/sflib/darwin-x86-32/sfsyscall.h b/dest/include/librz/sflib/darwin-x86-32/sfsyscall.h new file mode 100644 index 00000000000..10855e6c5cd --- /dev/null +++ b/dest/include/librz/sflib/darwin-x86-32/sfsyscall.h @@ -0,0 +1,154 @@ +/* + * sfsyscall.h --- SFLib syscall macros for Darwin/i386 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + + +/* + * Automatically generated by gensflib.py + * Tue Apr 25 20:10:54 2023 + */ + +#ifndef SFSYSCALL_H +#define SFSYSCALL_H + + +/* $Id$ */ + +#ifdef SF_USE_ERRNO +/* Remove errno stuff */ +int errno; +#error "SF_USER_ERRNO not supported yet" +#else +#define __sfsyscall_return(type, res) \ +do { \ + return (type) (res); \ +} while (0) +#endif + + +/* syscall macros */ + +#define _sfsyscall0(type,name) \ +type name(void) \ +{ \ +long __res; \ +__asm__ volatile ("int $0x80" \ + : "=a" (__res) \ + : "0" (__NR_##name)); \ +__sfsyscall_return(type,__res); \ +} + +#define _sfsyscall1(type,name,type1,arg1) \ +type name(type1 arg1) \ +{ \ +long __res; \ +__asm__ volatile ("pushl %2\n\t" \ + "pushl %%eax\n\t" \ + "int $0x80\n\t" \ + "add $8, %%esp" \ + : "=a" (__res) \ + : "0" (__NR_##name),"r" ((long)(arg1))); \ +__sfsyscall_return(type,__res); \ +} + +#define _sfsyscall2(type,name,type1,arg1,type2,arg2) \ +type name(type1 arg1,type2 arg2) \ +{ \ +long __res; \ +__asm__ volatile ("pushl %3\n\t" \ + "pushl %2\n\t" \ + "pushl %%eax\n\t" \ + "int $0x80\n\t" \ + "add $12, %%esp" \ + : "=a" (__res) \ + : "0" (__NR_##name),"r" ((long)(arg1)),"r" ((long)(arg2)) ); \ +__sfsyscall_return(type,__res); \ +} + +#define _sfsyscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ +type name(type1 arg1,type2 arg2,type3 arg3) \ +{ \ +long __res; \ +__asm__ volatile ("pusha; pushl %4\n\t" \ + "pushl %3\n\t" \ + "pushl %2\n\t" \ + "pushl %%eax\n\t" \ + "int $0x80\n\t" \ + "add $16, %%esp\n\t" \ + "popa" \ + : "=a" (__res) \ + : "0" (__NR_##name),"r" ((long)(arg1)),"r" ((long)(arg2)), \ + "r" ((long)(arg3)) ); \ +__sfsyscall_return(type,__res); \ +} + +#define _sfsyscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ +type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ +{ \ +long __res; \ +__asm__ volatile ("pushl %5\n\t" \ + "pushl %4\n\t" \ + "pushl %3\n\t" \ + "pushl %2\n\t" \ + "pushl %%eax\n\t" \ + "int $0x80\n\t" \ + "add $20, %%esp" \ + : "=a" (__res) \ + : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \ + "d" ((long)(arg3)),"S" ((long)(arg4)) ); \ +__sfsyscall_return(type,__res); \ +} + +#define _sfsyscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5) \ +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ +{ \ +long __res; \ +__asm__ volatile ("pushl %6\n\t" \ + "pushl %5\n\t" \ + "pushl %4\n\t" \ + "pushl %3\n\t" \ + "pushl %2\n\t" \ + "pushl %%eax\n\t" \ + "int $0x80\n\t" \ + "add $24, %%esp" \ + : "=a" (__res) \ + : "0" (__NR_##name),"r" ((long)(arg1)),"r" ((long)(arg2)), \ + "r" ((long)(arg3)),"r" ((long)(arg4)),"r" ((long)(arg5))); \ +__sfsyscall_return(type,__res); \ +} + +#define _sfsyscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5,type6,arg6) \ +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \ +{ \ +long __res; \ +__asm__ volatile ("pushl %7\n\t" \ + "pushl %6\n\t" \ + "pushl %5\n\t" \ + "pushl %4\n\t" \ + "pushl %3\n\t" \ + "pushl %2\n\t" \ + "pushl %%eax\n\t" \ + "int $0x80\n\t" \ + "add $28, %%esp" \ + : "=a" (__res) \ + : "0" (__NR_##name),"r" ((long)(arg1)),"r" ((long)(arg2)), \ + "r" ((long)(arg3)),"r" ((long)(arg4)),"r" ((long)(arg5)), \ + "r" ((long)(arg6))); \ +__sfsyscall_return(type,__res); \ +} + +#endif /* SFSYSCALL_H */ diff --git a/dest/include/librz/sflib/darwin-x86-32/sfsysnr.h b/dest/include/librz/sflib/darwin-x86-32/sfsysnr.h new file mode 100644 index 00000000000..16f386ba0c5 --- /dev/null +++ b/dest/include/librz/sflib/darwin-x86-32/sfsysnr.h @@ -0,0 +1,684 @@ +/* + * sfsysnr.h --- SFLib syscall numbers for Darwin/i386 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + + +/* + * Automatically generated by gensflib.py + * Tue Apr 25 20:10:54 2023 + */ + +#ifndef SFSYSNR_H +#define SFSYSNR_H + + +/* $Id$ */ + +/* + * Modified from /usr/include/sys/syscall.h + * created from OpenBSD: syscalls.master,v 1.50 2002/07/06 19:14:20 nordin Exp + */ + + +/* syscall: "syscall" ret: "int" args: "int" "..." */ +#define __NR_syscall 0 + +/* syscall: "exit" ret: "void" args: "int" */ +#define __NR_exit 1 + +/* syscall: "fork" ret: "int" args: */ +#define __NR_fork 2 + +/* syscall: "read" ret: "ssize_t" args: "int" "void *" "size_t" */ +#define __NR_read 3 + +/* syscall: "write" ret: "ssize_t" args: "int" "const void *" "size_t" */ +#define __NR_write 4 + +/* syscall: "open" ret: "int" args: "const char *" "int" "..." */ +#define __NR_open 5 + +/* syscall: "close" ret: "int" args: "int" */ +#define __NR_close 6 + +/* syscall: "wait4" ret: "int" args: "int" "int *" "int" "struct rusage *" */ +#define __NR_wait4 7 + + /* 8 is compat_43 ocreat */ + +/* syscall: "link" ret: "int" args: "const char *" "const char *" */ +#define __NR_link 9 + +/* syscall: "unlink" ret: "int" args: "const char *" */ +#define __NR_unlink 10 + + /* 11 is obsolete execv */ +/* syscall: "chdir" ret: "int" args: "const char *" */ +#define __NR_chdir 12 + +/* syscall: "fchdir" ret: "int" args: "int" */ +#define __NR_fchdir 13 + +/* syscall: "mknod" ret: "int" args: "const char *" "int" "dev_t" */ +#define __NR_mknod 14 + +/* syscall: "chmod" ret: "int" args: "const char *" "int" */ +#define __NR_chmod 15 + +/* syscall: "chown" ret: "int" args: "const char *" "uid_t" "gid_t" */ +#define __NR_chown 16 + +/* syscall: "break" ret: "int" args: "char *" */ +#define __NR_break 17 + + /* 18 is compat_25 ogetfsstat */ + + /* 19 is compat_43 olseek */ + +/* syscall: "getpid" ret: "pid_t" args: */ +#define __NR_getpid 20 + +/* syscall: "mount" ret: "int" args: "const char *" "const char *" "int" "void *" */ +#define __NR_mount 21 + +/* syscall: "unmount" ret: "int" args: "const char *" "int" */ +#define __NR_unmount 22 + +/* syscall: "setuid" ret: "int" args: "uid_t" */ +#define __NR_setuid 23 + +/* syscall: "getuid" ret: "uid_t" args: */ +#define __NR_getuid 24 + +/* syscall: "geteuid" ret: "uid_t" args: */ +#define __NR_geteuid 25 + +/* syscall: "ptrace" ret: "int" args: "int" "pid_t" "caddr_t" "int" */ +#define __NR_ptrace 26 + +/* syscall: "recvmsg" ret: "ssize_t" args: "int" "struct msghdr *" "int" */ +#define __NR_recvmsg 27 + +/* syscall: "sendmsg" ret: "ssize_t" args: "int" "const struct msghdr *" "int" */ +#define __NR_sendmsg 28 + +/* syscall: "recvfrom" ret: "ssize_t" args: "int" "void *" "size_t" "int" "struct sockaddr *" "socklen_t *" */ +#define __NR_recvfrom 29 + +/* syscall: "accept" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ +#define __NR_accept 30 + +/* syscall: "getpeername" ret: "int" args: "int" "struct sockaddr *" "int *" */ +#define __NR_getpeername 31 + +/* syscall: "getsockname" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ +#define __NR_getsockname 32 + +/* syscall: "access" ret: "int" args: "const char *" "int" */ +#define __NR_access 33 + +/* syscall: "chflags" ret: "int" args: "const char *" "u_int" */ +#define __NR_chflags 34 + +/* syscall: "fchflags" ret: "int" args: "int" "u_int" */ +#define __NR_fchflags 35 + +/* syscall: "sync" ret: "void" args: */ +#define __NR_sync 36 + +/* syscall: "kill" ret: "int" args: "int" "int" */ +#define __NR_kill 37 + + /* 38 is compat_43 ostat */ + +/* syscall: "getppid" ret: "pid_t" args: */ +#define __NR_getppid 39 + + /* 40 is compat_43 olstat */ + +/* syscall: "dup" ret: "int" args: "int" */ +#define __NR_dup 41 + +/* syscall: "opipe" ret: "int" args: */ +#define __NR_opipe 42 + +/* syscall: "getegid" ret: "gid_t" args: */ +#define __NR_getegid 43 + +/* syscall: "profil" ret: "int" args: "caddr_t" "size_t" "u_long" "u_int" */ +#define __NR_profil 44 + +/* syscall: "ktrace" ret: "int" args: "const char *" "int" "int" "pid_t" */ +#define __NR_ktrace 45 + +/* syscall: "sigaction" ret: "int" args: "int" "const struct sigaction *" "struct sigaction *" */ +#define __NR_sigaction 46 + +/* syscall: "getgid" ret: "gid_t" args: */ +#define __NR_getgid 47 + +/* syscall: "sigprocmask" ret: "int" args: "int" "sigset_t" */ +#define __NR_sigprocmask 48 + +/* syscall: "getlogin" ret: "int" args: "char *" "u_int" */ +#define __NR_getlogin 49 + +/* syscall: "setlogin" ret: "int" args: "const char *" */ +#define __NR_setlogin 50 + +/* syscall: "acct" ret: "int" args: "const char *" */ +#define __NR_acct 51 + +/* syscall: "sigpending" ret: "int" args: */ +#define __NR_sigpending 52 + +/* syscall: "sigaltstack" ret: "int" args: "const struct sigaltstack *" "struct sigaltstack *" */ +#define __NR_sigaltstack 53 + +/* syscall: "ioctl" ret: "int" args: "int" "u_long" "..." */ +#define __NR_ioctl 54 + +/* syscall: "reboot" ret: "int" args: "int" */ +#define __NR_reboot 55 + +/* syscall: "revoke" ret: "int" args: "const char *" */ +#define __NR_revoke 56 + +/* syscall: "symlink" ret: "int" args: "const char *" "const char *" */ +#define __NR_symlink 57 + +/* syscall: "readlink" ret: "int" args: "const char *" "char *" "size_t" */ +#define __NR_readlink 58 + +/* syscall: "execve" ret: "int" args: "const char *" "char *const *" "char *const *" */ +#define __NR_execve 59 + +/* syscall: "umask" ret: "int" args: "int" */ +#define __NR_umask 60 + +/* syscall: "chroot" ret: "int" args: "const char *" */ +#define __NR_chroot 61 + + /* 62 is compat_43 ofstat */ + + /* 63 is compat_43 ogetkerninfo */ + + /* 64 is compat_43 ogetpagesize */ + +/* syscall: "omsync" ret: "int" args: "caddr_t" "size_t" */ +#define __NR_omsync 65 + +/* syscall: "vfork" ret: "int" args: */ +#define __NR_vfork 66 + + /* 67 is obsolete vread */ + /* 68 is obsolete vwrite */ +/* syscall: "sbrk" ret: "int" args: "int" */ +#define __NR_sbrk 69 + +/* syscall: "sstk" ret: "int" args: "int" */ +#define __NR_sstk 70 + + /* 71 is compat_43 ommap */ + +/* syscall: "vadvise" ret: "int" args: "int" */ +#define __NR_vadvise 72 + +/* syscall: "munmap" ret: "int" args: "void *" "size_t" */ +#define __NR_munmap 73 + +/* syscall: "mprotect" ret: "int" args: "void *" "size_t" "int" */ +#define __NR_mprotect 74 + +/* syscall: "madvise" ret: "int" args: "void *" "size_t" "int" */ +#define __NR_madvise 75 + + /* 76 is obsolete vhangup */ + /* 77 is obsolete vlimit */ +/* syscall: "mincore" ret: "int" args: "void *" "size_t" "char *" */ +#define __NR_mincore 78 + +/* syscall: "getgroups" ret: "int" args: "int" "gid_t *" */ +#define __NR_getgroups 79 + +/* syscall: "setgroups" ret: "int" args: "int" "const gid_t *" */ +#define __NR_setgroups 80 + +/* syscall: "getpgrp" ret: "int" args: */ +#define __NR_getpgrp 81 + +/* syscall: "setpgid" ret: "int" args: "pid_t" "int" */ +#define __NR_setpgid 82 + +/* syscall: "setitimer" ret: "int" args: "int" "const struct itimerval *" "struct itimerval *" */ +#define __NR_setitimer 83 + + /* 84 is compat_43 owait */ + +/* syscall: "swapon" ret: "int" args: "const char *" */ +#define __NR_swapon 85 + +/* syscall: "getitimer" ret: "int" args: "int" "struct itimerval *" */ +#define __NR_getitimer 86 + + /* 87 is compat_43 ogethostname */ + + /* 88 is compat_43 osethostname */ + + /* 89 is compat_43 ogetdtablesize */ + +/* syscall: "dup2" ret: "int" args: "int" "int" */ +#define __NR_dup2 90 + +/* syscall: "fcntl" ret: "int" args: "int" "int" "..." */ +#define __NR_fcntl 92 + +/* syscall: "select" ret: "int" args: "int" "fd_set *" "fd_set *" "fd_set *" "struct timeval *" */ +#define __NR_select 93 + +/* syscall: "fsync" ret: "int" args: "int" */ +#define __NR_fsync 95 + +/* syscall: "setpriority" ret: "int" args: "int" "int" "int" */ +#define __NR_setpriority 96 + +/* syscall: "socket" ret: "int" args: "int" "int" "int" */ +#define __NR_socket 97 + +/* syscall: "connect" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */ +#define __NR_connect 98 + + /* 99 is compat_43 oaccept */ + +/* syscall: "getpriority" ret: "int" args: "int" "int" */ +#define __NR_getpriority 100 + + /* 101 is compat_43 osend */ + + /* 102 is compat_43 orecv */ + +/* syscall: "sigreturn" ret: "int" args: "struct sigcontext *" */ +#define __NR_sigreturn 103 + +/* syscall: "bind" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */ +#define __NR_bind 104 + +/* syscall: "setsockopt" ret: "int" args: "int" "int" "int" "const void *" "socklen_t" */ +#define __NR_setsockopt 105 + +/* syscall: "listen" ret: "int" args: "int" "int" */ +#define __NR_listen 106 + + /* 107 is obsolete vtimes */ + /* 108 is compat_43 osigvec */ + + /* 109 is compat_43 osigblock */ + + /* 110 is compat_43 osigsetmask */ + +/* syscall: "sigsuspend" ret: "int" args: "int" */ +#define __NR_sigsuspend 111 + + /* 112 is compat_43 osigstack */ + + /* 113 is compat_43 orecvmsg */ + + /* 114 is compat_43 osendmsg */ + + /* 115 is obsolete vtrace */ +/* syscall: "gettimeofday" ret: "int" args: "struct timeval *" "struct timezone *" */ +#define __NR_gettimeofday 116 + +/* syscall: "getrusage" ret: "int" args: "int" "struct rusage *" */ +#define __NR_getrusage 117 + +/* syscall: "getsockopt" ret: "int" args: "int" "int" "int" "void *" "socklen_t *" */ +#define __NR_getsockopt 118 + + /* 119 is obsolete resuba */ +/* syscall: "readv" ret: "ssize_t" args: "int" "const struct iovec *" "int" */ +#define __NR_readv 120 + +/* syscall: "writev" ret: "ssize_t" args: "int" "const struct iovec *" "int" */ +#define __NR_writev 121 + +/* syscall: "settimeofday" ret: "int" args: "const struct timeval *" "const struct timezone *" */ +#define __NR_settimeofday 122 + +/* syscall: "fchown" ret: "int" args: "int" "uid_t" "gid_t" */ +#define __NR_fchown 123 + +/* syscall: "fchmod" ret: "int" args: "int" "int" */ +#define __NR_fchmod 124 + + /* 125 is compat_43 orecvfrom */ + + /* 126 is compat_43 osetreuid */ + + /* 127 is compat_43 osetregid */ + +/* syscall: "rename" ret: "int" args: "const char *" "const char *" */ +#define __NR_rename 128 + + /* 129 is compat_43 otruncate */ + + /* 130 is compat_43 oftruncate */ + +/* syscall: "flock" ret: "int" args: "int" "int" */ +#define __NR_flock 131 + +/* syscall: "mkfifo" ret: "int" args: "const char *" "int" */ +#define __NR_mkfifo 132 + +/* syscall: "sendto" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "const struct sockaddr *" "socklen_t" */ +#define __NR_sendto 133 + +/* syscall: "shutdown" ret: "int" args: "int" "int" */ +#define __NR_shutdown 134 + +/* syscall: "socketpair" ret: "int" args: "int" "int" "int" "int *" */ +#define __NR_socketpair 135 + +/* syscall: "mkdir" ret: "int" args: "const char *" "int" */ +#define __NR_mkdir 136 + +/* syscall: "rmdir" ret: "int" args: "const char *" */ +#define __NR_rmdir 137 + +/* syscall: "utimes" ret: "int" args: "const char *" "const struct timeval *" */ +#define __NR_utimes 138 + + /* 139 is obsolete 4.2 sigreturn */ +/* syscall: "adjtime" ret: "int" args: "const struct timeval *" "struct timeval *" */ +#define __NR_adjtime 140 + + /* 141 is compat_43 ogetpeername */ + + /* 142 is compat_43 ogethostid */ + + /* 143 is compat_43 osethostid */ + + /* 144 is compat_43 ogetrlimit */ + + /* 145 is compat_43 osetrlimit */ + + /* 146 is compat_43 okillpg */ + +/* syscall: "setsid" ret: "int" args: */ +#define __NR_setsid 147 + +/* syscall: "quotactl" ret: "int" args: "const char *" "int" "int" "char *" */ +#define __NR_quotactl 148 + + /* 149 is compat_43 oquota */ + + /* 150 is compat_43 ogetsockname */ + +/* syscall: "nfssvc" ret: "int" args: "int" "void *" */ +#define __NR_nfssvc 155 + + /* 156 is compat_43 ogetdirentries */ + + /* 157 is compat_25 ostatfs */ + + /* 158 is compat_25 ostatfs */ + +/* syscall: "getfh" ret: "int" args: "const char *" "fhandle_t *" */ +#define __NR_getfh 161 + + /* 162 is compat_09 ogetdomainname */ + + /* 163 is compat_09 osetdomainname */ + + /* 164 is compat_09 ouname */ + +/* syscall: "sysarch" ret: "int" args: "int" "void *" */ +#define __NR_sysarch 165 + + /* 169 is compat_10 osemsys */ + + /* 170 is compat_10 omsgsys */ + + /* 171 is compat_10 oshmsys */ + +/* syscall: "pread" ret: "ssize_t" args: "int" "void *" "size_t" "int" "off_t" */ +#define __NR_pread 173 + +/* syscall: "pwrite" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "off_t" */ +#define __NR_pwrite 174 + +/* syscall: "setgid" ret: "int" args: "gid_t" */ +#define __NR_setgid 181 + +/* syscall: "setegid" ret: "int" args: "gid_t" */ +#define __NR_setegid 182 + +/* syscall: "seteuid" ret: "int" args: "uid_t" */ +#define __NR_seteuid 183 + +/* syscall: "lfs_bmapv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */ +#define __NR_lfs_bmapv 184 + +/* syscall: "lfs_markv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */ +#define __NR_lfs_markv 185 + +/* syscall: "lfs_segclean" ret: "int" args: "fsid_t *" "u_long" */ +#define __NR_lfs_segclean 186 + +/* syscall: "lfs_segwait" ret: "int" args: "fsid_t *" "struct timeval *" */ +#define __NR_lfs_segwait 187 + +/* syscall: "stat" ret: "int" args: "const char *" "struct stat *" */ +#define __NR_stat 188 + +/* syscall: "fstat" ret: "int" args: "int" "struct stat *" */ +#define __NR_fstat 189 + +/* syscall: "lstat" ret: "int" args: "const char *" "struct stat *" */ +#define __NR_lstat 190 + +/* syscall: "pathconf" ret: "long" args: "const char *" "int" */ +#define __NR_pathconf 191 + +/* syscall: "fpathconf" ret: "long" args: "int" "int" */ +#define __NR_fpathconf 192 + +/* syscall: "swapctl" ret: "int" args: "int" "const void *" "int" */ +#define __NR_swapctl 193 + +/* syscall: "getrlimit" ret: "int" args: "int" "struct rlimit *" */ +#define __NR_getrlimit 194 + +/* syscall: "setrlimit" ret: "int" args: "int" "const struct rlimit *" */ +#define __NR_setrlimit 195 + +/* syscall: "getdirentries" ret: "int" args: "int" "char *" "int" "long *" */ +#define __NR_getdirentries 196 + +/* syscall: "mmap" ret: "void *" args: "void *" "size_t" "int" "int" "int" "long" "off_t" */ +#define __NR_mmap 197 + +/* syscall: "__syscall" ret: "quad_t" args: "quad_t" "..." */ +#define __NR___syscall 198 + +/* syscall: "lseek" ret: "off_t" args: "int" "int" "off_t" "int" */ +#define __NR_lseek 199 + +/* syscall: "truncate" ret: "int" args: "const char *" "int" "off_t" */ +#define __NR_truncate 200 + +/* syscall: "ftruncate" ret: "int" args: "int" "int" "off_t" */ +#define __NR_ftruncate 201 + +/* syscall: "__sysctl" ret: "int" args: "int *" "u_int" "void *" "size_t *" "void *" "size_t" */ +#define __NR___sysctl 202 + +/* syscall: "mlock" ret: "int" args: "const void *" "size_t" */ +#define __NR_mlock 203 + +/* syscall: "munlock" ret: "int" args: "const void *" "size_t" */ +#define __NR_munlock 204 + +/* syscall: "undelete" ret: "int" args: "const char *" */ +#define __NR_undelete 205 + +/* syscall: "futimes" ret: "int" args: "int" "const struct timeval *" */ +#define __NR_futimes 206 + +/* syscall: "getpgid" ret: "pid_t" args: "pid_t" */ +#define __NR_getpgid 207 + +/* syscall: "xfspioctl" ret: "int" args: "int" "char *" "int" "struct ViceIoctl *" "int" */ +#define __NR_xfspioctl 208 + + /* 220 is compat_23 __osemctl */ + +/* syscall: "semget" ret: "int" args: "key_t" "int" "int" */ +#define __NR_semget 221 + +/* syscall: "semop" ret: "int" args: "int" "struct sembuf *" "u_int" */ +#define __NR_semop 222 + + /* 223 is obsolete sys_semconfig */ + /* 224 is compat_23 omsgctl */ + +/* syscall: "msgget" ret: "int" args: "key_t" "int" */ +#define __NR_msgget 225 + +/* syscall: "msgsnd" ret: "int" args: "int" "const void *" "size_t" "int" */ +#define __NR_msgsnd 226 + +/* syscall: "msgrcv" ret: "int" args: "int" "void *" "size_t" "long" "int" */ +#define __NR_msgrcv 227 + +/* syscall: "shmat" ret: "void *" args: "int" "const void *" "int" */ +#define __NR_shmat 228 + + /* 229 is compat_23 oshmctl */ + +/* syscall: "shmdt" ret: "int" args: "const void *" */ +#define __NR_shmdt 230 + +/* syscall: "shmget" ret: "int" args: "key_t" "int" "int" */ +#define __NR_shmget 231 + +/* syscall: "clock_gettime" ret: "int" args: "clockid_t" "struct timespec *" */ +#define __NR_clock_gettime 232 + +/* syscall: "clock_settime" ret: "int" args: "clockid_t" "const struct timespec *" */ +#define __NR_clock_settime 233 + +/* syscall: "clock_getres" ret: "int" args: "clockid_t" "struct timespec *" */ +#define __NR_clock_getres 234 + +/* syscall: "nanosleep" ret: "int" args: "const struct timespec *" "struct timespec *" */ +#define __NR_nanosleep 240 + +/* syscall: "minherit" ret: "int" args: "void *" "size_t" "int" */ +#define __NR_minherit 250 + +/* syscall: "rfork" ret: "int" args: "int" */ +#define __NR_rfork 251 + +/* syscall: "poll" ret: "int" args: "struct pollfd *" "unsigned long" "int" */ +#define __NR_poll 252 + +/* syscall: "issetugid" ret: "int" args: */ +#define __NR_issetugid 253 + +/* syscall: "lchown" ret: "int" args: "const char *" "uid_t" "gid_t" */ +#define __NR_lchown 254 + +/* syscall: "getsid" ret: "pid_t" args: "pid_t" */ +#define __NR_getsid 255 + +/* syscall: "msync" ret: "int" args: "void *" "size_t" "int" */ +#define __NR_msync 256 + +/* syscall: "__semctl" ret: "int" args: "int" "int" "int" "union semun *" */ +#define __NR___semctl 257 + +/* syscall: "shmctl" ret: "int" args: "int" "int" "struct shmid_ds *" */ +#define __NR_shmctl 258 + +/* syscall: "msgctl" ret: "int" args: "int" "int" "struct msqid_ds *" */ +#define __NR_msgctl 259 + +/* syscall: "getfsstat" ret: "int" args: "struct statfs *" "size_t" "int" */ +#define __NR_getfsstat 260 + +/* syscall: "statfs" ret: "int" args: "const char *" "struct statfs *" */ +#define __NR_statfs 261 + +/* syscall: "fstatfs" ret: "int" args: "int" "struct statfs *" */ +#define __NR_fstatfs 262 + +/* syscall: "pipe" ret: "int" args: "int *" */ +#define __NR_pipe 263 + +/* syscall: "fhopen" ret: "int" args: "const fhandle_t *" "int" */ +#define __NR_fhopen 264 + +/* syscall: "fhstat" ret: "int" args: "const fhandle_t *" "struct stat *" */ +#define __NR_fhstat 265 + +/* syscall: "fhstatfs" ret: "int" args: "const fhandle_t *" "struct statfs *" */ +#define __NR_fhstatfs 266 + +/* syscall: "preadv" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */ +#define __NR_preadv 267 + +/* syscall: "pwritev" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */ +#define __NR_pwritev 268 + +/* syscall: "kqueue" ret: "int" args: */ +#define __NR_kqueue 269 + +/* syscall: "kevent" ret: "int" args: "int" "const struct kevent *" "int" "struct kevent *" "int" "const struct timespec *" */ +#define __NR_kevent 270 + +/* syscall: "mlockall" ret: "int" args: "int" */ +#define __NR_mlockall 271 + +/* syscall: "munlockall" ret: "int" args: */ +#define __NR_munlockall 272 + +/* syscall: "getpeereid" ret: "int" args: "int" "uid_t *" "gid_t *" */ +#define __NR_getpeereid 273 + +/* syscall: "extattrctl" ret: "int" args: "const char *" "int" "const char *" "int" "const char *" */ +#define __NR_extattrctl 274 + +/* syscall: "extattr_set_file" ret: "int" args: "const char *" "int" "const char *" "void *" "size_t" */ +#define __NR_extattr_set_file 275 + +/* syscall: "extattr_get_file" ret: "ssize_t" args: "const char *" "int" "const char *" "void *" "size_t" */ +#define __NR_extattr_get_file 276 + +/* syscall: "extattr_delete_file" ret: "int" args: "const char *" "int" "const char *" */ +#define __NR_extattr_delete_file 277 + +/* syscall: "extattr_set_fd" ret: "int" args: "int" "int" "const char *" "void *" "size_t" */ +#define __NR_extattr_set_fd 278 + +/* syscall: "extattr_get_fd" ret: "ssize_t" args: "int" "int" "const char *" "void *" "size_t" */ +#define __NR_extattr_get_fd 279 + +/* syscall: "extattr_delete_fd" ret: "int" args: "int" "int" "const char *" */ +#define __NR_extattr_delete_fd 280 + +#define __NR_MAXSYSCALL 281 + +#endif /* SFSYSNR_H */ diff --git a/dest/include/librz/sflib/darwin-x86-64/sflib.h b/dest/include/librz/sflib/darwin-x86-64/sflib.h new file mode 100644 index 00000000000..d0c5540ff8b --- /dev/null +++ b/dest/include/librz/sflib/darwin-x86-64/sflib.h @@ -0,0 +1,152 @@ +/* + * sflib.h --- SFLib syscall library for OpenBSD/i386 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +/* + * Automatically generated by gensflib.py + * Fri Nov 25 15:52:34 2011 + */ + +#ifndef SFLIB_H +#define SFLIB_H + +#include "sfsysnr.h" +#include "sfsyscall.h" +#include "../common/sftypes.h" + +// syscall +static inline _sfsyscall1(void, exit, int, status) static inline _sfsyscall0(pid_t, fork) static inline _sfsyscall3(ssize_t, read, int, fd, void *, buf, size_t, count) static inline _sfsyscall3ipi(ssize_t, write, int, fd, const void *, buf, size_t, count) static inline _sfsyscall3(int, open, const char *, pathname, int, flags, mode_t, mode) static inline _sfsyscall1(int, close, int, fd) static inline _sfsyscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, struct rusage *, rusage) static inline _sfsyscall2(int, link, const char *, oldpath, const char *, newpath) static inline _sfsyscall1(int, unlink, const char *, pathname) static inline _sfsyscall1(int, chdir, const char *, path) + // fchdir + static inline _sfsyscall3(int, mknod, const char *, pathname, mode_t, mode, dev_t, dev) static inline _sfsyscall2(int, chmod, const char *, path, mode_t, mode) static inline _sfsyscall3(int, chown, const char *, path, uid_t, owner, gid_t, group) + // break + static inline _sfsyscall0(pid_t, getpid) + // mount + // unmount + // setuid + static inline _sfsyscall0(uid_t, getuid) static inline _sfsyscall0(uid_t, geteuid) static inline _sfsyscall4(long, ptrace, int, request, pid_t, pid, void *, addr, void *, data) + // recvmsg + // sendmsg + static inline _sfsyscall6(ssize_t, recvfrom, int, s, void *, buf, size_t, len, int, flags, struct sockaddr *, from, socklen_t *, fromlen) static inline _sfsyscall3(int, accept, int, s, struct sockaddr *, addr, socklen_t *, addrlen); +// getpeername +// getsockname +static inline _sfsyscall2(int, access, const char *, pathname, int, mode) + // chflags + // fchflags + static inline _sfsyscall0(int, sync) static inline _sfsyscall2(int, kill, pid_t, pid, int, sig) static inline _sfsyscall0(pid_t, getppid) static inline _sfsyscall1(int, dup, int, oldfd) + // opipe + static inline _sfsyscall0(gid_t, getegid) + // profil + // ktrace + // sigaction + static inline _sfsyscall0(gid_t, getgid) + // sigprocmask + // getlogin + // setlogin + static inline _sfsyscall1(int, acct, const char *, filename) static inline _sfsyscall1(int, sigpending, sigset_t *, set) + // sigaltstack + static inline _sfsyscall4(int, ioctl, int, d, int, request, char *, argp, int, len) + // reboot + // revoke + static inline _sfsyscall2(int, symlink, const char *, oldpath, const char *, newpath) static inline _sfsyscall3(int, readlink, const char *, path, char *, buf, size_t, bufsiz) static inline _sfsyscall3(int, execve, char *, s, char **, argv, char **, envp) static inline _sfsyscall1(mode_t, umask, mode_t, mask) static inline _sfsyscall1(int, chroot, const char *, path) + // omsync + static inline _sfsyscall0(pid_t, vfork) + // sbrk + // sstk + // vadvise + static inline _sfsyscall2(int, munmap, void *, start, size_t, length) static inline _sfsyscall3(int, mprotect, const void *, addr, size_t, len, int, prot) + // madvise + // mincore + // getgroups + static inline _sfsyscall2(int, setgroups, size_t, size, const gid_t *, list) static inline _sfsyscall0(pid_t, getpgrp) static inline _sfsyscall2(int, setpgid, pid_t, pid, pid_t, pgid) + // setitimer + static inline _sfsyscall2(int, swapon, const char *, path, int, swapflags) + // getitimer + static inline _sfsyscall2(int, dup2, int, oldfd, int, newfd) static inline _sfsyscall3(int, fcntl, int, fd, int, cmd, long, arg) static inline _sfsyscall5(int, select, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout) static inline _sfsyscall1(int, fsync, int, fd) static inline _sfsyscall3(int, setpriority, int, which, int, who, int, prio) static inline _sfsyscall3(int, socket, int, domain, int, type, int, protocol) static inline _sfsyscall3(int, connect, int, sockfd, const struct sockaddr *, serv_addr, socklen_t, addrlen) static inline _sfsyscall2(int, getpriority, int, which, int, who) static inline _sfsyscall1(int, sigreturn, unsigned long, __unused) static inline _sfsyscall3(int, bind, int, sockfd, struct sockaddr *, my_addr, socklen_t, addrlen) static inline _sfsyscall5(int, setsockopt, int, s, int, level, int, optname, void *, optval, socklen_t, optlen) static inline _sfsyscall2(int, listen, int, s, int, backlog) static inline _sfsyscall1(int, sigsuspend, const sigset_t *, mask) static inline _sfsyscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz) + // getrusage + // getsockopt + static inline _sfsyscall3(int, readv, int, fd, const struct iovec *, vector, int, count) static inline _sfsyscall3(int, writev, int, fd, const struct iovec *, vector, int, count) + // settimeofday + static inline _sfsyscall3(int, fchown, int, fd, uid_t, owner, gid_t, group) static inline _sfsyscall2(int, fchmod, int, fildes, mode_t, mode) static inline _sfsyscall2(int, rename, const char *, oldpath, const char *, newpath) + // flock + // mkfifo + static inline _sfsyscall6(ssize_t, sendto, int, s, const void *, msg, size_t, len, int, flags, const struct sockaddr *, to, socklen_t, tolen) + // shutdown + // socketpair + static inline _sfsyscall2(int, mkdir, const char *, pathname, mode_t, mode) static inline _sfsyscall1(int, rmdir, const char *, pathname) + // utimes + // adjtime + static inline _sfsyscall0(pid_t, setsid) + // quotactl + // nfssvc + // getfh + // sysarch + static inline _sfsyscall4(ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset) + // pwrite + // setgid + // setegid + // seteuid + // lfs_bmapv + // lfs_markv + // lfs_segclean + // lfs_segwait + static inline _sfsyscall2(int, stat, const char *, file_name, struct stat *, buf) static inline _sfsyscall2(int, fstat, int, filedes, struct stat *, buf) static inline _sfsyscall2(int, lstat, const char *, file_name, struct stat *, buf) + // pathconf + // fpathconf + // swapctl + // getrlimit + // setrlimit + static inline _sfsyscall4(int, getdirentries, int, fd, void *, buf, int, nbytes, long *, basep) static inline _sfsyscall6(void *, mmap, void *, start, size_t, length, int, prot, int, flags, int, fd, off_t, offset) static inline _sfsyscall3(off_t, lseek, int, fildes, off_t, offset, int, whence) static inline _sfsyscall2(int, truncate, const char *, path, off_t, length) static inline _sfsyscall2(int, ftruncate, int, fd, off_t, length) static inline _sfsyscall2(int, mlock, const void *, addr, size_t, len) static inline _sfsyscall2(int, munlock, const void *, addr, size_t, len) + // undelete + // futimes + static inline _sfsyscall1(pid_t, getpgid, pid_t, pid) + // xfspioctl + static inline _sfsyscall3(int, semget, long, key, int, nsems, int, semflg) static inline _sfsyscall3(int, semop, int, semid, struct sembuf *, sops, unsigned, nsops) + // msgget + // msgsnd + // msgrcv + static inline _sfsyscall3(void *, shmat, int, shmid, const void *, shmaddr, int, shmflg) + // shmdt + static inline _sfsyscall3(int, shmget, long, key, int, size, int, flags) + // clock_gettime + // clock_settime + // clock_getres + static inline _sfsyscall2(int, nanosleep, const struct timespec *, req, struct timespec *, rem) + // minherit + // rfork + static inline _sfsyscall3(int, poll, struct pollfd *, ufds, unsigned int, nfds, int, timeout) + // issetugid + static inline _sfsyscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group) static inline _sfsyscall1(pid_t, getsid, pid_t, pid) static inline _sfsyscall3(int, msync, const void *, start, size_t, length, int, flags) + // shmctl + // msgctl + // getfsstat + static inline _sfsyscall2(int, statfs, const char *, path, struct statfs *, buf) static inline _sfsyscall2(int, fstatfs, int, fd, struct statfs *, buf) static inline _sfsyscall1(int, pipe, unsigned long *, filedes) + // fhopen + // fhstat + // fhstatfs + // preadv + // pwritev + // kqueue + // kevent + static inline _sfsyscall1(int, mlockall, int, flags) static inline _sfsyscall0(int, munlockall) +// getpeereid +// extattrctl +// extattr_set_file +// extattr_get_file +// extattr_delete_file +// extattr_set_fd +// extattr_get_fd +// extattr_delete_fd + +#endif /* SFLIB_H */ diff --git a/dest/include/librz/sflib/darwin-x86-64/sfsyscall.h b/dest/include/librz/sflib/darwin-x86-64/sfsyscall.h new file mode 100644 index 00000000000..27268ed7a10 --- /dev/null +++ b/dest/include/librz/sflib/darwin-x86-64/sfsyscall.h @@ -0,0 +1,138 @@ +// ssed on the registers rdi, rsi, rdx, r10, r8 and r9 +/* + * sfsyscall.h --- SFLib syscall macros for OpenBSD/i386 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +#ifndef SFSYSCALL_H +#define SFSYSCALL_H + +#ifdef SF_USE_ERRNO +/* Remove errno stuff */ +int errno; +#error "SF_USER_ERRNO not supported yet" +#else +#define __sfsyscall_return(type, res) \ + do { \ + return (type)(res); \ + } while (0) +#endif + +/* syscall macros */ + +#define _sfsyscall0(type, name) \ + type name(void) { \ + long __res; \ + __asm__ volatile("syscall" \ + : "=a"(__res) \ + : "0"(0x2000000 | __NR_##name)); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall1(type, name, type1, arg1) \ + type name(type1 arg1) { \ + long __res; \ + __asm__ volatile("mov %2, %%rdi\n\t" \ + "syscall\n\t" \ + : "=a"(__res) \ + : "0"(0x2000000 | __NR_##name), "g"((long)(arg1))); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall2(type, name, type1, arg1, type2, arg2) \ + type name(type1 arg1, type2 arg2) { \ + long __res; \ + __asm__ volatile("mov %2, %%rdi\n\t" \ + "mov %3, %%rsi\n\t" \ + "syscall\n\t" \ + : "=a"(__res) \ + : "0"(0x2000000 | __NR_##name), "g"((long)(arg1)), "g"((long)(arg2))); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall3ipi(type, name, type1, arg1, type2, arg2, type3, arg3) \ + type name(type1 arg1, type2 arg2, type3 arg3) { \ + long __res; \ + __asm__ volatile("mov %4, %%rdx\n\t" \ + "syscall\n\t" \ + : "=a"(__res) \ + : "0"(0x2000000 | __NR_##name), \ + "D"(arg1), \ + "S"(arg2), \ + "g"((long)(arg3))); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ + type name(type1 arg1, type2 arg2, type3 arg3) { \ + long __res; \ + __asm__ volatile("mov %2, %%rdi\n\t" \ + "mov %3, %%rsi\n\t" \ + "mov %4, %%rdx\n\t" \ + "syscall\n\t" \ + : "=a"(__res) \ + : "0"(0x2000000 | __NR_##name), "g"((long)(arg1)), "g"((long)(arg2)), \ + "g"((long)(arg3))); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall4(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ + long __res; \ + __asm__ volatile("mov %2, %%rdi\n\t" \ + "mov %3, %%rsi\n\t" \ + "mov %4, %%rdx\n\t" \ + "mov %5, %%r10\n\t" \ + "syscall\n\t" \ + : "=a"(__res) \ + : "0"(0x2000000 | __NR_##name), "g"((long)(arg1)), "c"((long)(arg2)), \ + "d"((long)(arg3)), "S"((long)(arg4))); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall5(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, \ + type5, arg5) \ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \ + long __res; \ + __asm__ volatile("mov %2, %%rdi\n\t" \ + "mov %3, %%rsi\n\t" \ + "mov %4, %%rdx\n\t" \ + "mov %5, %%r10\n\t" \ + "mov %6, %%r8\n\t" \ + "syscall\n\t" \ + : "=a"(__res) \ + : "0"(0x2000000 | __NR_##name), "g"((long)(arg1)), "g"((long)(arg2)), \ + "g"((long)(arg3)), "g"((long)(arg4)), "g"((long)(arg5))); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall6(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, \ + type5, arg5, type6, arg6) \ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) { \ + long __res; \ + __asm__ volatile("mov %2, %%rdi\n\t" \ + "mov %3, %%rsi\n\t" \ + "mov %4, %%rdx\n\t" \ + "mov %5, %%r10\n\t" \ + "mov %6, %%r8\n\t" \ + "mov %7, %%r9\n\t" \ + "syscall\n\t" \ + : "=a"(__res) \ + : "0"(0x2000000 | __NR_##name), "g"((long)(arg1)), "g"((long)(arg2)), \ + "g"((long)(arg3)), "g"((long)(arg4)), "g"((long)(arg5)), \ + "g"((long)(arg6))); \ + __sfsyscall_return(type, __res); \ + } + +#endif /* SFSYSCALL_H */ diff --git a/dest/include/librz/sflib/darwin-x86-64/sfsysnr.h b/dest/include/librz/sflib/darwin-x86-64/sfsysnr.h new file mode 100644 index 00000000000..184beb327d0 --- /dev/null +++ b/dest/include/librz/sflib/darwin-x86-64/sfsysnr.h @@ -0,0 +1,681 @@ +/* + * sfsysnr.h --- SFLib syscall numbers for OpenBSD/i386 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +/* + * Automatically generated by gensflib.py + * Fri Nov 25 15:52:34 2011 + */ + +#ifndef SFSYSNR_H +#define SFSYSNR_H + +/* $Id$ */ + +/* + * Modified from /usr/include/sys/syscall.h + * created from OpenBSD: syscalls.master,v 1.50 2002/07/06 19:14:20 nordin Exp + */ + +/* syscall: "syscall" ret: "int" args: "int" "..." */ +#define __NR_syscall 0 + +/* syscall: "exit" ret: "void" args: "int" */ +#define __NR_exit 1 + +/* syscall: "fork" ret: "int" args: */ +#define __NR_fork 2 + +/* syscall: "read" ret: "ssize_t" args: "int" "void *" "size_t" */ +#define __NR_read 3 + +/* syscall: "write" ret: "ssize_t" args: "int" "const void *" "size_t" */ +#define __NR_write 4 + +/* syscall: "open" ret: "int" args: "const char *" "int" "..." */ +#define __NR_open 5 + +/* syscall: "close" ret: "int" args: "int" */ +#define __NR_close 6 + +/* syscall: "wait4" ret: "int" args: "int" "int *" "int" "struct rusage *" */ +#define __NR_wait4 7 + +/* 8 is compat_43 ocreat */ + +/* syscall: "link" ret: "int" args: "const char *" "const char *" */ +#define __NR_link 9 + +/* syscall: "unlink" ret: "int" args: "const char *" */ +#define __NR_unlink 10 + +/* 11 is obsolete execv */ +/* syscall: "chdir" ret: "int" args: "const char *" */ +#define __NR_chdir 12 + +/* syscall: "fchdir" ret: "int" args: "int" */ +#define __NR_fchdir 13 + +/* syscall: "mknod" ret: "int" args: "const char *" "int" "dev_t" */ +#define __NR_mknod 14 + +/* syscall: "chmod" ret: "int" args: "const char *" "int" */ +#define __NR_chmod 15 + +/* syscall: "chown" ret: "int" args: "const char *" "uid_t" "gid_t" */ +#define __NR_chown 16 + +/* syscall: "break" ret: "int" args: "char *" */ +#define __NR_break 17 + +/* 18 is compat_25 ogetfsstat */ + +/* 19 is compat_43 olseek */ + +/* syscall: "getpid" ret: "pid_t" args: */ +#define __NR_getpid 20 + +/* syscall: "mount" ret: "int" args: "const char *" "const char *" "int" "void *" */ +#define __NR_mount 21 + +/* syscall: "unmount" ret: "int" args: "const char *" "int" */ +#define __NR_unmount 22 + +/* syscall: "setuid" ret: "int" args: "uid_t" */ +#define __NR_setuid 23 + +/* syscall: "getuid" ret: "uid_t" args: */ +#define __NR_getuid 24 + +/* syscall: "geteuid" ret: "uid_t" args: */ +#define __NR_geteuid 25 + +/* syscall: "ptrace" ret: "int" args: "int" "pid_t" "caddr_t" "int" */ +#define __NR_ptrace 26 + +/* syscall: "recvmsg" ret: "ssize_t" args: "int" "struct msghdr *" "int" */ +#define __NR_recvmsg 27 + +/* syscall: "sendmsg" ret: "ssize_t" args: "int" "const struct msghdr *" "int" */ +#define __NR_sendmsg 28 + +/* syscall: "recvfrom" ret: "ssize_t" args: "int" "void *" "size_t" "int" "struct sockaddr *" "socklen_t *" */ +#define __NR_recvfrom 29 + +/* syscall: "accept" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ +#define __NR_accept 30 + +/* syscall: "getpeername" ret: "int" args: "int" "struct sockaddr *" "int *" */ +#define __NR_getpeername 31 + +/* syscall: "getsockname" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ +#define __NR_getsockname 32 + +/* syscall: "access" ret: "int" args: "const char *" "int" */ +#define __NR_access 33 + +/* syscall: "chflags" ret: "int" args: "const char *" "u_int" */ +#define __NR_chflags 34 + +/* syscall: "fchflags" ret: "int" args: "int" "u_int" */ +#define __NR_fchflags 35 + +/* syscall: "sync" ret: "void" args: */ +#define __NR_sync 36 + +/* syscall: "kill" ret: "int" args: "int" "int" */ +#define __NR_kill 37 + +/* 38 is compat_43 ostat */ + +/* syscall: "getppid" ret: "pid_t" args: */ +#define __NR_getppid 39 + +/* 40 is compat_43 olstat */ + +/* syscall: "dup" ret: "int" args: "int" */ +#define __NR_dup 41 + +/* syscall: "opipe" ret: "int" args: */ +#define __NR_opipe 42 + +/* syscall: "getegid" ret: "gid_t" args: */ +#define __NR_getegid 43 + +/* syscall: "profil" ret: "int" args: "caddr_t" "size_t" "u_long" "u_int" */ +#define __NR_profil 44 + +/* syscall: "ktrace" ret: "int" args: "const char *" "int" "int" "pid_t" */ +#define __NR_ktrace 45 + +/* syscall: "sigaction" ret: "int" args: "int" "const struct sigaction *" "struct sigaction *" */ +#define __NR_sigaction 46 + +/* syscall: "getgid" ret: "gid_t" args: */ +#define __NR_getgid 47 + +/* syscall: "sigprocmask" ret: "int" args: "int" "sigset_t" */ +#define __NR_sigprocmask 48 + +/* syscall: "getlogin" ret: "int" args: "char *" "u_int" */ +#define __NR_getlogin 49 + +/* syscall: "setlogin" ret: "int" args: "const char *" */ +#define __NR_setlogin 50 + +/* syscall: "acct" ret: "int" args: "const char *" */ +#define __NR_acct 51 + +/* syscall: "sigpending" ret: "int" args: */ +#define __NR_sigpending 52 + +/* syscall: "sigaltstack" ret: "int" args: "const struct sigaltstack *" "struct sigaltstack *" */ +#define __NR_sigaltstack 53 + +/* syscall: "ioctl" ret: "int" args: "int" "u_long" "..." */ +#define __NR_ioctl 54 + +/* syscall: "reboot" ret: "int" args: "int" */ +#define __NR_reboot 55 + +/* syscall: "revoke" ret: "int" args: "const char *" */ +#define __NR_revoke 56 + +/* syscall: "symlink" ret: "int" args: "const char *" "const char *" */ +#define __NR_symlink 57 + +/* syscall: "readlink" ret: "int" args: "const char *" "char *" "size_t" */ +#define __NR_readlink 58 + +/* syscall: "execve" ret: "int" args: "const char *" "char *const *" "char *const *" */ +#define __NR_execve 59 + +/* syscall: "umask" ret: "int" args: "int" */ +#define __NR_umask 60 + +/* syscall: "chroot" ret: "int" args: "const char *" */ +#define __NR_chroot 61 + +/* 62 is compat_43 ofstat */ + +/* 63 is compat_43 ogetkerninfo */ + +/* 64 is compat_43 ogetpagesize */ + +/* syscall: "omsync" ret: "int" args: "caddr_t" "size_t" */ +#define __NR_omsync 65 + +/* syscall: "vfork" ret: "int" args: */ +#define __NR_vfork 66 + +/* 67 is obsolete vread */ +/* 68 is obsolete vwrite */ +/* syscall: "sbrk" ret: "int" args: "int" */ +#define __NR_sbrk 69 + +/* syscall: "sstk" ret: "int" args: "int" */ +#define __NR_sstk 70 + +/* 71 is compat_43 ommap */ + +/* syscall: "vadvise" ret: "int" args: "int" */ +#define __NR_vadvise 72 + +/* syscall: "munmap" ret: "int" args: "void *" "size_t" */ +#define __NR_munmap 73 + +/* syscall: "mprotect" ret: "int" args: "void *" "size_t" "int" */ +#define __NR_mprotect 74 + +/* syscall: "madvise" ret: "int" args: "void *" "size_t" "int" */ +#define __NR_madvise 75 + +/* 76 is obsolete vhangup */ +/* 77 is obsolete vlimit */ +/* syscall: "mincore" ret: "int" args: "void *" "size_t" "char *" */ +#define __NR_mincore 78 + +/* syscall: "getgroups" ret: "int" args: "int" "gid_t *" */ +#define __NR_getgroups 79 + +/* syscall: "setgroups" ret: "int" args: "int" "const gid_t *" */ +#define __NR_setgroups 80 + +/* syscall: "getpgrp" ret: "int" args: */ +#define __NR_getpgrp 81 + +/* syscall: "setpgid" ret: "int" args: "pid_t" "int" */ +#define __NR_setpgid 82 + +/* syscall: "setitimer" ret: "int" args: "int" "const struct itimerval *" "struct itimerval *" */ +#define __NR_setitimer 83 + +/* 84 is compat_43 owait */ + +/* syscall: "swapon" ret: "int" args: "const char *" */ +#define __NR_swapon 85 + +/* syscall: "getitimer" ret: "int" args: "int" "struct itimerval *" */ +#define __NR_getitimer 86 + +/* 87 is compat_43 ogethostname */ + +/* 88 is compat_43 osethostname */ + +/* 89 is compat_43 ogetdtablesize */ + +/* syscall: "dup2" ret: "int" args: "int" "int" */ +#define __NR_dup2 90 + +/* syscall: "fcntl" ret: "int" args: "int" "int" "..." */ +#define __NR_fcntl 92 + +/* syscall: "select" ret: "int" args: "int" "fd_set *" "fd_set *" "fd_set *" "struct timeval *" */ +#define __NR_select 93 + +/* syscall: "fsync" ret: "int" args: "int" */ +#define __NR_fsync 95 + +/* syscall: "setpriority" ret: "int" args: "int" "int" "int" */ +#define __NR_setpriority 96 + +/* syscall: "socket" ret: "int" args: "int" "int" "int" */ +#define __NR_socket 97 + +/* syscall: "connect" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */ +#define __NR_connect 98 + +/* 99 is compat_43 oaccept */ + +/* syscall: "getpriority" ret: "int" args: "int" "int" */ +#define __NR_getpriority 100 + +/* 101 is compat_43 osend */ + +/* 102 is compat_43 orecv */ + +/* syscall: "sigreturn" ret: "int" args: "struct sigcontext *" */ +#define __NR_sigreturn 103 + +/* syscall: "bind" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */ +#define __NR_bind 104 + +/* syscall: "setsockopt" ret: "int" args: "int" "int" "int" "const void *" "socklen_t" */ +#define __NR_setsockopt 105 + +/* syscall: "listen" ret: "int" args: "int" "int" */ +#define __NR_listen 106 + +/* 107 is obsolete vtimes */ +/* 108 is compat_43 osigvec */ + +/* 109 is compat_43 osigblock */ + +/* 110 is compat_43 osigsetmask */ + +/* syscall: "sigsuspend" ret: "int" args: "int" */ +#define __NR_sigsuspend 111 + +/* 112 is compat_43 osigstack */ + +/* 113 is compat_43 orecvmsg */ + +/* 114 is compat_43 osendmsg */ + +/* 115 is obsolete vtrace */ +/* syscall: "gettimeofday" ret: "int" args: "struct timeval *" "struct timezone *" */ +#define __NR_gettimeofday 116 + +/* syscall: "getrusage" ret: "int" args: "int" "struct rusage *" */ +#define __NR_getrusage 117 + +/* syscall: "getsockopt" ret: "int" args: "int" "int" "int" "void *" "socklen_t *" */ +#define __NR_getsockopt 118 + +/* 119 is obsolete resuba */ +/* syscall: "readv" ret: "ssize_t" args: "int" "const struct iovec *" "int" */ +#define __NR_readv 120 + +/* syscall: "writev" ret: "ssize_t" args: "int" "const struct iovec *" "int" */ +#define __NR_writev 121 + +/* syscall: "settimeofday" ret: "int" args: "const struct timeval *" "const struct timezone *" */ +#define __NR_settimeofday 122 + +/* syscall: "fchown" ret: "int" args: "int" "uid_t" "gid_t" */ +#define __NR_fchown 123 + +/* syscall: "fchmod" ret: "int" args: "int" "int" */ +#define __NR_fchmod 124 + +/* 125 is compat_43 orecvfrom */ + +/* 126 is compat_43 osetreuid */ + +/* 127 is compat_43 osetregid */ + +/* syscall: "rename" ret: "int" args: "const char *" "const char *" */ +#define __NR_rename 128 + +/* 129 is compat_43 otruncate */ + +/* 130 is compat_43 oftruncate */ + +/* syscall: "flock" ret: "int" args: "int" "int" */ +#define __NR_flock 131 + +/* syscall: "mkfifo" ret: "int" args: "const char *" "int" */ +#define __NR_mkfifo 132 + +/* syscall: "sendto" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "const struct sockaddr *" "socklen_t" */ +#define __NR_sendto 133 + +/* syscall: "shutdown" ret: "int" args: "int" "int" */ +#define __NR_shutdown 134 + +/* syscall: "socketpair" ret: "int" args: "int" "int" "int" "int *" */ +#define __NR_socketpair 135 + +/* syscall: "mkdir" ret: "int" args: "const char *" "int" */ +#define __NR_mkdir 136 + +/* syscall: "rmdir" ret: "int" args: "const char *" */ +#define __NR_rmdir 137 + +/* syscall: "utimes" ret: "int" args: "const char *" "const struct timeval *" */ +#define __NR_utimes 138 + +/* 139 is obsolete 4.2 sigreturn */ +/* syscall: "adjtime" ret: "int" args: "const struct timeval *" "struct timeval *" */ +#define __NR_adjtime 140 + +/* 141 is compat_43 ogetpeername */ + +/* 142 is compat_43 ogethostid */ + +/* 143 is compat_43 osethostid */ + +/* 144 is compat_43 ogetrlimit */ + +/* 145 is compat_43 osetrlimit */ + +/* 146 is compat_43 okillpg */ + +/* syscall: "setsid" ret: "int" args: */ +#define __NR_setsid 147 + +/* syscall: "quotactl" ret: "int" args: "const char *" "int" "int" "char *" */ +#define __NR_quotactl 148 + +/* 149 is compat_43 oquota */ + +/* 150 is compat_43 ogetsockname */ + +/* syscall: "nfssvc" ret: "int" args: "int" "void *" */ +#define __NR_nfssvc 155 + +/* 156 is compat_43 ogetdirentries */ + +/* 157 is compat_25 ostatfs */ + +/* 158 is compat_25 ostatfs */ + +/* syscall: "getfh" ret: "int" args: "const char *" "fhandle_t *" */ +#define __NR_getfh 161 + +/* 162 is compat_09 ogetdomainname */ + +/* 163 is compat_09 osetdomainname */ + +/* 164 is compat_09 ouname */ + +/* syscall: "sysarch" ret: "int" args: "int" "void *" */ +#define __NR_sysarch 165 + +/* 169 is compat_10 osemsys */ + +/* 170 is compat_10 omsgsys */ + +/* 171 is compat_10 oshmsys */ + +/* syscall: "pread" ret: "ssize_t" args: "int" "void *" "size_t" "int" "off_t" */ +#define __NR_pread 173 + +/* syscall: "pwrite" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "off_t" */ +#define __NR_pwrite 174 + +/* syscall: "setgid" ret: "int" args: "gid_t" */ +#define __NR_setgid 181 + +/* syscall: "setegid" ret: "int" args: "gid_t" */ +#define __NR_setegid 182 + +/* syscall: "seteuid" ret: "int" args: "uid_t" */ +#define __NR_seteuid 183 + +/* syscall: "lfs_bmapv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */ +#define __NR_lfs_bmapv 184 + +/* syscall: "lfs_markv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */ +#define __NR_lfs_markv 185 + +/* syscall: "lfs_segclean" ret: "int" args: "fsid_t *" "u_long" */ +#define __NR_lfs_segclean 186 + +/* syscall: "lfs_segwait" ret: "int" args: "fsid_t *" "struct timeval *" */ +#define __NR_lfs_segwait 187 + +/* syscall: "stat" ret: "int" args: "const char *" "struct stat *" */ +#define __NR_stat 188 + +/* syscall: "fstat" ret: "int" args: "int" "struct stat *" */ +#define __NR_fstat 189 + +/* syscall: "lstat" ret: "int" args: "const char *" "struct stat *" */ +#define __NR_lstat 190 + +/* syscall: "pathconf" ret: "long" args: "const char *" "int" */ +#define __NR_pathconf 191 + +/* syscall: "fpathconf" ret: "long" args: "int" "int" */ +#define __NR_fpathconf 192 + +/* syscall: "swapctl" ret: "int" args: "int" "const void *" "int" */ +#define __NR_swapctl 193 + +/* syscall: "getrlimit" ret: "int" args: "int" "struct rlimit *" */ +#define __NR_getrlimit 194 + +/* syscall: "setrlimit" ret: "int" args: "int" "const struct rlimit *" */ +#define __NR_setrlimit 195 + +/* syscall: "getdirentries" ret: "int" args: "int" "char *" "int" "long *" */ +#define __NR_getdirentries 196 + +/* syscall: "mmap" ret: "void *" args: "void *" "size_t" "int" "int" "int" "long" "off_t" */ +#define __NR_mmap 197 + +/* syscall: "__syscall" ret: "quad_t" args: "quad_t" "..." */ +#define __NR___syscall 198 + +/* syscall: "lseek" ret: "off_t" args: "int" "int" "off_t" "int" */ +#define __NR_lseek 199 + +/* syscall: "truncate" ret: "int" args: "const char *" "int" "off_t" */ +#define __NR_truncate 200 + +/* syscall: "ftruncate" ret: "int" args: "int" "int" "off_t" */ +#define __NR_ftruncate 201 + +/* syscall: "__sysctl" ret: "int" args: "int *" "u_int" "void *" "size_t *" "void *" "size_t" */ +#define __NR___sysctl 202 + +/* syscall: "mlock" ret: "int" args: "const void *" "size_t" */ +#define __NR_mlock 203 + +/* syscall: "munlock" ret: "int" args: "const void *" "size_t" */ +#define __NR_munlock 204 + +/* syscall: "undelete" ret: "int" args: "const char *" */ +#define __NR_undelete 205 + +/* syscall: "futimes" ret: "int" args: "int" "const struct timeval *" */ +#define __NR_futimes 206 + +/* syscall: "getpgid" ret: "pid_t" args: "pid_t" */ +#define __NR_getpgid 207 + +/* syscall: "xfspioctl" ret: "int" args: "int" "char *" "int" "struct ViceIoctl *" "int" */ +#define __NR_xfspioctl 208 + +/* 220 is compat_23 __osemctl */ + +/* syscall: "semget" ret: "int" args: "key_t" "int" "int" */ +#define __NR_semget 221 + +/* syscall: "semop" ret: "int" args: "int" "struct sembuf *" "u_int" */ +#define __NR_semop 222 + +/* 223 is obsolete sys_semconfig */ +/* 224 is compat_23 omsgctl */ + +/* syscall: "msgget" ret: "int" args: "key_t" "int" */ +#define __NR_msgget 225 + +/* syscall: "msgsnd" ret: "int" args: "int" "const void *" "size_t" "int" */ +#define __NR_msgsnd 226 + +/* syscall: "msgrcv" ret: "int" args: "int" "void *" "size_t" "long" "int" */ +#define __NR_msgrcv 227 + +/* syscall: "shmat" ret: "void *" args: "int" "const void *" "int" */ +#define __NR_shmat 228 + +/* 229 is compat_23 oshmctl */ + +/* syscall: "shmdt" ret: "int" args: "const void *" */ +#define __NR_shmdt 230 + +/* syscall: "shmget" ret: "int" args: "key_t" "int" "int" */ +#define __NR_shmget 231 + +/* syscall: "clock_gettime" ret: "int" args: "clockid_t" "struct timespec *" */ +#define __NR_clock_gettime 232 + +/* syscall: "clock_settime" ret: "int" args: "clockid_t" "const struct timespec *" */ +#define __NR_clock_settime 233 + +/* syscall: "clock_getres" ret: "int" args: "clockid_t" "struct timespec *" */ +#define __NR_clock_getres 234 + +/* syscall: "nanosleep" ret: "int" args: "const struct timespec *" "struct timespec *" */ +#define __NR_nanosleep 240 + +/* syscall: "minherit" ret: "int" args: "void *" "size_t" "int" */ +#define __NR_minherit 250 + +/* syscall: "rfork" ret: "int" args: "int" */ +#define __NR_rfork 251 + +/* syscall: "poll" ret: "int" args: "struct pollfd *" "unsigned long" "int" */ +#define __NR_poll 252 + +/* syscall: "issetugid" ret: "int" args: */ +#define __NR_issetugid 253 + +/* syscall: "lchown" ret: "int" args: "const char *" "uid_t" "gid_t" */ +#define __NR_lchown 254 + +/* syscall: "getsid" ret: "pid_t" args: "pid_t" */ +#define __NR_getsid 255 + +/* syscall: "msync" ret: "int" args: "void *" "size_t" "int" */ +#define __NR_msync 256 + +/* syscall: "__semctl" ret: "int" args: "int" "int" "int" "union semun *" */ +#define __NR___semctl 257 + +/* syscall: "shmctl" ret: "int" args: "int" "int" "struct shmid_ds *" */ +#define __NR_shmctl 258 + +/* syscall: "msgctl" ret: "int" args: "int" "int" "struct msqid_ds *" */ +#define __NR_msgctl 259 + +/* syscall: "getfsstat" ret: "int" args: "struct statfs *" "size_t" "int" */ +#define __NR_getfsstat 260 + +/* syscall: "statfs" ret: "int" args: "const char *" "struct statfs *" */ +#define __NR_statfs 261 + +/* syscall: "fstatfs" ret: "int" args: "int" "struct statfs *" */ +#define __NR_fstatfs 262 + +/* syscall: "pipe" ret: "int" args: "int *" */ +#define __NR_pipe 263 + +/* syscall: "fhopen" ret: "int" args: "const fhandle_t *" "int" */ +#define __NR_fhopen 264 + +/* syscall: "fhstat" ret: "int" args: "const fhandle_t *" "struct stat *" */ +#define __NR_fhstat 265 + +/* syscall: "fhstatfs" ret: "int" args: "const fhandle_t *" "struct statfs *" */ +#define __NR_fhstatfs 266 + +/* syscall: "preadv" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */ +#define __NR_preadv 267 + +/* syscall: "pwritev" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */ +#define __NR_pwritev 268 + +/* syscall: "kqueue" ret: "int" args: */ +#define __NR_kqueue 269 + +/* syscall: "kevent" ret: "int" args: "int" "const struct kevent *" "int" "struct kevent *" "int" "const struct timespec *" */ +#define __NR_kevent 270 + +/* syscall: "mlockall" ret: "int" args: "int" */ +#define __NR_mlockall 271 + +/* syscall: "munlockall" ret: "int" args: */ +#define __NR_munlockall 272 + +/* syscall: "getpeereid" ret: "int" args: "int" "uid_t *" "gid_t *" */ +#define __NR_getpeereid 273 + +/* syscall: "extattrctl" ret: "int" args: "const char *" "int" "const char *" "int" "const char *" */ +#define __NR_extattrctl 274 + +/* syscall: "extattr_set_file" ret: "int" args: "const char *" "int" "const char *" "void *" "size_t" */ +#define __NR_extattr_set_file 275 + +/* syscall: "extattr_get_file" ret: "ssize_t" args: "const char *" "int" "const char *" "void *" "size_t" */ +#define __NR_extattr_get_file 276 + +/* syscall: "extattr_delete_file" ret: "int" args: "const char *" "int" "const char *" */ +#define __NR_extattr_delete_file 277 + +/* syscall: "extattr_set_fd" ret: "int" args: "int" "int" "const char *" "void *" "size_t" */ +#define __NR_extattr_set_fd 278 + +/* syscall: "extattr_get_fd" ret: "ssize_t" args: "int" "int" "const char *" "void *" "size_t" */ +#define __NR_extattr_get_fd 279 + +/* syscall: "extattr_delete_fd" ret: "int" args: "int" "int" "const char *" */ +#define __NR_extattr_delete_fd 280 + +#define __NR_MAXSYSCALL 281 + +#endif /* SFSYSNR_H */ diff --git a/dest/include/librz/sflib/linux-arm-32/sflib.h b/dest/include/librz/sflib/linux-arm-32/sflib.h new file mode 100644 index 00000000000..20bee69d3ea --- /dev/null +++ b/dest/include/librz/sflib/linux-arm-32/sflib.h @@ -0,0 +1,272 @@ +/* + * sflib.h --- SFLib syscall library for Linux/ARM + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + + +/* + * Automatically generated by gensflib.py + * Mon Mar 21 13:23:31 2022 + */ + +#ifndef SFLIB_H +#define SFLIB_H + + +#include "sfsysnr.h" +#include "sfsyscall.h" +#include "../common/sftypes.h" + +static inline _sfsyscall1(int, exit, int, status) +static inline _sfsyscall0( pid_t, fork ) +static inline _sfsyscall3( ssize_t, read, int, fd, void *, buf, size_t, count ) +static inline _sfsyscall3( ssize_t, write, int, fd, const void *, buf, size_t, count ) +static inline _sfsyscall3( int, open, const char *, pathname, int, flags, mode_t, mode ) +static inline _sfsyscall1( int, close, int, fd ) +static inline _sfsyscall2( int, creat, const char *, pathname, mode_t, mode ) +static inline _sfsyscall2( int, link, const char *, oldpath, const char *, newpath ) +static inline _sfsyscall1( int, unlink, const char *, pathname ) +static inline _sfsyscall3(int, execve, char *, s, char **, argv, char **,envp) +static inline _sfsyscall1( int, chdir, const char *, path ) +static inline _sfsyscall1( time_t, time, time_t *, t ) +static inline _sfsyscall3( int, mknod, const char *, pathname, mode_t, mode, dev_t, dev ) +static inline _sfsyscall2( int, chmod, const char *, path, mode_t, mode ) +static inline _sfsyscall3( int, lchown, const char *, path, uid_t, owner, gid_t, group ) +// break +static inline _sfsyscall3( off_t, lseek, int, fildes, off_t, offset, int, whence ) +static inline _sfsyscall0( pid_t, getpid ) +// mount +static inline _sfsyscall1( int, umount, const char *, dir ) +// setuid +static inline _sfsyscall0( uid_t, getuid ) +static inline _sfsyscall1( int, stime, time_t *, t ) +static inline _sfsyscall4(long, ptrace, int, request, pid_t, pid, void *,addr, void *,data) +static inline _sfsyscall1( unsigned int, alarm, unsigned int, seconds ) +static inline _sfsyscall0( int, pause ) +static inline _sfsyscall2( int, utime, const char *, filename, struct utimbuf *, buf ) +// stty +// gtty +static inline _sfsyscall2( int, access, const char *, pathname, int, mode ) +static inline _sfsyscall1( int, nice, int, inc ) +// ftime +static inline _sfsyscall0( int, sync ) +static inline _sfsyscall2( int, kill, pid_t, pid, int, sig ) +static inline _sfsyscall2( int, rename, const char *, oldpath, const char *, newpath ) +static inline _sfsyscall2( int, mkdir, const char *, pathname, mode_t, mode ) +static inline _sfsyscall1( int, rmdir, const char *, pathname ) +static inline _sfsyscall1( int, dup, int, oldfd ) +static inline _sfsyscall1( int, pipe, unsigned long *, filedes) +static inline _sfsyscall1( clock_t, times, struct tms *, buf ) +// prof +static inline _sfsyscall1( int, brk, void *, end_data_segment ) +// setgid +static inline _sfsyscall0( gid_t, getgid ) +static inline _sfsyscall2( sighandler_t, signal, int, signum, sighandler_t, handler ) +static inline _sfsyscall0( uid_t, geteuid ) +static inline _sfsyscall0( gid_t, getegid ) +static inline _sfsyscall1( int, acct, const char *, filename ) +// umount2 +// lock +static inline _sfsyscall4(int, ioctl, int,d, int,request, char *,argp, int,len) +static inline _sfsyscall3( int, fcntl, int, fd, int, cmd, long, arg ) +// mpx +static inline _sfsyscall2( int, setpgid, pid_t, pid, pid_t, pgid ) +// ulimit +static inline _sfsyscall1( mode_t, umask, mode_t, mask ) +static inline _sfsyscall1( int, chroot, const char *, path ) +static inline _sfsyscall2( int, ustat, dev_t, dev, struct ustat *, ubuf ) +static inline _sfsyscall2( int, dup2, int, oldfd, int, newfd ) +static inline _sfsyscall0( pid_t, getppid ) +static inline _sfsyscall0( pid_t, getpgrp ) +static inline _sfsyscall0( pid_t, setsid ) +// sigaction +// sgetmask +// ssetmask +static inline _sfsyscall2( int, setreuid, uid_t, ruid, uid_t, euid ) +static inline _sfsyscall2( int, setregid, gid_t, rgid, gid_t, egid ) +static inline _sfsyscall1( int, sigsuspend, const sigset_t *, mask ) +static inline _sfsyscall1( int, sigpending, sigset_t *, set ) +static inline _sfsyscall2( int, sethostname, const char *, name, size_t, len ) +// setrlimit +// getrlimit +// getrusage +static inline _sfsyscall2( int, gettimeofday, struct timeval *, tv, struct timezone *, tz ) +// settimeofday +// getgroups +static inline _sfsyscall2( int, setgroups, size_t, size, const gid_t *, list ) +static inline _sfsyscall5( int, select, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout) +static inline _sfsyscall2( int, symlink, const char *, oldpath, const char *, newpath ) +static inline _sfsyscall3( int, readlink, const char *, path, char *, buf, size_t, bufsiz ) +static inline _sfsyscall1( int, uselib, const char *, library ) +static inline _sfsyscall2( int, swapon, const char *, path, int, swapflags ) +// reboot +static inline _sfsyscall3( int, readdir, unsigned int, fd, struct dirent *, dirp, unsigned int, count ) +static inline _sfsyscall6(void *,mmap, void *,start, size_t,length, int,prot , int,flags, int,fd, off_t,offset) +static inline _sfsyscall2( int, munmap, void *, start, size_t, length ) +static inline _sfsyscall2( int, truncate, const char *, path, off_t, length ) +static inline _sfsyscall2( int, ftruncate, int, fd, off_t, length ) +static inline _sfsyscall2( int, fchmod, int, fildes, mode_t, mode ) +static inline _sfsyscall3( int, fchown, int, fd, uid_t, owner, gid_t, group ) +static inline _sfsyscall2( int, getpriority, int, which, int, who ) +static inline _sfsyscall3( int, setpriority, int, which, int, who, int, prio ) +// profil +static inline _sfsyscall2( int, statfs, const char *, path, struct statfs *, buf ) +static inline _sfsyscall2( int, fstatfs, int, fd, struct statfs *, buf ) +static inline _sfsyscall3( int, ioperm, unsigned long, from, unsigned long, num, int, turn_on ) +static inline _sfsyscall2( int, socketcall, int, call, unsigned long *,args); +static inline _sfsyscall3( int, syslog, int, type, char *, bufp, int, len ) +// setitimer +// getitimer +static inline _sfsyscall2( int, stat, const char *, file_name, struct stat *, buf ) +static inline _sfsyscall2( int, lstat, const char *, file_name, struct stat *, buf ) +static inline _sfsyscall2( int, fstat, int, filedes, struct stat *, buf ) +static inline _sfsyscall0( int, vhangup ) +static inline _sfsyscall0( int, idle ) +// syscall +static inline _sfsyscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, struct rusage *, rusage) +static inline _sfsyscall1( int, swapoff, const char *, path ) +static inline _sfsyscall1( int, sysinfo, struct sysinfo *, info ) +// ipc +static inline _sfsyscall1( int, fsync, int, fd ) +static inline _sfsyscall1( int, sigreturn, unsigned long, __unused ) +// clone +static inline _sfsyscall2( int, setdomainname, const char *, name, size_t, len ) +static inline _sfsyscall1( int, uname, struct utsname *, buf ) +// modify_ldt +// adjtimex +static inline _sfsyscall3( int, mprotect, const void *, addr, size_t, len, int, prot ) +// sigprocmask +static inline _sfsyscall2( caddr_t, create_module, const char *, name, size_t, size ) +static inline _sfsyscall2( int, init_module, const char *, name, struct module *, image ) +static inline _sfsyscall1( int, delete_module, const char *, name ) +static inline _sfsyscall1( int, get_kernel_syms, struct kernel_sym *, table ) +// quotactl +static inline _sfsyscall1( pid_t, getpgid, pid_t, pid ) +// fchdir +// bdflush +static inline _sfsyscall3( int, sysfs, int, option, unsigned int, fs_index, char *, buf ) +static inline _sfsyscall1( int, personality, unsigned long, persona ) +// afs_syscall +static inline _sfsyscall1( int, setfsuid, uid_t, fsuid ) +static inline _sfsyscall1( int, setfsgid, uid_t, fsgid ) +static inline _sfsyscall3( int, getdents, unsigned int, fd, struct dirent *, dirp, unsigned int, count ) +// flock +static inline _sfsyscall3( int, msync, const void *, start, size_t, length, int, flags ) +static inline _sfsyscall3( int, readv, int, fd, const struct iovec *, vector, int, count ) +static inline _sfsyscall3( int, writev, int, fd, const struct iovec *, vector, int, count ) +static inline _sfsyscall1( pid_t, getsid, pid_t, pid ) +static inline _sfsyscall1( int, fdatasync, int, fd ) +static inline _sfsyscall2( int, mlock, const void *, addr, size_t, len ) +static inline _sfsyscall2( int, munlock, const void *, addr, size_t, len ) +static inline _sfsyscall1( int, mlockall, int, flags ) +static inline _sfsyscall0( int, munlockall ) +static inline _sfsyscall2( int, sched_setparam, pid_t, pid, const struct sched_param *, p ) +static inline _sfsyscall2( int, sched_getparam, pid_t, pid, struct sched_param *, p ) +// sched_setscheduler +static inline _sfsyscall1( int, sched_getscheduler, pid_t, pid ) +static inline _sfsyscall0( int, sched_yield ) +static inline _sfsyscall1( int, sched_get_priority_max, int, policy ) +static inline _sfsyscall1( int, sched_get_priority_min, int, policy ) +static inline _sfsyscall2( int, sched_rr_get_interval, pid_t, pid, struct timespec *, tp ) +static inline _sfsyscall2( int, nanosleep, const struct timespec *, req, struct timespec *, rem ) +// mremap +static inline _sfsyscall3( int, setresuid, uid_t, ruid, uid_t, euid, uid_t, suid ) +static inline _sfsyscall3( int, getresuid, uid_t *, ruid, uid_t *, euid, uid_t *, suid ) +static inline _sfsyscall2( int, vm86, unsigned long, fn, struct vm86plus_struct *, v86 ) +// query_module +static inline _sfsyscall3( int, poll, struct pollfd *, ufds, unsigned int, nfds, int, timeout ) +// nfsservctl +// setresgid +// getresgid +// prctl +// rt_sigreturn +// rt_sigaction +// rt_sigprocmask +// rt_sigpending +// rt_sigtimedwait +// rt_sigqueueinfo +// rt_sigsuspend +static inline _sfsyscall4( ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset ) +// pwrite +static inline _sfsyscall3( int, chown, const char *, path, uid_t, owner, gid_t, group ) +// getcwd +static inline _sfsyscall2( int, capget, cap_user_header_t, header, cap_user_data_t, data ) +//static inline _sfsyscall2( int, capset, cap_user_header_t, header, const cap_user_data_t, data ) +// sigaltstack +// sendfile +static inline _sfsyscall0( pid_t, vfork ) +// ugetrlimit +// mmap2 +// truncate64 +// ftruncate64 +// stat64 +// lstat64 +// fstat64 +// lchown32 +// getuid32 +// getgid32 +// geteuid32 +// getegid32 +// setreuid32 +// setregid32 +// getgroups32 +// setgroups32 +// fchown32 +// setresuid32 +// getresuid32 +// setresgid32 +// getresgid32 +// chown32 +// setuid32 +// setgid32 +// setfsuid32 +// setfsgid32 +// getdents64 +// pivot_root +// mincore +// madvise +// fcntl64 +// security +// gettid +// readahead +// setxattr +// lsetxattr +// fsetxattr +// getxattr +// lgetxattr +// fgetxattr +// listxattr +// llistxattr +// flistxattr +// removexattr +// lremovexattr +// fremovexattr +// tkill +// sendfile64 +// futex +// sched_setaffinity +// sched_getaffinity +// io_setup +// io_destroy +// io_getevents +// io_submit +// io_cancel +// exit_group +// lookup_dcookie +// epoll_create +// epoll_ctl +// epoll_wait +// remap_file_pages + +#endif /* SFLIB_H */ diff --git a/dest/include/librz/sflib/linux-arm-32/sfsyscall.h b/dest/include/librz/sflib/linux-arm-32/sfsyscall.h new file mode 100644 index 00000000000..baad4fd5aef --- /dev/null +++ b/dest/include/librz/sflib/linux-arm-32/sfsyscall.h @@ -0,0 +1,174 @@ +/* sfsyscall.h --- SFLib syscall macros for Linux/arm64 - pancake */ + +#ifndef SFSYSCALL_H +#define SFSYSCALL_H + +/* $Id$ */ + +#ifdef SF_USE_ERRNO + +static int errno = 1234; + +#define __sfsyscall_return(type, res) \ + do { \ + if ((unsigned long)(res) >= (unsigned long)(-125)) { \ + errno = -(res); \ + res = -1; \ + } \ + return (type)(res); \ + } while (0) + +#else /* SF_USE_ERRNO */ + +#define __sfsyscall_return(type, res) \ + do { \ + return (type)(res); \ + } while (0) + +#endif /* SF_USE_ERRNO */ + +/* syscall macros */ + +#define _sfsyscall0(type, name) \ + type name(void) { \ + long __res; \ + __asm__ volatile("###> " #name " <###\n\t" \ + "svc 0" \ + : "=a"(__res) \ + : "0"(__NR_##name) \ + : "memory", "cc"); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall1(type, name, type1, arg1) \ + type name(type1 arg1) { \ + long __res; \ + register type1 r1 asm("r0"); \ + r1 = arg1; \ + asm volatile("###> " #name "(%2) <###\n\t" \ + "mov r7, %0\n\t" \ + "svc 0" \ + : "=g"(__res) \ + : "0"(__NR_##name), "r"(r1)); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall2(type, name, type1, arg1, type2, arg2) \ + type name(type1 arg1, type2 arg2) { \ + long __res; \ + register type1 r1 asm("r1"); \ + register type2 r2 asm("r2"); \ + r1 = arg1; \ + r2 = arg2; \ + __asm__ volatile("###> " #name "(%2, %3) <###\n\t" \ + "svc 0" \ + : "=g"(__res) \ + : "0"(__NR_##name), \ + "r"(r1), \ + "r"(r2)); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ + type name(type1 arg1, type2 arg2, type3 arg3) { \ + long __res; \ + register type1 r0 asm("r0"); \ + register type2 r1 asm("r1"); \ + register type3 r2 asm("r2"); \ + r0 = arg1; \ + r1 = arg2; \ + r2 = arg3; \ + __asm__ __volatile__("###> " #name "(%2, %3, %4) <###\n\t" \ + "mov r7, %1\n\t" \ + "svc 0" \ + : "=g"(__res) \ + : "0"(__NR_##name), \ + "r"(r0), \ + "r"(r1), \ + "r"(r2) \ + : "memory", "cc"); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall4(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ + long __res; \ + register type1 r1 asm("r1"); \ + ; \ + register type2 r2 asm("r2"); \ + register type3 r3 asm("r3"); \ + register type4 r4 asm("r4"); \ + r1 = arg1; \ + r2 = arg2; \ + r3 = arg3; \ + r4 = arg4; \ + asm volatile("###> " #name "(%2, %3, %4, %5) <###\n\t" \ + "svc 0" \ + : "=g"(__res) \ + : "0"(__NR_##name), \ + "r"(r1), \ + "r"(r2), \ + "r"(r3), \ + "r"(r4) \ + : "memory", "cc"); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall5(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) \ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ + type5 arg5) { \ + long __res; \ + register type1 r1 asm("r1"); \ + register type2 r2 asm("r2"); \ + register type3 r3 asm("r3"); \ + register type4 r4 asm("r4"); \ + register type5 r5 asm("r5"); \ + r1 = arg1; \ + r2 = arg2; \ + r3 = arg3; \ + r4 = arg4; \ + r5 = arg5; \ + asm volatile("###> " #name "(%2, %3, %4, %5, %6) <###\n\t" \ + "svc 0" \ + : "=g"(__res) \ + : "0"(__NR_##name), \ + "r"(r1), \ + "r"(r2), \ + "r"(r3), \ + "r"(r4), \ + "r"(r5) \ + : "memory", "cc"); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall6(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ + type5 arg5, type6 arg6) { \ + long __res; \ + register type1 r1 asm("r1"); \ + register type2 r2 asm("r2"); \ + register type3 r3 asm("r3"); \ + register type4 r4 asm("r4"); \ + register type5 r5 asm("r5"); \ + register type6 r6 asm("r6"); \ + r1 = arg1; \ + r2 = arg2; \ + r3 = arg3; \ + r4 = arg4; \ + r5 = arg5; \ + r6 = arg6; \ + asm volatile("###> " #name "(%2, %3, %4, %5, %6, %7) <###\n\t" \ + "svc 0" \ + : "=a"(__res) \ + : "0"(__NR_##name), \ + "r"(r1), \ + "r"(r2), \ + "r"(r3), \ + "r"(r4), \ + "r"(r5), \ + "r"(r6) \ + : "memory", "cc"); \ + __sfsyscall_return(type, __res); \ + } + +#endif /* SFSYSCALL_H */ diff --git a/dest/include/librz/sflib/linux-arm-32/sfsysnr.h b/dest/include/librz/sflib/linux-arm-32/sfsysnr.h new file mode 100644 index 00000000000..c1967a280e9 --- /dev/null +++ b/dest/include/librz/sflib/linux-arm-32/sfsysnr.h @@ -0,0 +1,316 @@ +/* + * sfsysnr.h --- SFLib syscall numbers for Linux/ARM + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + + +/* + * Automatically generated by gensflib.py + * Mon Mar 21 13:23:31 2022 + */ + +#ifndef SFSYSNR_H +#define SFSYSNR_H + + +/* $Id$ */ + +/* + * From linux/include/asm-arm/unistd.h + * Copyright (C) 2001-2002 Russell King + */ + + +#if defined(__thumb__) +#define __NR_SYSCALL_BASE 0 +#else +#define __NR_SYSCALL_BASE 0x900000 +#endif + +/* + * This file contains the system call numbers. + */ + +#define __NR_exit (__NR_SYSCALL_BASE+ 1) +#define __NR_fork (__NR_SYSCALL_BASE+ 2) +#define __NR_read (__NR_SYSCALL_BASE+ 3) +#define __NR_write (__NR_SYSCALL_BASE+ 4) +#define __NR_open (__NR_SYSCALL_BASE+ 5) +#define __NR_close (__NR_SYSCALL_BASE+ 6) +/*#define __NR_waitpid (__NR_SYSCALL_BASE+ 7) debian bug #201989 ARM doesnt have this syscall and its define breaks glibc*/ +#define __NR_creat (__NR_SYSCALL_BASE+ 8) +#define __NR_link (__NR_SYSCALL_BASE+ 9) +#define __NR_unlink (__NR_SYSCALL_BASE+ 10) +#define __NR_execve (__NR_SYSCALL_BASE+ 11) +#define __NR_chdir (__NR_SYSCALL_BASE+ 12) +#define __NR_time (__NR_SYSCALL_BASE+ 13) +#define __NR_mknod (__NR_SYSCALL_BASE+ 14) +#define __NR_chmod (__NR_SYSCALL_BASE+ 15) +#define __NR_lchown (__NR_SYSCALL_BASE+ 16) +#define __NR_break (__NR_SYSCALL_BASE+ 17) + +#define __NR_lseek (__NR_SYSCALL_BASE+ 19) +#define __NR_getpid (__NR_SYSCALL_BASE+ 20) +#define __NR_mount (__NR_SYSCALL_BASE+ 21) +#define __NR_umount (__NR_SYSCALL_BASE+ 22) +#define __NR_setuid (__NR_SYSCALL_BASE+ 23) +#define __NR_getuid (__NR_SYSCALL_BASE+ 24) +#define __NR_stime (__NR_SYSCALL_BASE+ 25) +#define __NR_ptrace (__NR_SYSCALL_BASE+ 26) +#define __NR_alarm (__NR_SYSCALL_BASE+ 27) + +#define __NR_pause (__NR_SYSCALL_BASE+ 29) +#define __NR_utime (__NR_SYSCALL_BASE+ 30) +#define __NR_stty (__NR_SYSCALL_BASE+ 31) +#define __NR_gtty (__NR_SYSCALL_BASE+ 32) +#define __NR_access (__NR_SYSCALL_BASE+ 33) +#define __NR_nice (__NR_SYSCALL_BASE+ 34) +#define __NR_ftime (__NR_SYSCALL_BASE+ 35) +#define __NR_sync (__NR_SYSCALL_BASE+ 36) +#define __NR_kill (__NR_SYSCALL_BASE+ 37) +#define __NR_rename (__NR_SYSCALL_BASE+ 38) +#define __NR_mkdir (__NR_SYSCALL_BASE+ 39) +#define __NR_rmdir (__NR_SYSCALL_BASE+ 40) +#define __NR_dup (__NR_SYSCALL_BASE+ 41) +#define __NR_pipe (__NR_SYSCALL_BASE+ 42) +#define __NR_times (__NR_SYSCALL_BASE+ 43) +#define __NR_prof (__NR_SYSCALL_BASE+ 44) +#define __NR_brk (__NR_SYSCALL_BASE+ 45) +#define __NR_setgid (__NR_SYSCALL_BASE+ 46) +#define __NR_getgid (__NR_SYSCALL_BASE+ 47) +#define __NR_signal (__NR_SYSCALL_BASE+ 48) +#define __NR_geteuid (__NR_SYSCALL_BASE+ 49) +#define __NR_getegid (__NR_SYSCALL_BASE+ 50) +#define __NR_acct (__NR_SYSCALL_BASE+ 51) +#define __NR_umount2 (__NR_SYSCALL_BASE+ 52) +#define __NR_lock (__NR_SYSCALL_BASE+ 53) +#define __NR_ioctl (__NR_SYSCALL_BASE+ 54) +#define __NR_fcntl (__NR_SYSCALL_BASE+ 55) +#define __NR_mpx (__NR_SYSCALL_BASE+ 56) +#define __NR_setpgid (__NR_SYSCALL_BASE+ 57) +#define __NR_ulimit (__NR_SYSCALL_BASE+ 58) + +#define __NR_umask (__NR_SYSCALL_BASE+ 60) +#define __NR_chroot (__NR_SYSCALL_BASE+ 61) +#define __NR_ustat (__NR_SYSCALL_BASE+ 62) +#define __NR_dup2 (__NR_SYSCALL_BASE+ 63) +#define __NR_getppid (__NR_SYSCALL_BASE+ 64) +#define __NR_getpgrp (__NR_SYSCALL_BASE+ 65) +#define __NR_setsid (__NR_SYSCALL_BASE+ 66) +#define __NR_sigaction (__NR_SYSCALL_BASE+ 67) +#define __NR_sgetmask (__NR_SYSCALL_BASE+ 68) +#define __NR_ssetmask (__NR_SYSCALL_BASE+ 69) +#define __NR_setreuid (__NR_SYSCALL_BASE+ 70) +#define __NR_setregid (__NR_SYSCALL_BASE+ 71) +#define __NR_sigsuspend (__NR_SYSCALL_BASE+ 72) +#define __NR_sigpending (__NR_SYSCALL_BASE+ 73) +#define __NR_sethostname (__NR_SYSCALL_BASE+ 74) +#define __NR_setrlimit (__NR_SYSCALL_BASE+ 75) +#define __NR_getrlimit (__NR_SYSCALL_BASE+ 76) /* Back compat 2GB limited rlimit */ +#define __NR_getrusage (__NR_SYSCALL_BASE+ 77) +#define __NR_gettimeofday (__NR_SYSCALL_BASE+ 78) +#define __NR_settimeofday (__NR_SYSCALL_BASE+ 79) +#define __NR_getgroups (__NR_SYSCALL_BASE+ 80) +#define __NR_setgroups (__NR_SYSCALL_BASE+ 81) +#define __NR_select (__NR_SYSCALL_BASE+ 82) +#define __NR_symlink (__NR_SYSCALL_BASE+ 83) + +#define __NR_readlink (__NR_SYSCALL_BASE+ 85) +#define __NR_uselib (__NR_SYSCALL_BASE+ 86) +#define __NR_swapon (__NR_SYSCALL_BASE+ 87) +#define __NR_reboot (__NR_SYSCALL_BASE+ 88) +#define __NR_readdir (__NR_SYSCALL_BASE+ 89) +#define __NR_mmap (__NR_SYSCALL_BASE+ 90) +#define __NR_munmap (__NR_SYSCALL_BASE+ 91) +#define __NR_truncate (__NR_SYSCALL_BASE+ 92) +#define __NR_ftruncate (__NR_SYSCALL_BASE+ 93) +#define __NR_fchmod (__NR_SYSCALL_BASE+ 94) +#define __NR_fchown (__NR_SYSCALL_BASE+ 95) +#define __NR_getpriority (__NR_SYSCALL_BASE+ 96) +#define __NR_setpriority (__NR_SYSCALL_BASE+ 97) +#define __NR_profil (__NR_SYSCALL_BASE+ 98) +#define __NR_statfs (__NR_SYSCALL_BASE+ 99) +#define __NR_fstatfs (__NR_SYSCALL_BASE+100) +#define __NR_ioperm (__NR_SYSCALL_BASE+101) +#define __NR_socketcall (__NR_SYSCALL_BASE+102) +#define __NR_syslog (__NR_SYSCALL_BASE+103) +#define __NR_setitimer (__NR_SYSCALL_BASE+104) +#define __NR_getitimer (__NR_SYSCALL_BASE+105) +#define __NR_stat (__NR_SYSCALL_BASE+106) +#define __NR_lstat (__NR_SYSCALL_BASE+107) +#define __NR_fstat (__NR_SYSCALL_BASE+108) + + +#define __NR_vhangup (__NR_SYSCALL_BASE+111) +#define __NR_idle (__NR_SYSCALL_BASE+112) +#define __NR_syscall (__NR_SYSCALL_BASE+113) /* syscall to call a syscall! */ +#define __NR_wait4 (__NR_SYSCALL_BASE+114) +#define __NR_swapoff (__NR_SYSCALL_BASE+115) +#define __NR_sysinfo (__NR_SYSCALL_BASE+116) +#define __NR_ipc (__NR_SYSCALL_BASE+117) +#define __NR_fsync (__NR_SYSCALL_BASE+118) +#define __NR_sigreturn (__NR_SYSCALL_BASE+119) +#define __NR_clone (__NR_SYSCALL_BASE+120) +#define __NR_setdomainname (__NR_SYSCALL_BASE+121) +#define __NR_uname (__NR_SYSCALL_BASE+122) +#define __NR_modify_ldt (__NR_SYSCALL_BASE+123) +#define __NR_adjtimex (__NR_SYSCALL_BASE+124) +#define __NR_mprotect (__NR_SYSCALL_BASE+125) +#define __NR_sigprocmask (__NR_SYSCALL_BASE+126) +#define __NR_create_module (__NR_SYSCALL_BASE+127) +#define __NR_init_module (__NR_SYSCALL_BASE+128) +#define __NR_delete_module (__NR_SYSCALL_BASE+129) +#define __NR_get_kernel_syms (__NR_SYSCALL_BASE+130) +#define __NR_quotactl (__NR_SYSCALL_BASE+131) +#define __NR_getpgid (__NR_SYSCALL_BASE+132) +#define __NR_fchdir (__NR_SYSCALL_BASE+133) +#define __NR_bdflush (__NR_SYSCALL_BASE+134) +#define __NR_sysfs (__NR_SYSCALL_BASE+135) +#define __NR_personality (__NR_SYSCALL_BASE+136) +#define __NR_afs_syscall (__NR_SYSCALL_BASE+137) /* Syscall for Andrew File System */ +#define __NR_setfsuid (__NR_SYSCALL_BASE+138) +#define __NR_setfsgid (__NR_SYSCALL_BASE+139) +#define __NR__llseek (__NR_SYSCALL_BASE+140) +#define __NR_getdents (__NR_SYSCALL_BASE+141) +#define __NR__newselect (__NR_SYSCALL_BASE+142) +#define __NR_flock (__NR_SYSCALL_BASE+143) +#define __NR_msync (__NR_SYSCALL_BASE+144) +#define __NR_readv (__NR_SYSCALL_BASE+145) +#define __NR_writev (__NR_SYSCALL_BASE+146) +#define __NR_getsid (__NR_SYSCALL_BASE+147) +#define __NR_fdatasync (__NR_SYSCALL_BASE+148) +#define __NR__sysctl (__NR_SYSCALL_BASE+149) +#define __NR_mlock (__NR_SYSCALL_BASE+150) +#define __NR_munlock (__NR_SYSCALL_BASE+151) +#define __NR_mlockall (__NR_SYSCALL_BASE+152) +#define __NR_munlockall (__NR_SYSCALL_BASE+153) +#define __NR_sched_setparam (__NR_SYSCALL_BASE+154) +#define __NR_sched_getparam (__NR_SYSCALL_BASE+155) +#define __NR_sched_setscheduler (__NR_SYSCALL_BASE+156) +#define __NR_sched_getscheduler (__NR_SYSCALL_BASE+157) +#define __NR_sched_yield (__NR_SYSCALL_BASE+158) +#define __NR_sched_get_priority_max (__NR_SYSCALL_BASE+159) +#define __NR_sched_get_priority_min (__NR_SYSCALL_BASE+160) +#define __NR_sched_rr_get_interval (__NR_SYSCALL_BASE+161) +#define __NR_nanosleep (__NR_SYSCALL_BASE+162) +#define __NR_mremap (__NR_SYSCALL_BASE+163) +#define __NR_setresuid (__NR_SYSCALL_BASE+164) +#define __NR_getresuid (__NR_SYSCALL_BASE+165) +#define __NR_vm86 (__NR_SYSCALL_BASE+166) +#define __NR_query_module (__NR_SYSCALL_BASE+167) +#define __NR_poll (__NR_SYSCALL_BASE+168) +#define __NR_nfsservctl (__NR_SYSCALL_BASE+169) +#define __NR_setresgid (__NR_SYSCALL_BASE+170) +#define __NR_getresgid (__NR_SYSCALL_BASE+171) +#define __NR_prctl (__NR_SYSCALL_BASE+172) +#define __NR_rt_sigreturn (__NR_SYSCALL_BASE+173) +#define __NR_rt_sigaction (__NR_SYSCALL_BASE+174) +#define __NR_rt_sigprocmask (__NR_SYSCALL_BASE+175) +#define __NR_rt_sigpending (__NR_SYSCALL_BASE+176) +#define __NR_rt_sigtimedwait (__NR_SYSCALL_BASE+177) +#define __NR_rt_sigqueueinfo (__NR_SYSCALL_BASE+178) +#define __NR_rt_sigsuspend (__NR_SYSCALL_BASE+179) +#define __NR_pread (__NR_SYSCALL_BASE+180) +#define __NR_pwrite (__NR_SYSCALL_BASE+181) +#define __NR_chown (__NR_SYSCALL_BASE+182) +#define __NR_getcwd (__NR_SYSCALL_BASE+183) +#define __NR_capget (__NR_SYSCALL_BASE+184) +#define __NR_capset (__NR_SYSCALL_BASE+185) +#define __NR_sigaltstack (__NR_SYSCALL_BASE+186) +#define __NR_sendfile (__NR_SYSCALL_BASE+187) + /* 188 reserved */ + /* 189 reserved */ +#define __NR_vfork (__NR_SYSCALL_BASE+190) +#define __NR_ugetrlimit (__NR_SYSCALL_BASE+191) /* SuS compliant getrlimit */ +#define __NR_mmap2 (__NR_SYSCALL_BASE+192) +#define __NR_truncate64 (__NR_SYSCALL_BASE+193) +#define __NR_ftruncate64 (__NR_SYSCALL_BASE+194) +#define __NR_stat64 (__NR_SYSCALL_BASE+195) +#define __NR_lstat64 (__NR_SYSCALL_BASE+196) +#define __NR_fstat64 (__NR_SYSCALL_BASE+197) +#define __NR_lchown32 (__NR_SYSCALL_BASE+198) +#define __NR_getuid32 (__NR_SYSCALL_BASE+199) +#define __NR_getgid32 (__NR_SYSCALL_BASE+200) +#define __NR_geteuid32 (__NR_SYSCALL_BASE+201) +#define __NR_getegid32 (__NR_SYSCALL_BASE+202) +#define __NR_setreuid32 (__NR_SYSCALL_BASE+203) +#define __NR_setregid32 (__NR_SYSCALL_BASE+204) +#define __NR_getgroups32 (__NR_SYSCALL_BASE+205) +#define __NR_setgroups32 (__NR_SYSCALL_BASE+206) +#define __NR_fchown32 (__NR_SYSCALL_BASE+207) +#define __NR_setresuid32 (__NR_SYSCALL_BASE+208) +#define __NR_getresuid32 (__NR_SYSCALL_BASE+209) +#define __NR_setresgid32 (__NR_SYSCALL_BASE+210) +#define __NR_getresgid32 (__NR_SYSCALL_BASE+211) +#define __NR_chown32 (__NR_SYSCALL_BASE+212) +#define __NR_setuid32 (__NR_SYSCALL_BASE+213) +#define __NR_setgid32 (__NR_SYSCALL_BASE+214) +#define __NR_setfsuid32 (__NR_SYSCALL_BASE+215) +#define __NR_setfsgid32 (__NR_SYSCALL_BASE+216) +#define __NR_getdents64 (__NR_SYSCALL_BASE+217) +#define __NR_pivot_root (__NR_SYSCALL_BASE+218) +#define __NR_mincore (__NR_SYSCALL_BASE+219) +#define __NR_madvise (__NR_SYSCALL_BASE+220) +#define __NR_fcntl64 (__NR_SYSCALL_BASE+221) + /* 222 for tux */ +#define __NR_security (__NR_SYSCALL_BASE+223) +#define __NR_gettid (__NR_SYSCALL_BASE+224) +#define __NR_readahead (__NR_SYSCALL_BASE+225) +#if 0 /* allocated in 2.5 */ +#define __NR_setxattr (__NR_SYSCALL_BASE+226) +#define __NR_lsetxattr (__NR_SYSCALL_BASE+227) +#define __NR_fsetxattr (__NR_SYSCALL_BASE+228) +#define __NR_getxattr (__NR_SYSCALL_BASE+229) +#define __NR_lgetxattr (__NR_SYSCALL_BASE+230) +#define __NR_fgetxattr (__NR_SYSCALL_BASE+231) +#define __NR_listxattr (__NR_SYSCALL_BASE+232) +#define __NR_llistxattr (__NR_SYSCALL_BASE+233) +#define __NR_flistxattr (__NR_SYSCALL_BASE+234) +#define __NR_removexattr (__NR_SYSCALL_BASE+235) +#define __NR_lremovexattr (__NR_SYSCALL_BASE+236) +#define __NR_fremovexattr (__NR_SYSCALL_BASE+237) +#endif +#define __NR_tkill (__NR_SYSCALL_BASE+238) +#if 0 /* allocated in 2.5 */ +#define __NR_sendfile64 (__NR_SYSCALL_BASE+239) +#define __NR_futex (__NR_SYSCALL_BASE+240) +#define __NR_sched_setaffinity (__NR_SYSCALL_BASE+241) +#define __NR_sched_getaffinity (__NR_SYSCALL_BASE+242) +#define __NR_io_setup (__NR_SYSCALL_BASE+243) +#define __NR_io_destroy (__NR_SYSCALL_BASE+244) +#define __NR_io_getevents (__NR_SYSCALL_BASE+245) +#define __NR_io_submit (__NR_SYSCALL_BASE+246) +#define __NR_io_cancel (__NR_SYSCALL_BASE+247) +#define __NR_exit_group (__NR_SYSCALL_BASE+248) +#define __NR_lookup_dcookie (__NR_SYSCALL_BASE+249) +#define __NR_epoll_create (__NR_SYSCALL_BASE+250) +#define __NR_epoll_ctl (__NR_SYSCALL_BASE+251) +#define __NR_epoll_wait (__NR_SYSCALL_BASE+252) +#define __NR_remap_file_pages (__NR_SYSCALL_BASE+253) + /* 254 for set_thread_area */ + /* 255 for get_thread_area */ + /* 256 for set_tid_address */ +#endif + +/* + * The following SWIs are ARM private. + */ +#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000) +#define __ARM_NR_breakpoint (__ARM_NR_BASE+1) +#define __ARM_NR_cacheflush (__ARM_NR_BASE+2) +#define __ARM_NR_usr26 (__ARM_NR_BASE+3) +#define __ARM_NR_usr32 (__ARM_NR_BASE+4) + + +#endif /* SFSYSNR_H */ diff --git a/dest/include/librz/sflib/linux-arm-64/sflib.h b/dest/include/librz/sflib/linux-arm-64/sflib.h new file mode 100644 index 00000000000..20bee69d3ea --- /dev/null +++ b/dest/include/librz/sflib/linux-arm-64/sflib.h @@ -0,0 +1,272 @@ +/* + * sflib.h --- SFLib syscall library for Linux/ARM + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + + +/* + * Automatically generated by gensflib.py + * Mon Mar 21 13:23:31 2022 + */ + +#ifndef SFLIB_H +#define SFLIB_H + + +#include "sfsysnr.h" +#include "sfsyscall.h" +#include "../common/sftypes.h" + +static inline _sfsyscall1(int, exit, int, status) +static inline _sfsyscall0( pid_t, fork ) +static inline _sfsyscall3( ssize_t, read, int, fd, void *, buf, size_t, count ) +static inline _sfsyscall3( ssize_t, write, int, fd, const void *, buf, size_t, count ) +static inline _sfsyscall3( int, open, const char *, pathname, int, flags, mode_t, mode ) +static inline _sfsyscall1( int, close, int, fd ) +static inline _sfsyscall2( int, creat, const char *, pathname, mode_t, mode ) +static inline _sfsyscall2( int, link, const char *, oldpath, const char *, newpath ) +static inline _sfsyscall1( int, unlink, const char *, pathname ) +static inline _sfsyscall3(int, execve, char *, s, char **, argv, char **,envp) +static inline _sfsyscall1( int, chdir, const char *, path ) +static inline _sfsyscall1( time_t, time, time_t *, t ) +static inline _sfsyscall3( int, mknod, const char *, pathname, mode_t, mode, dev_t, dev ) +static inline _sfsyscall2( int, chmod, const char *, path, mode_t, mode ) +static inline _sfsyscall3( int, lchown, const char *, path, uid_t, owner, gid_t, group ) +// break +static inline _sfsyscall3( off_t, lseek, int, fildes, off_t, offset, int, whence ) +static inline _sfsyscall0( pid_t, getpid ) +// mount +static inline _sfsyscall1( int, umount, const char *, dir ) +// setuid +static inline _sfsyscall0( uid_t, getuid ) +static inline _sfsyscall1( int, stime, time_t *, t ) +static inline _sfsyscall4(long, ptrace, int, request, pid_t, pid, void *,addr, void *,data) +static inline _sfsyscall1( unsigned int, alarm, unsigned int, seconds ) +static inline _sfsyscall0( int, pause ) +static inline _sfsyscall2( int, utime, const char *, filename, struct utimbuf *, buf ) +// stty +// gtty +static inline _sfsyscall2( int, access, const char *, pathname, int, mode ) +static inline _sfsyscall1( int, nice, int, inc ) +// ftime +static inline _sfsyscall0( int, sync ) +static inline _sfsyscall2( int, kill, pid_t, pid, int, sig ) +static inline _sfsyscall2( int, rename, const char *, oldpath, const char *, newpath ) +static inline _sfsyscall2( int, mkdir, const char *, pathname, mode_t, mode ) +static inline _sfsyscall1( int, rmdir, const char *, pathname ) +static inline _sfsyscall1( int, dup, int, oldfd ) +static inline _sfsyscall1( int, pipe, unsigned long *, filedes) +static inline _sfsyscall1( clock_t, times, struct tms *, buf ) +// prof +static inline _sfsyscall1( int, brk, void *, end_data_segment ) +// setgid +static inline _sfsyscall0( gid_t, getgid ) +static inline _sfsyscall2( sighandler_t, signal, int, signum, sighandler_t, handler ) +static inline _sfsyscall0( uid_t, geteuid ) +static inline _sfsyscall0( gid_t, getegid ) +static inline _sfsyscall1( int, acct, const char *, filename ) +// umount2 +// lock +static inline _sfsyscall4(int, ioctl, int,d, int,request, char *,argp, int,len) +static inline _sfsyscall3( int, fcntl, int, fd, int, cmd, long, arg ) +// mpx +static inline _sfsyscall2( int, setpgid, pid_t, pid, pid_t, pgid ) +// ulimit +static inline _sfsyscall1( mode_t, umask, mode_t, mask ) +static inline _sfsyscall1( int, chroot, const char *, path ) +static inline _sfsyscall2( int, ustat, dev_t, dev, struct ustat *, ubuf ) +static inline _sfsyscall2( int, dup2, int, oldfd, int, newfd ) +static inline _sfsyscall0( pid_t, getppid ) +static inline _sfsyscall0( pid_t, getpgrp ) +static inline _sfsyscall0( pid_t, setsid ) +// sigaction +// sgetmask +// ssetmask +static inline _sfsyscall2( int, setreuid, uid_t, ruid, uid_t, euid ) +static inline _sfsyscall2( int, setregid, gid_t, rgid, gid_t, egid ) +static inline _sfsyscall1( int, sigsuspend, const sigset_t *, mask ) +static inline _sfsyscall1( int, sigpending, sigset_t *, set ) +static inline _sfsyscall2( int, sethostname, const char *, name, size_t, len ) +// setrlimit +// getrlimit +// getrusage +static inline _sfsyscall2( int, gettimeofday, struct timeval *, tv, struct timezone *, tz ) +// settimeofday +// getgroups +static inline _sfsyscall2( int, setgroups, size_t, size, const gid_t *, list ) +static inline _sfsyscall5( int, select, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout) +static inline _sfsyscall2( int, symlink, const char *, oldpath, const char *, newpath ) +static inline _sfsyscall3( int, readlink, const char *, path, char *, buf, size_t, bufsiz ) +static inline _sfsyscall1( int, uselib, const char *, library ) +static inline _sfsyscall2( int, swapon, const char *, path, int, swapflags ) +// reboot +static inline _sfsyscall3( int, readdir, unsigned int, fd, struct dirent *, dirp, unsigned int, count ) +static inline _sfsyscall6(void *,mmap, void *,start, size_t,length, int,prot , int,flags, int,fd, off_t,offset) +static inline _sfsyscall2( int, munmap, void *, start, size_t, length ) +static inline _sfsyscall2( int, truncate, const char *, path, off_t, length ) +static inline _sfsyscall2( int, ftruncate, int, fd, off_t, length ) +static inline _sfsyscall2( int, fchmod, int, fildes, mode_t, mode ) +static inline _sfsyscall3( int, fchown, int, fd, uid_t, owner, gid_t, group ) +static inline _sfsyscall2( int, getpriority, int, which, int, who ) +static inline _sfsyscall3( int, setpriority, int, which, int, who, int, prio ) +// profil +static inline _sfsyscall2( int, statfs, const char *, path, struct statfs *, buf ) +static inline _sfsyscall2( int, fstatfs, int, fd, struct statfs *, buf ) +static inline _sfsyscall3( int, ioperm, unsigned long, from, unsigned long, num, int, turn_on ) +static inline _sfsyscall2( int, socketcall, int, call, unsigned long *,args); +static inline _sfsyscall3( int, syslog, int, type, char *, bufp, int, len ) +// setitimer +// getitimer +static inline _sfsyscall2( int, stat, const char *, file_name, struct stat *, buf ) +static inline _sfsyscall2( int, lstat, const char *, file_name, struct stat *, buf ) +static inline _sfsyscall2( int, fstat, int, filedes, struct stat *, buf ) +static inline _sfsyscall0( int, vhangup ) +static inline _sfsyscall0( int, idle ) +// syscall +static inline _sfsyscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, struct rusage *, rusage) +static inline _sfsyscall1( int, swapoff, const char *, path ) +static inline _sfsyscall1( int, sysinfo, struct sysinfo *, info ) +// ipc +static inline _sfsyscall1( int, fsync, int, fd ) +static inline _sfsyscall1( int, sigreturn, unsigned long, __unused ) +// clone +static inline _sfsyscall2( int, setdomainname, const char *, name, size_t, len ) +static inline _sfsyscall1( int, uname, struct utsname *, buf ) +// modify_ldt +// adjtimex +static inline _sfsyscall3( int, mprotect, const void *, addr, size_t, len, int, prot ) +// sigprocmask +static inline _sfsyscall2( caddr_t, create_module, const char *, name, size_t, size ) +static inline _sfsyscall2( int, init_module, const char *, name, struct module *, image ) +static inline _sfsyscall1( int, delete_module, const char *, name ) +static inline _sfsyscall1( int, get_kernel_syms, struct kernel_sym *, table ) +// quotactl +static inline _sfsyscall1( pid_t, getpgid, pid_t, pid ) +// fchdir +// bdflush +static inline _sfsyscall3( int, sysfs, int, option, unsigned int, fs_index, char *, buf ) +static inline _sfsyscall1( int, personality, unsigned long, persona ) +// afs_syscall +static inline _sfsyscall1( int, setfsuid, uid_t, fsuid ) +static inline _sfsyscall1( int, setfsgid, uid_t, fsgid ) +static inline _sfsyscall3( int, getdents, unsigned int, fd, struct dirent *, dirp, unsigned int, count ) +// flock +static inline _sfsyscall3( int, msync, const void *, start, size_t, length, int, flags ) +static inline _sfsyscall3( int, readv, int, fd, const struct iovec *, vector, int, count ) +static inline _sfsyscall3( int, writev, int, fd, const struct iovec *, vector, int, count ) +static inline _sfsyscall1( pid_t, getsid, pid_t, pid ) +static inline _sfsyscall1( int, fdatasync, int, fd ) +static inline _sfsyscall2( int, mlock, const void *, addr, size_t, len ) +static inline _sfsyscall2( int, munlock, const void *, addr, size_t, len ) +static inline _sfsyscall1( int, mlockall, int, flags ) +static inline _sfsyscall0( int, munlockall ) +static inline _sfsyscall2( int, sched_setparam, pid_t, pid, const struct sched_param *, p ) +static inline _sfsyscall2( int, sched_getparam, pid_t, pid, struct sched_param *, p ) +// sched_setscheduler +static inline _sfsyscall1( int, sched_getscheduler, pid_t, pid ) +static inline _sfsyscall0( int, sched_yield ) +static inline _sfsyscall1( int, sched_get_priority_max, int, policy ) +static inline _sfsyscall1( int, sched_get_priority_min, int, policy ) +static inline _sfsyscall2( int, sched_rr_get_interval, pid_t, pid, struct timespec *, tp ) +static inline _sfsyscall2( int, nanosleep, const struct timespec *, req, struct timespec *, rem ) +// mremap +static inline _sfsyscall3( int, setresuid, uid_t, ruid, uid_t, euid, uid_t, suid ) +static inline _sfsyscall3( int, getresuid, uid_t *, ruid, uid_t *, euid, uid_t *, suid ) +static inline _sfsyscall2( int, vm86, unsigned long, fn, struct vm86plus_struct *, v86 ) +// query_module +static inline _sfsyscall3( int, poll, struct pollfd *, ufds, unsigned int, nfds, int, timeout ) +// nfsservctl +// setresgid +// getresgid +// prctl +// rt_sigreturn +// rt_sigaction +// rt_sigprocmask +// rt_sigpending +// rt_sigtimedwait +// rt_sigqueueinfo +// rt_sigsuspend +static inline _sfsyscall4( ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset ) +// pwrite +static inline _sfsyscall3( int, chown, const char *, path, uid_t, owner, gid_t, group ) +// getcwd +static inline _sfsyscall2( int, capget, cap_user_header_t, header, cap_user_data_t, data ) +//static inline _sfsyscall2( int, capset, cap_user_header_t, header, const cap_user_data_t, data ) +// sigaltstack +// sendfile +static inline _sfsyscall0( pid_t, vfork ) +// ugetrlimit +// mmap2 +// truncate64 +// ftruncate64 +// stat64 +// lstat64 +// fstat64 +// lchown32 +// getuid32 +// getgid32 +// geteuid32 +// getegid32 +// setreuid32 +// setregid32 +// getgroups32 +// setgroups32 +// fchown32 +// setresuid32 +// getresuid32 +// setresgid32 +// getresgid32 +// chown32 +// setuid32 +// setgid32 +// setfsuid32 +// setfsgid32 +// getdents64 +// pivot_root +// mincore +// madvise +// fcntl64 +// security +// gettid +// readahead +// setxattr +// lsetxattr +// fsetxattr +// getxattr +// lgetxattr +// fgetxattr +// listxattr +// llistxattr +// flistxattr +// removexattr +// lremovexattr +// fremovexattr +// tkill +// sendfile64 +// futex +// sched_setaffinity +// sched_getaffinity +// io_setup +// io_destroy +// io_getevents +// io_submit +// io_cancel +// exit_group +// lookup_dcookie +// epoll_create +// epoll_ctl +// epoll_wait +// remap_file_pages + +#endif /* SFLIB_H */ diff --git a/dest/include/librz/sflib/linux-arm-64/sfsyscall.h b/dest/include/librz/sflib/linux-arm-64/sfsyscall.h new file mode 100644 index 00000000000..34b43f1c2c2 --- /dev/null +++ b/dest/include/librz/sflib/linux-arm-64/sfsyscall.h @@ -0,0 +1,174 @@ +/* sfsyscall.h --- SFLib syscall macros for Linux/arm64 - pancake */ + +#ifndef SFSYSCALL_H +#define SFSYSCALL_H + +/* $Id$ */ + +#ifdef SF_USE_ERRNO + +static int errno = 1234; + +#define __sfsyscall_return(type, res) \ + do { \ + if ((unsigned long)(res) >= (unsigned long)(-125)) { \ + errno = -(res); \ + res = -1; \ + } \ + return (type)(res); \ + } while (0) + +#else /* SF_USE_ERRNO */ + +#define __sfsyscall_return(type, res) \ + do { \ + return (type)(res); \ + } while (0) + +#endif /* SF_USE_ERRNO */ + +/* syscall macros */ + +#define _sfsyscall0(type, name) \ + type name(void) { \ + long __res; \ + __asm__ volatile("###> " #name " <###\n\t" \ + "svc 0" \ + : "=a"(__res) \ + : "0"(__NR_##name) \ + : "memory", "cc"); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall1(type, name, type1, arg1) \ + type name(type1 arg1) { \ + long __res; \ + register type1 x1 asm("x0"); \ + x1 = arg1; \ + asm volatile("###> " #name "(%2) <###\n\t" \ + "mov x8, %0\n\t" \ + "svc 0" \ + : "=g"(__res) \ + : "0"(__NR_##name), "r"(x1)); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall2(type, name, type1, arg1, type2, arg2) \ + type name(type1 arg1, type2 arg2) { \ + long __res; \ + register type1 x1 asm("x1"); \ + register type2 x2 asm("x2"); \ + x1 = arg1; \ + x2 = arg2; \ + __asm__ volatile("###> " #name "(%2, %3) <###\n\t" \ + "svc 0" \ + : "=g"(__res) \ + : "0"(__NR_##name), \ + "r"(x1), \ + "r"(x2)); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ + type name(type1 arg1, type2 arg2, type3 arg3) { \ + long __res; \ + register type1 x0 asm("x0"); \ + register type2 x1 asm("x1"); \ + register type3 x2 asm("x2"); \ + x0 = arg1; \ + x1 = arg2; \ + x2 = arg3; \ + __asm__ __volatile__("###> " #name "(%2, %3, %4) <###\n\t" \ + "mov x8, %1\n\t" \ + "svc 0" \ + : "=g"(__res) \ + : "0"(__NR_##name), \ + "r"(x0), \ + "r"(x1), \ + "r"(x2) \ + : "memory", "cc"); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall4(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ + long __res; \ + register type1 x1 asm("x1"); \ + ; \ + register type2 x2 asm("x2"); \ + register type3 x3 asm("x3"); \ + register type4 x4 asm("x4"); \ + x1 = arg1; \ + x2 = arg2; \ + x3 = arg3; \ + x4 = arg4; \ + asm volatile("###> " #name "(%2, %3, %4, %5) <###\n\t" \ + "svc 0" \ + : "=g"(__res) \ + : "0"(__NR_##name), \ + "r"(x1), \ + "r"(x2), \ + "r"(x3), \ + "r"(x4) \ + : "memory", "cc"); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall5(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) \ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ + type5 arg5) { \ + long __res; \ + register type1 x1 asm("x1"); \ + register type2 x2 asm("x2"); \ + register type3 x3 asm("x3"); \ + register type4 x4 asm("x4"); \ + register type5 x5 asm("x5"); \ + x1 = arg1; \ + x2 = arg2; \ + x3 = arg3; \ + x4 = arg4; \ + x5 = arg5; \ + asm volatile("###> " #name "(%2, %3, %4, %5, %6) <###\n\t" \ + "svc 0" \ + : "=g"(__res) \ + : "0"(__NR_##name), \ + "r"(x1), \ + "r"(x2), \ + "r"(x3), \ + "r"(x4), \ + "r"(x5) \ + : "memory", "cc"); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall6(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ + type5 arg5, type6 arg6) { \ + long __res; \ + register type1 x1 asm("x1"); \ + register type2 x2 asm("x2"); \ + register type3 x3 asm("x3"); \ + register type4 x4 asm("x4"); \ + register type5 x5 asm("x5"); \ + register type6 x6 asm("x6"); \ + x1 = arg1; \ + x2 = arg2; \ + x3 = arg3; \ + x4 = arg4; \ + x5 = arg5; \ + x6 = arg6; \ + asm volatile("###> " #name "(%2, %3, %4, %5, %6, %7) <###\n\t" \ + "svc 0" \ + : "=a"(__res) \ + : "0"(__NR_##name), \ + "r"(x1), \ + "r"(x2), \ + "r"(x3), \ + "r"(x4), \ + "r"(x5), \ + "r"(x6) \ + : "memory", "cc"); \ + __sfsyscall_return(type, __res); \ + } + +#endif /* SFSYSCALL_H */ diff --git a/dest/include/librz/sflib/linux-arm-64/sfsysnr.h b/dest/include/librz/sflib/linux-arm-64/sfsysnr.h new file mode 100644 index 00000000000..c1967a280e9 --- /dev/null +++ b/dest/include/librz/sflib/linux-arm-64/sfsysnr.h @@ -0,0 +1,316 @@ +/* + * sfsysnr.h --- SFLib syscall numbers for Linux/ARM + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + + +/* + * Automatically generated by gensflib.py + * Mon Mar 21 13:23:31 2022 + */ + +#ifndef SFSYSNR_H +#define SFSYSNR_H + + +/* $Id$ */ + +/* + * From linux/include/asm-arm/unistd.h + * Copyright (C) 2001-2002 Russell King + */ + + +#if defined(__thumb__) +#define __NR_SYSCALL_BASE 0 +#else +#define __NR_SYSCALL_BASE 0x900000 +#endif + +/* + * This file contains the system call numbers. + */ + +#define __NR_exit (__NR_SYSCALL_BASE+ 1) +#define __NR_fork (__NR_SYSCALL_BASE+ 2) +#define __NR_read (__NR_SYSCALL_BASE+ 3) +#define __NR_write (__NR_SYSCALL_BASE+ 4) +#define __NR_open (__NR_SYSCALL_BASE+ 5) +#define __NR_close (__NR_SYSCALL_BASE+ 6) +/*#define __NR_waitpid (__NR_SYSCALL_BASE+ 7) debian bug #201989 ARM doesnt have this syscall and its define breaks glibc*/ +#define __NR_creat (__NR_SYSCALL_BASE+ 8) +#define __NR_link (__NR_SYSCALL_BASE+ 9) +#define __NR_unlink (__NR_SYSCALL_BASE+ 10) +#define __NR_execve (__NR_SYSCALL_BASE+ 11) +#define __NR_chdir (__NR_SYSCALL_BASE+ 12) +#define __NR_time (__NR_SYSCALL_BASE+ 13) +#define __NR_mknod (__NR_SYSCALL_BASE+ 14) +#define __NR_chmod (__NR_SYSCALL_BASE+ 15) +#define __NR_lchown (__NR_SYSCALL_BASE+ 16) +#define __NR_break (__NR_SYSCALL_BASE+ 17) + +#define __NR_lseek (__NR_SYSCALL_BASE+ 19) +#define __NR_getpid (__NR_SYSCALL_BASE+ 20) +#define __NR_mount (__NR_SYSCALL_BASE+ 21) +#define __NR_umount (__NR_SYSCALL_BASE+ 22) +#define __NR_setuid (__NR_SYSCALL_BASE+ 23) +#define __NR_getuid (__NR_SYSCALL_BASE+ 24) +#define __NR_stime (__NR_SYSCALL_BASE+ 25) +#define __NR_ptrace (__NR_SYSCALL_BASE+ 26) +#define __NR_alarm (__NR_SYSCALL_BASE+ 27) + +#define __NR_pause (__NR_SYSCALL_BASE+ 29) +#define __NR_utime (__NR_SYSCALL_BASE+ 30) +#define __NR_stty (__NR_SYSCALL_BASE+ 31) +#define __NR_gtty (__NR_SYSCALL_BASE+ 32) +#define __NR_access (__NR_SYSCALL_BASE+ 33) +#define __NR_nice (__NR_SYSCALL_BASE+ 34) +#define __NR_ftime (__NR_SYSCALL_BASE+ 35) +#define __NR_sync (__NR_SYSCALL_BASE+ 36) +#define __NR_kill (__NR_SYSCALL_BASE+ 37) +#define __NR_rename (__NR_SYSCALL_BASE+ 38) +#define __NR_mkdir (__NR_SYSCALL_BASE+ 39) +#define __NR_rmdir (__NR_SYSCALL_BASE+ 40) +#define __NR_dup (__NR_SYSCALL_BASE+ 41) +#define __NR_pipe (__NR_SYSCALL_BASE+ 42) +#define __NR_times (__NR_SYSCALL_BASE+ 43) +#define __NR_prof (__NR_SYSCALL_BASE+ 44) +#define __NR_brk (__NR_SYSCALL_BASE+ 45) +#define __NR_setgid (__NR_SYSCALL_BASE+ 46) +#define __NR_getgid (__NR_SYSCALL_BASE+ 47) +#define __NR_signal (__NR_SYSCALL_BASE+ 48) +#define __NR_geteuid (__NR_SYSCALL_BASE+ 49) +#define __NR_getegid (__NR_SYSCALL_BASE+ 50) +#define __NR_acct (__NR_SYSCALL_BASE+ 51) +#define __NR_umount2 (__NR_SYSCALL_BASE+ 52) +#define __NR_lock (__NR_SYSCALL_BASE+ 53) +#define __NR_ioctl (__NR_SYSCALL_BASE+ 54) +#define __NR_fcntl (__NR_SYSCALL_BASE+ 55) +#define __NR_mpx (__NR_SYSCALL_BASE+ 56) +#define __NR_setpgid (__NR_SYSCALL_BASE+ 57) +#define __NR_ulimit (__NR_SYSCALL_BASE+ 58) + +#define __NR_umask (__NR_SYSCALL_BASE+ 60) +#define __NR_chroot (__NR_SYSCALL_BASE+ 61) +#define __NR_ustat (__NR_SYSCALL_BASE+ 62) +#define __NR_dup2 (__NR_SYSCALL_BASE+ 63) +#define __NR_getppid (__NR_SYSCALL_BASE+ 64) +#define __NR_getpgrp (__NR_SYSCALL_BASE+ 65) +#define __NR_setsid (__NR_SYSCALL_BASE+ 66) +#define __NR_sigaction (__NR_SYSCALL_BASE+ 67) +#define __NR_sgetmask (__NR_SYSCALL_BASE+ 68) +#define __NR_ssetmask (__NR_SYSCALL_BASE+ 69) +#define __NR_setreuid (__NR_SYSCALL_BASE+ 70) +#define __NR_setregid (__NR_SYSCALL_BASE+ 71) +#define __NR_sigsuspend (__NR_SYSCALL_BASE+ 72) +#define __NR_sigpending (__NR_SYSCALL_BASE+ 73) +#define __NR_sethostname (__NR_SYSCALL_BASE+ 74) +#define __NR_setrlimit (__NR_SYSCALL_BASE+ 75) +#define __NR_getrlimit (__NR_SYSCALL_BASE+ 76) /* Back compat 2GB limited rlimit */ +#define __NR_getrusage (__NR_SYSCALL_BASE+ 77) +#define __NR_gettimeofday (__NR_SYSCALL_BASE+ 78) +#define __NR_settimeofday (__NR_SYSCALL_BASE+ 79) +#define __NR_getgroups (__NR_SYSCALL_BASE+ 80) +#define __NR_setgroups (__NR_SYSCALL_BASE+ 81) +#define __NR_select (__NR_SYSCALL_BASE+ 82) +#define __NR_symlink (__NR_SYSCALL_BASE+ 83) + +#define __NR_readlink (__NR_SYSCALL_BASE+ 85) +#define __NR_uselib (__NR_SYSCALL_BASE+ 86) +#define __NR_swapon (__NR_SYSCALL_BASE+ 87) +#define __NR_reboot (__NR_SYSCALL_BASE+ 88) +#define __NR_readdir (__NR_SYSCALL_BASE+ 89) +#define __NR_mmap (__NR_SYSCALL_BASE+ 90) +#define __NR_munmap (__NR_SYSCALL_BASE+ 91) +#define __NR_truncate (__NR_SYSCALL_BASE+ 92) +#define __NR_ftruncate (__NR_SYSCALL_BASE+ 93) +#define __NR_fchmod (__NR_SYSCALL_BASE+ 94) +#define __NR_fchown (__NR_SYSCALL_BASE+ 95) +#define __NR_getpriority (__NR_SYSCALL_BASE+ 96) +#define __NR_setpriority (__NR_SYSCALL_BASE+ 97) +#define __NR_profil (__NR_SYSCALL_BASE+ 98) +#define __NR_statfs (__NR_SYSCALL_BASE+ 99) +#define __NR_fstatfs (__NR_SYSCALL_BASE+100) +#define __NR_ioperm (__NR_SYSCALL_BASE+101) +#define __NR_socketcall (__NR_SYSCALL_BASE+102) +#define __NR_syslog (__NR_SYSCALL_BASE+103) +#define __NR_setitimer (__NR_SYSCALL_BASE+104) +#define __NR_getitimer (__NR_SYSCALL_BASE+105) +#define __NR_stat (__NR_SYSCALL_BASE+106) +#define __NR_lstat (__NR_SYSCALL_BASE+107) +#define __NR_fstat (__NR_SYSCALL_BASE+108) + + +#define __NR_vhangup (__NR_SYSCALL_BASE+111) +#define __NR_idle (__NR_SYSCALL_BASE+112) +#define __NR_syscall (__NR_SYSCALL_BASE+113) /* syscall to call a syscall! */ +#define __NR_wait4 (__NR_SYSCALL_BASE+114) +#define __NR_swapoff (__NR_SYSCALL_BASE+115) +#define __NR_sysinfo (__NR_SYSCALL_BASE+116) +#define __NR_ipc (__NR_SYSCALL_BASE+117) +#define __NR_fsync (__NR_SYSCALL_BASE+118) +#define __NR_sigreturn (__NR_SYSCALL_BASE+119) +#define __NR_clone (__NR_SYSCALL_BASE+120) +#define __NR_setdomainname (__NR_SYSCALL_BASE+121) +#define __NR_uname (__NR_SYSCALL_BASE+122) +#define __NR_modify_ldt (__NR_SYSCALL_BASE+123) +#define __NR_adjtimex (__NR_SYSCALL_BASE+124) +#define __NR_mprotect (__NR_SYSCALL_BASE+125) +#define __NR_sigprocmask (__NR_SYSCALL_BASE+126) +#define __NR_create_module (__NR_SYSCALL_BASE+127) +#define __NR_init_module (__NR_SYSCALL_BASE+128) +#define __NR_delete_module (__NR_SYSCALL_BASE+129) +#define __NR_get_kernel_syms (__NR_SYSCALL_BASE+130) +#define __NR_quotactl (__NR_SYSCALL_BASE+131) +#define __NR_getpgid (__NR_SYSCALL_BASE+132) +#define __NR_fchdir (__NR_SYSCALL_BASE+133) +#define __NR_bdflush (__NR_SYSCALL_BASE+134) +#define __NR_sysfs (__NR_SYSCALL_BASE+135) +#define __NR_personality (__NR_SYSCALL_BASE+136) +#define __NR_afs_syscall (__NR_SYSCALL_BASE+137) /* Syscall for Andrew File System */ +#define __NR_setfsuid (__NR_SYSCALL_BASE+138) +#define __NR_setfsgid (__NR_SYSCALL_BASE+139) +#define __NR__llseek (__NR_SYSCALL_BASE+140) +#define __NR_getdents (__NR_SYSCALL_BASE+141) +#define __NR__newselect (__NR_SYSCALL_BASE+142) +#define __NR_flock (__NR_SYSCALL_BASE+143) +#define __NR_msync (__NR_SYSCALL_BASE+144) +#define __NR_readv (__NR_SYSCALL_BASE+145) +#define __NR_writev (__NR_SYSCALL_BASE+146) +#define __NR_getsid (__NR_SYSCALL_BASE+147) +#define __NR_fdatasync (__NR_SYSCALL_BASE+148) +#define __NR__sysctl (__NR_SYSCALL_BASE+149) +#define __NR_mlock (__NR_SYSCALL_BASE+150) +#define __NR_munlock (__NR_SYSCALL_BASE+151) +#define __NR_mlockall (__NR_SYSCALL_BASE+152) +#define __NR_munlockall (__NR_SYSCALL_BASE+153) +#define __NR_sched_setparam (__NR_SYSCALL_BASE+154) +#define __NR_sched_getparam (__NR_SYSCALL_BASE+155) +#define __NR_sched_setscheduler (__NR_SYSCALL_BASE+156) +#define __NR_sched_getscheduler (__NR_SYSCALL_BASE+157) +#define __NR_sched_yield (__NR_SYSCALL_BASE+158) +#define __NR_sched_get_priority_max (__NR_SYSCALL_BASE+159) +#define __NR_sched_get_priority_min (__NR_SYSCALL_BASE+160) +#define __NR_sched_rr_get_interval (__NR_SYSCALL_BASE+161) +#define __NR_nanosleep (__NR_SYSCALL_BASE+162) +#define __NR_mremap (__NR_SYSCALL_BASE+163) +#define __NR_setresuid (__NR_SYSCALL_BASE+164) +#define __NR_getresuid (__NR_SYSCALL_BASE+165) +#define __NR_vm86 (__NR_SYSCALL_BASE+166) +#define __NR_query_module (__NR_SYSCALL_BASE+167) +#define __NR_poll (__NR_SYSCALL_BASE+168) +#define __NR_nfsservctl (__NR_SYSCALL_BASE+169) +#define __NR_setresgid (__NR_SYSCALL_BASE+170) +#define __NR_getresgid (__NR_SYSCALL_BASE+171) +#define __NR_prctl (__NR_SYSCALL_BASE+172) +#define __NR_rt_sigreturn (__NR_SYSCALL_BASE+173) +#define __NR_rt_sigaction (__NR_SYSCALL_BASE+174) +#define __NR_rt_sigprocmask (__NR_SYSCALL_BASE+175) +#define __NR_rt_sigpending (__NR_SYSCALL_BASE+176) +#define __NR_rt_sigtimedwait (__NR_SYSCALL_BASE+177) +#define __NR_rt_sigqueueinfo (__NR_SYSCALL_BASE+178) +#define __NR_rt_sigsuspend (__NR_SYSCALL_BASE+179) +#define __NR_pread (__NR_SYSCALL_BASE+180) +#define __NR_pwrite (__NR_SYSCALL_BASE+181) +#define __NR_chown (__NR_SYSCALL_BASE+182) +#define __NR_getcwd (__NR_SYSCALL_BASE+183) +#define __NR_capget (__NR_SYSCALL_BASE+184) +#define __NR_capset (__NR_SYSCALL_BASE+185) +#define __NR_sigaltstack (__NR_SYSCALL_BASE+186) +#define __NR_sendfile (__NR_SYSCALL_BASE+187) + /* 188 reserved */ + /* 189 reserved */ +#define __NR_vfork (__NR_SYSCALL_BASE+190) +#define __NR_ugetrlimit (__NR_SYSCALL_BASE+191) /* SuS compliant getrlimit */ +#define __NR_mmap2 (__NR_SYSCALL_BASE+192) +#define __NR_truncate64 (__NR_SYSCALL_BASE+193) +#define __NR_ftruncate64 (__NR_SYSCALL_BASE+194) +#define __NR_stat64 (__NR_SYSCALL_BASE+195) +#define __NR_lstat64 (__NR_SYSCALL_BASE+196) +#define __NR_fstat64 (__NR_SYSCALL_BASE+197) +#define __NR_lchown32 (__NR_SYSCALL_BASE+198) +#define __NR_getuid32 (__NR_SYSCALL_BASE+199) +#define __NR_getgid32 (__NR_SYSCALL_BASE+200) +#define __NR_geteuid32 (__NR_SYSCALL_BASE+201) +#define __NR_getegid32 (__NR_SYSCALL_BASE+202) +#define __NR_setreuid32 (__NR_SYSCALL_BASE+203) +#define __NR_setregid32 (__NR_SYSCALL_BASE+204) +#define __NR_getgroups32 (__NR_SYSCALL_BASE+205) +#define __NR_setgroups32 (__NR_SYSCALL_BASE+206) +#define __NR_fchown32 (__NR_SYSCALL_BASE+207) +#define __NR_setresuid32 (__NR_SYSCALL_BASE+208) +#define __NR_getresuid32 (__NR_SYSCALL_BASE+209) +#define __NR_setresgid32 (__NR_SYSCALL_BASE+210) +#define __NR_getresgid32 (__NR_SYSCALL_BASE+211) +#define __NR_chown32 (__NR_SYSCALL_BASE+212) +#define __NR_setuid32 (__NR_SYSCALL_BASE+213) +#define __NR_setgid32 (__NR_SYSCALL_BASE+214) +#define __NR_setfsuid32 (__NR_SYSCALL_BASE+215) +#define __NR_setfsgid32 (__NR_SYSCALL_BASE+216) +#define __NR_getdents64 (__NR_SYSCALL_BASE+217) +#define __NR_pivot_root (__NR_SYSCALL_BASE+218) +#define __NR_mincore (__NR_SYSCALL_BASE+219) +#define __NR_madvise (__NR_SYSCALL_BASE+220) +#define __NR_fcntl64 (__NR_SYSCALL_BASE+221) + /* 222 for tux */ +#define __NR_security (__NR_SYSCALL_BASE+223) +#define __NR_gettid (__NR_SYSCALL_BASE+224) +#define __NR_readahead (__NR_SYSCALL_BASE+225) +#if 0 /* allocated in 2.5 */ +#define __NR_setxattr (__NR_SYSCALL_BASE+226) +#define __NR_lsetxattr (__NR_SYSCALL_BASE+227) +#define __NR_fsetxattr (__NR_SYSCALL_BASE+228) +#define __NR_getxattr (__NR_SYSCALL_BASE+229) +#define __NR_lgetxattr (__NR_SYSCALL_BASE+230) +#define __NR_fgetxattr (__NR_SYSCALL_BASE+231) +#define __NR_listxattr (__NR_SYSCALL_BASE+232) +#define __NR_llistxattr (__NR_SYSCALL_BASE+233) +#define __NR_flistxattr (__NR_SYSCALL_BASE+234) +#define __NR_removexattr (__NR_SYSCALL_BASE+235) +#define __NR_lremovexattr (__NR_SYSCALL_BASE+236) +#define __NR_fremovexattr (__NR_SYSCALL_BASE+237) +#endif +#define __NR_tkill (__NR_SYSCALL_BASE+238) +#if 0 /* allocated in 2.5 */ +#define __NR_sendfile64 (__NR_SYSCALL_BASE+239) +#define __NR_futex (__NR_SYSCALL_BASE+240) +#define __NR_sched_setaffinity (__NR_SYSCALL_BASE+241) +#define __NR_sched_getaffinity (__NR_SYSCALL_BASE+242) +#define __NR_io_setup (__NR_SYSCALL_BASE+243) +#define __NR_io_destroy (__NR_SYSCALL_BASE+244) +#define __NR_io_getevents (__NR_SYSCALL_BASE+245) +#define __NR_io_submit (__NR_SYSCALL_BASE+246) +#define __NR_io_cancel (__NR_SYSCALL_BASE+247) +#define __NR_exit_group (__NR_SYSCALL_BASE+248) +#define __NR_lookup_dcookie (__NR_SYSCALL_BASE+249) +#define __NR_epoll_create (__NR_SYSCALL_BASE+250) +#define __NR_epoll_ctl (__NR_SYSCALL_BASE+251) +#define __NR_epoll_wait (__NR_SYSCALL_BASE+252) +#define __NR_remap_file_pages (__NR_SYSCALL_BASE+253) + /* 254 for set_thread_area */ + /* 255 for get_thread_area */ + /* 256 for set_tid_address */ +#endif + +/* + * The following SWIs are ARM private. + */ +#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000) +#define __ARM_NR_breakpoint (__ARM_NR_BASE+1) +#define __ARM_NR_cacheflush (__ARM_NR_BASE+2) +#define __ARM_NR_usr26 (__ARM_NR_BASE+3) +#define __ARM_NR_usr32 (__ARM_NR_BASE+4) + + +#endif /* SFSYSNR_H */ diff --git a/dest/include/librz/sflib/linux-x86-32/sflib.h b/dest/include/librz/sflib/linux-x86-32/sflib.h new file mode 100644 index 00000000000..a757995493d --- /dev/null +++ b/dest/include/librz/sflib/linux-x86-32/sflib.h @@ -0,0 +1,226 @@ +/* + * sflib.h --- SFLib syscall library for Linux/i386 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + + +/* + * Automatically generated by gensflib.py + * Tue Apr 25 19:39:23 2023 + */ + +#ifndef SFLIB_H +#define SFLIB_H + + +#include "sfsysnr.h" +#include "sfsyscall.h" +#include "../common/sftypes.h" + + +static inline _sfsyscall1(int, exit, int, status) +static inline _sfsyscall0( pid_t, fork ) +static inline _sfsyscall3( ssize_t, read, int, fd, void *, buf, size_t, count ) +static inline _sfsyscall3( ssize_t, write, int, fd, const void *, buf, size_t, count ) +static inline _sfsyscall3( int, open, const char *, pathname, int, flags, mode_t, mode ) +static inline _sfsyscall1( int, close, int, fd ) +static inline _sfsyscall3( pid_t, waitpid, pid_t, pid, int *, status, int, options ) +static inline _sfsyscall2( int, creat, const char *, pathname, mode_t, mode ) +static inline _sfsyscall2( int, link, const char *, oldpath, const char *, newpath ) +static inline _sfsyscall1( int, unlink, const char *, pathname ) +static inline _sfsyscall3(int, execve, char *, s, char **, argv, char **,envp) +static inline _sfsyscall1( int, chdir, const char *, path ) +static inline _sfsyscall1( time_t, time, time_t *, t ) +static inline _sfsyscall3( int, mknod, const char *, pathname, mode_t, mode, dev_t, dev ) +static inline _sfsyscall2( int, chmod, const char *, path, mode_t, mode ) +static inline _sfsyscall3( int, lchown, const char *, path, uid_t, owner, gid_t, group ) +// break +// oldstat +static inline _sfsyscall3( off_t, lseek, int, fildes, off_t, offset, int, whence ) +static inline _sfsyscall0( pid_t, getpid ) +// mount +static inline _sfsyscall1( int, umount, const char *, dir ) +// setuid +static inline _sfsyscall0( uid_t, getuid ) +static inline _sfsyscall1( int, stime, time_t *, t ) +static inline _sfsyscall4(long, ptrace, int, request, pid_t, pid, void *,addr, void *,data) +static inline _sfsyscall1( unsigned int, alarm, unsigned int, seconds ) +// oldfstat +static inline _sfsyscall0( int, pause ) +static inline _sfsyscall2( int, utime, const char *, filename, struct utimbuf *, buf ) +// stty +// gtty +static inline _sfsyscall2( int, access, const char *, pathname, int, mode ) +static inline _sfsyscall1( int, nice, int, inc ) +// ftime +static inline _sfsyscall0( int, sync ) +static inline _sfsyscall2( int, kill, pid_t, pid, int, sig ) +static inline _sfsyscall2( int, rename, const char *, oldpath, const char *, newpath ) +static inline _sfsyscall2( int, mkdir, const char *, pathname, mode_t, mode ) +static inline _sfsyscall1( int, rmdir, const char *, pathname ) +static inline _sfsyscall1( int, dup, int, oldfd ) +static inline _sfsyscall1( int, pipe, unsigned long *, filedes) +static inline _sfsyscall1( clock_t, times, struct tms *, buf ) +// prof +static inline _sfsyscall1( int, brk, void *, end_data_segment ) +// setgid +static inline _sfsyscall0( gid_t, getgid ) +static inline _sfsyscall2( sighandler_t, signal, int, signum, sighandler_t, handler ) +static inline _sfsyscall0( uid_t, geteuid ) +static inline _sfsyscall0( gid_t, getegid ) +static inline _sfsyscall1( int, acct, const char *, filename ) +// umount2 +// lock +static inline _sfsyscall4(int, ioctl, int,d, int,request, char *,argp, int,len) +static inline _sfsyscall3( int, fcntl, int, fd, int, cmd, long, arg ) +// mpx +static inline _sfsyscall2( int, setpgid, pid_t, pid, pid_t, pgid ) +// ulimit +// oldolduname +static inline _sfsyscall1( mode_t, umask, mode_t, mask ) +static inline _sfsyscall1( int, chroot, const char *, path ) +static inline _sfsyscall2( int, ustat, dev_t, dev, struct ustat *, ubuf ) +static inline _sfsyscall2( int, dup2, int, oldfd, int, newfd ) +static inline _sfsyscall0( pid_t, getppid ) +static inline _sfsyscall0( pid_t, getpgrp ) +static inline _sfsyscall0( pid_t, setsid ) +// sigaction +// sgetmask +// ssetmask +static inline _sfsyscall2( int, setreuid, uid_t, ruid, uid_t, euid ) +static inline _sfsyscall2( int, setregid, gid_t, rgid, gid_t, egid ) +static inline _sfsyscall1( int, sigsuspend, const sigset_t *, mask ) +static inline _sfsyscall1( int, sigpending, sigset_t *, set ) +static inline _sfsyscall2( int, sethostname, const char *, name, size_t, len ) +// setrlimit +// oldgetrlimit +// getrusage +static inline _sfsyscall2( int, gettimeofday, struct timeval *, tv, struct timezone *, tz ) +// settimeofday +// getgroups +static inline _sfsyscall2( int, setgroups, size_t, size, const gid_t *, list ) +static inline _sfsyscall5( int, select, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout) +static inline _sfsyscall2( int, symlink, const char *, oldpath, const char *, newpath ) +// oldlstat +static inline _sfsyscall3( int, readlink, const char *, path, char *, buf, size_t, bufsiz ) +static inline _sfsyscall1( int, uselib, const char *, library ) +static inline _sfsyscall2( int, swapon, const char *, path, int, swapflags ) +// reboot +static inline _sfsyscall3( int, readdir, unsigned int, fd, struct dirent *, dirp, unsigned int, count ) +// oldmmap +static inline _sfsyscall2( int, munmap, void *, start, size_t, length ) +static inline _sfsyscall2( int, truncate, const char *, path, off_t, length ) +static inline _sfsyscall2( int, ftruncate, int, fd, off_t, length ) +static inline _sfsyscall2( int, fchmod, int, fildes, mode_t, mode ) +static inline _sfsyscall3( int, fchown, int, fd, uid_t, owner, gid_t, group ) +static inline _sfsyscall2( int, getpriority, int, which, int, who ) +static inline _sfsyscall3( int, setpriority, int, which, int, who, int, prio ) +// profil +static inline _sfsyscall2( int, statfs, const char *, path, struct statfs *, buf ) +static inline _sfsyscall2( int, fstatfs, int, fd, struct statfs *, buf ) +static inline _sfsyscall3( int, ioperm, unsigned long, from, unsigned long, num, int, turn_on ) +static inline _sfsyscall2( int, socketcall, int, call, unsigned long *,args); +static inline _sfsyscall3( int, syslog, int, type, char *, bufp, int, len ) +// setitimer +// getitimer +static inline _sfsyscall2( int, stat, const char *, file_name, struct stat *, buf ) +static inline _sfsyscall2( int, lstat, const char *, file_name, struct stat *, buf ) +static inline _sfsyscall2( int, fstat, int, filedes, struct stat *, buf ) +// olduname +static inline _sfsyscall1( int, iopl, int, level ) +static inline _sfsyscall0( int, vhangup ) +static inline _sfsyscall0( int, idle ) +// vm86old +static inline _sfsyscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, struct rusage *, rusage) +static inline _sfsyscall1( int, swapoff, const char *, path ) +static inline _sfsyscall1( int, sysinfo, struct sysinfo *, info ) +// ipc +static inline _sfsyscall1( int, fsync, int, fd ) +static inline _sfsyscall1( int, sigreturn, unsigned long, __unused ) +// clone +static inline _sfsyscall2( int, setdomainname, const char *, name, size_t, len ) +static inline _sfsyscall1( int, uname, struct utsname *, buf ) +// modify_ldt +// adjtimex +static inline _sfsyscall3( int, mprotect, const void *, addr, size_t, len, int, prot ) +// sigprocmask +static inline _sfsyscall2( caddr_t, create_module, const char *, name, size_t, size ) +static inline _sfsyscall2( int, init_module, const char *, name, struct module *, image ) +static inline _sfsyscall1( int, delete_module, const char *, name ) +static inline _sfsyscall1( int, get_kernel_syms, struct kernel_sym *, table ) +// quotactl +static inline _sfsyscall1( pid_t, getpgid, pid_t, pid ) +// fchdir +// bdflush +static inline _sfsyscall3( int, sysfs, int, option, unsigned int, fs_index, char *, buf ) +static inline _sfsyscall1( int, personality, unsigned long, persona ) +// afs_syscall +static inline _sfsyscall1( int, setfsuid, uid_t, fsuid ) +static inline _sfsyscall1( int, setfsgid, uid_t, fsgid ) +static inline _sfsyscall3( int, getdents, unsigned int, fd, struct dirent *, dirp, unsigned int, count ) +// flock +static inline _sfsyscall3( int, msync, const void *, start, size_t, length, int, flags ) +static inline _sfsyscall3( int, readv, int, fd, const struct iovec *, vector, int, count ) +static inline _sfsyscall3( int, writev, int, fd, const struct iovec *, vector, int, count ) +static inline _sfsyscall1( pid_t, getsid, pid_t, pid ) +static inline _sfsyscall1( int, fdatasync, int, fd ) +static inline _sfsyscall2( int, mlock, const void *, addr, size_t, len ) +static inline _sfsyscall2( int, munlock, const void *, addr, size_t, len ) +static inline _sfsyscall1( int, mlockall, int, flags ) +static inline _sfsyscall0( int, munlockall ) +static inline _sfsyscall2( int, sched_setparam, pid_t, pid, const struct sched_param *, p ) +static inline _sfsyscall2( int, sched_getparam, pid_t, pid, struct sched_param *, p ) +// sched_setscheduler +static inline _sfsyscall1( int, sched_getscheduler, pid_t, pid ) +static inline _sfsyscall0( int, sched_yield ) +static inline _sfsyscall1( int, sched_get_priority_max, int, policy ) +static inline _sfsyscall1( int, sched_get_priority_min, int, policy ) +static inline _sfsyscall2( int, sched_rr_get_interval, pid_t, pid, struct timespec *, tp ) +static inline _sfsyscall2( int, nanosleep, const struct timespec *, req, struct timespec *, rem ) +// mremap +static inline _sfsyscall3( int, setresuid, uid_t, ruid, uid_t, euid, uid_t, suid ) +static inline _sfsyscall3( int, getresuid, uid_t *, ruid, uid_t *, euid, uid_t *, suid ) +static inline _sfsyscall2( int, vm86, unsigned long, fn, struct vm86plus_struct *, v86 ) +// query_module +static inline _sfsyscall3( int, poll, struct pollfd *, ufds, unsigned int, nfds, int, timeout ) +// nfsservctl +// setresgid +// getresgid +// prctl +// rt_sigreturn +// rt_sigaction +// rt_sigprocmask +// rt_sigpending +// rt_sigtimedwait +// rt_sigqueueinfo +// rt_sigsuspend +static inline _sfsyscall4( ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset ) +// pwrite +static inline _sfsyscall3( int, chown, const char *, path, uid_t, owner, gid_t, group ) +// getcwd +static inline _sfsyscall2( int, capget, cap_user_header_t, header, cap_user_data_t, data ) +//static inline _sfsyscall2( int, capset, cap_user_header_t, header, const cap_user_data_t, data ) +// sigaltstack +// sendfile +// getpmsg +// putpmsg +static inline _sfsyscall0( pid_t, vfork ) +// getrlimit +static inline _sfsyscall6(void *,mmap, void *,start, size_t,length, int,prot , int,flags, int,fd, off_t,offset) + + +#include "../common/sfsocketcall.h" + + +#endif /* SFLIB_H */ diff --git a/dest/include/librz/sflib/linux-x86-32/sfsyscall.h b/dest/include/librz/sflib/linux-x86-32/sfsyscall.h new file mode 100644 index 00000000000..d1f6126afd8 --- /dev/null +++ b/dest/include/librz/sflib/linux-x86-32/sfsyscall.h @@ -0,0 +1,184 @@ +/* + * sfsyscall.h --- SFLib syscall macros for Linux/i386 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + + +/* + * Automatically generated by gensflib.py + * Tue Apr 25 19:39:23 2023 + */ + +#ifndef SFSYSCALL_H +#define SFSYSCALL_H + + +/* $Id$ */ + +#ifdef SF_USE_ERRNO + +static int errno=1234; + +#define __sfsyscall_return(type, res) \ +do { \ + if ((unsigned long)(res) >= (unsigned long)(-125)) { \ + errno = -(res); \ + res = -1; \ + } \ + return (type) (res); \ +} while (0) + +#else /* SF_USE_ERRNO */ + +#define __sfsyscall_return(type, res) \ +do { \ + return (type) (res); \ +} while (0) + +#endif /* SF_USE_ERRNO */ + + +/* syscall macros */ + +#define _sfsyscall0(type,name) \ +type name(void) \ +{ \ +long __res; \ +__asm__ volatile ("###> " #name "() <###\n\t" \ + "int $0x80" \ + : "=a" (__res) \ + : "0" (__NR_##name)); \ +__sfsyscall_return(type,__res); \ +} + +#define _sfsyscall1(type,name,type1,arg1) \ +type name(type1 arg1) \ +{ \ +long __res; \ +__asm__ volatile ("###> " #name "(%2) <###\n\t" \ + "pushl %%ebx\n\t" \ + "mov %2,%%ebx\n\t" \ + "int $0x80\n\t" \ + "popl %%ebx" \ + : "=a" (__res) \ + : "0" (__NR_##name),"r" ((long)(arg1))); \ +__sfsyscall_return(type,__res); \ +} + +#define _sfsyscall2(type,name,type1,arg1,type2,arg2) \ +type name(type1 arg1,type2 arg2) \ +{ \ +long __res; \ +__asm__ volatile ("###> " #name "(%2, %3) <###\n\t" \ + "pushl %%ebx\n\t" \ + "mov %2,%%ebx\n\t" \ + "int $0x80\n\t" \ + "popl %%ebx" \ + : "=a" (__res) \ + : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)) ); \ +__sfsyscall_return(type,__res); \ +} + +#define _sfsyscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ +type name(type1 arg1,type2 arg2,type3 arg3) \ +{ \ +long __res; \ +__asm__ volatile ("###> " #name "(%2, %3, %4) <###\n\t" \ + "pushl %%ebx\n\t" \ + "mov %2,%%ebx\n\t" \ + "int $0x80\n\t" \ + "popl %%ebx" \ + : "=a" (__res) \ + : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \ + "d" ((long)(arg3)) ); \ +__sfsyscall_return(type,__res); \ +} + +#define _sfsyscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ +type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ +{ \ +long __res; \ +__asm__ volatile ("###> " #name "(%2, %3, %4, %5) <###\n\t" \ + "pushl %%ebx\n\t" \ + "mov %2,%%ebx\n\t" \ + "int $0x80\n\t" \ + "popl %%ebx" \ + : "=a" (__res) \ + : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \ + "d" ((long)(arg3)),"S" ((long)(arg4)) ); \ +__sfsyscall_return(type,__res); \ +} + +#define _sfsyscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5) \ +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ +{ \ +long __res; \ +__asm__ volatile ("###> " #name "(%2, %3, %4, %5, %6) <###\n\t" \ + "pushl %%ebx\n\t" \ + "mov %2,%%ebx\n\t" \ + "int $0x80\n\t" \ + "popl %%ebx" \ + : "=a" (__res) \ + : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \ + "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \ +__sfsyscall_return(type,__res); \ +} + +#define _sfsyscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5,type6,arg6) \ +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \ +{ \ +long __res; \ +__asm__ volatile ("##> " #name "(%2, %3, %4, %5, %6, %7) <###\n\t" \ + "pushl %%ebx\n\t" \ + "pushl %%ebp\n\t" \ + "movl %2,%%ebx\n\t" \ + "movl %7,%%ebp\n\t" \ + "int $0x80\n\t" \ + "popl %%ebp\n\t" \ + "popl %%ebx" \ + : "=a" (__res) \ + : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \ + "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)), \ + "r" ((long)(arg6))); \ +__sfsyscall_return(type,__res); \ +} + + +#define _sfoldsyscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5,type6,arg6) \ +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \ +{ \ +long __res; \ +__asm__ volatile ("pushl %%ebx\n\t" \ + "pushl %7\n\t" \ + "pushl %6\n\t" \ + "pushl %5\n\t" \ + "pushl %4\n\t" \ + "pushl %3\n\t" \ + "pushl %2\n\t" \ + "movl %%esp, %%ebx\n\t" \ + "int $0x80\n\t" \ + "add $0x18,%%esp\n\t" \ + "popl %%ebx" \ + : "=a" (__res) \ + : "0" (__NR_##name),"r" ((long)(arg1)),"r" ((long)(arg2)), \ + "r" ((long)(arg3)),"r" ((long)(arg4)),"r" ((long)(arg5)), \ + "r" ((long)(arg6))); \ +__sfsyscall_return(type,__res); \ +} + + +#endif /* SFSYSCALL_H */ diff --git a/dest/include/librz/sflib/linux-x86-32/sfsysnr.h b/dest/include/librz/sflib/linux-x86-32/sfsysnr.h new file mode 100644 index 00000000000..f0ae56dc794 --- /dev/null +++ b/dest/include/librz/sflib/linux-x86-32/sfsysnr.h @@ -0,0 +1,223 @@ +/* + * sfsysnr.h --- SFLib syscall numbers for Linux/i386 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + + +/* + * Automatically generated by gensflib.py + * Tue Apr 25 19:39:23 2023 + */ + +#ifndef SFSYSNR_H +#define SFSYSNR_H + + +/* $Id$ */ + +#define __NR_exit 1 +#define __NR_fork 2 +#define __NR_read 3 +#define __NR_write 4 +#define __NR_open 5 +#define __NR_close 6 +#define __NR_waitpid 7 +#define __NR_creat 8 +#define __NR_link 9 +#define __NR_unlink 10 +#define __NR_execve 11 +#define __NR_chdir 12 +#define __NR_time 13 +#define __NR_mknod 14 +#define __NR_chmod 15 +#define __NR_lchown 16 +#define __NR_break 17 +#define __NR_oldstat 18 +#define __NR_lseek 19 +#define __NR_getpid 20 +#define __NR_mount 21 +#define __NR_umount 22 +#define __NR_setuid 23 +#define __NR_getuid 24 +#define __NR_stime 25 +#define __NR_ptrace 26 +#define __NR_alarm 27 +#define __NR_oldfstat 28 +#define __NR_pause 29 +#define __NR_utime 30 +#define __NR_stty 31 +#define __NR_gtty 32 +#define __NR_access 33 +#define __NR_nice 34 +#define __NR_ftime 35 +#define __NR_sync 36 +#define __NR_kill 37 +#define __NR_rename 38 +#define __NR_mkdir 39 +#define __NR_rmdir 40 +#define __NR_dup 41 +#define __NR_pipe 42 +#define __NR_times 43 +#define __NR_prof 44 +#define __NR_brk 45 +#define __NR_setgid 46 +#define __NR_getgid 47 +#define __NR_signal 48 +#define __NR_geteuid 49 +#define __NR_getegid 50 +#define __NR_acct 51 +#define __NR_umount2 52 +#define __NR_lock 53 +#define __NR_ioctl 54 +#define __NR_fcntl 55 +#define __NR_mpx 56 +#define __NR_setpgid 57 +#define __NR_ulimit 58 +#define __NR_oldolduname 59 +#define __NR_umask 60 +#define __NR_chroot 61 +#define __NR_ustat 62 +#define __NR_dup2 63 +#define __NR_getppid 64 +#define __NR_getpgrp 65 +#define __NR_setsid 66 +#define __NR_sigaction 67 +#define __NR_sgetmask 68 +#define __NR_ssetmask 69 +#define __NR_setreuid 70 +#define __NR_setregid 71 +#define __NR_sigsuspend 72 +#define __NR_sigpending 73 +#define __NR_sethostname 74 +#define __NR_setrlimit 75 +#define __NR_oldgetrlimit 76 +#define __NR_getrusage 77 +#define __NR_gettimeofday 78 +#define __NR_settimeofday 79 +#define __NR_getgroups 80 +#define __NR_setgroups 81 +#define __NR_select 142 +#define __NR_symlink 83 +#define __NR_oldlstat 84 +#define __NR_readlink 85 +#define __NR_uselib 86 +#define __NR_swapon 87 +#define __NR_reboot 88 +#define __NR_readdir 89 +#define __NR_oldmmap 90 +#define __NR_munmap 91 +#define __NR_truncate 92 +#define __NR_ftruncate 93 +#define __NR_fchmod 94 +#define __NR_fchown 95 +#define __NR_getpriority 96 +#define __NR_setpriority 97 +#define __NR_profil 98 +#define __NR_statfs 99 +#define __NR_fstatfs 100 +#define __NR_ioperm 101 +#define __NR_socketcall 102 +#define __NR_syslog 103 +#define __NR_setitimer 104 +#define __NR_getitimer 105 +#define __NR_stat 106 +#define __NR_lstat 107 +#define __NR_fstat 108 +#define __NR_olduname 109 +#define __NR_iopl 110 +#define __NR_vhangup 111 +#define __NR_idle 112 +#define __NR_vm86old 113 +#define __NR_wait4 114 +#define __NR_swapoff 115 +#define __NR_sysinfo 116 +#define __NR_ipc 117 +#define __NR_fsync 118 +#define __NR_sigreturn 119 +#define __NR_clone 120 +#define __NR_setdomainname 121 +#define __NR_uname 122 +#define __NR_modify_ldt 123 +#define __NR_adjtimex 124 +#define __NR_mprotect 125 +#define __NR_sigprocmask 126 +#define __NR_create_module 127 +#define __NR_init_module 128 +#define __NR_delete_module 129 +#define __NR_get_kernel_syms 130 +#define __NR_quotactl 131 +#define __NR_getpgid 132 +#define __NR_fchdir 133 +#define __NR_bdflush 134 +#define __NR_sysfs 135 +#define __NR_personality 136 +#define __NR_afs_syscall 137 /* Syscall for Andrew File System */ +#define __NR_setfsuid 138 +#define __NR_setfsgid 139 +#define __NR__llseek 140 +#define __NR_getdents 141 +#define __NR__newselect 142 +#define __NR_flock 143 +#define __NR_msync 144 +#define __NR_readv 145 +#define __NR_writev 146 +#define __NR_getsid 147 +#define __NR_fdatasync 148 +#define __NR__sysctl 149 +#define __NR_mlock 150 +#define __NR_munlock 151 +#define __NR_mlockall 152 +#define __NR_munlockall 153 +#define __NR_sched_setparam 154 +#define __NR_sched_getparam 155 +#define __NR_sched_setscheduler 156 +#define __NR_sched_getscheduler 157 +#define __NR_sched_yield 158 +#define __NR_sched_get_priority_max 159 +#define __NR_sched_get_priority_min 160 +#define __NR_sched_rr_get_interval 161 +#define __NR_nanosleep 162 +#define __NR_mremap 163 +#define __NR_setresuid 164 +#define __NR_getresuid 165 +#define __NR_vm86 166 +#define __NR_query_module 167 +#define __NR_poll 168 +#define __NR_nfsservctl 169 +#define __NR_setresgid 170 +#define __NR_getresgid 171 +#define __NR_prctl 172 +#define __NR_rt_sigreturn 173 +#define __NR_rt_sigaction 174 +#define __NR_rt_sigprocmask 175 +#define __NR_rt_sigpending 176 +#define __NR_rt_sigtimedwait 177 +#define __NR_rt_sigqueueinfo 178 +#define __NR_rt_sigsuspend 179 +#define __NR_pread 180 +#define __NR_pwrite 181 +#define __NR_chown 182 +#define __NR_getcwd 183 +#define __NR_capget 184 +#define __NR_capset 185 +#define __NR_sigaltstack 186 +#define __NR_sendfile 187 +#define __NR_getpmsg 188 /* some people actually want streams */ +#define __NR_putpmsg 189 /* some people actually want streams */ +#define __NR_vfork 190 +#define __NR_getrlimit 191 +#define __NR_mmap 192 + + +#endif /* SFSYSNR_H */ diff --git a/dest/include/librz/sflib/linux-x86-64/sflib.h b/dest/include/librz/sflib/linux-x86-64/sflib.h new file mode 100644 index 00000000000..0a8649dc277 --- /dev/null +++ b/dest/include/librz/sflib/linux-x86-64/sflib.h @@ -0,0 +1,334 @@ +/* + * sflib.h --- SFLib syscall library for Linux/amd64 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + + +/* + * Automatically generated by gensflib.py + * Mon Mar 21 13:23:31 2022 + */ + +#ifndef SFLIB_H +#define SFLIB_H + + +#include "sfsysnr.h" +#include "sfsyscall.h" +#include "../common/sftypes.h" + + +static inline _sfsyscall3( ssize_t, read, int, fd, void *, buf, size_t, count ) +static inline _sfsyscall3( ssize_t, write, int, fd, const void *, buf, size_t, count ) +static inline _sfsyscall3( int, open, const char *, pathname, int, flags, mode_t, mode ) +static inline _sfsyscall1( int, close, int, fd ) +static inline _sfsyscall2( int, stat, const char *, file_name, struct stat *, buf ) +static inline _sfsyscall2( int, fstat, int, filedes, struct stat *, buf ) +static inline _sfsyscall2( int, lstat, const char *, file_name, struct stat *, buf ) +static inline _sfsyscall3( int, poll, struct pollfd *, ufds, unsigned int, nfds, int, timeout ) +static inline _sfsyscall3( off_t, lseek, int, fildes, off_t, offset, int, whence ) +static inline _sfsyscall6(void *,mmap, void *,start, size_t,length, int,prot , int,flags, int,fd, off_t,offset) +static inline _sfsyscall3( int, mprotect, const void *, addr, size_t, len, int, prot ) +static inline _sfsyscall2( int, munmap, void *, start, size_t, length ) +static inline _sfsyscall1( int, brk, void *, end_data_segment ) +// rt_sigaction +// rt_sigprocmask +// rt_sigreturn +static inline _sfsyscall4(int, ioctl, int,d, int,request, char *,argp, int,len) +// pread64 +// pwrite64 +static inline _sfsyscall3( int, readv, int, fd, const struct iovec *, vector, int, count ) +static inline _sfsyscall3( int, writev, int, fd, const struct iovec *, vector, int, count ) +static inline _sfsyscall2( int, access, const char *, pathname, int, mode ) +static inline _sfsyscall1( int, pipe, unsigned long *, filedes) +static inline _sfsyscall5( int, select, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout) +static inline _sfsyscall0( int, sched_yield ) +// mremap +static inline _sfsyscall3( int, msync, const void *, start, size_t, length, int, flags ) +// mincore +// madvise +static inline _sfsyscall3(int, shmget, long, key, int, size, int, flags ) +static inline _sfsyscall3(void *, shmat, int, shmid, const void *, shmaddr, int, shmflg ) +// shmctl +static inline _sfsyscall1( int, dup, int, oldfd ) +static inline _sfsyscall2( int, dup2, int, oldfd, int, newfd ) +static inline _sfsyscall0( int, pause ) +static inline _sfsyscall2( int, nanosleep, const struct timespec *, req, struct timespec *, rem ) +// getitimer +static inline _sfsyscall1( unsigned int, alarm, unsigned int, seconds ) +// setitimer +static inline _sfsyscall0( pid_t, getpid ) +// sendfile +static inline _sfsyscall3(int, socket, int,domain, int,type, int,protocol) +static inline _sfsyscall3(int,connect, int,sockfd, const struct sockaddr *,serv_addr, socklen_t,addrlen) +static inline _sfsyscall3(int, accept, int,s, struct sockaddr *,addr, socklen_t,addrlen); +static inline _sfsyscall6(ssize_t, sendto, int, s, const void *, msg, size_t, len, int, flags, const struct sockaddr *, to, socklen_t, tolen) +static inline _sfsyscall6(ssize_t, recvfrom, int, s, void * , buf, size_t, len, int, flags, struct sockaddr * , from, socklen_t * , fromlen) +// sendmsg +// recvmsg +// shutdown +static inline _sfsyscall3(int, bind, int,sockfd, struct sockaddr *,my_addr, socklen_t,addrlen) +static inline _sfsyscall2(int,listen,int,s, int,backlog) +// getsockname +// getpeername +// socketpair +static inline _sfsyscall5(int, setsockopt, int, s, int, level, int, optname, void *, optval, socklen_t, optlen) +// getsockopt +// clone +static inline _sfsyscall0( pid_t, fork ) +static inline _sfsyscall0( pid_t, vfork ) +static inline _sfsyscall3(int, execve, char *, s, char **, argv, char **,envp) +static inline _sfsyscall1(int, exit, int, status) +static inline _sfsyscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, struct rusage *, rusage) +static inline _sfsyscall2( int, kill, pid_t, pid, int, sig ) +static inline _sfsyscall1( int, uname, struct utsname *, buf ) +static inline _sfsyscall3(int, semget, long, key, int, nsems, int, semflg) +static inline _sfsyscall3(int, semop, int, semid, struct sembuf *, sops, unsigned, nsops) +// semctl +// shmdt +// msgget +// msgsnd +// msgrcv +// msgctl +static inline _sfsyscall3( int, fcntl, int, fd, int, cmd, long, arg ) +// flock +static inline _sfsyscall1( int, fsync, int, fd ) +static inline _sfsyscall1( int, fdatasync, int, fd ) +static inline _sfsyscall2( int, truncate, const char *, path, off_t, length ) +static inline _sfsyscall2( int, ftruncate, int, fd, off_t, length ) +static inline _sfsyscall3( int, getdents, unsigned int, fd, struct dirent *, dirp, unsigned int, count ) +// getcwd +static inline _sfsyscall1( int, chdir, const char *, path ) +// fchdir +static inline _sfsyscall2( int, rename, const char *, oldpath, const char *, newpath ) +static inline _sfsyscall2( int, mkdir, const char *, pathname, mode_t, mode ) +static inline _sfsyscall1( int, rmdir, const char *, pathname ) +static inline _sfsyscall2( int, creat, const char *, pathname, mode_t, mode ) +static inline _sfsyscall2( int, link, const char *, oldpath, const char *, newpath ) +static inline _sfsyscall1( int, unlink, const char *, pathname ) +static inline _sfsyscall2( int, symlink, const char *, oldpath, const char *, newpath ) +static inline _sfsyscall3( int, readlink, const char *, path, char *, buf, size_t, bufsiz ) +static inline _sfsyscall2( int, chmod, const char *, path, mode_t, mode ) +static inline _sfsyscall2( int, fchmod, int, fildes, mode_t, mode ) +static inline _sfsyscall3( int, chown, const char *, path, uid_t, owner, gid_t, group ) +static inline _sfsyscall3( int, fchown, int, fd, uid_t, owner, gid_t, group ) +static inline _sfsyscall3( int, lchown, const char *, path, uid_t, owner, gid_t, group ) +static inline _sfsyscall1( mode_t, umask, mode_t, mask ) +static inline _sfsyscall2( int, gettimeofday, struct timeval *, tv, struct timezone *, tz ) +// getrlimit +// getrusage +static inline _sfsyscall1( int, sysinfo, struct sysinfo *, info ) +static inline _sfsyscall1( clock_t, times, struct tms *, buf ) +static inline _sfsyscall4(long, ptrace, int, request, pid_t, pid, void *,addr, void *,data) +static inline _sfsyscall0( uid_t, getuid ) +static inline _sfsyscall3( int, syslog, int, type, char *, bufp, int, len ) +static inline _sfsyscall0( gid_t, getgid ) +// setuid +// setgid +static inline _sfsyscall0( uid_t, geteuid ) +static inline _sfsyscall0( gid_t, getegid ) +static inline _sfsyscall2( int, setpgid, pid_t, pid, pid_t, pgid ) +static inline _sfsyscall0( pid_t, getppid ) +static inline _sfsyscall0( pid_t, getpgrp ) +static inline _sfsyscall0( pid_t, setsid ) +static inline _sfsyscall2( int, setreuid, uid_t, ruid, uid_t, euid ) +static inline _sfsyscall2( int, setregid, gid_t, rgid, gid_t, egid ) +// getgroups +static inline _sfsyscall2( int, setgroups, size_t, size, const gid_t *, list ) +static inline _sfsyscall3( int, setresuid, uid_t, ruid, uid_t, euid, uid_t, suid ) +static inline _sfsyscall3( int, getresuid, uid_t *, ruid, uid_t *, euid, uid_t *, suid ) +// setresgid +// getresgid +static inline _sfsyscall1( pid_t, getpgid, pid_t, pid ) +static inline _sfsyscall1( int, setfsuid, uid_t, fsuid ) +static inline _sfsyscall1( int, setfsgid, uid_t, fsgid ) +static inline _sfsyscall1( pid_t, getsid, pid_t, pid ) +static inline _sfsyscall2( int, capget, cap_user_header_t, header, cap_user_data_t, data ) +//static inline _sfsyscall2( int, capset, cap_user_header_t, header, const cap_user_data_t, data ) +// rt_sigpending +// rt_sigtimedwait +// rt_sigqueueinfo +// rt_sigsuspend +// sigaltstack +static inline _sfsyscall2( int, utime, const char *, filename, struct utimbuf *, buf ) +static inline _sfsyscall3( int, mknod, const char *, pathname, mode_t, mode, dev_t, dev ) +static inline _sfsyscall1( int, uselib, const char *, library ) +static inline _sfsyscall1( int, personality, unsigned long, persona ) +static inline _sfsyscall2( int, ustat, dev_t, dev, struct ustat *, ubuf ) +static inline _sfsyscall2( int, statfs, const char *, path, struct statfs *, buf ) +static inline _sfsyscall2( int, fstatfs, int, fd, struct statfs *, buf ) +static inline _sfsyscall3( int, sysfs, int, option, unsigned int, fs_index, char *, buf ) +static inline _sfsyscall2( int, getpriority, int, which, int, who ) +static inline _sfsyscall3( int, setpriority, int, which, int, who, int, prio ) +static inline _sfsyscall2( int, sched_setparam, pid_t, pid, const struct sched_param *, p ) +static inline _sfsyscall2( int, sched_getparam, pid_t, pid, struct sched_param *, p ) +// sched_setscheduler +static inline _sfsyscall1( int, sched_getscheduler, pid_t, pid ) +static inline _sfsyscall1( int, sched_get_priority_max, int, policy ) +static inline _sfsyscall1( int, sched_get_priority_min, int, policy ) +static inline _sfsyscall2( int, sched_rr_get_interval, pid_t, pid, struct timespec *, tp ) +static inline _sfsyscall2( int, mlock, const void *, addr, size_t, len ) +static inline _sfsyscall2( int, munlock, const void *, addr, size_t, len ) +static inline _sfsyscall1( int, mlockall, int, flags ) +static inline _sfsyscall0( int, munlockall ) +static inline _sfsyscall0( int, vhangup ) +// modify_ldt +// pivot_root +// prctl +// arch_prctl +// adjtimex +// setrlimit +static inline _sfsyscall1( int, chroot, const char *, path ) +static inline _sfsyscall0( int, sync ) +static inline _sfsyscall1( int, acct, const char *, filename ) +// settimeofday +// mount +// umount2 +static inline _sfsyscall2( int, swapon, const char *, path, int, swapflags ) +static inline _sfsyscall1( int, swapoff, const char *, path ) +// reboot +static inline _sfsyscall2( int, sethostname, const char *, name, size_t, len ) +static inline _sfsyscall2( int, setdomainname, const char *, name, size_t, len ) +static inline _sfsyscall1( int, iopl, int, level ) +static inline _sfsyscall3( int, ioperm, unsigned long, from, unsigned long, num, int, turn_on ) +static inline _sfsyscall2( caddr_t, create_module, const char *, name, size_t, size ) +static inline _sfsyscall2( int, init_module, const char *, name, struct module *, image ) +static inline _sfsyscall1( int, delete_module, const char *, name ) +static inline _sfsyscall1( int, get_kernel_syms, struct kernel_sym *, table ) +// query_module +// quotactl +// nfsservctl +// getpmsg +// putpmsg +// afs_syscall +// tuxcall +// security +// gettid +// readahead +// setxattr +// lsetxattr +// fsetxattr +// getxattr +// lgetxattr +// fgetxattr +// listxattr +// llistxattr +// flistxattr +// removexattr +// lremovexattr +// fremovexattr +// tkill +static inline _sfsyscall1( time_t, time, time_t *, t ) +// futex +// sched_setaffinity +// sched_getaffinity +// set_thread_area +// io_setup +// io_destroy +// io_getevents +// io_submit +// io_cancel +// get_thread_area +// lookup_dcookie +// epoll_create +// epoll_ctl_old +// epoll_wait_old +// remap_file_pages +// getdents64 +// set_tid_address +// restart_syscall +// semtimedop +// fadvise64 +// timer_create +// timer_settime +// timer_gettime +// timer_getoverrun +// timer_delete +// clock_settime +// clock_gettime +// clock_getres +// clock_nanosleep +// exit_group +// epoll_wait +// epoll_ctl +// tgkill +// utimes +// vserver +// mbind +// set_mempolicy +// get_mempolicy +// mq_open +// mq_unlink +// mq_timedsend +// mq_timedreceive +// mq_notify +// mq_getsetattr +// kexec_load +// waitid +// add_key +// request_key +// keyctl +// ioprio_set +// ioprio_get +// inotify_init +// inotify_add_watch +// inotify_rm_watch +// migrate_pages +// openat +// mkdirat +// mknodat +// fchownat +// futimesat +// newfstatat +// unlinkat +// renameat +// linkat +// symlinkat +// readlinkat +// fchmodat +// faccessat +// pselect6 +// ppoll +// unshare +// set_robust_list +// get_robust_list +// splice +// tee +// sync_file_range +// vmsplice +// move_pages +// utimensat +// getcpu +// epoll_pwait +// signalfd +// timerfd_create +// eventfd +// fallocate +// timerfd_settime +// timerfd_gettime +// accept4 +// signalfd4 +// eventfd2 +// epoll_create1 +// dup3 +// pipe2 +// inotify_init1 +// preadv +// pwritev + + +//#include "../common/sfsocketcall.h" + + +#endif /* SFLIB_H */ diff --git a/dest/include/librz/sflib/linux-x86-64/sfsyscall.h b/dest/include/librz/sflib/linux-x86-64/sfsyscall.h new file mode 100644 index 00000000000..700d0f97995 --- /dev/null +++ b/dest/include/librz/sflib/linux-x86-64/sfsyscall.h @@ -0,0 +1,203 @@ +/* + * sfsyscall.h --- SFLib syscall macros for Linux/amd64 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + + +/* + * Automatically generated by gensflib.py + * Mon Mar 21 13:23:31 2022 + */ + +#ifndef SFSYSCALL_H +#define SFSYSCALL_H + + +/* $Id$ */ + +#ifdef SF_USE_ERRNO + +static int errno=1234; + +#define __sfsyscall_return(type, res) \ +do { \ + if ((unsigned long)(res) >= (unsigned long)(-125)) { \ + errno = -(res); \ + res = -1; \ + } \ + return (type) (res); \ +} while (0) + +#else /* SF_USE_ERRNO */ + +#define __sfsyscall_return(type, res) \ +do { \ + return (type) (res); \ +} while (0) + +#endif /* SF_USE_ERRNO */ + + +/* syscall macros */ + +#define _sfsyscall0(type, name) \ +type name(void) { \ + long __res; \ + __asm__ volatile("###> " #name " <###\n\t" \ + "syscall" \ + : "=a" (__res) \ + : "0" (__NR_##name) \ + : "memory", "rcx", "r11", "cc" \ + ); \ + __sfsyscall_return(type,__res); \ +} + +#define _sfsyscall1(type, name, type1, arg1) \ +type name(type1 arg1) { \ + long __res; \ + register type1 rdi asm("rdi"); \ + rdi = arg1; \ + asm volatile("###> " #name "(%2) <###\n\t" \ + "syscall" \ + : "=a" (__res) \ + : "0" (__NR_##name), \ + "r" (rdi) \ + : "memory", "rcx", "r11", "cc" \ + ); \ + __sfsyscall_return(type,__res); \ +} + +#define _sfsyscall2(type, name, type1, arg1, type2, arg2) \ + type name(type1 arg1, type2 arg2) { \ + long __res; \ + register type1 rdi asm("rdi"); \ + register type2 rsi asm("rsi"); \ + rdi = arg1; \ + rsi = arg2; \ + __asm__ volatile("###> " #name "(%2, %3) <###\n\t" \ + "syscall" \ + : "=a" (__res) \ + : "0" (__NR_##name), \ + "r" (rdi), \ + "r" (rsi) \ + : "memory", "rcx", "r11", "cc" \ + ); \ + __sfsyscall_return(type, __res); \ +} + +#define _sfsyscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ + type name(type1 arg1, type2 arg2, type3 arg3) { \ + long __res; \ + register type1 rdi asm("rdi"); \ + register type2 rsi asm("rsi"); \ + register type3 rdx asm("rdx"); \ + rdi = arg1; \ + rsi = arg2; \ + rdx = arg3; \ + asm volatile("###> " #name "(%2, %3, %4) <###\n\t" \ + "syscall" \ + : "=a" (__res) \ + : "0" (__NR_##name), \ + "r" (rdi), \ + "r" (rsi), \ + "r" (rdx) \ + : "memory", "rcx", "r11", "cc" \ + ); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall4(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ + long __res; \ + register type1 rdi asm("rdi"); \ + register type2 rsi asm("rsi"); \ + register type3 rdx asm("rdx"); \ + register type4 r10 asm("r10"); \ + rdi = arg1; \ + rsi = arg2; \ + rdx = arg3; \ + r10 = arg4; \ + asm volatile("###> " #name "(%2, %3, %4, %5) <###\n\t" \ + "syscall" \ + : "=a" (__res) \ + : "0" (__NR_##name), \ + "r" (rdi), \ + "r" (rsi), \ + "r" (rdx), \ + "r" (r10) \ + : "memory", "rcx", "r11", "cc" \ + ); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall5(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) \ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ + type5 arg5) { \ + long __res; \ + register type1 rdi asm("rdi"); \ + register type2 rsi asm("rsi"); \ + register type3 rdx asm("rdx"); \ + register type4 r10 asm("r10"); \ + register type5 r8 asm("r8"); \ + rdi = arg1; \ + rsi = arg2; \ + rdx = arg3; \ + r10 = arg4; \ + r8 = arg5; \ + asm volatile("###> " #name "(%2, %3, %4, %5, %6) <###\n\t" \ + "syscall" \ + : "=a" (__res) \ + : "0" (__NR_##name), \ + "r" (rdi), \ + "r" (rsi), \ + "r" (rdx), \ + "r" (r10), \ + "r" (r8) \ + : "memory", "rcx", "r11", "cc" \ + ); \ + __sfsyscall_return(type, __res); \ + } + +#define _sfsyscall6(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5, type6, arg6)\ + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ + type5 arg5, type6 arg6) { \ + long __res; \ + register type1 rdi asm("rdi"); \ + register type2 rsi asm("rsi"); \ + register type3 rdx asm("rdx"); \ + register type4 r10 asm("r10"); \ + register type5 r8 asm("r8"); \ + register type6 r9 asm("r9"); \ + rdi = arg1; \ + rsi = arg2; \ + rdx = arg3; \ + r10 = arg4; \ + r8 = arg5; \ + r9 = arg6; \ + asm volatile("###> " #name "(%2, %3, %4, %5, %6, %7) <###\n\t" \ + "syscall" \ + : "=a" (__res) \ + : "0" (__NR_##name), \ + "r" (rdi), \ + "r" (rsi), \ + "r" (rdx), \ + "r" (r10), \ + "r" (r8), \ + "r" (r9) \ + : "memory", "rcx", "r11", "cc" \ + ); \ + __sfsyscall_return(type, __res); \ + } + +#endif /* SFSYSCALL_H */ diff --git a/dest/include/librz/sflib/linux-x86-64/sfsysnr.h b/dest/include/librz/sflib/linux-x86-64/sfsysnr.h new file mode 100644 index 00000000000..c9a62201217 --- /dev/null +++ b/dest/include/librz/sflib/linux-x86-64/sfsysnr.h @@ -0,0 +1,332 @@ +/* + * sfsysnr.h --- SFLib syscall numbers for Linux/amd64 + * see http://www.secdev.org/projects/shellforge.html for more informations + * + * Copyright (C) 2004 Philippe Biondi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + + +/* + * Automatically generated by gensflib.py + * Mon Mar 21 13:23:31 2022 + */ + +#ifndef SFSYSNR_H +#define SFSYSNR_H + +/* $Id$ */ + +#define __NR_read 0 +#define __NR_write 1 +#define __NR_open 2 +#define __NR_close 3 +#define __NR_stat 4 +#define __NR_fstat 5 +#define __NR_lstat 6 +#define __NR_poll 7 +#define __NR_lseek 8 +#define __NR_mmap 9 +#define __NR_mprotect 10 +#define __NR_munmap 11 +#define __NR_brk 12 +#define __NR_rt_sigaction 13 +#define __NR_rt_sigprocmask 14 +#define __NR_rt_sigreturn 15 +#define __NR_ioctl 16 +#define __NR_pread64 17 +#define __NR_pwrite64 18 +#define __NR_readv 19 +#define __NR_writev 20 +#define __NR_access 21 +#define __NR_pipe 22 +#define __NR_select 23 +#define __NR_sched_yield 24 +#define __NR_mremap 25 +#define __NR_msync 26 +#define __NR_mincore 27 +#define __NR_madvise 28 +#define __NR_shmget 29 +#define __NR_shmat 30 +#define __NR_shmctl 31 +#define __NR_dup 32 +#define __NR_dup2 33 +#define __NR_pause 34 +#define __NR_nanosleep 35 +#define __NR_getitimer 36 +#define __NR_alarm 37 +#define __NR_setitimer 38 +#define __NR_getpid 39 +#define __NR_sendfile 40 +#define __NR_socket 41 +#define __NR_connect 42 +#define __NR_accept 43 +#define __NR_sendto 44 +#define __NR_recvfrom 45 +#define __NR_sendmsg 46 +#define __NR_recvmsg 47 +#define __NR_shutdown 48 +#define __NR_bind 49 +#define __NR_listen 50 +#define __NR_getsockname 51 +#define __NR_getpeername 52 +#define __NR_socketpair 53 +#define __NR_setsockopt 54 +#define __NR_getsockopt 55 +#define __NR_clone 56 +#define __NR_fork 57 +#define __NR_vfork 58 +#define __NR_execve 59 +#define __NR_exit 60 +#define __NR_wait4 61 +#define __NR_kill 62 +#define __NR_uname 63 +#define __NR_semget 64 +#define __NR_semop 65 +#define __NR_semctl 66 +#define __NR_shmdt 67 +#define __NR_msgget 68 +#define __NR_msgsnd 69 +#define __NR_msgrcv 70 +#define __NR_msgctl 71 +#define __NR_fcntl 72 +#define __NR_flock 73 +#define __NR_fsync 74 +#define __NR_fdatasync 75 +#define __NR_truncate 76 +#define __NR_ftruncate 77 +#define __NR_getdents 78 +#define __NR_getcwd 79 +#define __NR_chdir 80 +#define __NR_fchdir 81 +#define __NR_rename 82 +#define __NR_mkdir 83 +#define __NR_rmdir 84 +#define __NR_creat 85 +#define __NR_link 86 +#define __NR_unlink 87 +#define __NR_symlink 88 +#define __NR_readlink 89 +#define __NR_chmod 90 +#define __NR_fchmod 91 +#define __NR_chown 92 +#define __NR_fchown 93 +#define __NR_lchown 94 +#define __NR_umask 95 +#define __NR_gettimeofday 96 +#define __NR_getrlimit 97 +#define __NR_getrusage 98 +#define __NR_sysinfo 99 +#define __NR_times 100 +#define __NR_ptrace 101 +#define __NR_getuid 102 +#define __NR_syslog 103 +/* at the very end the stuff that never runs during the benchmarks */ +#define __NR_getgid 104 +#define __NR_setuid 105 +#define __NR_setgid 106 +#define __NR_geteuid 107 +#define __NR_getegid 108 +#define __NR_setpgid 109 +#define __NR_getppid 110 +#define __NR_getpgrp 111 +#define __NR_setsid 112 +#define __NR_setreuid 113 +#define __NR_setregid 114 +#define __NR_getgroups 115 +#define __NR_setgroups 116 +#define __NR_setresuid 117 +#define __NR_getresuid 118 +#define __NR_setresgid 119 +#define __NR_getresgid 120 +#define __NR_getpgid 121 +#define __NR_setfsuid 122 +#define __NR_setfsgid 123 +#define __NR_getsid 124 +#define __NR_capget 125 +#define __NR_capset 126 +#define __NR_rt_sigpending 127 +#define __NR_rt_sigtimedwait 128 +#define __NR_rt_sigqueueinfo 129 +#define __NR_rt_sigsuspend 130 +#define __NR_sigaltstack 131 +#define __NR_utime 132 +#define __NR_mknod 133 +/* Only needed for a.out */ +#define __NR_uselib 134 +#define __NR_personality 135 +#define __NR_ustat 136 +#define __NR_statfs 137 +#define __NR_fstatfs 138 +#define __NR_sysfs 139 +#define __NR_getpriority 140 +#define __NR_setpriority 141 +#define __NR_sched_setparam 142 +#define __NR_sched_getparam 143 +#define __NR_sched_setscheduler 144 +#define __NR_sched_getscheduler 145 +#define __NR_sched_get_priority_max 146 +#define __NR_sched_get_priority_min 147 +#define __NR_sched_rr_get_interval 148 +#define __NR_mlock 149 +#define __NR_munlock 150 +#define __NR_mlockall 151 +#define __NR_munlockall 152 +#define __NR_vhangup 153 +#define __NR_modify_ldt 154 +#define __NR_pivot_root 155 +#define __NR__sysctl 156 +#define __NR_prctl 157 +#define __NR_arch_prctl 158 +#define __NR_adjtimex 159 +#define __NR_setrlimit 160 +#define __NR_chroot 161 +#define __NR_sync 162 +#define __NR_acct 163 +#define __NR_settimeofday 164 +#define __NR_mount 165 +#define __NR_umount2 166 +#define __NR_swapon 167 +#define __NR_swapoff 168 +#define __NR_reboot 169 +#define __NR_sethostname 170 +#define __NR_setdomainname 171 +#define __NR_iopl 172 +#define __NR_ioperm 173 +#define __NR_create_module 174 +#define __NR_init_module 175 +#define __NR_delete_module 176 +#define __NR_get_kernel_syms 177 +#define __NR_query_module 178 +#define __NR_quotactl 179 +#define __NR_nfsservctl 180 +/* reserved for LiS/STREAMS */ +#define __NR_getpmsg 181 +#define __NR_putpmsg 182 +/* reserved for AFS */ +#define __NR_afs_syscall 183 +/* reserved for tux */ +#define __NR_tuxcall 184 +#define __NR_security 185 +#define __NR_gettid 186 +#define __NR_readahead 187 +#define __NR_setxattr 188 +#define __NR_lsetxattr 189 +#define __NR_fsetxattr 190 +#define __NR_getxattr 191 +#define __NR_lgetxattr 192 +#define __NR_fgetxattr 193 +#define __NR_listxattr 194 +#define __NR_llistxattr 195 +#define __NR_flistxattr 196 +#define __NR_removexattr 197 +#define __NR_lremovexattr 198 +#define __NR_fremovexattr 199 +#define __NR_tkill 200 +#define __NR_time 201 +#define __NR_futex 202 +#define __NR_sched_setaffinity 203 +#define __NR_sched_getaffinity 204 +#define __NR_set_thread_area 205 +#define __NR_io_setup 206 +#define __NR_io_destroy 207 +#define __NR_io_getevents 208 +#define __NR_io_submit 209 +#define __NR_io_cancel 210 +#define __NR_get_thread_area 211 +#define __NR_lookup_dcookie 212 +#define __NR_epoll_create 213 +#define __NR_epoll_ctl_old 214 +#define __NR_epoll_wait_old 215 +#define __NR_remap_file_pages 216 +#define __NR_getdents64 217 +#define __NR_set_tid_address 218 +#define __NR_restart_syscall 219 +#define __NR_semtimedop 220 +#define __NR_fadvise64 221 +#define __NR_timer_create 222 +#define __NR_timer_settime 223 +#define __NR_timer_gettime 224 +#define __NR_timer_getoverrun 225 +#define __NR_timer_delete 226 +#define __NR_clock_settime 227 +#define __NR_clock_gettime 228 +#define __NR_clock_getres 229 +#define __NR_clock_nanosleep 230 +#define __NR_exit_group 231 +#define __NR_epoll_wait 232 +#define __NR_epoll_ctl 233 +#define __NR_tgkill 234 +#define __NR_utimes 235 +#define __NR_vserver 236 +#define __NR_mbind 237 +#define __NR_set_mempolicy 238 +#define __NR_get_mempolicy 239 +#define __NR_mq_open 240 +#define __NR_mq_unlink 241 +#define __NR_mq_timedsend 242 +#define __NR_mq_timedreceive 243 +#define __NR_mq_notify 244 +#define __NR_mq_getsetattr 245 +#define __NR_kexec_load 246 +#define __NR_waitid 247 +#define __NR_add_key 248 +#define __NR_request_key 249 +#define __NR_keyctl 250 +#define __NR_ioprio_set 251 +#define __NR_ioprio_get 252 +#define __NR_inotify_init 253 +#define __NR_inotify_add_watch 254 +#define __NR_inotify_rm_watch 255 +#define __NR_migrate_pages 256 +#define __NR_openat 257 +#define __NR_mkdirat 258 +#define __NR_mknodat 259 +#define __NR_fchownat 260 +#define __NR_futimesat 261 +#define __NR_newfstatat 262 +#define __NR_unlinkat 263 +#define __NR_renameat 264 +#define __NR_linkat 265 +#define __NR_symlinkat 266 +#define __NR_readlinkat 267 +#define __NR_fchmodat 268 +#define __NR_faccessat 269 +#define __NR_pselect6 270 +#define __NR_ppoll 271 +#define __NR_unshare 272 +#define __NR_set_robust_list 273 +#define __NR_get_robust_list 274 +#define __NR_splice 275 +#define __NR_tee 276 +#define __NR_sync_file_range 277 +#define __NR_vmsplice 278 +#define __NR_move_pages 279 +#define __NR_utimensat 280 +#define __IGNORE_getcpu /* implemented as a vsyscall */ +#define __NR_epoll_pwait 281 +#define __NR_signalfd 282 +#define __NR_timerfd_create 283 +#define __NR_eventfd 284 +#define __NR_fallocate 285 +#define __NR_timerfd_settime 286 +#define __NR_timerfd_gettime 287 +#define __NR_accept4 288 +#define __NR_signalfd4 289 +#define __NR_eventfd2 290 +#define __NR_epoll_create1 291 +#define __NR_dup3 292 +#define __NR_pipe2 293 +#define __NR_inotify_init1 294 +#define __NR_preadv 295 +#define __NR_pwritev 296 + +#endif /* SFSYSNR_H */ diff --git a/dest/share/cons/ayu b/dest/share/cons/ayu new file mode 100644 index 00000000000..9d1c57b946b --- /dev/null +++ b/dest/share/cons/ayu @@ -0,0 +1,59 @@ +# SPDX-FileCopyrightText: 2018 securisec +# SPDX-License-Identifier: LGPL-3.0-only + +ec ai.exec rgb:6d6 +ec ai.read rgb:66d +ec ai.write rgb:d66 +ec args rgb:2bc +ec b0x00 rgb:738699 # 00 bytes +ec b0x7f rgb:677 +ec b0xff rgb:abb0b6 # ff bytes +ec btext rgb:5de # text section opcode? first byte of opcode +ec comment rgb:95e6cb # rizin renerated comments +ec creg rgb:ff7733 # modified registries +ec flag rgb:5ccfe6 # flags. usually apprears above the current seek +ec fline rgb:55b4d4 # function line. the boundary of a function +ec flow rgb:c2d94c # lines that show jump destinations +ec flow2 rgb:ddd +ec fname rgb:ff6a00 # function name +ec graph.traced rgb:2eb +ec graph.box rgb:5c6773 # unselected boxes in visual graph mode +ec graph.box2 rgb:ff6a00 # currently selected box in visual graph mode +ec graph.box3 rgb:66d9ef +ec graph.box4 rgb:66d9ef +ec graph.current rgb:fff +ec graph.false rgb:f07178 # false line on visual graph mode +ec graph.true rgb:bae67e # true line on visual graph mode +ec graph.ujump rgb:55b4d4 # lines in graph that does not have true or false +ec help rgb:c2d94c # color of help explanation text +ec input rgb:888 +ec jmp rgb:c2d94c # jmp instructions +ec label rgb:66d9ef +ec linehl rgb:42505e # highlight color when using asm.highlight +ec mov rgb:d9d8d7 # mov instructions +ec nop rgb:a37acc # nop instructions +ec num rgb:f28779 # numbers +ec offset rgb:ed9366 # offset in visual mode +ec other rgb:888 +ec prompt rgb:5de # color for main rizin prompt +ec call rgb:ff7733 # push instructions +ec reg rgb:e6e1cf # register names +ec ret rgb:d66 # ret opcode +ec swi rgb:d66 +ec trap rgb:d66 +ec cmp rgb:5de +ec push rgb:5de +ec math rgb:5de +ec bin rgb:5de +ec pop rgb:5de +ec cjmp rgb:c2d94c # je, jg, etc +ec ucall rgb:5ccfe6 +ec ujmp rgb:c2d94c +ec usrcmt rgb:fa6e32 # user comment + +ec func_var rgb:95e6cb +ec func_var_type rgb:ffd580 +ec func_var_addr rgb:f28779 + +ec widget_bg rgb:888 rgb:000 +ec widget_sel rgb:5de rgb:333 diff --git a/dest/share/cons/basic b/dest/share/cons/basic new file mode 100644 index 00000000000..423d11e94aa --- /dev/null +++ b/dest/share/cons/basic @@ -0,0 +1,59 @@ +# SPDX-FileCopyrightText: 2015 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +# optimized for windows +ecd +k one=cyan +k two=white +ec fname `k one` +ec label `k one` +ec fline `k one` +ec flag `k one` +ec offset `k two` +ec comment red +ec usrcmt green +ec flow green +ec flow2 green +ec b0x00 white +ec b0xff red +ec bin cyan +ec b0x7f white +ec other gray +ec btext cyan +ec invalid red +ec trap red +ec ucall cyan +ec ujmp green +ec args green +ec help yellow +ec prompt cyan +ec mov gray +ec math gray +ec push yellow +ec reg white +ec creg white +ec num cyan +ec invalid red +ec swi cyan +ec cmp yellow +ec call cyan +ec cjmp green +ec jmp green +ec pop yellow +ec linehl rgb:004 +ec graph.true green +ec graph.false red +ec graph.ujump blue +ec graph.current blue +ec graph.traced blue +ec graph.box gray +ec graph.box2 blue +ec graph.box3 gray +ec graph.box4 gray + +ec func_var white +ec func_var_type blue +ec func_var_addr cyan + +ec widget_bg white gray +ec widget_sel black cyan diff --git a/dest/share/cons/behelit b/dest/share/cons/behelit new file mode 100644 index 00000000000..ea57c8c8205 --- /dev/null +++ b/dest/share/cons/behelit @@ -0,0 +1,69 @@ +# SPDX-FileCopyrightText: 2016 oblique +# SPDX-License-Identifier: LGPL-3.0-only + +ec b0x7f rgb:ff5f5f +ec b0xff rgb:ff005f +ec b0x00 rgb:262626 +ec btext rgb:af87ff +ec other rgb:4e4e4e +ec offset rgb:4e4e4e +ec flow rgb:5f87ff +ec flow2 rgb:5f87ff +ec input rgb:5fff5f +ec prompt rgb:5f87ff +ec args rgb:ff005f +ec help rgb:af87d7 +ec comment rgb:ff005f +ec usrcmt rgb:000000 rgb:5f87ff +ec flag rgb:5f87ff +ec fline rgb:af87ff +ec fname rgb:5f87ff +ec floc rgb:5f87ff +ec label rgb:5f87ff +ec mov rgb:5f87ff +ec call rgb:000000 rgb:00ff5f +ec jmp rgb:000000 rgb:5f5fff +ec cjmp rgb:000000 rgb:5f87ff +ec cmp rgb:ff005f +ec nop rgb:4e4e4e +ec math rgb:ffff5f +ec bin rgb:ff5f5f +ec ret rgb:ff005f +ec push rgb:af87ff +ec pop rgb:af87ff +ec swi rgb:8787ff +ec crypto rgb:000000 rgb:ff5f5f +ec trap rgb:000000 rgb:ff005f +ec ucall rgb:000000 rgb:00ff5f +ec ujmp rgb:000000 rgb:5f87ff + +ec invalid rgb:000000 rgb:ff005f +ec num rgb:af87ff rgb:121212 +ec reg rgb:5fff5f rgb:121212 +ec creg rgb:5f87ff +ec ai.read rgb:00ff5f +ec ai.write rgb:5f87ff +ec ai.exec rgb:ff005f +ec ai.seq rgb:af87ff +ec ai.ascii rgb:ff5f5f +ec graph.box rgb:00ff5f +ec graph.box2 rgb:5f87ff +ec graph.box3 rgb:af87ff +ec graph.box4 rgb:ff005f +ec graph.true rgb:00ff5f +ec graph.false rgb:ff005f +ec graph.ujump rgb:5f87ff +ec graph.current rgb:5f87ff +ec graph.traced rgb:ffff5f +ec linehl rgb:1f1f1f + +# background of the terminal must be #121212 +# foreground of the terminal must be #5fff5f +# xterm -bg rgb:12/12/12 -fg rgb:5f/ff/5f + +ec func_var rgb:ff005f +ec func_var_type blue +ec func_var_addr rgb:5f87ff + +ec widget_bg rgb:68f rgb:555 +ec widget_sel black rgb:0f6 diff --git a/dest/share/cons/bold b/dest/share/cons/bold new file mode 100644 index 00000000000..5488f948f1b --- /dev/null +++ b/dest/share/cons/bold @@ -0,0 +1,76 @@ +# SPDX-FileCopyrightText: 2018 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +ec b0x00 rgb:ccc +ec b0x7f rgb:ccc +ec b0xff red +ec btext rgb:fff . bold + +ec args white +ec bin white +ec cmp white +ec usrcmt black white bold +ec reg green . bold +ec creg rgb:f72 +ec flag yellow . bold +ec fline white + +ec flow yellow +ec flow2 white + +ec fname black green bold +ec help yellow . bold +ec input yellow . bold +ec label white . bold +ec math white +ec mov white +ec nop rgb:ccc + +ec comment yellow . bold +ec call black green bold +ec ucall black green bold +ec num rgb:fff . bold +ec jmp yellow . bold +ec cjmp yellow . bold +ec ujmp yellow . bold + +ec offset white . bold +ec other rgb:999 +ec pop rgb:999 + +ec prompt black yellow bold + +ec graph.box white +ec graph.box2 green +ec graph.box3 rgb:000 +ec graph.box4 rgb:000 + +ec graph.true green . bold +ec graph.false red + +ec push white +ec ret rgb:777 +ec swi black red bold +ec trap red +ec graph.ujump rgb:ddd +ec graph.current rgb:f72 +ec graph.traced rgb:f00 +ec gui.cflow rgb:f72 +ec gui.dataoffset rgb:f72 +ec crypto rgb:f72 +ec floc rgb:777 +ec invalid red +ec linehl rgb:008 + +ec func_var yellow . bold +ec func_var_type blue . bold +ec func_var_addr cyan . bold + +ec ai.read white . bold +ec ai.write white . bold +ec ai.exec red . bold +ec ai.seq green . bold +ec ai.ascii yellow . bold + +ec widget_bg yellow black +ec widget_sel black yellow diff --git a/dest/share/cons/bright b/dest/share/cons/bright new file mode 100644 index 00000000000..de5164fcb0d --- /dev/null +++ b/dest/share/cons/bright @@ -0,0 +1,75 @@ +# SPDX-FileCopyrightText: 2019 Khairul Azhar Kasmiran +# SPDX-License-Identifier: LGPL-3.0-only + +# rizin default palette but with bright colors for all + +ec b0x00 rgb:00ff00 +ec b0x7f rgb:00ffff +ec b0xff rgb:ff0000 +ec args rgb:ffff00 +ec bin rgb:00ffff +ec btext rgb:ffff00 +ec call rgb:00ff00 . bold +ec cjmp rgb:00ff00 +ec cmp rgb:00ffff +ec comment rgb:ff0000 +ec usrcmt rgb:ffffff +ec creg rgb:00ffff +ec flag rgb:00ffff +ec fline rgb:00ffff +ec floc rgb:00ffff +ec flow rgb:00ffff +ec flow2 rgb:0000ff +ec fname rgb:ff0000 +ec help rgb:00ff00 +ec input rgb:ffffff +ec invalid rgb:ff0000 . bold +ec jmp rgb:00ff00 +ec label rgb:00ffff +ec math rgb:ffff00 +ec mov rgb:ffffff +ec nop rgb:0000ff +ec num rgb:ffff00 +ec offset rgb:00ff00 +ec other rgb:ffffff +ec pop rgb:ff00ff . bold +ec prompt rgb:ffff00 +ec push rgb:ff00ff +ec crypto rgb:ffff00 +ec reg rgb:00ffff +ec ret rgb:ff0000 +ec swi rgb:ff00ff +ec trap rgb:ff0000 . bold +ec ucall rgb:00ff00 +ec ujmp rgb:00ff00 + +ec ai.read rgb:00ff00 +ec ai.write rgb:0000ff +ec ai.exec rgb:ff0000 +ec ai.seq rgb:ff00ff +ec ai.ascii rgb:ffff00 + +ec gui.cflow rgb:ffff00 +ec gui.dataoffset rgb:ffff00 +ec gui.background rgb:000000 +ec gui.alt_background rgb:ffffff +ec gui.border rgb:000000 +ec wordhl rgb:ff0000 +ec linehl rgb:000080 + +ec func_var rgb:ffffff +ec func_var_type rgb:ffff00 +ec func_var_addr rgb:00ffff + +ec widget_bg rgb:303030 +ec widget_sel rgb:ff0000 + +ec graph.box rgb:0000ff +ec graph.box2 rgb:00ff00 +ec graph.box3 rgb:ff00ff +ec graph.box4 rgb:808080 +ec graph.true rgb:00ff00 +ec graph.false rgb:ff0000 +ec graph.ujump rgb:0000ff # single jump +ec graph.traced rgb:ffff00 +ec graph.current rgb:0000ff diff --git a/dest/share/cons/cga b/dest/share/cons/cga new file mode 100644 index 00000000000..08e422766ca --- /dev/null +++ b/dest/share/cons/cga @@ -0,0 +1,75 @@ +# SPDX-FileCopyrightText: 2016 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +ec comment rgb:0ff +ec usrcmt rgb:f0f +ec mov white +ec fname rgb:f00 +ec args white +ec floc rgb:f0f +ec fline rgb:f0f +ec flag rgb:f0f +ec invalid rgb:f0f +ec trap rgb:f0f +ec swi rgb:f0f +ec ret rgb:f0f +ec input rgb:0ff +ec fname rgb:f0f +ec label rgb:f0f +ec flow rgb:f0f +ec flow2 rgb:f0f +ec prompt rgb:0ff +ec offset rgb:0ff +ec other rgb:fff +ec b0x00 rgb:fff +ec b0x7f rgb:f0f +ec b0xff rgb:0ff +ec math rgb:f0f +ec crypto rgb:f0f +ec bin rgb:f0f +ec btext rgb:f0f +ec push rgb:0ff +ec pop rgb:0ff +ec jmp rgb:f0f +ec cjmp rgb:f0f +ec call rgb:f0f +ec nop rgb:0ff +ec trap rgb:f0f +ec cmp rgb:0ff +ec reg rgb:f0f +ec creg rgb:f0f +ec num rgb:0ff +ec help rgb:0ff +ec trap rgb:000 rgb:f0f +ec ucall rgb:f0f +ec ujmp rgb:f0f +ec linehl rgb:008 + +ec graph.box rgb:f0f +ec graph.box2 rgb:f0f +ec graph.box3 rgb:f0f +ec graph.box4 rgb:f0f +ec graph.true rgb:f0f +ec graph.false rgb:0ff +ec graph.ujump rgb:f0f +ec graph.current rgb:0ff +ec graph.traced rgb:f0f + +ec gui.cflow rgb:0ff +ec gui.dataoffset rgb:0ff +ec gui.background rgb:0ff +ec gui.alt_background rgb:0ff +ec gui.border rgb:0ff + +ec ai.read rgb:0ff +ec ai.write rgb:f0f +ec ai.exec rgb:f0f +ec ai.seq rgb:f0f +ec ai.ascii rgb:f0f + +ec func_var rgb:f0f +ec func_var_type rgb:f0f +ec func_var_addr rgb:0ff + +ec widget_bg rgb:f0f rgb:000 +ec widget_sel rgb:0ff rgb:000 diff --git a/dest/share/cons/consonance b/dest/share/cons/consonance new file mode 100644 index 00000000000..2ad43c4d9a3 --- /dev/null +++ b/dest/share/cons/consonance @@ -0,0 +1,67 @@ +# SPDX-FileCopyrightText: 2014 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +# background of the terminal must be 134 o 033 +# xterm -fn 10x20 -bg rgb:20/20/20 -fg rgb:d0/d0/d0 +# ref: https://github.com/eugeneching/ida-consonance/blob/master/ida-consonance.clr + +ec b0x00 rgb:9aa +ec b0x7f rgb:577 +ec b0xff rgb:8cf +ec bin rgb:fff +ec btext rgb:fff +ec ucall rgb:2fa +ec call rgb:f2a +ec ujmp rgb:4cf +ec cjmp rgb:4cf +ec jmp rgb:4cf +ec cmp rgb:fff +ec comment rgb:fcc +ec usrcmt rgb:f2a +ec ret rgb:4cf +ec fline rgb:fff +ec flow rgb:789 +ec flow2 rgb:888 +ec fname rgb:ee0 +ec label rgb:ee0 +ec math rgb:fff +ec mov rgb:fff +ec nop rgb:888 +ec num rgb:fff +ec offset rgb:888 +ec other rgb:577 +ec pop rgb:fff +ec prompt rgb:4cf +ec push rgb:fff +ec reg rgb:789 +ec args rgb:789 +ec help rgb:ee0 +ec input rgb:c41 +ec trap rgb:d41 +ec swi rgb:f2a +ec creg rgb:789 +ec flag rgb:4cf +ec linehl rgb:004 + +ec graph.box rgb:789 +ec graph.box2 rgb:d41 +ec graph.box3 rgb:af2 +ec graph.box4 rgb:af2 +ec graph.true rgb:4f2 +ec graph.false rgb:d41 +ec graph.ujump rgb:4cf +ec graph.current rgb:af2 +ec graph.traced rgb:090 + +ec func_var rgb:fcc +ec func_var_type rgb:f2a +ec func_var_addr white + +ec ai.read rgb:fcc +ec ai.write rgb:f2a +ec ai.exec rgb:f2a +ec ai.seq rgb:f0f +ec ai.ascii rgb:fff + +ec widget_bg rgb:4cf rgb:344 +ec widget_sel black rgb:4cf diff --git a/dest/share/cons/cutter b/dest/share/cons/cutter new file mode 100644 index 00000000000..4fb8cec03af --- /dev/null +++ b/dest/share/cons/cutter @@ -0,0 +1,71 @@ +# SPDX-FileCopyrightText: 2017 xarkes +# SPDX-License-Identifier: LGPL-3.0-only + +ec comment rgb:8e8c8b +ec usrcmt rgb:8e8c8b +ec args rgb:20b0c0 +ec fname rgb:0693c9 +ec floc rgb:00ffff +ec fline rgb:5f8700 +ec flag rgb:0a8ab0 0 bold +ec label rgb:0068bd +ec help rgb:005f87 +ec flow rgb:5f8700 +ec flow2 rgb:5f8700 +ec prompt rgb:000000 +ec offset rgb:8e8c8b +ec input rgb:000000 +ec invalid rgb:e03030 +ec other rgb:005f87 +ec b0x00 rgb:707070 +ec b0x7f rgb:7f7f7f +ec b0xff rgb:e03030 +ec math rgb:005f87 +ec bin rgb:005f87 +ec btext rgb:000000 +ec push rgb:da3192 +ec pop rgb:da3192 +ec crypto rgb:d03080 +ec jmp rgb:5f8700 +ec cjmp rgb:5f8700 +ec ujmp rgb:5f8700 +ec call rgb:0693c9 +ec ucall rgb:0693c9 +ec nop rgb:005f87 +ec ret rgb:0693c9 +ec trap rgb:0693c9 +ec swi rgb:5f8700 +ec cmp rgb:da3192 +ec reg rgb:005f87 +ec creg rgb:005f87 +ec num rgb:ef5919 +ec mov rgb:da3192 +ec func_var rgb:d03080 +ec func_var_type rgb:876ac1 +ec func_var_addr rgb:b0b0b0 +ec widget_bg rgb:303030 +ec widget_sel rgb:ff0000 +ec ai.read rgb:1080d0 +ec ai.write rgb:005f87 +ec ai.exec rgb:b08000 +ec ai.seq rgb:d03080 +ec ai.ascii rgb:000000 +ec graph.box rgb:005f87 +ec graph.box2 rgb:5f8700 +ec graph.box3 rgb:e03030 +ec graph.box4 rgb:005f87 +ec graph.true rgb:5f8700 +ec graph.false rgb:e03030 +ec graph.ujump rgb:005f87 +ec graph.current rgb:00f0f0 +ec graph.traced rgb:e03030 +ec gui.cflow rgb:ffff00 +ec gui.dataoffset rgb:ffff00 +ec gui.background rgb:000000 +ec gui.alt_background rgb:ffffff +ec gui.border rgb:000000 +ec wordhl rgb:ff0000 +ec linehl rgb:efefef + +ec widget_bg rgb:4cf rgb:058 +ec widget_sel black rgb:d39 diff --git a/dest/share/cons/dark b/dest/share/cons/dark new file mode 100644 index 00000000000..f074ead4dde --- /dev/null +++ b/dest/share/cons/dark @@ -0,0 +1,63 @@ +# SPDX-FileCopyrightText: 2013 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +ec b0x00 rgb:444 +ec help rgb:366 +ec comment rgb:99a +ec usrcmt rgb:368 +ec input rgb:bbb +ec b0x7f rgb:555 +ec b0xff rgb:666 +ec bin rgb:f90 +ec btext rgb:366 +ec call rgb:44f rgb:123 +ec cjmp rgb:368 +ec cmp rgb:666 +ec fline rgb:366 +ec flag rgb:99a +ec flow rgb:bbb +ec flow2 rgb:99a +ec jmp rgb:368 +ec fname rgb:99a +ec label rgb:99a +ec math rgb:366 +ec bin rgb:366 +ec crypto rgb:366 +ec mov rgb:666 +ec nop rgb:444 +ec num rgb:99a +ec offset rgb:366 +ec other rgb:bbb +ec prompt rgb:366 +ec push rgb:99a +ec pop rgb:99a +ec reg rgb:368 +ec creg rgb:368 +ec trap rgb:000 rgb: +ec swi rgb:99a +ec ucall rgb:44f rgb:123 +ec ujmp rgb:368 +ec invalid rgb:rgb:44f rgb:123 +ec linehl rgb:004 +ec graph.box rgb:040 +ec graph.box2 rgb:040 +ec graph.box3 rgb:040 +ec graph.box4 rgb:040 +ec graph.true rgb:06c +ec graph.false rgb:035 +ec graph.ujump rgb:06c +ec graph.current rgb:99a +ec graph.traced rgb:bbb + +ec func_var rgb:99a +ec func_var_type rgb:636 +ec func_var_addr rgb:366 + +ec ai.read rgb:266 +ec ai.write rgb:366 +ec ai.exec rgb:368 +ec ai.seq rgb:d38 +ec ai.ascii rgb:99a + +ec widget_bg rgb:366 black +ec widget_sel rgb:44f rgb:123 diff --git a/dest/share/cons/darkda b/dest/share/cons/darkda new file mode 100644 index 00000000000..03d37662822 --- /dev/null +++ b/dest/share/cons/darkda @@ -0,0 +1,64 @@ +# SPDX-FileCopyrightText: 2018 securisec +# SPDX-License-Identifier: LGPL-3.0-only + +ec b0x00 rgb:7c7c61 +ec b0x7f rgb:aaff00 +ec b0xff rgb:aaff00 +ec other rgb:ff7f00 +ec bin rgb:ff5afd +ec btext rgb:617c7c +ec call rgb:ffd200 +ec cjmp rgb:9dd600 +ec jmp rgb:9dd600 +ec cmp rgb:00ffff +ec comment rgb:82607e +ec usrcmt rgb:f3c5ff +ec ret rgb:ffaa7f +ec num rgb:d25032 +ec fline rgb:2bc +ec flow rgb:00b1ab +ec flow2 rgb:ddd +ec fname rgb:00ffff +ec label rgb:66d9ef +ec math rgb:ffffff +ec mov rgb:ffffff +ec nop rgb:FFE792 +ec offset rgb:ababab +ec prompt rgb:fc0 +ec pop rgb:ef8d1a +ec push rgb:df077e +ec reg rgb:009d9d +ec args rgb:ffd200 +ec help rgb:009d9d +ec input rgb:888 +ec trap rgb:d66 +ec ucall rgb:ffd200 +ec ujmp rgb:9dd600 +ec swi rgb:df077e +ec creg rgb:69d200 +ec flag rgb:00b1ab +ec linehl rgb:00007f +ec ai.read rgb:66d +ec ai.write rgb:d66 +ec ai.exec rgb:6d6 +ec graph.box rgb:5202f0 +ec graph.box2 rgb:ffcc00 +ec graph.box3 rgb:66d9ef +ec graph.box4 rgb:66d9ef +ec graph.true rgb:009100 +ec graph.false rgb:bc0000 +ec graph.ujump rgb:0043cb +ec graph.current rgb:fff + +ec func_var rgb:99a +ec func_var_type rgb:df077e +ec func_var_addr rgb:ababab + +ec ai.read rgb:be077e +ec ai.write rgb:df077e +ec ai.exec rgb:9dd600 +ec ai.seq rgb:9dd600 +ec ai.ascii rgb:d25032 + +ec widget_bg rgb:099 rgb:444 +ec widget_sel rgb:000 yellow diff --git a/dest/share/cons/defragger b/dest/share/cons/defragger new file mode 100644 index 00000000000..9e905ce85d7 --- /dev/null +++ b/dest/share/cons/defragger @@ -0,0 +1,74 @@ +# SPDX-FileCopyrightText: 2018 Rene Laemmert +# SPDX-License-Identifier: LGPL-3.0-only + +ec call rgb:ffff00 +ec ucall rgb:ffff00 +ec comment rgb:32302f +ec usrcmt rgb:ffc5f3 +ec ret rgb:fb4934 +ec args rgb:a89984 +ec fname rgb:fad200 +ec fline rgb:458588 +ec floc rgb:00ffff +ec flag rgb:d75f00 +ec label rgb:8787d7 +ec help rgb:ff5f87 +ec flow2 rgb:0000ff +ec prompt rgb:d75f00 +ec offset rgb:afafaf +ec input rgb:d75f00 +ec invalid rgb:001f00 +ec other rgb:5f8787 +ec b0x00 rgb:005f5f +ec b0x7f rgb:005f5f +ec b0xff rgb:5f8787 +ec math rgb:00afd7 +ec bin rgb:87afaf +ec btext rgb:afafaf +ec push rgb:ff5f87 +ec pop rgb:87afaf +ec crypto rgb:0000ff +ec jmp rgb:ff5f87 +ec cjmp rgb:afaf00 +ec ujmp rgb:ff5f87 +ec nop rgb:5f8787 +ec trap rgb:ff0000 +ec swi rgb:ff0000 +ec cmp rgb:d75f00 +ec reg rgb:73adad +ec creg rgb:73adad +ec num rgb:d25032 +ec mov rgb:ebebeb +ec linehl rgb:00003f +ec ai.read rgb:00ff00 +ec ai.write rgb:0000ff +ec ai.exec rgb:ff0000 +ec ai.seq rgb:ff00ff +ec ai.ascii rgb:ffff00 +ec graph.box rgb:9e9e9e +ec graph.box2 rgb:5f87d7 +ec graph.box3 rgb:af5f87 +ec graph.box4 rgb:303030 +ec graph.ujump rgb:005fff +ec graph.current rgb:c68e00 +ec graph.true rgb:009100 +ec graph.false rgb:bc0000 +ec graph.traced rgb:ffff00 +ec gui.cflow rgb:ffff00 +ec gui.dataoffset rgb:ffff00 +ec gui.background rgb:303030 +ec gui.alt_background rgb:ffffff +ec gui.border rgb:5fd700 + +ec func_var rgb:64604f +ec func_var_type rgb:00afd7 +ec func_var_addr rgb:afafaf + +ec ai.read rgb:a55f00 +ec ai.write rgb:d75f00 +ec ai.exec rgb:ff5f87 +ec ai.seq rgb:9dd600 +ec ai.ascii rgb:d25032 + +ec widget_bg rgb:099 rgb:444 +ec widget_sel rgb:000 yellow diff --git a/dest/share/cons/durian b/dest/share/cons/durian new file mode 100644 index 00000000000..130de995af2 --- /dev/null +++ b/dest/share/cons/durian @@ -0,0 +1,62 @@ +# SPDX-FileCopyrightText: 2022 Florian Märkl +# SPDX-License-Identifier: LGPL-3.0-only + +# Based on Armin Ronacher's summerfruit.vim +# https://www.vim.org/scripts/script.php?script_id=1872 + +ec ai.exec "" +ec ai.read "" +ec ai.write "" +ec args rgb:0086d2 +ec b0x00 rgb:70796b +ec b0x7f rgb:70796b +ec b0xff rgb:abb0b6 +ec btext rgb:fb660a +ec creg rgb:fb660a +ec flag rgb:ff0086 +ec fline rgb:70796b +ec flow rgb:70796b +ec flow2 rgb:70796b +ec fname rgb:fb660a +ec graph.traced rgb:2eb +ec graph.box rgb:70796b +ec graph.box2 rgb:ff6a00 +ec graph.box3 rgb:66d9ef +ec graph.box4 rgb:66d9ef +ec graph.current rgb:fff +ec graph.false rgb:ff0086 +ec graph.true rgb:22a21f +ec graph.ujump rgb:0086d2 +ec help rgb:22a21f +ec input rgb:fb660a +ec jmp rgb:ff7733 +ec label rgb:ff0086 +ec linehl rgb:f00 rgb:b7dce8 +ec mov rgb:0086f7 +ec nop rgb:70796b +ec num rgb:0086f7 +ec offset rgb:0086d2 +ec other rgb:70796b +ec prompt rgb:0086d2 +ec call rgb:ff7733 "" bold +ec reg "" +ec ret rgb:fb660a +ec swi rgb:0086f7 +ec trap rgb:ff0086 +ec cmp rgb:0086f7 +ec push rgb:0086f7 +ec math rgb:0086f7 +ec bin rgb:0086f7 +ec pop rgb:0086f7 +ec cjmp rgb:ff7733 +ec ucall rgb:ff7733 "" bold +ec ujmp rgb:ff7733 +ec comment rgb:22a21f +ec usrcmt rgb:22a21f + +ec func_var rgb:22a21f +ec func_var_type rgb:fd8900 +ec func_var_addr rgb:0086d2 + +ec widget_bg rgb:888 rgb:000 +ec widget_sel rgb:5de rgb:333 diff --git a/dest/share/cons/focus b/dest/share/cons/focus new file mode 100644 index 00000000000..5a3ef83bddc --- /dev/null +++ b/dest/share/cons/focus @@ -0,0 +1,64 @@ +# SPDX-FileCopyrightText: 2014 condret +# SPDX-License-Identifier: LGPL-3.0-only + +ec fname rgb:0cf rgb:000 +ec label rgb:0cf rgb:000 +ec math rgb:ccc +ec bin rgb:f90 +ec call rgb:ff0 rgb:00f +ec ucall rgb:000 rgb:ff0 +ec jmp rgb:ff0 rgb:00f +ec cjmp rgb:ff0 +ec ujmp rgb:ff3 +ec ret rgb:f00 +ec trap rgb:000 rgb:f00 +ec offset rgb:fff +ec prompt byellow +ec comment rgb:0cf +ec usrcmt rgb:ff0 rgb:06f +ec push rgb:f3f +ec pop rgb:f3f bold +ec cmp rgb:ff0 rgb:060 +ec nop rgb:000 +ec b0x00 green +ec b0x7f cyan +ec b0xff red +ec btext yellow +ec other rgb:666 +ec num rgb:ff0 +ec reg rgb:6f0 rgb:000 +ec fline rgb:fc0 +ec flow rgb:ff3 +ec flow2 rgb:fff +ec mov rgb:888 +ec swi rgb:000 rgb:fff +ec floc rgb:af2 +ec linehl rgb:222 +ec ai.read green +ec ai.write blue +ec ai.exec red +ec ai.seq rgb:ff00ff +ec ai.ascii rgb:ffff00 + +ec graph.box blue +ec graph.box2 yellow +ec graph.box3 blue +ec graph.box4 blue +ec graph.true green +ec graph.false red +ec graph.ujump blue +ec graph.current blue +ec graph.traced red + +ec func_var cyan +ec func_var_type rgb:f3f +ec func_var_addr white + +ec ai.read rgb:8f0 +ec ai.write rgb:6f0 +ec ai.exec rgb:f3f +ec ai.seq white +ec ai.ascii yellow + +ec widget_bg rgb:ff0 rgb:000 +ec widget_sel rgb:000 rgb:0f0 diff --git a/dest/share/cons/gb b/dest/share/cons/gb new file mode 100644 index 00000000000..c4140d50c4d --- /dev/null +++ b/dest/share/cons/gb @@ -0,0 +1,74 @@ +# SPDX-FileCopyrightText: 2019 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +ec comment rgb:86c06c +ec usrcmt rgb:86c06c +ec mov rgb:306850 +ec fname rgb:e0f8cf +ec args white +ec floc rgb:86c06c +ec fline rgb:e0f8cf +ec flag rgb:e0f8cf +ec invalid rgb:306850 +ec input rgb:e0f8cf +ec label rgb:86c06c +ec flow rgb:86c06c +ec flow2 rgb:86c06c +ec prompt rgb:e0f8cf +ec offset rgb:306850 +ec other rgb:306850 +ec b0x00 rgb:306850 +ec b0x7f rgb:86c06c +ec b0xff rgb:e0f8cf +ec math rgb:86c06c +ec crypto rgb:86c06c +ec bin rgb:86c06c +ec btext rgb:86c06c +ec push rgb:86c06c +ec pop rgb:86c06c +ec jmp rgb:e0f8cf +ec cjmp rgb:e0f8cf +ec ujmp rgb:e0f8cf +ec call rgb:e0f8cf +ec trap rgb:e0f8cf +ec swi rgb:e0f8cf +ec ret rgb:e0f8cf +ec cmp rgb:86c06c +ec nop rgb:306850 +ec trap rgb:86c06c +ec reg rgb:e0f8cf +ec creg rgb:e8f8cf +ec num rgb:e0f8cf +ec help rgb:e0f8cf +ec trap rgb:000 rgb:86c06c +ec ucall rgb:86c06c +ec linehl rgb:306850 + +ec graph.box rgb:86c06c +ec graph.box2 rgb:86c06c +ec graph.box3 rgb:86c06c +ec graph.box4 rgb:86c06c +ec graph.true rgb:86c06c +ec graph.false rgb:e0f8cf +ec graph.ujump rgb:86c06c +ec graph.current rgb:e0f8cf +ec graph.traced rgb:86c06c + +ec gui.cflow rgb:e0f8cf +ec gui.dataoffset rgb:e0f8cf +ec gui.background rgb:e0f8cf +ec gui.alt_background rgb:e0f8cf +ec gui.border rgb:e0f8cf + +ec ai.read rgb:e0f8cf +ec ai.write rgb:86c06c +ec ai.exec rgb:86c06c +ec ai.seq rgb:86c06c +ec ai.ascii rgb:86c06c + +ec func_var rgb:86c06c +ec func_var_type rgb:86c06c +ec func_var_addr rgb:e0f8cf + +ec widget_bg rgb:86c06c rgb:000 +ec widget_sel rgb:e0f8cf rgb:000 diff --git a/dest/share/cons/gentoo b/dest/share/cons/gentoo new file mode 100644 index 00000000000..3a11254c2b7 --- /dev/null +++ b/dest/share/cons/gentoo @@ -0,0 +1,71 @@ +# SPDX-FileCopyrightText: 2019 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +ec comment cyan +ec usrcmt cyan +ec args cyan +ec fname green +ec floc yellow +ec fline blue +ec flag green +ec label yellow +ec help cyan +ec flow cyan +ec flow2 blue +ec prompt green +ec offset yellow +ec input rgb:f03030 +ec invalid red +ec other rgb:c0c0c0 +ec b0x00 rgb:808080 +ec b0x7f rgb:c0c0c0 +ec b0xff cyan +ec math white +ec bin rgb:f0f0f0 +ec btext rgb:009000 +ec push yellow +ec pop yellow +ec crypto cyan +ec call green +ec ucall green +ec nop rgb:3030f0 +ec ret rgb:30f030 +ec trap rgb:f03030 +ec ujmp rgb:009000 +ec jmp rgb:009000 +ec cjmp rgb:009000 +ec swi black yellow +ec cmp cyan +ec reg rgb:f0f0f0 +ec creg yellow +ec num yellow +ec mov rgb:d0d0d0 +ec func_var white +ec func_var_type yellow +ec func_var_addr white +ec widget_bg rgb:303030 +ec widget_sel rgb:ff0000 +ec ai.read rgb:e0e0e0 +ec ai.write rgb:d0d0d0 +ec ai.exec rgb:f0f0f0 +ec ai.seq rgb:f03030 +ec ai.ascii rgb:f03030 +ec graph.box rgb:3030f0 +ec graph.box2 cyan +ec graph.box3 rgb:30f030 +ec graph.box4 rgb:30f030 +ec graph.true rgb:30f030 +ec graph.false rgb:f03030 +ec graph.ujump rgb:3030f0 +ec graph.current rgb:f03030 +ec graph.traced rgb:f00000 +ec gui.cflow rgb:f03030 +ec gui.dataoffset rgb:3030f0 +ec gui.background rgb:000000 +ec gui.alt_background rgb:ffffff +ec gui.border rgb:000000 +ec wordhl rgb:ff0000 +ec linehl rgb:101010 + +ec widget_bg cyan rgb:3030f0 +ec widget_sel yellow rgb:090 diff --git a/dest/share/cons/lima b/dest/share/cons/lima new file mode 100644 index 00000000000..19d77a96f70 --- /dev/null +++ b/dest/share/cons/lima @@ -0,0 +1,68 @@ +# SPDX-FileCopyrightText: 2013 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +ec comment rgb:af2 +ec usrcmt rgb:af2 rgb:140 +ec mov rgb:090 +ec fname rgb:27a +ec args white +ec floc rgb:af2 +ec fline rgb:af2 +ec flag rgb:af2 +ec fname rgb:af2 +ec label rgb:af2 +ec flow rgb:af2 +ec flow2 rgb:af2 +ec prompt rgb:090 +ec offset rgb:ef0 +ec input rgb:7d5 +ec other rgb:090 +ec b0x00 rgb:040 +ec b0x7f rgb:090 +ec b0xff rgb:af2 +ec math rgb:090 +ec crypto rgb:090 +ec bin rgb:ef0 +ec btext rgb:ef0 +ec push rgb:ef0 +ec pop rgb:ef0 +ec jmp rgb:af2 +ec cjmp rgb:af2 +ec ujmp rgb:af2 +ec call rgb:fff +ec ucall rgb:fff +ec nop rgb:2da +ec ret rgb:5d5 +ec trap rgb:a7a +ec swi rgb:dd5 +ec cmp rgb:0a0 +ec reg rgb:af2 +ec creg rgb:af2 +ec num rgb:ef0 +ec help rgb:af2 +ec invalid rgb:ef0 +ec trap rgb:000 rgb:af2 +ec linehl rgb:140 + +ec graph.box rgb:af2 +ec graph.box2 rgb:0a0 +ec graph.box3 rgb:444 +ec graph.box4 rgb:444 +ec graph.true rgb:ef2 +ec graph.false rgb:5d5 +ec graph.ujump rgb:af2 +ec graph.current rgb:af2 +ec graph.traced rgb:090 + +ec func_var yellow +ec func_var_type green +ec func_var_addr yellow + +ec ai.read rgb:8e2 +ec ai.write rgb:9e2 +ec ai.exec rgb:af2 +ec ai.seq rgb:ef0 +ec ai.ascii rgb:ef0 + +ec widget_bg rgb:ef0 rgb:060 +ec widget_sel black rgb:af2 diff --git a/dest/share/cons/mars b/dest/share/cons/mars new file mode 100644 index 00000000000..2966dd102d6 --- /dev/null +++ b/dest/share/cons/mars @@ -0,0 +1,65 @@ +# SPDX-FileCopyrightText: 2022 Anton Kochkov +# SPDX-License-Identifier: LGPL-3.0-only + +ec b0x00 rgb:4f2526 +ec b0x7f rgb:727069 +ec b0xff rgb:443d35 +ec bin rgb:988c77 +ec btext rgb:abb0ce + +ec call rgb:f48d20 +ec ucall rgb:f07019 +ec jmp rgb:ee320b +ec ujmp rgb:a01a0a +ec cjmp rgb:871a0a + +ec args rgb:8e735c +ec cmp rgb:a0a0a0 +ec comment rgb:7f1609 +ec usrcmt rgb:d0e0b0 +ec reg rgb:fdf4cb +ec creg rgb:d0e0a0 +ec flag rgb:b0270e +ec fline rgb:dd0045 +ec flow rgb:f72 +ec flow2 rgb:fff +ec fname rgb:de0008 +ec help rgb:9a2813 +ec input rgb:f72 +ec label rgb:d20009 +ec math rgb:777 +ec mov rgb:ded0d0 +ec nop rgb:544 +ec num rgb:d10007 +ec offset rgb:686660 +ec other rgb:4c4040 +ec pop rgb:99300f +ec prompt rgb:8b1409 +ec push rgb:99300f +ec ret rgb:f55521 +ec swi rgb:ff7020 +ec trap rgb:f07020 +ec linehl rgb:111 + +ec graph.true rgb:e99e35 +ec graph.false rgb:9b260c +ec graph.ujump rgb:bf614a +ec graph.current rgb:fff862 +ec graph.traced rgb:f00005 +ec graph.box rgb:de3a0b +ec graph.box2 rgb:7c0003 +ec graph.box3 rgb:370001 +ec graph.box4 rgb:370001 + +ec func_var rgb:d18066 +ec func_var_type rgb:f07020 +ec func_var_addr rgb:82260e + +ec ai.read rgb:e0c0c0 +ec ai.write rgb:e0b0b0 +ec ai.exec rgb:e0a0a0 +ec ai.seq rgb:e09090 +ec ai.ascii rgb:f06050 + +ec widget_bg rgb:f07020 rgb:333 +ec widget_sel rgb:333 rgb:f07020 diff --git a/dest/share/cons/matrix b/dest/share/cons/matrix new file mode 100644 index 00000000000..af929acaa11 --- /dev/null +++ b/dest/share/cons/matrix @@ -0,0 +1,64 @@ +# SPDX-FileCopyrightText: 2015 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +ec b0x00 rgb:030 +ec b0x7f rgb:0f0 +ec b0xff rgb:050 +ec bin rgb:0f0 +ec crypto rgb:0f0 +ec other rgb:0a0 +ec btext rgb:0b0 +ec ucall rgb:0b0 +ec call rgb:0b0 +ec ujmp rgb:2f2 +ec cjmp rgb:2f2 +ec jmp rgb:2f2 +ec cmp rgb:191 +ec comment rgb:060 +ec usrcmt rgb:3f3 +ec ret rgb:0b0 +ec fline rgb:0a0 +ec flow bgreen +ec flow2 green +ec fname rgb:0b0 +ec label rgb:0f0 +ec math rgb:040 +ec invalid rgb:060 +ec mov rgb:383 +ec nop rgb:030 +ec num rgb:3f3 +ec offset rgb:383 +ec pop rgb:040 +ec prompt rgb:080 +ec push rgb:060 +ec reg rgb:1a1 +ec args rgb:0b0 +ec help rgb:0b0 +ec input rgb:0a0 +ec trap rgb:040 +ec swi rgb:0b0 +ec creg rgb:080 +ec flag rgb:0f0 +ec linehl rgb:020 +ec graph.box green +ec graph.box2 rgb:060 +ec graph.box3 rgb:ff0000 +ec graph.box4 rgb:0000ff +ec graph.true green +ec graph.false rgb:050 +ec graph.ujump green +ec graph.current green +ec graph.traced rgb:060 + +ec func_var rgb:060 +ec func_var_type rgb:383 +ec func_var_addr rgb:060 + +ec ai.read rgb:0a1 +ec ai.write rgb:1a1 +ec ai.exec rgb:383 +ec ai.seq rgb:3f3 +ec ai.ascii rgb:3f3 + +ec widget_bg rgb:0b0 rgb:000 +ec widget_sel black rgb:0c0 diff --git a/dest/share/cons/monokai b/dest/share/cons/monokai new file mode 100644 index 00000000000..58795353940 --- /dev/null +++ b/dest/share/cons/monokai @@ -0,0 +1,59 @@ +# SPDX-FileCopyrightText: 2018 securisec +# SPDX-License-Identifier: LGPL-3.0-only + +ec b0x00 rgb:555 +ec b0x7f rgb:fff +ec b0xff rgb:eee +ec other rgb:888 +ec bin rgb:FFE792 +ec btext rgb:a398e5 +ec ucall rgb:f1c40f +ec call rgb:f1c40f +ec ujmp rgb:A6df2E +ec cjmp rgb:A6df2E +ec jmp rgb:A6df2E +ec cmp rgb:ef8d1a +ec comment rgb:66d9ef +ec usrcmt rgb:f92672 +ec ret rgb:d66 +ec num rgb:a398e5 +ec fline rgb:2bc +ec flow rgb:A6df2E +ec flow2 rgb:ddd +ec fname rgb:66d9ef +ec label rgb:66d9ef +ec math rgb:ddd +ec mov rgb:ddd +ec nop rgb:FFE792 +ec offset rgb:f92672 +ec prompt rgb:ef8d1a +ec pop rgb:ef8d1a +ec push rgb:ef8d1a +ec reg rgb:fff +ec args rgb:2bc +ec help rgb:ef8d1a +ec input rgb:888 +ec trap rgb:d66 +ec swi rgb:d66 +ec creg rgb:df7 +ec flag rgb:ef8d1a +ec linehl rgb:008 +ec ai.read rgb:66d +ec ai.write rgb:d66 +ec ai.exec rgb:6d6 +ec ai.ascii rgb:a398e5 +ec graph.box rgb:66d9ef +ec graph.box2 rgb:ef8d1a +ec graph.box3 rgb:66d9ef +ec graph.box4 rgb:66d9ef +ec graph.true rgb:A6df2E +ec graph.false rgb:f92672 +ec graph.ujump rgb:a398e5 +ec graph.current rgb:fff + +ec func_var cyan +ec func_var_type rgb:a398e5 +ec func_var_addr rgb:f92672 + +ec widget_bg rgb:f1c40f rgb:555 +ec widget_sel white rgb:f92672 diff --git a/dest/share/cons/nord b/dest/share/cons/nord new file mode 100644 index 00000000000..87972ef750b --- /dev/null +++ b/dest/share/cons/nord @@ -0,0 +1,63 @@ +# SPDX-FileCopyrightText: 2022 Anton Kochkov +# SPDX-License-Identifier: LGPL-3.0-only + +ec b0x00 rgb:6c768a +ec b0x7f rgb:81a1c1 +ec b0xff rgb:aba2a2 +ec bin rgb:eceff4 +ec btext rgb:ecefd4 +ec ucall rgb:bf604a +ec call rgb:bf616a +ec ujmp rgb:88c0df +ec cjmp rgb:88d0f0 +ec jmp rgb:88c0d0 +ec cmp rgb:5e81ac +ec comment rgb:b48ead +ec usrcmt rgb:a1a1c1 +ec ret rgb:81a1c1 +ec fline rgb:d8dee9 +ec flow rgb:88d0e0 +ec flow2 rgb:888 +ec fname rgb:8fbcbb +ec label rgb:ebcb8b +ec math rgb:d8dee9 +ec mov rgb:eceff4 +ec nop rgb:4c566a +ec num rgb:a3be97 +ec offset rgb:6c767a +ec other rgb:91b1d0 +ec pop rgb:e5e9f0 +ec prompt rgb:81a1c1 +ec push rgb:e5e9f0 +ec reg rgb:68e0e2 +ec args rgb:88d0f2 +ec help rgb:ebcb8c +ec input rgb:eeb366 +ec trap rgb:b47ead +ec swi rgb:b47ead +ec creg rgb:ed9366 +ec flag rgb:b3ceac +ec linehl rgb:004 + +ec graph.box rgb:d8dee9 +ec graph.box2 rgb:bf614a +ec graph.box3 rgb:4c566a +ec graph.box4 rgb:4c566a +ec graph.true rgb:a3be8c +ec graph.false rgb:bf616a +ec graph.ujump rgb:88c0df +ec graph.current rgb:81a1c1 +ec graph.traced rgb:93ae80 + +ec func_var rgb:d08770 +ec func_var_type rgb:ebcb8b +ec func_var_addr rgb:d8dee9 + +ec ai.read rgb:a97e9d +ec ai.write rgb:c07e9d +ec ai.exec rgb:e08ead +ec ai.seq rgb:f98ead +ec ai.ascii rgb:f9ceed + +ec widget_bg rgb:4cf rgb:344 +ec widget_sel black rgb:4cf diff --git a/dest/share/cons/ogray b/dest/share/cons/ogray new file mode 100644 index 00000000000..4288694b046 --- /dev/null +++ b/dest/share/cons/ogray @@ -0,0 +1,66 @@ +# SPDX-FileCopyrightText: 2014 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +ec b0x00 rgb:ccc +ec b0x7f rgb:777 +ec b0xff rgb:333 +ec args rgb:fff +ec bin rgb:fff +ec btext rgb:fff +ec call rgb:f72 rgb:333 +ec cjmp rgb:f72 +ec cmp rgb:aaa +ec comment rgb:f72 +ec usrcmt rgb:000 rgb:f72 +ec reg rgb:fff +ec creg rgb:f72 +ec flag rgb:f72 +ec fline rgb:aaa +ec flow rgb:f72 +ec flow2 rgb:fff +ec fname rgb:f72 +ec help rgb:f72 +ec input rgb:f72 +ec jmp rgb:f72 +ec label rgb:f72 +ec math rgb:777 +ec mov rgb:ddd +ec nop rgb:333 +ec num rgb:f72 +ec offset rgb:555 +ec other rgb:999 +ec pop rgb:999 +ec prompt rgb:f72 +ec push rgb:ddd +ec ret rgb:777 +ec swi rgb:f72 +ec trap rgb:f72 +ec ucall rgb:f72 rgb:333 +ec ujmp rgb:f72 +ec graph.true rgb:f72 +ec graph.false rgb:777 +ec graph.ujump rgb:ddd +ec graph.current rgb:f72 +ec graph.traced rgb:f00 +ec graph.box rgb:fff +ec graph.box2 rgb:f72 +ec graph.box3 rgb:000 +ec graph.box4 rgb:000 +ec gui.cflow rgb:f72 +ec gui.dataoffset rgb:f72 +ec crypto rgb:f72 +ec floc rgb:777 +ec linehl rgb:111 + +ec func_var rgb:f72 +ec func_var_type rgb:777 +ec func_var_addr rgb:555 + +ec ai.read rgb:eee +ec ai.write rgb:ddd +ec ai.exec rgb:fff +ec ai.seq rgb:f72 +ec ai.ascii rgb:f72 + +ec widget_bg rgb:f72 rgb:333 +ec widget_sel rgb:333 rgb:f72 diff --git a/dest/share/cons/onedark b/dest/share/cons/onedark new file mode 100644 index 00000000000..d8e1ed26db9 --- /dev/null +++ b/dest/share/cons/onedark @@ -0,0 +1,70 @@ +# SPDX-FileCopyrightText: 2018 d4em0n +# SPDX-License-Identifier: LGPL-3.0-only + +#Inspired by onedark.vim +# e scr.color = 3 // to enable 16m color +ec func_var_type white +ec func_var rgb:61afef +ec func_var_addr rgb:4b5263 +ec b0x00 rgb:c678dd +ec b0xff rgb:be5046 +ec prompt rgb:d19a66 +ec fname rgb:56b6c2 +ec label rgb:0f3 +ec math rgb:660 +ec bin rgb:e5c07b +ec btext rgb:e5c07b +ec call rgb:e06c75 +ec ucall rgb:e06c75 +ec jmp rgb:c678dd +ec cjmp rgb:c678dd +ec ujmp rgb:c678dd +ec offset rgb:366 +ec comment rgb:56b6c2 +ec usrcmt rgb:ff0 +ec push rgb:61afef +ec pop rgb:61afef +ec cmp rgb:060 +ec nop rgb:abb2bf +ec num rgb:be5046 +ec reg rgb:e5c07b +ec fline rgb:fc0 +ec flow rgb:98c379 +ec flow2 rgb:98c379 +ec args rgb:d19a66 +ec floc rgb:fc0 +ec flag rgb:56b6c2 +ec label rgb:56b6c2 +ec help rgb:98c379 +ec input white +ec invalid rgb:e06c75 +ec crypto rgb:0000ff +ec ret rgb:be5046 +ec trap rgb:e06c75 +ec swi rgb:e06c75 +ec mov rgb:98c379 +ec creg rgb:e5c07b +ec ai.read rgb:98c379 +ec ai.write rgb:61afef +ec ai.exec rgb:e06c75 +ec ai.seq rgb:ff00ff +ec ai.ascii rgb:ffff00 +ec gui.cflow rgb:d19a66 +ec gui.dataoffset rgb:d19a66 +ec gui.background black +ec gui.alt_background white +ec gui.border black +ec linehl rgb:61afef +ec graph.box rgb:d19a66 +ec graph.box2 rgb:61afef +ec graph.box3 rgb:c678dd +ec graph.box4 rgb:000000 +ec graph.true rgb:98c379 +ec graph.false rgb:e06c75 +ec graph.ujump rgb:61afef +ec graph.current rgb:61afef +ec graph.traced rgb:d19a66 +ec linehl rgb:5c6370 + +ec widget_bg rgb:ec7 rgb:366 +ec widget_sel black rgb:98c379 diff --git a/dest/share/cons/pink b/dest/share/cons/pink new file mode 100644 index 00000000000..b138b4e7baf --- /dev/null +++ b/dest/share/cons/pink @@ -0,0 +1,67 @@ +# SPDX-FileCopyrightText: 2013 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +ec comment rgb:72d +ec help rgb:f5d +ec fname rgb:f5d +ec fline rgb:afd +ec flag rgb:f5d +ec label rgb:f5d +ec flow rgb:f5d +ec flow2 rgb:72d +ec prompt rgb:f5d +ec offset rgb:72d +ec input rgb:f5d +ec other rgb:d5a +ec b0x00 rgb:a27 +ec b0x7f rgb:55d +ec b0xff rgb:f5d +ec mov rgb:fff +ec bin rgb:fff +ec math rgb:fff +ec btext rgb:72d +ec push rgb:75a +ec pop rgb:75a +ec jmp rgb:f5d +ec cjmp rgb:f5d +ec ujmp rgb:f5d +ec usrcmt rgb:f5d rgb:502 +ec call rgb:000 rgb:faf +ec ucall rgb:000 rgb:faf +ec nop rgb:fa5 +ec ret rgb:ffa +ec trap rgb:a22 +ec swi rgb:255 +ec cmp rgb:a7f +ec reg rgb:f5d +ec creg rgb:f5d +ec num rgb:72d +ec crypto rgb:75d +ec linehl rgb:fdf +ec graph.true rgb:f5d +ec graph.false rgb:715 +ec graph.ujump rgb:f5d +ec graph.current rgb:f5d +ec graph.traced rgb:a7f +ec graph.box rgb:f5d +ec graph.box2 rgb:f5d +ec graph.box3 rgb:f5d +ec graph.box4 rgb:f5d +ec gui.cflow rgb:f5d +ec gui.dataoffset rgb:f5d +ec gui.background black +## gui.alt_background +## gui.border + +ec func_var rgb:72d +ec func_var_type blue +ec func_var_addr rgb:72d + +ec ai.read rgb:f6e +ec ai.write rgb:f5d +ec ai.exec rgb:75a +ec ai.seq rgb:72d +ec ai.ascii rgb:72d + +ec widget_bg rgb:72d rgb:222 +ec widget_sel white rgb:f5d diff --git a/dest/share/cons/rasta b/dest/share/cons/rasta new file mode 100644 index 00000000000..3a54c3825e8 --- /dev/null +++ b/dest/share/cons/rasta @@ -0,0 +1,68 @@ +# SPDX-FileCopyrightText: 2014 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +ec comment green +ec usrcmt yellow +ec fname yellow +ec fline green +ec flag green +ec label yellow +ec flow green +ec flow2 yellow +ec floc green +ec prompt green +ec offset yellow +ec input green +ec other green +ec b0x00 yellow +ec b0x7f green +ec b0xff red +ec math yellow +ec bin green +ec btext red +ec push yellow +ec pop green +ec jmp red +ec cjmp red +ec ujmp red +ec call red +ec ucall red +ec nop red +ec ret yellow +ec trap green +ec swi red +ec cmp yellow +ec reg green +ec num red +ec mov yellow +ec crypto yellow +ec args green +ec help yellow +ec input green +ec trap red +ec swi red +ec creg green +ec flag yellow +ec linehl rgb:008 +ec graph.box yellow +ec graph.box2 green +ec graph.box3 red +ec graph.box4 red +ec graph.true green +ec graph.false red +ec graph.ujump green +ec graph.current green +ec graph.traced yellow + +ec func_var green +ec func_var_type red +ec func_var_addr yellow + +ec ai.read green +ec ai.write green +ec ai.exec yellow +ec ai.seq red +ec ai.ascii red + +ec widget_bg yellow black +ec widget_sel black green diff --git a/dest/share/cons/sepia b/dest/share/cons/sepia new file mode 100644 index 00000000000..d126bc31af1 --- /dev/null +++ b/dest/share/cons/sepia @@ -0,0 +1,81 @@ +# SPDX-FileCopyrightText: 2018 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +# requires e scr.color=3 + +ec b0x00 rgb:431 +ec b0x7f rgb:fd9 +ec b0xff rgb:960 +ec bin rgb:fec +ec crypto rgb:0000ff +ec other rgb:ba6 +ec btext rgb:fec +ec ucall rgb:ffffff +ec call rgb:ffffff +ec ujmp rgb:fec +ec cjmp rgb:fec +ec jmp rgb:fec +ec cmp rgb:ca6 +ec comment rgb:fd9 +ec usrcmt rgb:fff +ec ret rgb:ab7 +ec fline rgb:ca6 +ec floc rgb:00ffff +ec flow rgb:ca6 +ec flow2 rgb:fec +ec fname rgb:bb7 +ec label rgb:788 +ec math rgb:db7 +ec invalid rgb:c64 +ec mov rgb:db7 +ec nop rgb:788 +ec num rgb:960 +ec offset rgb:960 +ec pop rgb:bb7 +ec prompt rgb:960 +ec push rgb:db7 +ec reg rgb:ca6 +ec args rgb:bb7 +ec help rgb:ab7 +ec input rgb:ca6 +ec trap rgb:431 +ec swi rgb:bb7 +ec creg rgb:960 +ec flag rgb:ffd +ec wordhl rgb:ff0000 +ec linehl rgb:210 +ec meta rgb:767676 +ec graph.true rgb:fd9 +ec graph.false rgb:431 +ec graph.ujump rgb:fd9 +ec graph.current rgb:0000ff +ec graph.traced rgb:0000ff +ec graph.box rgb:431 +ec graph.box2 rgb:ca6 +ec graph.box3 rgb:ca6 +ec graph.box4 rgb:ca6 +ec gui.cflow rgb:ffff00 +ec gui.dataoffset rgb:ffff00 +ec gui.alt_background rgb:ffffff +ec gui.background rgb:000000 +ec gui.border rgb:000000 + +ec func_var rgb:fd9 +ec func_var_type rgb:850 +ec func_var_addr rgb:960 + +ec ai.read rgb:cb7 +ec ai.write rgb:ca6 +ec ai.exec rgb:db7 +ec ai.seq rgb:960 +ec ai.ascii rgb:fec + +ec widget_bg rgb:db7 rgb:000000 +ec widget_sel rgb:000000 rgb:fec + +# Linux default colors (need to be sepiaized) + +ec diff.unknown rgb:881798 +ec diff.new rgb:c50f1f +ec diff.match rgb:767676 +ec diff.unmatch rgb:c19c00 diff --git a/dest/share/cons/smyck b/dest/share/cons/smyck new file mode 100644 index 00000000000..b12ec7f4164 --- /dev/null +++ b/dest/share/cons/smyck @@ -0,0 +1,61 @@ +# SPDX-FileCopyrightText: 2014 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +# ref: http://color.smyck.org/ +ec b0x00 rgb:222 +ec b0x7f rgb:fff +ec b0xff rgb:eee +ec other rgb:888 +ec bin rgb:888 +ec btext white +ec ucall rgb:9f4 +ec call rgb:9f4 +ec ujmp rgb:9c4 +ec cjmp rgb:9c4 +ec jmp rgb:9c4 +ec cmp rgb:888 +ec comment rgb:9df +ec usrcmt rgb:9f4 +ec ret rgb:d66 +ec num rgb:bb5 +ec fline rgb:2bc +ec flow rgb:888 +ec flow2 rgb:ddd +ec fname rgb:9df +ec label rgb:9df +ec math rgb:ddd +ec mov rgb:ddd +ec nop rgb:444 +ec offset rgb:bb5 +ec prompt rgb:bb5 +ec pop rgb:fd6 +ec push rgb:fd6 +ec reg rgb:fff +ec args rgb:2bc +ec help rgb:fd6 +ec input rgb:888 +ec trap rgb:d66 +ec swi rgb:d66 +ec creg rgb:df7 +ec flag rgb:9df +ec linehl rgb:004 +ec ai.read rgb:66d +ec ai.write rgb:d66 +ec ai.exec rgb:6d6 +ec ai.seq rgb:fd6 +ec ai.ascii white +ec graph.box rgb:9df +ec graph.box2 rgb:9df +ec graph.box3 rgb:9df +ec graph.box4 rgb:9df +ec graph.true rgb:9c4 +ec graph.false rgb:d66 +ec graph.ujump rgb:9c4 +ec graph.current rgb:fff + +ec func_var rgb:9df +ec func_var_type rgb:fd6 +ec func_var_addr rgb:bb5 + +ec widget_bg rgb:bb5 rgb:222 +ec widget_sel black rgb:9c4 diff --git a/dest/share/cons/solarized b/dest/share/cons/solarized new file mode 100644 index 00000000000..ad5f92fbc56 --- /dev/null +++ b/dest/share/cons/solarized @@ -0,0 +1,66 @@ +# SPDX-FileCopyrightText: 2014 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +ec b0x00 rgb:033 +ec b0x7f rgb:033 +ec b0xff rgb:577 +ec bin rgb:688 +ec btext rgb:899 +ec ucall rgb:890 +ec call rgb:890 #b80 +ec ujmp rgb:890 +ec cjmp rgb:890 # b80 #ee8 +ec jmp rgb:e37 +ec cmp rgb:c41 # ffe +ec comment rgb:28d +ec usrcmt rgb:890 +ec ret rgb:899 +ec fline rgb:b80 +ec flow rgb:3a9 +ec flow2 rgb:577 +ec fname rgb:d33 +ec label rgb:77c +ec math rgb:28d +ec mov rgb:3a9 +ec nop rgb:577 +ec num rgb:eee +ec offset rgb:9aa +ec other rgb:577 +ec pop rgb:688 +ec prompt rgb:c41 +ec push rgb:e37 +ec reg rgb:de8 +ec args rgb:de8 +ec help rgb:e37 +ec input rgb:c41 +ec trap rgb:f00 +ec swi rgb:f00 +ec creg rgb:de8 +ec flag rgb:c41 +ec linehl rgb:004 + +ec graph.box rgb:033 +ec graph.box2 rgb:de8 +ec graph.box3 rgb:033 +ec graph.box4 rgb:033 +ec graph.true rgb:890 +ec graph.false rgb:c41 +ec graph.ujump rgb:899 +ec graph.current rgb:f00 +ec graph.traced red + +ec func_var rgb:28d +ec func_var_type rgb:cc8 +ec func_var_addr rgb:9aa + +ec ai.read rgb:39e +ec ai.write rgb:577 +ec ai.exec rgb:ab4 +ec ai.seq rgb:899 +ec ai.ascii rgb:899 + +# background of the terminal must be 134 o 033 +# xterm -fn 10x20 -bg rgb:00/30/30 -fg rgb:e0/e0/e0 -e "rizin -c 'eco solarized' /bin/ls" + +ec widget_bg rgb:bb5 rgb:033 +ec widget_sel white rgb:c41 diff --git a/dest/share/cons/tango b/dest/share/cons/tango new file mode 100644 index 00000000000..b5548c95e02 --- /dev/null +++ b/dest/share/cons/tango @@ -0,0 +1,81 @@ +# SPDX-FileCopyrightText: 2014 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +# background of the terminal must be 134 o 033 +# xterm -fn 10x20 -bg rgb:20/20/20 -fg rgb:d0/d0/d0 +# ref: https://github.com/eugeneching/ida-consonance/blob/master/ida-consonance.clr + +# LIGHT MEDIUM DARK +# Butter fe5 ed0 ca0 +# Orange fa3 f70 c50 +# Chocolate eb6 c71 950 +# Chameleon 8e3 7d1 590 +# Sky Blue 79c 36a 248 +# Plum a7a 757 536 +# Scarlet Red e22 c00 a00 +# Aluminium eee ddd bbb +# DarkAluminium 888 555 333 + +# DARK THEME + +ec b0x00 rgb:757 +ec b0x7f rgb:c50 +ec b0xff rgb:950 +ec btext rgb:ca0 + +ec bin rgb:bbb +ec ucall rgb:7d1 +ec call rgb:7d1 +ec ujmp rgb:370 +ec cjmp rgb:370 +ec jmp rgb:370 +ec cmp rgb:bbb +ec comment rgb:370 +ec usrcmt rgb:7d1 +ec ret rgb:248 +ec fline rgb:950 +ec flow rgb:248 +ec flow2 rgb:248 +ec fname rgb:ca0 +ec label rgb:c50 +ec math rgb:bbb +ec mov rgb:bbb +ec nop rgb:333 +ec num rgb:ca0 +ec offset rgb:bbb +ec other rgb:950 +ec pop rgb:757 +ec prompt rgb:950 +ec push rgb:757 +ec reg rgb:c50 +ec args rgb:ca0 +ec help rgb:ddd +ec input rgb:ca0 +ec trap rgb:a00 +ec swi rgb:950 +ec creg rgb:590 +ec flag rgb:950 +ec linehl rgb:004 + +ec graph.true rgb:370 +ec graph.false rgb:a00 +ec graph.ujump rgb:bbb +ec graph.current rgb:7d1 +ec graph.traced rgb:f00 +ec graph.box rgb:950 +ec graph.box2 rgb:7d1 +ec graph.box3 rgb:950 +ec graph.box4 rgb:950 + +ec func_var rgb:370 +ec func_var_type rgb:a41 +ec func_var_addr rgb:aaa + +ec ai.read rgb:a81 +ec ai.write rgb:a41 +ec ai.exec rgb:c50 +ec ai.seq rgb:ca0 +ec ai.ascii rgb:ca0 + +ec widget_bg rgb:bb5 rgb:030 +ec widget_sel black rgb:840 diff --git a/dest/share/cons/twilight b/dest/share/cons/twilight new file mode 100644 index 00000000000..973963593c1 --- /dev/null +++ b/dest/share/cons/twilight @@ -0,0 +1,67 @@ +# SPDX-FileCopyrightText: 2014 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +# background of the terminal must be 134 o 033 +# xterm -fn 10x20 -bg rgb:14/14/14 -fg rgb:fe/ff/d3 +# ref: https://github.com/eugeneching/ida-consonance/blob/master/ida-consonance.clr + +ec b0x00 rgb:446 +ec b0x7f rgb:c64 +ec b0xff rgb:c64 +ec bin rgb:ffd +ec other rgb:aaa +ec btext rgb:bb7 +ec ucall rgb:9b7 +ec call rgb:9b7 +ec ujmp rgb:788 +ec cjmp rgb:788 +ec jmp rgb:788 +ec cmp rgb:ffd +ec comment rgb:c64 +ec usrcmt rgb:9b7 +ec ret rgb:ab7 +ec fline rgb:ca6 +ec flow rgb:446 +ec flow2 rgb:446 +ec fname rgb:bb7 +ec label rgb:788 +ec math rgb:ffd +ec invalid rgb:c64 +ec mov rgb:ffd +ec nop rgb:445 +ec num rgb:ffd +ec offset rgb:788 +ec pop rgb:bb7 +ec prompt rgb:788 +ec push rgb:ffd +ec reg rgb:ca6 +ec args rgb:bb7 +ec help rgb:ab7 +ec input rgb:ca6 +ec trap rgb:445 +ec swi rgb:bb7 +ec creg rgb:788 +ec flag rgb:ffd +ec linehl rgb:004 +ec graph.true rgb:9b7 +ec graph.false rgb:b97 +ec graph.ujump rgb:64c +ec graph.current blue +ec graph.traced blue +ec graph.box rgb:9b7 +ec graph.box2 rgb:b97 +ec graph.box3 rgb:b97 +ec graph.box4 rgb:b97 + +ec func_var rgb:c64 +ec func_var_type rgb:aa6 +ec func_var_addr rgb:788 + +ec ai.read rgb:db7 +ec ai.write rgb:ca6 +ec ai.exec rgb:ffd +ec ai.seq rgb:bb7 +ec ai.ascii rgb:bb7 + +ec widget_bg rgb:ffd rgb:344 +ec widget_sel black rgb:ca6 diff --git a/dest/share/cons/white b/dest/share/cons/white new file mode 100644 index 00000000000..1e58611cf07 --- /dev/null +++ b/dest/share/cons/white @@ -0,0 +1,62 @@ +# SPDX-FileCopyrightText: 2013 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +ec label rgb:c60 +ec help blue +ec math blue +ec bin blue +ec crypto magenta +ec other blue +ec push black +ec pop black +ec cmp magenta +ec nop black +ec jmp blue +ec cjmp magenta +ec ujmp green +ec call magenta white bold +ec ucall magenta white bold +ec input black +ec fline green +ec prompt black +ec flag blue +ec fname blue +ec comment magenta +ec usrcmt green +ec reg blue +ec creg blue +ec trap red +ec swi green +ec num blue +ec b0x7f gray +ec b0xff red +ec b0x00 rgb:777 +ec btext black +ec offset black +ec flow blue +ec flow2 green +ec mov black +ec invalid red +ec linehl rgb:ff0 +ec graph.box blue +ec graph.box2 green +ec graph.box3 red +ec graph.box4 blue +ec graph.true green +ec graph.false red +ec graph.ujump blue +ec graph.current rgb:0ff +ec graph.traced red + +ec func_var magenta +ec func_var_type blue +ec func_var_addr magenta + +ec ai.read magenta +ec ai.write magenta +ec ai.exec blue +ec ai.seq black +ec ai.ascii black + +ec widget_bg blue white +ec widget_sel black yellow diff --git a/dest/share/cons/white2 b/dest/share/cons/white2 new file mode 100644 index 00000000000..41ae34c124d --- /dev/null +++ b/dest/share/cons/white2 @@ -0,0 +1,58 @@ +# SPDX-FileCopyrightText: 2018 securisec +# SPDX-License-Identifier: LGPL-3.0-only + +ec ai.exec rgb:6d6 +ec ai.read rgb:66d +ec ai.write rgb:d66 +ec args rgb:2bc +ec b0x00 rgb:878585 # 00 bytes +ec b0x7f rgb:fff +ec b0xff rgb:abb0b6 # ff bytes +ec bin rgb:4F1900 0 bold # operations like xor +ec btext rgb:66737f # text section opcode? first byte of opcode +ec call rgb:A63A00 0 bold # call instructions +ec cjmp rgb:376B4C 0 bold underline # je, jg, etc +ec cmp rgb:F92672 0 bold # cmp instructions +ec comment rgb:001296 0 italic # rizin renerated comments +ec creg rgb:025F49 rgb:BFFFCB # modified registries +ec flag rgb:912D3A 0 bold # flags. usually apprears above the current seek +ec fline rgb:8D0004 # function line. the boundary of a function +ec flow rgb:376B4C # lines that show jump destinations +ec flow2 rgb:ddd +ec fname rgb:8D0004 0 bold italic # function name +ec graph.box rgb:007D96 # unselected boxes in visual graph mode +ec graph.box2 rgb:D100A7 # currently selected box in visual graph mode +ec graph.box3 rgb:66d9ef +ec graph.box4 rgb:66d9ef +ec graph.current rgb:fff +ec graph.false rgb:990000 # false line on visual graph mode +ec graph.true rgb:376B4C # true line on visual graph mode +ec graph.ujump rgb:007D96 # lines in graph that does not have true or false +ec help rgb:2F6F9F 0 italic # color of help explanation text +ec input rgb:888 +ec jmp rgb:376B4C 0 bold underline # jmp instructions +ec label rgb:66d9ef +ec linehl rgb:42505e # highlight color when using asm.highlight +ec math rgb:761B48 0 bold # math instructions like sub, add +ec mov black +ec nop rgb:a37acc # nop instructions +ec num rgb:761B48 # numbers +ec offset rgb:2F6F9F # offset in visual mode +ec other rgb:4D4D4D +ec pop rgb:ff7733 # pop instructions +ec prompt rgb:2F6F9F 0 bold # color for main rizin prompt +ec push rgb:ff7733 # push instructions +ec reg rgb:400080 # register names +ec ret rgb:F92672 0 bold # ret opcode +ec swi rgb:d66 +ec trap rgb:d66 +ec ucall rgb:A63A00 0 bold +ec ujmp rgb:376B4C 0 bold underline +ec usrcmt rgb:007D96 0 bold # user comment + +ec func_var rgb:400080 # var name in function +ec func_var_type rgb:305F65 0 italic # function variable +ec func_var_addr magenta + +ec widget_bg rgb:2f6f9f white +ec widget_sel white rgb:f73 bold diff --git a/dest/share/cons/xvilka b/dest/share/cons/xvilka new file mode 100644 index 00000000000..67952be764a --- /dev/null +++ b/dest/share/cons/xvilka @@ -0,0 +1,70 @@ +# SPDX-FileCopyrightText: 2013 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +ec prompt yellow +ec fname rgb:0cf +ec label rgb:0f3 +ec math rgb:660 +ec bin rgb:f90 +ec call red +ec ucall red +ec jmp rgb:03f +ec cjmp rgb:33c +ec ujmp rgb:330 +ec offset rgb:366 +ec comment rgb:0cf +ec usrcmt rgb:ff0 rgb:06f +ec push rgb:0c0 +ec pop rgb:0c0 +ec cmp rgb:060 +ec nop rgb:777 +ec b0x00 rgb:444 +ec b0x7f rgb:555 +ec b0xff rgb:666 +ec btext rgb:777 +ec other rgb:bbb +ec num rgb:f03 +ec reg rgb:6f0 +ec fline rgb:fc0 +ec flow rgb:0f0 +ec flow2 rgb:0f0 +ec args yellow +ec floc rgb:fc0 +ec flag rgb:0cf +ec label rgb:0cf +ec help green +ec input white +ec invalid red +ec crypto rgb:0000ff +ec ret rgb:ff0000 +ec trap red +ec swi red +ec mov white +ec creg rgb:6f0 +ec linehl rgb:004 +ec ai.read green +ec ai.write blue +ec ai.exec red +ec ai.seq rgb:ff00ff +ec ai.ascii rgb:ffff00 +ec graph.box yellow +ec graph.box2 blue +ec graph.box3 magenta +ec graph.box4 rgb:000000 +ec graph.true green +ec graph.false red +ec graph.ujump blue +ec graph.current blue +ec graph.traced yellow +ec gui.cflow yellow +ec gui.dataoffset yellow +ec gui.background black +ec gui.alt_background white +ec gui.border black + +ec func_var rgb:0cf +ec func_var_type rgb:0c0 +ec func_var_addr rgb:366 + +ec widget_bg green rgb:255 +ec widget_sel white rgb:336 bold diff --git a/dest/share/cons/zenburn b/dest/share/cons/zenburn new file mode 100644 index 00000000000..4370ec231a6 --- /dev/null +++ b/dest/share/cons/zenburn @@ -0,0 +1,67 @@ +# SPDX-FileCopyrightText: 2014 pancake +# SPDX-License-Identifier: LGPL-3.0-only + +# background of the terminal must be 134 o 033 # xterm -fn 10x20 -bg rgb:20/20/20 -fg rgb:ff/ff/c7 +# ref: https://github.com/eugeneching/ida-consonance/blob/master/ida-consonance.clr + +ec b0x00 rgb:8a8 +ec b0x7f rgb:aaa +ec b0xff rgb:8a8 +ec bin rgb:fcb +ec other rgb:aaa +ec btext rgb:ddc +ec ucall rgb:d52 +ec call rgb:d52 +ec ujmp rgb:d52 +ec cjmp rgb:d52 +ec jmp rgb:d52 +ec cmp rgb:ff8 +ec comment rgb:7a7 +ec usrcmt rgb:d52 +ec ret rgb:ff8 +ec fline rgb:ddc +ec flow rgb:d50 +ec flow2 rgb:d50 +ec fname rgb:d50 +ec label rgb:d50 +ec math rgb:daa +ec invalid rgb:ff8 +ec mov rgb:cd9 +ec nop rgb:8a8 +ec num rgb:c88 +ec offset rgb:aaa +ec pop rgb:ffc +ec prompt rgb:d50 +ec push rgb:ffc +ec reg rgb:8dd +ec args rgb:7a7 +ec help rgb:ffc +ec input rgb:da8 +ec trap rgb:d22 +ec swi rgb:d22 +ec creg rgb:ccc +ec flag rgb:d50 +ec linehl rgb:004 + +ec graph.box rgb:aaa +ec graph.box2 rgb:d52 +ec graph.box3 rgb:aaa +ec graph.box4 rgb:aaa +ec graph.true rgb:aaa +ec graph.false rgb:d52 +ec graph.ujump rgb:aaa +ec graph.current blue +ec graph.traced red + +ec func_var rgb:7a7 +ec func_var_type rgb:eec +ec func_var_addr rgb:aaa + +ec ai.read rgb:f87 +ec ai.write rgb:c88 +ec ai.exec rgb:cd9 +ec ai.seq rgb:ddc +ec ai.ascii rgb:ddc + +ec widget_bg rgb:8dd rgb:333 +ec widget_sel white rgb:b52 bold diff --git a/dest/share/flag/tags.rz b/dest/share/flag/tags.rz new file mode 100644 index 00000000000..bd233e2aefc --- /dev/null +++ b/dest/share/flag/tags.rz @@ -0,0 +1,10 @@ +ft dylib dlopen dlsym dlclose mmap LoadLibrary GetProcAddress +ft alloc malloc free$ calloc kalloc realloc +ft time settimeofday gettimeofday time adjtime ctime timed date$ sleep Sleep usleep clock_nanosleep localtime asctime difftime gmtime mktime timelocal timegm tzfile tzset +ft env getenv putenv unsetenv setenv GetEnvironmentVariable SetEnvironmentVariable ExpandEnvironmentStrings +ft fs open$ close read$ write CloseHandle FindFirstFileW _wfopen _wstat ftruncate lseek _chsize GetFullPathName realpath RemoveDirectory DeleteFile CreateFile WriteFile UnmapViewOfFile CreateFileMapping MapViewOfFile readlink chmod fchmod chown stat fstat lstat fstatat lstat64 stat64 chflags fchflags lchflags +ft network socket connect bind$ listen accept sendto recvfrom gethostbyname htons ntohs +ft threads pthread_create pthread_mutex_init pthread_cond_init CreateThread TerminateThread WaitForSingleObject GetCurrentThreadId +ft process getpid getppid kill exit abort assert gethostid sethostid sysctl +ft stdout ^printf puts write +ft string strcat strcpy strncpy strlen strtok strstr strlcpy asprintf sprintf snprintf diff --git a/dest/share/format/elf32 b/dest/share/format/elf32 new file mode 100644 index 00000000000..5780890b9f6 --- /dev/null +++ b/dest/share/format/elf32 @@ -0,0 +1,5 @@ +pfo elf_enums +pfn elf_ident "[4]z[1]E[1]E[1]E.:: magic (elf_class)class (elf_data)data (elf_hdr_version)version" +pfn elf_header "?[2]E[2]E[4]ExxxxN2N2N2N2N2N2 (elf_ident)ident (elf_type)type (elf_machine)machine (elf_obj_version)version entry phoff shoff flags ehsize phentsize phnum shentsize shnum shstrndx" +pfn elf_phdr "[4]Exxxxx[4]Ex (elf_p_type)type offset vaddr paddr filesz memsz (elf_p_flags)flags align" +pfn elf_shdr "x[4]E[4]Exxxxxxx name (elf_s_type)type (elf_s_flags_32)flags addr offset size link info addralign entsize" diff --git a/dest/share/format/elf64 b/dest/share/format/elf64 new file mode 100644 index 00000000000..aca563c394f --- /dev/null +++ b/dest/share/format/elf64 @@ -0,0 +1,5 @@ +pfo elf_enums +pfn elf_ident "[4]z[1]E[1]E[1]E.:: magic (elf_class)class (elf_data)data (elf_hdr_version)version" +pfn elf_header "?[2]E[2]E[4]EqqqxN2N2N2N2N2N2 (elf_ident)ident (elf_type)type (elf_machine)machine (elf_obj_version)version entry phoff shoff flags ehsize phentsize phnum shentsize shnum shstrndx" +pfn elf_phdr "[4]E[4]Eqqqqqq (elf_p_type)type (elf_p_flags)flags offset vaddr paddr filesz memsz align" +pfn elf_shdr "x[4]E[8]Eqqqxxqq name (elf_s_type)type (elf_s_flags_64)flags addr offset size link info addralign entsize" diff --git a/dest/share/format/elf_enums b/dest/share/format/elf_enums new file mode 100644 index 00000000000..bd24164b44a --- /dev/null +++ b/dest/share/format/elf_enums @@ -0,0 +1,15 @@ +td "enum elf_type {ET_NONE=0, ET_REL=1, ET_EXEC=2, ET_DYN=3, ET_CORE=4, ET_LOOS=0xfe00, ET_HIOS=0xfeff, ET_LOPROC=0xff00, ET_HIPROC=0xffff};" +td "enum elf_machine {EM_NONE=0, EM_M32=1, EM_SPARC=2, EM_386=3, EM_68K=4, EM_88K=5, EM_IAMCU=6, EM_860=7, EM_MIPS=8, EM_S370=9, EM_MIPS_RS3_LE=10, EM_RS6000=11, EM_PARISC=15, EM_nCUBE=16, EM_VPP500=17, EM_SPARC32PLUS=18, EM_960=19, EM_PPC=20, EM_PPC64=21, EM_S390=22, EM_SPU=23, EM_V800=36, EM_FR20=37, EM_RH32=38, EM_RCE=39, EM_ARM=40, EM_ALPHA=41, EM_SH=42, EM_SPARCV9=43, EM_TRICORE=44, EM_ARC=45, EM_H8_300=46, EM_H8_300H=47, EM_H8S=48, EM_H8_500=49, EM_IA_64=50, EM_MIPS_X=51, EM_COLDFIRE=52, EM_68HC12=53, EM_MMA=54, EM_PCP=55, EM_NCPU=56, EM_NDR1=57, EM_STARCORE=58, EM_ME16=59, EM_ST100=60, EM_TINYJ=61, EM_X86_64=62, EM_PDSP=63, EM_PDP10=64, EM_PDP11=65, EM_FX66=66, EM_ST9PLUS=67, EM_ST7=68, EM_68HC16=69, EM_68HC11=70, EM_68HC08=71, EM_68HC05=72, EM_SVX=73, EM_ST19=74, EM_VAX=75, EM_CRIS=76, EM_JAVELIN=77, EM_FIREPATH=78, EM_ZSP=79, EM_MMIX=80, EM_HUANY=81, EM_PRISM=82, EM_AVR=83, EM_FR30=84, EM_D10V=85, EM_D30V=86, EM_V850=87, EM_M32R=88, EM_MN10300=89, EM_MN10200=90, EM_PJ=91, EM_OPENRISC=92, EM_ARC_COMPACT=93, EM_XTENSA=94, EM_VIDEOCORE=95, EM_TMM_GPP=96, EM_NS32K=97, EM_TPC=98, EM_SNP1K=99, EM_ST200=100, EM_IP2K=101, EM_MAX=102, EM_CR=103, EM_F2MC16=104, EM_MSP430=105, EM_BLACKFIN=106, EM_SE_C33=107, EM_SEP=108, EM_ARCA=109, EM_UNICORE=110, EM_EXCESS=111, EM_DXP=112, EM_ALTERA_NIOS2=113, EM_CRX=114, EM_XGATE=115, EM_C166=116, EM_M16C=117, EM_DSPIC30F=118, EM_CE=119, EM_M32C=120, EM_TSK3000=131, EM_RS08=132, EM_SHARC=133, EM_ECOG2=134, EM_SCORE7=135, EM_DSP24=136, EM_VIDEOCORE3=137, EM_LATTICEMICO32=138, EM_SE_C17=139, EM_TI_C6000=140, EM_TI_C2000=141, EM_TI_C5500=142, EM_TI_ARP32=143, EM_TI_PRU=144, EM_MMDSP_PLUS=160, EM_CYPRESS_M8C=161, EM_R32C=162, EM_TRIMEDIA=163, EM_HEXAGON=164, EM_8051=165, EM_STXP7X=166, EM_NDS32=167, EM_ECOG1X=168, EM_MAXQ30=169, EM_XIMO16=170, EM_MANIK=171, EM_CRAYNV2=172, EM_RX=173, EM_METAG=174, EM_MCST_ELBRUS=175, EM_ECOG16=176, EM_CR16=177, EM_ETPU=178, EM_SLE9X=179, EM_L10M=180, EM_K10M=181, EM_AARCH64=183, EM_AVR32=185, EM_STM8=186, EM_TILE64=187, EM_TILEPRO=188, EM_CUDA=190, EM_TILEGX=191, EM_CLOUDSHIELD=192, EM_COREA_1ST=193, EM_COREA_2ND=194, EM_ARC_COMPACT2=195, EM_OPEN8=196, EM_RL78=197, EM_VIDEOCORE5=198, EM_78KOR=199, EM_56800EX=200, EM_BA1=201, EM_BA2=202, EM_XCORE=203, EM_MCHP_PIC=204, EM_INTEL205=205, EM_INTEL206=206, EM_INTEL207=207, EM_INTEL208=208, EM_INTEL209=209, EM_KM32=210, EM_KMX32=211, EM_KMX16=212, EM_KMX8=213, EM_KVARC=214, EM_CDP=215, EM_COGE=216, EM_COOL=217, EM_NORC=218, EM_CSR_KALIMBA=219, EM_AMDGPU=224, EM_RISCV=243, EM_LANAI=244, EM_BPF=247, EM_CSKY=252, EM_KVX=256};" +td "enum elf_class {ELFCLASSNONE=0, ELFCLASS32=1, ELFCLASS64=2};" +td "enum elf_data {ELFDATANONE=0, ELFDATA2LSB=1, ELFDATA2MSB=2};" +td "enum elf_hdr_version {EV_NONE=0, EV_CURRENT=1};" +td "enum elf_osabi {ELFOSABI_NONE=0,ELFOSABI_HPUX=1, ELFOSABI_NETBSD=2,ELFOSABI_SOLARIS=6,ELFOSABI_AIX=7,ELFOSABI_IRIX=8,ELFOSABI_FREEBSD=9,ELFOSABI_TRU64=10,ELFOSABI_MODESTO=11,ELFOSABI_OPENBSD=12,ELFOSABI_OPENVMS=13,ELFOSABI_NSK=14,ELFOSABI_AROS=15};" +td "enum elf_obj_version {EV_NONE=0, EV_CURRENT=1};" +td "enum elf_p_type {PT_NULL=0,PT_LOAD=1,PT_DYNAMIC=2,PT_INTERP=3,PT_NOTE=4,PT_SHLIB=5,PT_PHDR=6,PT_LOOS=0x60000000,PT_HIOS=0x6fffffff,PT_LOPROC=0x70000000,PT_HIPROC=0x7fffffff};" +td "enum elf_p_flags {PF_None=0,PF_Exec=1,PF_Write=2,PF_Write_Exec=3,PF_Read=4,PF_Read_Exec=5,PF_Read_Write=6,PF_Read_Write_Exec=7};" +td "enum elf_s_name {SHN_UNDEF=0,SHN_LORESERVE=0xff00,SHN_LOPROC=0xff00,SHN_HIPROC=0xff1f,SHN_LOOS=0xff20,SHN_HIOS=0xff3f,SHN_ABS=0xfff1,SHN_COMMON=0xfff2,SHN_HIRESERVE=0xffff};" +td "enum elf_s_type {SHT_NULL=0,SHT_PROGBITS=1,SHT_SYMTAB=2,SHT_STRTAB=3,SHT_RELA=4,SHT_HASH=5,SHT_DYNAMIC=6,SHT_NOTE=7,SHT_NOBITS=8,SHT_REL=9,SHT_SHLIB=10,SHT_DYNSYM=11,SHT_LOOS=0x60000000,SHT_HIOS=0x6fffffff,SHT_LOPROC=0x70000000,SHT_HIPROC=0x7fffffff};" +td "enum elf_s_flags_32 {SF32_None=0,SF32_Exec=1,SF32_Alloc=2,SF32_Alloc_Exec=3,SF32_Write=4,SF32_Write_Exec=5,SF32_Write_Alloc=6,SF32_Write_Alloc_Exec=7};" +td "enum elf_s_flags_64 {SF64_None=0,SF64_Exec=1,SF64_Alloc=2,SF64_Alloc_Exec=3,SF64_Write=4,SF64_Write_Exec=5,SF64_Write_Alloc=6,SF64_Write_Alloc_Exec=7};" +td "enum elf_sym_info_bind_e {STB_LOCAL=0,STB_GLOBAL=1,STB_WEAK=2,STB_OS_1=10,STB_OS_2=11,STB_OS_3=12,STB_PROC_1=13,STB_PROC_2=14,STB_PROC_3=15};" +td "enum elf_sym_info_type_e {STT_NOTYPE=0,STT_OBJECT=1,STT_FUNC=2,STT_SECTION=3,STT_FILE=4,STT_OS_1=10,STT_OS_2=11,STT_OS_3=12,STT_PROC_1=13,STT_PROC_2=14,STT_PROC_3=15};" diff --git a/dest/share/format/mz b/dest/share/format/mz new file mode 100644 index 00000000000..4a48ff0046e --- /dev/null +++ b/dest/share/format/mz @@ -0,0 +1 @@ +pfn dos_header "[2]zwwwwwwwwwwwww[4]www[10]wx e_magic e_cblp e_cp e_crlc e_cparhdr e_minalloc e_maxalloc e_ss e_sp e_csum e_ip e_cs e_lfarlc e_ovno e_res e_oemid e_oeminfo e_res2 e_lfanew" diff --git a/dest/share/format/pe32 b/dest/share/format/pe32 new file mode 100644 index 00000000000..fb3062786ee --- /dev/null +++ b/dest/share/format/pe32 @@ -0,0 +1,5 @@ +pfo mz +pfn pe_nt_image_headers32 "[4]z?? signature (pe_image_file_header)fileHeader (pe_image_optional_header32)optionalHeader" +pfn pe_image_optional_header32 "[2]Ebbxxxxxxxxxwwwwwwxxxx[2]E[2]Bxxxxxx[16]? (pe_magic)magic majorLinkerVersion minorLinkerVersion sizeOfCode sizeOfInitializedData sizeOfUninitializedData addressOfEntryPoint baseOfCode baseOfData imageBase sectionAlignment fileAlignment majorOperatingSystemVersion minorOperatingSystemVersion majorImageVersion minorImageVersion majorSubsystemVersion minorSubsystemVersion win32VersionValue sizeOfImage sizeOfHeaders checkSum (pe_subsystem)subsystem (pe_dllcharacteristics)dllCharacteristics sizeOfStackReserve sizeOfStackCommit sizeOfHeapReserve sizeOfHeapCommit loaderFlags numberOfRvaAndSizes (pe_image_data_directory)dataDirectory" +pfn pe_image_file_header "[2]Ewtxxw[2]B (pe_machine)machine numberOfSections timeDateStamp pointerToSymbolTable numberOfSymbols sizeOfOptionalHeader (pe_characteristics)characteristics" +pfn pe_image_data_directory "xx virtualAddress size" diff --git a/dest/share/format/zip b/dest/share/format/zip new file mode 100644 index 00000000000..5f51e4c940e --- /dev/null +++ b/dest/share/format/zip @@ -0,0 +1,6 @@ +pfn zip_local_file_hdr "xwwwwwxxxww magic extract flags compression last_mod_time last_mod_date crc32 compressed_size uncompressed_size namlen extras" +pfn zip_data_desc "xxx crc32 compressed_size uncompressed_size" +pfn zip_central_directory_hdr "xwwwwwwxxxwwwwwxx magic encoder extract flags compression last_mod_time last_mod_date crc32 compressed_size uncompressed_size namlen extras comment diskstart filetype filemode offset" +pfn zip_end_central_dir "xwwwwxxw magic disk finaldisk entries finalentries rootsize rootseek comment" +pfn zip64_end_central_dir "xqwwxxqqqq magic size encoder extract disk finaldisk entries finalentries rootsize rootseek" +pfn zip64_end_central_dir_loc "xxqx magic disk rootseek disks" diff --git a/dest/share/fortunes/fortunes.fun b/dest/share/fortunes/fortunes.fun new file mode 100644 index 00000000000..813fae0bb9a --- /dev/null +++ b/dest/share/fortunes/fortunes.fun @@ -0,0 +1,231 @@ +No disassemble!!! +Deltify your life with rizin +What do you want to debug today? +I love the smell of bugs in the morning. +I'm in your source securing your bits. +rizin contributes to the One Byte Per Child foundation. +I did it for the pwnz. +If you send the program you are debugging to 15 friends in 143 minutes and then step three times on the same opcode you will get the name of the person who loves you. +To remove this message, put `dbxenv suppress_startup_message 7.5' in your .dbxrc +Heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it. +rizin is for lulzhats +Microloft Visual Rizin.NET 2008. Now OOXML Powered! +A C program is like a fast dance on a newly waxed dance floor by people carrying razors - Waldi Ravens +rizin is like windows 7 but even better. +rizin-built farm beats the facebook one. +Thank you for using rizin. Have a nice night! +Your rizin was built 20h ago. TOO OLD! +Use rizin! Lemons included! +rz-ax -s 20e296b20ae296b220e296b20a +Connection lost with the license server, your rizin session will terminate in 30 minutes. +This is amazing ... +I love gradients. +Wait a moment ... +No such file or directory. +Default scripting languages are NodeJS and Python. +-bash: rizin: command not found +Press any key to continue ... +Ilo ni li pona li pali e lipu. mi wile e ni: sina kama jo e musi +rizin for FideOS, now with extra potato +Your project name should contain an uppercase letter, 8 vowels, some numbers, and the first 5 characters of your private bitcoin key. +This computer has gone to sleep. +Welcome back, lazy human! +---8<--------------------8<------------------8<-----------------8<------ +I accidentally the kernel with rizin. +I endians swap. +This page intentionally left blank. +Here be dragons. +Trust no one, nor a zero. Both lie. +EIP = 0x41414141 +/dev/brain: No such file or directory. +Virtual machines are great, but you lose the ability to kick the hardware. +Charlie! We are here. +The door is everything ... +The door controls time and space. +The door can see into your soul. +I am Pentium of Borg. Division is futile. You will be approximated. +Don't look at the code. Don't look. +Warning, your trial license is about to expire. +Please register your copy of rizin today! Only £29.90! +Welcome to IDA 10.0. +It's not you, it's me. +This software comes with no brain included. Please use your own. +rm: /: Permission denied. +That's embarrassing. +Wow, my cat knows rizin hotkeys better than me! +PEBCAK ERROR: Documentation not found. +License server overloaded (ETOOMUCHCASH) +Error: cannot yank negative sleep +If you're not satisfied by our product, we'll be happy to refund you. +Already up-to-date. +How about a nice game of chess? +THE ONLY WINNING MOVE IS NOT TO PLAY. +SHALL WE PLAY A GAME? +I nodejs so hard my exams. What a nodejs! +Now featuring NoSQL! +One does not simply write documentation. +Everything up-to-date. +Sharing your latest session to Facebook ... +This should be documented, since it's not that obvious. +The Hard ROP Cafe +Wait a minute! I found a bug, self-fixing ... OK +Hold on, this should never happen! +Well this is embarrassing ... +THIS IS NOT FUNNY +♥ -- +Can you stand on your head? +May the segfault be with you. +I script in C, because I can. +Initial frame selected; you cannot go up. +Unk, unk, unk, unk +This is just an existentialist experiment. +Nothing to see here. Move along. +I accidentally rizind my filesystem today. +No fix, no sleep +You see it, you fix it! +V is for Visual +rizin-goverity: found corruption - please eliminate! +Stop debugging me! +THIS IS NOT A BUG +Do you want to print 333.5K chars? (y/N) +Now with more better English! +:(){ :|:& };: +All your base are belong to rizin +Ask not what rizin can do for you - ask what you can do for rizin +Try with ASAN, and be amazed +bash: rizin2: command not found +rizin loves everyone, even Java coders, but less than others +It's not a bug, it's a work in progress +Stop swearing! +Wrong argument +For a full list of commands see `strings /dev/urandom` +Good morning, pal *<:-) +Of course rizin runs FreeBSD +Reverser by Birth, rizin by Choice +rizin, what else? +This incident will be reported +command not found: calc.exe +See you at the defcon CTF +Don't waste your time +getdruid to get eclectic uid +Welcome to "IDA - the roguelike" +255 shades of (truecolor) grey +When you sold that exploit, what they really bought, was your silence. +Greetings, human. +nothing personal, just bitness +Too old to crash +Insert coin to continue ... +See you in shell +Mess with the best, die like the rest. +Log On. Hack In. Go Anywhere. Get Everything. +Did you know that rizin can decompile to assembly? +Are you still there? +Follow the white rabbit +Do not try to sploit that binary - that's impossible. Instead, only try to realize the truth: there is no binary. +Hello Mr. Anderson +What has been executed cannot be unexecuted +What about taking a break? Here, have this nice 0xCC. +rizin is meant to be read by machines. +Prove you are a robot to continue ... +This is fine. +Using rizin to generate intelligence ... +Taking the file and moving it somewhere else +It's the year of desktop on rizin +💺 +It's the year of rizin on the desktop +A git pull a day keeps the segfault away +Are you a wizard? +rizin is a great OS, but a terrible hex editor +THE CAKE IS A PIE +Have you seen the latest rizin TV spot? +scp ~/.idapro/ida.key rizin.org:/var/www/rizin.org/pub/losers/ +Too bad there is no gif support in rizin. Yet. +Almost 5am, maybe you should go to bed. +Jingle sploits, jingle sploits, ropchain all the way. +256 colors ought to be enough for anybody +Run a command with unspecified long sequence of 'a', a developer will be summoned and do the analysis for you. +rizin is WYSIWYF - what you see is what you fix +Your endian swaps +*(ut64*)buffer ought to be illegal +There is no F5 key in rizin yet +Beer in mind. +Don’t feed the bugs! (except delicious stacktraces)! +Feed the bugs! +You haxor! Me jane? +rizin talks to you. tries to make you feel well. +Now i'm like an evil engineer. MUAHAHAH +We only have bugs, features are an unintended side-effect +Quantum disassemble: it's there as long as you don't observe it +Ceci n'est pas une rzpipe +(gdb) ^D +((fn [f s n] (str (f f s n) "zin")) (fn [f s n] (pr s) (if (> n 0) (f f (str s "ri") (dec n)) s)) "" (/ 1.0 0)) +There's no way you could crash rizin. No. Way. +When in doubt, try 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; pd;' +.-. .- -.. .- .-. . ..--- +You crackme up! +Search returned no hits. Did you mean 'Misassemble'? +We fix bugs while you sleep. +You find bugs while we sleep. +Come here, we are relatively friendly +Don't wait for Travis +Your problems are solved in an abandoned branch somewhere +aaaa is experimental +We feed trolls +Mind the tab +You have been designated for disassembly +What is the most complex rizin command? q - then you have to deal with real life /o\ +If you're having fun using rizin, odds are that you're doing something wrong. +Don't trust what can't be compiled +Coffee time! +Can you you challenge a perfect immortal machine? +Congratulations! You got the segfault 1.000.000! Click [here] to win a prize! +Well, it looks like it's working. +git pull now +git checkout hamster +Noot noot +This is an unregistered copy. +10 reasons you want to bt on all threads - you will be shocked by number 3! +Place a cat on your keyboard while running rizin, you'll not believe what will happen next +Help subcommand will be eventually removed. +Carpe noctum. +Your mouse has moved. Rizin NT must be restarted for the change to take effect. Reboot now? [ OK ] +There is only one binary, and we are all just reversing pieces of it. +Order pizza for $12.48? [Y/n] +rizinOS rizinpad 0.1 SMP GENERIC rizin_64 GNU/rizinOS +AHHHHH!!!! ASSEMBLY CODE!!!!!! HOLD ME I'M SCARED!!!!!!!!!! +In Rizin we trust +We don't make mistakes... just happy little segfaults. +rizin is for the people +Use headphones for best experience. +Starting bitcoin miner in background... +Downloading and verifying the blockchain... +The anti-virus database has been updated. +The motion picture contained in this videodisc is protected under the copyright laws. +This software is sold for home use only and all other rights are expressly reversed by the copyleft owner. +Any commercial use or duplication of this copylefted material without prior licensing is forbidden. +OpenBSD might pledge rizin but rizin unveils OpenBSD. +Error: There's a missing space before the opening parenthesis '(' +This accessory is not supported by this version of rizin. +When can we have an official anime mascot for rizin? +Sorry, rizin has experienced an internal error. +Segmentation fault (core dumped) +Use rz-bin to discover the real TRUTH +==1337== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) +**** COMMODORE 64 RIZIN V2 **** 64K RAM SYSTEM 38911 DISASM BYTES FREE READY. +Most likely your core dump fell into a blackhole, can't see it. +Long time no C +Come to C me! +Unable to locate package gdb +You C it, you fix it! +How good is your C? +You will soon have an out of memory experience. +This binary no good. Try another. +BSOD! +Mind the trap. +For a full documentation see `rizin -qc iz /lib/librz_core.so` +99 bugs, take one down pass it around. 100 bugs... +Now 8-bit clean with better ASCII! +Please insert disc 2 and press any key to continue... +You aren't losing functionality, you are losing the illusion that you ever had anything reliable. -- Darren J. Moffat, OpenSolaris developer +DOOM all the things! +Rizin is the vegan pineapple pizza of reverse engineering tools. diff --git a/dest/share/fortunes/fortunes.tips b/dest/share/fortunes/fortunes.tips new file mode 100644 index 00000000000..14b9650ced0 --- /dev/null +++ b/dest/share/fortunes/fortunes.tips @@ -0,0 +1,86 @@ +Tweak the disassembly output with `e asm.` +You can add commands into your ~/.rizinrc to customize your experience with Rizin +In visual mode press 'c' to toggle the cursor mode. Use tab to navigate +You can mark an offset in visual mode with the cursor and the ',' key. Later press '.' to go back +You can debug a program from the graph view ('ag') using standard rizin commands +Use the '[' and ']' keys in visual mode to adjust the screen width +Select your architecture with: 'e asm.arch=' or rizin -a from the shell +Move between your search hits in visual mode using the 'f' and 'F' keys +Save your projects with 'Ps ' and restore then with 'Po ' +Enable asm.trace to see the tracing information inside the disassembly +Change the registers of the child process in this way: 'dr eax=0x333' +Check your IO plugins with 'rizin -L' +Change the size of the file with the 'r' (resize) command +Calculate checksums for the current block with the commands starting with 'ph' ('ph md5', 'ph crc32', ..) +Use +,-,*,/ to change the size of the block +Change the block size with 'b '. In visual mode you can also enter rizin command pressing the ':' key (like vi does) +If you want to open the file in read-write mode, invoke rizin with '-w' +Print the contents of the current block with the 'p' command +Command layout is: ' @ '. For example: '3x 20 @ 0x33' will show 3 hexdumps of 20 bytes at 0x33 +Press 'c' in visual mode to toggle the cursor mode +Press 'C' in visual mode to toggle colors +You can 'copy/paste' bytes using the cursor in visual mode 'c' and using the 'y' and 'Y' keys +Move around the bytes with h,j,k,l! Arrow keys are neither portable nor efficient +Seek at relative offsets with 's +' or 's -' +Invert the block bytes using the 'I' key in visual mode +Switch between print modes using the 'p' and 'P' keys in visual mode +Add comments using the ';' key in visual mode or the 'CC' command from the rizin shell +Assemble opcodes with the 'a' and 'A' keys in visual mode, which are bindings to the 'wa' and 'wA' commands +Find expanded AES keys in memory with '/ca' +Find wide-char strings with the '/w ' command +Control the signal handlers of the child process with the 'dk' command +Get a free shell with 'rz-gg -i exec -x' +Interpret rizin scripts with '. '. Similar to the bash source alias command. +Most of commands accept '?' as a suffix. Use it to understand how they work :) +Find hexpairs with '/x a0 cc 33' +Step through your seek history with the commands 'u' (undo) and 'U' (redo) +Use zoom.byte=entropy and press 'z' in visual mode to zoom out to see the entropy of the whole file +Use 'zoom.byte=printable' in zoom mode ('z' in Visual mode) to find strings +Add colors to your screen with 'e scr.color=X' where 1 is 16 colors, 2 is 256 colors and 3 is 16M colors +Move the comments to the right changing their margin with asm.cmt.margin +Execute a command on the visual prompt with cmd.vprompt +Reduce the delta where flag resolving by address is used with cfg.delta +Disable these messages with 'e cfg.fortunes=false' in your ~/.rizinrc +Change your fortune types with 'e cfg.fortunes.file=fun,tips' in your ~/.rizinrc +Execute a command every time a breakpoint is hit with 'e cmd.bp=!my-program' +Disassemble in intel syntax with 'e asm.syntax=intel'. +Change the UID of the debugged process with child.uid (requires root) +Enhance your graphs by increasing the size of the block and graph.depth eval variable. +Control the height of the terminal on serial consoles with e scr.height +Use `rizin -B 0x123456 /bin/ls` option to set the base address of a PIE file. +Bindiff two files with '$ rz-diff -H /bin/true /bin/false' +Execute commands on a temporary offset by appending '@ offset' to your command. +Temporally drop the verbosity prefixing the commands with ':' +Change the graph block definition with graph.callblocks, graph.jmpblocks, graph.flagblocks +Use scr.accel to browse the file faster! +Use the 'id' command to see the source line related to the current seek +Analyze socket connections with the socket plugin: 'rizin socket://www.foo.com:80'. Use 'w' to send data +Setup dbg.fpregs to true to visualize the fpu registers in the debugger view. +To debug a program, you can call rizin with 'dbg://' or '-d ' +Use 'e' and 't' in Visual mode to edit configuration and track flags. +Use 'rz-bin -ris' to get the import/export symbols of any binary. +Remember to maintain your `$(rizin -H RZ_CACHEHOME)/history` file! +Enable the PAGER with 'e scr.pager=less -R' +Use 'e asm.offset=true' to show offsets in 16bit segment addressing mode. +The '%' command can be used to evaluate math expressions. Like this: '% (0x34+22)*4' +Set 'e bin.dbginfo=true' to load debug information at startup. +Rename a function using the 'afr @ ' command. +You can redefine descriptive commands in the hud file and using the 'V_' command. +Pass '-j' to rz-bin to get the information of the binary in JSON format. +Use rz-run to launch your programs with a predefined environment. +You are probably using an old version of rizin, go checkout the git! +Use '-e bin.strings=false' to disable automatic string search when loading the binary. +The unix-like reverse engineering framework. +This code was intentionally left blank, try 'e asm.arch=ws' +Thanks for using rizin! +give | and > a try piping and redirection +Run .dmm* to load the flags of the symbols of all modules loaded in the debugger +Use V! to enter into the visual panels mode (dwm style) +Toggle between disasm and graph with the space key +The more 'a' you add after 'aa' the more analysis steps are executed. +Review all the subcommands of aa to see better ways to analyze your targets. +Use /m to carve for known magic headers. speedup with search. +You can use registers in math expressions. For example: 'wx 1234 @ esp - 2' +For HTTP authentication 'e http.auth=1', 'e http.authfile=' +Save your project in compressed format with 'e prj.compress=true' +Use 'avg?' to know how you can use global variables in rizin diff --git a/dest/share/gittip b/dest/share/gittip new file mode 100644 index 00000000000..ef85fee4c66 --- /dev/null +++ b/dest/share/gittip @@ -0,0 +1 @@ +2fe648f54139e201cf17fbe1e611934d80e92c16 \ No newline at end of file diff --git a/dest/share/hud/main b/dest/share/hud/main new file mode 100644 index 00000000000..635b4828204 --- /dev/null +++ b/dest/share/hud/main @@ -0,0 +1,38 @@ +add comment;%i Comment;CC `ys` +list comments;CC;%ik +change block size;%i block size;b `ys` +analyze all;aa +analyze function;af +analyze preludes;ap +continue process execution;dc;%i +disable colors;e scr.color=0 +enable colors (ANSI 16);e scr.color=1 +enable colors (256);e scr.color=2 +enable colors (16M);e scr.color=3 +randomize colors;ecr +hide bytes in disassembly;e asm.bytes=false +show bytes in disassembly;e asm.bytes=true +list imports ;ii;%ik +list sections;iS;%ik +list symbols;is;%ik +list processes;dp*;%ik +run command;%i cmd;`ys`;%ik +seek to entrypoint;s entry0 +seek to main;s main +set breakpoint;db;%i new breakpoint address;db `ys` +remove breakpoint %i delete breakpoint at given address;db-`ys` +show backtrace;dbt;%ik +show bytes in disassembly;e asm.bytes=1 +show debugger register values;dr;%ik +show process memory maps;dm;%ik +step instruction;sr PC;pd 1;ds;%ik +step over call;sr PC;pd 1;dso;%ik +write string;%i string;w `ys` +write hexadecimal data in current offset;%i hexpairs;wx `ys` +xor current block with hexpair key;%i hexpair key;wox `ys` +edit eval configuration;Veq +calculator;%i enter math expression;? `ys`;%ik +disassemble 1024 bytes and pipe to less(1);b 1024;pd|less -R +rename function;%i New name;afn `ys` +set flag;%i Flag name;f `ys` +unset flag;%i Flag name to delete;f-`ys` diff --git a/dest/share/magic/apple b/dest/share/magic/apple new file mode 100644 index 00000000000..23e3b409089 --- /dev/null +++ b/dest/share/magic/apple @@ -0,0 +1,377 @@ +#------------------------------------------------------------------------------ +# $File: macintosh,v 1.22 2011/05/17 17:40:31 rrt Exp $ +# macintosh description +# +# BinHex is the Macintosh ASCII-encoded file format (see also "apple") +# Daniel Quinlan, quinlan@yggdrasil.com +#11 string must\ be\ converted\ with\ BinHex BinHex binary text +#!:mime application/mac-binhex40 +#>41 string x \b, version %.3s + +# Macintosh Applications and Installation binaries (franklsm@tuns.ca) +# GRR: Too weak +#0 string APPL Macintosh Application (data) +#>2 string x \b: %s + +# Macintosh System files (franklsm@tuns.ca) +# GRR: Too weak +#0 string zsys Macintosh System File (data) +#0 string FNDR Macintosh Finder (data) +#0 string librz Macintosh Library (data) +#>2 string x : %s +#0 string shlb Macintosh Shared Library (data) +#>2 string x : %s +#0 string cdev Macintosh Control Panel (data) +#>2 string x : %s +#0 string INIT Macintosh Extension (data) +#>2 string x : %s +#0 string FFIL Macintosh Truetype Font (data) +#>2 string x : %s +#0 string LWFN Macintosh Postscript Font (data) +#>2 string x : %s + +# Additional Macintosh Files (franklsm@tuns.ca) +# GRR: Too weak +#0 string PACT Macintosh Compact Pro Archive (data) +#>2 string x : %s +#0 string ttro Macintosh TeachText File (data) +#>2 string x : %s +#0 string TEXT Macintosh TeachText File (data) +#>2 string x : %s +#0 string PDF Macintosh PDF File (data) +#>2 string x : %s + +# MacBinary format (Eric Fischer, enf@pobox.com) +# +# Unfortunately MacBinary doesn't really have a magic number prior +# to the MacBinary III format. The checksum is really the way to +# do it, but the magic file format isn't up to the challenge. +# +# 0 byte 0 +# 1 byte # filename length +# 2 string # filename +# 65 string # file type +# 69 string # file creator +# 73 byte # Finder flags +# 74 byte 0 +# 75 beshort # vertical posn in window +# 77 beshort # horiz posn in window +# 79 beshort # window or folder ID +# 81 byte # protected? +# 82 byte 0 +# 83 belong # length of data segment +# 87 belong # length of resource segment +# 91 belong # file creation date +# 95 belong # file modification date +# 99 beshort # length of comment after resource +# 101 byte # new Finder flags +# 102 string mBIN # (only in MacBinary III) +# 106 byte # char. code of file name +# 107 byte # still more Finder flags +# 116 belong # total file length +# 120 beshort # length of add'l header +# 122 byte 129 # for MacBinary II +# 122 byte 130 # for MacBinary III +# 123 byte 129 # minimum version that can read fmt +# 124 beshort # checksum +# +# This attempts to use the version numbers as a magic number, requiring +# that the first one be 0x80, 0x81, 0x82, or 0x83, and that the second +# be 0x81. This works for the files I have, but maybe not for everyone's. + +# Unfortunately, this magic is quite weak - MPi +#122 beshort&0xFCFF 0x8081 Macintosh MacBinary data + +# MacBinary I doesn't have the version number field at all, but MacBinary II +# has been in use since 1987 so I hope there aren't many really old files +# floating around that this will miss. The original spec calls for using +# the nulls in 0, 74, and 82 as the magic number. +# +# Another possibility, that would also work for MacBinary I, is to use +# the assumption that 65-72 will all be ASCII (0x20-0x7F), that 73 will +# have bits 1 (changed), 2 (busy), 3 (bozo), and 6 (invisible) unset, +# and that 74 will be 0. So something like +# +# 71 belong&0x80804EFF 0x00000000 Macintosh MacBinary data +# +# >73 byte&0x01 0x01 \b, inited +# >73 byte&0x02 0x02 \b, changed +# >73 byte&0x04 0x04 \b, busy +# >73 byte&0x08 0x08 \b, bozo +# >73 byte&0x10 0x10 \b, system +# >73 byte&0x10 0x20 \b, bundle +# >73 byte&0x10 0x40 \b, invisible +# >73 byte&0x10 0x80 \b, locked + +#>65 string x \b, type "%4.4s" + +#>65 string 8BIM (PhotoShop) +#>65 string ALB3 (PageMaker 3) +#>65 string ALB4 (PageMaker 4) +#>65 string ALT3 (PageMaker 3) +#>65 string APPL (application) +#>65 string AWWP (AppleWorks word processor) +#>65 string CIRC (simulated circuit) +#>65 string DRWG (MacDraw) +#>65 string EPSF (Encapsulated PostScript) +#>65 string FFIL (font suitcase) +#>65 string FKEY (function key) +#>65 string FNDR (Macintosh Finder) +#>65 string GIFf (GIF image) +#>65 string Gzip (GNU gzip) +#>65 string INIT (system extension) +#>65 string LIB\ (library) +#>65 string LWFN (PostScript font) +#>65 string MSBC (Microsoft BASIC) +#>65 string PACT (Compact Pro archive) +#>65 string PDF\ (Portable Document Format) +#>65 string PICT (picture) +#>65 string PNTG (MacPaint picture) +#>65 string PREF (preferences) +#>65 string PROJ (Think C project) +#>65 string QPRJ (Think Pascal project) +#>65 string SCFL (Defender scores) +#>65 string SCRN (startup screen) +#>65 string SITD (StuffIt Deluxe) +#>65 string SPn3 (SuperPaint) +#>65 string STAK (HyperCard stack) +#>65 string Seg\ (StuffIt segment) +#>65 string TARF (Unix tar archive) +#>65 string TEXT (ASCII) +#>65 string TIFF (TIFF image) +#>65 string TOVF (Eudora table of contents) +#>65 string WDBN (Microsoft Word word processor) +#>65 string WORD (MacWrite word processor) +#>65 string XLS\ (Microsoft Excel) +#>65 string ZIVM (compress (.Z)) +#>65 string ZSYS (Pre-System 7 system file) +#>65 string acf3 (Aldus FreeHand) +#>65 string cdev (control panel) +#>65 string dfil (Desk Acessory suitcase) +#>65 string librz (library) +#>65 string nX^d (WriteNow word processor) +#>65 string nX^w (WriteNow dictionary) +#>65 string rsrc (resource) +#>65 string scbk (Scrapbook) +#>65 string shlb (shared library) +#>65 string ttro (SimpleText read-only) +#>65 string zsys (system file) + +#>69 string x \b, creator "%4.4s" + +# Somewhere, Apple has a repository of registered Creator IDs. These are +# just the ones that I happened to have files from and was able to identify. + +#>69 string 8BIM (Adobe Photoshop) +#>69 string ALD3 (PageMaker 3) +#>69 string ALD4 (PageMaker 4) +#>69 string ALFA (Alpha editor) +#>69 string APLS (Apple Scanner) +#>69 string APSC (Apple Scanner) +#>69 string BRKL (Brickles) +#>69 string BTFT (BitFont) +#>69 string CCL2 (Common Lisp 2) +#>69 string CCL\ (Common Lisp) +#>69 string CDmo (The Talking Moose) +#>69 string CPCT (Compact Pro) +#>69 string CSOm (Eudora) +#>69 string DMOV (Font/DA Mover) +#>69 string DSIM (DigSim) +#>69 string EDIT (Macintosh Edit) +#>69 string ERIK (Macintosh Finder) +#>69 string EXTR (self-extracting archive) +#>69 string Gzip (GNU gzip) +#>69 string KAHL (Think C) +#>69 string LWFU (LaserWriter Utility) +#>69 string LZIV (compress) +#>69 string MACA (MacWrite) +#>69 string MACS (Macintosh operating system) +#>69 string MAcK (MacKnowledge terminal emulator) +#>69 string MLND (Defender) +#>69 string MPNT (MacPaint) +#>69 string MSBB (Microsoft BASIC (binary)) +#>69 string MSWD (Microsoft Word) +#>69 string NCSA (NCSA Telnet) +#>69 string PJMM (Think Pascal) +#>69 string PSAL (Hunt the Wumpus) +#>69 string PSI2 (Apple File Exchange) +#>69 string R*ch (BBEdit) +#>69 string RMKR (Resource Maker) +#>69 string RSED (Resource Editor) +#>69 string Rich (BBEdit) +#>69 string SIT! (StuffIt) +#>69 string SPNT (SuperPaint) +#>69 string Unix (NeXT Mac filesystem) +#>69 string VIM! (Vim editor) +#>69 string WILD (HyperCard) +#>69 string XCEL (Microsoft Excel) +#>69 string aCa2 (Fontographer) +#>69 string aca3 (Aldus FreeHand) +#>69 string dosa (Macintosh MS-DOS file system) +#>69 string movr (Font/DA Mover) +#>69 string nX^n (WriteNow) +#>69 string pdos (Apple ProDOS file system) +#>69 string scbk (Scrapbook) +#>69 string ttxt (SimpleText) +#>69 string ufox (Foreign File Access) + +# Just in case... + +102 string mBIN MacBinary III data with surprising version number + +# sas magic from Bruce Foster (bef@nwu.edu) +# +#0 string SAS SAS +#>8 string x %s +#0 string SAS SAS +>24 string DATA data file +>24 string CATALOG catalog +>24 string INDEX data file index +>24 string VIEW data view +# sas 7+ magic from Reinhold Koch (reinhold.koch@roche.com) +# +#0x54 string SAS SAS 7+ +>0x9C string DATA data file +>0x9C string CATALOG catalog +>0x9C string INDEX data file index +>0x9C string VIEW data view + +# spss magic for SPSS system and portable files, +# from Bruce Foster (bef@nwu.edu). + +0 long 0xc1e2c3c9 SPSS Portable File +>40 string x %s + +0 string $FL2 SPSS System File +>24 string x %s + +0 string $FL3 SPSS System File +>24 string x %s + +# Macintosh filesystem data +# From "Tom N Harris" +# Fixed HFS+ and Partition map magic: Ethan Benson +# The MacOS epoch begins on 1 Jan 1904 instead of 1 Jan 1970, so these +# entries depend on the data arithmetic added after v.35 +# There's also some Pascal strings in here, ditto... + +# The boot block signature, according to IM:Files, is +# "for HFS volumes, this field always contains the value 0x4C4B." +# But if this is true for MFS or HFS+ volumes, I don't know. +# Alternatively, the boot block is supposed to be zeroed if it's +# unused, so a simply >0 should suffice. + +#0x400 beshort 0xD2D7 Macintosh MFS data +#>0 beshort 0x4C4B (bootable) +#>0x40a beshort &0x8000 (locked) +#>0x402 beldate-0x7C25B080 x created: %s, +#>0x406 beldate-0x7C25B080 >0 last backup: %s, +#>0x414 belong x block size: %d, +#>0x412 beshort x number of blocks: %d, +#>0x424 pstring x volume name: %s + +# "BD" gives many false positives +#0x400 beshort 0x4244 Macintosh HFS data +#>0 beshort 0x4C4B (bootable) +#>0x40a beshort &0x8000 (locked) +#>0x40a beshort ^0x0100 (mounted) +#>0x40a beshort &0x0200 (spared blocks) +#>0x40a beshort &0x0800 (unclean) +#>0x47C beshort 0x482B (Embedded HFS+ Volume) +#>0x402 beldate-0x7C25B080 x created: %s, +#>0x406 beldate-0x7C25B080 x last modified: %s, +#>0x440 beldate-0x7C25B080 >0 last backup: %s, +#>0x414 belong x block size: %d, +#>0x412 beshort x number of blocks: %d, +#>0x424 pstring x volume name: %s + +# disabled because it produces many false positives :( +#0x400 beshort 0x482B Macintosh HFS Extended +#>&0 beshort x version %d data +#>0 beshort 0x4C4B (bootable) +#>0x404 belong ^0x00000100 (mounted) +#>&2 belong &0x00000200 (spared blocks) +#>&2 belong &0x00000800 (unclean) +#>&2 belong &0x00008000 (locked) +#>&6 string x last mounted by: '%.4s', +## really, that should be treated as a belong and we print a string +## based on the value. TN1150 only mentions '8.10' for "MacOS 8.1" +#>&14 beldate-0x7C25B080 x created: %s, +## only the creation date is local time, all other timestamps in HFS+ are UTC. +#>&18 bedate-0x7C25B080 x last modified: %s, +#>&22 bedate-0x7C25B080 >0 last backup: %s, +#>&26 bedate-0x7C25B080 >0 last checked: %s, +#>&38 belong x block size: %d, +#>&42 belong x number of blocks: %d, +#>&46 belong x free blocks: %d + +# I don't think this is really necessary since it doesn't do much and +# anything with a valid driver descriptor will also have a valid +# partition map +#0 beshort 0x4552 Apple Device Driver data +#>&24 beshort =1 \b, MacOS + +# Is that the partition type a cstring or a pstring? Well, IM says "strings +# shorter than 32 bytes must be terminated with NULL" so I'll treat it as a +# cstring. Of course, partitions can contain more than four entries, but +# what're you gonna do? +# GRR: This magic is too weak, it is just "PM" +#0x200 beshort 0x504D Apple Partition data +#>0x2 beshort x (block size: %d): +#>0x230 string x first type: %s, +#>0x210 string x name: %s, +#>0x254 belong x number of blocks: %d, +#>0x400 beshort 0x504D +#>>0x430 string x second type: %s, +#>>0x410 string x name: %s, +#>>0x454 belong x number of blocks: %d, +#>>0x600 beshort 0x504D +#>>>0x630 string x third type: %s, +#>>>0x610 string x name: %s, +#>>>0x654 belong x number of blocks: %d, +#>>0x800 beshort 0x504D +#>>>0x830 string x fourth type: %s, +#>>>0x810 string x name: %s, +#>>>0x854 belong x number of blocks: %d, +#>>>0xa00 beshort 0x504D +#>>>>0xa30 string x fifth type: %s, +#>>>>0xa10 string x name: %s, +#>>>>0xa54 belong x number of blocks: %d +#>>>0xc00 beshort 0x504D +#>>>>0xc30 string x sixth type: %s, +#>>>>0xc10 string x name: %s, +#>>>>0xc54 belong x number of blocks: %d +## AFAIK, only the signature is different +#0x200 beshort 0x5453 Apple Old Partition data +#>0x2 beshort x block size: %d, +#>0x230 string x first type: %s, +#>0x210 string x name: %s, +#>0x254 belong x number of blocks: %d, +#>0x400 beshort 0x504D +#>>0x430 string x second type: %s, +#>>0x410 string x name: %s, +#>>0x454 belong x number of blocks: %d, +#>>0x800 beshort 0x504D +#>>>0x830 string x third type: %s, +#>>>0x810 string x name: %s, +#>>>0x854 belong x number of blocks: %d, +#>>>0xa00 beshort 0x504D +#>>>>0xa30 string x fourth type: %s, +#>>>>0xa10 string x name: %s, +#>>>>0xa54 belong x number of blocks: %d + +# From: Remi Mommsen +0 string BOMStore Mac OS X bill of materials (BOM) file + + +0 lelong 0x0b17c0de +>4 lelong 0 LLVM BitCode + +0 belong 0x4243c0de +>6 byte 0 LLVM IR bitcode + +0 lelong 0xff01ff02 +>4 lelong 1 +>8 lelong -1 XCode Symbols file + +0 string BCSymbolMap BitCode symbol map file diff --git a/dest/share/magic/archive b/dest/share/magic/archive new file mode 100644 index 00000000000..78136223f29 --- /dev/null +++ b/dest/share/magic/archive @@ -0,0 +1,262 @@ +# $OpenBSD: archive,v 1.6 2009/04/24 18:54:34 chl Exp $ + +#------------------------------------------------------------------------------ +# archive: file(1) magic for archive formats (see also "msdos" for self- +# extracting compressed archives) +# +# cpio, ar, arc, arj, hpack, lha/lharc, rar, squish, uc2, zip, zoo, etc. +# pre-POSIX "tar" archives are handled in the C code. + +# POSIX tar archives +257 string ustar\0 POSIX tar archive +!:mime application/x-tar # encoding: posix +257 string ustar\040\040\0 GNU tar archive +!:mime application/x-tar # encoding: gnu + +# cpio archives +# + +# Debian package (needs to go before regular portable archives) +# +0 string =!\ndebian +>8 string debian-split part of multipart Debian package +!:mime application/vnd.debian.binary-package +>8 string debian-binary Debian binary package +!:mime application/vnd.debian.binary-package +>8 string !debian +>68 string >\0 (format %s) +# These next two lines do not work, because a bzip2 Debian archive +# still uses gzip for the control.tar (first in the archive). Only +# data.tar varies, and the location of its filename varies too. +# file/libmagic does not current have support for ascii-string based +# (offsets) as of 2005-09-15. +#>81 string bz2 \b, uses bzip2 compression +#>84 string gz \b, uses gzip compression +#>136 ledate x created: %s + +# MIPS archive (needs to go before regular portable archives) +# +0 string =!\n__________E MIPS archive +>20 string U with MIPS Ucode members +>21 string L with MIPSEL members +>21 string B with MIPSEB members +>19 string L and an EL hash table +>19 string B and an EB hash table +>22 string X -- out of date + +0 search/1 -h- Software Tools format archive text + +# +# XXX - why are there multiple thingies? Note that 0x213c6172 is +# "! current ar archive +# 0 long 0x213c6172 archive file +# +# and for SVR1 archives, we have: +# +# 0 string \ System V Release 1 ar archive +# 0 string = archive +# +# XXX - did Aegis really store shared libraries, breakpointed modules, +# and absolute code program modules in the same format as new-style +# "ar" archives? +# +0 string =! current ar archive +!:mime application/x-archive +>8 string __.SYMDEF random library +>0 belong =65538 - pre SR9.5 +>0 belong =65539 - post SR9.5 +>0 beshort 2 - object archive +>0 beshort 3 - shared library module +>0 beshort 4 - debug break-pointed module +>0 beshort 5 - absolute code program module +0 string \ System V Release 1 ar archive +0 string = archive +# + +# MS Compress +4 string \x88\xf0\x27 MS Compress archive data +# updated by Joerg Jenderek +>9 string \0 +>>0 string KWAJ +>>>7 string \321\003 MS Compress archive data +>>>>14 ulong >0 \b, original size: %d byte(s) +>>>>18 ubyte >0x65 +>>>>>18 string x \b, was %.8s +>>>>>(10.b-4) string x \b.%.3s + +# JAR archiver (.j), this is the successor to ARJ, not Java's JAR (which is essentially ZIP) +0xe string \x1aJar\x1b JAR (ARJ Software, Inc.) archive data +0 string JARCS JAR (ARJ Software, Inc.) archive data + +# RAR archiver (Greg Roelofs, newt@uchicago.edu) +0 string Rar! RAR archive data, +!:mime application/x-rar +>44 byte x v%0x, +>10 byte >0 flags: +>>10 byte &0x01 Archive volume, +>>10 byte &0x02 Commented, +>>10 byte &0x04 Locked, +>>10 byte &0x08 Solid, +>>10 byte &0x20 Authenticated, +>35 byte 0 os: MS-DOS +>35 byte 1 os: OS/2 +>35 byte 2 os: Win32 +>35 byte 3 os: Unix +# some old version? idarc says: +0 string RE\x7e\x5e RAR archive data + +# SQUISH archiver (Greg Roelofs, newt@uchicago.edu) +0 string SQSH squished archive data (Acorn RISCOS) + +# UC2 archiver (Greg Roelofs, newt@uchicago.edu) +# [JW] see exe section for self-extracting version +0 string UC2\x1a UC2 archive data + +# ZIP archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu) +0 string PK\003\004 ZIP +>4 byte 0x00 Zip archive data +!:mime application/zip +>4 byte 0x09 Zip archive data, at least v0.9 to extract +!:mime application/zip +>4 byte 0x0a Zip archive data, at least v1.0 to extract +!:mime application/zip +>4 byte 0x0b Zip archive data, at least v1.1 to extract +!:mime application/zip +>0x161 string WINZIP Zip archive data, WinZIP self-extracting +!:mime application/zip +>4 byte 0x14 +>>30 ubelong !0x6d696d65 Zip archive data, at least v2.0 to extract +!:mime application/zip + +# ZIP footer +0 string PK\005\006 End of Zip archive + +# OpenOffice.org / KOffice / StarOffice documents +# From: Abel Cheung +# Listed here because they are basically zip files +>>30 string mimetype + +# KOffice (1.2 or above) formats +>>>50 string vnd.kde. KOffice (>=1.2) +>>>>58 string karbon Karbon document +>>>>58 string kchart KChart document +>>>>58 string kformula KFormula document +>>>>58 string kivio Kivio document +>>>>58 string kontour Kontour document +>>>>58 string kpresenter KPresenter document +>>>>58 string kspread KSpread document +>>>>58 string kword KWord document + +# OpenOffice formats (for OpenOffice 1.x / StarOffice 6/7) +>>>50 string vnd.sun.xml. OpenOffice.org 1.x +>>>>62 string writer Writer +>>>>>68 byte !0x2e document +>>>>>68 string .template template +>>>>>68 string .global global document +>>>>62 string calc Calc +>>>>>66 byte !0x2e spreadsheet +>>>>>66 string .template template +>>>>62 string draw Draw +>>>>>66 byte !0x2e document +>>>>>66 string .template template +>>>>62 string impress Impress +>>>>>69 byte !0x2e presentation +>>>>>69 string .template template +>>>>62 string math Math document + +# OpenDocument formats (for OpenOffice 2.x / StarOffice >= 8) +# http://lists.oasis-open.org/archives/office/200505/msg00006.html +>>>50 string vnd.oasis.opendocument. OpenDocument +>>>>73 string text +>>>>>77 byte !0x2d Text +!:mime application/vnd.oasis.opendocument.text +>>>>>77 string -template Text Template +>>>>>77 string -web HTML Document Template +>>>>>77 string -master Master Document +>>>>73 string graphics Drawing +>>>>>81 string -template Template +>>>>73 string presentation Presentation +>>>>>85 string -template Template +>>>>73 string spreadsheet Spreadsheet +>>>>>84 string -template Template +>>>>73 string chart Chart +>>>>>78 string -template Template +>>>>73 string formula Formula +>>>>>80 string -template Template +>>>>73 string database Database +>>>>73 string image Image + +# Zoo archiver +20 lelong 0xfdc4a7dc Zoo archive data +!:mime application/x-zoo +>4 byte >48 \b, v%c. +>>6 byte >47 \b%c +>>>7 byte >47 \b%c +>32 byte >0 \b, modify: v%d +>>33 byte x \b.%d+ +>42 lelong 0xfdc4a7dc \b, +>>70 byte >0 extract: v%d +>>>71 byte x \b.%d+ + +# Shell archives +10 string #\ This\ is\ a\ shell\ archive shell archive text +!:mime application/octet-stream + +# +# LBR. NB: May conflict with the questionable +# "binary Computer Graphics Metafile" format. +# +0 string \0\ \ \ \ \ \ \ \ \ \ \ \0\0 LBR archive data +# +# PMA (CP/M derivative of LHA) +# +2 string -pm0- PMarc archive data [pm0] +2 string -pm1- PMarc archive data [pm1] +2 string -pm2- PMarc archive data [pm2] +2 string -pms- PMarc SFX archive (CP/M, DOS) +5 string -pc1- PopCom compressed executable (CP/M) + +# Microsoft cabinets +# by David Necas (Yeti) +#0 string MSCF\0\0\0\0 Microsoft cabinet file data, +#>25 byte x v%d +#>24 byte x \b.%d +# MPi: All CABs have version 1.3, so this is pointless. + +# Felix von Leitner +0 string d8:announce BitTorrent file +!:mime application/x-bittorrent + +# Alternate ZIP string (amc@arwen.cs.berkeley.edu) +0 string PK00PK\003\004 Zip archive data + +# rzip archives +0 string RZIP rzip compressed data +>4 byte x - version %d +>5 byte x \b.%d +>6 belong x (%d byte(s)) + +# From: Dirk Jagdmann +# xar archive format: http://code.google.com/p/xar/ +0 string xar! xar archive +>6 beshort x - version %d + +# From: "Nelson A. de Oliveira" +# .kgb +0 string KGB_arch KGB Archiver file +>10 string x with compression level %.1s + +# xar (eXtensible ARchiver) archive +# From: "David Remahl" +0 string xar! xar archive +#>4 beshort x header size %d +>6 beshort x version %d, +#>8 quad x compressed TOC: %d, +#>16 quad x uncompressed TOC: %d, +>24 belong 0 no checksum +>24 belong 1 SHA-1 checksum +>24 belong 2 MD5 checksum + +0 lelong 0x0a02d40a protobuf: Google's protocol-buffer file diff --git a/dest/share/magic/cafebabe b/dest/share/magic/cafebabe new file mode 100644 index 00000000000..9d5acfb9fb5 --- /dev/null +++ b/dest/share/magic/cafebabe @@ -0,0 +1,29 @@ +# $OpenBSD: cafebabe,v 1.3 2009/04/24 18:54:34 chl Exp $ + +#------------------------------------------------------------------------------ +# Cafe Babes unite! +# +# Since Java bytecode and Mach-O fat-files have the same magic number, the test +# must be performed in the same "magic" sequence to get both right. The long +# at offset 4 in a mach-O fat file tells the number of architectures; the short at +# offset 4 in a Java bytecode file is the JVM minor version and the +# short at offset 6 is the JVM major version. Since there are only +# only 18 labeled Mach-O architectures at current, and the first released +# Java class format was version 43.0, we can safely choose any number +# between 18 and 39 to test the number of architectures against +# (and use as a hack). Let's not use 18, because the Mach-O people +# might add another one or two as time goes by... +# +0 beshort 0xcafe +>2 beshort 0xbabe +#>4 belong >30 compiled Java class data, +#>4 belong >30 +# !:mime application/x-java-applet +>>6 beshort <20 +>>>6 beshort x version %d. +>>>4 beshort x \b%d +>>>4 belong 1 Mach-O fat file with 1 architecture +>>>4 belong >1 +>>>>4 belong <20 Mach-O fat file with %d architectures +>2 beshort 0xd00d JAR compressed with pack200 +!:mime application/x-java-pack200 diff --git a/dest/share/magic/code b/dest/share/magic/code new file mode 100644 index 00000000000..3f331f72ba7 --- /dev/null +++ b/dest/share/magic/code @@ -0,0 +1,5 @@ +0 string #include C source code +0 string import java. JAVA source code +0 string #!/usr/bin/env python Python script +0 string #!/usr/bin/python Python script +0 string #!/usr/bin/perl PERL script diff --git a/dest/share/magic/compressed b/dest/share/magic/compressed new file mode 100644 index 00000000000..7e9da4de383 --- /dev/null +++ b/dest/share/magic/compressed @@ -0,0 +1,128 @@ + +#------------------Compression Formats----------------------------- + + +# bzip2 +0 string BZh91AY&SY bzip2 compressed data, block size = 900k +0 string BZh81AY&SY bzip2 compressed data, block size = 800k +0 string BZh71AY&SY bzip2 compressed data, block size = 700k +0 string BZh61AY&SY bzip2 compressed data, block size = 600k +0 string BZh51AY&SY bzip2 compressed data, block size = 500k +0 string BZh41AY&SY bzip2 compressed data, block size = 400k +0 string BZh31AY&SY bzip2 compressed data, block size = 300k +0 string BZh21AY&SY bzip2 compressed data, block size = 200k +0 string BZh11AY&SY bzip2 compressed data, block size = 100k + +# LZO +0 string \211LZO\000\015\012\032\012 LZO compressed data + +# 7-zip archiver, from Thomas Klausner (wiz@danbala.tuwien.ac.at) +# http://www.7-zip.org or DOC/7zFormat.txt +# +0 string 7z\274\257\047\034 7-zip archive data, +>6 byte <0 invalid +>6 byte 0 +>>7 byte 0 invalid +>6 byte >20 invalid +>6 byte x version %d +>7 byte x \b.%d + +# standard unix compress +# Implemented in the compress binwalk plugin. +#0 string \x1f\x9d\x90 compress'd data, 16 bits + +# http://tukaani.org/xz/xz-file-format.txt +0 string \xFD\x37\x7a\x58\x5a\x00 xz compressed data + +# gzip (GNU zip, not to be confused with Info-ZIP or PKWARE zip archiver) +# Edited by Chris Chittleborough , March 2002 +# * Original filename is only at offset 10 if "extra field" absent +# * Produce shorter output - notably, only report compression methods +# other than 8 ("deflate", the only method defined in RFC 1952). +#0 string \037\213\x08 gzip compressed data +0 string \x1f\x8b\x08 gzip compressed data +>3 byte &0x01 \b, ASCII +>3 byte&0xE0 !0x00 \b, invalid reserved flag bits +>8 byte 2 \b, maximum compression +>8 byte 4 \b, fastest compression +>8 byte 1 \b, invalid extra flags +>8 byte 3 \b, invalid extra flags +>8 byte >4 \b, invalid extra flags +>3 byte &0x02 \b, has header CRC +>3 byte&0x04 0x04 +>>10 leshort x \b, has %d byte(s) of extra data +>3 byte&0xC =0x08 \b, has original file name +>>10 string x \b{file-name:%s} +>>10 string x \b: "%s" +>3 byte &0x10 \b, has comment +>>3 byte&0xC 0 +>>>10 string x \b: "%s" +>9 byte =0x00 \b, from FAT filesystem (MS-DOS, OS/2, NT) +>9 byte =0x01 \b, from Amiga +>9 byte =0x02 \b, from VMS +>9 byte =0x03 \b, from Unix +>9 byte =0x04 \b, from VM/CMS +>9 byte =0x05 \b, from Atari +>9 byte =0x06 \b, from HPFS filesystem (OS/2, NT) +>9 byte =0x07 \b, from MacOS +>9 byte =0x08 \b, from Z-System +>9 byte =0x09 \b, from CP/M +>9 byte =0x0A \b, from TOPS/20 +>9 byte =0x0B \b, from NTFS filesystem (NT) +>9 byte =0x0C \b, from QDOS +>9 byte =0x0D \b, from Acorn RISCOS +#>9 byte =0xFF \b, from ZyNOS +#>9 byte >0x0D \b, invalid +#>>9 byte x source: 0x%.2X +#>9 byte <0 \b, invalid +#>>9 byte x source: 0x%.2X +>3 byte &0x20 \b, encrypted (invalid) +# Dates before 1992 are invalid, unless of course you're DD-WRT in which +# case you don't know how to set a date in your gzip files. Brilliant. +>4 lelong =0 \b, NULL date +>4 lelong <0 \b, invalid date +>4 lelong >0 +>>4 lelong <694224000 \b, invalid date +>>4 lelong =694224000 \b, invalid date +>>4 lelong >694224000 \b, last modified +>>4 ledate x %s + +# Zlib signatures +# Too short to be useful on their own; see: +# +# o src/binwalk/magic/zlib +# o src/binwalk/plugins/zlib.py +# +#0 beshort 0x789C zlib compressed data +#0 beshort 0x78DA zlib compressed data +#0 beshort 0x7801 zlib compressed data + + +# JAR +0 belong 0xcafed00d JAR compressed with pack200, +>5 byte x version %d. +>4 byte x \b%d + +# New LZMA format signature +# See lzma file for LZMA signatures +0 string \xFFLZMA\x00 LZMA compressed data (new), +>6 byte&0x10 0 single-block stream +>6 byte&0x10 0x10 multi-block stream + +## Classic LZMA signature +0 byte >0x5a +>0 byte <0x5e +>>5 belong 0xffffffff +>>>1 belong >0 +>>>>1 belong <0xfffff +>>>>>1 belong x LZMA BE compressed data dictionary size: %d bytes, + +#0 string \xff\x06\x00\x00\x73\x4e\x61\x50\x70\x59 Snappy compression, stream identifier + +#0 string \x1f\x9d\x90 compress'd data, 16 bits + +#0 beshort 0x7801 Zlib header, no compression +#0 beshort 0x789c Zlib compressed data, default compression +#0 beshort 0x78da Zlib compressed data, best compression +#0 beshort 0x785e Zlib compressed data, compressed + diff --git a/dest/share/magic/database b/dest/share/magic/database new file mode 100644 index 00000000000..90cbc38e52c --- /dev/null +++ b/dest/share/magic/database @@ -0,0 +1,240 @@ +# $OpenBSD: database,v 1.6 2009/04/24 18:54:34 chl Exp $ + +#------------------------------------------------------------------------------ +# database: file(1) magic for various databases +# +# extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk) +# +# +# GDBM magic numbers +# Will be maintained as part of the GDBM distribution in the future. +# +0 belong 0x13579ace GNU dbm 1.x or ndbm database, big endian +!:mime application/x-gdbm +0 lelong 0x13579ace GNU dbm 1.x or ndbm database, little endian +!:mime application/x-gdbm +0 string GDBM GNU dbm 2.x database +!:mime application/x-gdbm +# +# Berkeley DB +# +# Ian Darwin's file /etc/magic files: big/little-endian version. +# +# Hash 1.85/1.86 databases store metadata in network byte order. +# Btree 1.85/1.86 databases store the metadata in host byte order. +# Hash and Btree 2.X and later databases store the metadata in host byte order. + +0 long 0x00061561 Berkeley DB +!:mime application/x-dbm +>8 belong 4321 +>>4 belong >2 1.86 +>>4 belong <3 1.85 +>>4 belong >0 (Hash, version %d, native byte-order) +>8 belong 1234 +>>4 belong >2 1.86 +>>4 belong <3 1.85 +>>4 belong >0 (Hash, version %d, little-endian) + +0 belong 0x00061561 Berkeley DB +>8 belong 4321 +>>4 belong >2 1.86 +>>4 belong <3 1.85 +>>4 belong >0 (Hash, version %d, big-endian) +>8 belong 1234 +>>4 belong >2 1.86 +>>4 belong <3 1.85 +>>4 belong >0 (Hash, version %d, native byte-order) + +0 long 0x00053162 Berkeley DB 1.85/1.86 +>4 long >0 (Btree, version %d, native byte-order) +0 belong 0x00053162 Berkeley DB 1.85/1.86 +>4 belong >0 (Btree, version %d, big-endian) +0 lelong 0x00053162 Berkeley DB 1.85/1.86 +>4 lelong >0 (Btree, version %d, little-endian) + +12 long 0x00061561 Berkeley DB +>16 long >0 (Hash, version %d, native byte-order) +12 belong 0x00061561 Berkeley DB +>16 belong >0 (Hash, version %d, big-endian) +12 lelong 0x00061561 Berkeley DB +>16 lelong >0 (Hash, version %d, little-endian) + +12 long 0x00053162 Berkeley DB +>16 long >0 (Btree, version %d, native byte-order) +12 belong 0x00053162 Berkeley DB +>16 belong >0 (Btree, version %d, big-endian) +12 lelong 0x00053162 Berkeley DB +>16 lelong >0 (Btree, version %d, little-endian) + +12 long 0x00042253 Berkeley DB +>16 long >0 (Queue, version %d, native byte-order) +12 belong 0x00042253 Berkeley DB +>16 belong >0 (Queue, version %d, big-endian) +12 lelong 0x00042253 Berkeley DB +>16 lelong >0 (Queue, version %d, little-endian) + +# From Max Bowsher. +12 long 0x00040988 Berkeley DB +>16 long >0 (Log, version %d, native byte-order) +12 belong 0x00040988 Berkeley DB +>16 belong >0 (Log, version %d, big-endian) +12 lelong 0x00040988 Berkeley DB +>16 lelong >0 (Log, version %d, little-endian) + +# +# +# Round Robin Database Tool by Tobias Oetiker +#0 string RRD RRDTool DB +#>4 string x version %s +#---------------------------------------------------------------------- +# ROOT: file(1) magic for ROOT databases +# +#0 string root\0 ROOT file +#>4 belong x Version %d +#>33 belong x (Compression: %d) + +# XXX: Weak magic. +# Alex Ott +## Paradox file formats +#2 leshort 0x0800 Paradox +#>0x39 byte 3 v. 3.0 +#>0x39 byte 4 v. 3.5 +#>0x39 byte 9 v. 4.x +#>0x39 byte 10 v. 5.x +#>0x39 byte 11 v. 5.x +#>0x39 byte 12 v. 7.x +#>>0x04 byte 0 indexed .DB data file +#>>0x04 byte 1 primary index .PX file +#>>0x04 byte 2 non-indexed .DB data file +#>>0x04 byte 3 non-incrementing secondary index .Xnn file +#>>0x04 byte 4 secondary index .Ynn file +#>>0x04 byte 5 incrementing secondary index .Xnn file +#>>0x04 byte 6 non-incrementing secondary index .XGn file +#>>0x04 byte 7 secondary index .YGn file +#>>>0x04 byte 8 incrementing secondary index .XGn file + +## XBase database files +#0 byte 0x02 +#>8 leshort >0 +#>>12 leshort 0 FoxBase +#!:mime application/x-dbf +#>>>0x04 lelong 0 (no records) +#>>>0x04 lelong >0 (%ld records) +# +#0 byte 0x03 +#!:mime application/x-dbf +#>8 leshort >0 +#>>12 leshort 0 FoxBase+, FoxPro, dBaseIII+, dBaseIV, no memo +#>>>0x04 lelong 0 (no records) +#>>>0x04 lelong >0 (%ld records) +# +#0 byte 0x04 +#!:mime application/x-dbf +#>8 leshort >0 +#>>12 leshort 0 dBASE IV no memo file +#>>>0x04 lelong 0 (no records) +#>>>0x04 lelong >0 (%ld records) +# +#0 byte 0x05 +#!:mime application/x-dbf +#>8 leshort >0 +#>>12 leshort 0 dBASE V no memo file +#>>>0x04 lelong 0 (no records) +#>>>0x04 lelong >0 (%ld records) +# +#0 byte 0x30 +#!:mime application/x-dbf +#>8 leshort >0 +#>>12 leshort 0 Visual FoxPro +#>>>0x04 lelong 0 (no records) +#>>>0x04 lelong >0 (%ld records) +# +#0 byte 0x43 +#!:mime application/x-dbf +#>8 leshort >0 +#>>12 leshort 0 FlagShip with memo var size +#>>>0x04 lelong 0 (no records) +#>>>0x04 lelong >0 (%ld records) +# +#0 byte 0x7b +#!:mime application/x-dbf +#>8 leshort >0 +#>>12 leshort 0 dBASEIV with memo +#>>>0x04 lelong 0 (no records) +#>>>0x04 lelong >0 (%ld records) +# +#0 byte 0x83 +#!:mime application/x-dbf +#>8 leshort >0 +#>>12 leshort 0 FoxBase+, dBaseIII+ with memo +#>>>0x04 lelong 0 (no records) +#>>>0x04 lelong >0 (%ld records) +# +#0 byte 0x8b +#!:mime application/x-dbf +#>8 leshort >0 +#>>12 leshort 0 dBaseIV with memo +#>>>0x04 lelong 0 (no records) +#>>>0x04 lelong >0 (%ld records) +# +#0 byte 0x8e +#!:mime application/x-dbf +#>8 leshort >0 +#>>12 leshort 0 dBaseIV with SQL Table +#>>>0x04 lelong 0 (no records) +#>>>0x04 lelong >0 (%ld records) +# +#0 byte 0xb3 +#!:mime application/x-dbf +#>8 leshort >0 +#>>12 leshort 0 FlagShip with .dbt memo +#>>>0x04 lelong 0 (no records) +#>>>0x04 lelong >0 (%ld records) +# +#0 byte 0xf5 +#!:mime application/x-dbf +#>8 leshort >0 +#>>12 leshort 0 FoxPro with memo +#>>>0x04 lelong 0 (no records) +#>>>0x04 lelong >0 (%ld records) +# +#0 leshort 0x0006 DBase 3 index file + +# MS Access database +4 string Standard\ Jet\ DB Microsoft Access Database +!:mime application/x-msaccess + +# SE Linux policy database +#0 lelong 0xf97cff8c SE Linux policy +#>16 lelong x v%d +#>20 lelong 1 MLS +#>24 lelong x %d symbols +#>28 lelong x %d ocons + +# ICE authority file data (Wolfram Kleff) +#2 string ICE ICE authority data + +# X11 Xauthority file (Wolfram Kleff) +10 string MIT-MAGIC-COOKIE-1 X11 Xauthority data +11 string MIT-MAGIC-COOKIE-1 X11 Xauthority data +12 string MIT-MAGIC-COOKIE-1 X11 Xauthority data +13 string MIT-MAGIC-COOKIE-1 X11 Xauthority data +14 string MIT-MAGIC-COOKIE-1 X11 Xauthority data +15 string MIT-MAGIC-COOKIE-1 X11 Xauthority data +16 string MIT-MAGIC-COOKIE-1 X11 Xauthority data +17 string MIT-MAGIC-COOKIE-1 X11 Xauthority data +18 string MIT-MAGIC-COOKIE-1 X11 Xauthority data + +# From: Maxime Henrion +# PostgreSQL's custom dump format, Maxime Henrion +0 string PGDMP PostgreSQL custom database dump +>5 byte x - v%d +>6 byte x \b.%d +>5 beshort <0x101 \b-0 +>5 beshort >0x100 +>>7 byte x \b-%d + +# Type: Advanced Data Format (ADF) database +# URL: http://www.grc.nasa.gov/WWW/cgns/adf/ +# From: Nicolas Chauvat +#0 string @(#)ADF\ Database CGNS Advanced Data Format diff --git a/dest/share/magic/elf b/dest/share/magic/elf new file mode 100644 index 00000000000..1058ab4c225 --- /dev/null +++ b/dest/share/magic/elf @@ -0,0 +1,255 @@ +# $OpenBSD: elf,v 1.17 2009/04/24 18:54:34 chl Exp $ + +#------------------------------------------------------------------------------ +# elf: file(1) magic for ELF executables +# +# We have to check the byte order flag to see what byte order all the +# other stuff in the header is in. +# +# What're the correct byte orders for the nCUBE and the Fujitsu VPP500? +# +# updated by Daniel Quinlan (quinlan@yggdrasil.com) +0 string \177ELF ELF +>4 byte 0 invalid class +>4 byte 1 32-bit +>4 byte 2 64-bit +>5 byte 0 invalid byte order +>5 byte 1 LSB +>>16 leshort 0 no file type, +!:mime application/octet-stream +>>16 leshort 1 relocatable, +!:mime application/x-object +>>16 leshort 2 executable, +!:mime application/x-executable +>>16 leshort 3 shared object, +!:mime application/x-sharedlib +# Core handling from Peter Tobias +# corrections by Christian 'Dr. Disk' Hechelmann +>>16 leshort 4 core file +!:mime application/x-coredump +# Core file detection is not reliable. +#>>>(0x38+0xcc) string >\0 of '%s' +#>>>(0x38+0x10) lelong >0 (signal %d), +>>16 leshort &0xff00 processor-specific, +>>18 leshort 0 no machine, +>>18 leshort 1 AT&T WE32100 - invalid byte order, +>>18 leshort 2 SPARC - invalid byte order, +>>18 leshort 3 Intel 80386, +>>18 leshort 4 Motorola +>>>36 lelong &0x01000000 68000 - invalid byte order, +>>>36 lelong &0x00810000 CPU32 - invalid byte order, +>>>36 lelong 0 68020 - invalid byte order, +>>18 leshort 5 Motorola 88000 - invalid byte order, +>>18 leshort 6 Intel 80486, +>>18 leshort 7 Intel 80860, +# The official e_machine number for MIPS is now #8, regardless of endianness. +# The second number (#10) will be deprecated later. For now, we still +# say something if #10 is encountered, but only gory details for #8. +>>18 leshort 8 MIPS, +>>>36 lelong &0x20 N32 +>>18 leshort 10 MIPS, +>>>36 lelong &0x20 N32 +>>18 leshort 8 +# only for 32-bit +>>>4 byte 1 +>>>>36 lelong&0xf0000000 0x00000000 MIPS-I +>>>>36 lelong&0xf0000000 0x10000000 MIPS-II +>>>>36 lelong&0xf0000000 0x20000000 MIPS-III +>>>>36 lelong&0xf0000000 0x30000000 MIPS-IV +>>>>36 lelong&0xf0000000 0x40000000 MIPS-V +>>>>36 lelong&0xf0000000 0x50000000 MIPS32 +>>>>36 lelong&0xf0000000 0x60000000 MIPS64 +>>>>36 lelong&0xf0000000 0x70000000 MIPS32 rel2 +>>>>36 lelong&0xf0000000 0x80000000 MIPS64 rel2 +# only for 64-bit +>>>4 byte 2 +>>>>48 lelong&0xf0000000 0x00000000 MIPS-I +>>>>48 lelong&0xf0000000 0x10000000 MIPS-II +>>>>48 lelong&0xf0000000 0x20000000 MIPS-III +>>>>48 lelong&0xf0000000 0x30000000 MIPS-IV +>>>>48 lelong&0xf0000000 0x40000000 MIPS-V +>>>>48 lelong&0xf0000000 0x50000000 MIPS32 +>>>>48 lelong&0xf0000000 0x60000000 MIPS64 +>>>>48 lelong&0xf0000000 0x70000000 MIPS32 rel2 +>>>>48 lelong&0xf0000000 0x80000000 MIPS64 rel2 +>>18 leshort 9 Amdahl - invalid byte order, +>>18 leshort 10 MIPS (deprecated), +>>18 leshort 11 RS6000 - invalid byte order, +>>18 leshort 15 PA-RISC - invalid byte order, +>>>50 leshort 0x0214 2.0 +>>>48 leshort &0x0008 (LP64), +>>18 leshort 16 nCUBE, +>>18 leshort 17 Fujitsu VPP500, +>>18 leshort 18 SPARC32PLUS, +>>18 leshort 20 PowerPC, +>>18 leshort 22 IBM S/390, +>>18 leshort 36 NEC V800, +>>18 leshort 37 Fujitsu FR20, +>>18 leshort 38 TRW RH-32, +>>18 leshort 39 Motorola RCE, +>>18 leshort 40 ARM, +>>18 leshort 41 Alpha, +>>18 leshort 0xa390 IBM S/390 (obsolete), +>>18 leshort 42 Renesas SH, +>>18 leshort 43 SPARC V9 - invalid byte order, +>>18 leshort 44 Siemens Tricore Embedded Processor, +>>18 leshort 45 Argonaut RISC Core, Argonaut Technologies Inc., +>>18 leshort 46 Renesas H8/300, +>>18 leshort 47 Renesas H8/300H, +>>18 leshort 48 Renesas H8S, +>>18 leshort 49 Renesas H8/500, +>>18 leshort 50 IA-64, +>>18 leshort 51 Stanford MIPS-X, +>>18 leshort 52 Motorola Coldfire, +>>18 leshort 53 Motorola M68HC12, +>>18 leshort 54 Fujitsu MMA, +>>18 leshort 55 Siemens PCP, +>>18 leshort 56 Sony nCPU, +>>18 leshort 57 Denso NDR1, +>>18 leshort 58 Start*Core, +>>18 leshort 59 Toyota ME16, +>>18 leshort 60 ST100, +>>18 leshort 61 Tinyj emb., +>>18 leshort 62 x86-64, +>>18 leshort 63 Sony DSP, +>>18 leshort 66 FX66, +>>18 leshort 67 ST9+ 8/16 bit, +>>18 leshort 68 ST7 8 bit, +>>18 leshort 69 MC68HC16, +>>18 leshort 70 MC68HC11, +>>18 leshort 71 MC68HC08, +>>18 leshort 72 MC68HC05, +>>18 leshort 73 SGI SVx, +>>18 leshort 74 ST19 8 bit, +>>18 leshort 75 Digital VAX, +>>18 leshort 76 Axis cris, +>>18 leshort 77 Infineon 32-bit embedded, +>>18 leshort 78 Element 14 64-bit DSP, +>>18 leshort 79 LSI Logic 16-bit DSP, +>>18 leshort 80 MMIX, +>>18 leshort 81 Harvard machine-independent, +>>18 leshort 82 SiTera Prism, +>>18 leshort 83 Atmel AVR 8-bit, +>>18 leshort 84 Fujitsu FR30, +>>18 leshort 85 Mitsubishi D10V, +>>18 leshort 86 Mitsubishi D30V, +>>18 leshort 87 NEC v850, +>>18 leshort 88 Renesas M32R, +>>18 leshort 89 Matsushita MN10300, +>>18 leshort 90 Matsushita MN10200, +>>18 leshort 91 picoJava, +>>18 leshort 92 OpenRISC, +>>18 leshort 93 ARC Cores Tangent-A5, +>>18 leshort 0x3426 OpenRISC (obsolete), +>>18 leshort 0x8472 OpenRISC (obsolete), +>>18 leshort 94 Tensilica Xtensa, +>>18 leshort 97 NatSemi 32k, +>>18 leshort 106 Analog Devices Blackfin, +>>18 leshort 0x9026 Alpha (unofficial), +>>20 lelong 0 invalid version +>>20 lelong 1 version 1 +>>36 lelong 1 MathCoPro/FPU/MAU Required +>5 byte 2 MSB +>>16 beshort 0 no file type, +!:mime application/octet-stream +>>16 beshort 1 relocatable, +!:mime application/x-object +>>16 beshort 2 executable, +!:mime application/x-executable +>>16 beshort 3 shared object, +!:mime application/x-sharedlib +>>16 beshort 4 core file, +!:mime application/x-coredump +#>>>(0x38+0xcc) string >\0 of '%s' +#>>>(0x38+0x10) belong >0 (signal %d), +>>16 beshort &0xff00 processor-specific, +>>18 beshort 0 no machine, +>>18 beshort 1 AT&T WE32100, +>>18 beshort 2 SPARC, +>>18 beshort 3 Intel 80386 - invalid byte order, +>>18 beshort 4 Motorola +>>>36 belong &0x01000000 68000, +>>>36 belong &0x00810000 CPU32, +>>>36 belong 0 68020, +>>18 beshort 5 Motorola 88000, +>>18 beshort 6 Intel 80486 - invalid byte order, +>>18 beshort 7 Intel 80860, +# only for MIPS - see comment in little-endian section above. +>>18 beshort 8 MIPS, +>>>36 belong &0x20 N32 +>>18 beshort 10 MIPS, +>>>36 belong &0x20 N32 +>>18 beshort 8 +# only for 32-bit +>>>4 byte 1 +>>>>36 belong&0xf0000000 0x00000000 MIPS-I +>>>>36 belong&0xf0000000 0x10000000 MIPS-II +>>>>36 belong&0xf0000000 0x20000000 MIPS-III +>>>>36 belong&0xf0000000 0x30000000 MIPS-IV +>>>>36 belong&0xf0000000 0x40000000 MIPS-V +>>>>36 belong&0xf0000000 0x50000000 MIPS32 +>>>>36 belong&0xf0000000 0x60000000 MIPS64 +>>>>36 belong&0xf0000000 0x70000000 MIPS32 rel2 +>>>>36 belong&0xf0000000 0x80000000 MIPS64 rel2 +# only for 64-bit +>>>4 byte 2 +>>>>48 belong&0xf0000000 0x00000000 MIPS-I +>>>>48 belong&0xf0000000 0x10000000 MIPS-II +>>>>48 belong&0xf0000000 0x20000000 MIPS-III +>>>>48 belong&0xf0000000 0x30000000 MIPS-IV +>>>>48 belong&0xf0000000 0x40000000 MIPS-V +>>>>48 belong&0xf0000000 0x50000000 MIPS32 +>>>>48 belong&0xf0000000 0x60000000 MIPS64 +>>>>48 belong&0xf0000000 0x70000000 MIPS32 rel2 +>>>>48 belong&0xf0000000 0x80000000 MIPS64 rel2 +>>18 beshort 9 Amdahl, +>>18 beshort 10 MIPS (deprecated), +>>18 beshort 11 RS6000, +>>18 beshort 15 PA-RISC +>>>50 beshort 0x0214 2.0 +>>>48 beshort &0x0008 (LP64) +>>18 beshort 16 nCUBE, +>>18 beshort 17 Fujitsu VPP500, +>>18 beshort 18 SPARC32PLUS, +>>>36 belong&0xffff00 &0x000100 V8+ Required, +>>>36 belong&0xffff00 &0x000200 Sun UltraSPARC1 Extensions Required, +>>>36 belong&0xffff00 &0x000400 HaL R1 Extensions Required, +>>>36 belong&0xffff00 &0x000800 Sun UltraSPARC3 Extensions Required, +>>18 beshort 20 PowerPC or cisco 4500, +>>18 beshort 21 64-bit PowerPC or cisco 7500, +>>18 beshort 22 IBM S/390, +>>18 beshort 23 Cell SPU, +>>18 beshort 24 cisco SVIP, +>>18 beshort 25 cisco 7200, +>>18 beshort 36 NEC V800 or cisco 12000, +>>18 beshort 37 Fujitsu FR20, +>>18 beshort 38 TRW RH-32, +>>18 beshort 39 Motorola RCE, +>>18 beshort 40 ARM, +>>18 beshort 41 Alpha, +>>18 beshort 42 Renesas SH, +>>18 beshort 43 SPARC V9, +>>18 beshort 44 Siemens Tricore Embedded Processor, +>>18 beshort 45 Argonaut RISC Core, Argonaut Technologies Inc., +>>18 beshort 46 Renesas H8/300, +>>18 beshort 47 Renesas H8/300H, +>>18 beshort 48 Renesas H8S, +>>18 beshort 49 Renesas H8/500, +>>18 beshort 50 IA-64, +>>18 beshort 51 Stanford MIPS-X, +>>18 beshort 52 Motorola Coldfire, +>>18 beshort 53 Motorola M68HC12, +>>18 beshort 73 Cray NV1, +>>18 beshort 75 Digital VAX, +>>18 beshort 88 Renesas M32R, +>>18 leshort 92 OpenRISC, +>>18 leshort 0x3426 OpenRISC (obsolete), +>>18 leshort 0x8472 OpenRISC (obsolete), +>>18 beshort 94 Tensilica Xtensa, +>>18 beshort 97 NatSemi 32k, +>>18 beshort 0x18ad AVR32 (unofficial), +>>18 beshort 0x9026 Alpha (unofficial), +>>18 beshort 0xa390 IBM S/390 (obsolete), +>>20 belong 0 invalid version +>>20 belong 1 version 1 +>>36 belong 1 MathCoPro/FPU/MAU Required diff --git a/dest/share/magic/filesystems b/dest/share/magic/filesystems new file mode 100644 index 00000000000..7519b7d41d5 --- /dev/null +++ b/dest/share/magic/filesystems @@ -0,0 +1,1538 @@ +# $OpenBSD: filesystems,v 1.5 2009/12/23 02:24:39 krw Exp $ + +#------------------------------------------------------------------------------ +# filesystems: file(1) magic for different filesystems +# +#0 string \366\366\366\366 PC formatted floppy with no filesystem +## Sun disk labels +## From /usr/include/sun/dklabel.h: +#0774 beshort 0xdabe +## modified by Joerg Jenderek, because original test +## succeeds for Cabinet archive dao360.dl_ with negative blocks +#>0770 long >0 Sun disk label +#>>0 string x '%s +#>>>31 string >\0 \b%s +#>>>>63 string >\0 \b%s +#>>>>>95 string >\0 \b%s +#>>0 string x \b' +#>>0734 short >0 %d rpm, +#>>0736 short >0 %d phys cys, +#>>0740 short >0 %d alts/cyl, +#>>0746 short >0 %d interleave, +#>>0750 short >0 %d data cyls, +#>>0752 short >0 %d alt cyls, +#>>0754 short >0 %d heads/partition, +#>>0756 short >0 %d sectors/track, +#>>0764 long >0 start cyl %ld, +#>>0770 long x %ld blocks +## Is there a boot block written 1 sector in? +#>512 belong&077777777 0600407 \b, boot block present +## Joerg Jenderek: Smart Boot Manager backup file is 41 byte header + first sectors of disc +## (http://btmgr.sourceforge.net/docs/user-guide-3.html) +#0 string SBMBAKUP_ Smart Boot Manager backup file +#>9 string x \b, version %-5.5s +#>>14 string =_ +#>>>15 string x %-.1s +#>>>>16 string =_ \b. +#>>>>>17 string x \b%-.1s +#>>>>>>18 string =_ \b. +#>>>>>>>19 string x \b%-.1s +#>>>22 ubyte 0 +#>>>>21 ubyte x \b, from drive 0x%x +#>>>22 ubyte >0 +#>>>>21 string x \b, from drive %s + +# Joerg Jenderek +# DOS Emulator image is 128 byte, null right padded header + harddisc image +0 string DOSEMU\0 +>0x27E leshort 0xAA55 +#offset is 128 +>>19 ubyte 128 +>>>(19.b-1) ubyte 0x0 DOS Emulator image +>>>>7 ulelong >0 \b, %u heads +>>>>11 ulelong >0 \b, %d sectors/track +>>>>15 ulelong >0 \b, %d cylinders + +# updated by Joerg Jenderek at Sep 2007 +# only for sector sizes with 512 or more Bytes +0x1FE leshort 0xAA55 x86 boot sector +# to do also for sectors < than 512 Bytes and some other files, GRR +#30 search/481 \x55\xAA x86 boot sector +# not for BeOS floppy 1440k, MBRs +#(11.s-2) uleshort 0xAA55 x86 boot sector +>2 string OSBS \b, OS/BS MBR +# J\xf6rg Jenderek +>0x8C string Invalid\ partition\ table \b, MS-DOS MBR +# dr-dos with some upper-, lowercase variants +>0x9D string Invalid\ partition\ table$ +>>181 string No\ Operating\ System$ +>>>201 string Operating\ System\ load\ error$ \b, DR-DOS MBR, Version 7.01 to 7.03 +>0x9D string Invalid\ partition\ table$ +>>181 string No\ operating\ system$ +>>>201 string Operating\ system\ load\ error$ \b, DR-DOS MBR, Version 7.01 to 7.03 +>342 string Invalid\ partition\ table$ +>>366 string No\ operating\ system$ +>>>386 string Operating\ system\ load\ error$ \b, DR-DOS MBR, version 7.01 to 7.03 +>295 string NEWLDR\0 +>>302 string Bad\ PT\ $ +>>>310 string No\ OS\ $ +>>>>317 string OS\ load\ err$ +>>>>>329 string Moved\ or\ missing\ IBMBIO.LDR\n\r +>>>>>>358 string Press\ any\ key\ to\ continue.\n\r$ +>>>>>>>387 string Copyright\ (c)\ 1984,1998 +>>>>>>>>411 string Caldera\ Inc.\0 \b, DR-DOS MBR (IBMBIO.LDR) +>0x10F string Ung\201ltige\ Partitionstabelle \b, MS-DOS MBR, german version 4.10.1998, 4.10.2222 +>>0x1B8 ubelong >0 \b, Serial 0x%-.4x +>0x8B string Ung\201ltige\ Partitionstabelle \b, MS-DOS MBR, german version 5.00 to 4.00.950 +>271 string Invalid\ partition\ table\0 +>>295 string Error\ loading\ operating\ system\0 +>>>326 string Missing\ operating\ system\0 \b, mbr +# +>139 string Invalid\ partition\ table\0 +>>163 string Error\ loading\ operating\ system\0 +>>>194 string Missing\ operating\ system\0 \b, Microsoft Windows XP mbr +# http://www.heise.de/ct/05/09/006/ page 184 +#HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices\DosDevices\?:=Serial4Bytes+8Bytes +>>>>0x1B8 ulelong >0 \b,Serial 0x%-.4x +>300 string Invalid\ partition\ table\0 +>>324 string Error\ loading\ operating\ system\0 +>>>355 string Missing\ operating\ system\0 \b, Microsoft Windows XP MBR +#??>>>389 string Invalid\ system\ disk +>>>>0x1B8 ulelong >0 \b, Serial 0x%-.4x +>300 string Ung\201ltige\ Partitionstabelle +#split string to avoid error: String too long +>>328 string Fehler\ beim\ Laden\ +>>>346 string des\ Betriebssystems +>>>>366 string Betriebssystem\ nicht\ vorhanden \b, Microsoft Windows XP MBR (german) +>>>>>0x1B8 ulelong >0 \b, Serial 0x%-.4x +>0x145 string Default:\ F \b, FREE-DOS MBR +>64 string no\ active\ partition\ found +>>96 string read\ error\ while\ reading\ drive \b, FREE-DOS Beta 0.9 MBR +>271 string Operating\ system\ loading +>>296 string error\r \b, SYSLINUX MBR (2.10) +# http://www.acronis.de/ +>362 string MBR\ Error\ \0\r +>>376 string ress\ any\ key\ to\ +>>>392 string boot\ from\ floppy...\0 \b, Acronis MBR +# added by Joerg Jenderek +# http://www.visopsys.org/ +# http://partitionlogic.org.uk/ +>309 string No\ bootable\ partition\ found\r +>>339 string I/O\ Error\ reading\ boot\ sector\r \b, Visopsys MBR +>349 string No\ bootable\ partition\ found\r +>>379 string I/O\ Error\ reading\ boot\ sector\r \b, simple Visopsys MBR +# bootloader, bootmanager +>0x40 string SBML +# label with 11 characters of FAT 12 bit filesystem +>>43 string SMART\ BTMGR +>>>430 string SBMK\ Bad!\r +>>>>3 string SBM \b, Smart Boot Manager +>>>>>6 string >\0 \b, version %s +>382 string XOSLLOADXCF \b, eXtended Operating System Loader +>6 string LILO \b, LInux i386 boot LOader +>>120 string LILO \b, version 22.3.4 SuSe +>>172 string LILO \b, version 22.5.8 Debian +# updated by Joerg Jenderek +# variables according to grub-0.97/stage1/stage1.S or +# http://www.gnu.org/software/grub/manual/grub.html#Embedded-data +# usual values are marked with comments to get only informations of strange GRUB loaders +>0 ulelong 0x009048EB +>>0x41 ubyte <2 +>>>0x3E ubyte >2 \b; GRand Unified Bootloader +# 0x3 for 0.5.95,0.93,0.94,0.96 0x4 for 1.90 +>>>>0x3E ubyte x \b, stage1 version 0x%x +#If it is 0xFF, use a drive passed by BIOS +>>>>0x40 ubyte <0xFF \b, boot drive 0x%x +# in most case 0,1,0x2e for GRUB 0.5.95 +>>>>0x41 ubyte >0 \b, LBA flag 0x%x +>>>>0x42 uleshort <0x8000 \b, stage2 address 0x%x +#>>>>0x42 uleshort =0x8000 \b, stage2 address 0x%x (usual) +>>>>0x42 uleshort >0x8000 \b, stage2 address 0x%x +#>>>>0x44 ulelong =1 \b, 1st sector stage2 0x%x (default) +>>>>0x44 ulelong >1 \b, 1st sector stage2 0x%x +>>>>0x48 uleshort <0x800 \b, stage2 segment 0x%x +#>>>>0x48 uleshort =0x800 \b, stage2 segment 0x%x (usual) +>>>>0x48 uleshort >0x800 \b, stage2 segment 0x%x +>>>>402 string Geom\0Hard\ Disk\0Read\0\ Error\0 +>>>>>394 string stage1 \b, GRUB version 0.5.95 +>>>>382 string Geom\0Hard\ Disk\0Read\0\ Error\0 +>>>>>376 string GRUB\ \0 \b, GRUB version 0.93 or 1.94 +>>>>383 string Geom\0Hard\ Disk\0Read\0\ Error\0 +>>>>>377 string GRUB\ \0 \b, GRUB version 0.94 +>>>>385 string Geom\0Hard\ Disk\0Read\0\ Error\0 +>>>>>379 string GRUB\ \0 \b, GRUB version 0.95 or 0.96 +>>>>391 string Geom\0Hard\ Disk\0Read\0\ Error\0 +>>>>>385 string GRUB\ \0 \b, GRUB version 0.97 +#unknown version +>>>343 string Geom\0Read\0\ Error\0 +>>>>321 string Loading\ stage1.5 \b, GRUB version x.y +>>>380 string Geom\0Hard\ Disk\0Read\0\ Error\0 +>>>>374 string GRUB\ \0 \b, GRUB version n.m +# http://syslinux.zytor.com/ +>478 string Boot\ failed\r +>>495 string LDLINUX\ SYS \b, SYSLINUX bootloader (1.62) +>480 string Boot\ failed\r +>>495 string LDLINUX\ SYS \b, SYSLINUX bootloader (2.06 or 2.11) +>484 string Boot\ error\r \b, SYSLINUX bootloader (3.11) +>395 string chksum\0\ ERROR!\0 \b, Gujin bootloader +# http://www.bcdwb.de/bcdw/index_e.htm +>3 string BCDL +>>498 string BCDL\ \ \ \ BIN \b, Bootable CD Loader (1.50Z) +# mbr partition table entries +# OEM-ID not Microsoft,SYSLINUX,or MTOOLs +>3 string !MS +>>3 string !SYSLINUX +>>>3 string !MTOOL +# not FAT (32 bit) +>>>>82 string !FAT32 +#not IO.SYS +>>>>>472 string !IO\ \ \ \ \ \ SYS +>>>>>>480 string !IO\ \ \ \ \ \ SYS +#not Linux kernel +>>>>>>>514 string !HdrS +#not BeOS +>>>>>>>>422 string !Be\ Boot\ Loader +# active flag 0 or 0x80 and type > 0 +>>>>>>>>>446 ubyte <0x81 +>>>>>>>>>>446 ubyte&0x7F 0 +>>>>>>>>>>>450 ubyte >0 \b; partition 1: ID=0x%x +>>>>>>>>>>>>446 ubyte 0x80 \b, active +>>>>>>>>>>>>447 ubyte x \b, starthead %u +#>>>>>>>>>>>>448 ubyte x \b, start C_S: 0x%x +#>>>>>>>>>>>>448 ubeshort&1023 x \b, startcylinder? %d +>>>>>>>>>>>>454 ulelong x \b, startsector %u +>>>>>>>>>>>>458 ulelong x \b, %u sectors +# +>>>>>>>>>462 ubyte <0x81 +>>>>>>>>>>462 ubyte&0x7F 0 +>>>>>>>>>>>466 ubyte >0 \b; partition 2: ID=0x%x +>>>>>>>>>>>>462 ubyte 0x80 \b, active +>>>>>>>>>>>>463 ubyte x \b, starthead %u +#>>>>>>>>>>>>464 ubyte x \b, start C_S: 0x%x +#>>>>>>>>>>>>464 ubeshort&1023 x \b, startcylinder? %d +>>>>>>>>>>>>470 ulelong x \b, startsector %u +>>>>>>>>>>>>474 ulelong x \b, %u sectors +# +>>>>>>>>>478 ubyte <0x81 +>>>>>>>>>>478 ubyte&0x7F 0 +>>>>>>>>>>>482 ubyte >0 \b; partition 3: ID=0x%x +>>>>>>>>>>>>478 ubyte 0x80 \b, active +>>>>>>>>>>>>479 ubyte x \b, starthead %u +#>>>>>>>>>>>>480 ubyte x \b, start C_S: 0x%x +#>>>>>>>>>>>>481 ubyte x \b, start C2S: 0x%x +#>>>>>>>>>>>>480 ubeshort&1023 x \b, startcylinder? %d +>>>>>>>>>>>>486 ulelong x \b, startsector %u +>>>>>>>>>>>>490 ulelong x \b, %u sectors +# +>>>>>>>>>494 ubyte <0x81 +>>>>>>>>>>494 ubyte&0x7F 0 +>>>>>>>>>>>498 ubyte >0 \b; partition 4: ID=0x%x +>>>>>>>>>>>>494 ubyte 0x80 \b, active +>>>>>>>>>>>>495 ubyte x \b, starthead %u +#>>>>>>>>>>>>496 ubyte x \b, start C_S: 0x%x +#>>>>>>>>>>>>496 ubeshort&1023 x \b, startcylinder? %d +>>>>>>>>>>>>502 ulelong x \b, startsector %u +>>>>>>>>>>>>506 ulelong x \b, %u sectors +# mbr partition table entries end +# http://www.acronis.de/ +#FAT label=ACRONIS\ SZ +#OEM-ID=BOOTWIZ0 +>442 string Non-system\ disk,\ +>>459 string press\ any\ key...\x7\0 \b, Acronis Startup Recovery Loader +# DOS names like F11.SYS are 8 right space padded bytes+3 bytes +>>>477 ubyte&0xDF >0 +>>>>477 string x \b %-.3s +>>>>>480 ubyte&0xDF >0 +>>>>>>480 string x \b%-.5s +>>>>485 ubyte&0xDF >0 +>>>>>485 string x \b.%-.3s +# +>185 string FDBOOT\ Version\ +>>204 string \rNo\ Systemdisk.\ +>>>220 string Booting\ from\ harddisk.\n\r +>>>245 string Cannot\ load\ from\ harddisk.\n\r +>>>>273 string Insert\ Systemdisk\ +>>>>>291 string and\ press\ any\ key.\n\r \b, FDBOOT harddisk Bootloader +>>>>>>200 string >\0 \b, version %-3s +>242 string Bootsector\ from\ C.H.\ Hochst\204 +>>278 string No\ Systemdisk.\ +>>>293 string Booting\ from\ harddisk.\n\r +>>>441 string Cannot\ load\ from\ harddisk.\n\r +>>>>469 string Insert\ Systemdisk\ +>>>>>487 string and\ press\ any\ key.\n\r \b, WinImage harddisk Bootloader +>>>>>>209 string >\0 \b, version %-4.4s +>(1.b+2) ubyte 0xe +>>(1.b+3) ubyte 0x1f +>>>(1.b+4) ubyte 0xbe +>>>>(1.b+5) ubyte 0x77 +>>>>(1.b+6) ubyte 0x7c +>>>>>(1.b+7) ubyte 0xac +>>>>>>(1.b+8) ubyte 0x22 +>>>>>>>(1.b+9) ubyte 0xc0 +>>>>>>>>(1.b+10) ubyte 0x74 +>>>>>>>>>(1.b+11) ubyte 0xb +>>>>>>>>>>(1.b+12) ubyte 0x56 +>>>>>>>>>>(1.b+13) ubyte 0xb4 \b, mkdosfs boot message display +>103 string This\ is\ not\ a\ bootable\ disk.\ +>>132 string Please\ insert\ a\ bootable\ +>>>157 string floppy\ and\r\n +>>>>169 string press\ any\ key\ to\ try\ again...\r \b, FREE-DOS message display +# +>66 string Solaris\ Boot\ Sector +>>99 string Incomplete\ MDBoot\ load. +>>>89 string Version \b, Sun Solaris Bootloader +>>>>97 byte x version %c +# +>408 string OS/2\ !!\ SYS01475\r\0 +>>429 string OS/2\ !!\ SYS02025\r\0 +>>>450 string OS/2\ !!\ SYS02027\r\0 +>>>469 string OS2BOOT\ \ \ \ \b, IBM OS/2 Warp bootloader +# +>409 string OS/2\ !!\ SYS01475\r\0 +>>430 string OS/2\ !!\ SYS02025\r\0 +>>>451 string OS/2\ !!\ SYS02027\r\0 +>>>470 string OS2BOOT\ \ \ \ \b, IBM OS/2 Warp Bootloader +>112 string This\ disk\ is\ not\ bootable\r +>>142 string If\ you\ wish\ to\ make\ it\ bootable +>>>176 string run\ the\ DOS\ program\ SYS\ +>>>200 string after\ the\r +>>>>216 string system\ has\ been\ loaded\r\n +>>>>>242 string Please\ insert\ a\ DOS\ diskette\ +>>>>>271 string into\r\n\ the\ drive\ and\ +>>>>>>292 string strike\ any\ key...\0 \b, IBM OS/2 Warp message display +# XP +>430 string NTLDR\ is\ missing\xFF\r\n +>>449 string Disk\ error\xFF\r\n +>>>462 string Press\ any\ key\ to\ restart\r \b, Microsoft Windows XP Bootloader +# DOS names like NTLDR,CMLDR,$LDR$ are 8 right space padded bytes+3 bytes +>>>>417 ubyte&0xDF >0 +>>>>>417 string x %-.5s +>>>>>>422 ubyte&0xDF >0 +>>>>>>>422 string x \b%-.3s +>>>>>425 ubyte&0xDF >0 +>>>>>>425 string >\ \b.%-.3s +# +>>>>371 ubyte >0x20 +>>>>>368 ubyte&0xDF >0 +>>>>>>368 string x %-.5s +>>>>>>>373 ubyte&0xDF >0 +>>>>>>>>373 string x \b%-.3s +>>>>>>376 ubyte&0xDF >0 +>>>>>>>376 string x \b.%-.3s +# +>430 string NTLDR\ nicht\ gefunden\xFF\r\n +>>453 string Datentr\204gerfehler\xFF\r\n +>>>473 string Neustart\ mit\ beliebiger\ Taste\r \b, Microsoft Windows XP Bootloader (german) +>>>>417 ubyte&0xDF >0 +>>>>>417 string x %-.5s +>>>>>>422 ubyte&0xDF >0 +>>>>>>>422 string x \b%-.3s +>>>>>425 ubyte&0xDF >0 +>>>>>>425 string >\ \b.%-.3s +# offset variant +>>>>379 string \0 +>>>>>368 ubyte&0xDF >0 +>>>>>>368 string x %-.5s +>>>>>>>373 ubyte&0xDF >0 +>>>>>>>>373 string x \b%-.3s +# +>430 string NTLDR\ fehlt\xFF\r\n +>>444 string Datentr\204gerfehler\xFF\r\n +>>>464 string Neustart\ mit\ beliebiger\ Taste\r \b, Microsoft Windows XP Bootloader (2.german) +>>>>417 ubyte&0xDF >0 +>>>>>417 string x %-.5s +>>>>>>422 ubyte&0xDF >0 +>>>>>>>422 string x \b%-.3s +>>>>>425 ubyte&0xDF >0 +>>>>>>425 string >\ \b.%-.3s +# variant +>>>>371 ubyte >0x20 +>>>>>368 ubyte&0xDF >0 +>>>>>>368 string x %-.5s +>>>>>>>373 ubyte&0xDF >0 +>>>>>>>>373 string x \b%-.3s +>>>>>>376 ubyte&0xDF >0 +>>>>>>>376 string x \b.%-.3s +# +>430 string NTLDR\ fehlt\xFF\r\n +>>444 string Medienfehler\xFF\r\n +>>>459 string Neustart:\ Taste\ dr\201cken\r \b, Microsoft Windows XP Bootloader (3.german) +>>>>371 ubyte >0x20 +>>>>>368 ubyte&0xDF >0 +>>>>>>368 string x %-.5s +>>>>>>>373 ubyte&0xDF >0 +>>>>>>>>373 string x \b%-.3s +>>>>>>376 ubyte&0xDF >0 +>>>>>>>376 string x \b.%-.3s +# variant +>>>>417 ubyte&0xDF >0 +>>>>>417 string x %-.5s +>>>>>>422 ubyte&0xDF >0 +>>>>>>>422 string x \b%-.3s +>>>>>425 ubyte&0xDF >0 +>>>>>>425 string >\ \b.%-.3s +# +>430 string Datentr\204ger\ entfernen\xFF\r\n +>>454 string Medienfehler\xFF\r\n +>>>469 string Neustart:\ Taste\ dr\201cken\r \b, Microsoft Windows XP Bootloader (4.german) +>>>>368 ubyte&0xDF >0 +>>>>>368 string x %-.5s +>>>>>>373 ubyte&0xDF >0 +>>>>>>>373 string x \b%-.3s +>>>>>376 ubyte&0xDF >0 +>>>>>>376 string x \b.%-.3s +#>3 string NTFS\ \ \ \ +>389 string Fehler\ beim\ Lesen\ +>>407 string des\ Datentr\204gers +>>>426 string NTLDR\ fehlt +>>>>440 string NTLDR\ ist\ komprimiert +>>>>>464 string Neustart\ mit\ Strg+Alt+Entf\r \b, Microsoft Windows XP Bootloader NTFS (german) +#>3 string NTFS\ \ \ \ +>313 string A\ disk\ read\ error\ occurred.\r +>>345 string A\ kernel\ file\ is\ missing\ +>>>370 string from\ the\ disk.\r +>>>>484 string NTLDR\ is\ compressed +>>>>>429 string Insert\ a\ system\ diskette\ +>>>>>>454 string and\ restart\r\nthe\ system.\r \b, Microsoft Windows XP Bootloader NTFS +# DOS loader variants different languages,offsets +>472 ubyte&0xDF >0 +>>389 string Invalid\ system\ disk\xFF\r\n +>>>411 string Disk\ I/O\ error +>>>>428 string Replace\ the\ disk,\ and\ +>>>>>455 string press\ any\ key \b, Microsoft Windows 98 Bootloader +#IO.SYS +>>>>>>472 ubyte&0xDF >0 +>>>>>>>472 string x \b %-.2s +>>>>>>>>474 ubyte&0xDF >0 +>>>>>>>>>474 string x \b%-.5s +>>>>>>>>>>479 ubyte&0xDF >0 +>>>>>>>>>>>479 string x \b%-.1s +>>>>>>>480 ubyte&0xDF >0 +>>>>>>>>480 string x \b.%-.3s +#MSDOS.SYS +>>>>>>>483 ubyte&0xDF >0 \b+ +>>>>>>>>483 string x \b%-.5s +>>>>>>>>>488 ubyte&0xDF >0 +>>>>>>>>>>488 string x \b%-.3s +>>>>>>>>491 ubyte&0xDF >0 +>>>>>>>>>491 string x \b.%-.3s +# +>>390 string Invalid\ system\ disk\xFF\r\n +>>>412 string Disk\ I/O\ error\xFF\r\n +>>>>429 string Replace\ the\ disk,\ and\ +>>>>>451 string then\ press\ any\ key\r \b, Microsoft Windows 98 Bootloader +>>388 string Ungueltiges\ System\ \xFF\r\n +>>>410 string E/A-Fehler\ \ \ \ \xFF\r\n +>>>>427 string Datentraeger\ wechseln\ und\ +>>>>>453 string Taste\ druecken\r \b, Microsoft Windows 95/98/ME Bootloader (german) +#WINBOOT.SYS only not spaces (0xDF) +>>>>>>497 ubyte&0xDF >0 +>>>>>>>497 string x %-.5s +>>>>>>>>502 ubyte&0xDF >0 +>>>>>>>>>502 string x \b%-.1s +>>>>>>>>>>503 ubyte&0xDF >0 +>>>>>>>>>>>503 string x \b%-.1s +>>>>>>>>>>>>504 ubyte&0xDF >0 +>>>>>>>>>>>>>504 string x \b%-.1s +>>>>>>505 ubyte&0xDF >0 +>>>>>>>505 string x \b.%-.3s +#IO.SYS +>>>>>>472 ubyte&0xDF >0 or +>>>>>>>472 string x \b %-.2s +>>>>>>>>474 ubyte&0xDF >0 +>>>>>>>>>474 string x \b%-.5s +>>>>>>>>>>479 ubyte&0xDF >0 +>>>>>>>>>>>479 string x \b%-.1s +>>>>>>>480 ubyte&0xDF >0 +>>>>>>>>480 string x \b.%-.3s +#MSDOS.SYS +>>>>>>>483 ubyte&0xDF >0 \b+ +>>>>>>>>483 string x \b%-.5s +>>>>>>>>>488 ubyte&0xDF >0 +>>>>>>>>>>488 string x \b%-.3s +>>>>>>>>491 ubyte&0xDF >0 +>>>>>>>>>491 string x \b.%-.3s +# +>>390 string Ungueltiges\ System\ \xFF\r\n +>>>412 string E/A-Fehler\ \ \ \ \xFF\r\n +>>>>429 string Datentraeger\ wechseln\ und\ +>>>>>455 string Taste\ druecken\r \b, Microsoft Windows 95/98/ME Bootloader (German) +#WINBOOT.SYS only not spaces (0xDF) +>>>>>>497 ubyte&0xDF >0 +>>>>>>>497 string x %-.7s +>>>>>>>>504 ubyte&0xDF >0 +>>>>>>>>>504 string x \b%-.1s +>>>>>>505 ubyte&0xDF >0 +>>>>>>>505 string x \b.%-.3s +#IO.SYS +>>>>>>472 ubyte&0xDF >0 or +>>>>>>>472 string x \b %-.2s +>>>>>>>>474 ubyte&0xDF >0 +>>>>>>>>>474 string x \b%-.6s +>>>>>>>480 ubyte&0xDF >0 +>>>>>>>>480 string x \b.%-.3s +#MSDOS.SYS +>>>>>>>483 ubyte&0xDF >0 \b+ +>>>>>>>>483 string x \b%-.5s +>>>>>>>>>488 ubyte&0xDF >0 +>>>>>>>>>>488 string x \b%-.3s +>>>>>>>>491 ubyte&0xDF >0 +>>>>>>>>>491 string x \b.%-.3s +# +>>389 string Ungueltiges\ System\ \xFF\r\n +>>>411 string E/A-Fehler\ \ \ \ \xFF\r\n +>>>>428 string Datentraeger\ wechseln\ und\ +>>>>>454 string Taste\ druecken\r \b, Microsoft Windows 95/98/ME Bootloader (GERMAN) +# DOS names like IO.SYS,WINBOOT.SYS,MSDOS.SYS,WINBOOT.INI are 8 right space padded bytes+3 bytes +>>>>>>472 string x %-.2s +>>>>>>>474 ubyte&0xDF >0 +>>>>>>>>474 string x \b%-.5s +>>>>>>>>479 ubyte&0xDF >0 +>>>>>>>>>479 string x \b%-.1s +>>>>>>480 ubyte&0xDF >0 +>>>>>>>480 string x \b.%-.3s +>>>>>>483 ubyte&0xDF >0 \b+ +>>>>>>>483 string x \b%-.5s +>>>>>>>488 ubyte&0xDF >0 +>>>>>>>>488 string x \b%-.2s +>>>>>>>>490 ubyte&0xDF >0 +>>>>>>>>>490 string x \b%-.1s +>>>>>>>491 ubyte&0xDF >0 +>>>>>>>>491 string x \b.%-.3s +>479 ubyte&0xDF >0 +>>416 string Kein\ System\ oder\ +>>>433 string Laufwerksfehler +>>>>450 string Wechseln\ und\ Taste\ dr\201cken \b, Microsoft DOS Bootloader (german) +#IO.SYS +>>>>>479 string x \b %-.2s +>>>>>>481 ubyte&0xDF >0 +>>>>>>>481 string x \b%-.6s +>>>>>487 ubyte&0xDF >0 +>>>>>>487 string x \b.%-.3s +#MSDOS.SYS +>>>>>>490 ubyte&0xDF >0 \b+ +>>>>>>>490 string x \b%-.5s +>>>>>>>>495 ubyte&0xDF >0 +>>>>>>>>>495 string x \b%-.3s +>>>>>>>498 ubyte&0xDF >0 +>>>>>>>>498 string x \b.%-.3s +# +>376 search/41 Non-System\ disk\ or\ +>>395 search/41 disk\ error\r +>>>407 search/41 Replace\ and\ +>>>>419 search/41 press\ \b, +>>>>419 search/41 strike\ \b, old +>>>>426 search/41 any\ key\ when\ ready\r MS or PC-DOS bootloader +#449 Disk\ Boot\ failure\r MS 3.21 +#466 Boot\ Failure\r MS 3.30 +>>>>>468 search/18 \0 +#IO.SYS,IBMBIO.COM +>>>>>>&0 string x \b %-.2s +>>>>>>>&-20 ubyte&0xDF >0 +>>>>>>>>&-1 string x \b%-.4s +>>>>>>>>>&-16 ubyte&0xDF >0 +>>>>>>>>>>&-1 string x \b%-.2s +>>>>>>&8 ubyte&0xDF >0 \b. +>>>>>>>&-1 string x \b%-.3s +#MSDOS.SYS,IBMDOS.COM +>>>>>>&11 ubyte&0xDF >0 \b+ +>>>>>>>&-1 string x \b%-.5s +>>>>>>>>&-6 ubyte&0xDF >0 +>>>>>>>>>&-1 string x \b%-.1s +>>>>>>>>>>&-5 ubyte&0xDF >0 +>>>>>>>>>>>&-1 string x \b%-.2s +>>>>>>>&7 ubyte&0xDF >0 \b. +>>>>>>>>&-1 string x \b%-.3s +>441 string Cannot\ load\ from\ harddisk.\n\r +>>469 string Insert\ Systemdisk\ +>>>487 string and\ press\ any\ key.\n\r \b, MS (2.11) DOS bootloader +#>43 string \224R-LOADER\ \ SYS =label +>54 string SYS +>>324 string VASKK +>>>495 string NEWLDR\0 \b, DR-DOS Bootloader (LOADER.SYS) +# +>98 string Press\ a\ key\ to\ retry\0\r +>>120 string Cannot\ find\ file\ \0\r +>>>139 string Disk\ read\ error\0\r +>>>>156 string Loading\ ...\0 \b, DR-DOS (3.41) Bootloader +#DRBIOS.SYS +>>>>>44 ubyte&0xDF >0 +>>>>>>44 string x \b %-.6s +>>>>>>>50 ubyte&0xDF >0 +>>>>>>>>50 string x \b%-.2s +>>>>>>52 ubyte&0xDF >0 +>>>>>>>52 string x \b.%-.3s +# +>70 string IBMBIO\ \ COM +>>472 string Cannot\ load\ DOS!\ +>>>489 string Any\ key\ to\ retry \b, DR-DOS Bootloader +>>471 string Cannot\ load\ DOS\ +>>487 string press\ key\ to\ retry \b, Open-DOS Bootloader +>444 string KERNEL\ \ SYS +>>314 string BOOT\ error! \b, FREE-DOS Bootloader +>499 string KERNEL\ \ SYS +>>305 string BOOT\ err!\0 \b, Free-DOS Bootloader +>449 string KERNEL\ \ SYS +>>319 string BOOT\ error! \b, FREE-DOS 0.5 Bootloader +>125 string Loading\ FreeDOS...\r +>>311 string BOOT\ error!\r \b, FREE-DOS bootloader +>>>441 ubyte&0xDF >0 +>>>>441 string x \b %-.6s +>>>>>447 ubyte&0xDF >0 +>>>>>>447 string x \b%-.1s +>>>>>>>448 ubyte&0xDF >0 +>>>>>>>>448 string x \b%-.1s +>>>>449 ubyte&0xDF >0 +>>>>>449 string x \b.%-.3s +>124 string FreeDOS\0 +>>331 string \ err\0 \b, FREE-DOS BETa 0.9 Bootloader +# DOS names like KERNEL.SYS,KERNEL16.SYS,KERNEL32.SYS,METAKERN.SYS are 8 right space padded bytes+3 bytes +>>>497 ubyte&0xDF >0 +>>>>497 string x \b %-.6s +>>>>>503 ubyte&0xDF >0 +>>>>>>503 string x \b%-.1s +>>>>>>>504 ubyte&0xDF >0 +>>>>>>>>504 string x \b%-.1s +>>>>505 ubyte&0xDF >0 +>>>>>505 string x \b.%-.3s +>>333 string \ err\0 \b, FREE-DOS BEta 0.9 Bootloader +>>>497 ubyte&0xDF >0 +>>>>497 string x \b %-.6s +>>>>>503 ubyte&0xDF >0 +>>>>>>503 string x \b%-.1s +>>>>>>>504 ubyte&0xDF >0 +>>>>>>>>504 string x \b%-.1s +>>>>505 ubyte&0xDF >0 +>>>>>505 string x \b.%-.3s +>>334 string \ err\0 \b, FREE-DOS Beta 0.9 Bootloader +>>>497 ubyte&0xDF >0 +>>>>497 string x \b %-.6s +>>>>>503 ubyte&0xDF >0 +>>>>>>503 string x \b%-.1s +>>>>>>>504 ubyte&0xDF >0 +>>>>>>>>504 string x \b%-.1s +>>>>505 ubyte&0xDF >0 +>>>>>505 string x \b.%-.3s +>336 string Error!\ +>>343 string Hit\ a\ key\ to\ reboot. \b, FREE-DOS Beta 0.9sr1 Bootloader +>>>497 ubyte&0xDF >0 +>>>>497 string x \b %-.6s +>>>>>503 ubyte&0xDF >0 +>>>>>>503 string x \b%-.1s +>>>>>>>504 ubyte&0xDF >0 +>>>>>>>>504 string x \b%-.1s +>>>>505 ubyte&0xDF >0 +>>>>>505 string x \b.%-.3s +# added by Joerg Jenderek +# http://www.visopsys.org/ +# http://partitionlogic.org.uk/ +# OEM-ID=Visopsys +>478 ulelong 0 +>>(1.b+326) string I/O\ Error\ reading\ +>>>(1.b+344) string Visopsys\ loader\r +>>>>(1.b+361) string Press\ any\ key\ to\ continue.\r \b, Visopsys loader +# http://alexfru.chat.ru/epm.html#bootprog +>494 ubyte >0x4D +>>495 string >E +>>>495 string >>>3 string BootProg +# It just looks for a program file name at the root directory +# and loads corresponding file with following execution. +# DOS names like STARTUP.BIN,STARTUPC.COM,STARTUPE.EXE are 8 right space padded bytes+3 bytes +>>>>499 ubyte&0xDF >0 \b, COM/EXE Bootloader +>>>>>499 string x \b %-.1s +>>>>>>500 ubyte&0xDF >0 +>>>>>>>500 string x \b%-.1s +>>>>>>>>501 ubyte&0xDF >0 +>>>>>>>>>501 string x \b%-.1s +>>>>>>>>>>502 ubyte&0xDF >0 +>>>>>>>>>>>502 string x \b%-.1s +>>>>>>>>>>>>503 ubyte&0xDF >0 +>>>>>>>>>>>>>503 string x \b%-.1s +>>>>>>>>>>>>>>504 ubyte&0xDF >0 +>>>>>>>>>>>>>>>504 string x \b%-.1s +>>>>>>>>>>>>>>>>505 ubyte&0xDF >0 +>>>>>>>>>>>>>>>>>505 string x \b%-.1s +>>>>>>>>>>>>>>>>>>506 ubyte&0xDF >0 +>>>>>>>>>>>>>>>>>>>506 string x \b%-.1s +#name extension +>>>>>507 ubyte&0xDF >0 \b. +>>>>>>507 string x \b%-.1s +>>>>>>>508 ubyte&0xDF >0 +>>>>>>>>508 string x \b%-.1s +>>>>>>>>>509 ubyte&0xDF >0 +>>>>>>>>>>509 string x \b%-.1s +#If the boot sector fails to read any other sector, +#it prints a very short message ("RE") to the screen and hangs the computer. +#If the boot sector fails to find needed program in the root directory, +#it also hangs with another message ("NF"). +>>>>>492 string RENF \b, FAT (12 bit) +>>>>>495 string RENF \b, FAT (16 bit) +# http://alexfru.chat.ru/epm.html#bootprog +>494 ubyte >0x4D +>>495 string >E +>>>495 string >>>3 string BootProg +# It just looks for a program file name at the root directory +# and loads corresponding file with following execution. +# DOS names like STARTUP.BIN,STARTUPC.COM,STARTUPE.EXE are 8 right space padded bytes+3 bytes +>>>>499 ubyte&0xDF >0 \b, COM/EXE Bootloader +>>>>>499 string x \b %-.1s +>>>>>>500 ubyte&0xDF >0 +>>>>>>>500 string x \b%-.1s +>>>>>>>>501 ubyte&0xDF >0 +>>>>>>>>>501 string x \b%-.1s +>>>>>>>>>>502 ubyte&0xDF >0 +>>>>>>>>>>>502 string x \b%-.1s +>>>>>>>>>>>>503 ubyte&0xDF >0 +>>>>>>>>>>>>>503 string x \b%-.1s +>>>>>>>>>>>>>>504 ubyte&0xDF >0 +>>>>>>>>>>>>>>>504 string x \b%-.1s +>>>>>>>>>>>>>>>>505 ubyte&0xDF >0 +>>>>>>>>>>>>>>>>>505 string x \b%-.1s +>>>>>>>>>>>>>>>>>>506 ubyte&0xDF >0 +>>>>>>>>>>>>>>>>>>>506 string x \b%-.1s +#name extension +>>>>>507 ubyte&0xDF >0 \b. +>>>>>>507 string x \b%-.1s +>>>>>>>508 ubyte&0xDF >0 +>>>>>>>>508 string x \b%-.1s +>>>>>>>>>509 ubyte&0xDF >0 +>>>>>>>>>>509 string x \b%-.1s +#If the boot sector fails to read any other sector, +#it prints a very short message ("RE") to the screen and hangs the computer. +#If the boot sector fails to find needed program in the root directory, +#it also hangs with another message ("NF"). +>>>>>492 string RENF \b, FAT (12 bit) +>>>>>495 string RENF \b, FAT (16 bit) +# added by Joerg Jenderek +# http://syslinux.zytor.com/iso.php +0 ulelong 0x7c40eafa isolinux Loader +# http://syslinux.zytor.com/pxe.php +0 ulelong 0x007c05ea pxelinux Loader +0 ulelong 0x60669c66 pxelinux Loader +# loader end +# updated by Joerg Jenderek at Sep 2007 +>3 ubyte 0 +#no active flag +>>446 ubyte 0 +# partition 1 not empty +>>>450 ubyte >0 +# partitions 3,4 empty +>>>>482 ubyte 0 +>>>>>498 ubyte 0 +# partition 2 ID=0,5,15 +>>>>>>466 ubyte <0x10 +>>>>>>>466 ubyte 0x05 \b, extended partition table +>>>>>>>466 ubyte 0x0F \b, extended partition table (LBA) +>>>>>>>466 ubyte 0x0 \b, extended partition table (last) +# JuMP short bootcodeoffset NOP assembler instructions will usually be EB xx 90 +# http://mirror.href.com/thestarman/asm/2bytejumps.htmm#FWD +# older drives may use Near JuMP instruction E9 xx xx +>0 lelong&0x009000EB 0x009000EB +>0 lelong&0x000000E9 0x000000E9 +# maximal short forward jump is 07fx +>1 ubyte <0xff \b, code offset 0x%x +# mtools-3.9.8/msdos.h +# usual values are marked with comments to get only informations of strange FAT systems +# valid sectorsize must be a power of 2 from 32 to 32768 +>>11 uleshort&0x000f x +>>>11 uleshort <32769 +>>>>11 uleshort >31 +>>>>>3 string >\0 \b, OEM-ID "%8.8s" +#http://mirror.href.com/thestarman/asm/debug/debug2.htm#IHC +>>>>>>8 string IHC \b cached by Windows 9M +>>>>>11 uleshort >512 \b, Bytes/sector %u +#>>>>>11 uleshort =512 \b, Bytes/sector %u=512 (usual) +>>>>>11 uleshort <512 \b, Bytes/sector %u +>>>>>13 ubyte >1 \b, sectors/cluster %u +#>>>>>13 ubyte =1 \b, sectors/cluster %u (usual on Floppies) +>>>>>14 uleshort >32 \b, reserved sectors %u +#>>>>>14 uleshort =32 \b, reserved sectors %u (usual Fat32) +#>>>>>14 uleshort >1 \b, reserved sectors %u +#>>>>>14 uleshort =1 \b, reserved sectors %u (usual FAT12,FAT16) +>>>>>14 uleshort <1 \b, reserved sectors %u +>>>>>16 ubyte >2 \b, FATs %u +#>>>>>16 ubyte =2 \b, FATs %u (usual) +>>>>>16 ubyte =1 \b, FAT %u +>>>>>16 ubyte >0 +>>>>>17 uleshort >0 \b, root entries %u +#>>>>>17 uleshort =0 \b, root entries %u=0 (usual Fat32) +>>>>>19 uleshort >0 \b, sectors %u (volumes <=32 MB) +#>>>>>19 uleshort =0 \b, sectors %u=0 (usual Fat32) +>>>>>21 ubyte >0xF0 \b, Media descriptor 0x%x +#>>>>>21 ubyte =0xF0 \b, Media descriptor 0x%x (usual floppy) +>>>>>21 ubyte <0xF0 \b, Media descriptor 0x%x +>>>>>22 uleshort >0 \b, sectors/FAT %u +#>>>>>22 uleshort =0 \b, sectors/FAT %u=0 (usual Fat32) +>>>>>26 ubyte >2 \b, heads %u +#>>>>>26 ubyte =2 \b, heads %u (usual floppy) +>>>>>26 ubyte =1 \b, heads %u +#skip for Digital Research DOS (version 3.41) 1440 kB Bootdisk +>>>>>38 ubyte !0x70 +>>>>>>28 ulelong >0 \b, hidden sectors %u +#>>>>>>28 ulelong =0 \b, hidden sectors %u (usual floppy) +>>>>>>32 ulelong >0 \b, sectors %u (volumes > 32 MB) +#>>>>>>32 ulelong =0 \b, sectors %u (volumes > 32 MB) +# FAT<32 specific +>>>>>82 string !FAT32 +#>>>>>>36 ubyte 0x80 \b, physical drive 0x%x=0x80 (usual harddisk) +#>>>>>>36 ubyte 0 \b, physical drive 0x%x=0 (usual floppy) +>>>>>>36 ubyte !0x80 +>>>>>>>36 ubyte !0 \b, physical drive 0x%x +>>>>>>37 ubyte >0 \b, reserved 0x%x +#>>>>>>37 ubyte =0 \b, reserved 0x%x +>>>>>>38 ubyte >0x29 \b, dos < 4.0 BootSector (0x%x) +>>>>>>38 ubyte <0x29 \b, dos < 4.0 BootSector (0x%x) +>>>>>>38 ubyte =0x29 +>>>>>>>39 ulelong x \b, serial number 0x%x +>>>>>>>43 string >>>>>>43 string >NO\ NAME \b, label: "%11.11s" +>>>>>>>43 string =NO\ NAME \b, unlabeled +>>>>>>54 string FAT \b, FAT +>>>>>>>54 string FAT12 \b (12 bit) +>>>>>>>54 string FAT16 \b (16 bit) +# FAT32 specific +>>>>>82 string FAT32 \b, FAT (32 bit) +>>>>>>36 ulelong x \b, sectors/FAT %u +>>>>>>40 uleshort >0 \b, extension flags %u +#>>>>>>40 uleshort =0 \b, extension flags %u +>>>>>>42 uleshort >0 \b, fsVersion %u +#>>>>>>42 uleshort =0 \b, fsVersion %u (usual) +>>>>>>44 ulelong >2 \b, rootdir cluster %u +#>>>>>>44 ulelong =2 \b, rootdir cluster %u +#>>>>>>44 ulelong =1 \b, rootdir cluster %u +>>>>>>48 uleshort >1 \b, infoSector %u +#>>>>>>48 uleshort =1 \b, infoSector %u (usual) +>>>>>>48 uleshort <1 \b, infoSector %u +>>>>>>50 uleshort >6 \b, Backup boot sector %u +#>>>>>>50 uleshort =6 \b, Backup boot sector %u (usual) +>>>>>>50 uleshort <6 \b, Backup boot sector %u +>>>>>>54 ulelong >0 \b, reserved1 0x%x +>>>>>>58 ulelong >0 \b, reserved2 0x%x +>>>>>>62 ulelong >0 \b, reserved3 0x%x +# same structure as FAT1X +>>>>>>64 ubyte >0x80 \b, physical drive 0x%x +#>>>>>>64 ubyte =0x80 \b, physical drive 0x%x=80 (usual harddisk) +>>>>>>64 ubyte&0x7F >0 \b, physical drive 0x%x +#>>>>>>64 ubyte =0 \b, physical drive 0x%x=0 (usual floppy) +>>>>>>65 ubyte >0 \b, reserved 0x%x +>>>>>>66 ubyte >0x29 \b, dos < 4.0 BootSector (0x%x) +>>>>>>66 ubyte <0x29 \b, dos < 4.0 BootSector (0x%x) +>>>>>>66 ubyte =0x29 +>>>>>>>67 ulelong x \b, serial number 0x%x +>>>>>>>71 string >>>>>71 string >NO\ NAME \b, label: "%11.11s" +>>>>>>71 string =NO\ NAME \b, unlabeled +### FATs end +>0x200 lelong 0x82564557 \b, BSD disklabel +# FATX +0 string FATX FATX filesystem data + + +# romfs filesystems - Juan Cespedes +0 string -rom1fs-\0 romfs filesystem, version 1 +>8 belong x %d byte(s), +>16 string x named %s. + +# netboot image - Juan Cespedes +0 lelong 0x1b031336L Netboot image, +>4 lelong&0xFFFFFF00 0 +>>4 lelong&0x100 0x000 mode 2 +>>4 lelong&0x100 0x100 mode 3 +>4 lelong&0xFFFFFF00 !0 unknown mode + +0x18b string OS/2 OS/2 Boot Manager + +# added by Joerg Jenderek +# In the second sector (+0x200) are variables according to grub-0.97/stage2/asm.S or +# grub-1.94/kern/i386/pc/startup.S +# http://www.gnu.org/software/grub/manual/grub.html#Embedded-data +# usual values are marked with comments to get only informations of strange GRUB loaders +0x200 uleshort 0x70EA +# found only version 3.{1,2} +>0x206 ubeshort >0x0300 +# GRUB version (0.5.)95,0.93,0.94,0.96,0.97 > "00" +>>0x212 ubyte >0x29 +>>>0x213 ubyte >0x29 +# not iso9660_stage1_5 +#>>>0 ulelong&0x00BE5652 0x00BE5652 +>>>>0x213 ubyte >0x29 GRand Unified Bootloader +# config_file for stage1_5 is 0xffffffff + default "/boot/grub/stage2" +>>>>0x217 ubyte 0xFF stage1_5 +>>>>0x217 ubyte <0xFF stage2 +>>>>0x206 ubyte x \b version %u +>>>>0x207 ubyte x \b.%u +# module_size for 1.94 +>>>>0x208 ulelong <0xffffff \b, installed partition %u +#>>>>0x208 ulelong =0xffffff \b, %u (default) +>>>>0x208 ulelong >0xffffff \b, installed partition %u +# GRUB 0.5.95 unofficial +>>>>0x20C ulelong&0x2E300000 0x2E300000 +# 0=stage2 1=ffs 2=e2fs 3=fat 4=minix 5=reiserfs +>>>>>0x20C ubyte x \b, identifier 0x%x +#>>>>>0x20D ubyte =0 \b, LBA flag 0x%x (default) +>>>>>0x20D ubyte >0 \b, LBA flag 0x%x +# GRUB version as string +>>>>>0x20E string >\0 \b, GRUB version %-s +# for stage1_5 is 0xffffffff + config_file "/boot/grub/stage2" default +>>>>>>0x215 ulong 0xffffffff +>>>>>>>0x219 string >\0 \b, configuration file %-s +>>>>>>0x215 ulong !0xffffffff +>>>>>>>0x215 string >\0 \b, configuration file %-s +# newer GRUB versions +>>>>0x20C ulelong&0x2E300000 !0x2E300000 +##>>>>>0x20C ulelong =0 \b, saved entry %d (usual) +>>>>>0x20C ulelong >0 \b, saved entry %d +# for 1.94 contains kernel image size +# for 0.93,0.94,0.96,0.97 +# 0=stage2 1=ffs 2=e2fs 3=fat 4=minix 5=reiserfs 6=vstafs 7=jfs 8=xfs 9=iso9660 a=ufs2 +>>>>>0x210 ubyte x \b, identifier 0x%x +# The flag for LBA forcing is in most cases 0 +#>>>>>0x211 ubyte =0 \b, LBA flag 0x%x (default) +>>>>>0x211 ubyte >0 \b, LBA flag 0x%x +# GRUB version as string +>>>>>0x212 string >\0 \b, GRUB version %-s +# for stage1_5 is 0xffffffff + config_file "/boot/grub/stage2" default +>>>>>0x217 ulong 0xffffffff +>>>>>>0x21b string >\0 \b, configuration file %-s +>>>>>0x217 ulong !0xffffffff +>>>>>>0x217 string >\0 \b, configuration file %-s + +9564 lelong 0x00011954 Unix Fast File system [v1] (little-endian), +>8404 string x last mounted on %s, +#>9504 ledate x last checked at %s, +>8224 ledate x last written at %s, +>8401 byte x clean flag %d, +>8228 lelong x number of blocks %d, +>8232 lelong x number of data blocks %d, +>8236 lelong x number of cylinder groups %d, +>8240 lelong x block size %d, +>8244 lelong x fragment size %d, +>8252 lelong x minimum percentage of free blocks %d, +>8256 lelong x rotational delay %dms, +>8260 lelong x disk rotational speed %drps, +>8320 lelong 0 TIME optimization +>8320 lelong 1 SPACE optimization + +42332 lelong 0x19540119 Unix Fast File system [v2] (little-endian) +>&-1164 string x last mounted on %s, +>&-696 string >\0 volume name %s, +>&-304 leqldate x last written at %s, +>&-1167 byte x clean flag %d, +>&-1168 byte x readonly flag %d, +>&-296 lequad x number of blocks %lld, +>&-288 lequad x number of data blocks %lld, +>&-1332 lelong x number of cylinder groups %d, +>&-1328 lelong x block size %d, +>&-1324 lelong x fragment size %d, +>&-180 lelong x average file size %d, +>&-176 lelong x average number of files in dir %d, +>&-272 lequad x pending blocks to free %lld, +>&-264 lelong x pending inodes to free %d, +>&-664 lequad x system-wide uuid %0llx, +>&-1316 lelong x minimum percentage of free blocks %d, +>&-1248 lelong 0 TIME optimization +>&-1248 lelong 1 SPACE optimization + +66908 lelong 0x19540119 Unix Fast File system [v2] (little-endian) +>&-1164 string x last mounted on %s, +>&-696 string >\0 volume name %s, +>&-304 leqldate x last written at %s, +>&-1167 byte x clean flag %d, +>&-1168 byte x readonly flag %d, +>&-296 lequad x number of blocks %lld, +>&-288 lequad x number of data blocks %lld, +>&-1332 lelong x number of cylinder groups %d, +>&-1328 lelong x block size %d, +>&-1324 lelong x fragment size %d, +>&-180 lelong x average file size %d, +>&-176 lelong x average number of files in dir %d, +>&-272 lequad x pending blocks to free %lld, +>&-264 lelong x pending inodes to free %d, +>&-664 lequad x system-wide uuid %0llx, +>&-1316 lelong x minimum percentage of free blocks %d, +>&-1248 lelong 0 TIME optimization +>&-1248 lelong 1 SPACE optimization + +9564 belong 0x00011954 Unix Fast File system [v1] (big-endian), +>7168 belong 0x4c41424c Apple UFS Volume +>>7186 string x named %s, +>>7176 belong x volume label version %d, +>>7180 bedate x created on %s, +>8404 string x last mounted on %s, +#>9504 bedate x last checked at %s, +>8224 bedate x last written at %s, +>8401 byte x clean flag %d, +>8228 belong x number of blocks %d, +>8232 belong x number of data blocks %d, +>8236 belong x number of cylinder groups %d, +>8240 belong x block size %d, +>8244 belong x fragment size %d, +>8252 belong x minimum percentage of free blocks %d, +>8256 belong x rotational delay %dms, +>8260 belong x disk rotational speed %drps, +>8320 belong 0 TIME optimization +>8320 belong 1 SPACE optimization + +42332 belong 0x19540119 Unix Fast File system [v2] (big-endian) +>&-1164 string x last mounted on %s, +>&-696 string >\0 volume name %s, +>&-304 beqldate x last written at %s, +>&-1167 byte x clean flag %d, +>&-1168 byte x readonly flag %d, +>&-296 bequad x number of blocks %lld, +>&-288 bequad x number of data blocks %lld, +>&-1332 belong x number of cylinder groups %d, +>&-1328 belong x block size %d, +>&-1324 belong x fragment size %d, +>&-180 belong x average file size %d, +>&-176 belong x average number of files in dir %d, +>&-272 bequad x pending blocks to free %lld, +>&-264 belong x pending inodes to free %d, +>&-664 bequad x system-wide uuid %0llx, +>&-1316 belong x minimum percentage of free blocks %d, +>&-1248 belong 0 TIME optimization +>&-1248 belong 1 SPACE optimization + +66908 belong 0x19540119 Unix Fast File system [v2] (big-endian) +>&-1164 string x last mounted on %s, +>&-696 string >\0 volume name %s, +>&-304 beqldate x last written at %s, +>&-1167 byte x clean flag %d, +>&-1168 byte x readonly flag %d, +>&-296 bequad x number of blocks %lld, +>&-288 bequad x number of data blocks %lld, +>&-1332 belong x number of cylinder groups %d, +>&-1328 belong x block size %d, +>&-1324 belong x fragment size %d, +>&-180 belong x average file size %d, +>&-176 belong x average number of files in dir %d, +>&-272 bequad x pending blocks to free %lld, +>&-264 belong x pending inodes to free %d, +>&-664 bequad x system-wide uuid %0llx, +>&-1316 belong x minimum percentage of free blocks %d, +>&-1248 belong 0 TIME optimization +>&-1248 belong 1 SPACE optimization + +# ext2/ext3 filesystems - Andreas Dilger +# ext4 filesystem - Eric Sandeen +0x438 leshort 0xEF53 Linux +>0x44c lelong x rev %d +>0x43e leshort x \b.%d +# No journal? ext2 +>0x45c lelong ^0x0000004 ext2 filesystem data +>>0x43a leshort ^0x0000001 (mounted or unclean) +# Has a journal? ext3 or ext4 +>0x45c lelong &0x0000004 +# and small INCOMPAT? +>>0x460 lelong <0x0000040 +# and small RO_COMPAT? +>>>0x464 lelong <0x0000008 ext3 filesystem data +# else large RO_COMPAT? +>>>0x464 lelong >0x0000007 ext4 filesystem data +# else large INCOMPAT? +>>0x460 lelong >0x000003f ext4 filesystem data +# General flags for any ext* fs +>0x460 lelong &0x0000004 (needs journal recovery) +>0x43a leshort &0x0000002 (errors) +# INCOMPAT flags +>0x460 lelong &0x0000001 (compressed) +#>0x460 lelong &0x0000002 (filetype) +#>0x460 lelong &0x0000010 (meta bg) +>0x460 lelong &0x0000040 (extents) +>0x460 lelong &0x0000080 (64bit) +#>0x460 lelong &0x0000100 (mmp) +#>0x460 lelong &0x0000200 (flex bg) +# RO_INCOMPAT flags +#>0x464 lelong &0x0000001 (sparse super) +>0x464 lelong &0x0000002 (large files) +>0x464 lelong &0x0000008 (huge files) +#>0x464 lelong &0x0000010 (gdt checksum) +#>0x464 lelong &0x0000020 (many subdirs) +#>0x463 lelong &0x0000040 (extra isize) + +# SGI disk labels - Nathan Scott +0 belong 0x0BE5A941 SGI disk label (volume header) + +# SGI XFS filesystem - Nathan Scott +0 belong 0x58465342 SGI XFS filesystem data +>0x4 belong x (blksz %d, +>0x68 beshort x inosz %d, +>0x64 beshort ^0x2004 v1 dirs) +>0x64 beshort &0x2004 v2 dirs) + +############################################################################ +# Minix-ST kernel floppy +0x800 belong 0x46fc2700 Atari-ST Minix kernel image +>19 string \240\5\371\5\0\011\0\2\0 \b, 720k floppy +>19 string \320\2\370\5\0\011\0\1\0 \b, 360k floppy + +############################################################################ +# Hmmm, is this a better way of detecting _standard_ floppy images ? +19 string \320\2\360\3\0\011\0\1\0 DOS floppy 360k +>0x1FE leshort 0xAA55 \b, x86 hard disk boot sector +19 string \240\5\371\3\0\011\0\2\0 DOS floppy 720k +>0x1FE leshort 0xAA55 \b, x86 hard disk boot sector +19 string \100\013\360\011\0\022\0\2\0 DOS floppy 1440k +>0x1FE leshort 0xAA55 \b, x86 hard disk boot sector + +19 string \240\5\371\5\0\011\0\2\0 DOS floppy 720k, IBM +>0x1FE leshort 0xAA55 \b, x86 hard disk boot sector +19 string \100\013\371\5\0\011\0\2\0 DOS floppy 1440k, mkdosfs +>0x1FE leshort 0xAA55 \b, x86 hard disk boot sector + +19 string \320\2\370\5\0\011\0\1\0 Atari-ST floppy 360k +19 string \240\5\371\5\0\011\0\2\0 Atari-ST floppy 720k + +# Valid media descriptor bytes for MS-DOS: +# +# Byte Capacity Media Size and Type +# ------------------------------------------------- +# +# F0 2.88 MB 3.5-inch, 2-sided, 36-sector +# F0 1.44 MB 3.5-inch, 2-sided, 18-sector +# F9 720K 3.5-inch, 2-sided, 9-sector +# F9 1.2 MB 5.25-inch, 2-sided, 15-sector +# FD 360K 5.25-inch, 2-sided, 9-sector +# FF 320K 5.25-inch, 2-sided, 8-sector +# FC 180K 5.25-inch, 1-sided, 9-sector +# FE 160K 5.25-inch, 1-sided, 8-sector +# FE 250K 8-inch, 1-sided, single-density +# FD 500K 8-inch, 2-sided, single-density +# FE 1.2 MB 8-inch, 2-sided, double-density +# F8 ----- Fixed disk +# +# FC xxxK Apricot 70x1x9 boot disk. +# +# Originally a bitmap: +# xxxxxxx0 Not two sided +# xxxxxxx1 Double sided +# xxxxxx0x Not 8 SPT +# xxxxxx1x 8 SPT +# xxxxx0xx Not Removable drive +# xxxxx1xx Removable drive +# 11111xxx Must be one. +# +# But now it's rather random: +# 111111xx Low density disk +# 00 SS, Not 8 SPT +# 01 DS, Not 8 SPT +# 10 SS, 8 SPT +# 11 DS, 8 SPT +# +# 11111001 Double density 3½ floppy disk, high density 5¼ +# 11110000 High density 3½ floppy disk +# 11111000 Hard disk any format +# + +# CDROM Filesystems +# Modified for UDF by gerardo.cacciari@gmail.com +32769 string CD001 +>38913 string !NSR0 ISO 9660 CD-ROM filesystem data +!:mime application/x-iso9660-image +>38913 string NSR0 UDF filesystem data +!:mime application/x-iso9660-image +>>38917 string 1 (version 1.0) +>>38917 string 2 (version 1.5) +>>38917 string 3 (version 2.0) +>>38917 byte >0x33 (unknown version, ID 0x%X) +>>38917 byte <0x31 (unknown version, ID 0x%X) +# "application id" which appears to be used as a volume label +>32808 string >\0 '%s' +>34816 string \000CD001\001EL\ TORITO\ SPECIFICATION (bootable) +37633 string CD001 ISO 9660 CD-ROM filesystem data (raw 2352 byte sectors) +!:mime application/x-iso9660-image +32776 string CDROM High Sierra CD-ROM filesystem data + +# cramfs filesystem - russell@coker.com.au +0 lelong 0x28cd3d45 Linux Compressed ROM File System data, little endian +>4 lelong x size %u +>8 lelong &1 version #2 +>8 lelong &2 sorted_dirs +>8 lelong &4 hole_support +>32 lelong x CRC 0x%x, +>36 lelong x edition %u, +>40 lelong x %u blocks, +>44 lelong x %u files + +0 belong 0x28cd3d45 Linux Compressed ROM File System data, big endian +>4 belong x size %u +>8 belong &1 version #2 +>8 belong &2 sorted_dirs +>8 belong &4 hole_support +>32 belong x CRC 0x%x, +>36 belong x edition %u, +>40 belong x %u blocks, +>44 belong x %u files + +# reiserfs - russell@coker.com.au +0x10034 string ReIsErFs ReiserFS V3.5 +0x10034 string ReIsEr2Fs ReiserFS V3.6 +>0x1002c leshort x block size %d +>0x10032 leshort &2 (mounted or unclean) +>0x10000 lelong x num blocks %d +>0x10040 lelong 1 tea hash +>0x10040 lelong 2 yura hash +>0x10040 lelong 3 r5 hash + +# JFFS - russell@coker.com.au +0 lelong 0x34383931 Linux Journalled Flash File system, little endian +0 belong 0x34383931 Linux Journalled Flash File system, big endian + +# EST flat binary format (which isn't, but anyway) +# From: Mark Brown +0 string ESTFBINR EST flat binary + +# Aculab VoIP firmware +# From: Mark Brown +0 string VoIP\ Startup\ and Aculab VoIP firmware +>35 string x format %s + +# u-boot/PPCBoot image file +# From: Mark Brown +0 belong 0x27051956 u-boot/PPCBoot image +>4 string PPCBoot +>>12 string x version %s + +# JFFS2 file system +#0 leshort 0x1984 Linux old jffs2 filesystem data little endian +#0 leshort 0x1985 Linux jffs2 filesystem data little endian + +# Squashfs +0 string sqsh Squashfs filesystem, big endian, +>28 beshort x version %d. +>30 beshort x \b%d, +>28 beshort <3 +>>8 belong x %d byte(s), +>28 beshort >2 +>>63 bequad x %lld bytes, +#>>67 belong x %d byte(s), +>4 belong x %d inodes, +>28 beshort <2 +>>32 beshort x blocksize: %d byte(s), +>28 beshort >1 +>>51 belong x blocksize: %d byte(s), +>39 bedate x created: %s + +0 string hsqs Squashfs filesystem, little endian, +>28 leshort x version %d. +>30 leshort x \b%d, +>28 leshort <3 +>>8 lelong x %d byte(s), +>28 leshort >2 +>>63 lequad x %lld bytes, +#>>63 lelong x %d byte(s), +>4 lelong x %d inodes, +>28 leshort <2 +>>32 leshort x blocksize: %d byte(s), +>28 leshort >1 +>>51 lelong x blocksize: %d byte(s), +>39 ledate x created: %s + +# Squashfs +0 string hsqt Squashfs filesystem, little endian, +>28 leshort x version %d. +>30 leshort x \b%d, +>28 leshort <3 +>>8 lelong x %d byte(s), +>28 leshort >2 +>>63 lequad x %lld bytes, +#>>63 lelong x %d byte(s), +>4 lelong x %d inodes, +>28 leshort <2 +>>32 leshort x blocksize: %d byte(s), +>28 leshort >1 +>>51 lelong x blocksize: %d byte(s), +>39 ledate x created: %s +0 string hsqt Squashfs filesystem, little endian, +>28 beshort x version %d. +>30 beshort x \b%d, +>28 beshort <3 +>>8 belong x %d byte(s), +>28 beshort >2 +>>63 bequad x %lld bytes, +#>>67 belong x %d byte(s), +>4 belong x %d inodes, +>28 beshort <2 +>>32 beshort x blocksize: %d byte(s), +>28 beshort >1 +>>51 belong x blocksize: %d byte(s), +>39 bedate x created: %s + +# 0 string hsqs Squashfs filesystem, little endian, +# >28 leshort x version %d. +# >30 leshort x \b%d, +# >28 leshort <3 +# >>8 lelong x %d byte(s), +# >28 leshort >2 +# >>63 lequad x %lld bytes, +# #>>63 lelong x %d byte(s), +# >4 lelong x %d inodes, +# >28 leshort <2 +# >>32 leshort x blocksize: %d byte(s), +# >28 leshort >1 +# >>51 lelong x blocksize: %d byte(s), +# >39 ledate x created: %s + +#0 string td\000 floppy image data (TeleDisk) + +# AFS Dump Magic +# From: Ty Sarna +0 string \x01\xb3\xa1\x13\x22 AFS Dump +>&0 belong x (v%d) +>>&0 byte 0x76 +>>>&0 belong x Vol %d, +>>>>&0 byte 0x6e +>>>>>&0 string x %s +>>>>>>&1 byte 0x74 +>>>>>>>&0 beshort 2 +>>>>>>>>&4 bedate x on: %s +>>>>>>>>&0 bedate =0 full dump +>>>>>>>>&0 bedate !0 incremental since: %s + +#---------------------------------------------------------- +# VMS backup savesets - gerardo.cacciari@gmail.com +# +4 string \x01\x00\x01\x00\x01\x00 +>(0.s+16) string \x01\x01 +>>&(&0.b+8) byte 0x42 OpenVMS backup saveset data +>>>40 lelong x (block size %d, +>>>49 string >\0 original name '%s', +>>>2 short 1024 VAX generated) +>>>2 short 2048 AXP generated) +>>>2 short 4096 I64 generated) + +# Compaq/HP RILOE floppy image +# From: Dirk Jagdmann +0 string CPQRFBLO Compaq/HP RILOE floppy image + +#------------------------------------------------------------------------------ +# Files-11 On-Disk Structure (OpenVMS file system) - gerardo.cacciari@gmail.com +# These bits come from LBN 1 (home block) of ODS-2 and ODS-5 volumes, which is +# mapped to VBN 2 of [000000]INDEXF.SYS;1 +# +1008 string DECFILE11B Files-11 On-Disk Structure +>525 byte x Level %d +>525 byte x (ODS-%d OpenVMS file system), +>984 string x volume label is '%-12.12s' + +# From: Thomas Klausner +# http://filext.com/file-extension/DAA +# describes the daa file format. The magic would be: +0 string DAA\x0\x0\x0\x0\x0 PowerISO Direct-Access-Archive + +# From Albert Cahalan +# really le32 operation,destination,payloadsize (but quite predictable) +# 01 00 00 00 00 00 00 c0 00 02 00 00 +0 string \1\0\0\0\0\0\0\300\0\2\0\0 Marvell Libertas firmware + + +# DOS x86 sector updated and separated from "DOS/MBR boot sector" by Joerg Jenderek at May 2011 +# JuMP short bootcodeoffset NOP assembler instructions will usually be EB xx 90 +# over BIOS parameter block (BPB) +# http://thestarman.pcministry.com/asm/2bytejumps.htm#FWD +# older drives may use Near JuMP instruction E9 xx xx +# minimal short forward jump found 0x29 for bootloaders or 0x0 +# maximal short forward jump is 0x7f +# OEM-ID is empty or contain readable bytes +0 ulelong&0x804000E9 0x000000E9 +# reduce false positives with this check +>54 string FAT +# !:strength +60 +# mtools-3.9.8/msdos.h +# usual values are marked with comments to get only informations of strange FAT systems +# valid sectorsize must be a power of 2 from 32 to 32768 +#>11 uleshort&0x001f 0 +>>11 uleshort <32769 +>>>11 uleshort >31 +>>>>21 ubyte&0xf0 0xF0 +>>>>>0 ubyte 0xEB DOS/MBR boot sector +>>>>>>1 ubyte x \b, code offset 0x%x+2 +>>>>>0 ubyte 0xE9 +>>>>>>1 uleshort x \b, code offset 0x%x+3 +>>>>>3 string >\0 \b, OEM-ID "%-.8s" +#http://mirror.href.com/thestarman/asm/debug/debug2.htm#IHC +>>>>>>8 string IHC \b cached by Windows 9M +>>>>>11 uleshort >512 \b, Bytes/sector %u +#>>>>>11 uleshort =512 \b, Bytes/sector %u=512 (usual) +>>>>>11 uleshort <512 \b, Bytes/sector %u +>>>>>13 ubyte >1 \b, sectors/cluster %u +#>>>>>13 ubyte =1 \b, sectors/cluster %u (usual on Floppies) +# for lazy FAT32 implementation like Transcend digital photo frame PF830 +>>>>>82 string/c fat32 +>>>>>>14 uleshort !32 \b, reserved sectors %u +#>>>>>>14 uleshort =32 \b, reserved sectors %u (usual Fat32) +>>>>>82 string/c !fat32 +>>>>>>14 uleshort >1 \b, reserved sectors %u +#>>>>>>14 uleshort =1 \b, reserved sectors %u (usual FAT12,FAT16) +#>>>>>>14 uleshort 0 \b, reserved sectors %u (usual NTFS) +>>>>>16 ubyte >2 \b, FATs %u +#>>>>>16 ubyte =2 \b, FATs %u (usual) +>>>>>16 ubyte =1 \b, FAT %u +>>>>>16 ubyte >0 +>>>>>17 uleshort >0 \b, root entries %u +#>>>>>17 uleshort =0 \b, root entries %hu=0 (usual Fat32) +>>>>>19 uleshort >0 \b, sectors %u (volumes <=32 MB) +#>>>>>19 uleshort =0 \b, sectors %hu=0 (usual Fat32) +>>>>>21 ubyte >0xF0 \b, Media descriptor 0x%x +#>>>>>21 ubyte =0xF0 \b, Media descriptor 0x%x (usual floppy) +>>>>>21 ubyte <0xF0 \b, Media descriptor 0x%x +>>>>>22 uleshort >0 \b, sectors/FAT %u +#>>>>>22 uleshort =0 \b, sectors/FAT %hu=0 (usual Fat32) +>>>>>24 uleshort x \b, sectors/track %u +>>>>>26 ubyte >2 \b, heads %u +#>>>>>26 ubyte =2 \b, heads %u (usual floppy) +>>>>>26 ubyte =1 \b, heads %u +# valid only for sector sizes with more then 32 Bytes +>>>>>11 uleshort >32 +# http://en.wikipedia.org/wiki/Design_of_the_FAT_file_system#Extended_BIOS_Parameter_Block +# skip for values 2,2Ah,70h,73h,DFh +# and continue for extended boot signature values 0,28h,29h,80h +>>>>>>38 ubyte&0x56 =0 +>>>>>>>28 ulelong >0 \b, hidden sectors %u +#>>>>>>>28 ulelong =0 \b, hidden sectors %u (usual floppy) +>>>>>>>32 ulelong >0 \b, sectors %u (volumes > 32 MB) +#>>>>>>>32 ulelong =0 \b, sectors %u (volumes > 32 MB) +# FAT<32 bit specific +>>>>>>>82 string/c !fat32 +#>>>>>>>>36 ubyte 0x80 \b, physical drive 0x%x=0x80 (usual harddisk) +#>>>>>>>>36 ubyte 0 \b, physical drive 0x%x=0 (usual floppy) +>>>>>>>>36 ubyte !0x80 +>>>>>>>>>36 ubyte !0 \b, physical drive 0x%x +# VGA-copy CRC or +# in Windows NT bit 0 is a dirty flag to request chkdsk at boot time. bit 1 requests surface scan too +>>>>>>>>37 ubyte >0 \b, reserved 0x%x +#>>>>>>>>37 ubyte =0 \b, reserved 0x%x +# extended boot signatur value is 0x80 for NTFS, 0x28 or 0x29 for others +>>>>>>>>38 ubyte !0x29 \b, dos < 4.0 BootSector (0x%x) +>>>>>>>>38 ubyte&0xFE =0x28 +>>>>>>>>>39 ulelong x \b, serial number 0x%x +>>>>>>>>38 ubyte =0x29 +>>>>>>>>>43 string >>>>>>>>43 string >NO\ NAME \b, label: "%11.11s" +>>>>>>>>>43 string =NO\ NAME \b, unlabeled +# there exist some old floppies without word FAT at offset 54 +# a word like "FATnm " is only a hint for a FAT size on nm-bits +# Normally the number of clusters is calculated by the values of BPP. +# if it is small enough FAT is 12 bit, if it is too big enough FAT is 32 bit, +# otherwise FAT is 16 bit. +# http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-fat-widths.html +>>>>>82 string/c !fat32 +>>>>>>54 string FAT12 \b, FAT (12 bit) +>>>>>>54 string FAT16 \b, FAT (16 bit) +>>>>>>54 default x +# determinate FAT bit size by media descriptor +# small floppies implies FAT12 +>>>>>>>21 ubyte <0xF0 \b, FAT (12 bit by descriptor) +# with media descriptor F0h floppy or maybe superfloppy with FAT16 +>>>>>>>21 ubyte =0xF0 +# superfloppy (many sectors) implies FAT16 +>>>>>>>>32 ulelong >0xFFFF \b, FAT (16 bit by descriptor+sectors) +# no superfloppy with media descriptor F0h implies FAT12 +>>>>>>>>32 default x \b, FAT (12 bit by descriptor+sectors) +# with media descriptor F8h floppy or hard disc with FAT12 or FAT16 +>>>>>>>21 ubyte =0xF8 +# 360 KiB with media descriptor F8h, 9 sectors per track ,single sided floppy implies FAT12 +>>>>>>>>19 ubequad 0xd002f80300090001 \b, FAT (12 bit by descriptor+geometry) +# hard disc with FAT12 or FAT16 +>>>>>>>>19 default x \b, FAT (1Y bit by descriptor) +# with media descriptor FAh floppy, RAM disc with FAT12 or FAT16 or Tandy hard disc +>>>>>>>21 ubyte =0xFA +# 320 KiB with media descriptor FAh, 8 sectors per track ,single sided floppy implies FAT12 +>>>>>>>>19 ubequad 0x8002fa0200080001 \b, FAT (12 bit by descriptor+geometry) +# RAM disc with FAT12 or FAT16 or Tandy hard disc +>>>>>>>>19 default x \b, FAT (1Y bit by descriptor) +# others are floppy +>>>>>>>21 default x \b, FAT (12 bit by descriptor) +# FAT32 bit specific +>>>>>82 string/c fat32 \b, FAT (32 bit) +>>>>>>36 ulelong x \b, sectors/FAT %u +# http://technet.microsoft.com/en-us/library/cc977221.aspx +>>>>>>40 uleshort >0 \b, extension flags 0x%x +#>>>>>>40 uleshort =0 \b, extension flags %hu +>>>>>>42 uleshort >0 \b, fsVersion %u +#>>>>>>42 uleshort =0 \b, fsVersion %u (usual) +>>>>>>44 ulelong >2 \b, rootdir cluster %u +#>>>>>>44 ulelong =2 \b, rootdir cluster %u +#>>>>>>44 ulelong =1 \b, rootdir cluster %u +>>>>>>48 uleshort >1 \b, infoSector %u +#>>>>>>48 uleshort =1 \b, infoSector %u (usual) +>>>>>>48 uleshort <1 \b, infoSector %u +# 0 or 0xFFFF instead of usual 6 means no backup sector +>>>>>>50 uleshort =0xFFFF \b, no Backup boot sector +>>>>>>50 uleshort =0 \b, no Backup boot sector +#>>>>>>50 uleshort =6 \b, Backup boot sector %u (usual) +>>>>>>50 default x +>>>>>>>50 uleshort x \b, Backup boot sector %u +# corrected by Joerg Jenderek at Feb 2011 according to http://thestarman.pcministry.com/asm/mbr/MSWIN41.htm#FSINFO +>>>>>>52 ulelong >0 \b, reserved1 0x%x +>>>>>>56 ulelong >0 \b, reserved2 0x%x +>>>>>>60 ulelong >0 \b, reserved3 0x%x +# same structure as FAT1X +#>>>>>>64 ubyte =0x80 \b, physical drive 0x%x=80 (usual harddisk) +#>>>>>>64 ubyte =0 \b, physical drive 0x%x=0 (usual floppy) +>>>>>>64 ubyte !0x80 +>>>>>>>64 ubyte >0 \b, physical drive 0x%x +# in Windows NT bit 0 is a dirty flag to request chkdsk at boot time. bit 1 requests surface scan too +>>>>>>65 ubyte >0 \b, reserved 0x%x +>>>>>>66 ubyte !0x29 \b, dos < 4.0 BootSector (0x%x) +>>>>>>66 ubyte =0x29 +>>>>>>>67 ulelong x \b, serial number 0x%x +>>>>>>>71 string >>>>>>71 string >NO\ NAME \b, label: "%11.11s" +>>>>>>>71 string =NO\ NAME \b, unlabeled +# additional tests for floppy image added by Joerg Jenderek +# no fixed disk +>>>>>21 ubyte !0xF8 +# floppy media with 12 bit FAT +>>>>>>54 string !FAT16 +# test for FAT after bootsector +>>>>>>>(11.s) ulelong&0x00ffffF0 0x00ffffF0 \b, followed by FAT +# floppy image +!:mime application/x-ima +# NTFS specific added by Joerg Jenderek at Mar 2011 according to http://thestarman.pcministry.com/asm/mbr/NTFSBR.htm +# and http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/bios-parameter-block.html +# 0 FATs +>>>>>16 ubyte =0 +# 0 root entries +>>>>>>17 uleshort =0 +# 0 DOS sectors +>>>>>>>19 uleshort =0 +# 0 sectors/FAT +# dos < 4.0 BootSector value found is 0x80 +#38 ubyte =0x80 \b, dos < 4.0 BootSector (0x%x) +>>>>>>>>22 uleshort =0 \b; NTFS +>>>>>>>>>24 uleshort >0 \b, sectors/track %u +>>>>>>>>>36 ulelong !0x800080 \b, physical drive 0x%x +>>>>>>>>>40 ulequad >0 \b, sectors %lld +>>>>>>>>>48 ulequad >0 \b, $MFT start cluster %lld +>>>>>>>>>56 ulequad >0 \b, $MFTMirror start cluster %lld +# Values 0 to 127 represent MFT record sizes of 0 to 127 clusters. +# Values 128 to 255 represent MFT record sizes of 2^(256-N) bytes. +>>>>>>>>>64 lelong <256 +>>>>>>>>>>64 lelong <128 \b, clusters/RecordSegment %d +>>>>>>>>>>64 ubyte >127 \b, bytes/RecordSegment 2^(-1*%i) +# Values 0 to 127 represent index block sizes of 0 to 127 clusters. +# Values 128 to 255 represent index block sizes of 2^(256-N) byte +>>>>>>>>>68 ulelong <256 +>>>>>>>>>>68 ulelong <128 \b, clusters/index block %d +#>>>>>>>>>>68 ulelong >127 \b, bytes/index block 2^(256-%d) +>>>>>>>>>>68 ubyte >127 \b, bytes/index block 2^(-1*%i) +>>>>>>>>>72 ulequad x \b, serial number 0%llx +>>>>>>>>>80 ulelong >0 \b, checksum 0x%x +#>>>>>>>>>80 ulelong =0 \b, checksum 0x%x=0 (usual) +>>>>>>>>>0x258 ulelong&0x00009090 =0x00009090 +#>>>>>>>>>>&-92 indirect x \b; contains +# For 2nd NTFS sector added by Joerg Jenderek at Jan 2013 +# http://thestarman.pcministry.com/asm/mbr/NTFSbrHexEd.htm +# unused assembler instructions JMP y2;NOP;NOP +0x056 ulelong&0xFFFF0FFF 0x909002EB +# unicode loadername terminated by CTRL-D +>(0.s*2) ulelong&0xFFFFFF00 0x00040000 +# loadernames are NTLDR,CMLDR,PELDR,$LDR$ or BOOTMGR +>>0x002 lestring16 x Microsoft Windows XP/VISTA bootloader %-5.5s +>>0x12 string $ +>>>0x0c lestring16 x \b%-2.2s diff --git a/dest/share/magic/firmware b/dest/share/magic/firmware new file mode 100644 index 00000000000..19f6347e547 --- /dev/null +++ b/dest/share/magic/firmware @@ -0,0 +1 @@ +0 string HDR0 TRX Firmware Header diff --git a/dest/share/magic/flash b/dest/share/magic/flash new file mode 100644 index 00000000000..ea3e6fb20e9 --- /dev/null +++ b/dest/share/magic/flash @@ -0,0 +1,22 @@ +# $OpenBSD: flash,v 1.3 2009/04/24 18:54:34 chl Exp $ + +#------------------------------------------------------------------------------ +# flash: file(1) magic for Macromedia Flash file format +# +# See +# +# http://www.macromedia.com/software/flash/open/ +# +0 string FWS Macromedia Flash data, +>3 byte x version %d +!:mime application/x-shockwave-flash +0 string CWS Macromedia Flash data (compressed), +!:mime application/x-shockwave-flash +>3 byte x version %d +# From: Cal Peake +0 string FLV Macromedia Flash Video +!:mime video/x-flv + +# +# From Dave Wilson +0 string AGD4\xbe\xb8\xbb\xcb\x00 Macromedia Freehand 9 Document diff --git a/dest/share/magic/freebsd b/dest/share/magic/freebsd new file mode 100644 index 00000000000..95ea7d122a3 --- /dev/null +++ b/dest/share/magic/freebsd @@ -0,0 +1,144 @@ +# $OpenBSD: freebsd,v 1.2 2004/06/03 03:14:20 tedu Exp $ + +#------------------------------------------------------------------------------ +# freebsd: file(1) magic for FreeBSD objects +# +# All new-style FreeBSD magic numbers are in host byte order (i.e., +# little-endian on x86). +# +# XXX - this comes from the file "freebsd" in a recent FreeBSD version of +# "file"; it, and the NetBSD stuff in "netbsd", appear to use different +# schemes for distinguishing between executable images, shared libraries, +# and object files. +# +# FreeBSD says: +# +# Regardless of whether it's pure, demand-paged, or none of the +# above: +# +# if the entry point is < 4096, then it's a shared library if +# the "has run-time loader information" bit is set, and is +# position-independent if the "is position-independent" bit +# is set; +# +# if the entry point is >= 4096 (or >4095, same thing), then it's +# an executable, and is dynamically-linked if the "has run-time +# loader information" bit is set. +# +# On x86, NetBSD says: +# +# If it's neither pure nor demand-paged: +# +# if it has the "has run-time loader information" bit set, it's +# a dynamically-linked executable; +# +# if it doesn't have that bit set, then: +# +# if it has the "is position-independent" bit set, it's +# position-independent; +# +# if the entry point is non-zero, it's an executable, otherwise +# it's an object file. +# +# If it's pure: +# +# if it has the "has run-time loader information" bit set, it's +# a dynamically-linked executable, otherwise it's just an +# executable. +# +# If it's demand-paged: +# +# if it has the "has run-time loader information" bit set, +# then: +# +# if the entry point is < 4096, it's a shared library; +# +# if the entry point is = 4096 or > 4096 (i.e., >= 4096), +# it's a dynamically-linked executable); +# +# if it doesn't have the "has run-time loader information" bit +# set, then it's just an executable. +# +# (On non-x86, NetBSD does much the same thing, except that it uses +# 8192 on 68K - except for "68k4k", which is presumably "68K with 4K +# pages - SPARC, and MIPS, presumably because Sun-3's and Sun-4's +# had 8K pages; dunno about MIPS.) +# +# I suspect the two will differ only in perverse and uninteresting cases +# ("shared" libraries that aren't demand-paged and whose pages probably +# won't actually be shared, executables with entry points <4096). +# +# I leave it to those more familiar with FreeBSD and NetBSD to figure out +# what the right answer is (although using ">4095", FreeBSD-style, is +# probably better than separately checking for "=4096" and ">4096", +# NetBSD-style). (The old "netbsd" file analyzed FreeBSD demand paged +# executables using the NetBSD technique.) +# +0 lelong&0377777777 041400407 FreeBSD/i386 +>20 lelong <4096 +>>3 byte&0xC0 &0x80 shared library +>>3 byte&0xC0 0x40 PIC object +>>3 byte&0xC0 0x00 object +>20 lelong >4095 +>>3 byte&0x80 0x80 dynamically linked executable +>>3 byte&0x80 0x00 executable +>16 lelong >0 not stripped + +0 lelong&0377777777 041400410 FreeBSD/i386 pure +>20 lelong <4096 +>>3 byte&0xC0 &0x80 shared library +>>3 byte&0xC0 0x40 PIC object +>>3 byte&0xC0 0x00 object +>20 lelong >4095 +>>3 byte&0x80 0x80 dynamically linked executable +>>3 byte&0x80 0x00 executable +>16 lelong >0 not stripped + +0 lelong&0377777777 041400413 FreeBSD/i386 demand paged +>20 lelong <4096 +>>3 byte&0xC0 &0x80 shared library +>>3 byte&0xC0 0x40 PIC object +>>3 byte&0xC0 0x00 object +>20 lelong >4095 +>>3 byte&0x80 0x80 dynamically linked executable +>>3 byte&0x80 0x00 executable +>16 lelong >0 not stripped + +0 lelong&0377777777 041400314 FreeBSD/i386 compact demand paged +>20 lelong <4096 +>>3 byte&0xC0 &0x80 shared library +>>3 byte&0xC0 0x40 PIC object +>>3 byte&0xC0 0x00 object +>20 lelong >4095 +>>3 byte&0x80 0x80 dynamically linked executable +>>3 byte&0x80 0x00 executable +>16 lelong >0 not stripped + +# XXX gross hack to identify core files +# cores start with a struct tss; we take advantage of the following: +# byte 7: highest byte of the kernel stack pointer, always 0xfe +# 8/9: kernel (ring 0) ss value, always 0x0010 +# 10 - 27: ring 1 and 2 ss/esp, unused, thus always 0 +# 28: low order byte of the current PTD entry, always 0 since the +# PTD is page-aligned +# +7 string \357\020\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 FreeBSD/i386 a.out core file +>1039 string >\0 from '%s' + +# /var/run/ld.so.hints +# What are you laughing about? +0 lelong 011421044151 ld.so hints file (Little Endian +>4 lelong >0 \b, version %d) +>4 belong <1 \b) +0 belong 011421044151 ld.so hints file (Big Endian +>4 belong >0 \b, version %d) +>4 belong <1 \b) + +# +# Files generated by FreeBSD scrshot(1)/vidcontrol(1) utilities +# +0 string SCRSHOT_ scrshot(1) screenshot, +>8 byte x version %d, +>9 byte 2 %d byte(s) in header, +>>10 byte x %d chars wide by +>>11 byte x %d chars high diff --git a/dest/share/magic/gimp b/dest/share/magic/gimp new file mode 100644 index 00000000000..b31c1dfefa8 --- /dev/null +++ b/dest/share/magic/gimp @@ -0,0 +1,38 @@ +# $OpenBSD: gimp,v 1.1 2004/06/03 03:14:20 tedu Exp $ + +#------------------------------------------------------------------------------ +# GIMP Gradient: file(1) magic for the GIMP's gradient data files +# by Federico Mena + +0 string GIMP\ Gradient GIMP gradient data + +#------------------------------------------------------------------------------ +# XCF: file(1) magic for the XCF image format used in the GIMP developed +# by Spencer Kimball and Peter Mattis +# ('Bucky' LaDieu, nega@vt.edu) + +0 string gimp\ xcf GIMP XCF image data, +>9 string file version 0, +>9 string v version +>>10 string >\0 %s, +>14 belong x %u x +>18 belong x %u, +>22 belong 0 RGB Color +>22 belong 1 Greyscale +>22 belong 2 Indexed Color +>22 belong >2 Unknown Image Type. + +#------------------------------------------------------------------------------ +# XCF: file(1) magic for the patterns used in the GIMP, developed +# by Spencer Kimball and Peter Mattis +# ('Bucky' LaDieu, nega@vt.edu) + +20 string GPAT GIMP pattern data, +>24 string x %s + +#------------------------------------------------------------------------------ +# XCF: file(1) magic for the brushes used in the GIMP, developed +# by Spencer Kimball and Peter Mattis +# ('Bucky' LaDieu, nega@vt.edu) + +20 string GIMP GIMP brush data diff --git a/dest/share/magic/gpg b/dest/share/magic/gpg new file mode 100644 index 00000000000..6037a9fcf52 --- /dev/null +++ b/dest/share/magic/gpg @@ -0,0 +1,15 @@ +0 string BEGIN\ PGP\ PRIVATE\ KEY\ BLOCK PGP Private key +0 string BEGIN\ PGP\ PUBLIC\ KEY\ BLOCK PGP Public key +0 string BEGIN\ PRIVATE\ KEY PGP Private key +0 string BEGIN\ PUBLIC\ KEY Public key +0 string \x8c\x0d\x04\x01\x03\x02 GPG-IDEA +0 string \x8c\x0d\x04\x02\x03\x02 GPG-3DES +0 string \x8c\x0d\x04\x03\x03\x02 GPG-CAST5 +0 string \x8c\x0d\x04\x04\x03\x02 GPG-BLOWFISH +0 string \x8c\x0d\x04\x07\x03\x02 GPG-AES128 +0 string \x8c\x0d\x04\x08\x03\x02 GPG-AES192 +0 string \x8c\x0d\x04\x09\x03\x02 GPG-AES256 +0 string \x8c\x0d\x04\x0a\x03\x02 GPG-TWOFISH +0 string \x8c\x0d\x04\x0b\x03\x02 GPG-CAMELLIA128 +0 string \x8c\x0d\x04\x0c\x03\x02 GPG-CAMELLIA192 +0 string \x8c\x0d\x04\x0d\x03\x02 GPG-CAMELLIA256 diff --git a/dest/share/magic/html b/dest/share/magic/html new file mode 100644 index 00000000000..4f4419999c3 --- /dev/null +++ b/dest/share/magic/html @@ -0,0 +1,2 @@ +0 string \74html\76 HTML document +0 string \74HTML\76 HTML document diff --git a/dest/share/magic/images b/dest/share/magic/images new file mode 100644 index 00000000000..751ca95608b --- /dev/null +++ b/dest/share/magic/images @@ -0,0 +1,182 @@ +# $OpenBSD: images,v 1.10 2009/04/24 18:54:34 chl Exp $ + +#------------------------------------------------------------------------------ +# images: file(1) magic for image formats (see also "iff", and "c-lang" for +# XPM bitmaps) +# +# originally from jef@helios.ee.lbl.gov (Jef Poskanzer), +# additions by janl@ifi.uio.no as well as others. Jan also suggested +# merging several one- and two-line files into here. +# +# little magic: PCX (first byte is 0x0a) + +# Tag Image File Format, from Daniel Quinlan (quinlan@yggdrasil.com) +# The second word of TIFF files is the TIFF version number, 42, which has +# never changed. The TIFF specification recommends testing for it. +0 string MM\x00\x2a TIFF image data, big-endian +!:mime image/tiff +0 string II\x2a\x00 TIFF image data, little-endian +!:mime image/tiff + +# PNG [Portable Network Graphics, or "PNG's Not GIF"] images +# (Greg Roelofs, newt@uchicago.edu) +# (Albert Cahalan, acahalan@cs.uml.edu) +# +# 137 P N G \r \n ^Z \n [4-byte length] H E A D [HEAD data] [HEAD crc] ... +# +0 string \x89PNG PNG image data, +!:mime image/png +>4 belong !0x0d0a1a0a CORRUPTED, +>4 belong 0x0d0a1a0a +>>16 belong x %d x +>>20 belong x %d, +>>24 byte x %d-bit +>>25 byte 0 grayscale, +>>25 byte 2 \b/color RGB, +>>25 byte 3 colormap, +>>25 byte 4 gray+alpha, +>>25 byte 6 \b/color RGBA, +#>>26 byte 0 deflate/32K, +>>28 byte 0 non-interlaced +>>28 byte 1 interlaced +1 string PNG PNG image data, CORRUPTED + +# GIF +0 string GIF8 GIF image data +!:mime image/gif +>4 string 7a \b, version 8%s, +>4 string 9a \b, version 8%s, +>6 leshort >0 %d x +>8 leshort >0 %d +#>10 byte &0x80 color mapped, +#>10 byte&0x07 =0x00 2 colors +#>10 byte&0x07 =0x01 4 colors +#>10 byte&0x07 =0x02 8 colors +#>10 byte&0x07 =0x03 16 colors +#>10 byte&0x07 =0x04 32 colors +#>10 byte&0x07 =0x05 64 colors +#>10 byte&0x07 =0x06 128 colors +#>10 byte&0x07 =0x07 256 colors + +# ITC (CMU WM) raster files. It is essentially a byte-reversed Sun raster, +# 1 plane, no encoding. +0 string \361\0\100\273 CMU window manager raster image data +>4 lelong >0 %d x +>8 lelong >0 %d, +>12 lelong >0 %d-bit + +# Magick Image File Format +0 string id=ImageMagick MIFF image data + +# FIG (Facility for Interactive Generation of figures), an object-based format +0 search/1 #FIG FIG image text +>5 string x \b, version %.3s + +# XPM icons (Greg Roelofs, newt@uchicago.edu) +# note possible collision with C/REXX entry in c-lang; currently commented out +0 search/1 /*\ XPM\ */ X pixmap image text + +# Utah Raster Toolkit RLE images (janl@ifi.uio.no) +#0 leshort 0xcc52 RLE image data, +#>6 leshort x %d x +#>8 leshort x %d +#>2 leshort >0 \b, lower left corner: %d +#>4 leshort >0 \b, lower right corner: %d +#>10 byte&0x1 =0x1 \b, clear first +#>10 byte&0x2 =0x2 \b, no background +#>10 byte&0x4 =0x4 \b, alpha channel +#>10 byte&0x8 =0x8 \b, comment +#>11 byte >0 \b, %d color channels +#>12 byte >0 \b, %d bits per pixel +#>13 byte >0 \b, %d color map channels + +# +#2048 string PCD_IPI Kodak Photo CD image pack file +#>0xe02 byte&0x03 0x00 , landscape mode +#>0xe02 byte&0x03 0x01 , portrait mode +#>0xe02 byte&0x03 0x02 , landscape mode +#>0xe02 byte&0x03 0x03 , portrait mode +#0 string PCD_OPA Kodak Photo CD overview pack file + +# FITS format. Jeff Uphoff +# FITS is the Flexible Image Transport System, the de facto standard for +# data and image transfer, storage, etc., for the astronomical community. +# (FITS floating point formats are big-endian.) +0 string SIMPLE\ \ = FITS image data +>109 string 8 \b, 8-bit, character or unsigned binary integer +>108 string 16 \b, 16-bit, two's complement binary integer +>107 string \ 32 \b, 32-bit, two's complement binary integer +>107 string -32 \b, 32-bit, floating point, single precision +>107 string -64 \b, 64-bit, floating point, double precision + +# SMJPEG. A custom Motion JPEG format used by Loki Entertainment +# Software Torbjorn Andersson . +# +0 string \0\nSMJPEG SMJPEG +>8 belong x %d.x data +# According to the specification you could find any number of _TXT +# headers here, but I can't think of any way of handling that. None of +# the SMJPEG files I tried it on used this feature. Even if such a +# file is encountered the output should still be reasonable. +>16 string _SND \b, +>>24 beshort >0 %d Hz +>>26 byte 8 8-bit +>>26 byte 16 16-bit +>>28 string NONE uncompressed +# >>28 string APCM ADPCM compressed +>>27 byte 1 mono +>>28 byte 2 stereo +# Help! Isn't there any way to avoid writing this part twice? +>>32 string _VID \b, +# >>>48 string JFIF JPEG +>>>40 belong >0 %d frames +>>>44 beshort >0 (%d x +>>>46 beshort >0 %d) +>16 string _VID \b, +# >>32 string JFIF JPEG +>>24 belong >0 %d frames +>>28 beshort >0 (%d x +>>30 beshort >0 %d) + +0 string Paint\ Shop\ Pro\ Image\ File Paint Shop Pro Image File + +# "thumbnail file" (icon) +# descended from "xv", but in use by other applications as well (Wolfram Kleff) +0 string P7\ 332 XV "thumbnail file" (icon) data + +# partimage: file(1) magic for PartImage files (experimental, incomplete) +# Author: Hans-Joachim Baader +0 string PaRtImAgE-VoLuMe PartImage +>0x0020 string 0.6.1 file version %s +>>0x0060 lelong >-1 volume %d +#>>0x0064 8 byte identifier +#>>0x007c reserved +>>0x0200 string >\0 type %s +>>0x1400 string >\0 device %s, +>>0x1600 string >\0 original filename %s, +# Some fields omitted +>>0x2744 lelong 0 not compressed +>>0x2744 lelong 1 gzip compressed +>>0x2744 lelong 2 bzip2 compressed +>>0x2744 lelong >2 compressed with unknown algorithm +>0x0020 string >0.6.1 file version %s +>0x0020 string <0.6.1 file version %s + +# DCX is multi-page PCX, using a simple header of up to 1024 +# offsets for the respective PCX components. +# From: Joerg Wunsch +0 lelong 987654321 DCX multi-page PCX image data + +# Simon Walton +# Kodak Cineon format for scanned negatives +# http://www.kodak.com/US/en/motion/support/dlad/ +# 0 lelong 0xd75f2a80 Cineon image data +# >200 belong >0 \b, %ld x +# >204 belong >0 %ld + +#----------------------------------------------------------------------- +# From Albert Cahalan +# uncompressed 5:6:5 HighColor image for OLPC XO firmware icons +0 string C565 OLPC firmware icon image data +>4 leshort x %u x +>6 leshort x %u diff --git a/dest/share/magic/java b/dest/share/magic/java new file mode 100644 index 00000000000..03ed78de4c9 --- /dev/null +++ b/dest/share/magic/java @@ -0,0 +1,49 @@ +# $OpenBSD: java,v 1.5 2009/04/24 18:54:34 chl Exp $ + +#------------------------------------------------------------ +# Java ByteCode and Mach-O binaries (e.g., Mac OS X) use the +# same magic number, 0xcafebabe, so they are both handled +# in the entry called "cafebabe". +#------------------------------------------------------------ +# Java serialization +# From Martin Pool (m.pool@pharos.com.au) +#0 beshort 0xaced Java serialization data +#>2 beshort >0x0004 \b, version %d + +0 belong 0xfeedfeed Java KeyStore +!:mime application/x-java-keystore +# 0 belong 0xcececece Java JCE KeyStore +# !:mime application/x-java-jce-keystore + +# Android .dex format. http://retrodev.com/android/dexformat.html +# https://source.android.com/devices/tech/dalvik/dex-format.html +# From "Mike Fleming" +0 string dex\n +>0 regex dex\n[0-9][0-9][0-9]\0 Android DEX file +>4 string >000 version %s +0 string dey\n +>0 regex dey\n[0-9][0-9][0-9]\0 Android ODEX file +>4 string >000 version %s + +# Android .oat format +0 string oat\n +>0 regex oat\n[0-9][0-9][0-9]\0 Android OAT file +>4 string >000 version %s + +# Android .vdex format. +# https://android.googlesource.com/platform/art/+/master/runtime/vdex_file.h#114 +# http://romainthomas.fr/post/android-vdex/ +# https://github.com/anestisb/vdexExtractor/blob/master/src/vdex/vdex_common.h#L30 +0 string vdex +>0 regex vdex[0-9][0-9][0-9]\0 Android VDEX file +>4 string >000 version %s + +# Android .cdex format. https://android.googlesource.com/platform/art/+/android-9.0.0_r3/libdexfile/dex/compact_dex_file.h#29 +0 string cdex +>0 regex cdex[0-9][0-9][0-9]\0 Android CDEX file +>4 string >000 version %s + +# Android .art format. https://source.android.com/devices/tech/dalvik +0 string art\n +>0 regex art\n[0-9][0-9][0-9]\0 Android ART file +>4 string >000 version %s diff --git a/dest/share/magic/jpeg b/dest/share/magic/jpeg new file mode 100644 index 00000000000..c791e82864a --- /dev/null +++ b/dest/share/magic/jpeg @@ -0,0 +1,166 @@ +# $OpenBSD: jpeg,v 1.4 2009/04/24 18:54:34 chl Exp $ + +#------------------------------------------------------------------------------ +# JPEG images +# SunOS 5.5.1 had +# +# 0 string \377\330\377\340 JPEG file +# 0 string \377\330\377\356 JPG file +# +# both of which turn into "JPEG image data" here. +# +0 string \xff\xd8\xff JPEG image +>6 string JFIF , JFIF standard +>6 string Exif , EXIF standard + +# 0 beshort 0xffd8 +# !:mime image/jpeg +# >6 string JFIF JPEG image data\b, JFIF standard +# # The following added by Erik Rossen 1999-09-06 +# # in a vain attempt to add image size reporting for JFIF. Note that these +# # tests are not fool-proof since some perfectly valid JPEGs are currently +# # impossible to specify in magic(4) format. +# # First, a little JFIF version info: +# >>11 byte x \b %d. +# >>12 byte x \b%02d +# # Next, the resolution or aspect ratio of the image: +# #>>13 byte 0 \b, aspect ratio +# #>>13 byte 1 \b, resolution (DPI) +# #>>13 byte 2 \b, resolution (DPCM) +# #>>4 beshort x \b, segment length %d +# # Next, show thumbnail info, if it exists: +# >>18 byte !0 \b, thumbnail %dx +# >>>19 byte x \b%d +# +# # EXIF moved down here to avoid reporting a bogus version number, +# # and EXIF version number printing added. +# # - Patrik R=E5dman +# >6 string Exif JPEG image data\b, EXIF standard +# # Look for EXIF IFD offset in IFD 0, and then look for EXIF version tag in EXIF IFD. +# # All possible combinations of entries have to be enumerated, since no looping +# # is possible. And both endians are possible... +# # The combinations included below are from real-world JPEGs. +# # Little-endian +# >>12 string II +# # IFD 0 Entry #5: +# >>>70 leshort 0x8769 +# # EXIF IFD Entry #1: +# >>>>(78.l+14) leshort 0x9000 +# >>>>>(78.l+23) byte x %c +# >>>>>(78.l+24) byte x \b.%c +# >>>>>(78.l+25) byte !0x30 \b%c +# # IFD 0 Entry #9: +# >>>118 leshort 0x8769 +# # EXIF IFD Entry #3: +# >>>>(126.l+38) leshort 0x9000 +# >>>>>(126.l+47) byte x %c +# >>>>>(126.l+48) byte x \b.%c +# >>>>>(126.l+49) byte !0x30 \b%c +# # IFD 0 Entry #10 +# >>>130 leshort 0x8769 +# # EXIF IFD Entry #3: +# >>>>(138.l+38) leshort 0x9000 +# >>>>>(138.l+47) byte x %c +# >>>>>(138.l+48) byte x \b.%c +# >>>>>(138.l+49) byte !0x30 \b%c +# # EXIF IFD Entry #4: +# >>>>(138.l+50) leshort 0x9000 +# >>>>>(138.l+59) byte x %c +# >>>>>(138.l+60) byte x \b.%c +# >>>>>(138.l+61) byte !0x30 \b%c +# # EXIF IFD Entry #5: +# >>>>(138.l+62) leshort 0x9000 +# >>>>>(138.l+71) byte x %c +# >>>>>(138.l+72) byte x \b.%c +# >>>>>(138.l+73) byte !0x30 \b%c +# # IFD 0 Entry #11 +# >>>142 leshort 0x8769 +# # EXIF IFD Entry #3: +# >>>>(150.l+38) leshort 0x9000 +# >>>>>(150.l+47) byte x %c +# >>>>>(150.l+48) byte x \b.%c +# >>>>>(150.l+49) byte !0x30 \b%c +# # EXIF IFD Entry #4: +# >>>>(150.l+50) leshort 0x9000 +# >>>>>(150.l+59) byte x %c +# >>>>>(150.l+60) byte x \b.%c +# >>>>>(150.l+61) byte !0x30 \b%c +# # EXIF IFD Entry #5: +# >>>>(150.l+62) leshort 0x9000 +# >>>>>(150.l+71) byte x %c +# >>>>>(150.l+72) byte x \b.%c +# >>>>>(150.l+73) byte !0x30 \b%c +# # Big-endian +# >>12 string MM +# # IFD 0 Entry #9: +# >>>118 beshort 0x8769 +# # EXIF IFD Entry #1: +# >>>>(126.L+14) beshort 0x9000 +# >>>>>(126.L+23) byte x %c +# >>>>>(126.L+24) byte x \b.%c +# >>>>>(126.L+25) byte !0x30 \b%c +# # EXIF IFD Entry #3: +# >>>>(126.L+38) beshort 0x9000 +# >>>>>(126.L+47) byte x %c +# >>>>>(126.L+48) byte x \b.%c +# >>>>>(126.L+49) byte !0x30 \b%c +# # IFD 0 Entry #10 +# >>>130 beshort 0x8769 +# # EXIF IFD Entry #3: +# >>>>(138.L+38) beshort 0x9000 +# >>>>>(138.L+47) byte x %c +# >>>>>(138.L+48) byte x \b.%c +# >>>>>(138.L+49) byte !0x30 \b%c +# # EXIF IFD Entry #5: +# >>>>(138.L+62) beshort 0x9000 +# >>>>>(138.L+71) byte x %c +# >>>>>(138.L+72) byte x \b.%c +# >>>>>(138.L+73) byte !0x30 \b%c +# # IFD 0 Entry #11 +# >>>142 beshort 0x8769 +# # EXIF IFD Entry #4: +# >>>>(150.L+50) beshort 0x9000 +# >>>>>(150.L+59) byte x %c +# >>>>>(150.L+60) byte x \b.%c +# >>>>>(150.L+61) byte !0x30 \b%c +# # Here things get sticky. We can do ONE MORE marker segment with +# # indirect addressing, and that's all. It would be great if we could +# # do pointer arithemetic like in an assembler language. Christos? +# # And if there was some sort of looping construct to do searches, plus a few +# # named accumulators, it would be even more effective... +# # At least we can show a comment if no other segments got inserted before: +# >(4.S+5) byte 0xFE +# >>(4.S+8) string >\0 \b, comment: "%s" +# #>(4.S+5) byte 0xFE \b, comment +# #>>(4.S+6) beshort x \b length=%d +# #>>(4.S+8) string >\0 \b, "%s" +# # Or, we can show the encoding type (I've included only the three most common) +# # and image dimensions if we are lucky and the SOFn (image segment) is here: +# >(4.S+5) byte 0xC0 \b, baseline +# >>(4.S+6) byte x \b, precision %d +# >>(4.S+7) beshort x \b, %dx +# >>(4.S+9) beshort x \b%d +# >(4.S+5) byte 0xC1 \b, extended sequential +# >>(4.S+6) byte x \b, precision %d +# >>(4.S+7) beshort x \b, %dx +# >>(4.S+9) beshort x \b%d +# >(4.S+5) byte 0xC2 \b, progressive +# >>(4.S+6) byte x \b, precision %d +# >>(4.S+7) beshort x \b, %dx +# >>(4.S+9) beshort x \b%d +# # I've commented-out quantisation table reporting. I doubt anyone cares yet. +# #>(4.S+5) byte 0xDB \b, quantisation table +# #>>(4.S+6) beshort x \b length=%d +# #>14 beshort x \b, %d x +# #>16 beshort x \b %d +# +# # HSI is Handmade Software's proprietary JPEG encoding scheme +# #0 string hsi1 JPEG image data, HSI proprietary +# +# # From: David Santinoli +# 0 string \x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A JPEG 2000 image data +# +# # Type: JPEG 2000 codesream +# # From: Mathieu Malaterre +# 0 belong 0xff4fff51 JPEG 2000 codestream +# 45 beshort 0xff52 diff --git a/dest/share/magic/linux b/dest/share/magic/linux new file mode 100644 index 00000000000..2ebba04319c --- /dev/null +++ b/dest/share/magic/linux @@ -0,0 +1,227 @@ +# $OpenBSD: linux,v 1.6 2009/04/24 18:54:34 chl Exp $ + +#------------------------------------------------------------------------------ +# linux: file(1) magic for Linux files +# +# Values for Linux/i386 binaries, from Daniel Quinlan +# The following basic Linux magic is useful for reference, but using +# "long" magic is a better practice in order to avoid collisions. +# +# 2 leshort 100 Linux/i386 +# >0 leshort 0407 impure executable (OMAGIC) +# >0 leshort 0410 pure executable (NMAGIC) +# >0 leshort 0413 demand-paged executable (ZMAGIC) +# >0 leshort 0314 demand-paged executable (QMAGIC) +# +0 lelong 0x00640107 Linux/i386 impure executable (OMAGIC) +>16 lelong 0 \b, stripped +0 lelong 0x00640108 Linux/i386 pure executable (NMAGIC) +>16 lelong 0 \b, stripped +0 lelong 0x0064010b Linux/i386 demand-paged executable (ZMAGIC) +>16 lelong 0 \b, stripped +0 lelong 0x006400cc Linux/i386 demand-paged executable (QMAGIC) +>16 lelong 0 \b, stripped +# +# 0 string \007\001\000 Linux/i386 object file +# >20 lelong >0x1020 \b, DLL library +# +# 0 string \01\03\020\20 Minix-386 impure executable +# >28 long !0 not stripped +# 0 string \01\03\040\20 Minix-386 executable +# >28 long !0 not stripped +# # core dump file, from Bill Reynolds +# 216 lelong 0421 Linux/i386 core file +# >220 string >\0 of '%s' +# >200 lelong >0 (signal %d) +# +# LILO boot/chain loaders, from Daniel Quinlan +# this can be overridden by the DOS executable (COM) entry +#2 string LILO Linux/i386 LILO boot/chain loader +# +# Linux swap file, from Daniel Quinlan +4086 string SWAP-SPACE Linux/i386 swap file +# From: Jeff Bailey +# Linux swap file with swsusp1 image, from Jeff Bailey +4076 string SWAPSPACE2S1SUSPEND Linux/i386 swap file (new style) with SWSUSP1 image +# according to man page of mkswap (8) March 1999 +4086 string SWAPSPACE2 Linux/i386 swap file (new style) +>0x400 long x %d (4K pages) +>0x404 long x size %d pages +>>4086 string SWAPSPACE2 +>>>1052 string >\0 Label %s +# Linux kernel boot images, from Albert Cahalan +# and others such as Axel Kohlmeyer +# and Nicol�s Lichtmaier +# All known start with: b8 c0 07 8e d8 b8 00 90 8e c0 b9 00 01 29 f6 29 +# Linux kernel boot images (i386 arch) (Wolfram Kleff) +514 string HdrS Linux kernel +>510 leshort 0xAA55 x86 boot executable +>>518 leshort >0x1ff +>>529 byte 0 zImage, +>>>529 byte 1 bzImage, +>>>(526.s+0x200) string >\0 version %s, +>>498 leshort 1 RO-rootFS, +>>498 leshort 0 RW-rootFS, +>>508 leshort >0 root_dev 0x%X, +>>502 leshort >0 swap_dev 0x%X, +>>504 leshort >0 RAMdisksize %u KB, +>>506 leshort 0xFFFF Normal VGA +>>506 leshort 0xFFFE Extended VGA +>>506 leshort 0xFFFD Prompt for Videomode +>>506 leshort >0 Video mode %d +# This also matches new kernels, which were caught above by "HdrS". +0 belong 0xb8c0078e Linux kernel +>0x1e3 string Loading version 1.3.79 or older +>0x1e9 string Loading from prehistoric times + +# System.map files - Nicol�s Lichtmaier +8 search/1 \ A\ _text Linux kernel symbol map text + +# LSM entries - Nicol�s Lichtmaier +0 search/1 Begin3 Linux Software Map entry text +0 search/1 Begin4 Linux Software Map entry text (new format) + +# From Matt Zimmerman, enhanced for v3 by Matthew Palmer +0 belong 0x4f4f4f4d User-mode Linux COW file +>4 belong <3 \b, version %d +>>8 string >\0 \b, backing file %s +>4 belong >2 \b, version %d +>>32 string >\0 \b, backing file %s + +############################################################################ +# Linux kernel versions + +0 string \xb8\xc0\x07\x8e\xd8\xb8\x00\x90 Linux +>497 leshort 0 x86 boot sector +>>514 belong 0x8e of a kernel from the dawn of time! +>>514 belong 0x908ed8b4 version 0.99-1.1.42 +>>514 belong 0x908ed8b8 for memtest86 + +>497 leshort !0 x86 kernel +>>504 leshort >0 RAMdisksize=%u KB +>>502 leshort >0 swap=0x%X +>>508 leshort >0 root=0x%X +>>>498 leshort 1 \b-ro +>>>498 leshort 0 \b-rw +>>506 leshort 0xFFFF vga=normal +>>506 leshort 0xFFFE vga=extended +>>506 leshort 0xFFFD vga=ask +>>506 leshort >0 vga=%d +>>514 belong 0x908ed881 version 1.1.43-1.1.45 +>>514 belong 0x15b281cd +>>>0xa8e belong 0x55AA5a5a version 1.1.46-1.2.13,1.3.0 +>>>0xa99 belong 0x55AA5a5a version 1.3.1,2 +>>>0xaa3 belong 0x55AA5a5a version 1.3.3-1.3.30 +>>>0xaa6 belong 0x55AA5a5a version 1.3.31-1.3.41 +>>>0xb2b belong 0x55AA5a5a version 1.3.42-1.3.45 +>>>0xaf7 belong 0x55AA5a5a version 1.3.46-1.3.72 +>>514 string HdrS +>>>518 leshort >0x1FF +>>>>529 byte 0 \b, zImage +>>>>529 byte 1 \b, bzImage +>>>>(526.s+0x200) string >\0 \b, version %s + +# Linux boot sector thefts. +0 belong 0xb8c0078e Linux +>0x1e6 belong 0x454c4b53 ELKS Kernel +>0x1e6 belong !0x454c4b53 style boot sector + +# 0 lelong&0xFF00FFFF 0x4000301 Linux-8086 executable +# >2 byte&0x01 !0 \b, unmapped zero page +# >2 byte&0x20 0 \b, impure +# >2 byte&0x20 !0 +# >>2 byte&0x10 !0 \b, A_EXEC +# >2 byte&0x02 !0 \b, A_PAL +# >2 byte&0x04 !0 \b, A_NSYM +# >2 byte&0x08 !0 \b, A_STAND +# >2 byte&0x40 !0 \b, A_PURE +# >2 byte&0x80 !0 \b, A_TOVLY +# >28 long !0 \b, not stripped +# >37 string . +# >>36 string >\0 \b, libc version %s + +# 0 lelong&0xFF00FFFF 0x10000301 ld86 I80386 executable +# 0 lelong&0xFF00FFFF 0xB000301 ld86 M68K executable +# 0 lelong&0xFF00FFFF 0xC000301 ld86 NS16K executable +# 0 lelong&0xFF00FFFF 0x17000301 ld86 SPARC executable + +# SYSLINUX boot logo files (from 'ppmtolss16' sources) +# http://syslinux.zytor.com/ +# +0 lelong =0x1413f33d SYSLINUX' LSS16 image data +>4 leshort x \b, width %d +>6 leshort x \b, height %d + +0 string OOOM User-Mode-Linux's Copy-On-Write disk image +>4 belong x version %d + +# SE Linux policy database +# From: Mike Frysinger +0 lelong 0xf97cff8c SE Linux policy +>16 lelong x v%d +>20 lelong 1 MLS +>24 lelong x %d symbols +>28 lelong x %d ocons + +# Linux Logical Volume Manager (LVM) +# Emmanuel VARAGNAT +# +# System ID, UUID and volume group name are 128 bytes long +# but they should never be full and initialized with zeros... +# +# LVM1 +# +0x0 string HM\001 LVM1 (Linux Logical Volume Manager), version 1 +>0x12c string >\0 , System ID: %s + +0x0 string HM\002 LVM1 (Linux Logical Volume Manager), version 2 +>0x12c string >\0 , System ID: %s + +# LVM2 +# +# It seems that the label header can be in one the four first sector +# of the disk... (from _find_labeller in lib/label/label.c of LVM2) +# +# 0x200 seems to be the common case + +0x218 string LVM2\ 001 LVM2 (Linux Logical Volume Manager) +# read the offset to add to the start of the header, and the header +# start in 0x200 +>(0x214.l+0x200) string >\0 , UUID: %s + +0x018 string LVM2\ 001 LVM2 (Linux Logical Volume Manager) +>(0x014.l) string >\0 , UUID: %s + +0x418 string LVM2\ 001 LVM2 (Linux Logical Volume Manager) +>(0x414.l+0x400) string >\0 , UUID: %s + +0x618 string LVM2\ 001 LVM2 (Linux Logical Volume Manager) +>(0x614.l+0x600) string >\0 , UUID: %s + +# SE Linux policy database +0 lelong 0xf97cff8c SE Linux policy +>16 lelong x v%d +>20 lelong 1 MLS +>24 lelong x %d symbols +>28 lelong x %d ocons + +# LUKS: Linux Unified Key Setup, On-Disk Format, http://luks.endorphin.org/spec +# Anthon van der Neut (anthon@mnt.org) +0 string LUKS\xba\xbe LUKS encrypted file, +>6 beshort x ver %d +>8 string x [%s, +>40 string x %s, +>72 string x %s] +>168 string x UUID: %s + +0 string #!/bin/sh Shellscript + + +############################################################################ +# Android + +# Android bootimg: +# https://android.googlesource.com/platform/system/tools/mkbootimg/+/refs/heads/master/include/bootimg/bootimg.h +0 string ANDROID! Android boot image +0 string VNDRBOOT Android vendor boot image + diff --git a/dest/share/magic/mach b/dest/share/magic/mach new file mode 100644 index 00000000000..ff9f8358bd3 --- /dev/null +++ b/dest/share/magic/mach @@ -0,0 +1,25 @@ + +#------------------------------------------------------------ +# $File: mach,v 1.18 2014/03/29 15:40:34 christos Exp $ +# Mach has two magic numbers, 0xcafebabe and 0xfeedface. +# Unfortunately the first, cafebabe, is shared with +# Java ByteCode, so they are both handled in the file "cafebabe". +# The "feedface" ones are handled herein. +#------------------------------------------------------------ +# if set, it's for the 64-bit version of the architecture +# yes, this is separate from the low-order magic number bit +# it's also separate from the "64-bit libraries" bit in the +# upper 8 bits of the CPU subtype + + + +# +0 lelong&0xfffffffe 0xfeedface Mach-O + +0 belong&0xfffffffe 0xfeedface Mach-O +0 belong&0xfffffffe 0xcafebabe +>8 byte 0x00 Java CLASS +>8 byte !0x00 Fat-Mach-O + + +0 lelong&0xffffffff 0xc00cdefa MacOS Deteched Code Signature diff --git a/dest/share/magic/mail.news b/dest/share/magic/mail.news new file mode 100644 index 00000000000..d8902728c71 --- /dev/null +++ b/dest/share/magic/mail.news @@ -0,0 +1,55 @@ +# $OpenBSD: mail.news,v 1.6 2009/04/24 18:54:34 chl Exp $ + +#------------------------------------------------------------------------------ +# mail.news: file(1) magic for mail and news +# +# Unfortunately, saved netnews also has From line added in some news software. +#0 string From mail text +# There are tests to ascmagic.c to cope with mail and news. +0 string Relay-Version: old news text +!:mime message/rfc822 +0 string #!\ rnews batched news text +!:mime message/rfc822 +0 string N#!\ rnews mailed, batched news text +!:mime message/rfc822 +0 string Forward\ to mail forwarding text +!:mime message/rfc822 +0 string Pipe\ to mail piping text +!:mime message/rfc822 +0 string Return-Path: smtp mail text +!:mime message/rfc822 +0 string Path: news text +!:mime message/news +0 string Xref: news text +!:mime message/news +0 string From: news or mail text +!:mime message/rfc822 +0 string Article saved news text +!:mime message/news +0 string BABYL Emacs RMAIL text +0 string Received: RFC 822 mail text +!:mime message/rfc822 +0 string MIME-Version: MIME entity text +#0 string Content- MIME entity text + +# TNEF files... +0 lelong 0x223E9F78 Transport Neutral Encapsulation Format + +# From: Kevin Sullivan +0 string *mbx* MBX mail folder + +# From: Simon Matter +0 string \241\002\213\015skiplist\ file\0\0\0 Cyrus skiplist DB + +# JAM(mbp) Fidonet message area databases +# JHR file +0 string JAM\0 JAM message area header file +>12 leshort >0 (%d messages) + +# Squish Fidonet message area databases +# SQD file (requires at least one message in the area) +# XXX: Weak magic +#256 leshort 0xAFAE4453 Squish message area data file +#>4 leshort >0 (%d messages) + +#0 string \ code == HT_RC_ERROR - * code >= 0 <--> code != HT_RC_ERROR - * code > 0 <--> code == HT_RC_INSERTED || code == HT_RC_UPDATED - */ -typedef enum { - HT_RC_ERROR = -1, ///< Error (out of memory) - HT_RC_EXISTING = 0, ///< Existing KV prevented an insertion - HT_RC_INSERTED = 1, ///< New KV was inserted during insert/update operation - HT_RC_UPDATED = 2, ///< Existing KV was updated during update operation -} HtRetCode; - -typedef enum { - HT_STR_DUP = 0, ///< String is copied when inserting into HT - HT_STR_OWN, ///< String ownership is transferred when inserting into HT - HT_STR_CONST ///< String is treated as constant and not copied when inserting into HT -} HtStrOption; -#endif - -#include - -/* Kv represents a single key/value element in the hashtable */ -typedef struct Ht_(kv) { - KEY_TYPE key; - VALUE_TYPE value; - ut32 key_len; - ut32 value_len; -} HT_(Kv); - -typedef void (*HT_(FiniKv))(HT_(Kv) *kv, void *user); -typedef KEY_TYPE (*HT_(DupKey))(const KEY_TYPE); -typedef VALUE_TYPE (*HT_(DupValue))(const VALUE_TYPE); -typedef void (*HT_(FreeValue))(VALUE_TYPE val); -typedef ut32 (*HT_(CalcSizeK))(const KEY_TYPE); -typedef ut32 (*HT_(CalcSizeV))(const VALUE_TYPE); -typedef ut32 (*HT_(HashFunction))(const KEY_TYPE); -typedef int (*HT_(Comparator))(const KEY_TYPE, const KEY_TYPE); -typedef bool (*HT_(ForeachCallback))(void *user, const KEY_TYPE, const VALUE_TYPE); - -typedef struct Ht_(bucket_t) { - HT_(Kv) *arr; - ut32 count; -} HT_(Bucket); - -/** - * Options contain all the settings of the hashtable. - */ -typedef struct Ht_(options_t) { - HT_(Comparator) cmp; ///< RZ_NULLABLE. Function for comparing keys. - ///< Returns 0 if keys are equal. - ///< Function is invoked only if == operator applied to keys returns false. - HT_(HashFunction) hashfn; ///< RZ_NULLABLE. Function for hashing items in the hash table. - ///< If NULL KEY_TO_HASH macro is used. - HT_(DupKey) dupkey; ///< RZ_NULLABLE. Function for making a copy of key. - ///< If NULL simple assignment operator is used. - HT_(DupValue) dupvalue; ///< RZ_NULLABLE. Function for making a copy of value. - ///< If NULL simple assignment operator is used. - HT_(CalcSizeK) calcsizeK; ///< RZ_NULLABLE. Function to determine the key's size. - ///< If NULL zero value is used as a size. - ///< Key sizes are checked on equality during keys comparsion as a pre-check. - HT_(CalcSizeV) calcsizeV; ///< RZ_NULLABLE. Function to determine the value's size. - ///< If NULL zero value is used as a size. - ///< Not required for common scenarios. Could be used in subclasses. - HT_(FiniKv) finiKV; ///< RZ_NULLABLE. Function to clean up the key-value store. - void *finiKV_user; ///< RZ_NULLABLE. User data which is passed into finiKV. - size_t elem_size; ///< Size of each HtKv element (useful for subclassing like SdbKv). - ///< Zero value means to use default size of HtKv. -} HT_(Options); - -/* Ht is the hashtable structure */ -typedef struct Ht_(t) { - ut32 size; ///< Size of the hash table in buckets. - ut32 count; ///< Number of stored elements. - HT_(Bucket) *table; ///< Actual table. - ut32 prime_idx; - HT_(Options) opt; -} HtName_(Ht); - -typedef struct Ht_(iter_mut_t) { - HtName_(Ht) *ht; ///< The hash table to iterate over. - ut32 ti; ///< Table index - ut32 bi; ///< Bucket index - HT_(Kv) *kv; ///< Current Key-Value-pair. -} HT_(IterMutState); - -typedef struct Ht_(iter_t) { - const HtName_(Ht) *ht; ///< The hash table to iterate over. - ut32 ti; ///< Table index - ut32 bi; ///< Bucket index - const HT_(Kv) *kv; ///< Current Key-Value-pair. -} HT_(IterState); - -// Create a new Ht with the provided Options -RZ_API RZ_OWN HtName_(Ht) *Ht_(new_opt)(RZ_NONNULL HT_(Options) *opt); -// Create a new Ht with the provided Options and initial size -RZ_API RZ_OWN HtName_(Ht) *Ht_(new_opt_size)(RZ_NONNULL HT_(Options) *opt, ut32 initial_size); -// Destroy a hashtable and all of its entries. -RZ_API void Ht_(free)(RZ_NULLABLE HtName_(Ht) *ht); -// Insert a new Key-Value pair into the hashtable. If the key already exists, returns false. -RZ_API bool Ht_(insert)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, VALUE_TYPE value); -RZ_API HtRetCode Ht_(insert_ex)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, VALUE_TYPE value, RZ_OUT RZ_NULLABLE HT_(Kv) **out_kv); -// Insert a new Key-Value pair into the hashtable, or updates the value if the key already exists. -RZ_API bool Ht_(update)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, VALUE_TYPE value); -RZ_API HtRetCode Ht_(update_ex)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, VALUE_TYPE value, RZ_OUT RZ_NULLABLE HT_(Kv) **out_kv); -// Update the key of an element in the hashtable -RZ_API bool Ht_(update_key)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE old_key, const KEY_TYPE new_key); -// Delete a key from the hashtable. -RZ_API bool Ht_(delete)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key); -// Find the value corresponding to the matching key. -RZ_API VALUE_TYPE Ht_(find)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, RZ_NULLABLE bool *found); -// Iterates over all elements in the hashtable, calling the cb function on each Kv. -// If the cb returns false, the iteration is stopped. -// cb should not modify the hashtable. -// NOTE: cb can delete the current element, but it should be avoided -RZ_API void Ht_(foreach)(RZ_NONNULL HtName_(Ht) *ht, RZ_NONNULL HT_(ForeachCallback) cb, RZ_NULLABLE void *user); - -RZ_API ut32 Ht_(size)(const RZ_NONNULL HtName_(Ht) *ht); - -RZ_API RZ_BORROW HT_(Kv) *Ht_(find_kv)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, RZ_NULLABLE bool *found); -RZ_API bool Ht_(insert_kv)(RZ_NONNULL HtName_(Ht) *ht, RZ_NONNULL HT_(Kv) *kv, bool update); -RZ_API HtRetCode Ht_(insert_kv_ex)(RZ_NONNULL HtName_(Ht) *ht, RZ_NONNULL HT_(Kv) *kv, bool update, RZ_OUT RZ_NULLABLE HT_(Kv) **out_kv); - -RZ_API RZ_OWN HT_(IterMutState) *Ht_(new_iter_mut_state)(RZ_NONNULL HtName_(Ht) *ht); -RZ_API RZ_OWN HT_(IterState) *Ht_(new_iter_state)(const RZ_NONNULL HtName_(Ht) *ht); -RZ_API void Ht_(free_iter_mut_state)(RZ_NULLABLE HT_(IterMutState) *state); -RZ_API void Ht_(free_iter_state)(RZ_NULLABLE HT_(IterState) *state); - -RZ_API RZ_BORROW VALUE_TYPE *Ht_(iter_next_mut)(RzIterator *it); -RZ_API const VALUE_TYPE *Ht_(iter_next)(RzIterator *it); -RZ_API const KEY_TYPE *Ht_(iter_next_key)(RzIterator *it); - -RZ_API RZ_OWN RzIterator /* */ *Ht_(as_iter_mut)(RZ_NONNULL HtName_(Ht) *ht); -RZ_API RZ_OWN RzIterator /* */ *Ht_(as_iter)(const RZ_NONNULL HtName_(Ht) *ht); -RZ_API RZ_OWN RzIterator /* */ *Ht_(as_iter_keys)(const RZ_NONNULL HtName_(Ht) *ht); diff --git a/dest/include/librz/rz_util/ht_pp.h b/dest/include/librz/rz_util/ht_pp.h deleted file mode 100644 index 389b9ad9dae..00000000000 --- a/dest/include/librz/rz_util/ht_pp.h +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-FileCopyrightText: 2016-2018 crowell -// SPDX-FileCopyrightText: 2016-2018 pancake -// SPDX-FileCopyrightText: 2016-2018 ret2libc -// SPDX-License-Identifier: BSD-3-Clause - -#ifndef HT_PP_H -#define HT_PP_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** \file - * This header provides an hash table HtPP that has void* as key and void* as value. - * The API functions starts with "ht_pp_" and the types starts with "HtPP". - */ -#define HT_TYPE 1 -#include -#undef HT_TYPE - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/ht_pu.h b/dest/include/librz/rz_util/ht_pu.h deleted file mode 100644 index d9750870796..00000000000 --- a/dest/include/librz/rz_util/ht_pu.h +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-FileCopyrightText: 2016-2018 crowell -// SPDX-FileCopyrightText: 2016-2018 pancake -// SPDX-FileCopyrightText: 2016-2018 ret2libc -// SPDX-License-Identifier: BSD-3-Clause - -#ifndef HT_PU_H -#define HT_PU_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** \file - * This header provides an hash table HtPU that has void* as key and ut64 as value. - * The API functions starts with "ht_pu_" and the types starts with "HtPU". - */ -#define HT_TYPE 4 -#include -#undef HT_TYPE - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/ht_sp.h b/dest/include/librz/rz_util/ht_sp.h deleted file mode 100644 index bea09f2247a..00000000000 --- a/dest/include/librz/rz_util/ht_sp.h +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-FileCopyrightText: 2024 pelijah -// SPDX-License-Identifier: BSD-3-Clause - -#ifndef HT_SP_H -#define HT_SP_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** \file - * This header provides an hash table HtSP that has C-string as key and void* as value. - * The API functions starts with "ht_sp_" and the types starts with "HtSP". - */ -#define HT_TYPE 5 -#include - -RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(HtStrOption key_opt, RZ_NULLABLE HT_(DupValue) dup_val, RZ_NULLABLE HT_(FreeValue) free_val); -#undef HT_TYPE - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/dest/include/librz/rz_util/ht_ss.h b/dest/include/librz/rz_util/ht_ss.h deleted file mode 100644 index 0ec1c04640c..00000000000 --- a/dest/include/librz/rz_util/ht_ss.h +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-FileCopyrightText: 2024 pelijah -// SPDX-License-Identifier: BSD-3-Clause - -#ifndef HT_SS_H -#define HT_SS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** \file - * This header provides an hash table HtSS that has C-string as key and C-string as value. - * The API functions starts with "ht_ss_" and the types starts with "HtSS". - */ -#define HT_TYPE 6 -#include - -RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(HtStrOption key_opt, HtStrOption val_opt); -#undef HT_TYPE - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/dest/include/librz/rz_util/ht_su.h b/dest/include/librz/rz_util/ht_su.h deleted file mode 100644 index 672127a66da..00000000000 --- a/dest/include/librz/rz_util/ht_su.h +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-FileCopyrightText: 2024 pelijah -// SPDX-License-Identifier: BSD-3-Clause - -#ifndef HT_SU_H -#define HT_SU_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** \file - * This header provides an hash table HtSU that has C-string as key and ut64 as value. - * The API functions starts with "ht_su_" and the types starts with "HtSU". - */ -#define HT_TYPE 7 -#include - -RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(HtStrOption key_opt); -#undef HT_TYPE - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/dest/include/librz/rz_util/ht_up.h b/dest/include/librz/rz_util/ht_up.h deleted file mode 100644 index 7878ef7d08d..00000000000 --- a/dest/include/librz/rz_util/ht_up.h +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-FileCopyrightText: 2016-2018 crowell -// SPDX-FileCopyrightText: 2016-2018 pancake -// SPDX-FileCopyrightText: 2016-2018 ret2libc -// SPDX-FileCopyrightText: 2024 pelijah -// SPDX-License-Identifier: BSD-3-Clause - -#ifndef HT_UP_H -#define HT_UP_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** \file - * This header provides an hash table HtUP that has ut64 as key and void* as value. - * The API functions starts with "ht_up_" and the types starts with "HtUP". - */ -#define HT_TYPE 2 -#include - -RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(RZ_NULLABLE HT_(DupValue) valdup, RZ_NULLABLE HT_(FreeValue) valfree); -RZ_API RZ_OWN HtName_(Ht) *Ht_(new_size)(ut32 initial_size, RZ_NULLABLE HT_(DupValue) valdup, RZ_NULLABLE HT_(FreeValue) valfree); -#undef HT_TYPE - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/ht_uu.h b/dest/include/librz/rz_util/ht_uu.h deleted file mode 100644 index ca48a85a497..00000000000 --- a/dest/include/librz/rz_util/ht_uu.h +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2016-2018 crowell -// SPDX-FileCopyrightText: 2016-2018 pancake -// SPDX-FileCopyrightText: 2016-2018 ret2libc -// SPDX-License-Identifier: BSD-3-Clause - -#ifndef HT_UU_H -#define HT_UU_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** \file - * This header provides an hash table HtUU that has ut64 as key and ut64 as value. - * The API functions starts with "ht_uu" and the types starts with "HtUU". - */ -#define HT_TYPE 3 -#include - -RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(void); -#undef HT_TYPE - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/rz_alloc.h b/dest/include/librz/rz_util/rz_alloc.h deleted file mode 100644 index 1284c707e76..00000000000 --- a/dest/include/librz/rz_util/rz_alloc.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef RZ_ALLOC_H -#define RZ_ALLOC_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -RZ_API RZ_OWN void *rz_mem_alloc(size_t sz); -RZ_API void rz_mem_free(void *); -RZ_API RZ_OWN void *rz_malloc_aligned(size_t size, size_t alignment); -RZ_API void rz_free_aligned(void *p); - -#ifdef __cplusplus -} -#endif -#endif // RZ_ALLOC_H diff --git a/dest/include/librz/rz_util/rz_annotated_code.h b/dest/include/librz/rz_util/rz_annotated_code.h deleted file mode 100644 index 6913642fa44..00000000000 --- a/dest/include/librz/rz_util/rz_annotated_code.h +++ /dev/null @@ -1,180 +0,0 @@ - -#ifndef RZ_ANNOTATEDCODE_H -#define RZ_ANNOTATEDCODE_H - -// #include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum rz_syntax_highlight_type_t { - RZ_SYNTAX_HIGHLIGHT_TYPE_KEYWORD, - RZ_SYNTAX_HIGHLIGHT_TYPE_COMMENT, - RZ_SYNTAX_HIGHLIGHT_TYPE_DATATYPE, - RZ_SYNTAX_HIGHLIGHT_TYPE_FUNCTION_NAME, - RZ_SYNTAX_HIGHLIGHT_TYPE_FUNCTION_PARAMETER, - RZ_SYNTAX_HIGHLIGHT_TYPE_LOCAL_VARIABLE, - RZ_SYNTAX_HIGHLIGHT_TYPE_CONSTANT_VARIABLE, - RZ_SYNTAX_HIGHLIGHT_TYPE_GLOBAL_VARIABLE, -} RSyntaxHighlightType; - -/** Represents the type of annnotation. */ -typedef enum rz_code_annotation_type_t { - RZ_CODE_ANNOTATION_TYPE_OFFSET, /*!< Gives the offset of the specified range in annotation. */ - RZ_CODE_ANNOTATION_TYPE_SYNTAX_HIGHLIGHT, /*!< Represents the kind of data the specified range represents for highlighting purposes. */ - RZ_CODE_ANNOTATION_TYPE_FUNCTION_NAME, /*!< Specified range in annotation represents a function name. */ - RZ_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE, /*!< Specified range in annotation represents a global variable. */ - RZ_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE, /*!< Specified range in annotation represents a constant variable with an address. */ - RZ_CODE_ANNOTATION_TYPE_LOCAL_VARIABLE, /*!< Specified range in annotation represents a local variable. */ - RZ_CODE_ANNOTATION_TYPE_FUNCTION_PARAMETER, /*!< Specified range in annotation represents a function parameter. */ - // ... -} RzCodeAnnotationType; - -/** - * \brief Annotations for the decompiled code are represented using this structure. - */ -typedef struct rz_code_annotation_t { - size_t start; /**< Start of the range in the annotation(inclusive). */ - size_t end; /**< End of the range in the annotation(exclusive). */ - RzCodeAnnotationType type; - union { - /** If the annotation is of type RZ_CODE_ANNOTATION_TYPE_OFFSET, - * offset should be stored in the struct named offset in this union. - */ - struct { - ut64 offset; - } offset; - /** If the annotation is of type RZ_CODE_ANNOTATION_TYPE_SYNTAX_HIGHLIGHT, - * type of the syntax highlight will be stored in the struct named syntax_highlight - * in this union. - */ - struct { - RSyntaxHighlightType type; - } syntax_highlight; - - /** Information in annotations of type RZ_CODE_ANNOTATION_TYPE_FUNCTION_NAME, - * RZ_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE, and RZ_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE - * will be stored in the struct named reference in this union. - */ - struct { - char *name; - ut64 offset; - } reference; - - /** Information in annotations of type RZ_CODE_ANNOTATION_TYPE_LOCAL_VARIABLE - * and RZ_CODE_ANNOTATION_TYPE_FUNCTION_PARAMETER will be stored in the - * struct named variable in this union. - */ - struct { - char *name; - } variable; - }; -} RzCodeAnnotation; -/** - * \brief This structure contains the decompiled code and all the annotations for the decompiled code. - */ -typedef struct rz_annotated_code_t { - char *code; /**< Decompiled code. RzAnnotatedCode owns this string and it must free it. */ - RzVector /**/ annotations; /**< @ref RzVector contains the list of annotations for the decompiled code. */ -} RzAnnotatedCode; - -/** - * @brief Create and initialize a RzAnnotatedCode structure and returns its pointer. - * - * This function creates and initializes a new RzAnnotatedCode - * structure with the specified decompiled code that's passed - * as an argument. Here, the argument code must be a string that can be deallocated. - * This will initialize @ref RzVector annotations as well. - * - * @param code A deallocatable character array. - * @return Pointer to the new RzAnnotatedCode structure created. - */ -RZ_API RzAnnotatedCode *rz_annotated_code_new(char *code); -/** - * @brief Deallocates the dynamically allocated memory for the specified RzAnnotatedCode. - * - * @param code Pointer to a RzAnnotatedCode. - */ -RZ_API void rz_annotated_code_free(RzAnnotatedCode *code); -/** - * @brief Deallocates dynamically allocated memory for the specified annotation. - * - * This function recognizes the type of the specified annotation and - * frees memory that is dynamically allocated for it. - * - * @param e Pointer to the annotation. - * @param user Always NULL for this function. Present here for this function to be of the type @ref RzVectorFree. - */ -RZ_API void rz_annotation_free(void *e, void *user); -/** - * @brief Checks if the specified annotation is a reference. - * - * This function recognizes the type of the specified annotation and returns true if its - * type is any of the following three: RZ_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE, - * RZ_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE, RZ_CODE_ANNOTATION_TYPE_FUNCTION_NAME - * - * @param annotation Pointer to an annotation. - * @return Returns true if the specified annotation is a reference. - */ -RZ_API bool rz_annotation_is_reference(RzCodeAnnotation *annotation); -/** - * @brief Checks if the specified annotation is a function variable. - * - * This function recognizes the type of the specified annotation and returns true if its - * type is any of the following two: RZ_CODE_ANNOTATION_TYPE_LOCAL_VARIABLE, - * RZ_CODE_ANNOTATION_TYPE_FUNCTION_PARAMETER - * - * @param annotation Pointer to an annotation. - * @return Returns true if the specified annotation is a function variable. - */ -RZ_API bool rz_annotation_is_variable(RzCodeAnnotation *annotation); -/** - * @brief Inserts the specified annotation into the list of annotations in the specified RzAnnotatedCode. - * - * @param code Pointer to a RzAnnotatedCode. - * @param annotation Pointer to an annotation. - */ -RZ_API void rz_annotated_code_add_annotation(RzAnnotatedCode *code, RzCodeAnnotation *annotation); -/** - * @brief Returns all annotations with range that contains the given offset. - * - * Creates a @ref RzPVector and inserts the pointers to all annotations in which - * annotation->start <= offset < annotation->end. - * - * @param code Pointer to a RzAnnotatedCode. - * @param offset Offset. - * @return Pointer to the @ref RzPVector created. - */ -RZ_API RzPVector /**/ *rz_annotated_code_annotations_in(RzAnnotatedCode *code, size_t offset); -/** - * @brief Returns all annotations with range that overlap with the specified range. - * - * Creates an @ref RzPVector and inserts the pointers to all annotations whose - * range overlap with range specified. - * - * @param code Pointer to a RzAnnotatedCode. - * @param start Start of the range(inclusive). - * @param end End of the range(exclusive). - * @return Pointer to the @ref RzPVector created. - */ -RZ_API RzPVector /**/ *rz_annotated_code_annotations_range(RzAnnotatedCode *code, size_t start, size_t end); -/** - * @brief Returns the offset for every line of decompiled code in the specified RzAnnotatedCode. - * - * Creates an @ref RzVector and inserts the offsets for every seperate line of decompiled code in - * the specified RzAnnotatedCode. - * If a line of decompiled code doesn't have a unique offset, UT64_MAX is inserted as its offset. - * - * @param code Pointer to a RzAnnotatedCode. - * @return Pointer to the @ref RzVector created. - */ -RZ_API RzVector /**/ *rz_annotated_code_line_offsets(RzAnnotatedCode *code); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_ANNOTATEDCODE_H diff --git a/dest/include/librz/rz_util/rz_ascii_table.h b/dest/include/librz/rz_util/rz_ascii_table.h deleted file mode 100644 index d05a48ffc53..00000000000 --- a/dest/include/librz/rz_util/rz_ascii_table.h +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-FileCopyrightText: 2008-2016 pancake -// SPDX-FileCopyrightText: 2008-2016 r00tus3r -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_ASCII_TABLE_H -#define RZ_ASCII_TABLE_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -RZ_API const char *ret_ascii_table(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/rz_asn1.h b/dest/include/librz/rz_util/rz_asn1.h deleted file mode 100644 index 6160a1621a6..00000000000 --- a/dest/include/librz/rz_util/rz_asn1.h +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef RZ_ASN1_H -#define RZ_ASN1_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define RZ_ASN1_JSON_NULL "null" -#define RZ_ASN1_JSON_EMPTY "{}" - -#define RZ_ASN1_OID_LEN 64 - -/* Masks */ -#define RZ_ASN1_CLASS 0xC0 /* Bits 8 and 7 */ -#define RZ_ASN1_FORM 0x20 /* Bit 6 */ -#define RZ_ASN1_TAG 0x1F /* Bits 5 - 1 */ -#define RZ_ASN1_LENLONG 0x80 /* long form */ -#define RZ_ASN1_LENSHORT 0x7F /* Bits 7 - 1 */ - -/* Classes */ -#define RZ_ASN1_CLASS_UNIVERSAL 0x00 /* 0 = Universal (defined by ITU X.680) */ -#define RZ_ASN1_CLASS_APPLICATION 0x40 /* 1 = Application */ -#define RZ_ASN1_CLASS_CONTEXT 0x80 /* 2 = Context-specific */ -#define RZ_ASN1_CLASS_PRIVATE 0xC0 /* 3 = Private */ - -/* Forms */ -#define RZ_ASN1_FORM_PRIMITIVE 0x00 /* 0 = primitive */ -#define RZ_ASN1_FORM_CONSTRUCTED 0x20 /* 1 = constructed */ - -/* Tags */ -#define RZ_ASN1_TAG_EOC 0x00 /* 0: End-of-contents octets */ -#define RZ_ASN1_TAG_BOOLEAN 0x01 /* 1: Boolean */ -#define RZ_ASN1_TAG_INTEGER 0x02 /* 2: Integer */ -#define RZ_ASN1_TAG_BITSTRING 0x03 /* 2: Bit string */ -#define RZ_ASN1_TAG_OCTETSTRING 0x04 /* 4: Byte string */ -#define RZ_ASN1_TAG_NULL 0x05 /* 5: NULL */ -#define RZ_ASN1_TAG_OID 0x06 /* 6: Object Identifier */ -#define RZ_ASN1_TAG_OBJDESCRIPTOR 0x07 /* 7: Object Descriptor */ -#define RZ_ASN1_TAG_EXTERNAL 0x08 /* 8: External */ -#define RZ_ASN1_TAG_REAL 0x09 /* 9: Real */ -#define RZ_ASN1_TAG_ENUMERATED 0x0A /* 10: Enumerated */ -#define RZ_ASN1_TAG_EMBEDDED_PDV 0x0B /* 11: Embedded Presentation Data Value */ -#define RZ_ASN1_TAG_UTF8STRING 0x0C /* 12: UTF8 string */ -#define RZ_ASN1_TAG_SEQUENCE 0x10 /* 16: Sequence/sequence of */ -#define RZ_ASN1_TAG_SET 0x11 /* 17: Set/set of */ -#define RZ_ASN1_TAG_NUMERICSTRING 0x12 /* 18: Numeric string */ -#define RZ_ASN1_TAG_PRINTABLESTRING 0x13 /* 19: Printable string (ASCII subset) */ -#define RZ_ASN1_TAG_T61STRING 0x14 /* 20: T61/Teletex string */ -#define RZ_ASN1_TAG_VIDEOTEXSTRING 0x15 /* 21: Videotex string */ -#define RZ_ASN1_TAG_IA5STRING 0x16 /* 22: IA5/ASCII string */ -#define RZ_ASN1_TAG_UTCTIME 0x17 /* 23: UTC time */ -#define RZ_ASN1_TAG_GENERALIZEDTIME 0x18 /* 24: Generalized time */ -#define RZ_ASN1_TAG_GRAPHICSTRING 0x19 /* 25: Graphic string */ -#define RZ_ASN1_TAG_VISIBLESTRING 0x1A /* 26: Visible string (ASCII subset) */ -#define RZ_ASN1_TAG_GENERALSTRING 0x1B /* 27: General string */ -#define RZ_ASN1_TAG_UNIVERSALSTRING 0x1C /* 28: Universal string */ -#define RZ_ASN1_TAG_BMPSTRING 0x1E /* 30: Basic Multilingual Plane/Unicode string */ - -typedef struct rz_asn1_string_t { - ut32 length; - const char *string; - bool allocated; -} RzASN1String; - -typedef struct rz_asn1_list_t { - ut32 length; - struct rz_asn1_object_t **objects; -} RzASN1List; - -typedef struct rz_asn1_bin_t { - ut32 length; - ut8 *binary; -} RzASN1Binary; - -typedef struct rz_asn1_object_t { - ut8 klass; /* class type */ - ut8 form; /* defines if contains data or objects */ - ut8 tag; /* tag type */ - const ut8 *sector; /* Sector containing data */ - ut32 length; /* Sector Length */ - ut64 offset; /* Object offset */ - ut64 total_size; /* Object size (including header) */ - RzASN1List list; /* List of objects contained in the sector */ -} RzASN1Object; - -RZ_API RZ_OWN RzASN1Object *rz_asn1_object_parse(RZ_NONNULL const ut8 *buffer, ut32 length); -RZ_API RZ_OWN RzASN1Object *rz_asn1_object_parse_header(RZ_NONNULL const ut8 *buffer, ut32 length); -RZ_API RZ_OWN RzASN1Binary *rz_asn1_binary_parse(RZ_NULLABLE const ut8 *buffer, ut32 length); -RZ_API RZ_OWN RzASN1String *rz_asn1_string_parse(RZ_NULLABLE const char *string, bool allocated, ut32 length); -RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_bits(RZ_NULLABLE const ut8 *buffer, ut32 length); -RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_utctime(RZ_NULLABLE const ut8 *buffer, ut32 length); -RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_time(RZ_NULLABLE const ut8 *buffer, ut32 length); -RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_integer(RZ_NULLABLE const ut8 *buffer, ut32 length); -RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_string(RZ_NULLABLE const ut8 *buffer, ut32 length); -RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_bytes(RZ_NULLABLE const ut8 *buffer, ut32 length); -RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_boolean(RZ_NULLABLE const ut8 *buffer, ut32 length); -RZ_API RZ_OWN RzASN1String *rz_asn1_stringify_oid(RZ_NULLABLE const ut8 *buffer, ut32 length); - -RZ_API void rz_asn1_object_free(RZ_NULLABLE RzASN1Object *object); -RZ_API RZ_OWN char *rz_asn1_to_string(RZ_NULLABLE RzASN1Object *object); -RZ_API RZ_OWN RzStructuredData *rz_asn1_to_structure(RZ_NULLABLE RzASN1Object *object, bool simplified); -RZ_API void rz_asn1_string_free(RZ_NULLABLE RzASN1String *string); -RZ_API void rz_asn1_binary_free(RZ_NULLABLE RzASN1Binary *string); - -#ifdef __cplusplus -} -#endif - -#endif /* RZ_ASN1_H */ diff --git a/dest/include/librz/rz_util/rz_assert.h b/dest/include/librz/rz_util/rz_assert.h deleted file mode 100644 index de135047a9d..00000000000 --- a/dest/include/librz/rz_util/rz_assert.h +++ /dev/null @@ -1,235 +0,0 @@ -#ifndef RZ_ASSERT_H -#define RZ_ASSERT_H - -#include "rz_log.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define RZ_STATIC_ASSERT(x) \ - switch (0) { \ - case 0: \ - case (x):; \ - } - -RZ_API void rz_assert_log(RzLogLevel level, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); - -#if defined(__GNUC__) && defined(__cplusplus) -#define RZ_FUNCTION ((const char *)(__PRETTY_FUNCTION__)) -#elif defined(__STDC__) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define RZ_FUNCTION ((const char *)(__func__)) -#elif defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER > 1300)) -#define RZ_FUNCTION ((const char *)(__FUNCTION__)) -#else -#warning Do not know how to get function name in this setup -#define RZ_FUNCTION ((const char *)("???")) -#endif - -#define rz_warn_if_fail(expr) \ - do { \ - if (!(expr)) { \ - rz_assert_log(RZ_LOGLVL_WARN, "(%s:%d):%s%s runtime check failed: (%s)\n", \ - __FILE__, __LINE__, RZ_FUNCTION, RZ_FUNCTION[0] ? ":" : "", #expr); \ - } \ - } while (0) - -#define rz_warn_if_reached() \ - do { \ - rz_assert_log(RZ_LOGLVL_WARN, "(%s:%d):%s%s code should not be reached\n", \ - __FILE__, __LINE__, RZ_FUNCTION, RZ_FUNCTION[0] ? ":" : ""); \ - } while (0) - -/* - * RZ_CHECKS_LEVEL determines the behaviour of the rz_return/goto/break_* set of functions. - * - * 0: completely disable every function and make them like no-operation - * 1: silently enable checks. Check expressions and do return, but do not log anything - * 2: enable checks and logging (DEFAULT) - * 3: transform them into real assertion - */ -#ifndef RZ_CHECKS_LEVEL -#define RZ_CHECKS_LEVEL 2 -#endif - -#if RZ_CHECKS_LEVEL == 0 - -#define rz_return_if_fail(expr) \ - do { \ - ; \ - } while (0) -#define rz_return_val_if_fail(expr, val) \ - do { \ - ; \ - } while (0) -#define rz_return_if_reached() \ - do { \ - return; \ - } while (0) -#define rz_return_val_if_reached(val) \ - do { \ - return (val); \ - } while (0) - -#define rz_goto_if_fail(expr, where) \ - do { \ - ; \ - } while (0) -#define rz_goto_if_reached(where) \ - do { \ - goto where; \ - } while (0) - -#define rz_break_if_fail(expr) \ - do { \ - ; \ - } while (0) -#define rz_break_if_reached() \ - { \ - break; \ - } - -#elif RZ_CHECKS_LEVEL == 1 || RZ_CHECKS_LEVEL == 2 // RZ_CHECKS_LEVEL - -#if RZ_CHECKS_LEVEL == 1 -#define H_LOG_(loglevel, fmt, ...) -#else -#define H_LOG_(loglevel, fmt, ...) rz_assert_log(loglevel, fmt, __VA_ARGS__) -#endif - -/** - * rz_return_if_fail: - * @expr: the expression to check - * - * Verifies that the expression @expr, usually representing a precondition, - * evaluates to `true`. If the function returns a value, use - * rz_return_val_if_fail() instead. - * - * If @expr evaluates to %FALSE, the current function should be considered to - * have undefined behaviour (a programmer error). The only correct solution - * to such an error is to change the module that is calling the current - * function, so that it avoids this incorrect call. - * - * To make this undefined behaviour visible, if @expr evaluates to %FALSE, - * the result is usually that a critical message is logged and the current - * function returns. - * - */ -#define rz_return_if_fail(expr) \ - do { \ - if (!(expr)) { \ - H_LOG_(RZ_LOGLVL_WARN, "%s: assertion '%s' failed (line %d); exiting function\n", RZ_FUNCTION, #expr, __LINE__); \ - return; \ - } \ - } while (0) - -#define rz_return_val_if_fail(expr, val) \ - do { \ - if (!(expr)) { \ - H_LOG_(RZ_LOGLVL_WARN, "%s: assertion '%s' failed (line %d); returning %s\n", RZ_FUNCTION, #expr, __LINE__, #val); \ - return (val); \ - } \ - } while (0) - -#define rz_return_if_reached() \ - do { \ - H_LOG_(RZ_LOGLVL_ERROR, "file %s: line %d (%s): should not be reached; exiting function\n", __FILE__, __LINE__, RZ_FUNCTION); \ - return; \ - } while (0) - -#define rz_return_val_if_reached(val) \ - do { \ - H_LOG_(RZ_LOGLVL_ERROR, "file %s: line %d (%s): should not be reached; returning %s\n", __FILE__, __LINE__, RZ_FUNCTION, #val); \ - return (val); \ - } while (0) - -#define rz_goto_if_fail(expr, where) \ - do { \ - if (!(expr)) { \ - H_LOG_(RZ_LOGLVL_WARN, "%s: assertion '%s' failed (line %d); jumping to %s\n", RZ_FUNCTION, #expr, __LINE__, #where); \ - goto where; \ - } \ - } while (0) - -#define rz_goto_if_reached(where) \ - do { \ - H_LOG_(RZ_LOGLVL_ERROR, "file %s: line %d (%s): should not be reached; jumping to %s\n", __FILE__, __LINE__, RZ_FUNCTION, #where); \ - goto where; \ - } while (0) - -#define rz_break_if_fail(expr) \ - { \ - if (!(expr)) { \ - H_LOG_(RZ_LOGLVL_WARN, "%s: assertion '%s' failed (line %d); exiting loop\n", RZ_FUNCTION, #expr, __LINE__); \ - break; \ - } \ - } - -#define rz_break_if_reached() \ - { \ - H_LOG_(RZ_LOGLVL_ERROR, "file %s: line %d (%s): should not be reached; exiting loop\n", __FILE__, __LINE__, RZ_FUNCTION); \ - break; \ - } - -#else // RZ_CHECKS_LEVEL - -#include - -#define rz_return_if_fail(expr) \ - do { \ - assert(expr); \ - if (!(expr)) { \ - return; \ - } \ - } while (0) -#define rz_return_val_if_fail(expr, val) \ - do { \ - assert(expr); \ - if (!(expr)) { \ - return (val); \ - } \ - } while (0) -#define rz_return_if_reached() \ - do { \ - assert(false); \ - return; \ - } while (0) -#define rz_return_val_if_reached(val) \ - do { \ - assert(false); \ - return (val); \ - } while (0) - -#define rz_goto_if_fail(expr, where) \ - do { \ - assert(expr); \ - if (!(expr)) { \ - goto where; \ - } \ - } while (0) -#define rz_goto_if_reached(where) \ - do { \ - assert(false); \ - goto where; \ - } while (0) - -#define rz_break_if_fail(expr) \ - { \ - assert(expr); \ - if (!(expr)) { \ - break; \ - } \ - } -#define rz_break_if_reached() \ - { \ - assert(false); \ - break; \ - } - -#endif // RZ_CHECKS_LEVEL - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/rz_axml.h b/dest/include/librz/rz_util/rz_axml.h deleted file mode 100644 index 4c9ff0a7804..00000000000 --- a/dest/include/librz/rz_util/rz_axml.h +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-FileCopyrightText: 2021 keegan -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_AXML_H -#define RZ_AXML_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -RZ_API RZ_OWN char *rz_axml_decode(RZ_NONNULL const ut8 *buffer, const ut64 size); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_AXML_H diff --git a/dest/include/librz/rz_util/rz_base16.h b/dest/include/librz/rz_util/rz_base16.h deleted file mode 100644 index 278431aac67..00000000000 --- a/dest/include/librz/rz_util/rz_base16.h +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-FileCopyrightText: 2025 Ahmed Ibrahim -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_BASE16_H -#define RZ_BASE16_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -RZ_API int rz_base16_encode(RZ_OUT RZ_NONNULL char *bout, RZ_NONNULL const ut8 *bin, size_t sz); -RZ_API int rz_base16_decode(RZ_OUT RZ_NONNULL ut8 *bout, RZ_NONNULL const char *bin); - -RZ_API RZ_OWN char *rz_base16_encode_dyn(RZ_NONNULL const ut8 *bin, size_t sz); -RZ_API RZ_OWN ut8 *rz_base16_decode_dyn(RZ_NONNULL const char *in, st64 len); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_BASE16_H diff --git a/dest/include/librz/rz_util/rz_base32.h b/dest/include/librz/rz_util/rz_base32.h deleted file mode 100644 index bf9e37f0265..00000000000 --- a/dest/include/librz/rz_util/rz_base32.h +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-FileCopyrightText: 2025 Ahmed Ibrahim -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_BASE32_H -#define RZ_BASE32_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -RZ_API size_t rz_base32_encode(RZ_OUT RZ_NONNULL char *bout, RZ_NONNULL const ut8 *bin, size_t sz); -RZ_API st64 rz_base32_decode(RZ_OUT RZ_NONNULL ut8 *bout, RZ_NONNULL const char *bin, st64 len); - -RZ_API RZ_OWN char *rz_base32_encode_dyn(RZ_NONNULL const ut8 *bin, size_t sz); -RZ_API RZ_OWN ut8 *rz_base32_decode_dyn(RZ_NONNULL const char *in, st64 len); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_BASE32_H diff --git a/dest/include/librz/rz_util/rz_base36.h b/dest/include/librz/rz_util/rz_base36.h deleted file mode 100644 index 7f230d6da20..00000000000 --- a/dest/include/librz/rz_util/rz_base36.h +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-FileCopyrightText: 2025 Ahmed Ibrahim -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_BASE36_H -#define RZ_BASE36_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -RZ_API size_t rz_base36_encode(RZ_OUT RZ_NONNULL char *bout, ut64 val); -RZ_API RZ_OWN char *rz_base36_encode_dyn(ut64 val); - -RZ_API st64 rz_base36_decode(RZ_OUT RZ_NONNULL ut64 *bout, RZ_NONNULL const char *bin, st64 len); -RZ_API RZ_OWN ut64 *rz_base36_decode_dyn(RZ_NONNULL const char *bin, const size_t len); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_BASE36_H diff --git a/dest/include/librz/rz_util/rz_base64.h b/dest/include/librz/rz_util/rz_base64.h deleted file mode 100644 index f0676473a76..00000000000 --- a/dest/include/librz/rz_util/rz_base64.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef RZ_BASE64_H -#define RZ_BASE64_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -RZ_API size_t rz_base64_encode(RZ_OUT RZ_NULLABLE char *bout, RZ_NULLABLE const ut8 *bin, size_t sz); -RZ_API st64 rz_base64_decode(RZ_OUT RZ_NULLABLE ut8 *bout, RZ_NULLABLE const char *bin, st64 len); -RZ_API RZ_OWN ut8 *rz_base64_decode_dyn(RZ_NULLABLE const char *in, st64 len); -RZ_API RZ_OWN char *rz_base64_encode_dyn(RZ_NULLABLE const ut8 *bin, size_t sz); -#ifdef __cplusplus -} -#endif - -#endif // RZ_BASE64_H diff --git a/dest/include/librz/rz_util/rz_base85.h b/dest/include/librz/rz_util/rz_base85.h deleted file mode 100644 index 2e2cd0dc80e..00000000000 --- a/dest/include/librz/rz_util/rz_base85.h +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-FileCopyrightText: 2025 Ahmed Ibrahim -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_BASE85_H -#define RZ_BASE85_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -RZ_API int rz_base85_encode(RZ_OUT RZ_NONNULL char *dest, RZ_NONNULL const char *src, size_t n, int delims, int wrap, int y_abbr); -RZ_API st64 rz_base85_decode(RZ_OUT RZ_NONNULL char *dest, RZ_NONNULL const char *src, st64 len, int delims, int ignore_garbage); - -RZ_API RZ_OWN char *rz_base85_encode_dyn(RZ_NONNULL const char *src, size_t n, int delims, int wrap, int y_abbr); -RZ_API RZ_OWN char *rz_base85_decode_dyn(RZ_NONNULL const char *src, st64 len, int delims, int ignore_garbage, size_t *out_len); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_BASE85_H diff --git a/dest/include/librz/rz_util/rz_base91.h b/dest/include/librz/rz_util/rz_base91.h deleted file mode 100644 index c75940caf9c..00000000000 --- a/dest/include/librz/rz_util/rz_base91.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef RZ_BASE91_H -#define RZ_BASE91_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -RZ_API int rz_base91_encode(char *bout, const ut8 *bin, int len); -RZ_API int rz_base91_decode(ut8 *bout, const char *bin, int len); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_BASE91_H diff --git a/dest/include/librz/rz_util/rz_big.h b/dest/include/librz/rz_util/rz_big.h deleted file mode 100644 index ae6caf3d015..00000000000 --- a/dest/include/librz/rz_util/rz_big.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef RZ_BIG_H -#define RZ_BIG_H - -#include "../rz_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if HAVE_LIB_GMP -/* Use GMP's data struct */ -#define RzNumBig mpz_t -#elif HAVE_LIB_SSL -#define RzNumBig BIGNUM -#else -/* Use default impl */ -#define RZ_BIG_WORD_SIZE 4 -/* Let's support 4096-bit big number */ -#define RZ_BIG_ARRAY_SIZE (512 / RZ_BIG_WORD_SIZE) -/* RZ_BIG_WORD_SIZE == 4, 32 bits long */ -#define RZ_BIG_DTYPE ut32 -#define RZ_BIG_DTYPE_TMP ut64 -#define RZ_BIG_SPRINTF_FORMAT_STR "%.08x" -#define RZ_BIG_FORMAT_STR_LEN 9 -#define RZ_BIG_SSCANF_FORMAT_STR "%8x" -#define RZ_BIG_MAX_VAL (RZ_BIG_DTYPE_TMP) UT32_MAX - -typedef struct rz_num_big_t { - RZ_BIG_DTYPE array[RZ_BIG_ARRAY_SIZE]; - int sign; -} RzNumBig; -#endif - -RZ_API RzNumBig *rz_big_new(void); -RZ_API void rz_big_free(RzNumBig *b); -RZ_API void rz_big_init(RzNumBig *b); -RZ_API void rz_big_fini(RzNumBig *b); - -/* Assignment operations */ -RZ_API void rz_big_from_int(RzNumBig *b, st64 v); -RZ_API st64 rz_big_to_int(RzNumBig *b); -RZ_API void rz_big_from_hexstr(RzNumBig *b, const char *str); -RZ_API char *rz_big_to_hexstr(RzNumBig *b); -RZ_API void rz_big_assign(RzNumBig *dst, RzNumBig *src); - -/* Basic arithmetic operations */ -RZ_API void rz_big_add(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a + b */ -RZ_API void rz_big_sub(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a - b */ -RZ_API void rz_big_mul(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a * b */ -RZ_API void rz_big_div(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a / b */ -RZ_API void rz_big_mod(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a % b */ -RZ_API void rz_big_divmod(RzNumBig *c, RzNumBig *d, RzNumBig *a, RzNumBig *b); /* c = a/b, d = a%b */ - -/* Bitwise operations(for >= 0) */ -RZ_API void rz_big_and(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a & b */ -RZ_API void rz_big_or(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a | b */ -RZ_API void rz_big_xor(RzNumBig *c, RzNumBig *a, RzNumBig *b); /* c = a ^ b */ -RZ_API void rz_big_lshift(RzNumBig *c, RzNumBig *a, size_t nbits); /* c = a << nbits */ -RZ_API void rz_big_rshift(RzNumBig *c, RzNumBig *a, size_t nbits); /* c = a >> nbits */ - -/* Special operators and comparison */ -RZ_API int rz_big_cmp(RzNumBig *a, RzNumBig *b); /* Return 1 if a>b, -1 if a 1024 */ -RZ_API void rz_big_isqrt(RzNumBig *c, RzNumBig *a); /* Integer square root -- e.g. isqrt(5) => 2*/ - -#ifdef __cplusplus -} -#endif - -#endif // RZ_BIG_H diff --git a/dest/include/librz/rz_util/rz_bits.h b/dest/include/librz/rz_util/rz_bits.h deleted file mode 100644 index 3062f64ee5c..00000000000 --- a/dest/include/librz/rz_util/rz_bits.h +++ /dev/null @@ -1,186 +0,0 @@ -// SPDX-FileCopyrightText: 2023 billow -// SPDX-License-Identifier: LGPL-3.0-only// - -#ifndef RIZIN_RZ_BITS_H -#define RIZIN_RZ_BITS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/** - * \brief Count number of 1s in the given value. - * Reference: https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel - * - * \param v The value to count the set bits in. - * - * \return Number of set bits in \p v. - */ -#define DEFINE_COUNT_ONES(T) \ - static inline size_t rz_bits_count_ones_##T(T v) { \ - v = v - ((v >> 1) & (T) ~(T)0 / 3); \ - v = (v & (T) ~(T)0 / 15 * 3) + ((v >> 2) & (T) ~(T)0 / 15 * 3); \ - v = (v + (v >> 4)) & (T) ~(T)0 / 255 * 15; \ - size_t c = (T)(v * ((T) ~(T)0 / 255)) >> (sizeof(T) - 1) * CHAR_BIT; \ - return c; \ - } - -DEFINE_COUNT_ONES(ut64); -DEFINE_COUNT_ONES(ut32); -DEFINE_COUNT_ONES(ut16); -DEFINE_COUNT_ONES(ut8); - -/** - * \brief Count trailing zeros of \p v. - * If v == 0 it returns 64. - * - * \param v The value to count the trailing zeros for. - * - * \return The number of trailing zeros. - */ -static inline size_t rz_bits_trailing_zeros(ut64 v) { - if (v == 0) { - return 64; - } -#if HAVE___BUILTIN_CTZLL - return __builtin_ctzll(v); -#else - // src: https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch - size_t c; - if (v & 0x1) { - // special case for odd v (assumed to happen half of the time) - return 0; - } - c = 1; - if ((v & 0xffffffff) == 0) { - v >>= 32; - c += 32; - } - if ((v & 0xffff) == 0) { - v >>= 16; - c += 16; - } - if ((v & 0xff) == 0) { - v >>= 8; - c += 8; - } - if ((v & 0xf) == 0) { - v >>= 4; - c += 4; - } - if ((v & 0x3) == 0) { - v >>= 2; - c += 2; - } - c -= v & 0x1; - return c; -#endif -} - -/** - * \brief Get the number of leading zeros of a 64-bit integer in binary representation. - * \param x the 64-bit integer - * \return the number of leading zeros - */ -static inline int rz_bits_leading_zeros(ut64 x) { - if (x == 0) { - return 64; - } -#if HAVE___BUILTIN_CLZLL - return __builtin_clzll(x); -#else - int n = 0; - if (x == 0) - return 64; - - if (x <= 0x00000000FFFFFFFFULL) { - n = n + 32; - x = x << 32; - } - if (x <= 0x0000FFFFFFFFFFFFULL) { - n = n + 16; - x = x << 16; - } - if (x <= 0x00FFFFFFFFFFFFFFULL) { - n = n + 8; - x = x << 8; - } - if (x <= 0x0FFFFFFFFFFFFFFFULL) { - n = n + 4; - x = x << 4; - } - if (x <= 0x3FFFFFFFFFFFFFFFULL) { - n = n + 2; - x = x << 2; - } - if (x <= 0x7FFFFFFFFFFFFFFFULL) { - n = n + 1; - } - - return n; -#endif -} - -/** - * \brief Copies a bit range from \p src to \p dst at specified positions - * \param src 64-bit unsigned integer to copy bits from - * \param src_pos bit position related to \p src - * \param dst 64-bit unsigned integer to copy bits to - * \param dst_pos bit position related to \p dst - * \param size number of bits to copy (needs to be <= 64) - * \return a new 64-bit unsigned integer with the specified bit range replaced - */ -static inline ut64 rz_bits_copy_ut64(ut64 src, ut8 src_pos, ut64 dst, ut8 dst_pos, ut8 size) { - if (size >= 64) { - return src; - } - - ut64 mask = ((1ull) << size) - 1; - return (dst & ~(mask << dst_pos)) | (src >> src_pos & mask) << dst_pos; -} - -/** - * \brief Similar to rz_bits_copy_ut64() but for 8-bit unsigned integers - */ -static inline ut8 rz_bits_copy_ut8(ut8 src, ut8 src_pos, ut8 dst, ut8 dst_pos, ut8 size) { - if (size >= 8) { - return src; - } - - ut8 mask = ((1u) << size) - 1; - return (dst & ~(mask << dst_pos)) | (src >> src_pos & mask) << dst_pos; -} - -/** - * \brief Sign-extends a value from a specified bit-width to full width of type. - * - * This macro defines an inline function that performs sign extension on an - * unsigned integer value of `bits` significant bits, extending it to a signed - * integer of full bit-width `B`. It works for 8, 16, 32, and 64-bit integers. - * - * The function shifts the value left to discard higher bits, then arithmetically - * shifts it back right, preserving the sign. - * - * \param value The input unsigned integer of type ut##B. - * \param bits The number of significant bits in `value` (must be less than or equal to B). - * \return The sign-extended signed integer of type st##B. - */ -#define SIGN_EXT_IMPL(B) \ - static inline st##B rz_bits_sign_ext##B(ut##B value, ut##B bits) { \ - return (st##B)(value << (B - bits)) >> (B - bits); \ - } - -SIGN_EXT_IMPL(8); -SIGN_EXT_IMPL(16); -SIGN_EXT_IMPL(32); -SIGN_EXT_IMPL(64); - -RZ_API ut64 rz_bits_spread(const ut64 mask, const ut64 value); - -#ifdef __cplusplus -} -#endif -#endif // RIZIN_RZ_BITS_H diff --git a/dest/include/librz/rz_util/rz_bitvector.h b/dest/include/librz/rz_util/rz_bitvector.h deleted file mode 100644 index 7af3fa0ce60..00000000000 --- a/dest/include/librz/rz_util/rz_bitvector.h +++ /dev/null @@ -1,157 +0,0 @@ -// SPDX-FileCopyrightText: 2021 heersin -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_BITVECTOR_H -#define RZ_BITVECTOR_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \struct bitvector_t - * \brief structure for bitvector - * - * Ref : https://web.cs.dal.ca/~jamie/UWO/BitVectors/README.html - */ -typedef struct bitvector_t { - struct { - ut8 *large_a; ///< little endian array of bytes for bitvectors > 64 bits whose size is defined in _elem_len - ut64 small_u; ///< value of the bitvector when the size is <= 64 bits - } bits; - /** - * \brief This flag is set if the bit vector is allocated on the stack. - * This means large_a must not be reallocated or freed. - */ - bool stack_alloc; - /** - * \brief length of ut8 array (bits.large_a) -- real / physical - * NOTE: It is possible that a bits.large_a is larger than required for the - * bit vector length. - */ - ut32 _elem_len; - ut32 len; ///< number of bits -- virtual / logical -} RzBitVector; - -// init -RZ_API bool rz_bv_init(RZ_NONNULL RzBitVector *bv, ut32 length); -RZ_API RZ_OWN RzBitVector *rz_bv_new(ut32 length); -RZ_API RZ_OWN RzBitVector *rz_bv_dup(const RZ_NONNULL RzBitVector *bv); -RZ_API RZ_OWN RzBitVector *rz_bv_append(RZ_NONNULL RzBitVector *bv1, RZ_NONNULL RzBitVector *bv2); -RZ_API ut32 rz_bv_copy(RZ_NONNULL RzBitVector *dst, RZ_NONNULL const RzBitVector *src); -RZ_API ut32 rz_bv_copy_nbits( - RZ_NONNULL RzBitVector *dst, ut32 dst_start_pos, - RZ_NONNULL const RzBitVector *src, ut32 src_start_pos, - ut32 nbit); -RZ_API void rz_bv_fini(RZ_NONNULL RzBitVector *bv); -RZ_API void rz_bv_free(RZ_NULLABLE RzBitVector *bv); -// read and write to a bit -RZ_API bool rz_bv_set(RZ_NONNULL RzBitVector *bv, ut32 pos, bool b); -RZ_API bool rz_bv_set_all(RZ_NONNULL RzBitVector *bv, bool b); -RZ_API bool rz_bv_set_range(RZ_NONNULL RzBitVector *bv, ut32 pos_start, ut32 pos_end, bool b); -RZ_API bool rz_bv_toggle(RZ_NONNULL RzBitVector *bv, ut32 pos); -RZ_API bool rz_bv_toggle_all(RZ_NONNULL RzBitVector *bv); -RZ_API RZ_OWN RzBitVector *rz_bv_append_zero(RZ_NONNULL RzBitVector *bv, ut32 delta_len); -RZ_API RZ_OWN RzBitVector *rz_bv_prepend_zero(RZ_NONNULL RzBitVector *bv, ut32 delta_len); -RZ_API RZ_OWN RzBitVector *rz_bv_cut_head(RZ_NONNULL RzBitVector *bv, ut32 delta_len); -RZ_API RZ_OWN RzBitVector *rz_bv_cut_tail(RZ_NONNULL RzBitVector *bv, ut32 delta_len); -RZ_API bool rz_bv_get(RZ_NONNULL const RzBitVector *bv, ut32 pos); -// logic operations -RZ_API bool rz_bv_lshift(RZ_NONNULL RzBitVector *bv, ut32 size); -RZ_API bool rz_bv_rshift(RZ_NONNULL RzBitVector *bv, ut32 size); -RZ_API bool rz_bv_lshift_fill(RZ_NONNULL RzBitVector *bv, ut32 size, bool fill_bit); -RZ_API bool rz_bv_rshift_fill(RZ_NONNULL RzBitVector *bv, ut32 size, bool fill_bit); -RZ_API RZ_OWN RzBitVector *rz_bv_and(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API bool rz_bv_and_inplace(RZ_INOUT RZ_NONNULL RzBitVector *x, RZ_NONNULL const RzBitVector *y); -RZ_API RZ_OWN RzBitVector *rz_bv_or(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API bool rz_bv_or_inplace(RZ_INOUT RZ_NONNULL RzBitVector *x, RZ_NONNULL const RzBitVector *y); -RZ_API RZ_OWN RzBitVector *rz_bv_xor(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API bool rz_bv_xor_inplace(RZ_INOUT RZ_NONNULL RzBitVector *x, RZ_NONNULL const RzBitVector *y); -#define rz_bv_neg rz_bv_complement_2 -#define rz_bv_neg_inplace rz_bv_complement_2_inplace -#define rz_bv_not rz_bv_complement_1 -#define rz_bv_not_inplace rz_bv_complement_1_inplace -RZ_API RZ_OWN RzBitVector *rz_bv_complement_1(RZ_NONNULL RzBitVector *bv); -RZ_API bool rz_bv_complement_1_inplace(RZ_INOUT RZ_NONNULL RzBitVector *bv); -RZ_API RZ_OWN RzBitVector *rz_bv_complement_2(RZ_NONNULL RzBitVector *bv); -RZ_API bool rz_bv_complement_2_inplace(RZ_INOUT RZ_NONNULL RzBitVector *bv); - -// Module 2 arithmetic operations -RZ_API RZ_OWN RzBitVector *rz_bv_add(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y, RZ_NULLABLE bool *carry); -RZ_API bool rz_bv_add_inplace(RZ_INOUT RZ_NONNULL RZ_BORROW RzBitVector *x, const RZ_NONNULL RzBitVector *y, RZ_NULLABLE bool *carry); -RZ_API RZ_OWN RzBitVector *rz_bv_sub(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y, RZ_NULLABLE bool *borrow); -RZ_API bool rz_bv_sub_inplace(RZ_INOUT RZ_NONNULL RzBitVector *x, RZ_INOUT RZ_NONNULL RzBitVector *y, RZ_NULLABLE bool *borrow); -RZ_API RZ_OWN RzBitVector *rz_bv_mul(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API bool rz_bv_mul_inplace(RZ_NONNULL RZ_INOUT RzBitVector *x, const RZ_NONNULL RzBitVector *y); -RZ_API RZ_OWN RzBitVector *rz_bv_div(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API bool rz_bv_div_inplace(RZ_NONNULL RZ_INOUT RzBitVector *x, const RZ_NONNULL RzBitVector *y); -RZ_API RZ_OWN RzBitVector *rz_bv_mod(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API bool rz_bv_mod_inplace(RZ_NONNULL RZ_INOUT RzBitVector *x, const RZ_NONNULL RzBitVector *y); -RZ_API RZ_OWN RzBitVector *rz_bv_sdiv(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API RZ_OWN RzBitVector *rz_bv_smod(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); - -RZ_API bool rz_bv_msb(RZ_NONNULL const RzBitVector *bv); -RZ_API bool rz_bv_lsb(RZ_NONNULL const RzBitVector *bv); -RZ_API bool rz_bv_eq(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API bool rz_bv_ule(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API bool rz_bv_sle(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); - -RZ_API ut32 rz_bv_clz(RZ_NONNULL RzBitVector *bv); -RZ_API ut32 rz_bv_ctz(RZ_NONNULL RzBitVector *bv); - -RZ_API bool rz_bv_cast_inplace(RZ_INOUT RZ_NONNULL RzBitVector *bv, ut32 to_size, bool fill_bit); -RZ_API RzBitVector *rz_bv_cast(RZ_NONNULL RzBitVector *bv, ut32 to_size, bool fill_bit); - -// some convert functions -RZ_API ut8 rz_bv_to_ut8(RZ_NONNULL const RzBitVector *x); -RZ_API ut16 rz_bv_to_ut16(RZ_NONNULL const RzBitVector *x); -RZ_API ut32 rz_bv_to_ut32(RZ_NONNULL const RzBitVector *x); -RZ_API ut64 rz_bv_to_ut64(RZ_NONNULL const RzBitVector *x); -// misc -RZ_API bool rz_bv_is_zero_vector(RZ_NONNULL const RzBitVector *x); -RZ_API bool rz_bv_is_all_one(RZ_NONNULL const RzBitVector *x); -RZ_API RZ_OWN RzBitVector *rz_bv_new_from_ut64(ut32 length, ut64 value); -RZ_API RZ_OWN RzBitVector *rz_bv_new_from_st64(ut32 length, st64 value); -RZ_API RZ_OWN RzBitVector *rz_bv_new_from_bytes_le(RZ_IN RZ_NONNULL const ut8 *buf, ut32 bit_offset, ut32 size); -RZ_API RZ_OWN RzBitVector *rz_bv_new_from_bytes_be(RZ_IN RZ_NONNULL const ut8 *buf, ut32 bit_offset, ut32 size); -RZ_API bool rz_bv_set_from_ut64(RZ_NONNULL RzBitVector *bv, ut64 value); -RZ_API bool rz_bv_set_from_st64(RZ_NONNULL RzBitVector *bv, st64 value); -RZ_API void rz_bv_set_from_bytes_ble(RZ_NONNULL RzBitVector *bv, RZ_IN RZ_NONNULL const ut8 *buf, ut32 bit_offset, ut32 size, bool big_endian); -RZ_API void rz_bv_set_from_bytes_le(RZ_NONNULL RzBitVector *bv, RZ_IN RZ_NONNULL const ut8 *buf, ut32 bit_offset, ut32 size); -RZ_API void rz_bv_set_from_bytes_be(RZ_NONNULL RzBitVector *bv, RZ_IN RZ_NONNULL const ut8 *buf, ut32 bit_offset, ut32 size); -RZ_API void rz_bv_set_to_bytes_ble(RZ_NONNULL const RzBitVector *bv, RZ_OUT RZ_NONNULL ut8 *buf, bool big_endian); -RZ_API void rz_bv_set_to_bytes_le(RZ_NONNULL const RzBitVector *bv, RZ_OUT RZ_NONNULL ut8 *buf); -RZ_API void rz_bv_set_to_bytes_be(RZ_NONNULL const RzBitVector *bv, RZ_OUT RZ_NONNULL ut8 *buf); -RZ_API RZ_OWN char *rz_bv_as_string(RZ_NONNULL const RzBitVector *bv); -RZ_API RZ_OWN char *rz_bv_as_hex_string(RZ_NONNULL const RzBitVector *bv, bool pad); - -RZ_API ut32 rz_bv_len(RZ_NONNULL const RzBitVector *bv); -RZ_API ut32 rz_bv_len_bytes(RZ_NONNULL const RzBitVector *bv); -RZ_API bool rz_bv_cmp(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API ut32 rz_bv_hash(RZ_NULLABLE RzBitVector *x); -#define rz_bv_new_zero(l) rz_bv_new(l) -#define rz_bv_new_one(l) rz_bv_new_from_ut64(l, 1) -#define rz_bv_new_two(l) rz_bv_new_from_ut64(l, 2) -#define rz_bv_new_minus_one(l) rz_bv_new_from_st64(l, -1) - -// extra added to basic -RZ_API RZ_OWN RzBitVector *rz_bv_pred(RZ_NONNULL RzBitVector *bv); -RZ_API RZ_OWN RzBitVector *rz_bv_succ(RZ_NONNULL RzBitVector *bv); -RZ_API bool rz_bv_arshift(RZ_NONNULL RzBitVector *bv, ut32 dist); -RZ_API RZ_OWN RzBitVector *rz_bv_signed_cast(RZ_NONNULL RzBitVector *bv, ut32 to_size); -RZ_API RZ_OWN RzBitVector *rz_bv_unsigned_cast(RZ_NONNULL RzBitVector *bv, ut32 to_size); - -RZ_API bool rz_bv_slt(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API bool rz_bv_ult(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API bool rz_bv_sgt(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API bool rz_bv_ugt(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API bool rz_bv_sge(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); -RZ_API bool rz_bv_uge(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_IL_BITVECTOR_H diff --git a/dest/include/librz/rz_util/rz_buf.h b/dest/include/librz/rz_util/rz_buf.h deleted file mode 100644 index e232e570634..00000000000 --- a/dest/include/librz/rz_util/rz_buf.h +++ /dev/null @@ -1,410 +0,0 @@ -#ifndef RZ_BUF_H -#define RZ_BUF_H -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// TODO: choose whether the _at operations should preserve the current seek or not - -#define RZ_BUF_SET 0 -#define RZ_BUF_CUR 1 -#define RZ_BUF_END 2 - -typedef struct rz_buf_t RzBuffer; - -typedef bool (*RzBufferInit)(RzBuffer *b, const void *user); -typedef bool (*RzBufferFini)(RzBuffer *b); -typedef st64 (*RzBufferRead)(RZ_BORROW RzBuffer *b, RZ_OUT ut8 *buf, ut64 len); -typedef st64 (*RzBufferWrite)(RzBuffer *b, const ut8 *buf, ut64 len); -typedef ut64 (*RzBufferGetSize)(RzBuffer *b); -typedef bool (*RzBufferResize)(RzBuffer *b, ut64 newsize); -typedef st64 (*RzBufferSeek)(RzBuffer *b, st64 addr, int whence); -typedef ut8 *(*RzBufferGetWholeBuf)(RzBuffer *b, ut64 *sz); -typedef void (*RzBufferFreeWholeBuf)(RzBuffer *b); -typedef RzList *(*RzBufferNonEmptyList)(RzBuffer *b); - -typedef struct rz_buffer_methods_t { - RzBufferInit init; - RzBufferFini fini; - RzBufferRead read; ///< The buffer read() method. It should behave as rz_buf_read() documents. - RzBufferWrite write; - RzBufferGetSize get_size; - RzBufferResize resize; - RzBufferSeek seek; - RzBufferGetWholeBuf get_whole_buf; - RzBufferFreeWholeBuf free_whole_buf; -} RzBufferMethods; - -typedef enum { - RZ_BUFFER_INVALID = 0, - RZ_BUFFER_FILE, - RZ_BUFFER_IO_FD, - RZ_BUFFER_IO, ///< A buffer over RzIO. - RZ_BUFFER_BYTES, ///< A buffer over raw bytes. - RZ_BUFFER_MMAP, - RZ_BUFFER_SPARSE, - RZ_BUFFER_REF, - RZ_BUFFER_CUSTOM, ///< A buffer with custom methods. -} RzBufferType; - -struct rz_buf_t { - RzBufferType type; - const RzBufferMethods *methods; - void *priv; - ut8 *whole_buf; - bool readonly; - ut8 Oxff_priv; - int refctr; - int fd; -}; - -typedef struct rz_buf_sparse_chunk_t { - ut64 from; ///< inclusive - ut64 to; ///< inclusive, there can't be chunks with size == 0 - ut8 *data; ///< size == to - from + 1 -} RzBufferSparseChunk; - -typedef enum { - RZ_BUF_SPARSE_WRITE_MODE_SPARSE, ///< all writes are performed in the sparse overlay - RZ_BUF_SPARSE_WRITE_MODE_THROUGH ///< all writes are performed in the underlying base buffer -} RzBufferSparseWriteMode; - -/* utils */ - -/// change cur according to addr and whence (RZ_BUF_SET/RZ_BUF_CUR/RZ_BUF_END) -static inline st64 rz_seek_offset(ut64 cur, ut64 length, st64 addr, int whence) { - switch (whence) { - case RZ_BUF_CUR: - if (ST64_ADD_OVFCHK((st64)cur, addr)) { - return -1; - } - return cur + addr; - case RZ_BUF_SET: - if ((st64)addr < 0) { - return -1; - } - return addr; - case RZ_BUF_END: - if (ST64_ADD_OVFCHK((st64)length, addr)) { - return -1; - } - return length + addr; - default: - rz_warn_if_reached(); - return -1; - } -} - -/* constructors */ -RZ_API RZ_OWN RzBuffer *rz_buf_new_empty(ut64 len); -RZ_API RZ_OWN RzBuffer *rz_buf_new_file(const char *file, int perm, int mode); -RZ_API RZ_OWN RzBuffer *rz_buf_new_mmap(const char *file, int flags, int mode); -RZ_API RZ_OWN RzBuffer *rz_buf_new_slice(RzBuffer *b, ut64 offset, ut64 size); -RZ_API RZ_OWN RzBuffer *rz_buf_new_slurp(const char *file); -RZ_API RZ_OWN RzBuffer *rz_buf_new_sparse(ut8 Oxff); -RZ_API RZ_OWN RzBuffer *rz_buf_new_sparse_overlay(RzBuffer *b, RzBufferSparseWriteMode write_mode); -RZ_API RZ_OWN RzBuffer *rz_buf_new_with_buf(RzBuffer *b); -RZ_API RZ_OWN RzBuffer *rz_buf_new_with_bytes(RZ_NULLABLE RZ_BORROW const ut8 *bytes, ut64 len); -RZ_API RZ_OWN RzBuffer *rz_buf_new_from_bytes(RZ_NULLABLE RZ_OWN ut8 *bytes, ut64 len); -RZ_API RZ_OWN RzBuffer *rz_buf_new_with_io_fd(RZ_NONNULL void /* RzIOBind */ *iob, int fd); -RZ_API RZ_OWN RzBuffer *rz_buf_new_with_io(RZ_NONNULL void /* RzIOBind */ *iob); -RZ_API RZ_OWN RzBuffer *rz_buf_new_with_methods(RZ_NONNULL const RzBufferMethods *methods, void *init_user, RzBufferType type); -RZ_API RZ_OWN RzBuffer *rz_buf_new_with_pointers(const ut8 *bytes, ut64 len, bool steal); -RZ_API RZ_OWN RzBuffer *rz_buf_new_with_string(RZ_NONNULL const char *msg); - -/* methods */ - -RZ_API RZ_OWN char *rz_buf_get_nstring(RZ_NONNULL RzBuffer *b, ut64 addr, size_t size); -RZ_API RZ_OWN char *rz_buf_get_string(RZ_NONNULL RzBuffer *b, ut64 addr); -RZ_API ut64 rz_buf_read_string(RZ_NONNULL RzBuffer *b, RZ_BORROW RZ_NULLABLE char **s); -RZ_API RZ_OWN char *rz_buf_to_string(RZ_NONNULL RzBuffer *b); -RZ_API RzBuffer *rz_buf_ref(RzBuffer *b); -RZ_API bool rz_buf_append_buf(RZ_NONNULL RzBuffer *b, RZ_NONNULL RzBuffer *a); -RZ_API bool rz_buf_append_buf_slice(RZ_NONNULL RzBuffer *b, RZ_NONNULL RzBuffer *a, ut64 offset, ut64 size); -RZ_API bool rz_buf_append_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len); -RZ_API bool rz_buf_append_nbytes(RZ_NONNULL RzBuffer *b, ut64 len); -RZ_API bool rz_buf_append_ut16(RZ_NONNULL RzBuffer *b, ut16 n); -RZ_API bool rz_buf_append_ut32(RZ_NONNULL RzBuffer *b, ut32 n); -RZ_API bool rz_buf_append_ut64(RZ_NONNULL RzBuffer *b, ut64 n); -RZ_API bool rz_buf_dump(RZ_NONNULL RzBuffer *buf, RZ_NONNULL const char *file); -RZ_API bool rz_buf_fini(RzBuffer *b); -RZ_API bool rz_buf_prepend_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len); -RZ_API bool rz_buf_read8(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut8 *result); -RZ_API bool rz_buf_read8_at(RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *result); -RZ_API bool rz_buf_resize(RZ_NONNULL RzBuffer *b, ut64 newsize); -RZ_API bool rz_buf_set_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len); -RZ_API bool rz_buf_write8(RZ_NONNULL RzBuffer *b, ut8 value); -RZ_API bool rz_buf_write8_at(RZ_NONNULL RzBuffer *b, ut64 addr, ut8 value); -RZ_API st64 rz_buf_append_string(RZ_NONNULL RzBuffer *b, RZ_NONNULL const char *str); -RZ_API st64 rz_buf_fread(RZ_NONNULL RzBuffer *b, RZ_NONNULL ut8 *buf, RZ_NONNULL const char *fmt, int n); -RZ_API st64 rz_buf_fread_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL ut8 *buf, RZ_NONNULL const char *fmt, int n); -RZ_API st64 rz_buf_fwrite(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, RZ_NONNULL const char *fmt, int n); -RZ_API st64 rz_buf_fwrite_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL const ut8 *buf, RZ_NONNULL const char *fmt, int n); -RZ_API st64 rz_buf_insert_bytes(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL const ut8 *buf, ut64 len); -RZ_API st64 rz_buf_read(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len); -RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len); -RZ_API st64 rz_buf_seek(RZ_NONNULL RzBuffer *b, st64 addr, int whence); -RZ_API st64 rz_buf_write(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len); -RZ_API st64 rz_buf_write_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL const ut8 *buf, ut64 len); -RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b); -RZ_API ut64 rz_buf_tell(RZ_NONNULL RzBuffer *b); -RZ_API void rz_buf_free(RzBuffer *b); -RZ_API void rz_buf_set_overflow_byte(RZ_NONNULL RzBuffer *b, ut8 Oxff); -RZ_API bool rz_buf_is_bytes_buf(const RzBuffer *b); -RZ_DEPRECATE RZ_API RZ_BORROW ut8 *rz_buf_data(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut64 *size); -RZ_API RZ_BORROW const ut8 *rz_buf_get_whole_hot_paths(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut64 *sz); -RZ_API RzBufferType rz_buf_type(RZ_NONNULL const RzBuffer *b); - -/** - * \brief Callback to be used with rz_buf_fwd_scan(). - * - * \param buf Buffer it can read. - * \param len Length of buffer to read. - * \param user User data. - * - * \return The number of bytes read. - */ -typedef ut64 (*RzBufferFwdScan)(RZ_BORROW RZ_NONNULL const ut8 *buf, ut64 len, RZ_NULLABLE void *user); -RZ_API ut64 rz_buf_fwd_scan(RZ_NONNULL RzBuffer *b, ut64 start, ut64 amount, RZ_NONNULL RzBufferFwdScan fwd_scan, RZ_NULLABLE void *user); - -RZ_API st64 rz_buf_uleb128(RZ_NONNULL RzBuffer *buffer, RZ_NONNULL ut64 *value); -RZ_API st64 rz_buf_sleb128(RZ_NONNULL RzBuffer *buffer, RZ_NONNULL st64 *value); - -static inline st64 rz_buf_uleb128_at(RzBuffer *b, ut64 addr, ut64 *v) { - rz_buf_seek(b, addr, RZ_BUF_SET); - return rz_buf_uleb128(b, v); -} -static inline st64 rz_buf_sleb128_at(RzBuffer *b, ut64 addr, st64 *v) { - rz_buf_seek(b, addr, RZ_BUF_SET); - return rz_buf_sleb128(b, v); -} - -/* generated methods */ - -#define DEFINE_RZ_BUF_READ_BLE(size) \ - static inline bool rz_buf_read_ble##size(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut##size *result, bool big_endian) { \ - rz_return_val_if_fail(b && result, false); \ -\ - ut8 tmp[sizeof(ut##size)]; \ - if (rz_buf_read(b, tmp, sizeof(tmp)) != sizeof(tmp)) { \ - return false; \ - } \ -\ - *result = rz_read_ble##size(tmp, big_endian); \ - return true; \ - } \ -\ - static inline bool rz_buf_read_ble##size##_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut##size *result, bool big_endian) { \ - rz_return_val_if_fail(b && result, false); \ -\ - ut8 tmp[sizeof(ut##size)]; \ - if (rz_buf_read_at(b, addr, tmp, sizeof(tmp)) != sizeof(tmp)) { \ - return false; \ - } \ -\ - *result = rz_read_ble##size(tmp, big_endian); \ - return true; \ - } - -#define DEFINE_RZ_BUF_WRITE_BLE(size) \ - static inline bool rz_buf_write_ble##size(RZ_NONNULL RzBuffer *b, ut##size value, bool big_endian) { \ - ut8 tmp[sizeof(ut##size)]; \ - rz_write_ble##size(tmp, value, big_endian); \ -\ - return rz_buf_write(b, tmp, sizeof(tmp)) == sizeof(tmp); \ - } \ -\ - static inline bool rz_buf_write_ble##size##_at(RZ_NONNULL RzBuffer *b, ut64 addr, ut##size value, bool big_endian) { \ - ut8 tmp[sizeof(ut##size)]; \ - rz_write_ble##size(tmp, value, big_endian); \ -\ - return rz_buf_write_at(b, addr, tmp, sizeof(tmp)) == sizeof(tmp); \ - } - -/** - * \brief Read a big endian or little endian (ut16, ut32, ut64) at the specified address or cursor in the buffer. - * \param b ... - * \param addr (optional) - * \param result ... - * \param big_endian ... - * \return Return the status of the operation. - */ -DEFINE_RZ_BUF_READ_BLE(16) -DEFINE_RZ_BUF_READ_BLE(32) -DEFINE_RZ_BUF_READ_BLE(64) -DEFINE_RZ_BUF_READ_BLE(128) - -/** - * \brief Write a big endian or little endian ut16 at the specified address or cursor in the buffer. - * \param b ... - * \param addr (optional) - * \param result ... - * \param big_endian ... - * \return Return the status of the operation. - */ -DEFINE_RZ_BUF_WRITE_BLE(16) -DEFINE_RZ_BUF_WRITE_BLE(32) -DEFINE_RZ_BUF_WRITE_BLE(64) -DEFINE_RZ_BUF_WRITE_BLE(128) - -#define DEFINE_RZ_BUF_READ_OFFSET_BLE(size) \ - static inline bool rz_buf_read_ble##size##_offset(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT ut##size *result, bool big_endian) { \ - rz_return_val_if_fail(b && offset && result, false); \ - if (!rz_buf_read_ble##size##_at(b, *offset, result, big_endian)) { \ - return false; \ - } \ - *offset += sizeof(*result); \ - return true; \ - } - -static inline bool rz_buf_read_offset(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT ut8 *result, size_t size) { - rz_return_val_if_fail(b && offset && result, false); - if (rz_buf_read_at(b, *offset, result, size) != (st64)size) { - return false; - } - *offset += size; - return true; -} - -#define DEFINE_RZ_BUF_WRITE_OFFSET_BLE(size) \ - static inline bool rz_buf_write_ble##size##_offset(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_INOUT ut64 *offset, ut##size value, bool big_endian) { \ - rz_return_val_if_fail(b && offset, false); \ - if (!rz_buf_write_ble##size##_at(b, *offset, value, big_endian)) { \ - return false; \ - } \ - *offset += sizeof(value); \ - return true; \ - } - -static inline bool rz_buf_write_offset(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL ut8 *result, size_t size) { - rz_return_val_if_fail(b && offset && result, false); - if (rz_buf_write_at(b, *offset, result, size) != (st64)size) { - return false; - } - *offset += size; - return true; -} - -#define rz_buf_read_ble8_at(b, addr, result, endian) ((void)endian, rz_buf_read8_at(b, addr, result)) -#define rz_buf_write_ble8_at(b, addr, value, endian) ((void)endian, rz_buf_write8_at(b, addr, value)) - -/** - * \brief Read a big endian or little endian (ut16, ut32, ut64) at the specified offset in the buffer and shifts the offset. - * \param b ... - * \param offset ... - * \param result ... - * \param big_endian ... - * \return Return the status of the operation. - */ -DEFINE_RZ_BUF_READ_OFFSET_BLE(8) -DEFINE_RZ_BUF_READ_OFFSET_BLE(16) -DEFINE_RZ_BUF_READ_OFFSET_BLE(32) -DEFINE_RZ_BUF_READ_OFFSET_BLE(64) - -/** - * \brief Write a big endian or little endian ut16 at the specified address or cursor in the buffer and shifts the offset. - * \param b ... - * \param addr (optional) - * \param result ... - * \param big_endian ... - * \return Return the status of the operation. - */ -DEFINE_RZ_BUF_WRITE_OFFSET_BLE(8) -DEFINE_RZ_BUF_WRITE_OFFSET_BLE(16) -DEFINE_RZ_BUF_WRITE_OFFSET_BLE(32) -DEFINE_RZ_BUF_WRITE_OFFSET_BLE(64) - -#define rz_buf_read_le16(b, result) rz_buf_read_ble16(b, result, false) -#define rz_buf_read_le32(b, result) rz_buf_read_ble32(b, result, false) -#define rz_buf_read_le64(b, result) rz_buf_read_ble64(b, result, false) - -#define rz_buf_read_le16_at(b, addr, result) rz_buf_read_ble16_at(b, addr, result, false) -#define rz_buf_read_le32_at(b, addr, result) rz_buf_read_ble32_at(b, addr, result, false) -#define rz_buf_read_le64_at(b, addr, result) rz_buf_read_ble64_at(b, addr, result, false) - -#define rz_buf_read8_offset(b, offset, result) rz_buf_read_ble8_offset(b, offset, result, false) - -#define rz_buf_read_le16_offset(b, offset, result) rz_buf_read_ble16_offset(b, offset, result, false) -#define rz_buf_read_le32_offset(b, offset, result) rz_buf_read_ble32_offset(b, offset, result, false) -#define rz_buf_read_le64_offset(b, offset, result) rz_buf_read_ble64_offset(b, offset, result, false) - -#define rz_buf_read_be16(b, result) rz_buf_read_ble16(b, result, true) -#define rz_buf_read_be32(b, result) rz_buf_read_ble32(b, result, true) -#define rz_buf_read_be64(b, result) rz_buf_read_ble64(b, result, true) - -#define rz_buf_read_be16_at(b, addr, result) rz_buf_read_ble16_at(b, addr, result, true) -#define rz_buf_read_be32_at(b, addr, result) rz_buf_read_ble32_at(b, addr, result, true) -#define rz_buf_read_be64_at(b, addr, result) rz_buf_read_ble64_at(b, addr, result, true) - -#define rz_buf_read_be16_offset(b, offset, result) rz_buf_read_ble16_offset(b, offset, result, true) -#define rz_buf_read_be32_offset(b, offset, result) rz_buf_read_ble32_offset(b, offset, result, true) -#define rz_buf_read_be64_offset(b, offset, result) rz_buf_read_ble64_offset(b, offset, result, true) - -#define rz_buf_write_le16(b, value) rz_buf_write_ble16(b, value, false) -#define rz_buf_write_le32(b, value) rz_buf_write_ble32(b, value, false) -#define rz_buf_write_le64(b, value) rz_buf_write_ble64(b, value, false) - -#define rz_buf_write_le16_at(b, addr, value) rz_buf_write_ble16_at(b, addr, value, false) -#define rz_buf_write_le32_at(b, addr, value) rz_buf_write_ble32_at(b, addr, value, false) -#define rz_buf_write_le64_at(b, addr, value) rz_buf_write_ble64_at(b, addr, value, false) - -#define rz_buf_write8_offset(b, offset, value) rz_buf_write_ble8_offset(b, offset, value, false) - -#define rz_buf_write_le16_offset(b, offset, value) rz_buf_write_ble16_offset(b, offset, value, false) -#define rz_buf_write_le32_offset(b, offset, value) rz_buf_write_ble32_offset(b, offset, value, false) -#define rz_buf_write_le64_offset(b, offset, value) rz_buf_write_ble64_offset(b, offset, value, false) - -#define rz_buf_write_be16(b, value) rz_buf_write_ble16(b, value, true) -#define rz_buf_write_be32(b, value) rz_buf_write_ble32(b, value, true) -#define rz_buf_write_be64(b, value) rz_buf_write_ble64(b, value, true) - -#define rz_buf_write_be16_at(b, addr, value) rz_buf_write_ble16_at(b, addr, value, true) -#define rz_buf_write_be32_at(b, addr, value) rz_buf_write_ble32_at(b, addr, value, true) -#define rz_buf_write_be64_at(b, addr, value) rz_buf_write_ble64_at(b, addr, value, true) - -#define rz_buf_write_be16_offset(b, offset, value) rz_buf_write_ble16_offset(b, offset, value, true) -#define rz_buf_write_be32_offset(b, offset, value) rz_buf_write_ble32_offset(b, offset, value, true) -#define rz_buf_write_be64_offset(b, offset, value) rz_buf_write_ble64_offset(b, offset, value, true) - -#undef DEFINE_RZ_BUF_READ_BLE -#undef DEFINE_RZ_BUF_WRITE_BLE -#undef DEFINE_RZ_BUF_READ_OFFSET_BLE -#undef DEFINE_RZ_BUF_WRITE_OFFSET_BLE - -/** - * \brief Peeks at the next byte in the buffer without modify the buffer position. - * - * It assumes that the buffer contains at least one byte beyond the current position. - * otherwise, the behavior of the function is undefined. - * \param b The buffer - * \return The byte value - */ -static inline ut8 rz_buf_peek(RZ_NONNULL RzBuffer *b) { - ut8 x = 0; - rz_buf_read8_at(b, rz_buf_tell(b), &x); - return x; -} - -// sparse-specific - -RZ_API const RzBufferSparseChunk *rz_buf_sparse_get_chunks(RzBuffer *b, RZ_NONNULL size_t *count); -RZ_API void rz_buf_sparse_set_write_mode(RzBuffer *b, RzBufferSparseWriteMode mode); -RZ_API bool rz_buf_sparse_populated_in(RzBuffer *b, ut64 from, ut64 to); - -RZ_API bool rz_deflatew_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed, int wbits); -RZ_API bool rz_deflate_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed); -RZ_API bool rz_inflatew_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed, int wbits); -RZ_API bool rz_inflate_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed); -RZ_API bool rz_lzma_dec_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed); -RZ_API bool rz_lzma_enc_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_BUF_H diff --git a/dest/include/librz/rz_util/rz_debruijn.h b/dest/include/librz/rz_util/rz_debruijn.h deleted file mode 100644 index 5fd24698428..00000000000 --- a/dest/include/librz/rz_util/rz_debruijn.h +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-FileCopyrightText: 2014 crowell -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_DEBRUIJN_H -#define RZ_DEBRUIJN_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// For information about the algorithm, see Joe Sawada and Frank Ruskey, "An -// Efficient Algorithm for Generating Necklaces with Fixed Density" - -RZ_API RZ_OWN char *rz_debruijn_pattern(int size, int start, const char *charset); -RZ_API int rz_debruijn_offset(int start, const char *charset, ut64 value, bool is_big_endian); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_DEBRUIJN_H diff --git a/dest/include/librz/rz_util/rz_event.h b/dest/include/librz/rz_util/rz_event.h deleted file mode 100644 index 4ec71c3c94e..00000000000 --- a/dest/include/librz/rz_util/rz_event.h +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-FileCopyrightText: 2018 pancake -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_EVENT_H -#define RZ_EVENT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -typedef struct rz_event_t { - void *user; - bool incall; - HtUP *callbacks; - RzVector /**/ all_callbacks; - RzVector /**/ pending_unhook; ///< while inside of a call and a handle is unhooked, the unhook is deferred and saved here - int next_handle; -} RzEvent; - -typedef struct rz_event_callback_handle_t { - int handle; - int type; -} RzEventCallbackHandle; - -typedef void (*RzEventCallback)(RzEvent *ev, int type, void *user, void *data); - -typedef enum { - RZ_EVENT_ALL = 0, - RZ_EVENT_META_SET, // RzEventMeta - RZ_EVENT_META_DEL, // RzEventMeta - RZ_EVENT_META_CLEAR, // RzEventMeta - RZ_EVENT_CLASS_NEW, // RzEventClass - RZ_EVENT_CLASS_DEL, // RzEventClass - RZ_EVENT_CLASS_RENAME, // RzEventClassRename - RZ_EVENT_CLASS_ATTR_SET, // RzEventClassAttr - RZ_EVENT_CLASS_ATTR_DEL, // RzEventClassAttrSet - RZ_EVENT_CLASS_ATTR_RENAME, // RzEventClassAttrRename - RZ_EVENT_DEBUG_PROCESS_FINISHED, // RzEventDebugProcessFinished - RZ_EVENT_IO_WRITE, // RzEventIOWrite - RZ_EVENT_IO_DESC_CLOSE, // RzEventIODescClose - RZ_EVENT_IO_MAP_DEL, // RzEventIOMapDel - RZ_EVENT_BIN_FILE_DEL, // RzEventBinFileDel - RZ_EVENT_MAX, -} RzEventType; - -typedef struct rz_event_meta_t { - int type; - ut64 addr; - const char *string; -} RzEventMeta; - -typedef struct rz_event_class_t { - const char *name; -} RzEventClass; - -typedef struct rz_event_class_rename_t { - const char *name_old; - const char *name_new; -} RzEventClassRename; - -typedef struct rz_event_class_attr_t { - const char *class_name; - int attr_type; // RzAnalysisClassAttrType - const char *attr_id; -} RzEventClassAttr; - -typedef struct rz_event_class_attr_set_t { - RzEventClassAttr attr; - const char *content; -} RzEventClassAttrSet; - -typedef struct rz_event_class_attr_rename_t { - RzEventClassAttr attr; - const char *attr_id_new; -} RzEventClassAttrRename; - -typedef struct rz_event_debug_process_finished_t { - int pid; -} RzEventDebugProcessFinished; - -RZ_API RzEvent *rz_event_new(void *user); -RZ_API void rz_event_free(RzEvent *ev); -RZ_API RzEventCallbackHandle rz_event_hook(RzEvent *ev, int type, RzEventCallback cb, void *user); -RZ_API void rz_event_unhook(RzEvent *ev, RzEventCallbackHandle handle); -RZ_API void rz_event_send(RzEvent *ev, int type, void *data); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/rz_file.h b/dest/include/librz/rz_util/rz_file.h deleted file mode 100644 index 33e53c4a8f1..00000000000 --- a/dest/include/librz/rz_util/rz_file.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef RZ_FILE_H -#define RZ_FILE_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rz_mmap_t { - ut8 *buf; - ut64 base; - ut64 len; - int perm; - int mode; - char *filename; - int fd; -#if __WINDOWS__ - void *fm; -#endif -} RzMmap; - -/* is */ -RZ_API bool rz_file_is_abspath(const char *file); -RZ_API bool rz_file_is_c(const char *file); -RZ_API bool rz_file_is_directory(RZ_NULLABLE const char *str); -RZ_API bool rz_file_is_regular(const char *str); - -RZ_API bool rz_file_truncate(const char *filename, ut64 newsize); -RZ_API ut64 rz_file_size(const char *str); -RZ_API char *rz_file_root(const char *root, const char *path); -RZ_API RzMmap *rz_file_mmap(const char *file, int perm, int mode, ut64 base); -RZ_API void *rz_file_mmap_resize(RzMmap *m, ut64 newsize); -RZ_API void rz_file_mmap_free(RzMmap *m); -RZ_API bool rz_file_chmod(const char *file, const char *mod, int recursive); -RZ_API char *rz_file_temp(const char *prefix); -RZ_API char *rz_file_path(const char *bin); -RZ_API RZ_OWN char *rz_file_path_join(RZ_NONNULL const char *s1, RZ_NULLABLE const char *s2); -RZ_API const char *rz_file_basename(const char *path); -RZ_API const char *rz_file_dos_basename(RZ_BORROW RZ_NONNULL const char *path); -RZ_API char *rz_file_dirname(const char *path); -RZ_API RZ_OWN char *rz_file_abspath_rel(const char *cwd, const char *file); -RZ_API RZ_OWN char *rz_file_abspath(const char *file); -// make path relative to base -RZ_API char *rz_file_relpath(const char *base, const char *path); -RZ_API char *rz_file_path_local_to_unix(const char *path); -RZ_API char *rz_file_path_unix_to_local(const char *path); -RZ_API char *rz_file_binsh(void); -RZ_API ut8 *rz_inflatew(RZ_NONNULL const ut8 *src, int srcLen, int *srcConsumed, int *dstLen, int wbits); -RZ_API ut8 *rz_inflate(RZ_NONNULL const ut8 *src, int srcLen, int *srcConsumed, int *dstLen); -RZ_API ut8 *rz_inflate_ignore_header(RZ_NONNULL const ut8 *src, int srcLen, int *srcConsumed, int *dstLen); -RZ_API ut8 *rz_deflatew(RZ_NONNULL const ut8 *src, int srcLen, int *srcConsumed, int *dstLen, int wbits); -RZ_API ut8 *rz_deflate(RZ_NONNULL const ut8 *src, int srcLen, int *srcConsumed, int *dstLen); -RZ_API ut8 *rz_file_gzslurp(const char *str, int *outlen, int origonfail); -RZ_API char *rz_stdin_slurp(int *sz); -RZ_API RZ_OWN char *rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz); -RZ_API RZ_OWN char *rz_file_slurp_range(RZ_NONNULL const char *str, ut64 off, int sz, RZ_OUT RZ_NULLABLE int *osz); -RZ_API char *rz_file_slurp_random_line(const char *file); -RZ_API char *rz_file_slurp_random_line_count(const char *file, int *linecount); -RZ_API ut8 *rz_file_slurp_hexpairs(const char *str, int *usz); -RZ_API bool rz_file_dump(const char *file, const ut8 *buf, int len, bool append); -RZ_API bool rz_file_touch(const char *file); -RZ_API bool rz_file_hexdump(const char *file, const ut8 *buf, int len, int append); -RZ_API bool rz_file_rm(const char *file); -RZ_API bool rz_file_exists(RZ_NULLABLE const char *str); -RZ_API bool rz_file_fexists(const char *fmt, ...) RZ_PRINTF_CHECK(1, 2); -RZ_API char *rz_file_slurp_line(const char *file, int line, int context); -RZ_API char *rz_file_slurp_lines(const char *file, int line, int count); -RZ_API RZ_OWN char *rz_file_slurp_lines_from_bottom(const char *file, int line); -RZ_API int rz_file_mkstemp(RZ_NULLABLE const char *prefix, char **oname); -RZ_API char *rz_file_tmpdir(void); -RZ_API char *rz_file_readlink(const char *path); -RZ_API bool rz_file_copy(const char *src, const char *dst); -RZ_API RzList /**/ *rz_file_globsearch(const char *globbed_path, int maxdepth); -RZ_API bool rz_file_deflate(RZ_NONNULL const char *src, RZ_NONNULL const char *dst); -RZ_API bool rz_file_inflate(RZ_NONNULL const char *src, RZ_NONNULL const char *dst); -RZ_API bool rz_file_is_deflated(RZ_NONNULL const char *src); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_FILE_H diff --git a/dest/include/librz/rz_util/rz_float.h b/dest/include/librz/rz_util/rz_float.h deleted file mode 100644 index 146bc2f4ada..00000000000 --- a/dest/include/librz/rz_util/rz_float.h +++ /dev/null @@ -1,207 +0,0 @@ -/** - * \file rz_float.h - * rizin's float representation based on bitvector - * current design targets the IEEE-754 float format implementation - * take berkeley softfloat algorithm as a ref - * ref : http://www.jhauser.us/arithmetic/SoftFloat.html - */ - -#ifndef RZ_FLOAT_H -#define RZ_FLOAT_H -#include -#include - -/** - * - * Portable float nums in C - */ -RZ_API float rz_types_gen_f32_nan(void); -RZ_API float rz_types_gen_f32_inf(void); -RZ_API double rz_types_gen_f64_nan(void); -RZ_API double rz_types_gen_f64_inf(void); -RZ_API long double rz_types_gen_f128_nan(void); -RZ_API long double rz_types_gen_f128_inf(void); - -#define F32_NAN (rz_types_gen_f32_nan()) -#define F32_PINF (rz_types_gen_f32_inf()) -#define F32_NINF (-rz_types_gen_f32_inf()) -#define F64_NAN (rz_types_gen_f64_nan()) -#define F64_PINF (rz_types_gen_f64_inf()) -#define F64_NINF (-rz_types_gen_f64_inf()) -#define F80_NAN (rz_types_gen_f128_nan()) -#define F80_PINF (rz_types_gen_f128_inf()) -#define F80_NINF (-rz_types_gen_f128_inf()) -#define F128_NAN (rz_types_gen_f128_nan()) -#define F128_PINF (rz_types_gen_f128_inf()) -#define F128_NINF (-rz_types_gen_f128_inf()) - -typedef enum rz_float_format_enum { - /// basic IEEE 754 float format enums - /// ref : https://en.wikipedia.org/wiki/IEEE_754#Basic_and_interchange_formats - /// 1. IEEE binary representations, use binary digits to represent float. machine-friendly - RZ_FLOAT_IEEE754_BIN_32, ///< IEEE-754 binary 32 format (single) - RZ_FLOAT_IEEE754_BIN_64, ///< IEEE-754 binary64 format (double) - RZ_FLOAT_IEEE754_BIN_80, ///< IEEE-754 binary80 format - RZ_FLOAT_IEEE754_BIN_128, ///< IEEE-754 binary128 format - RZ_FLOAT_IEEE754_BIN_16, ///< half precision - - /// 2. IEEE decimal representations, use decimal digits to represent float precisely - /// the standard doesn't give an encoding to store decimal digits in binary. - /// two encoding ways in real-world : Binary integer decimal (BID) and Densely packed decimal (DPD) - RZ_FLOAT_IEEE754_DEC_64, ///< IEEE-754 decimal64 format, not implemented - RZ_FLOAT_IEEE754_DEC_128, ///< IEEE-754 decimal128 format, not implemented - - /// may add others in the future - RZ_FLOAT_UNK ///< End of enums -} RzFloatFormat; - -typedef enum rz_float_format_info { - RZ_FLOAT_INFO_BASE, ///< base of float representation, 2 for binary, 10 for decimal representation - RZ_FLOAT_INFO_EXP_LEN, ///< info about width of exponent field, in bits - RZ_FLOAT_INFO_MAN_LEN, ///< info about width of mantissa field, in bits - RZ_FLOAT_INFO_TOTAL_LEN, ///< info of length of format bv - RZ_FLOAT_INFO_BIAS ///< exponent bias -} RzFloatInfo; - -typedef enum rz_float_round_enum { - RZ_FLOAT_RMODE_RNE, ///< rounding to nearest, ties to even - RZ_FLOAT_RMODE_RNA, ///< rounding to nearest, ties away - RZ_FLOAT_RMODE_RTP, ///< rounding towards positive - RZ_FLOAT_RMODE_RTN, ///< rounding towards negative - RZ_FLOAT_RMODE_RTZ, ///< rounding towards zero - RZ_FLOAT_RMODE_UNK ///< end -} RzFloatRMode; ///< Rounding Mode - -typedef enum rz_float_exception_enum { - RZ_FLOAT_E_INVALID_OP = 1, ///< Invalid operation - RZ_FLOAT_E_DIV_ZERO = 2, ///< Divide zero - RZ_FLOAT_E_OVERFLOW = 4, ///< overflow exception - RZ_FLOAT_E_UNDERFLOW = 8, ///< underflow exception - RZ_FLOAT_E_INEXACT = 16 ///< calculated result is inexact -} RzFloatException; - -/** IEEE-754-2008 special num in float (NaN, Infinity) - * A : MSB of the mantissa, represents `is_quiet` flag - * quiet_NaN : A == 1, signaling_NaN : A == 0 - * PA-RISC and MIPS, use A as is_signal flag. Should reverse the case - */ -typedef enum rz_float_speciality_enum { - RZ_FLOAT_SPEC_NOT = 0, ///< not a special num - RZ_FLOAT_SPEC_ZERO = 1, ///< zero float - RZ_FLOAT_SPEC_PINF = 2, ///< positive infinity - RZ_FLOAT_SPEC_NINF = 3, ///< negative infinity - RZ_FLOAT_SPEC_QNAN = 4, ///< Quiet NaN - RZ_FLOAT_SPEC_SNAN = 5, ///< Signaling NaN -} RzFloatSpec; - -typedef struct rz_float_t { - RzFloatFormat r; ///< An interpretation of bitvector - RzBitVector *s; ///< The bitvector of float - RzFloatException exception; ///< exception of float operations -} RzFloat; - -static inline bool rz_float_is_neg_zero_f32(float zero) { - if (zero == 0.0f) { - return 1.0f / zero == F32_NINF; - } - return false; -} - -static inline bool rz_float_is_neg_zero_f64(double zero) { - if (zero == 0.0) { - return 1.0 / zero == F64_NINF; - } - return false; -} - -static inline bool rz_float_is_neg_zero_long_double(long double zero) { - if (zero == 0.0l) { - return 1.0l / zero == F128_NINF; - } - return false; -} - -#define IS_NEG_ZERO32(z) rz_float_is_neg_zero_f32(z) -#define IS_NEG_ZERO64(z) rz_float_is_neg_zero_f64(z) -#define IS_NEG_ZEROLD(z) rz_float_is_neg_zero_long_double(z) - -RZ_API ut32 rz_float_get_format_info(RzFloatFormat format, RzFloatInfo which_info); -RZ_API void rz_float_fini(RZ_NONNULL RzFloat *f); -RZ_API void rz_float_free(RZ_NULLABLE RzFloat *f); -RZ_API bool rz_float_init(RZ_NONNULL RzFloat *f, RzFloatFormat format); -RZ_API RZ_OWN RzFloat *rz_float_new(RzFloatFormat format); -RZ_API RZ_OWN RzFloat *rz_float_dup(RZ_NONNULL RzFloat *f); -RZ_API RZ_OWN RzFloat *rz_float_new_from_f32(float value); -RZ_API RZ_OWN RzFloat *rz_float_new_from_f64(double value); -RZ_API RZ_OWN RzFloat *rz_float_new_from_f80(long double value); -RZ_API RZ_OWN RzFloat *rz_float_new_from_f128(long double value); -RZ_API RZ_OWN RzFloat *rz_float_new_from_bv(RZ_NONNULL const RzBitVector *bv); -RZ_API bool rz_float_set_from_f32(RZ_NONNULL RzFloat *f, float value); -RZ_API bool rz_float_set_from_f64(RZ_NONNULL RzFloat *f, double value); -RZ_API bool rz_float_set_from_f80(RZ_NONNULL RzFloat *f, long double value); -RZ_API bool rz_float_set_from_f128(RZ_NONNULL RzFloat *f, long double value); -RZ_API RZ_OWN RzBitVector *rz_float_get_exponent_squashed(RZ_NONNULL RzFloat *f); -RZ_API RZ_OWN RzBitVector *rz_float_get_mantissa_squashed(RZ_NONNULL RzFloat *f); -RZ_API RZ_OWN RzBitVector *rz_float_get_mantissa_stretched(RZ_NONNULL RzFloat *f); -RZ_API bool rz_float_get_sign(RZ_NONNULL RzFloat *f); -RZ_API bool rz_float_set_sign(RZ_NONNULL RzFloat *f, bool new_sign); -RZ_API RZ_OWN RzBitVector *rz_float_get_exponent(RZ_NONNULL RzFloat *f); -RZ_API RZ_OWN ut32 rz_float_get_exponent_val(RZ_NONNULL RzFloat *f); -RZ_API RZ_OWN st32 rz_float_get_exponent_val_no_bias(RZ_NONNULL RzFloat *f); -RZ_API RZ_OWN RzBitVector *rz_float_get_mantissa(RZ_NONNULL RzFloat *f); -RZ_API bool rz_float_is_negative(RZ_NONNULL RzFloat *f); -RZ_API RzFloatSpec rz_float_detect_spec(RZ_NONNULL RzFloat *f); -RZ_API bool rz_float_is_inf(RZ_NONNULL RzFloat *f); -RZ_API bool rz_float_is_nan(RZ_NONNULL RzFloat *f); -RZ_API bool rz_float_is_zero(RZ_NONNULL RzFloat *f); -RZ_API bool rz_float_is_equal(RZ_NONNULL RzFloat *x, RZ_NONNULL RzFloat *y); -RZ_API RZ_OWN RzFloat *rz_float_neg(RZ_NONNULL RzFloat *f); -RZ_API RZ_OWN RzFloat *rz_float_succ(RZ_NONNULL RzFloat *f); -RZ_API RZ_OWN RzFloat *rz_float_pred(RZ_NONNULL RzFloat *f); -RZ_API RZ_OWN st32 rz_float_cmp(RZ_NONNULL RzFloat *x, RZ_NONNULL RzFloat *y); - -RZ_API RZ_OWN RzFloat *rz_float_add_ieee_bin(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_sub_ieee_bin(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_mul_ieee_bin(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_div_ieee_bin(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_rem_ieee_bin(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_mod_ieee_bin(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_fma_ieee_bin(RZ_NONNULL RzFloat *a, RZ_NONNULL RzFloat *b, RZ_NONNULL RzFloat *c, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_sqrt_ieee_bin(RZ_NONNULL RzFloat *n, RzFloatRMode mode); - -RZ_API RZ_OWN RzFloat *rz_float_add(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_sub(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_mul(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_div(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_rem(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_mod(RZ_NONNULL RzFloat *left, RZ_NONNULL RzFloat *right, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_fma(RZ_NONNULL RzFloat *a, RZ_NONNULL RzFloat *b, RZ_NONNULL RzFloat *c, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_sqrt(RZ_NONNULL RzFloat *n, RzFloatRMode mode); - -RZ_API RZ_OWN RzFloat *rz_float_trunc(RZ_NONNULL RzFloat *f); -RZ_API RZ_OWN RzFloat *rz_float_abs(RZ_NONNULL RzFloat *f); -RZ_API RZ_OWN RzFloat *rz_float_round_to_integral(RZ_NONNULL RzFloat *f, RzFloatRMode mode); -RZ_API RZ_OWN RzBitVector *rz_float_round_significant(bool sign, RzBitVector *sig, ut32 precision, RzFloatRMode mode, bool *should_inc); -RZ_API RZ_OWN RzFloat *rz_float_round_bv_and_pack(bool sign, st32 exp, RzBitVector *sig, RzFloatFormat format, RzFloatRMode mode); - -RZ_API RZ_OWN RzFloat *rz_float_new_from_ut64_as_f64(ut64 value); -RZ_API RZ_OWN RzFloat *rz_float_new_from_ut32_as_f32(ut32 value); -RZ_API RZ_OWN char *rz_float_as_string(RZ_NULLABLE RzFloat *f); -RZ_API RZ_OWN char *rz_float_as_dec_string(RZ_NULLABLE RzFloat *f); -RZ_API RZ_OWN char *rz_float_as_bit_string(RZ_NULLABLE RzFloat *f); -RZ_API RZ_OWN char *rz_float_as_hex_string(RZ_NULLABLE RzFloat *f, bool use_pad); -RZ_API bool rz_float_set_from_inf(RZ_NONNULL RzFloat *f, bool is_negative); -RZ_API bool rz_float_set_from_zero(RZ_NONNULL RzFloat *f); -RZ_API bool rz_float_set_from_qnan(RZ_NONNULL RzFloat *f); -RZ_API bool rz_float_set_from_snan(RZ_NONNULL RzFloat *f); -RZ_API RZ_OWN RzFloat *rz_float_new_inf(RzFloatFormat format, bool is_negative); -RZ_API RZ_OWN RzFloat *rz_float_new_zero(RzFloatFormat format, bool negative); -RZ_API RZ_OWN RzFloat *rz_float_new_qnan(RzFloatFormat format); -RZ_API RZ_OWN RzFloat *rz_float_new_snan(RzFloatFormat format); - -RZ_API RZ_OWN RzFloat *rz_float_cast_float(RZ_NONNULL RzBitVector *bv, RzFloatFormat format, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_cast_sfloat(RZ_NONNULL RzBitVector *bv, RzFloatFormat format, RzFloatRMode mode); -RZ_API RZ_OWN RzBitVector *rz_float_cast_int(RZ_NONNULL RzFloat *f, ut32 length, RzFloatRMode mode); -RZ_API RZ_OWN RzBitVector *rz_float_cast_sint(RZ_NONNULL RzFloat *f, ut32 length, RzFloatRMode mode); -RZ_API RZ_OWN RzFloat *rz_float_convert(RZ_NONNULL RzFloat *f, RzFloatFormat format, RzFloatRMode mode); -#endif // RZ_FLOAT_H diff --git a/dest/include/librz/rz_util/rz_graph.h b/dest/include/librz/rz_util/rz_graph.h deleted file mode 100644 index 191493e5cc5..00000000000 --- a/dest/include/librz/rz_util/rz_graph.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef RZ_GRAPH_H -#define RZ_GRAPH_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rz_graph_node_t { - unsigned int idx; - void *data; - RzList *out_nodes; - RzList *in_nodes; - RzList *all_neighbours; - RzListFree free; -} RzGraphNode; - -typedef struct rz_graph_edge_t { - RzGraphNode *from; - RzGraphNode *to; - int nth; -} RzGraphEdge; - -typedef struct rz_graph_t { - unsigned int n_nodes; - unsigned int n_edges; - int last_index; - RzList *nodes; /* RzGraphNode */ -} RzGraph; - -typedef struct rz_graph_visitor_t { - void (*discover_node)(RzGraphNode *n, struct rz_graph_visitor_t *vis); - void (*finish_node)(RzGraphNode *n, struct rz_graph_visitor_t *vis); - void (*tree_edge)(const RzGraphEdge *e, struct rz_graph_visitor_t *vis); - void (*back_edge)(const RzGraphEdge *e, struct rz_graph_visitor_t *vis); - void (*fcross_edge)(const RzGraphEdge *e, struct rz_graph_visitor_t *vis); - void *data; -} RzGraphVisitor; -typedef void (*RzGraphNodeCallback)(RzGraphNode *n, RzGraphVisitor *vis); -typedef void (*RzGraphEdgeCallback)(const RzGraphEdge *e, RzGraphVisitor *vis); - -// Contrructs a new RzGraph, returns heap-allocated graph. -RZ_API RzGraph *rz_graph_new(void); -// Destroys the graph and all nodes. -RZ_API void rz_graph_free(RzGraph *g); -// Gets the data of a node by index. -RZ_API RzGraphNode *rz_graph_get_node(const RzGraph *g, unsigned int idx); -RZ_API RzListIter *rz_graph_node_iter(const RzGraph *g, unsigned int idx); -RZ_API void rz_graph_reset(RzGraph *g); -RZ_API RzGraphNode *rz_graph_add_node(RzGraph *g, void *data); -RZ_API RzGraphNode *rz_graph_add_nodef(RzGraph *g, void *data, RzListFree user_free); -RZ_API void rz_graph_del_node(RzGraph *g, RZ_OWN RzGraphNode *n); -RZ_API void rz_graph_add_edge(RzGraph *g, RzGraphNode *from, RzGraphNode *to); -RZ_API void rz_graph_add_edge_at(RzGraph *g, RzGraphNode *from, RzGraphNode *to, int nth); -RZ_API RzGraphNode *rz_graph_node_split_forward(RzGraph *g, RzGraphNode *split_me, void *data); -RZ_API void rz_graph_del_edge(RzGraph *g, RzGraphNode *from, RzGraphNode *to); -RZ_API const RzList *rz_graph_get_neighbours(const RzGraph *g, const RzGraphNode *n); -RZ_API RzGraphNode *rz_graph_nth_neighbour(const RzGraph *g, const RzGraphNode *n, int nth); -RZ_API const RzList *rz_graph_innodes(const RzGraph *g, const RzGraphNode *n); -RZ_API const RzList *rz_graph_all_neighbours(const RzGraph *g, const RzGraphNode *n); -RZ_API const RzList *rz_graph_get_nodes(const RzGraph *g); -RZ_API bool rz_graph_adjacent(const RzGraph *g, const RzGraphNode *from, const RzGraphNode *to); -RZ_API void rz_graph_dfs_node(RzGraph *g, RzGraphNode *n, RzGraphVisitor *vis); -RZ_API void rz_graph_dfs_node_reverse(RzGraph *g, RzGraphNode *n, RzGraphVisitor *vis); -RZ_API void rz_graph_dfs(RzGraph *g, RzGraphVisitor *vis); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_GRAPH_H diff --git a/dest/include/librz/rz_util/rz_graph_drawable.h b/dest/include/librz/rz_util/rz_graph_drawable.h deleted file mode 100644 index 8d836c24cc2..00000000000 --- a/dest/include/librz/rz_util/rz_graph_drawable.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef RZ_GRAPH_DRAWABLE_H -#define RZ_GRAPH_DRAWABLE_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define RZ_GRAPH_NODE_TYPE_GROUP_MASK 0xff000000 - -typedef enum { - RZ_GRAPH_NODE_TYPE_NONE = 0, ///< No type for this node specified. - RZ_GRAPH_NODE_TYPE_DEFAULT, ///< Node contains a title string, a body string and an absract offset value. - RZ_GRAPH_NODE_TYPE_CFG, ///< Node is part of an control flow graph of a procedure. - RZ_GRAPH_NODE_TYPE_ICFG, ///< Node is part of an inter-procedural control flow graph. -} RzGraphNodeType; - -typedef enum { - RZ_GRAPH_NODE_SUBTYPE_NONE = 0, ///< No details given to this node. - RZ_GRAPH_NODE_SUBTYPE_CFG_ENTRY = 1 << 0, ///< Entry node of the procedure CFG. - RZ_GRAPH_NODE_SUBTYPE_CFG_CALL = 1 << 1, ///> A node which calls another procedure. - RZ_GRAPH_NODE_SUBTYPE_CFG_RETURN = 1 << 2, ///< A return node of the procedure. - RZ_GRAPH_NODE_SUBTYPE_CFG_EXIT = 1 << 3, ///< A node which exits the program (precedure does not return). - RZ_GRAPH_NODE_SUBTYPE_CFG_COND = 1 << 4, ///< A conditional instruction node. - RZ_GRAPH_NODE_SUBTYPE_ICFG_MALLOC = 1 << 5, ///< Node represents a memory allocating procedure. -} RzGraphNodeSubType; - -typedef struct { - char *title; - char *body; - /** - * \brief Optional offset for the object corresponding to node. - * - * Interactive output modes can use it to provide actions like seeking to - * this position or modify the object. - */ - ut64 offset; -} RzGraphNodeInfoDataDefault; - -typedef struct { - /** - * \brief Address of the node. - */ - ut64 address; - /** - * \brief Address of called procedure, if node is of type RZ_GRAPH_NODE_TYPE_CFG_CALL. - * It is set to UT64_MAX if invalid. - */ - ut64 call_address; -} RzGraphNodeInfoDataCFG; - -typedef struct { - /** - * \brief Address of the node. - */ - ut64 address; - bool is_malloc; ///< Flag set if this node is a memory allocating function. -} RzGraphNodeInfoDataICFG; - -/** - * \brief Generic drawable graph node. - * - * Provides minimal information to draw something without output format specific details. - */ -typedef struct rz_analysis_graph_node_info_t { - /** - * \brief Optional flags which describe the node further. - */ - RzGraphNodeType type; - RzGraphNodeSubType subtype; - union { - RzGraphNodeInfoDataDefault def; - RzGraphNodeInfoDataCFG cfg; - RzGraphNodeInfoDataICFG icfg; - }; -} RzGraphNodeInfo; - -RZ_API RZ_OWN char *rz_graph_get_node_subtype_annotation(RzGraphNodeSubType subtype, bool utf8); -RZ_API RZ_OWN RzGraphNodeInfo *rz_graph_get_node_info_data(RZ_BORROW void *data); -RZ_API void rz_graph_free_node_info(RZ_NULLABLE void *ptr); -RZ_API RzGraphNodeInfo *rz_graph_create_node_info_default(const char *title, const char *body, ut64 offset); -RZ_API RzGraphNodeInfo *rz_graph_create_node_info_icfg(ut64 address, RzGraphNodeType type, RzGraphNodeSubType subtype); -RZ_API RzGraphNodeInfo *rz_graph_create_node_info_cfg(ut64 address, ut64 call_target_addr, RzGraphNodeType type, RzGraphNodeSubType subtype); -RZ_API RzGraphNode *rz_graph_add_node_info(RzGraph /**/ *graph, const char *title, const char *body, ut64 offset); - -/** - * @brief Convert graph to Graphviz dot format. - * - * @param graph Graph with RzGraphNodeInfo used as node user data - * @param node_properties List node styling attributes. Can be set to NULL. - * @param edge_properties List edge styling attributes. Can be set to NULL. - */ -RZ_API RZ_OWN char *rz_graph_drawable_to_dot(RZ_NONNULL RzGraph /**/ *graph, RZ_NULLABLE const char *node_properties, RZ_NULLABLE const char *edge_properties); -/** - * @brief Convert graph to JSON. - * - * @param[in] graph Graph to convert - * @param[out] pj Json output structure. Can be used to include the resulting JSON value inside bigger JSON. - * @param[in] use_offset Set this to true if graph uses \ref RzGraphNodeInfo::offset offset field. - */ -RZ_API void rz_graph_drawable_to_json(RZ_NONNULL RzGraph /**/ *graph, RZ_NONNULL PJ *pj, bool use_offset); -RZ_API RZ_OWN char *rz_graph_drawable_to_json_str(RZ_NONNULL RzGraph /**/ *graph, bool use_offset); -RZ_API RZ_OWN char *rz_graph_drawable_to_cmd(RZ_NONNULL RzGraph /**/ *graph); -RZ_API RZ_OWN char *rz_graph_drawable_to_gml(RZ_NONNULL RzGraph /**/ *graph); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/dest/include/librz/rz_util/rz_hex.h b/dest/include/librz/rz_util/rz_hex.h deleted file mode 100644 index a0d39ff6824..00000000000 --- a/dest/include/librz/rz_util/rz_hex.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef RZ_HEX_H -#define RZ_HEX_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -RZ_API int rz_hex_pair2bin(const char *arg); -RZ_API int rz_hex_str2bin_msb(RZ_NONNULL const char *in, RZ_NONNULL RZ_OUT ut8 *out); -RZ_API size_t rz_hex_str2bin_mask(RZ_NONNULL const char *in, RZ_NONNULL RZ_OUT ut8 *out, RZ_NULLABLE RZ_OUT ut8 *mask, bool lsb_extend); -RZ_API int rz_hex_str2bin(RZ_NONNULL const char *in, RZ_NONNULL RZ_OUT ut8 *out); -RZ_API int rz_hex_bin2str(const ut8 *in, int len, char *out); -RZ_API void rz_hex_ut2st_str(const ut32 in, RZ_INOUT char *out, const int len); -RZ_API char *rz_hex_bin2strdup(const ut8 *in, int len); -RZ_API bool rz_hex_to_byte(ut8 *val, ut8 c); -RZ_API ut8 rz_hex_digit_to_byte(const char c); -RZ_API ut16 rz_hex_digit_pair_to_byte(const char *c); -RZ_API int rz_hex_str_is_valid(const char *s, bool allow_prefix); -RZ_API st64 rz_hex_bin_truncate(ut64 in, int n); -RZ_API char *rz_hex_from_c(const char *code); -RZ_API char *rz_hex_from_py(const char *code); -RZ_API char *rz_hex_from_code(const char *code); -RZ_API char *rz_hex_no_code(const char *code); -RZ_API char *rz_hex_from_py_str(char *out, const char *code); -RZ_API char *rz_hex_from_py_array(char *out, const char *code); -RZ_API char *rz_hex_from_c_str(char *out, const char **code); -RZ_API char *rz_hex_from_c_array(char *out, const char *code); -#ifdef __cplusplus -} -#endif - -#endif // RZ_HEX_H diff --git a/dest/include/librz/rz_util/rz_idpool.h b/dest/include/librz/rz_util/rz_idpool.h deleted file mode 100644 index 1d885557a60..00000000000 --- a/dest/include/librz/rz_util/rz_idpool.h +++ /dev/null @@ -1,84 +0,0 @@ -// SPDX-FileCopyrightText: 2017-2018 condret -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_ID_STORAGE_H -#define RZ_ID_STORAGE_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rz_id_pool_t { - ut32 start_id; - ut32 last_id; - ut32 next_id; - RzVector *freed_ids; -} RzIDPool; - -RZ_API RzIDPool *rz_id_pool_new(ut32 start_id, ut32 last_id); -RZ_API bool rz_id_pool_grab_id(RzIDPool *pool, ut32 *grabber); -RZ_API bool rz_id_pool_kick_id(RzIDPool *pool, ut32 kick); -RZ_API void rz_id_pool_free(RzIDPool *pool); - -typedef struct rz_id_storage_t { - RzIDPool *pool; - void **data; - ut32 top_id; - ut32 size; -} RzIDStorage; - -typedef bool (*RzIDStorageForeachCb)(void *user, void *data, ut32 id); -typedef bool (*ROIDStorageCompareCb)(void *in, void *incoming, void *user, int *cmp_res); - -RZ_API RzIDStorage *rz_id_storage_new(ut32 start_id, ut32 last_id); -RZ_API bool rz_id_storage_set(RzIDStorage *storage, void *data, ut32 id); -RZ_API bool rz_id_storage_add(RzIDStorage *storage, void *data, ut32 *id); -RZ_API void *rz_id_storage_get(RzIDStorage *storage, ut32 id); -RZ_API bool rz_id_storage_get_next(RzIDStorage *storage, ut32 *id); -RZ_API bool rz_id_storage_get_prev(RzIDStorage *storage, ut32 *id); -RZ_API void rz_id_storage_delete(RzIDStorage *storage, ut32 id); -RZ_API void *rz_id_storage_take(RzIDStorage *storage, ut32 id); -RZ_API bool rz_id_storage_foreach(RzIDStorage *storage, RzIDStorageForeachCb cb, void *user); -RZ_API void rz_id_storage_free(RzIDStorage *storage); -RZ_API RzList *rz_id_storage_list(RzIDStorage *s); -RZ_API bool rz_id_storage_get_lowest(RzIDStorage *storage, ut32 *id); -RZ_API bool rz_id_storage_get_highest(RzIDStorage *storage, ut32 *id); - -typedef struct rz_ordered_id_storage_t { - ut32 *permutation; - ut32 psize; - ut32 ptop; - RzIDStorage *data; - ROIDStorageCompareCb cmp; -} ROIDStorage; - -RZ_API ROIDStorage *rz_oids_new(ut32 start_id, ut32 last_id); -RZ_API void *rz_oids_get(ROIDStorage *storage, ut32 id); -RZ_API void *rz_oids_oget(ROIDStorage *storage, ut32 od); -RZ_API bool rz_oids_get_id(ROIDStorage *storage, ut32 od, ut32 *id); -RZ_API bool rz_oids_get_od(ROIDStorage *storage, ut32 id, ut32 *od); -RZ_API bool rz_oids_to_front(ROIDStorage *storage, const ut32 id); -RZ_API bool rz_oids_to_rear(ROIDStorage *storage, const ut32 id); -RZ_API void rz_oids_delete(ROIDStorage *storage, ut32 id); -RZ_API void rz_oids_odelete(ROIDStorage *st, ut32 od); -RZ_API void rz_oids_free(ROIDStorage *storage); -RZ_API bool rz_oids_add(ROIDStorage *storage, void *data, ut32 *id, ut32 *od); -RZ_API void *rz_oids_take(ROIDStorage *storage, ut32 id); -RZ_API void *rz_oids_otake(ROIDStorage *st, ut32 od); -RZ_API bool rz_oids_foreach(ROIDStorage *storage, RzIDStorageForeachCb cb, void *user); -RZ_API bool rz_oids_foreach_prev(ROIDStorage *storage, RzIDStorageForeachCb cb, void *user); -RZ_API bool rz_oids_insert(ROIDStorage *storage, void *data, ut32 *id, ut32 *od, void *user); -RZ_API bool rz_oids_sort(ROIDStorage *storage, void *user); -RZ_API ut32 rz_oids_find(ROIDStorage *storage, void *incoming, void *user); -RZ_API void *rz_oids_last(ROIDStorage *storage); -RZ_API void *rz_oids_first(ROIDStorage *storage); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/rz_intervaltree.h b/dest/include/librz/rz_util/rz_intervaltree.h deleted file mode 100644 index 72ab5cf5ea7..00000000000 --- a/dest/include/librz/rz_util/rz_intervaltree.h +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-FileCopyrightText: 2019 thestr4ng3r -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_INTERVALTREE_H -#define RZ_INTERVALTREE_H - -#include "rz_rbtree.h" -#include "../rz_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * RzIntervalTree is a special RBTree (augmented red-black tree) - * that holds its entries, each associated with a interval, - * ordered by the start of the interval. - * - * It allows efficient lookup for intersections with a given interval or value. - * This is achieved by, at each node, saving the maximum value of the node - * and all of its children. - * - * It can hold multiple entries with the same start or end. - * For multiple entries with the same start, the ordering is undefined. - */ - -typedef struct rz_interval_node_t { - RBNode node; - ut64 start; // inclusive, key of the node - ut64 end; // may be inclusive or exclusive, this is only determined by how they are queried - ut64 max_end; // augmented value, maximum end of this node and all of its children - void *data; -} RzIntervalNode; - -typedef void (*RzIntervalNodeFree)(void *data); - -typedef struct rz_interval_tree_t { - RzIntervalNode *root; - RzIntervalNodeFree free; -} RzIntervalTree; - -RZ_API void rz_interval_tree_init(RzIntervalTree *tree, RzIntervalNodeFree free); -RZ_API void rz_interval_tree_fini(RzIntervalTree *tree); - -// return false if the insertion failed. -RZ_API bool rz_interval_tree_insert(RzIntervalTree *tree, ut64 start, ut64 end, void *data); - -// Removes a given node from the tree. The node will be freed. -// If free is true, the data in the node is freed as well. -// false if the removal failed -// Complexity is O(log(n) + m) if there are m nodes with the same start as the given node. -RZ_API bool rz_interval_tree_delete(RzIntervalTree *tree, RzIntervalNode *node, bool free); - -// Change start/end of a given node. -// It is more efficient if only the end changed. -// The RzIntervalNode pointer is INVALID after this operation! -// Complexity is O(log(n) + m) if there are m nodes with the same start as the given node. -RZ_API bool rz_interval_tree_resize(RzIntervalTree *tree, RzIntervalNode *node, ut64 new_start, ut64 new_end); - -// Returns an iterator that starts at the leftmost node that has the given start -// Iterating over it will yield all nodes with given start, then all with a higher one. -RZ_API RBIter rz_interval_tree_first_at(RzIntervalTree *tree, ut64 start); - -// Returns a node that starts at exactly start or NULL -RZ_API RzIntervalNode *rz_interval_tree_node_at(RzIntervalTree *tree, ut64 start); - -// Returns a node that starts at exactly start and contains data or NULL -RZ_API RzIntervalNode *rz_interval_tree_node_at_data(RzIntervalTree *tree, ut64 start, void *data); - -// Same as rz_interval_tree_node_at, but directly returns the contained value or NULL -static inline void *rz_interval_tree_at(RzIntervalTree *tree, ut64 start) { - RzIntervalNode *node = rz_interval_tree_node_at(tree, start); - return node ? node->data : NULL; -} - -typedef bool (*RzIntervalIterCb)(RzIntervalNode *node, void *user); - -// Call cb for all entries starting at exactly start -RZ_API bool rz_interval_tree_all_at(RzIntervalTree *tree, ut64 start, RzIntervalIterCb cb, void *user); - -// Call cb for all entries whose intervals contain value -// end_inclusive if true, all start/end values are considered inclusive/inclusive, else inclusive/exclusive -RZ_API bool rz_interval_tree_all_in(RzIntervalTree *tree, ut64 value, bool end_inclusive, RzIntervalIterCb cb, void *user); - -// Call cb for all entries whose intervals intersect the given interval (might not contain it completely) -// end_inclusive if true, all start/end values are considered inclusive/inclusive, else inclusive/exclusive -RZ_API bool rz_interval_tree_all_intersect(RzIntervalTree *tree, ut64 start, ut64 end, bool end_inclusive, RzIntervalIterCb cb, void *user); - -typedef RBIter RzIntervalTreeIter; - -static inline RzIntervalNode *rz_interval_tree_iter_get(RzIntervalTreeIter *it) { - return rz_rbtree_iter_get(it, RzIntervalNode, node); -} - -static inline bool rz_interval_tree_empty(RzIntervalTree *tree) { - return tree->root == NULL; -} - -#define rz_interval_tree_foreach(tree, it, dat) \ - if ((tree)->root) \ - for ((it) = rz_rbtree_first(&(tree)->root->node); rz_rbtree_iter_has(&it) && (dat = rz_interval_tree_iter_get(&it)->data); rz_rbtree_iter_next(&(it))) - -#define rz_interval_tree_foreach_prev(tree, it, dat) \ - if ((tree)->root) \ - for ((it) = rz_rbtree_last(&(tree)->root->node); rz_rbtree_iter_has(&it) && (dat = rz_rbtree_iter_get(&it, RzIntervalNode, node)->data); rz_rbtree_iter_prev(&(it))) - -#ifdef __cplusplus -} -#endif - -#endif // RZ_INTERVALTREE_H diff --git a/dest/include/librz/rz_util/rz_iterator.h b/dest/include/librz/rz_util/rz_iterator.h deleted file mode 100644 index af81bccf87e..00000000000 --- a/dest/include/librz/rz_util/rz_iterator.h +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-FileCopyrightText: 2024 billow -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_ITERATOR_H -#define RZ_ITERATOR_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct rz_iterator_t; -typedef void *(*rz_iterator_next_cb)(struct rz_iterator_t *); -typedef void (*rz_iterator_free_cb)(void *); - -typedef struct rz_iterator_t { - void *cur; - void *u; - rz_iterator_next_cb next; - rz_iterator_free_cb free; - rz_iterator_free_cb free_u; -} RzIterator; - -#define rz_iterator_foreach(iter, val) \ - for ((val) = rz_iterator_next(iter); (val) != NULL; (val) = rz_iterator_next(iter)) - -RZ_API RZ_OWN RzIterator *rz_iterator_new( - RZ_NONNULL rz_iterator_next_cb next, - RZ_NULLABLE rz_iterator_free_cb free, - RZ_NULLABLE rz_iterator_free_cb free_u, - RZ_NONNULL RZ_OWN void *u); -RZ_API RZ_BORROW void *rz_iterator_next(RZ_NONNULL RZ_BORROW RzIterator *it); -RZ_API void rz_iterator_free(RzIterator *it); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_ITERATOR_H diff --git a/dest/include/librz/rz_util/rz_itv.h b/dest/include/librz/rz_util/rz_itv.h deleted file mode 100644 index 9b6ac35f07d..00000000000 --- a/dest/include/librz/rz_util/rz_itv.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef RZ_INTERVAL_H -#define RZ_INTERVAL_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief An interval in 64-bit address space which is aware of address space wraparound. - * - * Precondition: 0 <= size < 2**64 and addr + size <= 2**64 - * Interval range is [addr, addr + size) - * e.g. with addr = 10 and size = 5, interval range is [10, 15) where 10 <= x < (10 + 5). - * - * This interval is usually (though not always!) treated as right open interval. - */ -typedef struct rz_interval_t { - ut64 addr; ///< Start address of the interval. - ut64 size; ///< Size of the interval in bytes. -} RzInterval; - -typedef enum { - RZ_INTERVAL_IN = 0, ///< A value is in the interval. - RZ_INTERVAL_OUT, ///< A value is outside of the interval. - RZ_INTERVAL_UNDEF, ///< A value affiliation is not defined for the interval. -} RzIntervalAffiliation; - -typedef enum rz_interval_bound_t { - RZ_INTERVAL_BOUND_CLOSED = 0, ///< A closed interval: `[a, b]`. True if right and left open are NOT set. - RZ_INTERVAL_BOUND_RIGHT_OPEN = 1, ///< A right-open interval: `[a, b)`. This is the assumed default interpretation in Rizin. - RZ_INTERVAL_BOUND_LEFT_OPEN = 2, ///< A left-open interval: `(a, b]`. - RZ_INTERVAL_BOUND_OPEN = 3, ///< An open interval: `(a, b)`. True if right and left open are set. - RZ_INTERVAL_BOUND_UNDEF = 4, ///< Undefined. -} RzIntervalBound; - -/** - * \brief An interval with explicitly defined bounds. - */ -typedef struct { - ut64 a; ///< The left-hand value. - ut64 b; ///< The right-hand value. - RzIntervalBound bound; ///< Interval bound attribute. -} RzIntervalBoundedUt64; - -typedef RzInterval rz_itv_t; - -static inline RzIntervalAffiliation rz_itv_bound_contains_ut64(RzIntervalBoundedUt64 *itv, ut64 value) { - switch (itv->bound) { - default: - return RZ_INTERVAL_UNDEF; - case RZ_INTERVAL_BOUND_RIGHT_OPEN: - return (itv->a <= value && value < itv->b) ? RZ_INTERVAL_IN : RZ_INTERVAL_OUT; - case RZ_INTERVAL_BOUND_LEFT_OPEN: - return (itv->a < value && value <= itv->b) ? RZ_INTERVAL_IN : RZ_INTERVAL_OUT; - case RZ_INTERVAL_BOUND_OPEN: - return (itv->a < value && value < itv->b) ? RZ_INTERVAL_IN : RZ_INTERVAL_OUT; - case RZ_INTERVAL_BOUND_CLOSED: - return (itv->a <= value && value <= itv->b) ? RZ_INTERVAL_IN : RZ_INTERVAL_OUT; - } -} - -static inline RzInterval *rz_itv_new(ut64 addr, ut64 size) { - RzInterval *itv = RZ_NEW(RzInterval); - if (itv) { - itv->addr = addr; - itv->size = size; - } - return itv; -} - -static inline void rz_itv_free(RzInterval *itv) { - free(itv); -} - -static inline ut64 rz_itv_begin(RzInterval itv) { - return itv.addr; -} - -static inline ut64 rz_itv_size(RzInterval itv) { - return itv.size; -} - -static inline ut64 rz_itv_end(RzInterval itv) { - return itv.addr + itv.size; -} - -// Returns true if itv equals itv2 -static inline bool rz_itv_eq(RzInterval itv, RzInterval itv2) { - return itv.addr == itv2.addr && itv.size == itv2.size; -} - -// Returns true if itv contained addr -static inline bool rz_itv_contain(RzInterval itv, ut64 addr) { - const ut64 end = itv.addr + itv.size; - return itv.addr <= addr && (!end || addr < end); -} - -// Returns true if x is a subset of itv -static inline bool rz_itv_include(RzInterval itv, RzInterval x) { - const ut64 end = itv.addr + itv.size; - return itv.addr <= x.addr && (!end || (x.addr + x.size && x.addr + x.size <= end)); -} - -// Returns true if itv and x overlap (implying they are non-empty) -static inline bool rz_itv_overlap(RzInterval itv, RzInterval x) { - const ut64 end = itv.addr + itv.size, end1 = x.addr + x.size; - return (!end1 || itv.addr < end1) && (!end || x.addr < end); -} - -static inline bool rz_itv_overlap2(RzInterval itv, ut64 addr, ut64 size) { - RzInterval rai = { addr, size }; - return rz_itv_overlap(itv, rai); -} - -// Precondition: itv and x overlap -// Returns the intersection of itv and x -static inline RzInterval rz_itv_intersect(RzInterval itv, RzInterval x) { - const ut64 addr = RZ_MAX(itv.addr, x.addr); - const ut64 end = RZ_MIN(itv.addr + itv.size - 1, x.addr + x.size - 1) + 1; - RzInterval rai = { addr, end - addr }; - return rai; -} - -RZ_API bool rz_itv_str_to_bounded_itv_ut64(RZ_NONNULL const char *itv_str, RZ_OUT RzIntervalBoundedUt64 *out_itv); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_INTERVAL_H diff --git a/dest/include/librz/rz_util/rz_json.h b/dest/include/librz/rz_util/rz_json.h deleted file mode 100644 index 2b38a6b7a9d..00000000000 --- a/dest/include/librz/rz_util/rz_json.h +++ /dev/null @@ -1,75 +0,0 @@ -// SPDX-FileCopyrightText: 2020 thestr4ng3r -// SPDX-FileCopyrightText: 2020 Yaroslav Stavnichiy -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_JSON_H -#define RZ_JSON_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * rz_json is a JSON parsing API, - * heavily based on nxjson by Yaroslav Stavnichiy , - * which is available under LGPLv3 or later. - * - * rz_json does NOT format json, it only parses. To format json, see rz_pj.h instead. - * It operates in-place, which means the parsed string will be MODIFIED. - * This means all string values in RzJson point directly into the input string, - * removing the need to copy them. - * - * It also supports both line and block style comments. - */ - -typedef enum rz_json_type_t { - RZ_JSON_NULL, - RZ_JSON_OBJECT, // properties can be found in child nodes - RZ_JSON_ARRAY, // items can be found in child nodes - RZ_JSON_STRING, // value can be found in the str_value field - RZ_JSON_INTEGER, // value can be found in the num.u_value/num.s_value fields - RZ_JSON_DOUBLE, // value can be found in the num.dbl_value field - RZ_JSON_BOOLEAN // value can be found in the num.u_value field -} RzJsonType; - -typedef struct rz_json_t { - RzJsonType type; // type of json node, see above - const char *key; // key of the property; for object's children only - union { - const char *str_value; // text value of STRING node - struct { - union { - ut64 u_value; // the value of INTEGER or BOOLEAN node - st64 s_value; - }; - double dbl_value; // the value of DOUBLE node - } num; - struct { // children of OBJECT or ARRAY - size_t count; - struct rz_json_t *first; - struct rz_json_t *last; - } children; - }; - struct rz_json_t *next; // points to next child -} RzJson; - -RZ_API RzJson *rz_json_parse(char *text); - -RZ_API void rz_json_free(RzJson *js); - -RZ_API const RzJson *rz_json_get(const RzJson *json, const char *key); // get object's property by key -RZ_API const RzJson *rz_json_item(const RzJson *json, size_t idx); // get array element by index -RZ_API const RzJson *rz_json_get_path(const RzJson *json, const char *path); // reach into an object by (simple) JSON path like [0].methods[1].flags[0] -RZ_API void rz_json_to_pj(const RzJson *json, RZ_NONNULL PJ *pj, bool with_key); -RZ_API RZ_OWN char *rz_json_as_string(const RzJson *json, bool with_key); // shows the string representation of RzJson -RZ_API bool rz_json_eq(RZ_NONNULL RZ_BORROW const RzJson *a, RZ_NONNULL RZ_BORROW const RzJson *b); -RZ_API bool rz_json_string_eq(RZ_NONNULL RZ_BORROW const char *sa, RZ_NONNULL RZ_BORROW const char *sb); - -#ifdef __cplusplus -} -#endif - -#endif /* NXJSON_H */ diff --git a/dest/include/librz/rz_util/rz_lang_byte_array.h b/dest/include/librz/rz_util/rz_lang_byte_array.h deleted file mode 100644 index 66f06ec04ec..00000000000 --- a/dest/include/librz/rz_util/rz_lang_byte_array.h +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-FileCopyrightText: 2022 RizinOrg -// SPDX-FileCopyrightText: 2022 deroad -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_LANG_BYTE_ARRAY_H -#define RZ_LANG_BYTE_ARRAY_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum rz_lang_byte_array_type_t { - RZ_LANG_BYTE_ARRAY_RIZIN = 0, - RZ_LANG_BYTE_ARRAY_ASM, - RZ_LANG_BYTE_ARRAY_BASH, - RZ_LANG_BYTE_ARRAY_C_CPP_BYTES, - RZ_LANG_BYTE_ARRAY_C_CPP_HALFWORDS_BE, - RZ_LANG_BYTE_ARRAY_C_CPP_HALFWORDS_LE, - RZ_LANG_BYTE_ARRAY_C_CPP_WORDS_BE, - RZ_LANG_BYTE_ARRAY_C_CPP_WORDS_LE, - RZ_LANG_BYTE_ARRAY_C_CPP_DOUBLEWORDS_BE, - RZ_LANG_BYTE_ARRAY_C_CPP_DOUBLEWORDS_LE, - RZ_LANG_BYTE_ARRAY_GOLANG, - RZ_LANG_BYTE_ARRAY_JAVA, - RZ_LANG_BYTE_ARRAY_JSON, - RZ_LANG_BYTE_ARRAY_KOTLIN, - RZ_LANG_BYTE_ARRAY_NODEJS, - RZ_LANG_BYTE_ARRAY_OBJECTIVE_C, - RZ_LANG_BYTE_ARRAY_PYTHON, - RZ_LANG_BYTE_ARRAY_RUST, - RZ_LANG_BYTE_ARRAY_SWIFT, - RZ_LANG_BYTE_ARRAY_YARA, -} RzLangByteArrayType; - -RZ_API RZ_OWN char *rz_lang_byte_array(RZ_NONNULL const ut8 *buffer, size_t size, RzLangByteArrayType type); - -#ifdef __cplusplus -} -#endif - -#endif /* RZ_LANG_BYTE_ARRAY_H */ diff --git a/dest/include/librz/rz_util/rz_log.h b/dest/include/librz/rz_util/rz_log.h deleted file mode 100644 index 8b9e268acf5..00000000000 --- a/dest/include/librz/rz_util/rz_log.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef RZ_LOG_H -#define RZ_LOG_H - -#include -#include - -#if (defined(_WIN32) || defined(_WIN64)) && !defined(__GNUC__) -#define MACRO_LOG_FUNC __FUNCTION__ -// TODO: Windows weak symbols? -#elif defined(__EMSCRIPTEN__) // TODO: test upon Emscripten's version once it supports weak symbols -#define MACRO_LOG_FUNC __func__ -#else -#define MACRO_LOG_FUNC __func__ -#endif - -typedef enum rz_log_level { - RZ_LOGLVL_DEBUG = 0, - RZ_LOGLVL_VERBOSE, - RZ_LOGLVL_INFO, - RZ_LOGLVL_WARN, - RZ_LOGLVL_ERROR, - RZ_LOGLVL_FATAL, ///< This will call rz_sys_breakpoint() and trap the process for debugging! - /* other flags */ - RZ_LOGLVL_SIZE, - RZ_LOGLVL_NONE = 0xFF -} RzLogLevel; - -#define RZ_DEFAULT_LOGLVL RZ_LOGLVL_WARN - -typedef void (*RzLogCallback)(const char *output, const char *funcname, const char *filename, - ut32 lineno, RzLogLevel level, const char *tag, const char *fmtstr, ...) RZ_PRINTF_CHECK(7, 8); - -#define RZ_VLOG(lvl, tag, fmtstr, args) rz_vlog(MACRO_LOG_FUNC, __FILE__, \ - __LINE__, lvl, tag, NULL, fmtstr, args); - -#define RZ_LOG(lvl, tag, fmtstr, ...) rz_log(MACRO_LOG_FUNC, __FILE__, \ - __LINE__, lvl, tag, fmtstr, ##__VA_ARGS__); - -#if RZ_BUILD_DEBUG -#define RZ_DEFAULT_LOGLVL_ABORT RZ_LOGLVL_FATAL -#define RZ_LOG_DEBUG(fmtstr, ...) rz_log(MACRO_LOG_FUNC, __FILE__, \ - __LINE__, RZ_LOGLVL_DEBUG, NULL, fmtstr, ##__VA_ARGS__); -#else -#define RZ_LOG_DEBUG(fmtstr, ...) -#endif - -#define RZ_LOG_VERBOSE(fmtstr, ...) rz_log(MACRO_LOG_FUNC, __FILE__, \ - __LINE__, RZ_LOGLVL_VERBOSE, NULL, fmtstr, ##__VA_ARGS__); -#define RZ_LOG_INFO(fmtstr, ...) rz_log(MACRO_LOG_FUNC, __FILE__, \ - __LINE__, RZ_LOGLVL_INFO, NULL, fmtstr, ##__VA_ARGS__); -#define RZ_LOG_WARN(fmtstr, ...) rz_log(MACRO_LOG_FUNC, __FILE__, \ - __LINE__, RZ_LOGLVL_WARN, NULL, fmtstr, ##__VA_ARGS__); -#define RZ_LOG_ERROR(fmtstr, ...) rz_log(MACRO_LOG_FUNC, __FILE__, \ - __LINE__, RZ_LOGLVL_ERROR, NULL, fmtstr, ##__VA_ARGS__); -#define RZ_LOG_FATAL(fmtstr, ...) rz_log(MACRO_LOG_FUNC, __FILE__, \ - __LINE__, RZ_LOGLVL_FATAL, NULL, fmtstr, ##__VA_ARGS__); - -#ifdef __cplusplus -extern "C" { -#endif - -// Called by rz_core to set the configuration variables -RZ_API void rz_log_set_level(RzLogLevel level); -RZ_API void rz_log_set_abortlevel(RzLogLevel level); -RZ_API bool rz_log_set_file(RZ_NULLABLE const char *filename); -RZ_API void rz_log_set_show_sources(bool show_sources); -RZ_API void rz_log_set_colors(bool show_colors); - -// Functions for adding log callbacks -RZ_API void rz_log_add_callback(RZ_NULLABLE RzLogCallback cbfunc); -RZ_API void rz_log_del_callback(RZ_NULLABLE RzLogCallback cbfunc); -// TODO: rz_log_get_callbacks() - -/* Define rz_log as weak so it can be 'overwritten' externally - This allows another method of output redirection on POSIX (Windows?) - You can override this function to handle all logging logic / output yourself */ -RZ_API void rz_log(const char *funcname, const char *filename, - ut32 lineno, RzLogLevel level, const char *tag, const char *fmtstr, ...) RZ_PRINTF_CHECK(6, 7); - -RZ_API void rz_vlog(const char *funcname, const char *filename, - ut32 lineno, RzLogLevel level, const char *tag, RZ_OWN RZ_NULLABLE const char **out, - const char *fmtstr, va_list args); - -RZ_API void rz_log_str(const char *funcname, const char *filename, - ut32 lineno, RzLogLevel level, const char *tag, const char *msg); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_LOG_H diff --git a/dest/include/librz/rz_util/rz_luhn.h b/dest/include/librz/rz_util/rz_luhn.h deleted file mode 100644 index 52295641cd9..00000000000 --- a/dest/include/librz/rz_util/rz_luhn.h +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-FileCopyrightText: 2021 deroad -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_LUHN_H -#define RZ_LUHN_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -RZ_API bool rz_calculate_luhn_value(const char *data, ut64 *result); - -#ifdef __cplusplus -} -#endif - -#endif /* RZ_LUHN_H */ diff --git a/dest/include/librz/rz_util/rz_mem.h b/dest/include/librz/rz_util/rz_mem.h deleted file mode 100644 index 19c9a2da28a..00000000000 --- a/dest/include/librz/rz_util/rz_mem.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef RZ_MEM_H -#define RZ_MEM_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rz_mem_pool_t { - ut8 **nodes; - int ncount; - int npool; - // - int nodesize; - int poolsize; - int poolcount; -} RMemoryPool; - -RZ_API ut64 rz_mem_get_num(const ut8 *b, int size); - -/* MEMORY POOL */ -RZ_API void *rz_mem_dup(const void *s, int l); -RZ_API void rz_mem_memzero(void *, size_t); -RZ_API void rz_mem_reverse(ut8 *b, int l); -RZ_API int rz_mem_protect(void *ptr, int size, const char *prot); -RZ_API int rz_mem_set_num(ut8 *dest, int dest_size, ut64 num); -RZ_API int rz_mem_eq(const ut8 *a, const ut8 *b, int len); -RZ_API bool rz_mem_eq_masked(const ut8 *a, const ut8 *b, const ut8 *mask, size_t size); -RZ_API void rz_mem_copybits(ut8 *dst, const ut8 *src, int bits); -RZ_API void rz_mem_copybits_delta(ut8 *dst, int doff, const ut8 *src, int soff, int bits); -RZ_API void rz_mem_copyloop(ut8 *dest, const ut8 *orig, int dsize, int osize); -RZ_API void *rz_mem_copy(void *dest, size_t dmax, const void *src, size_t smax); -RZ_API const ut8 *rz_mem_mem(const ut8 *haystack, int hlen, const ut8 *needle, int nlen); -RZ_API const ut8 *rz_mem_mem_aligned(const ut8 *haystack, int hlen, const ut8 *needle, int nlen, int align); -RZ_API int rz_mem_count(const ut8 **addr); -RZ_API bool rz_mem_is_printable(const ut8 *a, int la); -RZ_API bool rz_mem_is_zero(const ut8 *b, int l); -RZ_API ut64 rz_mem_align_padding(const ut64 address, ut64 alignment); -RZ_API RZ_OWN ut8 *rz_mem_copy_offset(const ut8 *buf, size_t buf_size, size_t offset); -RZ_API RZ_OWN ut8 *rz_mem_swap_bytes_2(RZ_NONNULL const ut8 *buf, size_t buf_size); -RZ_API RZ_OWN ut8 *rz_mem_swap_bytes_2_inplace(RZ_OUT RZ_NONNULL ut8 *buf, size_t buf_size); -RZ_API RZ_OWN ut8 *rz_mem_swap_bytes_4(RZ_NONNULL const ut8 *buf, size_t buf_size); -RZ_API RZ_OWN ut8 *rz_mem_swap_bytes_4_inplace(RZ_OUT RZ_NONNULL ut8 *buf, size_t buf_size); - -/** - * \brief Returns the alignment of the \p ptr. - * - * \param ptr The pointer to get the alignment for. - * - * \return Returns the pointer alignment or UT64_MAX if \p ptr == NULL or ((utptr) ptr) == 0. - */ -static inline ut64 rz_mem_ptr_alignment(RZ_NONNULL const void *ptr) { - if (ptr == NULL || ((utptr)ptr) == 0) { - return UT64_MAX; - } - return 1ull << rz_bits_trailing_zeros((utptr)ptr); -} - -#ifdef __cplusplus -} -#endif -#endif // RZ_MEM_H diff --git a/dest/include/librz/rz_util/rz_name.h b/dest/include/librz/rz_util/rz_name.h deleted file mode 100644 index e23f79a030a..00000000000 --- a/dest/include/librz/rz_util/rz_name.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef RZ_NAME_H -#define RZ_NAME_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -RZ_API bool rz_name_check(const char *name, bool strict); -RZ_API bool rz_name_filter(char *name, int len, bool strict); -RZ_API char *rz_name_filter2(const char *name, bool strict); -RZ_API bool rz_name_validate_char(const char ch, bool strict); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_NAME_H diff --git a/dest/include/librz/rz_util/rz_num.h b/dest/include/librz/rz_util/rz_num.h deleted file mode 100644 index 7b1fbfb9d8c..00000000000 --- a/dest/include/librz/rz_util/rz_num.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef RZ_NUM_H -#define RZ_NUM_H - -#include - -#define RZ_NUMCALC_STRSZ 1024 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - double d; - ut64 n; -} RzNumCalcValue; - -typedef enum { - RNCNAME, - RNCNUMBER, - RNCEND, - RNCINC, - RNCDEC, - RNCLT, // comparison operator < - RNCGT, // comparison operator > - RNCPLUS = '+', - RNCMINUS = '-', - RNCMUL = '*', - RNCEXP = 'E', - RNCDIV = '/', - RNCMOD = '%', - // RNCXOR='^', RNCOR='|', RNCAND='&', - RNCNEG = '~', - RNCAND = '&', - RNCORR = '|', - RNCXOR = '^', - RNCPRINT = ';', - RNCASSIGN = '=', - RNCLEFTP = '(', - RNCRIGHTP = ')', - RNCSHL = '<', - RNCSHR = '>', - RNCROL = '#', - RNCROR = '$' -} RzNumCalcToken; - -typedef struct rz_num_calc_t { - RzNumCalcToken curr_tok; - RzNumCalcValue number_value; - char string_value[RZ_NUMCALC_STRSZ]; - int errors; - char oc; - const char *calc_err; - int calc_i; - const char *calc_buf; - int calc_len; - bool under_calc; -} RzNumCalc; - -typedef struct rz_num_t { - ut64 (*callback)(struct rz_num_t *userptr, const char *str, int *ok); - const char *(*cb_from_value)(struct rz_num_t *userptr, ut64 value, int *ok); - // RzNumCallback callback; - ut64 value; - double fvalue; - void *userptr; - int dbz; /// division by zero happened - RzNumCalc nc; -} RzNum; - -typedef ut64 (*RzNumCallback)(struct rz_num_t *self, const char *str, int *ok); -typedef const char *(*RzNumCallback2)(struct rz_num_t *self, ut64, int *ok); - -RZ_API RzNum *rz_num_new(RzNumCallback cb, RzNumCallback2 cb2, void *ptr); -RZ_API void rz_num_free(RzNum *num); -RZ_API char *rz_num_units(char *buf, size_t len, ut64 number); -RZ_API int rz_num_conditional(RzNum *num, const char *str); -RZ_API ut64 rz_num_calc(RzNum *num, const char *str, const char **err); -RZ_API const char *rz_num_calc_index(RzNum *num, const char *p); -RZ_API int rz_num_is_valid_input(RzNum *num, const char *input_value); -RZ_API ut64 rz_num_get_input_value(RzNum *num, const char *input_value); -RZ_API char *rz_num_as_string(RzNum *___, ut64 n, bool printable_only); -RZ_API ut64 rz_num_tail(RzNum *num, ut64 addr, const char *hex); -RZ_API ut64 rz_num_tail_base(RzNum *num, ut64 addr, ut64 off); -RZ_API void rz_num_minmax_swap(ut64 *a, ut64 *b); -RZ_API void rz_num_minmax_swap_i(int *a, int *b); // XXX this can be a cpp macro :?? -RZ_API ut64 rz_num_math(RzNum *num, const char *str); -RZ_API ut64 rz_num_get(RZ_NULLABLE RzNum *num, RZ_NULLABLE const char *str); -RZ_API int rz_num_to_bits(char *out, ut64 num); -RZ_API int rz_num_to_trits(char *out, ut64 num); // Rename this please -RZ_API ut32 rz_num_rand32(ut32 max); -RZ_API ut64 rz_num_rand64(ut64 max); -RZ_API void rz_num_irand(void); -RZ_API ut64 rz_get_input_num_value(RzNum *num, const char *input_value); -RZ_API bool rz_is_valid_input_num_value(RzNum *num, const char *input_value); -RZ_API int rz_num_between(RzNum *num, const char *input_value); -RZ_API int rz_num_str_len(const char *str); -RZ_API int rz_num_str_split(char *str); -RZ_API RzList /**/ *rz_num_str_split_list(char *str); -RZ_API void *rz_num_dup(ut64 n); -RZ_API size_t rz_num_base_of_string(RzNum *num, RZ_NONNULL const char *str); -RZ_API double rz_num_get_float(RzNum *num, const char *str); -RZ_API bool rz_num_is_hex_prefix(const char *p); - -/** - * \brief Absolute value of a 64-bit number. Store result in `ut64` - * \return unsigned 64-bit number - */ -static inline ut64 rz_num_abs(st64 num) { - if (num == ST64_MIN) { - return UT64_GT0; - } - return num < 0 ? -num : num; -} - -/** - * \brief Padding to align v to the next alignment-boundary. - * \return the least `d` such that `(v + d) % alignment == 0`. - */ -static inline ut64 rz_num_align_delta(ut64 v, ut64 alignment) { - if (!alignment) { - return 0; - } - ut64 excess = v % alignment; - if (!excess) { - return 0; - } - return alignment - excess; -} - -/** - * \brief Get the 64-bit value that has exactly its \p width lowest bits set to 1. - * e.g. - * rz_num_bitmask(2) == 0b11 - * rz_num_bitmask(3) == 0b111 - * ... - */ -static inline ut64 rz_num_bitmask(ut8 width) { - if (width >= 64) { - return 0xffffffffffffffffull; - } - return (1ull << (ut64)width) - 1; -} - -#define CONVERT_TO_TWO_COMPLEMENT(x) \ - static inline st##x convert_to_two_complement_##x(ut##x value) { \ - if (value <= ST##x##_MAX) { \ - return (st##x)value; \ - } \ -\ - value = ~value + 1; \ - return -(st##x)value; \ - } - -CONVERT_TO_TWO_COMPLEMENT(8) -CONVERT_TO_TWO_COMPLEMENT(16) -CONVERT_TO_TWO_COMPLEMENT(32) -CONVERT_TO_TWO_COMPLEMENT(64) - -/// Typical comparison (1/0/-1) for two numbers of arbitrary types, including unsigned -#define RZ_NUM_CMP(a, b) ((a) > (b) ? 1 : ((b) > (a) ? -1 : 0)) - -/** - * Divide 2^64 by the given divisor - * - * Idea: https://stackoverflow.com/a/55584872 - * Proof: https://git.sr.ht/~thestr4ng3r/isa-bit-twiddling/tree/808253ab4d262f9e7dd7b87d0396f1afd7c5804b/item/Bit_Twiddling.thy#L26-43 - * - * \param divisor must be non-zero - */ -static inline ut64 rz_num_2_pow_64_div(ut64 divisor) { - return (-(st64)divisor) / divisor + 1; -} - -#ifdef __cplusplus -} -#endif - -#endif // RZ_NUM_H diff --git a/dest/include/librz/rz_util/rz_panels.h b/dest/include/librz/rz_util/rz_panels.h deleted file mode 100644 index 20d8aaf3d5d..00000000000 --- a/dest/include/librz/rz_util/rz_panels.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef RZ_PANELS_H -#define RZ_PANELS_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - VERTICAL, - HORIZONTAL, - NONE -} RzPanelLayout; - -typedef enum { - PANEL_TYPE_DEFAULT = 0, - PANEL_TYPE_MENU = 1 -} RzPanelType; - -typedef enum { - PANEL_EDGE_NONE = 0, - PANEL_EDGE_BOTTOM, - PANEL_EDGE_RIGHT -} RzPanelEdge; - -typedef void (*RzPanelMenuUpdateCallback)(void *user, const char *parent); -typedef void (*RzPanelDirectionCallback)(void *user, int direction); -typedef void (*RzPanelRotateCallback)(void *user, bool rev); -typedef void (*RzPanelPrintCallback)(void *user, void *p); - -typedef struct rz_panel_pos_t { - int x; - int y; - int w; - int h; -} RzPanelPos; - -typedef struct rz_panel_model_t { - RzPanelDirectionCallback directionCb; - RzPanelRotateCallback rotateCb; - RzPanelPrintCallback print_cb; - RzPanelType type; - char *cmd; - char *title; - ut64 baseAddr; - ut64 addr; - bool cache; - char *cmdStrCache; - char *readOnly; - char *funcName; - RzPVector /**/ filter; - int n_filter; - int rotate; -} RzPanelModel; - -typedef struct rz_panel_view_t { - RzPanelPos pos; - RzPanelPos prevPos; - int sx; - int sy; - int curpos; - bool refresh; - int edge; -} RzPanelView; - -typedef struct rz_panel_t { - RzPanelModel *model; - RzPanelView *view; -} RzPanel; - -typedef void (*RzPanelAlmightyCallback)(void *user, RzPanel *panel, const RzPanelLayout dir, RZ_NULLABLE const char *title); - -RZ_IPI void rz_panel_free(RZ_NULLABLE RzPanel *panel); -RZ_IPI void rz_save_panels_layout(RzCore *core, const char *_name); -RZ_IPI bool rz_load_panels_layout(RzCore *core, const char *_name); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_PANELS_H diff --git a/dest/include/librz/rz_util/rz_path.h b/dest/include/librz/rz_util/rz_path.h deleted file mode 100644 index 4d85498de0a..00000000000 --- a/dest/include/librz/rz_util/rz_path.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef RZ_UTIL_PATH_H_ -#define RZ_UTIL_PATH_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Holds Rizin's path prefix and synchronization utilities. - * - * This structure stores the computed prefix of Rizin's path, along with a flag - * indicating whether the prefix has already been computed to avoid redundant work. - * It also includes a mutex to ensure thread-safe access when computing or accessing the prefix. - */ -typedef struct rz_path_t { - char *prefix; ///< the computed path prefix. - bool prefix_searched; ///< flag indicating if the prefix has already been computed. - RzThreadLock *prefix_mutex; ///< mutex to protect access to the prefix in multithreaded contexts. -} RzPath; - -#ifdef RZ_API - -RZ_API void rz_path_set_prefix(RZ_BORROW RZ_NONNULL RzPath *sys_path, RZ_NONNULL const char *path); -RZ_API const char *rz_path_prefix(RZ_BORROW RZ_NONNULL RzPath *sys_path); -RZ_API RZ_OWN char *rz_path_incdir(RZ_BORROW RZ_NULLABLE RzPath *sys_path); -RZ_API RZ_OWN char *rz_path_bindir(RZ_BORROW RZ_NULLABLE RzPath *sys_path); -RZ_API RZ_OWN char *rz_path_libdir(RZ_BORROW RZ_NULLABLE RzPath *sys_path); - -RZ_API RZ_OWN char *rz_path_system(RZ_BORROW RZ_NULLABLE RzPath *sys_path, RZ_NULLABLE const char *path); -RZ_API RZ_OWN char *rz_path_extra(RZ_NULLABLE const char *path); -RZ_API RZ_OWN char *rz_path_home_prefix(RZ_NULLABLE const char *path); -RZ_API RZ_OWN char *rz_path_home(RZ_NULLABLE const char *path); - -RZ_API RZ_OWN char *rz_path_system_rc(RZ_BORROW RZ_NULLABLE RzPath *sys_path); -RZ_API RZ_OWN char *rz_path_home_rc(void); -RZ_API RZ_OWN char *rz_path_home_config_rc(void); -RZ_API RZ_OWN char *rz_path_home_config_rcdir(void); -RZ_API RZ_OWN char *rz_path_home_config(void); -RZ_API RZ_OWN char *rz_path_home_cache(void); -RZ_API RZ_OWN char *rz_path_home_history(void); -RZ_API RZ_OWN char *rz_path_normalize_expand(char *usr_input, size_t len); - -RZ_API RZ_OWN char *rz_path_home_expand(RZ_NULLABLE const char *path); - -RZ_API RZ_OWN char *rz_path_realpath(RZ_NULLABLE const char *path); - -RZ_API RZ_OWN RzPath *rz_path_new(void); -RZ_API void rz_path_free(RZ_OWN RZ_NULLABLE RzPath *p); - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/rz_pj.h b/dest/include/librz/rz_util/rz_pj.h deleted file mode 100644 index 2e3f9eceb18..00000000000 --- a/dest/include/librz/rz_util/rz_pj.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef RZ_PJ_H -#define RZ_PJ_H - -#define RZ_PRINT_JSON_DEPTH_LIMIT 128 - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct pj_t { - RzStrBuf sb; - bool is_first; - bool is_key; - char braces[RZ_PRINT_JSON_DEPTH_LIMIT]; - int level; -} PJ; - -/* lifecycle */ -RZ_API PJ *pj_new(void); -RZ_API void pj_free(PJ *j); -RZ_API void pj_reset(PJ *j); // clear the pj contents, but keep the buffer allocated to re-use it -RZ_API char *pj_drain(PJ *j); -/* encode the pj data as a string */ -RZ_API const char *pj_string(PJ *pj); -// RZ_API void pj_print(PJ *j, PrintfCallback cb); -RZ_API void pj_raw(PJ *j, const char *k); - -/* nesting */ -// RZ_API PJ *pj_begin(char type, PrintfCallback cb); -/* close the current json list or array */ -RZ_API PJ *pj_end(PJ *j); -/* object, array */ -/* open new json list { */ -RZ_API PJ *pj_o(PJ *j); -/* open new array [ */ -RZ_API PJ *pj_a(PJ *j); -/* keys, values */ -/* new key with no value "name": */ -RZ_API PJ *pj_k(PJ *j, const char *k); -/* "name":"null" */ -RZ_API PJ *pj_knull(PJ *j, const char *k); -/* unsigned "name":n */ -RZ_API PJ *pj_kn(PJ *j, const char *k, ut64 n); -/* signed "name":n */ -RZ_API PJ *pj_kN(PJ *j, const char *k, st64 n); -/* literal key "name":"key" */ -RZ_API PJ *pj_ks(PJ *j, const char *k, const char *v); - -/* begin named array entry: "name": [...] */ -RZ_API PJ *pj_ka(PJ *j, const char *k); -/* begin named json entry: "name": {...} */ -RZ_API PJ *pj_ko(PJ *j, const char *k); - -/* named entry for primitive types */ -RZ_API PJ *pj_ki(PJ *j, const char *k, int d); -RZ_API PJ *pj_kd(PJ *j, const char *k, double d); -RZ_API PJ *pj_kf(PJ *j, const char *k, float d); -RZ_API PJ *pj_kb(PJ *j, const char *k, bool v); - -/* named "null" */ -RZ_API PJ *pj_null(PJ *j); - -/* array with first v_len bytes of v */ -RZ_API PJ *pj_r(PJ *j, const ut8 *v, size_t v_len); - -/* named entry with pj_r */ -RZ_API PJ *pj_kr(PJ *j, const char *k, const ut8 *v, size_t v_len); - -/* string, escaped for json */ -RZ_API PJ *pj_s(PJ *j, const char *k); -/* string, escaped for json without quotes */ -RZ_API PJ *pj_S(PJ *j, const char *k); -/* string, raw */ -RZ_API PJ *pj_j(PJ *j, const char *k); - -/* formatted primitive types */ -RZ_API PJ *pj_n(PJ *j, ut64 n); -RZ_API PJ *pj_N(PJ *j, st64 n); -RZ_API PJ *pj_i(PJ *j, int d); -RZ_API PJ *pj_d(PJ *j, double d); -RZ_API PJ *pj_f(PJ *j, float d); -RZ_API PJ *pj_b(PJ *j, bool v); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/rz_pkcs7.h b/dest/include/librz/rz_util/rz_pkcs7.h deleted file mode 100644 index 2de9e611146..00000000000 --- a/dest/include/librz/rz_util/rz_pkcs7.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef RZ_PKCS7_H -#define RZ_PKCS7_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rz_pkcs7_certificaterevocationlists_t { - ut32 length; - RzX509CertificateRevocationList **elements; -} RzPKCS7CertificateRevocationLists; - -typedef struct rz_pkcs7_extendedcertificatesandcertificates_t { - ut32 length; - RzX509Certificate **elements; -} RzPKCS7ExtendedCertificatesAndCertificates; - -typedef struct rz_pkcs7_digestalgorithmidentifiers_t { - ut32 length; - RzX509AlgorithmIdentifier **elements; -} RzPKCS7DigestAlgorithmIdentifiers; - -typedef struct rz_pkcs7_contentinfo_t { - RzASN1String *contentType; // OID - RzASN1Binary *content; // optional. oid structure definition -} RzPKCS7ContentInfo; - -typedef struct rz_pkcs7_issuerandserialnumber_t { - RzX509Name issuer; - RzASN1Binary *serialNumber; -} RzPKCS7IssuerAndSerialNumber; - -typedef struct rz_pkcs7_attribute_t { - RzASN1String *oid; // OID - RzASN1Binary *data; // optional. oid structure definition -} RzPKCS7Attribute; - -typedef struct rz_pkcs7_attributes_t { - ut32 length; - RzPKCS7Attribute **elements; -} RzPKCS7Attributes; - -typedef struct rz_pkcs7_signerinfo_t { - ut32 version; - RzPKCS7IssuerAndSerialNumber issuerAndSerialNumber; - RzX509AlgorithmIdentifier digestAlgorithm; - RzPKCS7Attributes authenticatedAttributes; // Optional - RzX509AlgorithmIdentifier digestEncryptionAlgorithm; - RzASN1Binary *encryptedDigest; - RzPKCS7Attributes unauthenticatedAttributes; // Optional -} RzPKCS7SignerInfo; - -typedef struct rz_pkcs7_signerinfos_t { - ut32 length; - RzPKCS7SignerInfo **elements; -} RzPKCS7SignerInfos; - -typedef struct rz_pkcs7_signeddata_t { - ut32 version; - RzPKCS7DigestAlgorithmIdentifiers digestAlgorithms; - RzPKCS7ContentInfo contentInfo; - RzPKCS7ExtendedCertificatesAndCertificates certificates; // Optional - RzPKCS7CertificateRevocationLists crls; // Optional - RzPKCS7SignerInfos signerinfos; -} RzPKCS7SignedData; - -typedef struct rz_pkcs7_container_t { - RzASN1String *contentType; - RzPKCS7SignedData signedData; -} RzCMS; - -typedef struct rz_cms_attribute_type_optional_value_t { - RzASN1String *type; // OID - RzASN1Binary *data; // optional. -} RzSpcAttributeTypeAndOptionalValue; - -typedef struct rz_cms_digest_info_t { - RzX509AlgorithmIdentifier digestAlgorithm; - RzASN1Binary *digest; -} RzSpcDigestInfo; - -typedef struct rz_cms_indirect_data_content_t { - RzSpcAttributeTypeAndOptionalValue data; - RzSpcDigestInfo messageDigest; -} RzSpcIndirectDataContent; - -RZ_API RZ_OWN RzCMS *rz_pkcs7_cms_parse(RZ_NULLABLE const ut8 *buffer, ut32 length); -RZ_API void rz_pkcs7_cms_free(RZ_NULLABLE RzCMS *container); -RZ_API RZ_OWN RzStructuredData *rz_pkcs7_cms_to_structure(RZ_NULLABLE RzCMS *container); -RZ_API RZ_OWN RzSpcIndirectDataContent *rz_pkcs7_spcinfo_parse(RZ_NONNULL RzCMS *cms); -RZ_API void rz_pkcs7_spcinfo_free(RZ_NULLABLE RzSpcIndirectDataContent *spcinfo); -RZ_API RZ_OWN RzStructuredData *rz_pkcs7_spcinfo_to_structure(RZ_NULLABLE RzSpcIndirectDataContent *spcinfo); - -#ifdef __cplusplus -} -#endif - -#endif /* RZ_PKCS7_H */ diff --git a/dest/include/librz/rz_util/rz_pkcs8.h b/dest/include/librz/rz_util/rz_pkcs8.h deleted file mode 100644 index 4701c4989ee..00000000000 --- a/dest/include/librz/rz_util/rz_pkcs8.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef RZ_PKCS8_H -#define RZ_PKCS8_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define RZ_PKCS8_VERSION_1 0 -#define RZ_PKCS8_VERSION_2 1 - -typedef struct pkcs8_private_key_algorithm_t { - RzASN1String *algorithm; ///< OBJECT IDENTIFIER - RzASN1Binary *parameters; ///< ANY -} RzPKCS8PrivateKeyAlgorithm; - -typedef struct private_key_info_t { - ut32 version; - RzPKCS8PrivateKeyAlgorithm private_key_algorithm; ///< OBJECT IDENTIFIER - RzASN1Binary *private_key; ///< OCTET STRING - RzASN1Binary *public_key; ///< BIT STRING -} RzPrivateKeyInfo; - -RZ_API RZ_OWN RzPrivateKeyInfo *rz_pkcs8_private_key_info_parse(RZ_NULLABLE const ut8 *buffer, ut32 length); -RZ_API void rz_pkcs8_private_key_info_free(RZ_NULLABLE RzPrivateKeyInfo *pki); -RZ_API RZ_OWN char *rz_pkcs8_private_key_algorithm(RZ_NONNULL const RzPrivateKeyInfo *pki); -RZ_API RZ_OWN RzStructuredData *rz_pkcs8_private_key_info_to_structure(RZ_NULLABLE const RzPrivateKeyInfo *pki); - -#ifdef __cplusplus -} -#endif - -#endif /* RZ_PKCS8_H */ diff --git a/dest/include/librz/rz_util/rz_print.h b/dest/include/librz/rz_util/rz_print.h deleted file mode 100644 index 761458ad493..00000000000 --- a/dest/include/librz/rz_util/rz_print.h +++ /dev/null @@ -1,245 +0,0 @@ -#ifndef RZ_PRINT_H -#define RZ_PRINT_H - -#include "rz_types.h" -#include "rz_cons.h" -#include "rz_bind.h" -#include "rz_io.h" -#include "rz_reg.h" -#include "rz_cmd.h" -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define RZ_PRINT_FLAGS_COLOR 0x00000001 -#define RZ_PRINT_FLAGS_CURSOR 0x00000004 -#define RZ_PRINT_FLAGS_HEADER 0x00000008 -#define RZ_PRINT_FLAGS_SPARSE 0x00000010 -#define RZ_PRINT_FLAGS_SEGOFF 0x00000020 -#define RZ_PRINT_FLAGS_OFFSET 0x00000040 -#define RZ_PRINT_FLAGS_REFS 0x00000080 -#define RZ_PRINT_FLAGS_DIFFOUT 0x00000100 /* only show different rows in `cc` hexdiffing */ -#define RZ_PRINT_FLAGS_ADDRDEC 0x00000200 -#define RZ_PRINT_FLAGS_COMMENT 0x00000400 -#define RZ_PRINT_FLAGS_COMPACT 0x00000800 -#define RZ_PRINT_FLAGS_NONHEX 0x00001000 -#define RZ_PRINT_FLAGS_SECSUB 0x00002000 -#define RZ_PRINT_FLAGS_HDROFF 0x00008000 -#define RZ_PRINT_FLAGS_STYLE 0x00010000 -#define RZ_PRINT_FLAGS_NONASCII 0x00020000 -#define RZ_PRINT_FLAGS_ALIGN 0x00040000 -#define RZ_PRINT_FLAGS_UNALLOC 0x00080000 -#define RZ_PRINT_FLAGS_BGFILL 0x00100000 -#define RZ_PRINT_FLAGS_SECTION 0x00200000 -#define RZ_PRINT_FLAGS_NODOT 0x00400000 /* hide the dot before printable characters */ - -typedef const char *(*RzPrintNameCallback)(void *user, ut64 addr); -typedef int (*RzPrintSizeCallback)(void *user, ut64 addr); -typedef char *(*RzPrintCommentCallback)(void *user, ut64 addr); -typedef const char *(*RzPrintSectionGet)(void *user, ut64 addr); -typedef const char *(*RzPrintColorFor)(void *user, ut64 addr, bool verbose); -typedef char *(*RzPrintHasRefs)(void *user, ut64 addr, RzOutputMode mode); - -typedef enum { - RZ_ASM_TOKEN_UNKNOWN = 0, ///< Does not fit to any token below. - RZ_ASM_TOKEN_MNEMONIC, ///< Asm mnemonics like: mov, push, lea... - RZ_ASM_TOKEN_OPERATOR, ///< Arithmetic operators: +,-,<< etc. - RZ_ASM_TOKEN_NUMBER, ///< Numbers - RZ_ASM_TOKEN_REGISTER, ///< Registers - RZ_ASM_TOKEN_SEPARATOR, ///< Brackets, comma etc. - RZ_ASM_TOKEN_META, ///< Meta information (e.g Hexagon packet prefix, ARM & Hexagon number prefix). - - RZ_ASM_TOKEN_LAST, -} RzAsmTokenType; - -/** - * \brief A token of an asm string holding meta data. - */ -typedef struct { - size_t start; ///< byte-offset into `str` where this token starts. Must be exactly at a utf-8 codepoint boundary. - size_t len; ///< `str` length of token in bytes. - RzAsmTokenType type; - union { - ut64 number; ///< Number of RZ_ASM_TOKEN_NUMBER - } val; -} RzAsmToken; - -/** - * \brief A tokenized asm string. - */ -typedef struct { - ut32 op_type; ///< RzAnalysisOpType. Mnemonic color depends on this. - RzStrBuf *str; ///< Contains the raw asm string - RzPVector /**/ *tokens; ///< Contains only the tokenization meta-info without strings, ordered by start for log2(n) access -} RzAsmTokenString; - -typedef struct { - const RzRegSet *reg_sets; ///< Array of reg sets used to lookup register names during parsing. - ut32 ana_op_type; ///< Analysis op type (see: _RzAnalysisOpType) of the token string to parse. -} RzAsmParseParam; - -/** - * \brief Pattern for a asm string token. - */ -typedef struct { - RzAsmTokenType type; ///< Asm token type. - char *pattern; ///< The regex pattern describing the tokens. - RzRegex *regex; ///< Compiled regex pattern. -} RzAsmTokenPattern; - -/** - * \brief Holds certain options to alter the colorizing of asm strings. - * - */ -typedef struct { - bool reset_bg; ///< Reset the background color? - ut64 hl_addr; ///< Address which should be highlighted. Usually the function address. -} RzPrintAsmColorOpts; - -typedef struct rz_print_zoom_t { - ut8 *buf; - ut64 from; - ut64 to; - int size; - int mode; -} RzPrintZoom; - -typedef struct rz_print_t { - void *user; - RzIOBind iob; - bool pava; - RzCoreBind coreb; - const char *cfmt; - char datefmt[32]; - int datezone; - int (*write)(const unsigned char *buf, int len); - PrintfCallback cb_printf; - char *(*cb_color)(int idx, int last, bool bg); - bool scr_prompt; - int (*disasm)(void *p, ut64 addr); - PrintfCallback oprintf; - int big_endian; - int width; - int limit; - int bits; - bool histblock; - // true if the cursor is enabled, false otherwise - bool cur_enabled; - // offset of the selected byte from the first displayed one - int cur; - // offset of the selected byte from the first displayed one, when a - // range of bytes is selected. -1 is used if no bytes are selected. - int ocur; - int cols; - int flags; - int seggrn; - bool use_comments; - int col; - int stride; - int bytespace; - int pairs; - bool resetbg; - RzPrintZoom *zoom; - RzPrintNameCallback offname; - RzPrintSizeCallback offsize; - RzPrintColorFor colorfor; - RzPrintHasRefs hasrefs; - RzPrintCommentCallback get_comments; - RzPrintSectionGet get_section_name; - Sdb *sdb_types; - RzCons *cons; - RzConsBind consbind; - RzNum *num; - RzReg *reg; - RzRegItem *(*get_register)(const RzReg *reg, const char *name, int type); - ut64 (*get_register_value)(RzReg *reg, RzRegItem *item); - bool (*exists_var)(struct rz_print_t *print, ut64 func_addr, char *str); - bool esc_bslash; - bool wide_offsets; - const char *strconv_mode; - char io_unalloc_ch; - bool show_offset; - - // when true it uses row_offsets - bool calc_row_offsets; - // offset of the first byte of each printed row. - // Last elements is marked with a UT32_MAX. - ut32 *row_offsets; - // size of row_offsets - int row_offsets_sz; - // when true it makes visual mode flush the buffer to screen - bool vflush; - // represents the first not-visible offset on the screen - // (only when in visual disasm mode) - ut64 screen_bounds; - // Memoized current row number to calculate screen_bounds - int rows; - RzPrintAsmColorOpts colorize_opts; ///< Coloize options for asm strings. -} RzPrint; - -#ifdef RZ_API - -/* RzConsBreak handlers */ -typedef bool (*RzPrintIsInterruptedCallback)(); - -RZ_API bool rz_print_is_interrupted(void); -RZ_API void rz_print_set_is_interrupted_cb(RzPrintIsInterruptedCallback cb); - -/* ... */ -RZ_API char *rz_print_hexpair(RzPrint *p, const char *str, int idx); -RZ_API RzPrint *rz_print_new(void); -RZ_API RzPrint *rz_print_free(RzPrint *p); -RZ_API void rz_print_set_flags(RzPrint *p, int _flags); -RZ_API void rz_print_addr(RzPrint *p, ut64 addr); -RZ_API char *rz_print_section_str(RzPrint *p, ut64 at); -RZ_API void rz_print_hexii(RzPrint *p, ut64 addr, const ut8 *buf, int len, int step); -RZ_API RZ_OWN char *rz_print_hexdump_str(RZ_NONNULL RzPrint *p, ut64 addr, RZ_NONNULL const ut8 *buf, int len, int base, int step, size_t zoomsz); -RZ_API RZ_OWN char *rz_print_jsondump_str(RZ_NONNULL RzPrint *p, RZ_NONNULL const ut8 *buf, int len, int wordsize); -RZ_API RZ_OWN char *rz_print_hexdiff_str(RZ_NONNULL RzPrint *p, ut64 aa, RZ_NONNULL const ut8 *_a, ut64 ba, RZ_NONNULL const ut8 *_b, int len, int scndcol); -RZ_API void rz_print_bytes(RzPrint *p, const ut8 *buf, int len, const char *fmt); -RZ_API void rz_print_byte(RzPrint *p, const char *fmt, int idx, ut8 ch); -RZ_API const char *rz_print_byte_color(RzPrint *p, int ch); -RZ_API void rz_print_raw(RzPrint *p, ut64 addr, const ut8 *buf, int len); -RZ_API bool rz_print_have_cursor(RzPrint *p, int cur, int len); -RZ_API bool rz_print_cursor_pointer(RzPrint *p, int cur, int len); -RZ_API int rz_print_get_cursor(RzPrint *p); -RZ_API void rz_print_set_cursor(RzPrint *p, int curset, int ocursor, int cursor); -#define SEEFLAG -2 -#define JSONOUTPUT -3 - -/* mode values for rz_print_format_* API */ -#define RZ_PRINT_MUSTSEE (1) // enable printing of data in specified fmt -#define RZ_PRINT_ISFIELD (1 << 1) -#define RZ_PRINT_SEEFLAGS (1 << 2) -#define RZ_PRINT_JSON (1 << 3) -#define RZ_PRINT_MUSTSET (1 << 4) -#define RZ_PRINT_UNIONMODE (1 << 5) -#define RZ_PRINT_VALUE (1 << 6) -#define RZ_PRINT_DOT (1 << 7) -#define RZ_PRINT_QUIET (1 << 8) -#define RZ_PRINT_STRUCT (1 << 9) - -RZ_API void rz_print_offset(RzPrint *p, ut64 off, int invert, int opt, int dec, int delta, const char *label); -RZ_API void rz_print_offset_sg(RzPrint *p, ut64 off, int invert, int offseg, int seggrn, int offdec, int delta, const char *label); -RZ_API const char *rz_print_color_op_type(RZ_NONNULL RzPrint *p, ut32 /* RzAnalaysisOpType */ analysis_type); -RZ_API void rz_print_init_rowoffsets(RzPrint *p); -RZ_API ut32 rz_print_rowoff(RzPrint *p, int i); -RZ_API void rz_print_set_rowoff(RzPrint *p, int i, ut32 offset, bool overwrite); -RZ_API int rz_print_row_at_off(RzPrint *p, ut32 offset); - -// WIP -RZ_API void rz_print_set_screenbounds(RzPrint *p, ut64 addr); -RZ_API RZ_OWN char *rz_print_json_indent(RZ_NULLABLE const char *s, bool color, const char *tab, RZ_NULLABLE const char **palette); -RZ_API char *rz_print_json_human(const char *s); - -RZ_API RZ_OWN RzStrBuf *rz_print_colorize_asm_str(RZ_BORROW RzPrint *p, const RzAsmTokenString *toks); -RZ_API void rz_print_colored_help(const char **options, size_t options_len, bool have_examples); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/rz_protobuf.h b/dest/include/librz/rz_util/rz_protobuf.h deleted file mode 100644 index 22a8b55e2fa..00000000000 --- a/dest/include/librz/rz_util/rz_protobuf.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef RZ_PROTOBUF_H -#define RZ_PROTOBUF_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -RZ_API RZ_OWN char *rz_protobuf_decode(RZ_NULLABLE const ut8 *buffer, const ut64 size, bool debug); - -#ifdef __cplusplus -} -#endif - -#endif /* RZ_PROTOBUF_H */ diff --git a/dest/include/librz/rz_util/rz_punycode.h b/dest/include/librz/rz_util/rz_punycode.h deleted file mode 100644 index 315acf96d2e..00000000000 --- a/dest/include/librz/rz_util/rz_punycode.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef RZ_PUNYCODE_H -#define RZ_PUNYCODE_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -RZ_API char *rz_punycode_encode(const ut8 *src, int srclen, int *dstlen); -RZ_API char *rz_punycode_decode(const char *src, int srclen, int *dstlen); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_PUNYCODE_H diff --git a/dest/include/librz/rz_util/rz_range.h b/dest/include/librz/rz_util/rz_range.h deleted file mode 100644 index 38d5fbe2ca6..00000000000 --- a/dest/include/librz/rz_util/rz_range.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef RZ_RANGE_H -#define RZ_RANGE_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* range.c */ - -typedef struct rz_range_item_t { - ut64 fr; - ut64 to; - ut8 *data; - int datalen; -} RRangeItem; - -typedef struct rz_range_t { - int count; - int changed; - RzList /**/ *ranges; -} RRange; - -RZ_API RRange *rz_range_new(void); -RZ_API RRange *rz_range_new_from_string(const char *string); -RZ_API RRange *rz_range_free(RRange *r); -RZ_API RRangeItem *rz_range_item_get(RRange *r, ut64 addr); -RZ_API ut64 rz_range_size(RRange *r); -RZ_API int rz_range_add_from_string(RRange *rgs, const char *string); -RZ_API RRangeItem *rz_range_add(RRange *rgs, ut64 from, ut64 to, int rw); -RZ_API int rz_range_sub(RRange *rgs, ut64 from, ut64 to); -RZ_API int rz_range_contains(RRange *rgs, ut64 addr); -RZ_API int rz_range_sort(RRange *rgs); -RZ_API void rz_range_percent(RRange *rgs); -RZ_API int rz_range_list(RRange *rgs, int rad); -RZ_API int rz_range_get_n(RRange *rgs, int n, ut64 *from, ut64 *to); -RZ_API RRange *rz_range_inverse(RRange *rgs, ut64 from, ut64 to, int flags); -RZ_API int rz_range_overlap(ut64 a0, ut64 a1, ut64 b0, ut64 b1, int *d); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_RANGE_H diff --git a/dest/include/librz/rz_util/rz_rbtree.h b/dest/include/librz/rz_util/rz_rbtree.h deleted file mode 100644 index 499b27139db..00000000000 --- a/dest/include/librz/rz_util/rz_rbtree.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef RZ_RBTREE_H -#define RZ_RBTREE_H - -#include -#include -#include - -#include "rz_list.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// max height <= 2 * floor(log2(n + 1)) -// We use `int` for size, so <= 2 * 31 -#define RZ_RBTREE_MAX_HEIGHT 62 - -// Singleton can be zero initialized -typedef struct rz_rb_node_t { - struct rz_rb_node_t *child[2]; - bool red; -} RBNode; - -typedef RBNode *RBTree; - -// incoming < in_tree => return < 0 -// incoming == in_tree => return == 0 -// incoming > in_tree => return > 0 -typedef int (*RBComparator)(const void *incoming, const RBNode *in_tree, void *user); - -typedef void (*RBNodeFree)(RBNode *node, void *user); -typedef void (*RBNodeSum)(RBNode *node); - -typedef struct rz_rb_iter_t { - // current depth - // if len == 0, the iterator is at the end/empty - // else path[len-1] is the current node - int len; - - // current path from root to the current node - // excluding nodes into whose right (or left, for reverse iteration) branch the iterator has descended - // (these nodes are before the current) - RBNode *path[RZ_RBTREE_MAX_HEIGHT]; -} RBIter; - -typedef int (*RContRBCmp)(void *incoming, void *in, void *user); -typedef void (*RContRBFree)(void *); -typedef struct rz_containing_rb_node_t { - RBNode node; - void *data; -} RContRBNode; - -typedef struct rz_containing_rb_tree_t { - RContRBNode *root; - RContRBFree free; -} RContRBTree; - -// Routines for augmented red-black trees. The user should provide an aggregation (monoid sum) callback `sum` -// to calculate extra information such as size, sum, ... -RZ_API bool rz_rbtree_aug_delete(RBNode **root, void *data, RBComparator cmp, void *cmp_user, RBNodeFree freefn, void *free_user, RBNodeSum sum); -RZ_API bool rz_rbtree_aug_insert(RBNode **root, void *data, RBNode *node, RBComparator cmp, void *cmp_user, RBNodeSum sum); -RZ_API bool rz_rbtree_aug_update_sum(RBNode *root, void *data, RBNode *node, RBComparator cmp, void *cmp_user, RBNodeSum sum); - -RZ_API bool rz_rbtree_delete(RBNode **root, void *data, RBComparator cmp, void *cmp_user, RBNodeFree freefn, void *free_user); -RZ_API RBNode *rz_rbtree_find(RBNode *root, void *data, RBComparator cmp, void *user); -RZ_API void rz_rbtree_free(RZ_NULLABLE RBNode *root, RBNodeFree freefn, void *user); -RZ_API bool rz_rbtree_insert(RBNode **root, void *data, RBNode *node, RBComparator cmp, void *user); -// Return the smallest node that is greater than or equal to `data` -RZ_API RBNode *rz_rbtree_lower_bound(RBNode *root, void *data, RBComparator cmp, void *user); -// Return the greatest node that is less than or equal to `data` -RZ_API RBNode *rz_rbtree_upper_bound(RBNode *root, void *data, RBComparator cmp, void *user); - -// Create a forward iterator starting from the leftmost node -RZ_API RBIter rz_rbtree_first(RBNode *root); -// Create a backward iterator starting from the rightmost node -RZ_API RBIter rz_rbtree_last(RBNode *root); - -// Iterate [lower_bound, end] forward, used with rz_rbtree_iter_next -RZ_API RBIter rz_rbtree_lower_bound_forward(RBNode *root, void *data, RBComparator cmp, void *user); -// Iterate [begin, upper_bound] backward, used with rz_rbtree_iter_prev -RZ_API RBIter rz_rbtree_upper_bound_backward(RBNode *root, void *data, RBComparator cmp, void *user); - -// struct Node { int key; RBNode rb; }; -// rz_rbtree_iter_get (it, struct Node, rb) -#define rz_rbtree_iter_get(it, struc, rb) (container_of((it)->path[(it)->len - 1], struc, rb)) -// If the iterator still contains elements, including the current -#define rz_rbtree_iter_has(it) ((it)->len) -// Move forward -RZ_API void rz_rbtree_iter_next(RBIter *it); -// Move backward -RZ_API void rz_rbtree_iter_prev(RBIter *it); - -// Iterate all elements of the forward iterator -#define rz_rbtree_iter_while(it, data, struc, rb) \ - for (; rz_rbtree_iter_has(&it) && (data = rz_rbtree_iter_get(&it, struc, rb)); rz_rbtree_iter_next(&(it))) - -// Iterate all elements of the backward iterator -#define rz_rbtree_iter_while_prev(it, data, struc, rb) \ - for (; rz_rbtree_iter_has(&it) && (data = rz_rbtree_iter_get(&it, struc, rb)); rz_rbtree_iter_prev(&(it))) - -#define rz_rbtree_foreach(root, it, data, struc, rb) \ - for ((it) = rz_rbtree_first(root); rz_rbtree_iter_has(&it) && (data = rz_rbtree_iter_get(&it, struc, rb)); rz_rbtree_iter_next(&(it))) - -#define rz_rbtree_foreach_prev(root, it, data, struc, rb) \ - for ((it) = rz_rbtree_last(root); rz_rbtree_iter_has(&it) && (data = rz_rbtree_iter_get(&it, struc, rb)); rz_rbtree_iter_prev(&(it))) - -RZ_API RZ_OWN RContRBTree *rz_rbtree_cont_new(void); -RZ_API RZ_OWN RContRBTree *rz_rbtree_cont_newf(RContRBFree f); -RZ_API bool rz_rbtree_cont_insert(RContRBTree *tree, void *data, RContRBCmp cmp, void *user); -RZ_API bool rz_rbtree_cont_delete(RContRBTree *tree, void *data, RContRBCmp cmp, void *user); -RZ_API void *rz_rbtree_cont_find(RContRBTree *tree, void *data, RContRBCmp cmp, void *user); - -#define rz_rbtree_cont_foreach(tree, it, dat) \ - for ((it) = rz_rbtree_first((tree)->root ? &(tree)->root->node : NULL); rz_rbtree_iter_has(&it) && (dat = rz_rbtree_iter_get(&it, RContRBNode, node)->data); rz_rbtree_iter_next(&(it))) - -#define rz_rbtree_cont_foreach_prev(tree, it, dat) \ - for ((it) = rz_rbtree_last((tree)->root ? &(tree)->root->node : NULL); rz_rbtree_iter_has(&it) && (dat = rz_rbtree_iter_get(&it, RContRBNode, node)->data); rz_rbtree_iter_prev(&(it))) - -RZ_API void rz_rbtree_cont_free(RContRBTree *tree); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/rz_regex.h b/dest/include/librz/rz_util/rz_regex.h deleted file mode 100644 index e87080e557d..00000000000 --- a/dest/include/librz/rz_util/rz_regex.h +++ /dev/null @@ -1,212 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Rot127 -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_REGEX_H -#define RZ_REGEX_H - -#include -#include -#include -#include -#include - -#define RZ_REGEX_SIZE size_t - -// Some basic PCRE2 macros. There are way more defined -// and should be added here if needed. -#define RZ_REGEX_ERROR_NOMATCH (-1) /* PCRE2_ERROR_NOMATCH */ -#define RZ_REGEX_ERROR_PARTIAL (-2) /* PCRE2_ERROR_PARTIAL */ - -/** - * \brief Regex compilation flags. They are only used for rz_regex_new() - * C alters what is compiled by rz_regex_new() - * J alters what is compiled by rz_regex_new() (with JIT enabled). - * M is inspected during rz_regex_match() execution - * D is inspected during pcre2_dfa_match() execution (not used). - */ -#define RZ_REGEX_DEFAULT 0 -#define RZ_REGEX_LITERAL 0x02000000u /* PCRE2_LITERAL - C */ -#define RZ_REGEX_CASELESS 0x00000008u /* PCRE2_CASELESS - C */ -/** - * \brief If RZ_REGEX_EXTENDED is passed to rz_regex_new_16() or rz_regex_new_32() - * spaces in the pattern **will** be skipped! You need to replace them with \s. - * This is in accordance with the PCRE2 documentation. - * - * If RZ_REGEX_EXTENDED is passed to rz_regex_new() (the UTF-8 regular expressions) - * the spaces **will not** be skipped but interally be replaced with '\s'. - * This was done to keep our interal regex matching stable. - * - * Values can be passed as cflags. - */ -#define RZ_REGEX_EXTENDED 0x00000080u /* PCRE2_EXTENDED - C */ -#define RZ_REGEX_EXTENDED_MORE 0x01000000u /* PCRE2_EXTENDED_MORE - C */ -#define RZ_REGEX_MULTILINE 0x00000400u /* PCRE2_MULTILINE - C */ -#define RZ_REGEX_DOTALL 0x00000020u /* PCRE2_DOTALL - C */ - -// Can be passed as jflags -#define RZ_REGEX_JIT_PARTIAL_SOFT 0x00000002u /* PCRE2_JIT_PARTIAL_SOFT */ -#define RZ_REGEX_JIT_PARTIAL_HARD 0x00000004u /* PCRE2_JIT_PARTIAL_HARD */ - -// Can be passed for mflags -#define RZ_REGEX_PARTIAL_SOFT 0x00000010u /* PCRE2_PARTIAL_SOFT */ -#define RZ_REGEX_PARTIAL_HARD 0x00000020u /* PCRE2_PARTIAL_HARD */ - -#define RZ_REGEX_UNSET (~(RZ_REGEX_SIZE)0) /* PCRE2_UNSET */ -#define RZ_REGEX_ZERO_TERMINATED (~(RZ_REGEX_SIZE)0) /* PCRE2_ZERO_TERMINATED */ - -typedef int RzRegexStatus; ///< An status number returned by the regex API. -typedef size_t RzRegexSize; ///< Size of a text or regex. This is the size measured in code width. For UTF-8: bytes. -typedef ut32 RzRegexFlags; ///< Regex flag bits. -typedef uint8_t *RzRegexPattern; ///< A regex pattern string. -typedef void RzRegex; ///< A regex expression for UTF-8 strings. -typedef void RzRegexCompContext; ///< A PCRE2 compile context for UTF-8 strings. -typedef void RzRegex16; ///< A regex expression for UTF-16 strings (host endianess). -typedef void RzRegexCompContext16; ///< A PCRE2 compile context for UTF-16 strings (host endianess). -typedef void RzRegex32; ///< A regex expression for UTF-32 strings (host endianess). -typedef void RzRegexCompContext32; ///< A PCRE2 compile context for UTF-32 strings (host endianess). - -typedef enum { - RZ_REGEX_UTF8, - RZ_REGEX_UTF16, - RZ_REGEX_UTF32, -} RzRegexType; - -typedef struct { - RzRegexType re_type; - RzRegexFlags compile_flags_jit; - union { - RzRegex *re8; - RzRegex16 *re16; - RzRegex32 *re32; - }; - void *jit_stack; ///< The JIT stack for this pattern. Must be used only by one thread at a time. -} RzRegexMulti; - -typedef struct { - RzRegexSize group_idx; ///< Index of the group. Used to determine name if any was given. - /** - * \brief Start offset into the text where the match starts. - * The offset is in code units, not in characters! - * One code unit is 1 byte for UTF-8, 2 bytes for UTF-16, and 4 bytes for UTF-32. - */ - RzRegexSize start; - /** - * \brief The length of the match in number of code units. - * One code unit is 1 byte for UTF-8, 2 bytes for UTF-16, and 4 bytes for UTF-32. - */ - RzRegexSize len; ///< Length of match in bytes. -} RzRegexMatch; - -typedef void RzRegexMatchData; ///< PCRE2 internal match data type - -RZ_API RZ_OWN RzRegex *rz_regex_new(RZ_NONNULL const char *pattern, RzRegexFlags cflags, RzRegexFlags jflags, - RzRegexCompContext *ccontext); -RZ_API RZ_OWN RzRegex16 *rz_regex_new_16(RZ_NONNULL const char *pattern, RzRegexFlags cflags, RzRegexFlags jflags, - RzRegexCompContext *ccontext); -RZ_API RZ_OWN RzRegex32 *rz_regex_new_32(RZ_NONNULL const char *pattern, RzRegexFlags cflags, RzRegexFlags jflags, - RzRegexCompContext *ccontext); -RZ_API RZ_OWN RzRegexMulti *rz_regex_new_multi(RZ_NONNULL const char *pattern, RzRegexFlags cflags, RzRegexFlags jflags, - RzRegexCompContext *ccontext, RzRegexType type); -RZ_API RZ_OWN RzRegex *rz_regex_new_bytes(RZ_NONNULL const ut8 *pattern, size_t pattern_len, RzRegexFlags cflags, RzRegexFlags jflags, - RzRegexCompContext *ccontext); -RZ_API void rz_regex_free(RZ_OWN RzRegex *regex); -RZ_API void rz_regex_free_16(RZ_OWN RzRegex16 *regex); -RZ_API void rz_regex_free_32(RZ_OWN RzRegex32 *regex); -RZ_API void rz_regex_free_multi(RZ_NULLABLE RZ_OWN RzRegexMulti *regex); -RZ_API RZ_OWN RzRegexMulti *rz_regex_multi_clone(RZ_NONNULL RzRegexMulti *regex, bool clone_jit); -RZ_API void rz_regex_free_multi_clone(RZ_NULLABLE RZ_OWN RzRegexMulti *regex); -RZ_API void rz_regex_error_msg(RzRegexStatus errcode, RZ_OUT char *errbuf, RzRegexSize errbuf_size); -RZ_API const ut8 *rz_regex_get_match_name(RZ_NONNULL const RzRegex *regex, ut32 name_idx); -RZ_API st32 rz_regex_get_group_idx_by_name(RZ_NONNULL const RzRegex *regex, const char *group); -RZ_API RzRegexStatus rz_regex_match(RZ_NONNULL const RzRegex *regex, RZ_NONNULL const char *text, - RzRegexSize text_size, - RzRegexSize text_offset, - RzRegexFlags mflags); -RZ_API RZ_OWN RzPVector /**/ *rz_regex_match_all_not_grouped( - RZ_NONNULL const RzRegex *regex, - RZ_NONNULL const char *text, - RzRegexSize text_size, - RzRegexSize text_offset, - RzRegexFlags mflags); -RZ_API RZ_OWN RzPVector /**/ *rz_regex_match_first( - RZ_NONNULL const RzRegex *regex, - RZ_NONNULL const char *text, - RzRegexSize text_size, - RzRegexSize text_offset, - RzRegexFlags mflags); -RZ_API RZ_OWN RzPVector /**/ *rz_regex_match_first_16( - RZ_NONNULL const RzRegex16 *regex, - RZ_NONNULL const ut16 *text, - RzRegexSize text_size, - RzRegexSize text_offset, - RzRegexFlags mflags); -RZ_API RZ_OWN RzPVector /**/ *rz_regex_match_first_32( - RZ_NONNULL const RzRegex32 *regex, - RZ_NONNULL const ut32 *text, - RzRegexSize text_size, - RzRegexSize text_offset, - RzRegexFlags mflags); -RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all( - RZ_NONNULL const RzRegex *regex, - RZ_NONNULL const char *text, - RzRegexSize text_size, - RzRegexSize text_offset, - RzRegexFlags mflags); -RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all_overlap( - RZ_NONNULL const RzRegex *regex, - RZ_NONNULL const char *text, - RzRegexSize text_size, - RzRegexSize text_offset, - RzRegexFlags mflags); -RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all_16( - RZ_NONNULL const RzRegex16 *regex, - RZ_NONNULL const ut16 *text, - RzRegexSize text_size, - RzRegexSize text_offset, - RzRegexFlags mflags); -RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all_overlap_16( - RZ_NONNULL const RzRegex16 *regex, - RZ_NONNULL const ut16 *text, - RzRegexSize text_size, - RzRegexSize text_offset, - RzRegexFlags mflags); -RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all_32( - RZ_NONNULL const RzRegex32 *regex, - RZ_NONNULL const ut32 *text, - RzRegexSize text_size, - RzRegexSize text_offset, - RzRegexFlags mflags); -RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all_overlap_32( - RZ_NONNULL const RzRegex32 *regex, - RZ_NONNULL const ut32 *text, - RzRegexSize text_size, - RzRegexSize text_offset, - RzRegexFlags mflags); -RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all_multi( - RZ_NONNULL const RzRegexMulti *regex, - RZ_NONNULL const ut8 *text, - RzRegexSize text_size, - RzRegexSize text_offset, - RzRegexFlags mflags); -RZ_API RZ_OWN RzPVector /* *>*/ *rz_regex_match_all_overlap_multi( - RZ_NONNULL const RzRegexMulti *regex, - RZ_NONNULL const ut8 *text, - RzRegexSize text_size, - RzRegexSize text_offset, - RzRegexFlags mflags); -RZ_API bool rz_regex_contains(RZ_NONNULL const char *pattern, RZ_NONNULL const char *text, - RzRegexSize text_size, - RzRegexFlags cflags, RzRegexFlags mflags); -RZ_API RzRegexSize rz_regex_find(RZ_NONNULL const char *pattern, RZ_NONNULL RZ_BORROW char *text, - RzRegexSize text_size, RzRegexSize text_offset, - RzRegexFlags cflags, RzRegexFlags mflags); -RZ_API RZ_OWN RzStrBuf *rz_regex_full_match_str(RZ_NONNULL const char *pattern, RZ_NONNULL const char *text, - RzRegexSize text_size, - RzRegexFlags cflags, RzRegexFlags mflags, RZ_NONNULL const char *separator); -RZ_API RZ_OWN RzRegexCompContext *rz_regex_compile_context_new(); -RZ_API void rz_regex_compile_context_free(RzRegexCompContext *ccontext); -RZ_API void rz_regex_set_nul_as_newline(RZ_NONNULL RzRegexCompContext *ccontext); -RZ_API RzRegexFlags rz_regex_parse_flag_desc(RZ_NULLABLE const char *re_flags_desc); -RZ_API RZ_OWN char *rz_regex_create_wildcard_pattern(size_t min_len, size_t max_len); - -#endif /* RZ_REGEX_H */ diff --git a/dest/include/librz/rz_util/rz_serialize.h b/dest/include/librz/rz_util/rz_serialize.h deleted file mode 100644 index 6410f92d473..00000000000 --- a/dest/include/librz/rz_util/rz_serialize.h +++ /dev/null @@ -1,138 +0,0 @@ -// SPDX-FileCopyrightText: Florian Märkl -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_SERIALIZE_H -#define RZ_SERIALIZE_H - -#include -#include -#include - -/** - * \brief Detailed info about a (de)serialization result - * - * This is currently just a list of strings which may be warnings - * or detailed error messages. - */ -typedef RzList RzSerializeResultInfo; - -static inline RzSerializeResultInfo *rz_serialize_result_info_new(void) { - return rz_list_newf(free); -} - -static inline void rz_serialize_result_info_free(RzSerializeResultInfo *info) { - rz_list_free(info); -} - -// Common helpers for writing (de)serialization code - -/** - * \brief Push an error to the local RzSerializeResultInfo - * \res RzSerializeInfoResult * - * \param ... printf-style arguments to be pushed as the error to res - */ -#define RZ_SERIALIZE_ERR(res, ...) \ - do { \ - if (res) { \ - rz_list_push(res, rz_str_newf(__VA_ARGS__)); \ - } \ - } while (0) - -/** - * \brief Hashtable-based key parser to prevent strcmp chains - * - * This enables string values to be used in a switch/case-like - * fashion. - */ -typedef HtSP RzKeyParser; - -static inline RzKeyParser *rz_key_parser_new(void) { - return ht_sp_new(HT_STR_DUP, NULL, NULL); -} - -static inline void rz_key_parser_free(RzKeyParser *parser) { - ht_sp_free(parser); -} - -static inline void rz_key_parser_add(RzKeyParser *parser, const char *key, int val) { - ht_sp_insert(parser, key, (void *)(size_t)val); -} - -#define RZ_KEY_PARSER_UNKNOWN -1 - -/** - * \brief switch-like macro over RzKeyParser values - * \param parser RzKeyParser * - * \param key const char * - */ -#define RZ_KEY_PARSER_SWITCH(parser, key) \ - bool key_parser_found = false; \ - int key_parser_v = (int)(size_t)ht_sp_find(parser, key, &key_parser_found); \ - if (!key_parser_found) { \ - key_parser_v = RZ_KEY_PARSER_UNKNOWN; \ - } \ - switch (key_parser_v) - -/** - * \brief Iterate over all keys in a json object and call RZ_KEY_PARSER_SWITCH on each - * \param parser RzKeyParser * - * \param json RzJson * - * \param child var name for the `RzJson *child` - * \param body code block with cases - */ -#define RZ_KEY_PARSER_JSON(parser, json, child, body) \ - if (json->type == RZ_JSON_OBJECT) { \ - for (RzJson *child = json->children.first; child; child = child->next) { \ - RZ_KEY_PARSER_SWITCH(parser, child->key) { \ - body \ - } \ - } \ - } - -/** - * \brief Get an sdb sub-namespace or fail - * \param db Sdb * the Sdb from which to take the sub-namespace - * \param subdb Sdb * where to put the sub-namespace - * \param res RzSerializeResult * where to push an error on failure - * \param ns const char * - * \param rip code to execute if the function failed - * - * Example: - * - * Sdb *subdb; - * RZ_SERIALIZE_SUB(db, subdb, res, "files", return false;) - * // do something with subdb - * - */ -#define RZ_SERIALIZE_SUB(db, subdb, res, ns, rip) \ - do { \ - subdb = sdb_ns(db, ns, false); \ - if (!subdb) { \ - RZ_SERIALIZE_ERR(res, "missing " ns " namespace"); \ - rip \ - } \ - } while (0) - -/** - * \brief Get an sdb sub-namespace and evaluate `call` or fail - * \param db Sdb * the Sdb from which to take the sub-namespace - * \param subdb Sdb * where to put the sub-namespace - * \param res RzSerializeResult * where to push an error on failure - * \param ns const char * - * \param call function call - * \param rip code to execute if the function failed - * - * Example: - * - * Sdb *subdb; - * RZ_SERIALIZE_SUB_DO(db, subdb, res, "files", - * rz_serialize_io_files_load(subdb, io, res), return false;) - * - */ -#define RZ_SERIALIZE_SUB_DO(db, subdb, res, ns, call, rip) \ - RZ_SERIALIZE_SUB(db, subdb, res, ns, rip); \ - if (!(call)) { \ - rip \ - } - -#endif // RZ_SERIALIZE_H diff --git a/dest/include/librz/rz_util/rz_set.h b/dest/include/librz/rz_util/rz_set.h deleted file mode 100644 index 9a8a4076390..00000000000 --- a/dest/include/librz/rz_util/rz_set.h +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-FileCopyrightText: pancake -// SPDX-FileCopyrightText: 2024 pelijah -// SPDX-License-Identifier: MIT - -#ifndef RZ_SET_H -#define RZ_SET_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef HtSP RzSetS; - -RZ_API RZ_OWN RzSetS *rz_set_s_new(HtStrOption opt); -RZ_API void rz_set_s_free(RZ_NULLABLE RzSetS *set); -RZ_API void rz_set_s_add(RZ_NONNULL RzSetS *set, const char *str); -RZ_API bool rz_set_s_contains(RZ_NONNULL RzSetS *set, const char *str); -RZ_API void rz_set_s_delete(RZ_NONNULL RzSetS *set, const char *str); -RZ_API ut32 rz_set_s_size(const RZ_NONNULL RzSetS *set); -RZ_API RZ_OWN RzPVector /**/ *rz_set_s_to_vector(RZ_NONNULL RzSetS *set); -RZ_API RzIterator /* */ *rz_set_s_as_iter(const RZ_NONNULL RzSetS *set); - -typedef HtUP RzSetU; - -RZ_API RZ_OWN RzSetU *rz_set_u_new(void); -RZ_API void rz_set_u_free(RZ_NULLABLE RzSetU *set); -RZ_API void rz_set_u_add(RZ_NONNULL RzSetU *set, ut64 u); -RZ_API bool rz_set_u_contains(RZ_NONNULL RzSetU *set, ut64 u); -RZ_API void rz_set_u_delete(RZ_NONNULL RzSetU *set, ut64 u); -RZ_API ut32 rz_set_u_size(const RZ_NONNULL RzSetU *set); -RZ_API RzIterator /* */ *rz_set_u_as_iter(const RZ_NONNULL RzSetU *set); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/rz_signal.h b/dest/include/librz/rz_util/rz_signal.h deleted file mode 100644 index 50a41d589b4..00000000000 --- a/dest/include/librz/rz_util/rz_signal.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef RZ_SIGNAL_H -#define RZ_SIGNAL_H - -#include - -#if __UNIX__ -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Returns atoi(str) if signal with `str` name not found. */ -RZ_API int rz_signal_from_string(const char *str); - -/* Return NULL if signal with `code` not found. */ -RZ_API const char *rz_signal_to_string(int code); - -// XXX this function should be portable, not-unix specific -#if __UNIX__ -RZ_API void rz_signal_sigmask(int how, const sigset_t *newmask, sigset_t *oldmask); -#endif - -#ifdef __cplusplus -} -#endif - -#endif // RZ_SIGNAL_H diff --git a/dest/include/librz/rz_util/rz_spaces.h b/dest/include/librz/rz_util/rz_spaces.h deleted file mode 100644 index be0393cf013..00000000000 --- a/dest/include/librz/rz_util/rz_spaces.h +++ /dev/null @@ -1,120 +0,0 @@ -#ifndef RZ_SPACES_H -#define RZ_SPACES_H - -#define RZ_SPACES_MAX 512 - -#include "rz_util.h" -#include "rz_serialize.h" -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * RzSpaces represents a set of Spaces. - * A Space is used to group similar objects and it can have a name. Name - * "*"/""/NULL is reserved to indicate "all spaces". - * - * You can have groups of "meta" (e.g. bin meta, format meta, etc.), groups of - * flags, etc. - * - * It is possible to hook into the RzSpaces functions by using RzEvent. - * RZ_SPACE_EVENT_COUNT: called when you need to count how many elements there are in a given RzSpace - * RZ_SPACE_EVENT_RENAME: called when renaming a RzSpace with an oldname to a newname - * RZ_SPACE_EVENT_UNSET: called when deleting a RzSpace with a given name - */ - -typedef struct rz_space_t { - char *name; - RBNode rb; -} RzSpace; - -typedef enum { - RZ_SPACE_EVENT_COUNT = 1, - RZ_SPACE_EVENT_RENAME, - RZ_SPACE_EVENT_UNSET, -} RzSpaceEventType; - -typedef struct rz_space_event_t { - union { - struct { - const RzSpace *space; - } count; - struct { - const RzSpace *space; - } unset; - struct { - const RzSpace *space; - const char *oldname; - const char *newname; - } rename; - } data; - int res; -} RzSpaceEvent; - -typedef struct rz_spaces_t { - const char *name; - RzSpace *current; - RBTree spaces; - RzList /**/ *spacestack; - RzEvent *event; -} RzSpaces; - -// Create a new RzSpaces with the given name -RZ_API RzSpaces *rz_spaces_new(const char *name); -// Initialize an existing RzSpaces with the given name -RZ_API bool rz_spaces_init(RzSpaces *sp, const char *name); -// Finalize an existing RzSpaces -RZ_API void rz_spaces_fini(RzSpaces *sp); -// Finalize and free an existing RzSpaces -RZ_API void rz_spaces_free(RzSpaces *sp); -// Delete all spaces -RZ_API void rz_spaces_purge(RzSpaces *sp); -// Get the RzSpace with the given name -RZ_API RzSpace *rz_spaces_get(RzSpaces *sp, const char *name); -// Add a new RzSpace if one does not already exist, otherwise return the existing one -RZ_API RzSpace *rz_spaces_add(RzSpaces *sp, const char *name); -// Add and select a new RzSpace if one does not already exist, otherwise return and select the existing one -RZ_API RzSpace *rz_spaces_set(RzSpaces *sp, const char *name); -// Remove the RzSpace with the given name or all of them if name is NULL -RZ_API bool rz_spaces_unset(RzSpaces *sp, const char *name); -// Change the name of RzSpace with oname to nname -RZ_API bool rz_spaces_rename(RzSpaces *sp, const char *oname, const char *nname); -// Count the elements that belong to the RzSpace with the given name -RZ_API int rz_spaces_count(RzSpaces *sp, const char *name); -// Add/Select the RzSpace with the given name and save the current one in the history -RZ_API bool rz_spaces_push(RzSpaces *sp, const char *name); -// Select the RzSpace that was set before the current one -RZ_API bool rz_spaces_pop(RzSpaces *sp); - -static inline RzSpace *rz_spaces_current(RzSpaces *sp) { - return sp->current; -} - -static inline const char *rz_spaces_current_name(RzSpaces *sp) { - return sp->current ? sp->current->name : "*"; -} - -static inline bool rz_spaces_is_empty(RzSpaces *sp) { - RBIter it = rz_rbtree_first(sp->spaces); - return it.len == 0; -} - -typedef RBIter RzSpaceIter; -#define rz_spaces_foreach(sp, it, s) \ - rz_rbtree_foreach ((sp)->spaces, (it), (s), RzSpace, rb) - -/* serialize */ - -RZ_API void rz_serialize_spaces_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzSpaces *spaces); -/** - * @param load_name whether to overwrite the name in spaces with the value from db - */ -RZ_API bool rz_serialize_spaces_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzSpaces *spaces, bool load_name, RZ_NULLABLE RzSerializeResultInfo *res); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_SPACES_H diff --git a/dest/include/librz/rz_util/rz_stack.h b/dest/include/librz/rz_util/rz_stack.h deleted file mode 100644 index b0c9aab3bcc..00000000000 --- a/dest/include/librz/rz_util/rz_stack.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef RZ_STACK_H -#define RZ_STACK_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*RzStackFree)(void *ptr); - -typedef struct rz_stack_t { - void **elems; - unsigned int n_elems; - int top; - RzStackFree free; -} RzStack; - -RZ_API RzStack *rz_stack_new(ut32 n); -RZ_API void rz_stack_free(RzStack *s); -RZ_API bool rz_stack_is_empty(RzStack *s); -RZ_API RzStack *rz_stack_newf(ut32 n, RzStackFree f); -RZ_API bool rz_stack_push(RzStack *s, void *el); -RZ_API void *rz_stack_pop(RzStack *s); -RZ_API size_t rz_stack_size(RzStack *s); -RZ_API void *rz_stack_peek(RzStack *s); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_STACK_H diff --git a/dest/include/librz/rz_util/rz_str.h b/dest/include/librz/rz_util/rz_str.h deleted file mode 100644 index 4e619cdb738..00000000000 --- a/dest/include/librz/rz_util/rz_str.h +++ /dev/null @@ -1,342 +0,0 @@ -#ifndef RZ_STR_H -#define RZ_STR_H - -#include -#include "rz_assert.h" -#include "rz_str_util.h" -#include "rz_list.h" -#include "rz_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - RZ_STRING_TYPE_RAW, ///< The raw sequence of bytes without any marker of beginning or end - RZ_STRING_TYPE_ZERO, ///< C-style strings (ASCII or UTF-8) with zero as the end marker - RZ_STRING_TYPE_SIZED, ///< Pascal-style strings with the first byte marking the size of the string -} RzStrType; - -/** - * \brief String character encodings. - */ -typedef enum { - /** - * \brief Unknown 8bit encoding but with ASCII from 0 to 0x7f. - * It is also used everywhere like it is ASCII. - */ - RZ_STRING_ENC_8BIT = 'b', - RZ_STRING_ENC_UTF8 = '8', - /** - * \brief Modified UTF-8 from Android: - * https://source.android.com/docs/core/runtime/dex-format#mutf-8 - */ - RZ_STRING_ENC_MUTF8 = 'm', - RZ_STRING_ENC_UTF16LE = 'u', - RZ_STRING_ENC_UTF32LE = 'U', - RZ_STRING_ENC_UTF16BE = 'n', - RZ_STRING_ENC_UTF32BE = 'N', - RZ_STRING_ENC_IBM037 = 'c', - RZ_STRING_ENC_IBM290 = 'd', - RZ_STRING_ENC_EBCDIC_UK = 'k', - RZ_STRING_ENC_EBCDIC_US = 's', - RZ_STRING_ENC_EBCDIC_ES = 't', - RZ_STRING_ENC_GUESS = 'g', - RZ_STRING_ENC_SETTINGS = 'S', ///< Use str.encoding. -} RzStrEnc; - -/** - * \brief Group together some common options used by string escaping functions - */ -typedef struct { - bool show_asciidot; ///< When true, dots `.` are placed instead of unprintable ASCII characters. - bool esc_bslash; ///< When true, backslashes `\` are quoted with `\\` - bool esc_double_quotes; ///< When true, double quotes `"` are quoted with `\"` - bool dot_nl; ///< When true, \n is converted into the graphiz-compatible newline \l - bool keep_printable; ///< Keep all printable characters (excludes \n, \t etc.). -} RzStrEscOptions; - -/** - * \brief Convenience macro for local temporary strings - * \param buf Target buffer, **must** be an array type, not a pointer. - * - * This eases the common pattern where a stack-allocated string of a fixed - * size is created and filled with `snprintf()` to be used as a temporary string. - * - * Example: - * - * char k[32]; - * char v[32]; - * sdb_set(db, rz_strf(k, "key.%d", 42), rz_strf(v, "val.%d", 123)); - */ -#define rz_strf(buf, ...) ( \ - snprintf(buf, sizeof(buf), __VA_ARGS__) < 0 \ - ? rz_assert_log(RZ_LOGLVL_FATAL, "rz_strf error while using snprintf"), \ - NULL \ - : buf) - -typedef int (*RzStrRangeCallback)(void *, int); - -#define RZ_STR_ISEMPTY(x) (!(x) || !*(x)) -#define RZ_STR_ISNOTEMPTY(x) ((x) && *(x)) -#define RZ_STR_DUP(x) ((x) ? strdup((x)) : NULL) -#define RZ_STR_EQ(x, y) (rz_str_cmp((x), (y), -1) == 0) -#define RZ_STR_NE(x, y) (rz_str_cmp((x), (y), -1) != 0) -#define rz_str_array(x, y) ((y >= 0 && y < (sizeof(x) / sizeof(*x))) ? x[y] : "") -RZ_API const char *rz_str_enc_as_string(RzStrEnc enc); -RZ_API RzStrEnc rz_str_enc_string_as_type(RZ_NULLABLE const char *enc); -RZ_API RZ_OWN char *rz_str_repeat(const char *str, ut16 times); -RZ_API RZ_OWN char *rz_str_pad(const char ch, ssize_t len); -RZ_API const char *rz_str_rstr(const char *base, const char *p); -RZ_API const char *rz_strstr_ansi(RZ_NONNULL const char *a, RZ_NONNULL const char *b, bool icase); -RZ_API const char *rz_str_rchr(const char *base, const char *p, int ch); -RZ_API const char *rz_str_closer_chr(const char *b, const char *s); -RZ_API int rz_str_bounds(const char *str, int *h); -RZ_API char *rz_str_crop(const char *str, unsigned int x, unsigned int y, unsigned int x2, unsigned int y2); -RZ_API char *rz_str_scale(const char *r, int w, int h); -RZ_API bool rz_str_range_in(const char *r, ut64 addr); -RZ_API size_t rz_str_utf8_cols(const char *s); -RZ_API size_t rz_str_utf8_num_ucp(RZ_NONNULL const char *str); -RZ_API size_t rz_str_utf8_get_width_utf16(RZ_NONNULL const char *str); -RZ_API size_t rz_str_utf8_ansi_cols(const char *str); -RZ_API size_t rz_str_len_utf8char(const char *s, int left); -RZ_API size_t rz_str_utf8_charsize(const char *str); -RZ_API size_t rz_str_utf8_charsize_prev(const char *str, int prev_len); -RZ_API size_t rz_str_utf8_charsize_last(const char *str); -RZ_API void rz_str_filter_zeroline(char *str, int len); -RZ_API size_t rz_str_utf8_codepoint(const char *s, size_t left); -RZ_API bool rz_str_char_fullwidth(const char *s, size_t left); -RZ_API int rz_str_write(int fd, const char *b); -RZ_API size_t rz_str_ncpy(char *dst, const char *src, size_t n); -RZ_API size_t rz_str_ncat(RZ_NONNULL RZ_OUT char *dst, RZ_NONNULL const char *src, size_t n); -RZ_API void rz_str_sanitize(char *c); -RZ_API char *rz_str_sanitize_sdb_key(const char *s); -RZ_API const char *rz_str_casestr(const char *a, const char *b); -RZ_API const char *rz_str_firstbut(const char *s, char ch, const char *but); -RZ_API const char *rz_str_lastbut(const char *s, char ch, const char *but); -RZ_API size_t rz_str_split(char *str, char ch); -RZ_API RzList /**/ *rz_str_split_list(char *str, const char *c, int n); -RZ_API RZ_OWN RzList /**/ *rz_str_split_list_regex(RZ_NONNULL char *str, RZ_NONNULL const char *r, int n); -RZ_API RzList /**/ *rz_str_split_duplist(const char *str, const char *c, bool trim); -RZ_API RzList /**/ *rz_str_split_duplist_n(const char *str, const char *c, int n, bool trim); -RZ_API RZ_OWN RzList /**/ *rz_str_split_duplist_n_regex(RZ_NONNULL const char *_str, RZ_NONNULL const char *r, int n, bool trim); -RZ_API size_t *rz_str_split_lines(char *str, size_t *count); -RZ_API RZ_OWN char *rz_str_replace(RZ_OWN char *str, const char *key, const char *val, int g); -RZ_API char *rz_str_replace_icase(char *str, const char *key, const char *val, int g, int keep_case); -RZ_API char *rz_str_replace_in(char *str, ut32 sz, const char *key, const char *val, int g); -#define rz_str_cpy(x, y) memmove((x), (y), strlen(y) + 1); -#define rz_str_cat(x, y) memmove((x) + strlen(x), (y), strlen(y) + 1); -RZ_API int rz_str_bits(char *strout, const ut8 *buf, int len, const char *bitz); -RZ_API int rz_str_bits64(char *strout, ut64 in); -RZ_API ut64 rz_str_bits_from_string(const char *buf, const char *bitz); -RZ_API int rz_str_rwx(const char *str); -RZ_API int rz_str_replace_ch(char *s, char a, char b, bool g); -RZ_API int rz_str_replace_char(char *s, int a, int b); -RZ_API int rz_str_replace_char_once(char *s, int a, int b); -RZ_API void rz_str_remove_char(char *str, char c); -RZ_API const char *rz_str_rwx_i(int rwx); -RZ_API int rz_str_fmtargs(const char *fmt); -RZ_API char *rz_str_arg_escape(const char *arg); -RZ_API int rz_str_arg_unescape(char *arg); -RZ_API char **rz_str_argv(const char *str, int *_argc); -RZ_API void rz_str_argv_free(char **argv); -RZ_API int rz_snprintf(char *string, int len, const char *fmt, ...) RZ_PRINTF_CHECK(3, 4); -RZ_API bool rz_str_is_whitespace(RZ_NONNULL const char *str); -RZ_API bool rz_str_is_ascii(const char *str); -RZ_API bool rz_str_is_utf8(RZ_NONNULL const char *str); -RZ_API char *rz_str_nextword(char *s, char ch); -RZ_API bool rz_str_is_printable(const char *str); -RZ_API bool rz_str_is_printable_limited(RZ_NONNULL const char *str, size_t size); -RZ_API bool rz_str_is_printable_incl_newlines(const char *str); -RZ_API char *rz_str_appendlen(char *ptr, const char *string, int slen); -RZ_API char *rz_str_newf(const char *fmt, ...) RZ_PRINTF_CHECK(1, 2); -RZ_API char *rz_str_newlen(const char *str, int len); -RZ_API const char *rz_str_sysbits(const int v); -RZ_API char *rz_str_trunc_ellipsis(const char *str, int len); -RZ_API const char *rz_str_bool(int b); -RZ_API bool rz_str_is_true(const char *s); -RZ_API bool rz_str_is_false(RZ_NULLABLE const char *s); -RZ_API bool rz_str_is_bool(const char *val); -RZ_API const char *rz_str_ansi_chrn(const char *str, size_t n); -RZ_API size_t rz_str_ansi_len(const char *str); -RZ_API size_t rz_str_ansi_nlen(const char *str, size_t len); -RZ_API int rz_str_ansi_trim(char *str, int str_len, int n); -RZ_API int rz_str_ansi_filter(char *str, char **out, int **cposs, int len); -RZ_API char *rz_str_ansi_crop(const char *str, unsigned int x, unsigned int y, unsigned int x2, unsigned int y2); -RZ_API int rz_str_word_count(const char *string); -RZ_API int rz_str_char_count(const char *string, char ch); -RZ_API char *rz_str_word_get0set(char *stra, int stralen, int idx, const char *newstr, int *newlen); -RZ_API int rz_str_word_set0(char *str); -RZ_API int rz_str_word_set0_stack(char *str); -static inline const char *rz_str_word_get_next0(const char *str) { - return str + strlen(str) + 1; -} -RZ_API const char *rz_str_word_get0(const char *str, int idx); -RZ_API RZ_OWN char *rz_str_skip_separator_chars(RZ_NONNULL const char *string); -RZ_API void rz_str_trim(RZ_NONNULL RZ_INOUT char *str); -RZ_API void rz_str_trim_char(RZ_NONNULL RZ_INOUT char *str, const char c); -RZ_API char *rz_str_trim_dup(const char *str); -RZ_API char *rz_str_trim_lines(char *str); -RZ_API void rz_str_trim_head(RZ_NONNULL RZ_INOUT char *str); -RZ_API void rz_str_trim_head_char(RZ_NONNULL RZ_INOUT char *str, const char c); -RZ_API const char *rz_str_trim_head_ro(RZ_NONNULL const char *str); -RZ_API const char *rz_str_trim_head_wp(RZ_NONNULL const char *str); -RZ_API RZ_INOUT char *rz_str_trim_tail(RZ_NONNULL RZ_INOUT char *str); -RZ_API void rz_str_trim_tail_char(RZ_NONNULL RZ_INOUT char *str, const char c); -RZ_API ut64 rz_str_djb2_hash(const char *str); -RZ_API char *rz_str_trim_nc(char *str); -RZ_API bool rz_str_is2utf8(RZ_NONNULL const char *c); -RZ_API bool rz_str_is3utf8(RZ_NONNULL const char *c); -RZ_API bool rz_str_is4utf8(RZ_NONNULL const char *c); -RZ_API bool rz_str_isXutf8(RZ_NONNULL const char *c, ut8 x); -RZ_API const char *rz_str_strchr(RZ_NONNULL const char *str, RZ_NONNULL const char *c); -RZ_API const char *rz_str_nstr(const char *from, const char *to, int size); -RZ_API const char *rz_str_case_nstr(RZ_NONNULL const char *from, RZ_NONNULL const char *to, int size); -RZ_API const char *rz_str_lchr(const char *str, char chr); -RZ_API const char *rz_sub_str_lchr(RZ_NONNULL const char *str, int start, int end, char chr); -RZ_API const char *rz_sub_str_rchr(RZ_NONNULL const char *str, int start, int end, char chr); -RZ_API RZ_OWN char *rz_sub_str_ptr(RZ_NONNULL const char *str, RZ_NONNULL const char *start, RZ_NONNULL const char *end); -RZ_API char *rz_str_ichr(char *str, char chr); -RZ_API bool rz_str_ccmp(const char *dst, const char *orig, int ch); -RZ_API bool rz_str_cmp_list(const char *list, const char *item, char sep); -RZ_API int rz_str_cmp(RZ_NULLABLE const char *dst, RZ_NULLABLE const char *orig, int len); -RZ_API int rz_str_casecmp(const char *dst, const char *orig); -RZ_API int rz_str_ncasecmp(const char *dst, const char *orig, size_t n); -RZ_API int rz_str_ccpy(char *dst, char *orig, int ch); -static inline const char *rz_str_get(const char *str) { - return str ? str : ""; -} -static inline const char *rz_str_get_null(const char *str) { - return str ? str : "(null)"; -} -RZ_API char *rz_str_ndup(RZ_NULLABLE const char *ptr, int len); -RZ_API RZ_OWN char *rz_str_dup(RZ_NULLABLE const char *str); -RZ_API int rz_str_delta(char *p, char a, char b); -RZ_API void rz_str_filter(char *str); -RZ_API const char *rz_str_tok(const char *str1, const char b, size_t len); -RZ_API const char *rz_str_str_xy(const char *s, const char *word, const char *prev, int *x, int *y); - -typedef void (*str_operation)(char *c); - -RZ_API int rz_str_do_until_token(str_operation op, char *str, const char tok); - -RZ_API void rz_str_reverse(char *str); -RZ_API int rz_str_path_unescape(char *path); -RZ_API char *rz_str_path_escape(const char *path); -RZ_API int rz_str_unescape(char *buf); -RZ_DEPRECATE RZ_API RZ_OWN char *rz_str_escape(RZ_NONNULL const char *buf); -RZ_API char *rz_str_escape_sh(const char *buf); -RZ_API bool rz_str_escape_code_point(ut32 /* RzCodePoint */ cp, size_t ch_bytes, RZ_NONNULL const RzStrEscOptions *opts); -RZ_DEPRECATE RZ_API char *rz_str_escape_dot(const char *buf); -RZ_DEPRECATE RZ_API char *rz_str_escape_8bit(const char *buf, bool colors, RzStrEscOptions *opt); -RZ_API RZ_OWN char *rz_str_escape_utf8(RZ_NONNULL const char *buf, RZ_NONNULL const RzStrEscOptions *opt); -RZ_API RZ_OWN char *rz_str_escape_utf16le(RZ_NONNULL const char *buf, size_t buf_size, RZ_NONNULL const RzStrEscOptions *opt); -RZ_API RZ_OWN char *rz_str_escape_utf32le(RZ_NONNULL const char *buf, size_t buf_size, RZ_NONNULL const RzStrEscOptions *opt); -RZ_API RZ_OWN char *rz_str_escape_utf16be(RZ_NONNULL const char *buf, size_t buf_size, RZ_NONNULL const RzStrEscOptions *opt); -RZ_API RZ_OWN char *rz_str_escape_utf32be(RZ_NONNULL const char *buf, size_t buf_size, RZ_NONNULL const RzStrEscOptions *opt); -RZ_API RZ_OWN char *rz_str_format_msvc_argv(size_t argc, const char **argv); -RZ_API void rz_str_uri_decode(char *buf); -RZ_API char *rz_str_uri_encode(const char *buf); -RZ_API char *rz_str_utf16_decode(const ut8 *s, int len); -RZ_DEPRECATE RZ_API char *rz_str_utf16_encode(const char *s, int len); -RZ_API RZ_OWN ut16 *rz_str_utf8_to_utf16(RZ_NONNULL const char *utf8_str, bool big_endian); -RZ_API RZ_OWN ut32 *rz_str_utf8_to_utf32(RZ_NONNULL const char *utf8_str, bool big_endian); -RZ_API char *rz_str_escape_utf8_for_json(const char *s, int len); -RZ_API char *rz_str_escape_mutf8_for_json(const char *s, int len); -RZ_API char *rz_str_home(const char *str); -RZ_API size_t rz_str_nlen(const char *s, size_t n); -RZ_API size_t rz_str_nlen_w(const char *s, int n); -RZ_API size_t rz_wstr_clen(const char *s); -RZ_API char *rz_str_prepend(char *ptr, const char *string); -RZ_API char *rz_str_prefix_all(const char *s, const char *pfx); -RZ_API RZ_OWN char *rz_str_append(RZ_OWN RZ_NULLABLE char *ptr, const char *string); -RZ_API char *rz_str_append_owned(char *ptr, char *string); -RZ_API RZ_OWN char *rz_str_appendf(RZ_OWN RZ_NULLABLE char *ptr, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); -RZ_API char *rz_str_appendch(char *x, char y); -RZ_API void rz_str_case(char *str, bool up); -RZ_API void rz_str_trim_path(char *s); -RZ_API ut8 rz_str_contains_macro(const char *input_value); -RZ_API void rz_str_truncate_cmd(char *string); -RZ_API char *rz_str_replace_thunked(char *str, char *clean, int *thunk, int clen, - const char *key, const char *val, int g); -RZ_API bool rz_str_glob(const char *str, const char *glob); -RZ_API int rz_str_binstr2bin(const char *str, ut8 *out, int outlen); -RZ_API char *rz_str_between(const char *str, const char *prefix, const char *suffix); -RZ_API bool rz_str_startswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle); -RZ_API bool rz_str_startswith_icase(RZ_NONNULL const char *str, RZ_NONNULL const char *needle); -RZ_API bool rz_str_endswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle); -RZ_API bool rz_str_endswith_icase(RZ_NONNULL const char *str, RZ_NONNULL const char *needle); -RZ_API bool rz_str_isnumber(const char *str); -RZ_API const char *rz_str_last(const char *in, const char *ch); -RZ_API char *rz_str_highlight(char *str, const char *word, const char *color, const char *color_reset); -RZ_API char *rz_str_from_ut64(ut64 val); -RZ_API char *rz_str_list_join(RzList /**/ *str, const char *sep); -RZ_API char *rz_str_array_join(const char **a, size_t n, const char *sep); -RZ_API RzList /**/ *rz_str_wrap(char *str, size_t width); - -RZ_API const char *rz_str_sep(const char *base, const char *sep); -RZ_API const char *rz_str_rsep(const char *base, const char *p, const char *sep); - -typedef struct rz_str_stringify_opt_t { - const ut8 *buffer; ///< String buffer (cannot be NULL). - ut32 length; ///< String buffer length. - RzStrEnc encoding; ///< String encoding type (cannot be RZ_STRING_ENC_GUESS) - ut32 wrap_at; ///< Adds a new line the output when it exceeds this value. - bool escape_nl; ///< When enabled escapes new lines (\n). - bool json; ///< Encodes the output as a JSON string. - bool stop_at_nil; ///< When enabled stops printing when '\0' is found. - bool stop_at_unprintable; ///< When enabled stops printing at first non-printable character. - bool urlencode; ///< Encodes the output following RFC 3986. -} RzStrStringifyOpt; - -RZ_API RzStrEnc rz_str_guess_encoding_from_buffer(RZ_NONNULL const ut8 *buffer, ut32 length); -RZ_API RZ_OWN char *rz_str_stringify_raw_buffer(RzStrStringifyOpt *option, RZ_NULLABLE RZ_OUT ut32 *length); - -RZ_API const char *rz_str_indent(int indent); - -/** - * \brief Returns true if the given encoding has the same byte character width as UTF-8. - * This is only true for UTF-8 and ASCII. - * - * Examples: - * - * ```c - * // IBM290 character width is always one byte, but the equivalent Japanese - * // characters in UTF-8 are 3 bytes. - * assert(rz_string_enc_same_char_width_as_utf8(RZ_STR_ENC_IBM290) == false); - * - * // ASCII character width is always one byte, and the equivalent - * // UTF-8 characters are also always 1 byte. - * assert(rz_string_enc_same_char_width_as_utf8(RZ_STR_ENC_8BIT) == true); - * ``` - */ -static inline bool rz_string_enc_same_char_width_as_utf8(RzStrEnc enc) { - return enc == RZ_STRING_ENC_UTF8 || enc == RZ_STRING_ENC_8BIT; -} - -RZ_API bool rz_string_enc_is_utf(RzStrEnc enc); -RZ_API bool rz_string_enc_is_utf_native_endian(RzStrEnc enc); -RZ_API size_t rz_string_enc_code_point_width(RzStrEnc enc); -RZ_API bool rz_string_enc_requires_scanning(RzStrEnc enc); - -static inline bool rz_string_code_points_align(RzStrEnc enc, size_t memory_alignment) { - rz_return_val_if_fail(memory_alignment, false); - if (rz_string_enc_code_point_width(enc) == memory_alignment) { - return true; - } - switch (enc) { - case RZ_STRING_ENC_SETTINGS: - rz_warn_if_reached(); - return false; - case RZ_STRING_ENC_GUESS: - return false; - default: - return memory_alignment % rz_string_enc_code_point_width(enc) == 0; - } -} - -#ifdef __cplusplus -} -#endif - -#endif // RZ_STR_H diff --git a/dest/include/librz/rz_util/rz_str_constpool.h b/dest/include/librz/rz_util/rz_str_constpool.h deleted file mode 100644 index 68dfee3361a..00000000000 --- a/dest/include/librz/rz_util/rz_str_constpool.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef RZ_STR_CONSTPOOL_H -#define RZ_STR_CONSTPOOL_H - -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * RzStrConstPool is a pool of constant strings. - * References to strings will be valid as long as the RzStrConstPool is alive. - */ - -typedef struct rz_str_constpool_t { - HtSP *ht; -} RzStrConstPool; - -RZ_API bool rz_str_constpool_init(RzStrConstPool *pool); -RZ_API void rz_str_constpool_fini(RzStrConstPool *pool); -RZ_API const char *rz_str_constpool_get(RzStrConstPool *pool, const char *str); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_STR_CONSTPOOL_H diff --git a/dest/include/librz/rz_util/rz_str_search.h b/dest/include/librz/rz_util/rz_str_search.h deleted file mode 100644 index 59c5ba79b07..00000000000 --- a/dest/include/librz/rz_util/rz_str_search.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef RZ_STR_SEARCH_H -#define RZ_STR_SEARCH_H - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Represent a detected string. - */ -typedef struct { - char *string; ///< The detected string. Note that this one is always in UTF-8. No matter what the ecoding is in memory. - RzRegexMulti *regex; ///< Regex matching the string. If set, the string member is the pattern. - ut64 addr; ///< Address/offset of the string in the RzBuffer - ut32 size; ///< Size of buffer containing the string in bytes - ut32 length; ///< Length of string in chars - RzStrEnc encoding; ///< String encoding in memory. - size_t alignment; ///< The address alignment a matched string must have. If search.align is set, both must match. - /** - * \brief Maps UTF-8 code point offsets to their memory offset. - * This is necessary if the string's character width in memory doesn't match UTF-8 character width. - * E.g. the in memory string is IBM270 (Japanese) and has a character width of 1 bytes. - * But the decoded string above is always UTF-8 and has a character width of 1-4 bytes. - * - * It is NULL if the string encoding in memory is UTF-8 or ASCII. - */ - ut64 *byte_mem_map; -} RzDetectedString; - -/** - * Defines the search parameters for rz_scan_strings - */ -typedef struct { - size_t max_str_length; ///< Maximum size of a detected string. - size_t min_str_length; ///< Minimum string length - bool prefer_big_endian; ///< True if the preferred endianess for UTF strings is big-endian - bool check_ascii_freq; ///< If true, perform check on ASCII frequencies when looking for false positives -} RzUtilStrScanOptions; - -RZ_API void rz_detected_string_free(RzDetectedString *str); - -RZ_API bool rz_scan_strings_single_raw(RZ_NONNULL const ut8 *buf, ut64 size, RZ_NONNULL const RzUtilStrScanOptions *opt, RzStrEnc type, RZ_NONNULL RzDetectedString **output); -RZ_API int rz_scan_strings_raw(RZ_NONNULL const ut8 *buf, RZ_NONNULL RzList /**/ *list, RZ_NONNULL const RzUtilStrScanOptions *opt, - const ut64 from, const ut64 to, RzStrEnc type); -RZ_API int rz_scan_strings(RZ_NONNULL RzBuffer *buf_to_scan, RZ_NONNULL RzList /**/ *list, RZ_NONNULL const RzUtilStrScanOptions *opt, - const ut64 from, const ut64 to, RzStrEnc type); -RZ_API int rz_scan_strings_whole_buf(RZ_NONNULL const RzBuffer *buf_to_scan, RZ_NONNULL RzList /**/ *list, RZ_NONNULL const RzUtilStrScanOptions *opt, RzStrEnc type); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_STR_SEARCH_H diff --git a/dest/include/librz/rz_util/rz_str_util.h b/dest/include/librz/rz_util/rz_str_util.h deleted file mode 100644 index b9c3276e092..00000000000 --- a/dest/include/librz/rz_util/rz_str_util.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef RZ_STR_UTIL_H -#define RZ_STR_UTIL_H - -#define IS_NULLSTR(x) (!(x) || !*(x)) -#define IS_WHITECHAR(x) ((x) == ' ' || (x) == '\t' || (x) == '\n' || (x) == '\r') -#define IS_SEPARATOR(x) ((x) == ' ' || (x) == '\t' || (x) == '\n' || (x) == '\r' || (x) == ' ' || \ - (x) == ',' || (x) == ';' || (x) == ':' || (x) == '[' || (x) == ']' || \ - (x) == '(' || (x) == ')' || (x) == '{' || (x) == '}') -#define IS_HEXCHAR(x) (((x) >= '0' && (x) <= '9') || ((x) >= 'a' && (x) <= 'f') || ((x) >= 'A' && (x) <= 'F')) -#define IS_PRINTABLE(x) ((x) >= ' ' && (x) <= '~') -#define IS_DIGIT(x) ((x) >= '0' && (x) <= '9') -#define IS_OCTAL(x) ((x) >= '0' && (x) <= '7') -#define IS_WHITESPACE(x) ((x) == ' ' || (x) == '\t') -#define IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z') -#define IS_LOWER(c) ((c) >= 'a' && (c) <= 'z') -#define IS_ALPHANUM(c) (IS_DIGIT(c) || IS_UPPER(c) || IS_LOWER(c)) - -#endif // RZ_STR_UTIL_H diff --git a/dest/include/librz/rz_util/rz_strbuf.h b/dest/include/librz/rz_util/rz_strbuf.h deleted file mode 100644 index 3e208d2d2f6..00000000000 --- a/dest/include/librz/rz_util/rz_strbuf.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef RZ_STRBUF_H -#define RZ_STRBUF_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - char buf[32]; - size_t len; // string length in chars or binary buffer size - char *ptr; // ptr replacing buf in case strlen > sizeof(buf) - size_t ptrlen; // string length + 1 or binary buffer size -} RzStrBuf; - -#define RZ_STRBUF_SAFEGET(sb) (rz_strbuf_get(sb) ? rz_strbuf_get(sb) : "") -RZ_API RzStrBuf *rz_strbuf_new(const char *s); -RZ_API const char *rz_strbuf_set(RzStrBuf *sb, const char *s); // return = the string or NULL on fail -RZ_API bool rz_strbuf_slice(RZ_NONNULL RzStrBuf *sb, size_t from, size_t len); -RZ_API bool rz_strbuf_setbin(RzStrBuf *sb, const ut8 *s, size_t len); -RZ_API ut8 *rz_strbuf_getbin(RzStrBuf *sb, size_t *len); -RZ_API const char *rz_strbuf_setf(RzStrBuf *sb, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); // return = the string or NULL on fail -RZ_API const char *rz_strbuf_vsetf(RzStrBuf *sb, const char *fmt, va_list ap); // return = the string or NULL on fail -RZ_API bool rz_strbuf_append(RzStrBuf *sb, const char *s); -RZ_API bool rz_strbuf_append_n(RzStrBuf *sb, const char *s, size_t l); -RZ_API bool rz_strbuf_prepend(RzStrBuf *sb, const char *s); -RZ_API bool rz_strbuf_appendf(RzStrBuf *sb, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3); -RZ_API bool rz_strbuf_vappendf(RzStrBuf *sb, const char *fmt, va_list ap); -RZ_API char *rz_strbuf_get(RzStrBuf *sb); -RZ_API RZ_OWN char *rz_strbuf_drain(RZ_OWN RZ_NONNULL RzStrBuf *sb); -RZ_API RZ_OWN char *rz_strbuf_drain_nofree(RzStrBuf *sb); -RZ_API size_t rz_strbuf_length(RzStrBuf *sb); -RZ_API void rz_strbuf_free(RzStrBuf *sb); -RZ_API void rz_strbuf_fini(RzStrBuf *sb); -RZ_API void rz_strbuf_init(RzStrBuf *sb); -RZ_API const char *rz_strbuf_initf(RzStrBuf *sb, const char *fmt, ...); // same as init + setf for convenience -RZ_API bool rz_strbuf_copy(RzStrBuf *dst, RzStrBuf *src); -RZ_API bool rz_strbuf_equals(RzStrBuf *sa, RzStrBuf *sb); -RZ_API bool rz_strbuf_reserve(RzStrBuf *sb, size_t len); -RZ_API bool rz_strbuf_is_empty(RzStrBuf *sb); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_STRBUF_H diff --git a/dest/include/librz/rz_util/rz_strpool.h b/dest/include/librz/rz_util/rz_strpool.h deleted file mode 100644 index 4f80ca2f182..00000000000 --- a/dest/include/librz/rz_util/rz_strpool.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef RZ_STRPOOL_H -#define RZ_STRPOOL_H - -#include - -#define RZ_STRPOOL_INC 1024 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - char *str; - int len; - int size; -} RzStrpool; - -RZ_API RzStrpool *rz_strpool_new(int sz); -RZ_API char *rz_strpool_alloc(RzStrpool *p, int l); -RZ_API int rz_strpool_memcat(RzStrpool *p, const char *s, int len); -RZ_API int rz_strpool_ansi_chop(RzStrpool *p, int n); -RZ_API int rz_strpool_append(RzStrpool *p, const char *s); -RZ_API void rz_strpool_free(RzStrpool *p); -RZ_API int rz_strpool_fit(RzStrpool *p); -RZ_API char *rz_strpool_get(RzStrpool *p, int index); -RZ_API char *rz_strpool_get_i(RzStrpool *p, int index); -RZ_API int rz_strpool_get_index(RzStrpool *p, const char *s); -RZ_API char *rz_strpool_next(RzStrpool *p, int index); -RZ_API char *rz_strpool_slice(RzStrpool *p, int index); -RZ_API char *rz_strpool_empty(RzStrpool *p); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_STRPOOL_H diff --git a/dest/include/librz/rz_util/rz_structured_data.h b/dest/include/librz/rz_util/rz_structured_data.h deleted file mode 100644 index 0aadf997418..00000000000 --- a/dest/include/librz/rz_util/rz_structured_data.h +++ /dev/null @@ -1,74 +0,0 @@ -// SPDX-FileCopyrightText: 2025 deroad -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_STRUCTURED_DATA_H -#define RZ_STRUCTURED_DATA_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum rz_structured_data_block_t { - RZ_STRUCTURED_DATA_BLOCK_MAP = 0, - RZ_STRUCTURED_DATA_BLOCK_ARRAY = 1, -} RzStructuredDataBlock; - -typedef struct rz_structured_data_t RzStructuredData; - -typedef void (*RzStructuredDataIteratorNew)(RZ_NULLABLE void *user, RzStructuredDataBlock block, size_t n_elems); -typedef void (*RzStructuredDataIteratorEnd)(RZ_NULLABLE void *user); -typedef void (*RzStructuredDataIteratorKey)(RZ_NULLABLE void *user, RZ_NONNULL const char *key); -typedef void (*RzStructuredDataIteratorValueUnsigned)(RZ_NULLABLE void *user, ut64 n, bool hex); -typedef void (*RzStructuredDataIteratorValueSigned)(RZ_NULLABLE void *user, st64 n); -typedef void (*RzStructuredDataIteratorValueDouble)(RZ_NULLABLE void *user, double d); -typedef void (*RzStructuredDataIteratorValueBool)(RZ_NULLABLE void *user, bool b); -typedef void (*RzStructuredDataIteratorValueString)(RZ_NULLABLE void *user, RZ_NONNULL const char *v); - -typedef struct rz_structured_data_iterator_t { - RzStructuredDataIteratorNew new_struct; ///< Creates a new structure - RzStructuredDataIteratorEnd end_struct; ///< Ends the current structure - RzStructuredDataIteratorKey key; ///< Defines a key, called before a enter() or value_*() - RzStructuredDataIteratorValueUnsigned val_unsigned; ///< Inserts a value of numeric unsigned type - RzStructuredDataIteratorValueSigned val_signed; ///< Inserts a value of numeric signed type - RzStructuredDataIteratorValueDouble val_double; ///< Inserts a value of numeric double type - RzStructuredDataIteratorValueBool val_bool; ///< Inserts a value of boolean type - RzStructuredDataIteratorValueString val_string; ///< Inserts a value of string type -} RzStructuredDataIterator; - -RZ_API RZ_OWN RzStructuredData *rz_structured_data_new_map(); -RZ_API RZ_OWN RzStructuredData *rz_structured_data_new_array(); -RZ_API void rz_structured_data_free(RZ_NULLABLE RzStructuredData *sd); - -/* primitive types for maps */ -RZ_API RZ_BORROW RzStructuredData *rz_structured_data_map_add_map(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key); -RZ_API RZ_BORROW RzStructuredData *rz_structured_data_map_add_array(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key); -RZ_API bool rz_structured_data_map_add(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key, RZ_NONNULL RZ_OWN RzStructuredData *child); -RZ_API bool rz_structured_data_map_add_unsigned(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key, ut64 n, bool hex); -RZ_API bool rz_structured_data_map_add_signed(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key, st64 n); -RZ_API bool rz_structured_data_map_add_double(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key, double d); -RZ_API bool rz_structured_data_map_add_boolean(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key, bool b); -RZ_API bool rz_structured_data_map_add_string(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *key, RZ_NONNULL const char *v); - -/* primitive types for arrays */ -RZ_API RZ_BORROW RzStructuredData *rz_structured_data_array_add_map(RZ_NONNULL RzStructuredData *parent); -RZ_API RZ_BORROW RzStructuredData *rz_structured_data_array_add_array(RZ_NONNULL RzStructuredData *parent); -RZ_API bool rz_structured_data_array_add(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL RZ_OWN RzStructuredData *child); -RZ_API bool rz_structured_data_array_add_unsigned(RZ_NONNULL RzStructuredData *parent, ut64 n, bool hex); -RZ_API bool rz_structured_data_array_add_signed(RZ_NONNULL RzStructuredData *parent, st64 n); -RZ_API bool rz_structured_data_array_add_double(RZ_NONNULL RzStructuredData *parent, double d); -RZ_API bool rz_structured_data_array_add_boolean(RZ_NONNULL RzStructuredData *parent, bool b); -RZ_API bool rz_structured_data_array_add_string(RZ_NONNULL RzStructuredData *parent, RZ_NONNULL const char *v); - -RZ_API void rz_structured_data_iterate(RZ_NONNULL const RzStructuredData *sd, RZ_NONNULL const RzStructuredDataIterator *iterator, RZ_NULLABLE void *user); -RZ_API void rz_structured_data_to_pj(RZ_NONNULL const RzStructuredData *sd, RZ_NONNULL PJ *pj); -RZ_API RZ_OWN char *rz_structured_data_to_json(RZ_NONNULL const RzStructuredData *sd); -RZ_API RZ_OWN char *rz_structured_data_to_yaml(RZ_NONNULL const RzStructuredData *sd); - -#ifdef __cplusplus -} -#endif - -#endif /* RZ_STRUCTURED_DATA_H */ diff --git a/dest/include/librz/rz_util/rz_subprocess.h b/dest/include/librz/rz_util/rz_subprocess.h deleted file mode 100644 index 74b1232354a..00000000000 --- a/dest/include/librz/rz_util/rz_subprocess.h +++ /dev/null @@ -1,124 +0,0 @@ -// SPDX-FileCopyrightText: Florian Märkl , Riccardo Schirone -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_UTIL_SUBPROCESS_H -#define RZ_UTIL_SUBPROCESS_H - -#include -#include - -/** - * Enum used to determine how pipes should be created, if at all, in the - * subprocess. - */ -typedef enum rz_subprocess_pipe_create_t { - ///< No pipe should be created. It can be used for stdin, stdout and stderr. - RZ_SUBPROCESS_PIPE_NONE, - ///< A new pipe should be created. It can be used for stdin, stdout and stderr. - RZ_SUBPROCESS_PIPE_CREATE, - ///< A new PTY should be created. It can be used for stdin, stdout and stderr. - RZ_SUBPROCESS_PIPE_PTY, - ///< Re-use the same pipe/PTY as stdout. It can be used for stderr only. - RZ_SUBPROCESS_PIPE_STDOUT, -} RzSubprocessPipeCreate; - -/** - * Values passed to rz_subprocess API to mention stdin, stdout, stderr or a combination of those - */ -#define RZ_SUBPROCESS_STDIN (1 << 0) -#define RZ_SUBPROCESS_STDOUT (1 << 1) -#define RZ_SUBPROCESS_STDERR (1 << 2) - -typedef enum rz_process_wait_reason_t { - RZ_SUBPROCESS_DEAD, - RZ_SUBPROCESS_TIMEDOUT, - RZ_SUBPROCESS_BYTESREAD, -} RzSubprocessWaitReason; - -typedef enum rz_subprocess_fork_mode_t { - RZ_SUBPROCESS_FORK, - RZ_SUBPROCESS_FORKPTY, -} RzSubprocessForkMode; - -/** - * Provide results from running a sub-process, like output, return value, etc. - */ -typedef struct rz_process_output_t { - ///< Output generated by the process - ut8 *out; - ///< Number of bytes in the \p out field - int out_len; - ///< Error generated by the process - ut8 *err; - ///< Number of bytes in the \p err field - int err_len; - ///< Return value (exit code) of the sub-process - int ret; - ///< True if the process has exited because of a timeout - bool timeout; -} RzSubprocessOutput; - -typedef struct rz_pty_t { - int master_fd; - int slave_fd; - char *name; -} RzPty; - -/** - * Specify how the new subprocess should be created. - */ -typedef struct rz_subprocess_opt_t { - ///< Name of the executable to run. It is searched also in PATH - const char *file; - ///< Arguments to pass to the subprocess. These are just the arguments and do not include the program name (aka argv[0]) - const char **args; - ///< Number of arguments in \p args array - size_t args_size; - ///< Names of environment variables that subprocess should have differently from parent - const char **envvars; - ///< Values of environment variables that subprocess should have differently from parent - const char **envvals; - ///< Number of elements contained in both \p envvars and \p envvals - size_t env_size; - ///< Specify how to deal with subprocess stdin - RzSubprocessPipeCreate stdin_pipe; - ///< Specify how to deal with subprocess stdout - RzSubprocessPipeCreate stdout_pipe; - ///< Specify how to deal with subprocess stderr - RzSubprocessPipeCreate stderr_pipe; - - /* Both the following fields only matter when using PTY in the pipe options */ - ///< Provide the PTY to use (if NULL, then a new one will be created, if required) - ///< No need to close the PTY once it has been used, you can free it directly - RzPty *pty; - ///< Use raw mode for the created PTY (disable echo, control characters, etc.) - ///< If you don't know what to put here, put true here. - bool make_raw; -} RzSubprocessOpt; - -typedef struct rz_subprocess_t RzSubprocess; - -RZ_API bool rz_subprocess_init(void); -RZ_API void rz_subprocess_fini(void); -RZ_API RzSubprocess *rz_subprocess_start( - const char *file, const char *args[], size_t args_size, - const char *envvars[], const char *envvals[], size_t env_size); -RZ_API RZ_OWN RzSubprocess *rz_subprocess_start_opt(RZ_NONNULL const RzSubprocessOpt *opt); -RZ_API void rz_subprocess_free(RzSubprocess *proc); -RZ_API RzSubprocessWaitReason rz_subprocess_wait(RzSubprocess *proc, ut64 timeout_ms); -RZ_API void rz_subprocess_kill(RzSubprocess *proc); -RZ_API int rz_subprocess_ret(RzSubprocess *proc); -RZ_API ut8 *rz_subprocess_out(RzSubprocess *proc, int *length); -RZ_API ut8 *rz_subprocess_err(RzSubprocess *proc, int *length); -RZ_API ssize_t rz_subprocess_stdin_write(RzSubprocess *proc, const ut8 *buf, size_t buf_size); -RZ_API RzStrBuf *rz_subprocess_stdout_read(RzSubprocess *proc, size_t n, ut64 timeout_ms); -RZ_API RZ_BORROW RzStrBuf *rz_subprocess_stdout_readline(RzSubprocess *proc, ut64 timeout_ms); -RZ_API RzSubprocessOutput *rz_subprocess_drain(RzSubprocess *proc); -RZ_API void rz_subprocess_output_free(RzSubprocessOutput *out); - -RZ_API RZ_OWN RzPty *rz_subprocess_openpty(RZ_BORROW RZ_NULLABLE char *slave_name, RZ_NULLABLE void /* const struct termios */ *term_params, RZ_NULLABLE void /* const struct winsize */ *win_params); -RZ_API void rz_subprocess_close_pty(RZ_BORROW RZ_NONNULL const RzPty *pty); -RZ_API bool rz_subprocess_login_tty(RZ_BORROW RZ_NONNULL const RzPty *pty); -RZ_API void rz_subprocess_pty_free(RZ_OWN RzPty *pty); - -#endif // RZ_UTIL_SUBPROCESS_H diff --git a/dest/include/librz/rz_util/rz_sys.h b/dest/include/librz/rz_util/rz_sys.h deleted file mode 100644 index f5a35ce6bc0..00000000000 --- a/dest/include/librz/rz_util/rz_sys.h +++ /dev/null @@ -1,213 +0,0 @@ -#ifndef RZ_SYS_H -#define RZ_SYS_H - -#include -#include - -#if __WINDOWS__ -#define RZ_SYS_DEVNULL "nul" -#else -#define RZ_SYS_DEVNULL "/dev/null" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - RZ_SYS_BITS_8 = 1, - RZ_SYS_BITS_16 = 2, - RZ_SYS_BITS_32 = 4, - RZ_SYS_BITS_64 = 8, -}; - -typedef struct { - char *sysname; - char *nodename; - char *release; - char *version; - char *machine; -} RSysInfo; - -RZ_API RSysInfo *rz_sys_info(void); -RZ_API void rz_sys_info_free(RSysInfo *si); - -RZ_API int rz_sys_sigaction(int *sig, void (*handler)(int)); -RZ_API int rz_sys_signal(int sig, void (*handler)(int)); -RZ_API void rz_sys_env_init(void); -RZ_API char **rz_sys_get_environ(void); -RZ_API void rz_sys_set_environ(char **e); - -RZ_API int rz_sys_fork(void); -RZ_API int rz_sys_kill(int pid, int sig); -// nocleanup = false => exit(); true => _exit() -RZ_API void rz_sys_exit(int status, bool nocleanup); - -/* openpty family of functions */ -RZ_API /* pid_t */ int rz_sys_forkpty(int *amaster, char *name, void /* const struct termios */ *termp, void /* const struct winsize */ *winp); -RZ_API int rz_sys_openpty(int *amaster, int *aslave, char *name, void /* const struct termios */ *termp, void /* const struct winsize */ *winp); -RZ_API int rz_sys_login_tty(int fd); - -RZ_API bool rz_is_heap(void *p); -RZ_API bool rz_sys_stop(void); -RZ_API char *rz_sys_pid_to_path(int pid); -RZ_API int rz_sys_run(const ut8 *buf, int len); -RZ_API int rz_sys_run_rop(const ut8 *buf, int len); -RZ_API int rz_sys_getpid(void); -#if !HAVE_PIPE || (__UNIX__ && HAVE_PIPE) -RZ_API int rz_sys_pipe(int pipefd[2], bool close_on_exec); -RZ_API int rz_sys_pipe_close(int fd); -#else -#define rz_sys_pipe pipe -#define rz_sys_pipe_close close -#endif -#if !HAVE_EXECV || (__UNIX__ && HAVE_EXECV && HAVE_PIPE && !HAVE_PIPE2) -RZ_API int rz_sys_execv(RZ_NONNULL const char *pathname, RZ_NONNULL char *const argv[]); -#else -#define rz_sys_execv execv -#endif -#if !HAVE_EXECVE || (__UNIX__ && HAVE_EXECVE && HAVE_PIPE && !HAVE_PIPE2) -RZ_API int rz_sys_execve(const char *pathname, char *const argv[], char *const envp[]); -#else -#define rz_sys_execve execve -#endif -#if !HAVE_EXECVP || (__UNIX__ && HAVE_EXECVP && HAVE_PIPE && !HAVE_PIPE2) -RZ_API int rz_sys_execvp(const char *file, char *const argv[]); -#else -#define rz_sys_execvp execvp -#endif -#if !HAVE_EXECL || (__UNIX__ && HAVE_EXECL && HAVE_PIPE && !HAVE_PIPE2) -RZ_API int rz_sys_execl(const char *pathname, const char *arg, ...); -#else -#define rz_sys_execl execl -#endif -#if !HAVE_SYSTEM || (__UNIX__ && HAVE_SYSTEM && HAVE_PIPE && !HAVE_PIPE2) -RZ_API int rz_sys_system(const char *command); -#else -#define rz_sys_system system -#endif -#define rz_sys_xsystem(cmd) RZ_V_NOT(rz_sys_system(cmd), -1) - -RZ_API const char *rz_sys_arch_str(int arch); -RZ_API int rz_sys_arch_id(const char *arch); -RZ_API bool rz_sys_arch_match(const char *archstr, const char *arch); -RZ_API RzList /**/ *rz_sys_dir(const char *path); -RZ_API void rz_sys_perror_str(const char *fun); -#define rz_sys_mkdir_failed() (errno != EEXIST) -RZ_API bool rz_sys_mkdir(const char *dir); -RZ_API bool rz_sys_mkdirp(const char *dir); -RZ_API int rz_sys_sleep(int secs); -RZ_API int rz_sys_usleep(int usecs); -RZ_API char *rz_sys_getenv(const char *key); -RZ_API bool rz_sys_getenv_asbool(const char *key); -RZ_API int rz_sys_setenv(const char *key, const char *value); -RZ_API int rz_sys_clearenv(void); -RZ_API char *rz_sys_whoami(char *buf); -RZ_API char *rz_sys_getdir(void); -RZ_API bool rz_sys_chdir(RZ_NONNULL const char *s); -RZ_API bool rz_sys_aslr(bool enable); -RZ_API void *rz_sys_dlopen(RZ_NULLABLE const char *libname); -RZ_API void *rz_sys_dlsym(void *handler, const char *name); -RZ_API int rz_sys_dlclose(void *handler); -RZ_API int rz_sys_cmd_str_full(const char *cmd, const char *input, char **output, int *len, char **sterr); -#if __WINDOWS__ -#if UNICODE -#define W32_TCHAR_FSTR "%S" -#define W32_TCALL(name) name "W" -#define rz_sys_conv_utf8_to_win(buf) rz_utf8_to_utf16(buf) -#define rz_sys_conv_utf8_to_win_l(buf, len) rz_utf8_to_utf16_l(buf, len) -#define rz_sys_conv_win_to_utf8(buf) rz_utf16_to_utf8(buf) -#define rz_sys_conv_win_to_utf8_l(buf, len) rz_utf16_to_utf8_l((wchar_t *)buf, len) -#else -#define W32_TCHAR_FSTR "%s" -#define W32_TCALL(name) name "A" -#define rz_sys_conv_utf8_to_win(buf) rz_utf8_to_acp(buf) -#define rz_sys_conv_utf8_to_win_l(buf, len) rz_utf8_to_acp_l(buf, len) -#define rz_sys_conv_win_to_utf8(buf) rz_acp_to_utf8(buf) -#define rz_sys_conv_win_to_utf8_l(buf, len) rz_acp_to_utf8_l(buf, len) -#endif -typedef void *HANDLE; -RZ_API char *rz_sys_get_src_dir_w32(void); -RZ_API bool rz_sys_create_child_proc_w32(const char *cmdline, HANDLE in, HANDLE out, HANDLE err); -RZ_API char **rz_sys_utf8_argv_new(int argc, const wchar_t **argv); -RZ_API void rz_sys_utf8_argv_free(int argc, char **utf8_argv); -#endif -RZ_API int rz_sys_open_perms(int rizin_perms); -RZ_API int rz_sys_open(const char *path, int perm, int mode); -RZ_API FILE *rz_sys_fopen(const char *path, const char *mode); -RZ_API int rz_sys_truncate_fd(int fd, ut64 length); -RZ_API int rz_sys_truncate(const char *file, int sz); -RZ_API int rz_sys_cmdf(const char *fmt, ...) RZ_PRINTF_CHECK(1, 2); -RZ_API char *rz_sys_cmd_str(const char *cmd, const char *input, int *len); -RZ_API char *rz_sys_cmd_strf(const char *cmd, ...) RZ_PRINTF_CHECK(1, 2); -// #define rz_sys_cmd_str(cmd, input, len) rz_sys_cmd_str_full(cmd, input, len, 0) -RZ_API void rz_sys_backtrace(void); - -#ifndef __has_builtin -#define __has_builtin(n) (0) -#endif - -#if __has_builtin(__builtin_debugtrap) -#define rz_sys_breakpoint() __builtin_debugtrap() -#endif - -#ifndef rz_sys_breakpoint -#if __WINDOWS__ -#define rz_sys_breakpoint() \ - { \ - __debugbreak(); \ - } -#else -#if __GNUC__ -#define rz_sys_breakpoint() __builtin_trap() -#elif __i386__ || __x86_64__ -#define rz_sys_breakpoint() __asm__ volatile("int3"); -#elif __arm64__ || __aarch64__ -#define rz_sys_breakpoint() __asm__ volatile("brk 0"); -// #define rz_sys_breakpoint() __asm__ volatile ("brk #1"); -#elif (__arm__ || __thumb__) -#if __ARM_ARCH > 5 -#define rz_sys_breakpoint() __asm__ volatile("bkpt $0"); -#else -#define rz_sys_breakpoint() __asm__ volatile("svc $1"); -#endif -#elif __mips__ -#define rz_sys_breakpoint() __asm__ volatile("break"); -// # define rz_sys_breakpoint() __asm__ volatile ("teq $0, $0"); -#elif __EMSCRIPTEN__ -// TODO: cannot find a better way to breakpoint in wasm/asm.js -#define rz_sys_breakpoint() \ - { \ - char *a = NULL; \ - *a = 0; \ - } -#else -#warning rz_sys_breakpoint not implemented for this platform -#define rz_sys_trap() __asm__ __volatile__(".word 0"); -#define rz_sys_breakpoint() \ - { \ - char *a = NULL; \ - *a = 0; \ - } -#endif -#endif -#endif - -/* syscmd */ -RZ_API RZ_OWN char *rz_syscmd_cat(RZ_NONNULL const char *file); -RZ_API RZ_OWN char *rz_syscmd_mkdir(RZ_NONNULL const char *dir); -RZ_API RZ_OWN char *rz_syscmd_uniq(RZ_NONNULL const char *file); -RZ_API RZ_OWN char *rz_syscmd_head(RZ_NONNULL const char *file, int count); -RZ_API RZ_OWN char *rz_syscmd_tail(RZ_NONNULL const char *file, int count); -RZ_API RZ_OWN char *rz_syscmd_join(RZ_NONNULL const char *file1, RZ_NONNULL const char *file2); -RZ_API RZ_OWN char *rz_syscmd_sort(RZ_NONNULL const char *file); -RZ_API RZ_OWN char *rz_syscmd_sort_pipe(RZ_NULLABLE const char *input, int *length); -RZ_API RZ_OWN char *rz_syscmd_uniq_pipe(RZ_NULLABLE const char *input, int *length); -RZ_API RZ_OWN char *rz_syscmd_sort_str(RZ_NONNULL const char *input); -RZ_API RZ_OWN char *rz_syscmd_uniq_str(RZ_NONNULL const char *input); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_SYS_H diff --git a/dest/include/librz/rz_util/rz_table.h b/dest/include/librz/rz_util/rz_table.h deleted file mode 100644 index b8821145cfd..00000000000 --- a/dest/include/librz/rz_util/rz_table.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef RZ_UTIL_TABLE_H -#define RZ_UTIL_TABLE_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - RZ_TABLE_ALIGN_LEFT = 0, - RZ_TABLE_ALIGN_RIGHT, - RZ_TABLE_ALIGN_CENTER, - // size - RZ_TABLE_ALIGN_ENUM_MAX, -} RzTableAlign; - -typedef enum { - RZ_TABLE_COLUMN_TYPE_STRING = 0, - RZ_TABLE_COLUMN_TYPE_NUMBER, - RZ_TABLE_COLUMN_TYPE_BOOL, - // size - RZ_TABLE_COLUMN_TYPE_ENUM_MAX, -} RzTableColumnType; - -typedef int (*RzTableColumnTypeComparator)(const void *a, const void *b); - -typedef struct { - char *name; ///< Column name - RzTableColumnType type; ///< Inferred type of the data - RzTableColumnTypeComparator type_cmp; ///< Column comparator used for sorting - RzTableAlign align; ///< Column alignment left, right, center - int width; ///< Computed column width - int total; ///< Sum of the rows associated to this column. -} RzTableColumn; - -typedef struct { - RzPVector /**/ *items; -} RzTableRow; - -typedef void (*RzTableSelector)(RzTableRow *acc, RzTableRow *new_row, size_t nth); -typedef const char *(*RzTableColorSelector)(const char *value, const char *column, const size_t column_n, const RzTableColumnType type, void *user); - -typedef enum { - RZ_TABLE_CHAR_MODE_ASCII = 0, - RZ_TABLE_CHAR_MODE_UTF8, - RZ_TABLE_CHAR_MODE_UTF8_CURVY, - // size - RZ_TABLE_CHAR_MODE_ENUM_MAX, -} RzTableCharMode; - -typedef struct { - RzVector /**/ *rows; ///< Rows data - RzVector /**/ *cols; ///< Columns data - size_t totalCols; ///< Total number of columns - bool showHeader; ///< When true, upon call of rz_table_tostring, it will show the header - bool showFancy; ///< When true, upon call of rz_table_tostring, it will use the fancy table output - bool showJSON; ///< When true, upon call of rz_table_tostring, it will return a json structure - bool showCSV; ///< When true, upon call of rz_table_tostring, it will return a csv structure - bool showSum; ///< When true, upon call of rz_table_tostring, it will show the toal sum of each row - RzTableCharMode char_mode; ///< Sets the charset type used for the string output - RzTableColorSelector color; ///< It is used to retrieve a color palette to use in each column data. - void *color_user; ///< Additional data that is passed via RzTableColorSelector() -} RzTable; - -RZ_API RZ_OWN RzTable *rz_table_new(void); -RZ_API void rz_table_free(RZ_NULLABLE RzTable *t); -RZ_API void rz_table_add_column(RZ_NONNULL RzTable *t, const RzTableColumnType type, RZ_NONNULL const char *name); -RZ_API void rz_table_set_columnsf(RZ_NONNULL RzTable *t, RZ_NONNULL const char *fmt, ...); -RZ_API void rz_table_set_vcolumnsf(RZ_NONNULL RzTable *t, RZ_NONNULL const char *fmt, va_list ap); -RZ_API void rz_table_add_row(RZ_NONNULL RzTable *t, RZ_NONNULL const char *name, ...); -RZ_API void rz_table_add_vrowf(RZ_NONNULL RzTable *t, RZ_NONNULL const char *fmt, va_list ap); -RZ_API void rz_table_add_rowf(RZ_NONNULL RzTable *t, RZ_NONNULL const char *fmt, ...); -RZ_API void rz_table_add_row_columnsf(RZ_NONNULL RzTable *t, RZ_NONNULL const char *fmt, ...); -RZ_API void rz_table_add_row_vec(RZ_NONNULL RzTable *t, RZ_NONNULL RZ_OWN RzPVector /**/ *items); -RZ_API RZ_OWN char *rz_table_tofancystring(RZ_NONNULL RzTable *t); -RZ_API RZ_OWN char *rz_table_tosimplestring(RZ_NONNULL RzTable *t); -RZ_API RZ_OWN char *rz_table_tostring(RZ_NONNULL RzTable *t); -RZ_API RZ_OWN char *rz_table_tocsv(RZ_NONNULL RzTable *t); -RZ_API RZ_OWN char *rz_table_tojson(RZ_NONNULL RzTable *t); -RZ_API void rz_table_sort(RZ_NONNULL RzTable *t, size_t nth, bool reverse); -RZ_API void rz_table_sortlen(RZ_NONNULL RzTable *t, size_t nth, bool reverse); -RZ_API void rz_table_uniq(RZ_NONNULL RzTable *t); -RZ_API void rz_table_group(RZ_NONNULL RzTable *t, size_t nth, RZ_NULLABLE RzTableSelector selector); -RZ_API bool rz_table_query(RZ_NONNULL RzTable *t, RZ_NULLABLE const char *q); -RZ_API bool rz_table_align(RZ_NONNULL RzTable *t, size_t nth, RzTableAlign align); -RZ_API RZ_OWN RzTable *rz_table_transpose(RZ_NONNULL RzTable *t); -RZ_API void rz_table_columns_select(RZ_NONNULL RzTable *t, RZ_NONNULL RzList /**/ *col_names); -RZ_API void rz_table_show_header(RZ_NONNULL RzTable *t, bool show_header); -RZ_API void rz_table_set_char_mode(RZ_NONNULL RzTable *t, RzTableCharMode mode); -RZ_API void rz_table_set_color_selector(RZ_NONNULL RzTable *t, RZ_NULLABLE RzTableColorSelector color_cb, void *user); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/rz_th_ht.h b/dest/include/librz/rz_util/rz_th_ht.h deleted file mode 100644 index 23eed7aa55f..00000000000 --- a/dest/include/librz/rz_util/rz_th_ht.h +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-FileCopyrightText: 2023 RizinOrg -// SPDX-FileCopyrightText: 2023 deroad -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_TH_HASH_TABLE_H -#define RZ_TH_HASH_TABLE_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef RZ_API - -#define rz_th_ht_header(name, type, ktype, vtype) \ - typedef struct rz_th_##name##_t RzThread##type; \ - RZ_API void rz_th_##name##_free(RzThread##type *ht); \ - RZ_API RzThread##type *rz_th_##name##_new(type *table); \ - RZ_API bool rz_th_##name##_insert(RzThread##type *ht, const ktype key, vtype value); \ - RZ_API bool rz_th_##name##_update(RzThread##type *ht, const ktype key, vtype value); \ - RZ_API bool rz_th_##name##_delete(RzThread##type *ht, const ktype key); \ - RZ_API vtype rz_th_##name##_find(RzThread##type *ht, const ktype key, bool *found); \ - RZ_API type *rz_th_##name##_move(RzThread##type *ht); \ - RZ_API void rz_th_##name##_foreach(RzThread##type *ht, type##ForeachCallback cb, void *user) - -rz_th_ht_header(ht_pp, HtPP, void *, void *); -rz_th_ht_header(ht_up, HtUP, ut64, void *); -rz_th_ht_header(ht_uu, HtUU, ut64, ut64); -rz_th_ht_header(ht_pu, HtPU, void *, ut64); -rz_th_ht_header(ht_sp, HtSP, char *, void *); -rz_th_ht_header(ht_ss, HtSS, char *, char *); -rz_th_ht_header(ht_su, HtSU, char *, ut64); - -#endif /* RZ_API */ - -#ifdef __cplusplus -} -#endif - -#endif /* RZ_TH_HASH_TABLE_H */ diff --git a/dest/include/librz/rz_util/rz_time.h b/dest/include/librz/rz_util/rz_time.h deleted file mode 100644 index 6cf57fae673..00000000000 --- a/dest/include/librz/rz_util/rz_time.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef RZ_TIME_H -#define RZ_TIME_H - -#include -#include - -#define RZ_NSEC_PER_SEC 1000000000ULL -#define RZ_NSEC_PER_MSEC 1000000ULL -#define RZ_USEC_PER_SEC 1000000ULL -#define RZ_NSEC_PER_USEC 1000ULL -#define RZ_USEC_PER_MSEC 1000ULL - -#define ASCTIME_BUF_MINLEN 26 - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _MSC_VER -struct timeval; -#endif - -RZ_API int rz_time_gettimeofday(struct timeval *p); - -// wall clock time in microseconds -RZ_API ut64 rz_time_now(void); - -// monotonic time in microseconds -RZ_API ut64 rz_time_now_mono(void); - -RZ_API RZ_OWN char *rz_time_stamp_to_str(ut32 timestamp); -RZ_API ut32 rz_time_dos_time_stamp_to_posix(ut32 timestamp); -RZ_API bool rz_time_stamp_is_dos_format(const ut32 certainPosixTimeStamp, const ut32 possiblePosixOrDosTimeStamp); -RZ_API RZ_OWN char *rz_time_date_dos_to_string(ut32 timestamp); -RZ_API RZ_OWN char *rz_time_date_hfs_to_string(ut32 timestamp); -RZ_API RZ_OWN char *rz_time_date_w32_to_string(ut64 timestamp); -#define rz_time_date_unix_to_string rz_time_stamp_to_str -RZ_API RZ_OWN char *rz_time_date_now_to_string(void); - -// Thread-safe cross platform wrappers -RZ_API char *rz_asctime_r(RZ_NONNULL const struct tm *tm, RZ_NONNULL char *buf); -RZ_API char *rz_ctime_r(RZ_NONNULL const time_t *timer, RZ_NONNULL char *buf); -RZ_API struct tm *rz_localtime_r(RZ_NONNULL const time_t *time, RZ_NONNULL struct tm *res); -RZ_API struct tm *rz_gmtime_r(RZ_NONNULL const time_t *time, RZ_NONNULL struct tm *res); - -#define RZ_TIME_PROFILE_ENABLED 0 - -#if RZ_TIME_PROFILE_ENABLED -#define RZ_TIME_PROFILE_BEGIN ut64 __now__ = rz_time_now_mono() -#define RZ_TIME_PROFILE_END eprintf("%s %" PFMT64d "\n", __FUNCTION__, rz_time_now_mono() - __now__) -#else -#define RZ_TIME_PROFILE_BEGIN \ - do { \ - } while (0) -#define RZ_TIME_PROFILE_END \ - do { \ - } while (0) -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_util/rz_tree.h b/dest/include/librz/rz_util/rz_tree.h deleted file mode 100644 index 105c9ffb919..00000000000 --- a/dest/include/librz/rz_util/rz_tree.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef RZ_TREE_H -#define RZ_TREE_H -#include - -struct rz_tree_t; - -typedef struct rz_tree_node_t { - struct rz_tree_node_t *parent; - struct rz_tree_t *tree; - RzList /**/ *children; - unsigned int n_children; - int depth; - RzListFree free; - void *data; -} RTreeNode; - -typedef struct rz_tree_t { - RTreeNode *root; -} RTree; - -typedef struct rz_tree_visitor_t { - void (*pre_visit)(RTreeNode *, struct rz_tree_visitor_t *); - void (*post_visit)(RTreeNode *, struct rz_tree_visitor_t *); - void (*discover_child)(RTreeNode *, struct rz_tree_visitor_t *); - void *data; -} RTreeVisitor; -typedef void (*RTreeNodeVisitCb)(RTreeNode *n, RTreeVisitor *vis); - -RZ_API RTree *rz_tree_new(void); -RZ_API RTreeNode *rz_tree_add_node(RTree *t, RTreeNode *node, void *child_data); -RZ_API void rz_tree_reset(RTree *t); -RZ_API void rz_tree_free(RTree *t); -RZ_API void rz_tree_dfs(RTree *t, RTreeVisitor *vis); -RZ_API void rz_tree_bfs(RTree *t, RTreeVisitor *vis); -#endif // RZ_TREE_H diff --git a/dest/include/librz/rz_util/rz_uleb128.h b/dest/include/librz/rz_util/rz_uleb128.h deleted file mode 100644 index 71f137c62f9..00000000000 --- a/dest/include/librz/rz_util/rz_uleb128.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef RZ_ULEB128_H -#define RZ_ULEB128_H - -#include - -// LEB128 or Little Endian Base 128 is a form of variable-length code -// compression used to store an arbitrarily large integer in a small number of -// bytes. LEB128 is used in the DWARF debug file format. - -RZ_API const ut8 *rz_uleb128(const ut8 *data, int datalen, RZ_NULLABLE ut64 *v, const char **error); -RZ_API const ut8 *rz_uleb128_decode(const ut8 *data, int *datalen, ut64 *v); -RZ_API int rz_uleb128_len(const ut8 *data, int size); -RZ_API ut8 *rz_uleb128_encode(const ut64 s, int *len); -RZ_API const ut8 *rz_leb128(const ut8 *data, int datalen, st64 *v); -RZ_API st64 rz_sleb128(const ut8 **data, const ut8 *end); -RZ_API size_t read_u32_leb128(const ut8 *p, const ut8 *max, ut32 *out_val); -RZ_API size_t read_i32_leb128(const ut8 *p, const ut8 *max, st32 *out_val); -RZ_API size_t read_u64_leb128(const ut8 *p, const ut8 *max, ut64 *out_val); -RZ_API size_t read_i64_leb128(const ut8 *p, const ut8 *max, st64 *out_val); -#endif // RZ_ULEB128_H diff --git a/dest/include/librz/rz_util/rz_unicode.h b/dest/include/librz/rz_util/rz_unicode.h deleted file mode 100644 index a1361af2374..00000000000 --- a/dest/include/librz/rz_util/rz_unicode.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef RZ_UNICODE_H -#define RZ_UNICODE_H - -#include -#include "rz_str.h" - -#define RZ_UNICODE_NUL 0 -#define RZ_UNICODE_MAX_BYTES_PER_CHAR 4 -#define RZ_UNICODE_VERSION_MAJOR 16 -#define RZ_UNICODE_VERSION_MINOR 0 -#define RZ_UNICODE_VERSION_PATCH 0 -#define RZ_UNICODE_LAST_ASCII 0x7F -#define RZ_UNICODE_FIRST_1BYTE_CODE_POINT 0x0 -#define RZ_UNICODE_FIRST_2BYTE_CODE_POINT 0x80 -#define RZ_UNICODE_FIRST_3BYTE_CODE_POINT 0x0800 -#define RZ_UNICODE_FIRST_4BYTE_CODE_POINT 0x010000 -#define RZ_UNICODE_LAST_CODE_POINT 0x10ffff -/** - * \brief String width of "\U00hhhhhh" - */ -#define RZ_UNICODE_ESCAPED_STR_WIDTH 10 - -struct rz_unicode_range_name_entry_t { - ut32 from; - ut32 to; - const char *name; -}; - -typedef struct rz_unicode_range_name_entry_t RzUnicodeRangeNameTable[]; - -struct rz_unicode_range_entry_t { - ut32 from; - ut32 to; -}; - -typedef struct rz_unicode_range_entry_t RzUnicodeRangeTable[]; - -/** - * \brief An Unicode code point. - * - * NOTE: Be careful when assigning char values to it. On some platforms - * they might get sign extended and the code point is an invalid value. - */ -typedef ut32 RzCodePoint; - -RZ_API bool rz_unicode_code_point_is_printable(const RzCodePoint c); -RZ_API bool rz_unicode_code_point_is_defined(const RzCodePoint c); -RZ_API bool rz_unicode_code_point_is_legal_decode(const RzCodePoint c); -RZ_API bool rz_unicode_code_point_is_control(const RzCodePoint c); -RZ_API bool rz_unicode_code_point_is_surrogate(const RzCodePoint c); -RZ_API bool rz_unicode_code_point_is_private(const RzCodePoint c); -RZ_API bool rz_unicode_code_point_is_format(const RzCodePoint c); -RZ_API RzStrEnc rz_unicode_bom_encoding(const ut8 *ptr, size_t ptrlen); -RZ_API void rz_unicode_code_point_escape(RzCodePoint code_point, RZ_NONNULL RZ_OUT char **dst, RZ_NONNULL const RzStrEscOptions *opt); -RZ_API void rz_unicode_byte_escape(char ch, RZ_NONNULL RZ_OUT char **dst, RZ_NONNULL const RzStrEscOptions *opt); - -#endif // RZ_UNICODE_H diff --git a/dest/include/librz/rz_util/rz_utf16.h b/dest/include/librz/rz_util/rz_utf16.h deleted file mode 100644 index 350203cd728..00000000000 --- a/dest/include/librz/rz_util/rz_utf16.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef RZ_UTF16_H -#define RZ_UTF16_H - -/* For RzCodePoint definition */ -#include "rz_utf8.h" - -/** - * \brief First Unicode code point which needs 4 bytes to be encoded. - */ -#define RZ_UTF16_FIRST_4BYTES_CODE_POINT 0x10000 -/** - * \brief Width of an UTF16 character in bytes. - */ -#define RZ_UTF16_CODE_POINT_WIDTH 2 - -RZ_API size_t rz_utf16_decode(RZ_NONNULL const ut8 *buf, size_t buf_len, RZ_NULLABLE RZ_OUT RzCodePoint *ch, bool check_is_def, bool bigendian); -RZ_API size_t rz_utf16le_decode(RZ_NONNULL const ut8 *buf, size_t buf_len, RZ_NULLABLE RZ_OUT RzCodePoint *ch, bool check_is_def); -RZ_API size_t rz_utf16be_decode(RZ_NONNULL const ut8 *buf, size_t buf_len, RZ_NULLABLE RZ_OUT RzCodePoint *ch, bool check_is_def); -RZ_API size_t rz_utf16_encode(RZ_NONNULL RZ_OUT ut8 *buf, RzCodePoint ch, bool big_endian); -RZ_API bool rz_utf16_is_printable_code_point(RZ_NONNULL const ut8 *buf, size_t buf_len, bool big_endian, size_t lookahead); -RZ_API RZ_OWN ut8 *rz_str_utf16_to_utf8(RZ_NONNULL const ut8 *src, size_t len_src, bool little_endian); - -#endif // RZ_UTF16_H diff --git a/dest/include/librz/rz_util/rz_utf32.h b/dest/include/librz/rz_util/rz_utf32.h deleted file mode 100644 index aea1ada602e..00000000000 --- a/dest/include/librz/rz_util/rz_utf32.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef RZ_UTF32_H -#define RZ_UTF32_H - -/* For RzCodePoint definition */ -#include "rz_utf8.h" - -/** - * \brief Unicode byte order markings (BOM) - * according to https://www.unicode.org/faq/utf_bom.html#BOM - */ -#define RZ_UTF32_UNICODE_BOM_LE 0xFFFE0000 -#define RZ_UTF32_UNICODE_BOM_BE 0x0000FFFE - -/** - * \brief Width of an UTF32 character in bytes. - */ -#define RZ_UTF32_WIDTH_CHAR 4 -#define RZ_UTF32_CODE_POINT_WIDTH 4 - -RZ_API size_t rz_utf32_decode(RZ_NONNULL const ut8 *buf, size_t buf_len, RZ_NULLABLE RZ_OUT RzCodePoint *ch, bool check_is_def, bool big_endian); -RZ_API int rz_utf32le_decode(const ut8 *ptr, int ptrlen, RZ_NULLABLE RZ_OUT RzCodePoint *ch, bool check_validity); -RZ_API int rz_utf32be_decode(const ut8 *ptr, int ptrlen, RZ_NULLABLE RZ_OUT RzCodePoint *ch, bool check_validity); -RZ_API size_t rz_utf32_encode(RZ_NONNULL RZ_OUT ut8 *buf, RzCodePoint ch, bool big_endian); -RZ_API bool rz_utf32_valid_code_point(RZ_NONNULL const ut8 *buf, size_t buf_len, bool big_endian, size_t lookahead); -RZ_API RZ_OWN ut8 *rz_str_utf32_to_utf8(RZ_NONNULL const ut8 *src, size_t len_src, bool little_endian); - -#endif // RZ_UTF32_H diff --git a/dest/include/librz/rz_util/rz_utf8.h b/dest/include/librz/rz_util/rz_utf8.h deleted file mode 100644 index f764c1e3f93..00000000000 --- a/dest/include/librz/rz_util/rz_utf8.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef RZ_UTF8_H -#define RZ_UTF8_H - -/* For RzStrEnc definition */ -#include "rz_unicode.h" - -/** - * \brief Width of an UTF32 character in bytes. - */ -#define RZ_UTF8_CODE_POINT_WIDTH 1 - -/** - * \brief An Unicode code point. - */ -RZ_API size_t rz_utf8_encode(RZ_OUT RZ_NONNULL ut8 *ptr, const RzCodePoint ch); -RZ_API size_t rz_utf8_decode(RZ_NONNULL const ut8 *buf, size_t buf_len, RZ_NULLABLE RZ_OUT RzCodePoint *cp, bool check_is_def); -RZ_API int rz_mutf8_decode(const ut8 *ptr, int ptrlen, RzCodePoint *ch); -RZ_API int rz_utf8_encode_str(const RzCodePoint *str, ut8 *dst, const int dst_length); -RZ_API int rz_utf8_size(const ut8 *ptr); -RZ_API size_t rz_utf8_strlen(const ut8 *str); -RZ_API const char *rz_utf_block_name(int idx); -RZ_API int rz_utf_block_idx(RzCodePoint ch); -RZ_API int *rz_utf_block_list(const ut8 *str, int len, int **freq_list); -#if __WINDOWS__ -#define rz_utf16_to_utf8(wc) rz_utf16_to_utf8_l((wchar_t *)wc, -1) -#define rz_utf8_to_utf16(cstring) rz_utf8_to_utf16_l((char *)cstring, -1) -RZ_API char *rz_utf16_to_utf8_l(const wchar_t *wc, int len); -RZ_API wchar_t *rz_utf8_to_utf16_l(const char *cstring, int len); -RZ_API char *rz_acp_to_utf8_l(const char *str, int len); -RZ_API char *rz_utf8_to_acp_l(const char *str, int len); -#define rz_acp_to_utf8(str) rz_acp_to_utf8_l((char *)str, -1) -#define rz_utf8_to_acp(cstring) rz_utf8_to_acp_l((char *)cstring, -1) -#endif // __WINDOWS__ - -#endif // RZ_UTF8_H diff --git a/dest/include/librz/rz_util/rz_version.h b/dest/include/librz/rz_util/rz_version.h deleted file mode 100644 index f99e50643b6..00000000000 --- a/dest/include/librz/rz_util/rz_version.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef RZ_VERSION_H -#define RZ_VERSION_H - -#include "rz_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -RZ_API RZ_OWN char *rz_version_gittip(RZ_BORROW RZ_NONNULL RzPath *sys_path); -RZ_API RZ_OWN char *rz_version_str(RZ_BORROW RZ_NONNULL RzPath *sys_path, RZ_NULLABLE const char *program); - -#ifdef __cplusplus -} -#endif - -#endif // RZ_VERSION_H diff --git a/dest/include/librz/rz_util/rz_x509.h b/dest/include/librz/rz_util/rz_x509.h deleted file mode 100644 index 03fcd402a74..00000000000 --- a/dest/include/librz/rz_util/rz_x509.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef RZ_X509_H -#define RZ_X509_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Following RFC 5280 - */ - -typedef struct rz_x509_validity_t { - RzASN1String *notBefore; - RzASN1String *notAfter; -} RzX509Validity; - -typedef struct rz_x509_name_t { - ut32 length; - RzASN1String **oids; - RzASN1String **names; -} RzX509Name; - -typedef struct rz_x509_algorithmidentifier_t { - RzASN1String *algorithm; // OBJECT IDENTIFIER - RzASN1Binary *parameters; // OPTIONAL -} RzX509AlgorithmIdentifier; - -typedef struct rz_x509_authoritykeyidentifier_t { - RzASN1Binary *keyIdentifier; - RzX509Name authorityCertIssuer; - RzASN1Binary *authorityCertSerialNumber; -} RzX509AuthorityKeyIdentifier; - -typedef struct rz_x509_subjectpublickeyinfo_t { - RzX509AlgorithmIdentifier algorithm; - // This is a bit string, but it encapsulate mod + pubkey - RzASN1Binary *subjectPublicKey; // BIT STRING - // Extracted module and exponent from pubkey - RzASN1Binary *subjectPublicKeyExponent; - RzASN1Binary *subjectPublicKeyModule; -} RzX509SubjectPublicKeyInfo; - -typedef struct rz_x509_extension_t { - RzASN1String *extnID; // OBJECT IDENTIFIER - bool critical; - RzASN1Binary *extnValue; // OCTET STRING -} RzX509Extension; - -typedef struct rz_x509_extensions_t { - ut32 length; - RzX509Extension **extensions; -} RzX509Extensions; - -typedef struct rz_x509_tbscertificate_t { - ut32 version; // INTEGER - RzASN1String *serialNumber; // INTEGER - RzX509AlgorithmIdentifier signature; - RzX509Name issuer; - RzX509Validity validity; - RzX509Name subject; - RzX509SubjectPublicKeyInfo subjectPublicKeyInfo; - RzASN1Binary *issuerUniqueID; // BIT STRING - RzASN1Binary *subjectUniqueID; // BIT STRING - RzX509Extensions extensions; -} RzX509TBSCertificate; - -typedef struct rz_x509_certificate_t { - RzX509TBSCertificate tbsCertificate; - RzX509AlgorithmIdentifier algorithmIdentifier; - RzASN1Binary *signature; // BIT STRING -} RzX509Certificate; - -// RFC 1422 - -typedef struct rz_x509_crlentry { - RzASN1Binary *userCertificate; // INTEGER ? - RzASN1String *revocationDate; // UTCTime -} RzX509CRLEntry; - -typedef struct rz_x509_certificaterevocationlist { - RzX509AlgorithmIdentifier signature; - RzX509Name issuer; - RzASN1String *lastUpdate; // UTCTime - RzASN1String *nextUpdate; // UTCTime - ut32 length; - RzX509CRLEntry **revokedCertificates; -} RzX509CertificateRevocationList; - -RZ_API RZ_OWN RzX509CertificateRevocationList *rz_x509_crl_parse(RZ_NULLABLE RzASN1Object *object); -RZ_API RZ_OWN RzStructuredData *rz_x509_crl_to_structure(RZ_NULLABLE RzX509CertificateRevocationList *crl); - -RZ_API RZ_OWN RzX509Certificate *rz_x509_certificate_parse(RZ_NULLABLE RzASN1Object *object); -RZ_API RZ_OWN RzX509Certificate *rz_x509_certificate_parse2(RZ_NULLABLE const ut8 *buffer, ut32 length); -RZ_API void rz_x509_certificate_free(RZ_NULLABLE RzX509Certificate *certificate); -RZ_API RZ_OWN RzStructuredData *rz_x509_certificate_to_structure(RZ_NULLABLE RzX509Certificate *certificate); - -#ifdef __cplusplus -} -#endif - -#endif /* RZ_X509_H */ diff --git a/dest/include/librz/rz_vector.h b/dest/include/librz/rz_vector.h deleted file mode 100644 index 704595e3367..00000000000 --- a/dest/include/librz/rz_vector.h +++ /dev/null @@ -1,491 +0,0 @@ -#ifndef RZ_VECTOR_H -#define RZ_VECTOR_H - -#include -#include -#ifdef __cplusplus -extern "C" { -#endif - -/* - * RzVector can contain arbitrarily sized elements. - * RzPVector uses RzVector internally and always contains void *s - * - * Thus, for storing pointers it is highly encouraged to always use RzPVector - * as it is specifically made for this purpose and is more consistent with RzList, - * while RzVector can be used as, for example, a flat array of a struct. - * - * Notable differences between RzVector and RzPVector: - * ------------------------------------------------- - * When RzVector expects an element to be inserted, for example in rz_vector_push(..., void *x), - * this void * value is interpreted as a pointer to the actual data for the element. - * => If you use RzVector as a dynamic replacement for (struct SomeStruct)[], you will - * pass a struct SomeStruct * to these functions. - * - * Because RzPVector only handles pointers, the given void * is directly interpreted as the - * actual pointer to be inserted. - * => If you use RzPVector as a dynamic replacement for (SomeType *)[], you will pass - * SomeType * directly to these functions. - * - * The same differentiation goes for the free functions: - * - The element parameter in RzVectorFree is a pointer to the element inside the array. - * - The element parameter in RzPVectorFree is the actual pointer stored in the array. - * - * General Hint: - * ------------- - * remove/pop functions do not reduce the capacity. - * Call rz_(p)vector_shrink explicitly if desired. - */ - -// RzPVectorComparator should return negative, 0, positive to indicate "value < vec_data", "value == vec_data", "value > vec_data". -typedef int (*RzPVectorComparator)(const void *value, const void *vec_data, void *user); -typedef int (*RzVectorComparator)(const void *a, const void *b, void *user); -typedef void (*RzVectorFree)(void *e, void *user); -typedef void (*RzPVectorFree)(void *e); - -typedef struct rz_vector_t { - void *a; - size_t len; - size_t capacity; - size_t elem_size; - RzVectorFree free; - void *free_user; -} RzVector; - -// RzPVector directly wraps RzVector for type safety -typedef struct rz_pvector_t { - RzVector v; -} RzPVector; - -// RzVector - -RZ_API void rz_vector_init(RzVector *vec, size_t elem_size, RzVectorFree free, void *free_user); - -RZ_API RzVector *rz_vector_new(size_t elem_size, RzVectorFree free, void *free_user); - -// clears the vector and calls vec->free on every element if set. -RZ_API void rz_vector_fini(RzVector *vec); - -// frees the vector and calls vec->free on every element if set. -RZ_API void rz_vector_free(RzVector *vec); - -typedef void (*RzVectorItemCpyFunc)(void *, void *); -typedef void (*RzPVectorItemCpyFunc)(void *, void *); - -RZ_API bool rz_vector_clone_intof( - RZ_NONNULL RZ_BORROW RZ_OUT RzVector *dst, - RZ_NONNULL RZ_BORROW RZ_IN const RzVector *src, - RZ_NULLABLE const RzVectorItemCpyFunc item_cpy); -RZ_API RZ_OWN RzVector *rz_vector_clonef( - RZ_NONNULL RZ_BORROW RZ_IN const RzVector *vec, - RZ_NULLABLE const RzVectorItemCpyFunc item_cpy); -RZ_API bool rz_vector_clone_into( - RZ_NONNULL RZ_BORROW RZ_OUT RzVector *dst, - RZ_NONNULL RZ_BORROW RZ_IN const RzVector *src); -RZ_API RZ_OWN RzVector *rz_vector_clone( - RZ_NONNULL RZ_BORROW RZ_IN const RzVector *vec); - -static inline bool rz_vector_empty(RZ_NULLABLE const RzVector *vec) { - return vec ? vec->len == 0 : true; -} - -RZ_API void rz_vector_clear(RzVector *vec); - -// returns the length of the vector -static inline size_t rz_vector_len(RZ_NULLABLE const RzVector *vec) { - return vec ? vec->len : 0; -} - -// returns a pointer to the offset inside the array where the element of the index lies. -static inline void *rz_vector_index_ptr(const RzVector *vec, size_t index) { - rz_return_val_if_fail(vec && index < vec->capacity, NULL); - return (char *)vec->a + vec->elem_size * index; -} - -// returns a pointer to the first element of the vector -static inline void *rz_vector_head(const RzVector *vec) { - rz_return_val_if_fail(vec, NULL); - return (void *)vec->a; -} - -// returns a pointer to the last element of the vector -static inline void *rz_vector_tail(RzVector *vec) { - rz_return_val_if_fail(vec, NULL); - if (vec->len < 1) { - return NULL; - } - return (char *)vec->a + vec->elem_size * (vec->len - 1); -} - -// helper function to assign an element of size vec->elem_size from elem to p. -// elem is a pointer to the actual data to assign! -RZ_API void rz_vector_assign(RzVector *vec, void *p, void *elem); - -// assign the value of size vec->elem_size at elem to vec at the given index. -// elem is a pointer to the actual data to assign! -RZ_API void *rz_vector_assign_at(RzVector *vec, size_t index, void *elem); - -// remove the element at the given index and write the content to into. -// It is the caller's responsibility to free potential resources associated with the element. -RZ_API void rz_vector_remove_at(RzVector *vec, size_t index, void *into); - -/** - * remove all elements in the given range and write the contents to into (must be appropriately large). - * It is the caller's responsibility to free potential resources associated with the elements. - */ -RZ_API void rz_vector_remove_range(RzVector *vec, size_t index, size_t count, void *into); - -// insert the value of size vec->elem_size at x at the given index. -// x is a pointer to the actual data to assign! -RZ_API void *rz_vector_insert(RzVector *vec, size_t index, void *x); - -// insert count values of size vec->elem_size into vec starting at the given index. -RZ_API void *rz_vector_insert_range(RzVector *vec, size_t index, RZ_NULLABLE void *first, size_t count); - -// like rz_vector_remove_at for the last element -RZ_API void rz_vector_pop(RzVector *vec, void *into); - -// like rz_vector_remove_at for the first element -RZ_API void rz_vector_pop_front(RzVector *vec, void *into); - -// like rz_vector_insert for the end of vec -RZ_API void *rz_vector_push(RzVector *vec, void *x); - -// like rz_vector_insert for the beginning of vec -RZ_API void *rz_vector_push_front(RzVector *vec, void *x); - -/** - * \brief Swap two elements of the vector - * \param index_a index of the first element to swap - * \param index_b index of the second element to swap - * \return true if the swap succeeded - **/ -RZ_API bool rz_vector_swap(RzVector *vec, size_t index_a, size_t index_b); - -// make sure the capacity is at least capacity. -RZ_API void *rz_vector_reserve(RzVector *vec, size_t capacity); - -// shrink capacity to len. -RZ_API void *rz_vector_shrink(RzVector *vec); - -/** - * \brief Turn the vector into a fixed-size array. - * This will clear the vector and return an array of its original contents whose - * ownership is transferred to the caller. - * This is useful when RzVector is used for its dynamically growing functionality as an - * intermediate step to generate a fixed-size array in the end. - */ -RZ_API void *rz_vector_flush(RzVector *vec); - -// sort vector -RZ_API void rz_vector_sort(RzVector *vec, RzVectorComparator cmp, bool reverse, void *user); - -/* - * example: - * - * RzVector *v = ...; // - * MyStruct *it; - * rz_vector_foreach (v, it) { - * // Do something with it - * } - */ -#define rz_vector_foreach(vec, it) \ - if (!rz_vector_empty(vec)) \ - for (it = (void *)(vec)->a; (char *)it != (char *)(vec)->a + ((vec)->len * (vec)->elem_size); it = (void *)((char *)it + (vec)->elem_size)) - -#define rz_vector_foreach_prev(vec, it) \ - if (!rz_vector_empty(vec)) \ - for (it = (void *)((char *)(vec)->a + (((vec)->len - 1) * (vec)->elem_size)); (char *)it != (char *)(vec)->a - (vec)->elem_size; it = (void *)((char *)it - (vec)->elem_size)) - -#define rz_vector_enumerate(vec, it, i) \ - if (!rz_vector_empty(vec)) \ - for (it = (void *)(vec)->a, i = 0; i < (vec)->len; it = (void *)((char *)it + (vec)->elem_size), i++) - -/* - * example: - * - * RzVector *v = ...; // contains {(st64)0, (st64)2, (st64)4, (st64)6, (st64)8}; - * size_t l; - * #define CMP(x, y) x - (*(st64 *)y) - * rz_vector_lower_bound (v, 3, l, CMP); - * // l == 2 - */ -#define rz_vector_lower_bound(vec, x, i, cmp) \ - do { \ - size_t h = (vec)->len, m; \ - for (i = 0; i < h;) { \ - m = i + ((h - i) >> 1); \ - if ((cmp(x, ((char *)(vec)->a + (vec)->elem_size * m))) > 0) { \ - i = m + 1; \ - } else { \ - h = m; \ - } \ - } \ - } while (0) - -#define rz_vector_upper_bound(vec, x, i, cmp) \ - do { \ - size_t h = (vec)->len, m; \ - for (i = 0; i < h;) { \ - m = i + ((h - i) >> 1); \ - if ((cmp(x, ((char *)(vec)->a + (vec)->elem_size * m))) < 0) { \ - h = m; \ - } else { \ - i = m + 1; \ - } \ - } \ - } while (0) - -// RzPVector - -RZ_API void rz_pvector_init(RzPVector *vec, RzPVectorFree free); -RZ_API void rz_pvector_fini(RzPVector *vec); - -RZ_API RzPVector *rz_pvector_new(RzPVectorFree free); - -RZ_API RzPVector *rz_pvector_new_with_len(RzPVectorFree free, size_t length); - -// clear the vector and call vec->v.free on every element. -RZ_API void rz_pvector_clear(RzPVector *vec); - -// free the vector and call vec->v.free on every element. -RZ_API void rz_pvector_free(RzPVector *vec); - -/// See rz_vector_clone() for detailed semantics -static inline RzPVector *rz_pvector_clone(RzPVector *vec) { - return (RzPVector *)rz_vector_clone(&vec->v); -} - -static inline RzPVector *rz_pvector_clonef(RzPVector *vec, RzPVectorItemCpyFunc item_cpy) { - return (RzPVector *)rz_vector_clonef(&vec->v, item_cpy); -} - -static inline size_t rz_pvector_len(const RzPVector *vec) { - if (!vec) { - return 0; - } - return vec->v.len; -} - -static inline void *rz_pvector_at(const RzPVector *vec, size_t index) { - rz_return_val_if_fail(vec, NULL); - if (index >= vec->v.len) { - return NULL; - } - return ((void **)vec->v.a)[index]; -} - -static inline void rz_pvector_set(RzPVector *vec, size_t index, void *e) { - rz_return_if_fail(vec && index < vec->v.len); - ((void **)vec->v.a)[index] = e; -} - -static inline bool rz_pvector_empty(const RzPVector *vec) { - return rz_pvector_len(vec) == 0; -} - -// same as rz_pvector_index_ptr(, 0) -static inline void **rz_pvector_data(RzPVector *vec) { - rz_return_val_if_fail(vec, NULL); - return (void **)vec->v.a; -} - -// returns the first element of the vector -static inline void *rz_pvector_head(RzPVector *vec) { - rz_return_val_if_fail(vec, NULL); - if (vec->v.len < 1) { - return NULL; - } - return ((void **)vec->v.a)[0]; -} - -// returns the last element of the vector -static inline void *rz_pvector_tail(RzPVector *vec) { - rz_return_val_if_fail(vec, NULL); - if (vec->v.len < 1) { - return NULL; - } - return ((void **)vec->v.a)[vec->v.len - 1]; -} - -// returns the respective pointer inside the vector if x is found or NULL otherwise. -RZ_API void **rz_pvector_contains(RzPVector *vec, const void *x); - -// find the element in the vec based on cmparator -RZ_API RZ_BORROW void **rz_pvector_find(RZ_NONNULL const RzPVector *vec, RZ_NONNULL const void *element, RZ_NONNULL RzPVectorComparator cmp, void *user); - -// find the element index in the vec based on cmparator -RZ_API size_t rz_pvector_find_index(RZ_NONNULL const RzPVector *vec, RZ_NONNULL const void *element, RZ_NONNULL RzPVectorComparator cmp, void *user); - -// join two pvector into one, pvec1 should free the joined element in pvec2 -RZ_API bool rz_pvector_join(RZ_NONNULL RzPVector *pvec1, RZ_NONNULL RzPVector *pvec2); - -RZ_API void *rz_pvector_assign_at(RZ_BORROW RZ_NONNULL RzPVector *vec, size_t index, RZ_OWN RZ_NONNULL void *ptr); - -// removes and returns the pointer at the given index. Does not call free. -RZ_API void *rz_pvector_remove_at(RzPVector *vec, size_t index); - -// removes the element x, if present. Does not call free. -RZ_API void rz_pvector_remove_data(RzPVector *vec, void *x); - -// like rz_vector_insert, but the pointer x is the actual data to be inserted. -static inline void **rz_pvector_insert(RzPVector *vec, size_t index, void *x) { - return (void **)rz_vector_insert(&vec->v, index, &x); -} - -// like rz_vector_insert_range. -static inline void **rz_pvector_insert_range(RzPVector *vec, size_t index, void **first, size_t count) { - return (void **)rz_vector_insert_range(&vec->v, index, first, count); -} - -// like rz_vector_pop, but returns the pointer directly. -RZ_API void *rz_pvector_pop(RzPVector *vec); - -// like rz_vector_pop_front, but returns the pointer directly. -RZ_API void *rz_pvector_pop_front(RzPVector *vec); - -// like rz_vector_push, but the pointer x is the actual data to be inserted. -static inline void **rz_pvector_push(RzPVector *vec, void *x) { - return (void **)rz_vector_push(&vec->v, &x); -} - -// like rz_vector_push_front, but the pointer x is the actual data to be inserted. -static inline void **rz_pvector_push_front(RzPVector *vec, void *x) { - return (void **)rz_vector_push_front(&vec->v, &x); -} - -// sort vec using quick sort. -RZ_API void rz_pvector_sort(RzPVector *vec, RzPVectorComparator cmp, void *user); - -// Returns a new RzPVector which contains only unique values -RZ_API RZ_OWN RzPVector *rz_pvector_uniq(RZ_NONNULL const RzPVector *vec, RZ_NONNULL RzPVectorComparator cmp, void *user); - -static inline void **rz_pvector_reserve(RzPVector *vec, size_t capacity) { - return (void **)rz_vector_reserve(&vec->v, capacity); -} - -static inline void **rz_pvector_shrink(RzPVector *vec) { - return (void **)rz_vector_shrink(&vec->v); -} - -static inline void **rz_pvector_flush(RzPVector *vec) { - return (void **)rz_vector_flush(&vec->v); -} - -/* - * example: - * - * RzPVector *v = ...; - * void **it; - * rz_pvector_foreach (v, it) { - * void *p = *it; - * // Do something with p - * } - */ -#define rz_pvector_foreach(vec, it) \ - if (!rz_pvector_empty(vec)) \ - for (it = (void **)(vec)->v.a; (vec)->v.len && it != (void **)(vec)->v.a + (vec)->v.len; it++) - -// like rz_pvector_foreach() but inverse -#define rz_pvector_foreach_prev(vec, it) \ - if (!rz_pvector_empty(vec)) \ - for (it = ((vec)->v.len == 0 ? NULL : (void **)(vec)->v.a + (vec)->v.len - 1); it && it != (void **)(vec)->v.a - 1; it--) - -/** - * \brief Like rz_pvector_foreach() but with index - */ -#define rz_pvector_enumerate(vec, it, idx) \ - if (!rz_pvector_empty(vec)) \ - for (it = (void **)(vec)->v.a, idx = 0; idx < (vec)->v.len; it++, idx++) - -/* - * \brief Find the index of the least element greater than or equal to the lower bound x using binary search - * example: - * - * st64 a[] = { 0, 2, 4, 6, 8 }; - * size_t index; - * #define CMP(x, y) x - y - * rz_pvector_lower_bound (v, 3, index, CMP); - * // index == 2 (contains value 4) - */ -#define rz_array_lower_bound(array, len, x, i, cmp) \ - do { \ - size_t h = len, m; \ - for (i = 0; i < h;) { \ - m = i + ((h - i) >> 1); \ - if (cmp((x), ((array)[m])) > 0) { \ - i = m + 1; \ - } else { \ - h = m; \ - } \ - } \ - } while (0) - -/* - * \brief Find the index of the least element greater than the upper bound x using binary search - * example: - * - * st64 a[] = { 0, 2, 4, 6, 8 }; - * size_t index; - * #define CMP(x, y) x - y - * rz_pvector_lower_bound (v, 2, index, CMP); - * // index == 2 (contains value 4) - */ -#define rz_array_upper_bound(array, len, x, i, cmp) \ - do { \ - size_t h = len, m; \ - for (i = 0; i < h;) { \ - m = i + ((h - i) >> 1); \ - if (cmp((x), ((array)[m])) < 0) { \ - h = m; \ - } else { \ - i = m + 1; \ - } \ - } \ - } while (0) - -/** - * \brief Find an element elem in the \p array, - * lying within \p start and \p stop index such that \p cmp(x, elem) == 0 - * The index of the element elem is stored in \p itr - * If \p itr == \p stop, then no such element was found - */ -#define rz_array_find(array, x, itr, start, stop, cmp) \ - do { \ - for (itr = start; itr < stop; itr++) { \ - if (cmp((array[itr]), x) == 0) { \ - break; \ - } \ - } \ - return itr; \ - } while (0) - -/* - * example: - * - * RzPVector *v = ...; // contains {(void*)0, (void*)2, (void*)4, (void*)6, (void*)8}; - * size_t index; - * #define CMP(x, y) x - y - * rz_pvector_lower_bound (v, (void *)2, index, CMP); - * // index == 1 - */ -#define rz_pvector_lower_bound(vec, x, i, cmp) \ - rz_array_lower_bound((void **)(vec)->v.a, (vec)->v.len, x, i, cmp) - -/* - * example: - * - * RzPVector *v = ...; // contains {(void*)0, (void*)2, (void*)4, (void*)6, (void*)8}; - * size_t index; - * #define CMP(x, y) x - y - * rz_pvector_upper_bound (v, (void *)2, index, CMP); - * // index == 2 - */ -#define rz_pvector_upper_bound(vec, x, i, cmp) \ - rz_array_upper_bound((void **)(vec)->v.a, (vec)->v.len, x, i, cmp) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/rz_windows.h b/dest/include/librz/rz_windows.h deleted file mode 100644 index 0d90d38d145..00000000000 --- a/dest/include/librz/rz_windows.h +++ /dev/null @@ -1,74 +0,0 @@ -// SPDX-FileCopyrightText: 2022 GustavoLCR -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef RZ_WINDOWS_H -#define RZ_WINDOWS_H -/* - * This file is to be included whenever access to - * Windows APIs and type definitions is necessary. - * You should avoid including this file in often used - * header files as it will slow down compilation. - */ -#if __WINDOWS__ || _WIN32 || _MSC_VER -#include -#ifdef NTDDI_WIN10_TH2 -/* Avoid using Developer Preview and default to Windows 10/Windows Server 2016 */ -#undef _WIN32_WINNT -#undef NTDDI_VERSION -#define _WIN32_WINNT _WIN32_WINNT_WIN10 -#define NTDDI_VERSION NTDDI_WIN10 -#endif -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#define NOGDICAPMASKS // CC_*, LC_*, PC_*, CP_*, TC_*, RC_ -#define NOWINMESSAGES // WM_ *, EM_ *, LB_ *, CB_ * -#define NOWINSTYLES // WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_* -#define NOSYSMETRICS // SM_* -#define NOMENUS // MF_* -#define NOICONS // IDI_* -#define NOKEYSTATES // MK_* -#define NOSYSCOMMANDS // SC_* -#define NORASTEROPS // Binary and Tertiary raster ops -#define NOSHOWWINDOW // SW_* -#define OEMRESOURCE // OEM Resource values -#define NOATOM // Atom Manager routines -#define NOCOLOR // Screen colors -#define NOCTLMGR // Control and Dialog routines -#define NODRAWTEXT // DrawText() and DT_* -#define NOGDI // All GDI defines and routines -#define NOKERNEL // All KERNEL defines and routines -#define NOMB // MB_* and MessageBox() -#define NOMEMMGR // GMEM_*, LMEM_*, GHND, LHND, associated routines -#define NOMETAFILE // typedef METAFILEPICT -#define NOMINMAX // Macros min(a,b) and max(a,b) -#define NOOPENFILE // OpenFile(), OemToAnsi, AnsiToOem, and OF_* -#define NOSCROLL // SB_* and scrolling routines -#define NOSOUND // Sound driver routines -#define NOSYSPARAMSINFO // System Parameter information definitions -#define NOTEXTMETRIC // typedef TEXTMETRIC and associated routines -#define NOWH // SetWindowsHook and WH_* -#define NOCOMM // COMM driver routines -#define NOKANJI // Kanji support stuff. -#define NOHELP // Help engine interface. -#define NOPROFILER // Profiler interface. -#define NODEFERWINDOWPOS // DeferWindowPos routines -#define NOMCX // Modem Configuration Extensions -#define NOIME // Input Method Manager -/* Includes windows.h */ -#include -#include -typedef int socklen_t; -#undef USE_SOCKETS -#define __addr_t_defined -#include -/* Windows <=8 compatibility */ -#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING -#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0 -#endif -#ifndef ENABLE_VIRTUAL_TERMINAL_INPUT -#define ENABLE_VIRTUAL_TERMINAL_INPUT 0 -#endif -#include -#endif -#endif diff --git a/dest/include/librz/rz_windows_heap.h b/dest/include/librz/rz_windows_heap.h deleted file mode 100644 index 1fccf607452..00000000000 --- a/dest/include/librz/rz_windows_heap.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef RZ_WINDOWS_HEAP_H -#define RZ_WINDOWS_HEAP_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rz_heap_block { - ut64 userAddress; - ut64 headerAddress; - ut64 granularity; - ut64 unusedBytes; - char type[100]; - ut64 size; -} RzWindowsHeapBlock; - -typedef struct rz_heap_info { - ut64 base; - ut64 blockCount; - ut64 allocated; - ut64 committed; -} RzWindowsHeapInfo; - -#ifdef __cplusplus -} -#endif - -#endif // diff --git a/dest/include/librz/sdb/buffer.h b/dest/include/librz/sdb/buffer.h deleted file mode 100644 index 62d79329a05..00000000000 --- a/dest/include/librz/sdb/buffer.h +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-FileCopyrightText: unknown -// SPDX-License-Identifier: CC-PDDC - -#ifndef BUFFER_H -#define BUFFER_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief The callback which writes to the file descriptor. - * - * Takes the parameters \c fd, \c buf, \c len in this order, and - * returns the number of bytes successfully written. - */ -typedef int (*BufferOp)(int, const char *, int); - -typedef struct buffer { - char *x; ///< The underlying memory buffer. - unsigned int p; ///< Anything between 0 and p is buffered; not yet written out. - unsigned int n; ///< The total size of the memory buffer. - int fd; ///< The file descriptor to write to when the buffer is full. - BufferOp op; ///< The callback which writes to the file descriptor. -} buffer; - -extern void buffer_init(buffer *, BufferOp, int, char *, unsigned int); -extern int buffer_flush(buffer *); -extern int buffer_putalign(buffer *, const char *, unsigned int); -extern int buffer_putflush(buffer *, const char *, unsigned int); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/sdb/cdb.h b/dest/include/librz/sdb/cdb.h deleted file mode 100644 index ca1a48b3441..00000000000 --- a/dest/include/librz/sdb/cdb.h +++ /dev/null @@ -1,69 +0,0 @@ -// SPDX-FileCopyrightText: D. J. Bernstein -// SPDX-License-Identifier: CC-PDDC - -/** - * \internal - * \file - * \brief Reading and operating on a \ref cdb structure. - * - * The \ref cdb structure is an associative array mapping strings to - * strings. Originally written by D. J. Bernstein, see - * for a description of the binary format. - */ - -#ifndef CDB_H -#define CDB_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \def KVLSZ - * \brief The size in bytes of the key-value lengths combined. - */ - -#define KVLSZ 4 -#define CDB_MAX_KEY 0xff -#define CDB_MAX_VALUE 0xffffff - -#define CDB_HASHSTART 5381 - -/** \internal - * \brief The \ref cdb structure. - * - * An associative array of strings to strings based on cdb by - * D. J. Bernstein, see . - */ -struct cdb { - char *map; ///< Maps the file in memory. NULL if no map is available. - int fd; ///< The file descriptor from which the cdb structure is read. - ut32 size; ///< Initialized if map is nonzero. - ut32 loop; ///< The search state, number of hash slots searched in a given key. - ut32 khash; ///< Hash of key. Initialized if loop is nonzero. - ut32 kpos; ///< Key position. Initialized if loop is nonzero. - ut32 hpos; ///< Current hash table position. Initialized if loop is nonzero. - ut32 hslots; ///< Number of slots of current hash table. Initialized if loop is nonzero. - ut32 dpos; ///< Data position. Initialized if cdb_findnext() returns 1. - ut32 dlen; ///< Data length. Initialized if cdb_findnext() returns 1. -}; - -/* TODO Remove this! */ -bool cdb_getkvlen(struct cdb *db, ut32 *klen, ut32 *vlen, ut32 pos); -void cdb_free(struct cdb *); -bool cdb_init(struct cdb *, int fd); -void cdb_findstart(struct cdb *); -bool cdb_read(struct cdb *, char *, unsigned int, ut32); -int cdb_findnext(struct cdb *, ut32 u, const char *, ut32); - -#define cdb_datapos(c) ((c)->dpos) -#define cdb_datalen(c) ((c)->dlen) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/sdb/cdb_make.h b/dest/include/librz/sdb/cdb_make.h deleted file mode 100644 index 48273ae38bc..00000000000 --- a/dest/include/librz/sdb/cdb_make.h +++ /dev/null @@ -1,52 +0,0 @@ -// SPDX-FileCopyrightText: D. J. Bernstein -// SPDX-License-Identifier: CC-PDDC - -#ifndef CDB_MAKE_H -#define CDB_MAKE_H - -#include "buffer.h" -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define CDB_HPLIST 1000 - -struct cdb_hp { - ut32 h; - ut32 p; -}; - -struct cdb_hplist { - struct cdb_hp hp[CDB_HPLIST]; - struct cdb_hplist *next; - int num; -}; - -struct cdb_make { - char bspace[8192]; - char final[1024]; - ut32 count[256]; - ut32 start[256]; - struct cdb_hplist *head; - struct cdb_hp *split; /* includes space for hash */ - struct cdb_hp *hash; - ut32 numentries; - ut32 memsize; - buffer b; - ut32 pos; - int fd; -}; - -extern int cdb_make_start(struct cdb_make *, int); -extern int cdb_make_addbegin(struct cdb_make *, unsigned int, unsigned int); -extern int cdb_make_addend(struct cdb_make *, unsigned int, unsigned int, ut32); -extern int cdb_make_add(struct cdb_make *, const char *, unsigned int, const char *, unsigned int); -extern int cdb_make_finish(struct cdb_make *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/sdb/sdb.h b/dest/include/librz/sdb/sdb.h deleted file mode 100644 index a46675542d6..00000000000 --- a/dest/include/librz/sdb/sdb.h +++ /dev/null @@ -1,331 +0,0 @@ -// SPDX-FileCopyrightText: pancake -// SPDX-License-Identifier: MIT - -#ifndef SDB_H -#define SDB_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include "sdbht.h" -#include "cdb.h" -#include "cdb_make.h" - -/* Key value sizes */ -#define SDB_CDB_MIN_VALUE 1 -#define SDB_CDB_MAX_VALUE CDB_MAX_VALUE -#define SDB_CDB_MIN_KEY 2 -#define SDB_CDB_MAX_KEY CDB_MAX_KEY - -#if __WINDOWS__ && !__CYGWIN__ -#include -#include -#include -#include -#include -#define ftruncate _chsize -#ifndef _MSC_VER -extern __attribute__((dllimport)) void *__cdecl _aligned_malloc(size_t, size_t); -extern __attribute__((dllimport)) void __cdecl _aligned_free(void *memblock); -extern char *strdup(const char *); -#else -#include -#include // for _aligned_malloc -#endif - -// #define SDB_MODE 0 -#define SDB_MODE _S_IWRITE | _S_IREAD -#else -#define SDB_MODE 0644 -// #define SDB_MODE 0600 -#endif - -// #define SDB_RS '\x1e' -#define SDB_RS ',' -#define SDB_SS "," -#define SDB_MAX_PATH 256 -#define SDB_NUM_BASE 16 -#define SDB_NUM_BUFSZ 64 - -#define SDB_OPTION_NONE 0 -#define SDB_OPTION_ALL 0xff -#define SDB_OPTION_SYNC (1 << 0) -#define SDB_OPTION_NOSTAMP (1 << 1) -#define SDB_OPTION_FS (1 << 2) - -#define SDB_LIST_UNSORTED 0 -#define SDB_LIST_SORTED 1 - -typedef bool (*VALUE_EQ_F)(const char *, const char *); - -typedef struct sdb_t { - char *dir; // path+name - char *path; - char *name; - int fd; - int refs; // reference counter - int lock; - struct cdb db; - struct cdb_make m; - HtSS *ht; - ut32 eod; - ut32 pos; - ut32 dump_end_pos; ///< Used in sdb_dump_next() - int fdump; - char *ndump; - int options; - int ns_lock; // TODO: merge into options? - RzList /**/ *ns; - ut32 depth; -} Sdb; - -typedef struct sdb_ns_t { - char *name; - ut32 hash; - Sdb *sdb; -} SdbNs; - -RZ_API RZ_OWN Sdb *sdb_new0(void); -RZ_API RZ_OWN Sdb *sdb_new(const char *path, const char *file, int lock); - -RZ_API int sdb_open(Sdb *s, const char *file); -RZ_API void sdb_close(Sdb *s); - -RZ_API void sdb_config(Sdb *s, int options); -RZ_API bool sdb_free(Sdb *s); -RZ_API void sdb_file(Sdb *s, const char *dir); -RZ_API bool sdb_merge(Sdb *d, Sdb *s); -RZ_API int sdb_count(Sdb *s); -RZ_API void sdb_reset(Sdb *s); -RZ_API void sdb_setup(Sdb *s, int options); -RZ_API void sdb_drain(Sdb *, Sdb *); - -// Copy everything, including namespaces, from src to dst -RZ_API void sdb_copy(Sdb *src, Sdb *dst); - -RZ_API bool sdb_stats(Sdb *s, ut32 *disk, ut32 *mem); - -typedef bool (*SdbForeachCallback)(void *user, const SdbKv *kv); -RZ_API bool sdb_foreach(RZ_NONNULL Sdb *s, RZ_NONNULL SdbForeachCallback cb, RZ_NULLABLE void *user); -RZ_API RZ_OWN RzPVector /**/ *sdb_get_items(RZ_NONNULL Sdb *s, bool sorted); -RZ_API RZ_OWN RzPVector /**/ *sdb_get_items_filter(RZ_NONNULL Sdb *s, RZ_NONNULL SdbForeachCallback filter, RZ_NULLABLE void *user, bool sorted); -RZ_API RZ_OWN RzPVector /**/ *sdb_get_items_match(RZ_NONNULL Sdb *s, RZ_NONNULL const char *expr, bool sorted); - -RZ_API int sdb_query(Sdb *s, const char *cmd); -RZ_API int sdb_queryf(Sdb *s, const char *fmt, ...); -RZ_API int sdb_query_lines(Sdb *s, const char *cmd); -RZ_API char *sdb_querys(Sdb *s, char *buf, size_t len, const char *cmd); -RZ_API char *sdb_querysf(Sdb *s, char *buf, size_t buflen, const char *fmt, ...); -RZ_API int sdb_query_file(Sdb *s, const char *file); -RZ_API bool sdb_exists(Sdb *, const char *key); -RZ_API bool sdb_remove(Sdb *, const char *key); -RZ_API int sdb_unset(Sdb *, const char *key); -RZ_API int sdb_unset_like(Sdb *s, const char *k); - -// diffing -typedef struct sdb_diff_t { - const RzList /**/ *path; - const char *k; - const char *v; // if null, k is a namespace - bool add; -} SdbDiff; - -// Format diff in a readable form into str. str, size and return are like in snprintf. -RZ_API int sdb_diff_format(char *str, int size, const SdbDiff *diff); - -typedef void (*SdbDiffCallback)(const SdbDiff *diff, void *user); - -// Returns true iff the contents of a and b are equal including contained namespaces -// If cb is non-null, it will be called subsequently with differences. -RZ_API bool sdb_diff(Sdb *a, Sdb *b, SdbDiffCallback cb, void *cb_user); - -RZ_API bool sdb_diff_eq(Sdb *a, Sdb *b, VALUE_EQ_F eq, SdbDiffCallback cb, void *cb_user); - -// Gets a pointer to the value associated with `key`. -RZ_API char *sdb_get(Sdb *, const char *key); - -// Gets a pointer to the value associated with `key` and returns in `vlen` the -// length of the value string. -RZ_API char *sdb_get_len(Sdb *, const char *key, int *vlen); - -// Gets a const pointer to the value associated with `key` -RZ_API const char *sdb_const_get(Sdb *, const char *key); - -// Gets a const pointer to the value associated with `key` and returns in -// `vlen` the length of the value string. -RZ_API const char *sdb_const_get_len(Sdb *s, const char *key, int *vlen); -RZ_API bool sdb_set(Sdb *, const char *key, const char *data); -RZ_API bool sdb_set_owned(Sdb *s, const char *key, char *val); -RZ_API bool sdb_concat(Sdb *s, const char *key, const char *value); -RZ_API bool sdb_uncat(Sdb *s, const char *key, const char *value); -RZ_API bool sdb_add(Sdb *s, const char *key, const char *val); -RZ_API bool sdb_sync(Sdb *); -RZ_API void sdbkv_free(RZ_NULLABLE SdbKv *kv); - -/* num.c */ -RZ_API bool sdb_num_exists(Sdb *, const char *key); -RZ_API int sdb_num_base(const char *s); -RZ_API bool sdb_num_set(Sdb *s, const char *key, ut64 v); -RZ_API ut64 sdb_num_get(Sdb *s, const char *key); -RZ_API bool sdb_num_add(Sdb *s, const char *key, ut64 v); -RZ_API ut64 sdb_num_inc(Sdb *s, const char *key, ut64 n); -RZ_API ut64 sdb_num_dec(Sdb *s, const char *key, ut64 n); -RZ_API int sdb_num_min(Sdb *s, const char *key, ut64 v); -RZ_API int sdb_num_max(Sdb *s, const char *key, ut64 v); - -/* create db */ -RZ_API bool sdb_disk_create(Sdb *s); -RZ_API bool sdb_disk_insert(Sdb *s, const char *key, const char *val); -RZ_API bool sdb_disk_finish(Sdb *s); -RZ_API bool sdb_disk_unlink(Sdb *s); - -/* plaintext sdb files */ -RZ_API bool sdb_text_save_fd(Sdb *s, int fd, bool sort); -RZ_API bool sdb_text_save(Sdb *s, const char *file, bool sort); -RZ_API bool sdb_text_load_buf(Sdb *s, char *buf, size_t sz); -RZ_API bool sdb_text_load(Sdb *s, const char *file); - -/* iterate */ -RZ_API void sdb_dump_begin(RZ_NONNULL Sdb *s); -RZ_API bool sdb_dump_next(RZ_NONNULL Sdb *s, RZ_OUT RZ_NONNULL SdbKv *kv); - -/* numeric */ -RZ_API char *sdb_itoa(ut64 n, char *s, int base); -RZ_API ut64 sdb_atoi(const char *s); -RZ_API const char *sdb_itoca(ut64 n); - -/* locking */ -RZ_API bool sdb_lock(const char *s); -RZ_API RZ_OWN char *sdb_lock_file(const char *f); -RZ_API void sdb_unlock(const char *s); -RZ_API bool sdb_unlink(Sdb *s); -RZ_API int sdb_lock_wait(RZ_UNUSED const char *s); - -/* expiration */ -RZ_API ut64 sdb_now(void); -RZ_API ut64 sdb_unow(void); -RZ_API ut32 sdb_hash(const char *key); -RZ_API ut32 sdb_hash_len(const char *key, ut32 *len); -RZ_API ut8 sdb_hash_byte(const char *s); - -// namespace -RZ_API Sdb *sdb_ns(Sdb *s, const char *name, int create); -RZ_API Sdb *sdb_ns_path(Sdb *s, const char *path, int create); -RZ_API void sdb_ns_init(Sdb *s); -RZ_API void sdb_ns_free_all(Sdb *s); -RZ_API void sdb_ns_lock(Sdb *s, int lock, int depth); -RZ_API void sdb_ns_sync(Sdb *s); -RZ_API int sdb_ns_set(Sdb *s, const char *name, Sdb *r); -RZ_API bool sdb_ns_unset(Sdb *s, const char *name, Sdb *r); - -// array -RZ_API bool sdb_array_contains(Sdb *s, const char *key, const char *val); -RZ_API bool sdb_array_contains_num(Sdb *s, const char *key, ut64 val); -RZ_API int sdb_array_indexof(Sdb *s, const char *key, const char *val); -RZ_API bool sdb_array_set(Sdb *s, const char *key, int idx, const char *val); -RZ_API bool sdb_array_set_num(Sdb *s, const char *key, int idx, ut64 val); -RZ_API bool sdb_array_append(Sdb *s, const char *key, const char *val); -RZ_API bool sdb_array_append_num(Sdb *s, const char *key, ut64 val); -RZ_API bool sdb_array_prepend(Sdb *s, const char *key, const char *val); -RZ_API bool sdb_array_prepend_num(Sdb *s, const char *key, ut64 val); -RZ_API char *sdb_array_get(Sdb *s, const char *key, int idx); -RZ_API bool sdb_array_get_num(RZ_NONNULL RZ_BORROW Sdb *s, RZ_NONNULL const char *key, int idx, RZ_OUT RZ_NONNULL ut64 *out_number); -RZ_API int sdb_array_get_idx(Sdb *s, const char *key, const char *val); // agetv -RZ_API bool sdb_array_insert(Sdb *s, const char *key, int idx, const char *val); -RZ_API int sdb_array_insert_num(Sdb *s, const char *key, int idx, ut64 val); -RZ_API int sdb_array_unset(Sdb *s, const char *key, int n); // leaves empty bucket -RZ_API int sdb_array_delete(Sdb *s, const char *key, int n); -RZ_API void sdb_array_sort(Sdb *s, const char *key); -RZ_API void sdb_array_sort_num(Sdb *s, const char *key); -// set - -// Adds string `val` at the end of array `key`. -RZ_API bool sdb_array_add(Sdb *s, const char *key, const char *val); - -// Adds number `val` at the end of array `key`. -RZ_API bool sdb_array_add_num(Sdb *s, const char *key, ut64 val); - -// Adds string `val` in the sorted array `key`. -RZ_API int sdb_array_add_sorted(Sdb *s, const char *key, const char *val); - -// Adds number `val` in the sorted array `key`. -RZ_API bool sdb_array_add_sorted_num(Sdb *s, const char *key, ut64 val); - -// Removes the string `val` from the array `key`. -RZ_API int sdb_array_remove(Sdb *s, const char *key, const char *val); - -// Removes the number `val` from the array `key`. -RZ_API int sdb_array_remove_num(Sdb *s, const char *key, ut64 val); - -// helpers -RZ_API char *sdb_anext(char *str, char **next); -RZ_API const char *sdb_const_anext(const char *str); -RZ_API int sdb_alen(const char *str); -RZ_API int sdb_alen_ignore_empty(const char *str); -RZ_API int sdb_array_size(Sdb *s, const char *key); -RZ_API int sdb_array_length(Sdb *s, const char *key); - -int sdb_array_list(Sdb *s, const char *key); - -// Adds the string `val` to the start of array `key`. -RZ_API bool sdb_array_push(Sdb *s, const char *key, const char *val); - -// Returns the string at the start of array `key` or -// NULL if there are no elements. -RZ_API char *sdb_array_pop(Sdb *s, const char *key); - -// Adds the number `val` to the start of array `key`. -RZ_API int sdb_array_push_num(Sdb *s, const char *key, ut64 num); - -// Returns the number at the start of array `key`. -RZ_API ut64 sdb_array_pop_num(Sdb *s, const char *key); - -RZ_API char *sdb_array_pop_head(Sdb *s, const char *key); -RZ_API char *sdb_array_pop_tail(Sdb *s, const char *key); - -/* Util.c */ -RZ_API int sdb_isnum(const char *s); -RZ_API bool sdb_isempty(Sdb *s); - -RZ_API const char *sdb_type(const char *k); -RZ_API bool sdb_match(const char *str, const char *glob); -RZ_API bool sdb_bool_set(Sdb *db, const char *str, bool v); -RZ_API bool sdb_bool_get(Sdb *db, const char *str); - -// base64 -RZ_API ut8 *sdb_decode(const char *in, int *len); -RZ_API char *sdb_encode(const ut8 *bin, int len); -RZ_API void sdb_encode_raw(char *bout, const ut8 *bin, int len); -RZ_API int sdb_decode_raw(ut8 *bout, const char *bin, int len); - -// binfmt -RZ_API char *sdb_fmt_tostr(void *stru, const char *fmt); -RZ_API char **sdb_fmt_array(const char *list); -RZ_API ut64 *sdb_fmt_array_num(const char *list); - -// raw array helpers -RZ_API char *sdb_array_compact(char *p); -RZ_API char *sdb_aslice(char *out, int from, int to); -#define sdb_aforeach(x, y) \ - { \ - char *next; \ - if (y) \ - for (x = y;;) { \ - x = sdb_anext(x, &next); -#define sdb_aforeach_next(x) \ - if (!next) \ - break; \ - *(next - 1) = ','; \ - x = next; \ - } \ - } - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dest/include/librz/sdb/sdbht.h b/dest/include/librz/sdb/sdbht.h deleted file mode 100644 index b22f67967d2..00000000000 --- a/dest/include/librz/sdb/sdbht.h +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-FileCopyrightText: pancake -// SPDX-License-Identifier: MIT - -#ifndef __SDB_HT_H -#define __SDB_HT_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** keyvalue pair **/ -typedef struct sdb_kv { - // sub of HtSSKv so we can cast safely - HtSSKv base; -} SdbKv; - -static inline const char *sdbkv_key(const SdbKv *kv) { - return kv->base.key; -} - -static inline const char *sdbkv_value(const SdbKv *kv) { - return kv->base.value; -} - -static inline ut32 sdbkv_key_len(const SdbKv *kv) { - return kv->base.key_len; -} - -static inline ut32 sdbkv_value_len(const SdbKv *kv) { - return kv->base.value_len; -} - -RZ_API SdbKv *sdbkv_new2(const char *k, int kl, const char *v, int vl); -RZ_API SdbKv *sdbkv_new(const char *k, const char *v); -extern RZ_API void sdbkv_free(RZ_NULLABLE SdbKv *kv); -RZ_API RZ_OWN char *sdbkv_dup_value(RZ_NONNULL const SdbKv *kv); - -extern RZ_API ut32 sdb_hash(const char *key); - -RZ_API HtSS *sdb_ht_new(void); -// Destroy a hashtable and all of its entries. -RZ_API void sdb_ht_free(HtSS *ht); -// Insert a new Key-Value pair into the hashtable. If the key already exists, returns false. -RZ_API bool sdb_ht_insert(HtSS *ht, const char *key, const char *value); -// Insert a new Key-Value pair into the hashtable, or updates the value if the key already exists. -RZ_API bool sdb_ht_insert_kvp(HtSS *ht, SdbKv *kvp, bool update); -// Insert a new Key-Value pair into the hashtable, or updates the value if the key already exists. -RZ_API bool sdb_ht_update(HtSS *ht, const char *key, const char *value); -// Delete a key from the hashtable. -RZ_API bool sdb_ht_delete(HtSS *ht, const char *key); -// Find the value corresponding to the matching key. -RZ_API char *sdb_ht_find(HtSS *ht, const char *key, bool *found); -// Find the KeyValuePair corresponding to the matching key. -RZ_API SdbKv *sdb_ht_find_kvp(HtSS *ht, const char *key, bool *found); - -#ifdef __cplusplus -} -#endif - -#endif // __SDB_HT_H diff --git a/dest/include/librz/sflib/common/sfsocketcall.h b/dest/include/librz/sflib/common/sfsocketcall.h deleted file mode 100644 index 567f85b21f1..00000000000 --- a/dest/include/librz/sflib/common/sfsocketcall.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * sfsocketcall.h -- linux socket implementation - * see http://www.secdev.org/projects/shellforge.html - * for more informations - * - * Copyright (C) 2003 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - -/* $Id$ */ - -#ifndef SFSOCKETCALL_H -#define SFSOCKETCALL_H - -int socketcall(int call, unsigned long *args); - -#define SYS_socket 1 /* sys_socket(2) */ -#define SYS_bind 2 /* sys_bind(2) */ -#define SYS_connect 3 /* sys_connect(2) */ -#define SYS_listen 4 /* sys_listen(2) */ -#define SYS_accept 5 /* sys_accept(2) */ -#define SYS_getsockname 6 /* sys_getsockname(2) */ -#define SYS_getpeername 7 /* sys_getpeername(2) */ -#define SYS_socketpair 8 /* sys_socketpair(2) */ -#define SYS_send 9 /* sys_send(2) */ -#define SYS_recv 10 /* sys_recv(2) */ -#define SYS_sendto 11 /* sys_sendto(2) */ -#define SYS_recvfrom 12 /* sys_recvfrom(2) */ -#define SYS_shutdown 13 /* sys_shutdown(2) */ -#define SYS_setsockopt 14 /* sys_setsockopt(2) */ -#define SYS_getsockopt 15 /* sys_getsockopt(2) */ -#define SYS_sendmsg 16 /* sys_sendmsg(2) */ -#define SYS_recvmsg 17 /* sys_recvmsg(2) */ - - -#define __sys_socketcall0(type, name) \ -type name(void) \ -{ \ - return socketcall(SYS_##name, 0); \ -} - -#define __sys_socketcall1(type, name, type0, arg0) \ -type name(type0 arg0) \ -{ \ - unsigned long arr[1]; \ - arr[0] = (long)arg0; \ - return socketcall(SYS_##name, arr); \ -} - -#define __sys_socketcall2(type, name, type0,arg0, type1,arg1) \ -type name(type0 arg0, type1 arg1) \ -{ \ - unsigned long arr[2]; \ - arr[0] = (long)arg0; \ - arr[1] = (long)arg1; \ - return socketcall(SYS_##name, arr); \ -} - -#define __sys_socketcall3(type, name, type0,arg0, type1,arg1, type2,arg2) \ -type name(type0 arg0, type1 arg1, type2 arg2) \ -{ \ - unsigned long arr[3]; \ - arr[0] = (long)arg0; \ - arr[1] = (long)arg1; \ - arr[2] = (long)arg2; \ - return socketcall(SYS_##name, arr); \ -} - -#define __sys_socketcall4(type, name, type0,arg0, type1,arg1, type2,arg2, type3,arg3) \ -type name(type0 arg0, type1 arg1, type2 arg2, type3 arg3) \ -{ \ - unsigned long arr[4]; \ - arr[0] = (long)arg0; \ - arr[1] = (long)arg1; \ - arr[2] = (long)arg2; \ - arr[3] = (long)arg3; \ - return socketcall(SYS_##name, arr); \ -} - -#define __sys_socketcall5(type, name, type0,arg0, type1,arg1, type2,arg2, type3,arg3, type4,arg4) \ -type name(type0 arg0, type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ -{ \ - unsigned long arr[5]; \ - arr[0] = (long)arg0; \ - arr[1] = (long)arg1; \ - arr[2] = (long)arg2; \ - arr[3] = (long)arg3; \ - arr[4] = (long)arg4; \ - return socketcall(SYS_##name, arr); \ -} - -#define __sys_socketcall6(type, name, type0,arg0, type1,arg1, type2,arg2, type3,arg3, type4,arg4, type5,arg5) \ -type name(type0 arg0, type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ -{ \ - unsigned long arr[6]; \ - arr[0] = (long)arg0; \ - arr[1] = (long)arg1; \ - arr[2] = (long)arg2; \ - arr[3] = (long)arg3; \ - arr[4] = (long)arg4; \ - arr[5] = (long)arg5; \ - return socketcall(SYS_##name, arr); \ -} - -inline static __sys_socketcall3(int,socket, int,domain, int,type, int,protocol) -inline static __sys_socketcall3(int,bind, int,sockfd, struct sockaddr *,my_addr, socklen_t,addrlen) -inline static __sys_socketcall3(int,connect, int,sockfd, const struct sockaddr *,serv_addr, socklen_t,addrlen) -inline static __sys_socketcall2(int,listen, int,s, int,backlog) -inline static __sys_socketcall3(int,accept, int,s, struct sockaddr *,addr, socklen_t*,addrlen) - -inline static __sys_socketcall4(int,send, int,s, const void *,msg, size_t,len, int,flags) -inline static __sys_socketcall4(ssize_t,recv, int,s, void *,buf, size_t,len, int,flags) - - -inline static __sys_socketcall6(ssize_t,recvfrom, int,s, void *,buf, size_t,len, int,flags, struct sockaddr *,from, socklen_t *,fromlen) -inline static __sys_socketcall3(ssize_t,recvmsg, int,s, struct msghdr *,msg, int,flags) -inline static __sys_socketcall6(ssize_t,sendto, int,s, const void *,buf, size_t,len, int,flags, const struct sockaddr *,to, socklen_t,tolen) -inline static __sys_socketcall3(ssize_t,sendmsg, int,s, const struct msghdr *,msg, int,flags) - - - -#endif /* SFSOCKETCALL_H */ diff --git a/dest/include/librz/sflib/common/sftypes.h b/dest/include/librz/sflib/common/sftypes.h deleted file mode 100644 index fab3f831055..00000000000 --- a/dest/include/librz/sflib/common/sftypes.h +++ /dev/null @@ -1,3573 +0,0 @@ -/* - * sftypes.h -- shellforge lib types - * see http://www.cartel-securite.net/pbiondi/shellforge.html - * for more informations - * - * Copyright (C) 2003 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - -/* $Id$ */ - -#ifndef SFTYPES_H -#define SFTYPES_H - - -#define NULL ((void*)0) - - -/* XXX this is far from true on every architecture! */ -typedef unsigned long uint64_t; -typedef unsigned int uint32_t; -typedef unsigned short uint16_t; -typedef unsigned char uint8_t; -typedef long int64_t; -typedef int int32_t; -typedef short int16_t; -typedef char int8_t; - - -typedef int pid_t; -typedef int ssize_t; -typedef int size_t; -typedef int off_t; -typedef int mode_t; -typedef int clock_t; -typedef int uid_t; -typedef int gid_t; -typedef void (*sighandler_t)(int); - -struct dirent { - int d_ino; - int d_off; - unsigned short int d_reclen; - char d_name[256]; -}; - -struct tms { - clock_t tms_utime; /* user time */ - clock_t tms_stime; /* system time */ - clock_t tms_cutime; /* user time of children */ - clock_t tms_cstime; /* system time of children */ -}; -typedef int dev_t; -typedef int caddr_t; -typedef int sigset_t; -typedef int cap_user_header_t; -typedef int cap_user_data_t; -typedef int time_t; -struct vm86plus_struct {}; -typedef int ptrdiff_t; -struct utimbuf {}; -struct __sysctl_args {}; -struct timezone {}; -struct sysinfo{}; -struct iovec {}; -struct statfs {}; -struct pollfd {}; -struct kernel_sym {}; -struct module {}; -struct utsname {}; -struct ustat {}; -struct stat {}; -struct sched_param {}; -struct timeval -{ - long tv_sec; /* seconds */ - long tv_usec; /* microseconds */ -}; -struct timespec -{ - time_t tv_sec; /* seconds */ - long tv_nsec; /* nanoseconds */ -}; - - - -#define PROT_READ 0x1 /* Page can be read. */ -#define PROT_WRITE 0x2 /* Page can be written. */ -#define PROT_EXEC 0x4 /* Page can be executed. */ -#define PROT_NONE 0x0 /* Page can not be accessed. */ - -/* Sharing types (must choose one and only one of these). */ -#define MAP_SHARED 0x01 /* Share changes. */ -#define MAP_PRIVATE 0x02 /* Changes are private. */ -#define MAP_TYPE 0x0f /* Mask for type of mapping. */ -#define MAP_FIXED 0x10 /* Interpret addr exactly. */ -#define MAP_FILE 0 -#define MAP_ANONYMOUS 0x20 /* Don't use a file. */ -#define MAP_ANON MAP_ANONYMOUS - -/**************** Error codes *****************/ - -#define EPERM 1 /* Operation not permitted */ -#define ENOENT 2 /* No such file or directory */ -#define ESRCH 3 /* No such process */ -#define EINTR 4 /* Interrupted system call */ -#define EIO 5 /* I/O error */ -#define ENXIO 6 /* No such device or address */ -#define E2BIG 7 /* Argument list too long */ -#define ENOEXEC 8 /* Exec format error */ -#define EBADF 9 /* Bad file number */ -#define ECHILD 10 /* No child processes */ -#define EAGAIN 11 /* Try again */ -#define ENOMEM 12 /* Out of memory */ -#define EACCES 13 /* Permission denied */ -#define EFAULT 14 /* Bad address */ -#define ENOTBLK 15 /* Block device required */ -#define EBUSY 16 /* Device or resource busy */ -#define EEXIST 17 /* File exists */ -#define EXDEV 18 /* Cross-device link */ -#define ENODEV 19 /* No such device */ -#define ENOTDIR 20 /* Not a directory */ -#define EISDIR 21 /* Is a directory */ -#define EINVAL 22 /* Invalid argument */ -#define ENFILE 23 /* File table overflow */ -#define EMFILE 24 /* Too many open files */ -#define ENOTTY 25 /* Not a typewriter */ -#define ETXTBSY 26 /* Text file busy */ -#define EFBIG 27 /* File too large */ -#define ENOSPC 28 /* No space left on device */ -#define ESPIPE 29 /* Illegal seek */ -#define EROFS 30 /* Read-only file system */ -#define EMLINK 31 /* Too many links */ -#define EPIPE 32 /* Broken pipe */ -#define EDOM 33 /* Math argument out of domain of func */ -#define ERANGE 34 /* Math result not representable */ - -#define ESTRPIPE 86 /* Streams pipe error */ -#define EUSERS 87 /* Too many users */ -#define ENOTSOCK 88 /* Socket operation on non-socket */ -#define EDESTADDRREQ 89 /* Destination address required */ -#define EMSGSIZE 90 /* Message too long */ -#define EPROTOTYPE 91 /* Protocol wrong type for socket */ -#define ENOPROTOOPT 92 /* Protocol not available */ -#define EPROTONOSUPPORT 93 /* Protocol not supported */ -#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ -#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ -#define EPFNOSUPPORT 96 /* Protocol family not supported */ -#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ -#define EADDRINUSE 98 /* Address already in use */ -#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ -#define ENETDOWN 100 /* Network is down */ -#define ENETUNREACH 101 /* Network is unreachable */ -#define ENETRESET 102 /* Network dropped connection because of reset */ -#define ECONNABORTED 103 /* Software caused connection abort */ -#define ECONNRESET 104 /* Connection reset by peer */ -#define ENOBUFS 105 /* No buffer space available */ -#define EISCONN 106 /* Transport endpoint is already connected */ -#define ENOTCONN 107 /* Transport endpoint is not connected */ -#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ -#define ETOOMANYREFS 109 /* Too many references: cannot splice */ -#define ETIMEDOUT 110 /* Connection timed out */ -#define ECONNREFUSED 111 /* Connection refused */ -#define EHOSTDOWN 112 /* Host is down */ -#define EHOSTUNREACH 113 /* No route to host */ -#define EALREADY 114 /* Operation already in progress */ -#define EINPROGRESS 115 /* Operation now in progress */ -#define ESTALE 116 /* Stale NFS file handle */ -#define EUCLEAN 117 /* Structure needs cleaning */ -#define ENOTNAM 118 /* Not a XENIX named type file */ -#define ENAVAIL 119 /* No XENIX semaphores available */ -#define EISNAM 120 /* Is a named type file */ -#define EREMOTEIO 121 /* Remote I/O error */ -#define EDQUOT 122 /* Quota exceeded */ - - - -/**************** Select *******************************/ - -typedef long int fd_mask; - -#define FD_SETSIZE 1024 - -#define NFDBITS (8 * sizeof (fd_mask)) -#define __FDELT(d) ((d) / NFDBITS) -#define FDMASK(d) ((fd_mask) 1 << ((d) % NFDBITS)) - -typedef struct - { - fd_mask fds_bits[FD_SETSIZE / NFDBITS]; - } fd_set; - -# define __FDS_BITS(set) ((set)->fds_bits) - - -#define FD_ZERO(set) \ - do { \ - unsigned int __i; \ - fd_set *__arr = (set); \ - for (__i = 0; __i < sizeof (fd_set) / sizeof (fd_mask); ++__i) \ - __FDS_BITS (__arr)[__i] = 0; \ - } while (0) - -#define FD_SET(d, set) (__FDS_BITS (set)[__FDELT (d)] |= FDMASK (d)) -#define FD_CLR(d, set) (__FDS_BITS (set)[__FDELT (d)] &= ~FDMASK (d)) -#define FD_ISSET(d, set) (__FDS_BITS (set)[__FDELT (d)] & FDMASK (d)) - -/**************** Sockets and network *******************/ - - -typedef unsigned int socklen_t; - -/* SOCK_ constants */ -enum __socket_type -{ - SOCK_STREAM = 1, /* Sequenced, reliable, connection-based - byte streams. */ -#define SOCK_STREAM SOCK_STREAM - SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams - of fixed maximum length. */ -#define SOCK_DGRAM SOCK_DGRAM - SOCK_RAW = 3, /* Raw protocol interface. */ -#define SOCK_RAW SOCK_RAW - SOCK_RDM = 4, /* Reliably-delivered messages. */ -#define SOCK_RDM SOCK_RDM - SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based, - datagrams of fixed maximum length. */ -#define SOCK_SEQPACKET SOCK_SEQPACKET - SOCK_PACKET = 10 /* Linux specific way of getting packets - at the dev level. For writing rarp and - other similar things on the user level. */ -#define SOCK_PACKET SOCK_PACKET -}; - -/* Protocol families. */ -#define PF_UNSPEC 0 /* Unspecified. */ -#define PF_LOCAL 1 /* Local to host (pipes and file-domain). */ -#define PF_UNIX PF_LOCAL /* Old BSD name for PF_LOCAL. */ -#define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */ -#define PF_INET 2 /* IP protocol family. */ -#define PF_AX25 3 /* Amateur Radio AX.25. */ -#define PF_IPX 4 /* Novell Internet Protocol. */ -#define PF_APPLETALK 5 /* Appletalk DDP. */ -#define PF_NETROM 6 /* Amateur radio NetROM. */ -#define PF_BRIDGE 7 /* Multiprotocol bridge. */ -#define PF_ATMPVC 8 /* ATM PVCs. */ -#define PF_X25 9 /* Reserved for X.25 project. */ -#if __linux__ -#define PF_INET6 28 /* IP version 6 on linux. */ -#endif - -#if __FreeBSD__ -#define PF_INET6 10 /* IP version 6. */ -#endif - -#define PF_ROSE 11 /* Amateur Radio X.25 PLP. */ -#define PF_DECnet 12 /* Reserved for DECnet project. */ -#define PF_NETBEUI 13 /* Reserved for 802.2LLC project. */ -#define PF_SECURITY 14 /* Security callback pseudo AF. */ -#define PF_KEY 15 /* PF_KEY key management API. */ -#define PF_NETLINK 16 -#define PF_ROUTE PF_NETLINK /* Alias to emulate 4.4BSD. */ -#define PF_PACKET 17 /* Packet family. */ -#define PF_ASH 18 /* Ash. */ -#define PF_ECONET 19 /* Acorn Econet. */ -#define PF_ATMSVC 20 /* ATM SVCs. */ -#define PF_SNA 22 /* Linux SNA Project */ -#define PF_IRDA 23 /* IRDA sockets. */ -#define PF_PPPOX 24 /* PPPoX sockets. */ -#define PF_WANPIPE 25 /* Wanpipe API sockets. */ -#define PF_BLUETOOTH 31 /* Bluetooth sockets. */ -#define PF_MAX 32 /* For now.. */ - - /* Address families. */ -#define AF_UNSPEC PF_UNSPEC -#define AF_LOCAL PF_LOCAL -#define AF_UNIX PF_UNIX -#define AF_FILE PF_FILE -#define AF_INET PF_INET -#define AF_AX25 PF_AX25 -#define AF_IPX PF_IPX -#define AF_APPLETALK PF_APPLETALK -#define AF_NETROM PF_NETROM -#define AF_BRIDGE PF_BRIDGE -#define AF_ATMPVC PF_ATMPVC -#define AF_X25 PF_X25 -#define AF_INET6 PF_INET6 -#define AF_ROSE PF_ROSE -#define AF_DECnet PF_DECnet -#define AF_NETBEUI PF_NETBEUI -#define AF_SECURITY PF_SECURITY -#define AF_KEY PF_KEY -#define AF_NETLINK PF_NETLINK -#define AF_ROUTE PF_ROUTE -#define AF_PACKET PF_PACKET -#define AF_ASH PF_ASH -#define AF_ECONET PF_ECONET -#define AF_ATMSVC PF_ATMSVC -#define AF_SNA PF_SNA -#define AF_IRDA PF_IRDA -#define AF_PPPOX PF_PPPOX -#define AF_WANPIPE PF_WANPIPE -#define AF_BLUETOOTH PF_BLUETOOTH -#define AF_MAX PF_MAX - -#define SOL_RAW 255 -#define SOL_DECNET 261 -#define SOL_X25 262 -#define SOL_PACKET 263 -#define SOL_ATM 264 /* ATM layer (cell level). */ -#define SOL_AAL 265 /* ATM Adaption Layer (packet level). */ -#define SOL_IRDA 266 - -typedef unsigned short int sa_family_t; -#define __SOCKADDR_COMMON(sa_prefix) \ - sa_family_t sa_prefix##family -#define __SOCKADDR_COMMON_SIZE (sizeof (unsigned short int)) - -struct sockaddr - { - __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */ - char sa_data[14]; /* Address data. */ - }; - -typedef unsigned int in_addr_t; -typedef unsigned short in_port_t; -struct in_addr - { - in_addr_t s_addr; - }; - -struct sockaddr_in - { - __SOCKADDR_COMMON (sin_); - in_port_t sin_port; /* Port number. */ - struct in_addr sin_addr; /* Internet address. */ - - /* Pad to size of `struct sockaddr'. */ - unsigned char sin_zero[sizeof (struct sockaddr) - - __SOCKADDR_COMMON_SIZE - - sizeof (in_port_t) - - sizeof (struct in_addr)]; - }; - -struct sockaddr_un -{ - __SOCKADDR_COMMON (sun_); - char sun_path[108]; /* Path name. */ -}; - -struct in6_addr -{ - union - { - uint8_t __u6_addr8[16]; - } __in6_u; -}; - -#define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}} -static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; - -struct sockaddr_in6 -{ - __SOCKADDR_COMMON (sin6_); - in_port_t sin6_port; /* Transport layer port # */ - uint32_t sin6_flowinfo; /* IPv6 flow information */ - struct in6_addr sin6_addr; /* IPv6 address */ - uint32_t sin6_scope_id; /* IPv6 scope-id */ -}; - -/**** Ancillairy messages ****/ - -enum - { - SCM_RIGHTS = 0x01, /* Transfer file descriptors. */ -#define SCM_RIGHTS SCM_RIGHTS -#ifdef __USE_BSD - SCM_CREDENTIALS = 0x02, /* Credentials passing. */ -# define SCM_CREDENTIALS SCM_CREDENTIALS -#endif - __SCM_CONNECT = 0x03 /* Data array is `struct scm_connect'. */ - }; - -struct msghdr - { - void *msg_name; /* Address to send to/receive from. */ - socklen_t msg_namelen; /* Length of address data. */ - - struct iovec *msg_iov; /* Vector of data to send/receive into. */ - size_t msg_iovlen; /* Number of elements in the vector. */ - - void *msg_control; /* Ancillary data (eg BSD filedesc passing). */ - size_t msg_controllen; /* Ancillary data buffer length. */ - - int msg_flags; /* Flags on received message. */ - }; - -/* Structure used for storage of ancillary data object information. */ -struct cmsghdr - { - size_t cmsg_len; /* Length of data in cmsg_data plus length - of cmsghdr structure. */ - int cmsg_level; /* Originating protocol. */ - int cmsg_type; /* Protocol specific type. */ - }; - - -# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1)) -#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg) -#define CMSG_FIRSTHDR(mhdr) \ - ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \ - ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) NULL) -#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \ - & (size_t) ~(sizeof (size_t) - 1)) -#define CMSG_SPACE(len) (CMSG_ALIGN (len) \ - + CMSG_ALIGN (sizeof (struct cmsghdr))) -#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len)) - -#define SOL_SOCKET 1 - -#define SO_DEBUG 1 -#define SO_REUSEADDR 2 -#define SO_TYPE 3 -#define SO_ERROR 4 -#define SO_DONTROUTE 5 -#define SO_BROADCAST 6 -#define SO_SNDBUF 7 -#define SO_RCVBUF 8 -#define SO_KEEPALIVE 9 -#define SO_OOBINLINE 10 -#define SO_NO_CHECK 11 -#define SO_PRIORITY 12 -#define SO_LINGER 13 -#define SO_BSDCOMPAT 14 -/* To add :#define SO_REUSEPORT 15 */ -#define SO_PASSCRED 16 -#define SO_PEERCRED 17 -#define SO_RCVLOWAT 18 -#define SO_SNDLOWAT 19 -#define SO_RCVTIMEO 20 -#define SO_SNDTIMEO 21 - -/* Security levels - as per NRL IPv6 - don't actually do anything */ -#define SO_SECURITY_AUTHENTICATION 22 -#define SO_SECURITY_ENCRYPTION_TRANSPORT 23 -#define SO_SECURITY_ENCRYPTION_NETWORK 24 - -#define SO_BINDTODEVICE 25 - -/* Socket filtering */ -#define SO_ATTACH_FILTER 26 -#define SO_DETACH_FILTER 27 - -#define SO_PEERNAME 28 -#define SO_TIMESTAMP 29 -#define SCM_TIMESTAMP SO_TIMESTAMP - -#define SO_ACCEPTCONN 30 - - - -#ifdef SF_BIGENDIAN -#define IP(t,z,y,x) ((x)|(y)<<8|(z)<<16|(t)<<24) -#define htons(x) (x) -#else -#define IP(x,y,z,t) ((x)|(y)<<8|(z)<<16|(t)<<24) -#define htons(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff)) -#endif - -#define ntohs(x) htons(x) -#define SA_IN(sa, ip, port) do{ (sa).sin_family=PF_INET; \ - (sa).sin_port=(htons(port)); \ - (sa).sin_addr.s_addr=(ip); \ - }while(0) - - -#define O_ACCMODE 0003 -#define O_RDONLY 00 -#define O_WRONLY 01 -#define O_RDWR 02 -#define O_CREAT 0100 /* not fcntl */ -#define O_EXCL 0200 /* not fcntl */ -#define O_NOCTTY 0400 /* not fcntl */ -#define O_TRUNC 01000 /* not fcntl */ -#define O_APPEND 02000 -#define O_NONBLOCK 04000 -#define O_NDELAY O_NONBLOCK -#define O_SYNC 010000 -#define FASYNC 020000 /* fcntl, for BSD compatibility */ -#define O_DIRECT 040000 /* direct disk access hint */ -#define O_LARGEFILE 0100000 -#define O_DIRECTORY 0200000 /* must be a directory */ -#define O_NOFOLLOW 0400000 /* don't follow links */ - -#define F_DUPFD 0 /* dup */ -#define F_GETFD 1 /* get close_on_exec */ -#define F_SETFD 2 /* set/clear close_on_exec */ -#define F_GETFL 3 /* get file->f_flags */ -#define F_SETFL 4 /* set file->f_flags */ -#define F_GETLK 5 -#define F_SETLK 6 -#define F_SETLKW 7 - -#define F_SETOWN 8 /* for sockets. */ -#define F_GETOWN 9 /* for sockets. */ -#define F_SETSIG 10 /* for sockets. */ -#define F_GETSIG 11 /* for sockets. */ - -#define F_GETLK64 12 /* using 'struct flock64' */ -#define F_SETLK64 13 -#define F_SETLKW64 14 - -/* for F_[GET|SET]FL */ -#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ - -/* for posix fcntl() and lockf() */ -#define F_RDLCK 0 -#define F_WRLCK 1 -#define F_UNLCK 2 - -/* for old implementation of bsd flock () */ -#define F_EXLCK 4 /* or 3 */ -#define F_SHLCK 8 /* or 4 */ - -/* for leases */ -#define F_INPROGRESS 16 - -/* operations for bsd flock(), also used by the kernel implementation */ -#define LOCK_SH 1 /* shared lock */ -#define LOCK_EX 2 /* exclusive lock */ -#define LOCK_NB 4 /* or'd with one of the above to prevent - blocking */ -#define LOCK_UN 8 /* remove lock */ - -#define LOCK_MAND 32 /* This is a mandatory flock */ -#define LOCK_READ 64 /* ... Which allows concurrent read operations */ -#define LOCK_WRITE 128 /* ... Which allows concurrent write operations */ -#define LOCK_RW 192 /* ... Which allows concurrent read & write ops */ - - -/**************** from ptrace.h *********/ - - -enum __ptrace_request -{ - /* Indicate that the process making this request should be traced. - All signals received by this process can be intercepted by its - parent, and its parent can use the other `ptrace' requests. */ - PTRACE_TRACEME = 0, -#define PT_TRACE_ME PTRACE_TRACEME - - /* Return the word in the process's text space at address ADDR. */ - PTRACE_PEEKTEXT = 1, -#define PT_READ_I PTRACE_PEEKTEXT - - /* Return the word in the process's data space at address ADDR. */ - PTRACE_PEEKDATA = 2, -#define PT_READ_D PTRACE_PEEKDATA - - /* Return the word in the process's user area at offset ADDR. */ - PTRACE_PEEKUSER = 3, -#define PT_READ_U PTRACE_PEEKUSER - - /* Write the word DATA into the process's text space at address ADDR. */ - PTRACE_POKETEXT = 4, -#define PT_WRITE_I PTRACE_POKETEXT - - /* Write the word DATA into the process's data space at address ADDR. */ - PTRACE_POKEDATA = 5, -#define PT_WRITE_D PTRACE_POKEDATA - - /* Write the word DATA into the process's user area at offset ADDR. */ - PTRACE_POKEUSER = 6, -#define PT_WRITE_U PTRACE_POKEUSER - - /* Continue the process. */ - PTRACE_CONT = 7, -#define PT_CONTINUE PTRACE_CONT - - /* Kill the process. */ - PTRACE_KILL = 8, -#define PT_KILL PTRACE_KILL - - /* Single step the process. - This is not supported on all machines. */ - PTRACE_SINGLESTEP = 9, -#define PT_STEP PTRACE_SINGLESTEP - - /* Get all general purpose registers used by a processes. - This is not supported on all machines. */ - PTRACE_GETREGS = 12, -#define PT_GETREGS PTRACE_GETREGS - - /* Set all general purpose registers used by a processes. - This is not supported on all machines. */ - PTRACE_SETREGS = 13, -#define PT_SETREGS PTRACE_SETREGS - - /* Get all floating point registers used by a processes. - This is not supported on all machines. */ - PTRACE_GETFPREGS = 14, -#define PT_GETFPREGS PTRACE_GETFPREGS - - /* Set all floating point registers used by a processes. - This is not supported on all machines. */ - PTRACE_SETFPREGS = 15, -#define PT_SETFPREGS PTRACE_SETFPREGS - - /* Attach to a process that is already running. */ - PTRACE_ATTACH = 16, -#define PT_ATTACH PTRACE_ATTACH - - /* Detach from a process attached to with PTRACE_ATTACH. */ - PTRACE_DETACH = 17, -#define PT_DETACH PTRACE_DETACH - - /* Get all extended floating point registers used by a processes. - This is not supported on all machines. */ - PTRACE_GETFPXREGS = 18, -#define PT_GETFPXREGS PTRACE_GETFPXREGS - - /* Set all extended floating point registers used by a processes. - This is not supported on all machines. */ - PTRACE_SETFPXREGS = 19, -#define PT_SETFPXREGS PTRACE_SETFPXREGS - - /* Continue and stop at the next (return from) syscall. */ - PTRACE_SYSCALL = 24 -#define PT_SYSCALL PTRACE_SYSCALL -}; - - -/************************ ioctl ******************/ -/* from asm/ioctl.h */ - -#define _IOC_NRBITS 8 -#define _IOC_TYPEBITS 8 -#define _IOC_SIZEBITS 14 -#define _IOC_DIRBITS 2 - -#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) -#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) -#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) -#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) - -#define _IOC_NRSHIFT 0 -#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) -#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) -#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) - -/* - * * Direction bits. - * */ -#define _IOC_NONE 0U -#define _IOC_WRITE 1U -#define _IOC_READ 2U - -#define _IOC(dir,type,nr,size) \ - (((dir) << _IOC_DIRSHIFT) | \ - ((type) << _IOC_TYPESHIFT) | \ - ((nr) << _IOC_NRSHIFT) | \ - ((size) << _IOC_SIZESHIFT)) - -/* provoke compile error for invalid uses of size argument */ -extern unsigned int __invalid_size_argument_for_IOC; -#define _IOC_TYPECHECK(t) \ - ((sizeof(t) == sizeof(t[1]) && \ - sizeof(t) < (1 << _IOC_SIZEBITS)) ? \ - sizeof(t) : __invalid_size_argument_for_IOC) - - /* used to create numbers */ -#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) -#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size))) -#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) -#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) -#define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) -#define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) -#define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) - - /* used to decode ioctl numbers.. */ -#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) -#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) -#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) -#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) - -/* ...and for the drivers/sound files... */ - -#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) -#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) -#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) -#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) -#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) - -/* from asm/ioctls.h */ - -#define TCGETS 0x5401 -#define TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */ -#define TCSETSW 0x5403 -#define TCSETSF 0x5404 -#define TCGETA 0x5405 -#define TCSETA 0x5406 -#define TCSETAW 0x5407 -#define TCSETAF 0x5408 -#define TCSBRK 0x5409 -#define TCXONC 0x540A -#define TCFLSH 0x540B -#define TIOCEXCL 0x540C -#define TIOCNXCL 0x540D -#define TIOCSCTTY 0x540E -#define TIOCGPGRP 0x540F -#define TIOCSPGRP 0x5410 -#define TIOCOUTQ 0x5411 -#define TIOCSTI 0x5412 -#define TIOCGWINSZ 0x5413 -#define TIOCSWINSZ 0x5414 -#define TIOCMGET 0x5415 -#define TIOCMBIS 0x5416 -#define TIOCMBIC 0x5417 -#define TIOCMSET 0x5418 -#define TIOCGSOFTCAR 0x5419 -#define TIOCSSOFTCAR 0x541A -#define FIONREAD 0x541B -#define TIOCINQ FIONREAD -#define TIOCLINUX 0x541C -#define TIOCCONS 0x541D -#define TIOCGSERIAL 0x541E -#define TIOCSSERIAL 0x541F -#define TIOCPKT 0x5420 -#define FIONBIO 0x5421 -#define TIOCNOTTY 0x5422 -#define TIOCSETD 0x5423 -#define TIOCGETD 0x5424 -#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ -/* #define TIOCTTYGSTRUCT 0x5426 - Former debugging-only ioctl */ -#define TIOCSBRK 0x5427 /* BSD compatibility */ -#define TIOCCBRK 0x5428 /* BSD compatibility */ -#define TIOCGSID 0x5429 /* Return the session ID of FD */ -#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ -#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ - -#define FIONCLEX 0x5450 -#define FIOCLEX 0x5451 -#define FIOASYNC 0x5452 -#define TIOCSERCONFIG 0x5453 -#define TIOCSERGWILD 0x5454 -#define TIOCSERSWILD 0x5455 -#define TIOCGLCKTRMIOS 0x5456 -#define TIOCSLCKTRMIOS 0x5457 -#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ -#define TIOCSERGETLSR 0x5459 /* Get line status register */ -#define TIOCSERGETMULTI 0x545A /* Get multiport config */ -#define TIOCSERSETMULTI 0x545B /* Set multiport config */ - -#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ -#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ -#define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ -#define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ -#define FIOQSIZE 0x5460 - -/* Used for packet mode */ -#define TIOCPKT_DATA 0 -#define TIOCPKT_FLUSHREAD 1 -#define TIOCPKT_FLUSHWRITE 2 -#define TIOCPKT_STOP 4 -#define TIOCPKT_START 8 -#define TIOCPKT_NOSTOP 16 -#define TIOCPKT_DOSTOP 32 - -#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ - - - -/********************** termio *******************/ -/* from /usr/include/asm/termios.h */ - -struct winsize { - unsigned short ws_row; - unsigned short ws_col; - unsigned short ws_xpixel; - unsigned short ws_ypixel; -}; - -#define NCC 8 -struct termio { - unsigned short c_iflag; /* input mode flags */ - unsigned short c_oflag; /* output mode flags */ - unsigned short c_cflag; /* control mode flags */ - unsigned short c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[NCC]; /* control characters */ -}; - -/* modem lines */ -#define TIOCM_LE 0x001 -#define TIOCM_DTR 0x002 -#define TIOCM_RTS 0x004 -#define TIOCM_ST 0x008 -#define TIOCM_SR 0x010 -#define TIOCM_CTS 0x020 -#define TIOCM_CAR 0x040 -#define TIOCM_RNG 0x080 -#define TIOCM_DSR 0x100 -#define TIOCM_CD TIOCM_CAR -#define TIOCM_RI TIOCM_RNG -#define TIOCM_OUT1 0x2000 -#define TIOCM_OUT2 0x4000 -#define TIOCM_LOOP 0x8000 - -/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ - -/* line disciplines */ -#define N_TTY 0 -#define N_SLIP 1 -#define N_MOUSE 2 -#define N_PPP 3 -#define N_STRIP 4 -#define N_AX25 5 -#define N_X25 6 /* X.25 async */ -#define N_6PACK 7 -#define N_MASC 8 /* Reserved for Mobitex module */ -#define N_R3964 9 /* Reserved for Simatic R3964 module */ -#define N_PROFIBUS_FDL 10 /* Reserved for Profibus */ -#define N_IRDA 11 /* Linux IR - http://irda.sourceforge.net/ */ -#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */ -#define N_HDLC 13 /* synchronous HDLC */ -#define N_SYNC_PPP 14 /* synchronous PPP */ -#define N_HCI 15 /* Bluetooth HCI UART */ - -typedef unsigned char cc_t; -typedef unsigned int speed_t; -typedef unsigned int tcflag_t; - -#define NCCS 19 -struct termios { - tcflag_t c_iflag; /* input mode flags */ - tcflag_t c_oflag; /* output mode flags */ - tcflag_t c_cflag; /* control mode flags */ - tcflag_t c_lflag; /* local mode flags */ - cc_t c_line; /* line discipline */ - cc_t c_cc[NCCS]; /* control characters */ -}; - -/* c_cc characters */ -#define VINTR 0 -#define VQUIT 1 -#define VERASE 2 -#define VKILL 3 -#define VEOF 4 -#define VTIME 5 -#define VMIN 6 -#define VSWTC 7 -#define VSTART 8 -#define VSTOP 9 -#define VSUSP 10 -#define VEOL 11 -#define VREPRINT 12 -#define VDISCARD 13 -#define VWERASE 14 -#define VLNEXT 15 -#define VEOL2 16 - -/* c_iflag bits */ -#define IGNBRK 0000001 -#define BRKINT 0000002 -#define IGNPAR 0000004 -#define PARMRK 0000010 -#define INPCK 0000020 -#define ISTRIP 0000040 -#define INLCR 0000100 -#define IGNCR 0000200 -#define ICRNL 0000400 -#define IUCLC 0001000 -#define IXON 0002000 -#define IXANY 0004000 -#define IXOFF 0010000 -#define IMAXBEL 0020000 - -/* c_oflag bits */ -#define OPOST 0000001 -#define OLCUC 0000002 -#define ONLCR 0000004 -#define OCRNL 0000010 -#define ONOCR 0000020 -#define ONLRET 0000040 -#define OFILL 0000100 -#define OFDEL 0000200 -#define NLDLY 0000400 -#define NL0 0000000 -#define NL1 0000400 -#define CRDLY 0003000 -#define CR0 0000000 -#define CR1 0001000 -#define CR2 0002000 -#define CR3 0003000 -#define TABDLY 0014000 -#define TAB0 0000000 -#define TAB1 0004000 -#define TAB2 0010000 -#define TAB3 0014000 -#define XTABS 0014000 -#define BSDLY 0020000 -#define BS0 0000000 -#define BS1 0020000 -#define VTDLY 0040000 -#define VT0 0000000 -#define VT1 0040000 -#define FFDLY 0100000 -#define FF0 0000000 -#define FF1 0100000 - -/* c_cflag bit meaning */ -#define CBAUD 0010017 -#define B0 0000000 /* hang up */ -#define B50 0000001 -#define B75 0000002 -#define B110 0000003 -#define B134 0000004 -#define B150 0000005 -#define B200 0000006 -#define B300 0000007 -#define B600 0000010 -#define B1200 0000011 -#define B1800 0000012 -#define B2400 0000013 -#define B4800 0000014 -#define B9600 0000015 -#define B19200 0000016 -#define B38400 0000017 -#define EXTA B19200 -#define EXTB B38400 -#define CSIZE 0000060 -#define CS5 0000000 -#define CS6 0000020 -#define CS7 0000040 -#define CS8 0000060 -#define CSTOPB 0000100 -#define CREAD 0000200 -#define PARENB 0000400 -#define PARODD 0001000 -#define HUPCL 0002000 -#define CLOCAL 0004000 -#define CBAUDEX 0010000 -#define B57600 0010001 -#define B115200 0010002 -#define B230400 0010003 -#define B460800 0010004 -#define B500000 0010005 -#define B576000 0010006 -#define B921600 0010007 -#define B1000000 0010010 -#define B1152000 0010011 -#define B1500000 0010012 -#define B2000000 0010013 -#define B2500000 0010014 -#define B3000000 0010015 -#define B3500000 0010016 -#define B4000000 0010017 -#define CIBAUD 002003600000 /* input baud rate (not used) */ -#define CMSPAR 010000000000 /* mark or space (stick) parity */ -#define CRTSCTS 020000000000 /* flow control */ - -/* c_lflag bits */ -#define ISIG 0000001 -#define ICANON 0000002 -#define XCASE 0000004 -#define ECHO 0000010 -#define ECHOE 0000020 -#define ECHOK 0000040 -#define ECHONL 0000100 -#define NOFLSH 0000200 -#define TOSTOP 0000400 -#define ECHOCTL 0001000 -#define ECHOPRT 0002000 -#define ECHOKE 0004000 -#define FLUSHO 0010000 -#define PENDIN 0040000 -#define IEXTEN 0100000 - -/* tcflow() and TCXONC use these */ -#define TCOOFF 0 -#define TCOON 1 -#define TCIOFF 2 -#define TCION 3 - -/* tcflush() and TCFLSH use these */ -#define TCIFLUSH 0 -#define TCOFLUSH 1 -#define TCIOFLUSH 2 - -/* tcsetattr uses these */ -#define TCSANOW 0 -#define TCSADRAIN 1 -#define TCSAFLUSH 2 - - - -#endif /* SFTYPES_H */ - -/****************** Elf headers ***************/ -/* From /usr/include/elf.h */ - - - -/* Type for a 16-bit quantity. */ -typedef uint16_t Elf32_Half; -typedef uint16_t Elf64_Half; - -/* Types for signed and unsigned 32-bit quantities. */ -typedef uint32_t Elf32_Word; -typedef int32_t Elf32_Sword; -typedef uint32_t Elf64_Word; -typedef int32_t Elf64_Sword; - -/* Types for signed and unsigned 64-bit quantities. */ -typedef uint64_t Elf32_Xword; -typedef int64_t Elf32_Sxword; -typedef uint64_t Elf64_Xword; -typedef int64_t Elf64_Sxword; - -/* Type of addresses. */ -typedef uint32_t Elf32_Addr; -typedef uint64_t Elf64_Addr; - -/* Type of file offsets. */ -typedef uint32_t Elf32_Off; -typedef uint64_t Elf64_Off; - -/* Type for section indices, which are 16-bit quantities. */ -typedef uint16_t Elf32_Section; -typedef uint16_t Elf64_Section; - -/* Type for version symbol information. */ -typedef Elf32_Half Elf32_Versym; -typedef Elf64_Half Elf64_Versym; - - -/* The ELF file header. This appears at the start of every ELF file. */ - -#define EI_NIDENT (16) - -typedef struct -{ - unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ - Elf32_Half e_type; /* Object file type */ - Elf32_Half e_machine; /* Architecture */ - Elf32_Word e_version; /* Object file version */ - Elf32_Addr e_entry; /* Entry point virtual address */ - Elf32_Off e_phoff; /* Program header table file offset */ - Elf32_Off e_shoff; /* Section header table file offset */ - Elf32_Word e_flags; /* Processor-specific flags */ - Elf32_Half e_ehsize; /* ELF header size in bytes */ - Elf32_Half e_phentsize; /* Program header table entry size */ - Elf32_Half e_phnum; /* Program header table entry count */ - Elf32_Half e_shentsize; /* Section header table entry size */ - Elf32_Half e_shnum; /* Section header table entry count */ - Elf32_Half e_shstrndx; /* Section header string table index */ -} Elf32_Ehdr; - -typedef struct -{ - unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ - Elf64_Half e_type; /* Object file type */ - Elf64_Half e_machine; /* Architecture */ - Elf64_Word e_version; /* Object file version */ - Elf64_Addr e_entry; /* Entry point virtual address */ - Elf64_Off e_phoff; /* Program header table file offset */ - Elf64_Off e_shoff; /* Section header table file offset */ - Elf64_Word e_flags; /* Processor-specific flags */ - Elf64_Half e_ehsize; /* ELF header size in bytes */ - Elf64_Half e_phentsize; /* Program header table entry size */ - Elf64_Half e_phnum; /* Program header table entry count */ - Elf64_Half e_shentsize; /* Section header table entry size */ - Elf64_Half e_shnum; /* Section header table entry count */ - Elf64_Half e_shstrndx; /* Section header string table index */ -} Elf64_Ehdr; - -/* Fields in the e_ident array. The EI_* macros are indices into the - array. The macros under each EI_* macro are the values the byte - may have. */ - -#define EI_MAG0 0 /* File identification byte 0 index */ -#define ELFMAG0 0x7f /* Magic number byte 0 */ - -#define EI_MAG1 1 /* File identification byte 1 index */ -#define ELFMAG1 'E' /* Magic number byte 1 */ - -#define EI_MAG2 2 /* File identification byte 2 index */ -#define ELFMAG2 'L' /* Magic number byte 2 */ - -#define EI_MAG3 3 /* File identification byte 3 index */ -#define ELFMAG3 'F' /* Magic number byte 3 */ - -/* Conglomeration of the identification bytes, for easy testing as a word. */ -#define ELFMAG "\177ELF" -#define SELFMAG 4 - -#define EI_CLASS 4 /* File class byte index */ -#define ELFCLASSNONE 0 /* Invalid class */ -#define ELFCLASS32 1 /* 32-bit objects */ -#define ELFCLASS64 2 /* 64-bit objects */ -#define ELFCLASSNUM 3 - -#define EI_DATA 5 /* Data encoding byte index */ -#define ELFDATANONE 0 /* Invalid data encoding */ -#define ELFDATA2LSB 1 /* 2's complement, little endian */ -#define ELFDATA2MSB 2 /* 2's complement, big endian */ -#define ELFDATANUM 3 - -#define EI_VERSION 6 /* File version byte index */ - /* Value must be EV_CURRENT */ - -#define EI_OSABI 7 /* OS ABI identification */ -#define ELFOSABI_NONE 0 /* UNIX System V ABI */ -#define ELFOSABI_SYSV 0 /* Alias. */ -#define ELFOSABI_HPUX 1 /* HP-UX */ -#define ELFOSABI_NETBSD 2 /* NetBSD. */ -#define ELFOSABI_LINUX 3 /* Linux. */ -#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */ -#define ELFOSABI_AIX 7 /* IBM AIX. */ -#define ELFOSABI_IRIX 8 /* SGI Irix. */ -#define ELFOSABI_FREEBSD 9 /* FreeBSD. */ -#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */ -#define ELFOSABI_MODESTO 11 /* Novell Modesto. */ -#define ELFOSABI_OPENBSD 12 /* OpenBSD. */ -#define ELFOSABI_ARM 97 /* ARM */ -#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ - -#define EI_ABIVERSION 8 /* ABI version */ - -#define EI_PAD 9 /* Byte index of padding bytes */ - -/* Legal values for e_type (object file type). */ - -#define ET_NONE 0 /* No file type */ -#define ET_REL 1 /* Relocatable file */ -#define ET_EXEC 2 /* Executable file */ -#define ET_DYN 3 /* Shared object file */ -#define ET_CORE 4 /* Core file */ -#define ET_NUM 5 /* Number of defined types */ -#define ET_LOOS 0xfe00 /* OS-specific range start */ -#define ET_HIOS 0xfeff /* OS-specific range end */ -#define ET_LOPROC 0xff00 /* Processor-specific range start */ -#define ET_HIPROC 0xffff /* Processor-specific range end */ - -/* Legal values for e_machine (architecture). */ - -#define EM_NONE 0 /* No machine */ -#define EM_M32 1 /* AT&T WE 32100 */ -#define EM_SPARC 2 /* SUN SPARC */ -#define EM_386 3 /* Intel 80386 */ -#define EM_68K 4 /* Motorola m68k family */ -#define EM_88K 5 /* Motorola m88k family */ -#define EM_860 7 /* Intel 80860 */ -#define EM_MIPS 8 /* MIPS R3000 big-endian */ -#define EM_S370 9 /* IBM System/370 */ -#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ - -#define EM_PARISC 15 /* HPPA */ -#define EM_VPP500 17 /* Fujitsu VPP500 */ -#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ -#define EM_960 19 /* Intel 80960 */ -#define EM_PPC 20 /* PowerPC */ -#define EM_PPC64 21 /* PowerPC 64-bit */ -#define EM_S390 22 /* IBM S390 */ - -#define EM_V800 36 /* NEC V800 series */ -#define EM_FR20 37 /* Fujitsu FR20 */ -#define EM_RH32 38 /* TRW RH-32 */ -#define EM_RCE 39 /* Motorola RCE */ -#define EM_ARM 40 /* ARM */ -#define EM_FAKE_ALPHA 41 /* Digital Alpha */ -#define EM_SH 42 /* Hitachi SH */ -#define EM_SPARCV9 43 /* SPARC v9 64-bit */ -#define EM_TRICORE 44 /* Siemens Tricore */ -#define EM_ARC 45 /* Argonaut RISC Core */ -#define EM_H8_300 46 /* Hitachi H8/300 */ -#define EM_H8_300H 47 /* Hitachi H8/300H */ -#define EM_H8S 48 /* Hitachi H8S */ -#define EM_H8_500 49 /* Hitachi H8/500 */ -#define EM_IA_64 50 /* Intel Merced */ -#define EM_MIPS_X 51 /* Stanford MIPS-X */ -#define EM_COLDFIRE 52 /* Motorola Coldfire */ -#define EM_68HC12 53 /* Motorola M68HC12 */ -#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/ -#define EM_PCP 55 /* Siemens PCP */ -#define EM_NCPU 56 /* Sony nCPU embeeded RISC */ -#define EM_NDR1 57 /* Denso NDR1 microprocessor */ -#define EM_STARCORE 58 /* Motorola Start*Core processor */ -#define EM_ME16 59 /* Toyota ME16 processor */ -#define EM_ST100 60 /* STMicroelectronic ST100 processor */ -#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/ -#define EM_X86_64 62 /* AMD x86-64 architecture */ -#define EM_PDSP 63 /* Sony DSP Processor */ - -#define EM_FX66 66 /* Siemens FX66 microcontroller */ -#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ -#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ -#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ -#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ -#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ -#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ -#define EM_SVX 73 /* Silicon Graphics SVx */ -#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */ -#define EM_VAX 75 /* Digital VAX */ -#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ -#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */ -#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ -#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ -#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ -#define EM_HUANY 81 /* Harvard University machine-independent object files */ -#define EM_PRISM 82 /* SiTera Prism */ -#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ -#define EM_FR30 84 /* Fujitsu FR30 */ -#define EM_D10V 85 /* Mitsubishi D10V */ -#define EM_D30V 86 /* Mitsubishi D30V */ -#define EM_V850 87 /* NEC v850 */ -#define EM_M32R 88 /* Mitsubishi M32R */ -#define EM_MN10300 89 /* Matsushita MN10300 */ -#define EM_MN10200 90 /* Matsushita MN10200 */ -#define EM_PJ 91 /* picoJava */ -#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ -#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ -#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ -#define EM_NUM 95 - -/* If it is necessary to assign new unofficial EM_* values, please - pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the - chances of collision with official or non-GNU unofficial values. */ - -#define EM_ALPHA 0x9026 - -/* Legal values for e_version (version). */ - -#define EV_NONE 0 /* Invalid ELF version */ -#define EV_CURRENT 1 /* Current version */ -#define EV_NUM 2 - -/* Section header. */ - -typedef struct -{ - Elf32_Word sh_name; /* Section name (string tbl index) */ - Elf32_Word sh_type; /* Section type */ - Elf32_Word sh_flags; /* Section flags */ - Elf32_Addr sh_addr; /* Section virtual addr at execution */ - Elf32_Off sh_offset; /* Section file offset */ - Elf32_Word sh_size; /* Section size in bytes */ - Elf32_Word sh_link; /* Link to another section */ - Elf32_Word sh_info; /* Additional section information */ - Elf32_Word sh_addralign; /* Section alignment */ - Elf32_Word sh_entsize; /* Entry size if section holds table */ -} Elf32_Shdr; - -typedef struct -{ - Elf64_Word sh_name; /* Section name (string tbl index) */ - Elf64_Word sh_type; /* Section type */ - Elf64_Xword sh_flags; /* Section flags */ - Elf64_Addr sh_addr; /* Section virtual addr at execution */ - Elf64_Off sh_offset; /* Section file offset */ - Elf64_Xword sh_size; /* Section size in bytes */ - Elf64_Word sh_link; /* Link to another section */ - Elf64_Word sh_info; /* Additional section information */ - Elf64_Xword sh_addralign; /* Section alignment */ - Elf64_Xword sh_entsize; /* Entry size if section holds table */ -} Elf64_Shdr; - -/* Special section indices. */ - -#define SHN_UNDEF 0 /* Undefined section */ -#define SHN_LORESERVE 0xff00 /* Start of reserved indices */ -#define SHN_LOPROC 0xff00 /* Start of processor-specific */ -#define SHN_BEFORE 0xff00 /* Order section before all others - (Solaris). */ -#define SHN_AFTER 0xff01 /* Order section after all others - (Solaris). */ -#define SHN_HIPROC 0xff1f /* End of processor-specific */ -#define SHN_LOOS 0xff20 /* Start of OS-specific */ -#define SHN_HIOS 0xff3f /* End of OS-specific */ -#define SHN_ABS 0xfff1 /* Associated symbol is absolute */ -#define SHN_COMMON 0xfff2 /* Associated symbol is common */ -#define SHN_XINDEX 0xffff /* Index is in extra table. */ -#define SHN_HIRESERVE 0xffff /* End of reserved indices */ - -/* Legal values for sh_type (section type). */ - -#define SHT_NULL 0 /* Section header table entry unused */ -#define SHT_PROGBITS 1 /* Program data */ -#define SHT_SYMTAB 2 /* Symbol table */ -#define SHT_STRTAB 3 /* String table */ -#define SHT_RELA 4 /* Relocation entries with addends */ -#define SHT_HASH 5 /* Symbol hash table */ -#define SHT_DYNAMIC 6 /* Dynamic linking information */ -#define SHT_NOTE 7 /* Notes */ -#define SHT_NOBITS 8 /* Program space with no data (bss) */ -#define SHT_REL 9 /* Relocation entries, no addends */ -#define SHT_SHLIB 10 /* Reserved */ -#define SHT_DYNSYM 11 /* Dynamic linker symbol table */ -#define SHT_INIT_ARRAY 14 /* Array of constructors */ -#define SHT_FINI_ARRAY 15 /* Array of destructors */ -#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */ -#define SHT_GROUP 17 /* Section group */ -#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */ -#define SHT_NUM 19 /* Number of defined types. */ -#define SHT_LOOS 0x60000000 /* Start OS-specific */ -#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */ -#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */ -#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */ -#define SHT_SUNW_move 0x6ffffffa -#define SHT_SUNW_COMDAT 0x6ffffffb -#define SHT_SUNW_syminfo 0x6ffffffc -#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ -#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ -#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ -#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */ -#define SHT_HIOS 0x6fffffff /* End OS-specific type */ -#define SHT_LOPROC 0x70000000 /* Start of processor-specific */ -#define SHT_HIPROC 0x7fffffff /* End of processor-specific */ -#define SHT_LOUSER 0x80000000 /* Start of application-specific */ -#define SHT_HIUSER 0x8fffffff /* End of application-specific */ - -/* Legal values for sh_flags (section flags). */ - -#define SHF_WRITE (1 << 0) /* Writable */ -#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ -#define SHF_EXECINSTR (1 << 2) /* Executable */ -#define SHF_MERGE (1 << 4) /* Might be merged */ -#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */ -#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */ -#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */ -#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling - required */ -#define SHF_GROUP (1 << 9) /* Section is member of a group. */ -#define SHF_TLS (1 << 10) /* Section hold thread-local data. */ -#define SHF_MASKOS 0x0ff00000 /* OS-specific. */ -#define SHF_MASKPROC 0xf0000000 /* Processor-specific */ -#define SHF_ORDERED (1 << 30) /* Special ordering requirement - (Solaris). */ -#define SHF_EXCLUDE (1 << 31) /* Section is excluded unless - referenced or allocated (Solaris).*/ - -/* Section group handling. */ -#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */ - -/* Symbol table entry. */ - -typedef struct -{ - Elf32_Word st_name; /* Symbol name (string tbl index) */ - Elf32_Addr st_value; /* Symbol value */ - Elf32_Word st_size; /* Symbol size */ - unsigned char st_info; /* Symbol type and binding */ - unsigned char st_other; /* Symbol visibility */ - Elf32_Section st_shndx; /* Section index */ -} Elf32_Sym; - -typedef struct -{ - Elf64_Word st_name; /* Symbol name (string tbl index) */ - unsigned char st_info; /* Symbol type and binding */ - unsigned char st_other; /* Symbol visibility */ - Elf64_Section st_shndx; /* Section index */ - Elf64_Addr st_value; /* Symbol value */ - Elf64_Xword st_size; /* Symbol size */ -} Elf64_Sym; - -/* The syminfo section if available contains additional information about - every dynamic symbol. */ - -typedef struct -{ - Elf32_Half si_boundto; /* Direct bindings, symbol bound to */ - Elf32_Half si_flags; /* Per symbol flags */ -} Elf32_Syminfo; - -typedef struct -{ - Elf64_Half si_boundto; /* Direct bindings, symbol bound to */ - Elf64_Half si_flags; /* Per symbol flags */ -} Elf64_Syminfo; - -/* Possible values for si_boundto. */ -#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */ -#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */ -#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */ - -/* Possible bitmasks for si_flags. */ -#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */ -#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */ -#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */ -#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy - loaded */ -/* Syminfo version values. */ -#define SYMINFO_NONE 0 -#define SYMINFO_CURRENT 1 -#define SYMINFO_NUM 2 - - -/* How to extract and insert information held in the st_info field. */ - -#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) -#define ELF32_ST_TYPE(val) ((val) & 0xf) -#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) - -/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */ -#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) -#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) -#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) - -/* Legal values for ST_BIND subfield of st_info (symbol binding). */ - -#define STB_LOCAL 0 /* Local symbol */ -#define STB_GLOBAL 1 /* Global symbol */ -#define STB_WEAK 2 /* Weak symbol */ -#define STB_NUM 3 /* Number of defined types. */ -#define STB_LOOS 10 /* Start of OS-specific */ -#define STB_HIOS 12 /* End of OS-specific */ -#define STB_LOPROC 13 /* Start of processor-specific */ -#define STB_HIPROC 15 /* End of processor-specific */ - -/* Legal values for ST_TYPE subfield of st_info (symbol type). */ - -#define STT_NOTYPE 0 /* Symbol type is unspecified */ -#define STT_OBJECT 1 /* Symbol is a data object */ -#define STT_FUNC 2 /* Symbol is a code object */ -#define STT_SECTION 3 /* Symbol associated with a section */ -#define STT_FILE 4 /* Symbol's name is file name */ -#define STT_COMMON 5 /* Symbol is a common data object */ -#define STT_TLS 6 /* Symbol is thread-local data object*/ -#define STT_NUM 7 /* Number of defined types. */ -#define STT_LOOS 10 /* Start of OS-specific */ -#define STT_HIOS 12 /* End of OS-specific */ -#define STT_LOPROC 13 /* Start of processor-specific */ -#define STT_HIPROC 15 /* End of processor-specific */ - - -/* Symbol table indices are found in the hash buckets and chain table - of a symbol hash table section. This special index value indicates - the end of a chain, meaning no further symbols are found in that bucket. */ - -#define STN_UNDEF 0 /* End of a chain. */ - - -/* How to extract and insert information held in the st_other field. */ - -#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) - -/* For ELF64 the definitions are the same. */ -#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) - -/* Symbol visibility specification encoded in the st_other field. */ -#define STV_DEFAULT 0 /* Default symbol visibility rules */ -#define STV_INTERNAL 1 /* Processor specific hidden class */ -#define STV_HIDDEN 2 /* Sym unavailable in other modules */ -#define STV_PROTECTED 3 /* Not preemptible, not exported */ - - -/* Relocation table entry without addend (in section of type SHT_REL). */ - -typedef struct -{ - Elf32_Addr r_offset; /* Address */ - Elf32_Word r_info; /* Relocation type and symbol index */ -} Elf32_Rel; - -/* I have seen two different definitions of the Elf64_Rel and - Elf64_Rela structures, so we'll leave them out until Novell (or - whoever) gets their act together. */ -/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */ - -typedef struct -{ - Elf64_Addr r_offset; /* Address */ - Elf64_Xword r_info; /* Relocation type and symbol index */ -} Elf64_Rel; - -/* Relocation table entry with addend (in section of type SHT_RELA). */ - -typedef struct -{ - Elf32_Addr r_offset; /* Address */ - Elf32_Word r_info; /* Relocation type and symbol index */ - Elf32_Sword r_addend; /* Addend */ -} Elf32_Rela; - -typedef struct -{ - Elf64_Addr r_offset; /* Address */ - Elf64_Xword r_info; /* Relocation type and symbol index */ - Elf64_Sxword r_addend; /* Addend */ -} Elf64_Rela; - -/* How to extract and insert information held in the r_info field. */ - -#define ELF32_R_SYM(val) ((val) >> 8) -#define ELF32_R_TYPE(val) ((val) & 0xff) -#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) - -#define ELF64_R_SYM(i) ((i) >> 32) -#define ELF64_R_TYPE(i) ((i) & 0xffffffff) -#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) - -/* Program segment header. */ - -typedef struct -{ - Elf32_Word p_type; /* Segment type */ - Elf32_Off p_offset; /* Segment file offset */ - Elf32_Addr p_vaddr; /* Segment virtual address */ - Elf32_Addr p_paddr; /* Segment physical address */ - Elf32_Word p_filesz; /* Segment size in file */ - Elf32_Word p_memsz; /* Segment size in memory */ - Elf32_Word p_flags; /* Segment flags */ - Elf32_Word p_align; /* Segment alignment */ -} Elf32_Phdr; - -typedef struct -{ - Elf64_Word p_type; /* Segment type */ - Elf64_Word p_flags; /* Segment flags */ - Elf64_Off p_offset; /* Segment file offset */ - Elf64_Addr p_vaddr; /* Segment virtual address */ - Elf64_Addr p_paddr; /* Segment physical address */ - Elf64_Xword p_filesz; /* Segment size in file */ - Elf64_Xword p_memsz; /* Segment size in memory */ - Elf64_Xword p_align; /* Segment alignment */ -} Elf64_Phdr; - -/* Legal values for p_type (segment type). */ - -#define PT_NULL 0 /* Program header table entry unused */ -#define PT_LOAD 1 /* Loadable program segment */ -#define PT_DYNAMIC 2 /* Dynamic linking information */ -#define PT_INTERP 3 /* Program interpreter */ -#define PT_NOTE 4 /* Auxiliary information */ -#define PT_SHLIB 5 /* Reserved */ -#define PT_PHDR 6 /* Entry for header table itself */ -#define PT_TLS 7 /* Thread-local storage segment */ -#define PT_NUM 8 /* Number of defined types */ -#define PT_LOOS 0x60000000 /* Start of OS-specific */ -#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */ -#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */ -#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */ -#define PT_LOSUNW 0x6ffffffa -#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ -#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */ -#define PT_HISUNW 0x6fffffff -#define PT_HIOS 0x6fffffff /* End of OS-specific */ -#define PT_LOPROC 0x70000000 /* Start of processor-specific */ -#define PT_HIPROC 0x7fffffff /* End of processor-specific */ - -/* Legal values for p_flags (segment flags). */ - -#define PF_X (1 << 0) /* Segment is executable */ -#define PF_W (1 << 1) /* Segment is writable */ -#define PF_R (1 << 2) /* Segment is readable */ -#define PF_MASKOS 0x0ff00000 /* OS-specific */ -#define PF_MASKPROC 0xf0000000 /* Processor-specific */ - -/* Legal values for note segment descriptor types for core files. */ - -#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ -#define NT_FPREGSET 2 /* Contains copy of fpregset struct */ -#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */ -#define NT_PRXREG 4 /* Contains copy of prxregset struct */ -#define NT_TASKSTRUCT 4 /* Contains copy of task structure */ -#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */ -#define NT_AUXV 6 /* Contains copy of auxv array */ -#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */ -#define NT_ASRS 8 /* Contains copy of asrset struct */ -#define NT_PSTATUS 10 /* Contains copy of pstatus struct */ -#define NT_PSINFO 13 /* Contains copy of psinfo struct */ -#define NT_PRCRED 14 /* Contains copy of prcred struct */ -#define NT_UTSNAME 15 /* Contains copy of utsname struct */ -#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */ -#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */ -#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct*/ - -/* Legal values for the note segment descriptor types for object files. */ - -#define NT_VERSION 1 /* Contains a version string. */ - - -/* Dynamic section entry. */ - -typedef struct -{ - Elf32_Sword d_tag; /* Dynamic entry type */ - union - { - Elf32_Word d_val; /* Integer value */ - Elf32_Addr d_ptr; /* Address value */ - } d_un; -} Elf32_Dyn; - -typedef struct -{ - Elf64_Sxword d_tag; /* Dynamic entry type */ - union - { - Elf64_Xword d_val; /* Integer value */ - Elf64_Addr d_ptr; /* Address value */ - } d_un; -} Elf64_Dyn; - -/* Legal values for d_tag (dynamic entry type). */ - -#define DT_NULL 0 /* Marks end of dynamic section */ -#define DT_NEEDED 1 /* Name of needed library */ -#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */ -#define DT_PLTGOT 3 /* Processor defined value */ -#define DT_HASH 4 /* Address of symbol hash table */ -#define DT_STRTAB 5 /* Address of string table */ -#define DT_SYMTAB 6 /* Address of symbol table */ -#define DT_RELA 7 /* Address of Rela relocs */ -#define DT_RELASZ 8 /* Total size of Rela relocs */ -#define DT_RELAENT 9 /* Size of one Rela reloc */ -#define DT_STRSZ 10 /* Size of string table */ -#define DT_SYMENT 11 /* Size of one symbol table entry */ -#define DT_INIT 12 /* Address of init function */ -#define DT_FINI 13 /* Address of termination function */ -#define DT_SONAME 14 /* Name of shared object */ -#define DT_RPATH 15 /* Library search path (deprecated) */ -#define DT_SYMBOLIC 16 /* Start symbol search here */ -#define DT_REL 17 /* Address of Rel relocs */ -#define DT_RELSZ 18 /* Total size of Rel relocs */ -#define DT_RELENT 19 /* Size of one Rel reloc */ -#define DT_PLTREL 20 /* Type of reloc in PLT */ -#define DT_DEBUG 21 /* For debugging; unspecified */ -#define DT_TEXTREL 22 /* Reloc might modify .text */ -#define DT_JMPREL 23 /* Address of PLT relocs */ -#define DT_BIND_NOW 24 /* Process relocations of object */ -#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */ -#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */ -#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */ -#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */ -#define DT_RUNPATH 29 /* Library search path */ -#define DT_FLAGS 30 /* Flags for the object being loaded */ -#define DT_ENCODING 32 /* Start of encoded range */ -#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ -#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ -#define DT_NUM 34 /* Number used */ -#define DT_LOOS 0x6000000d /* Start of OS-specific */ -#define DT_HIOS 0x6ffff000 /* End of OS-specific */ -#define DT_LOPROC 0x70000000 /* Start of processor-specific */ -#define DT_HIPROC 0x7fffffff /* End of processor-specific */ -#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */ - -/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the - Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's - approach. */ -#define DT_VALRNGLO 0x6ffffd00 -#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */ -#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */ -#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */ -#define DT_CHECKSUM 0x6ffffdf8 -#define DT_PLTPADSZ 0x6ffffdf9 -#define DT_MOVEENT 0x6ffffdfa -#define DT_MOVESZ 0x6ffffdfb -#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */ -#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting - the following DT_* entry. */ -#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */ -#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */ -#define DT_VALRNGHI 0x6ffffdff -#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */ -#define DT_VALNUM 12 - -/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the - Dyn.d_un.d_ptr field of the Elf*_Dyn structure. - - If any adjustment is made to the ELF object after it has been - built these entries will need to be adjusted. */ -#define DT_ADDRRNGLO 0x6ffffe00 -#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */ -#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */ -#define DT_CONFIG 0x6ffffefa /* Configuration information. */ -#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */ -#define DT_AUDIT 0x6ffffefc /* Object auditing. */ -#define DT_PLTPAD 0x6ffffefd /* PLT padding. */ -#define DT_MOVETAB 0x6ffffefe /* Move table. */ -#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */ -#define DT_ADDRRNGHI 0x6ffffeff -#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */ -#define DT_ADDRNUM 10 - -/* The versioning entry types. The next are defined as part of the - GNU extension. */ -#define DT_VERSYM 0x6ffffff0 - -#define DT_RELACOUNT 0x6ffffff9 -#define DT_RELCOUNT 0x6ffffffa - -/* These were chosen by Sun. */ -#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */ -#define DT_VERDEF 0x6ffffffc /* Address of version definition - table */ -#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */ -#define DT_VERNEED 0x6ffffffe /* Address of table with needed - versions */ -#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */ -#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ -#define DT_VERSIONTAGNUM 16 - -/* Sun added these machine-independent extensions in the "processor-specific" - range. Be compatible. */ -#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */ -#define DT_FILTER 0x7fffffff /* Shared object to get values from */ -#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) -#define DT_EXTRANUM 3 - -/* Values of `d_un.d_val' in the DT_FLAGS entry. */ -#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */ -#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ -#define DF_TEXTREL 0x00000004 /* Object contains text relocations */ -#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ -#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */ - -/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 - entry in the dynamic section. */ -#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ -#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ -#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ -#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ -#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/ -#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/ -#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ -#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ -#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ -#define DF_1_TRANS 0x00000200 -#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ -#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ -#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */ -#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/ -#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */ -#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */ -#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */ - -/* Flags for the feature selection in DT_FEATURE_1. */ -#define DTF_1_PARINIT 0x00000001 -#define DTF_1_CONFEXP 0x00000002 - -/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */ -#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ -#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not - generally available. */ - -/* Version definition sections. */ - -typedef struct -{ - Elf32_Half vd_version; /* Version revision */ - Elf32_Half vd_flags; /* Version information */ - Elf32_Half vd_ndx; /* Version Index */ - Elf32_Half vd_cnt; /* Number of associated aux entries */ - Elf32_Word vd_hash; /* Version name hash value */ - Elf32_Word vd_aux; /* Offset in bytes to verdaux array */ - Elf32_Word vd_next; /* Offset in bytes to next verdef - entry */ -} Elf32_Verdef; - -typedef struct -{ - Elf64_Half vd_version; /* Version revision */ - Elf64_Half vd_flags; /* Version information */ - Elf64_Half vd_ndx; /* Version Index */ - Elf64_Half vd_cnt; /* Number of associated aux entries */ - Elf64_Word vd_hash; /* Version name hash value */ - Elf64_Word vd_aux; /* Offset in bytes to verdaux array */ - Elf64_Word vd_next; /* Offset in bytes to next verdef - entry */ -} Elf64_Verdef; - - -/* Legal values for vd_version (version revision). */ -#define VER_DEF_NONE 0 /* No version */ -#define VER_DEF_CURRENT 1 /* Current version */ -#define VER_DEF_NUM 2 /* Given version number */ - -/* Legal values for vd_flags (version information flags). */ -#define VER_FLG_BASE 0x1 /* Version definition of file itself */ -#define VER_FLG_WEAK 0x2 /* Weak version identifier */ - -/* Versym symbol index values. */ -#define VER_NDX_LOCAL 0 /* Symbol is local. */ -#define VER_NDX_GLOBAL 1 /* Symbol is global. */ -#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */ -#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */ - -/* Auxialiary version information. */ - -typedef struct -{ - Elf32_Word vda_name; /* Version or dependency names */ - Elf32_Word vda_next; /* Offset in bytes to next verdaux - entry */ -} Elf32_Verdaux; - -typedef struct -{ - Elf64_Word vda_name; /* Version or dependency names */ - Elf64_Word vda_next; /* Offset in bytes to next verdaux - entry */ -} Elf64_Verdaux; - - -/* Version dependency section. */ - -typedef struct -{ - Elf32_Half vn_version; /* Version of structure */ - Elf32_Half vn_cnt; /* Number of associated aux entries */ - Elf32_Word vn_file; /* Offset of filename for this - dependency */ - Elf32_Word vn_aux; /* Offset in bytes to vernaux array */ - Elf32_Word vn_next; /* Offset in bytes to next verneed - entry */ -} Elf32_Verneed; - -typedef struct -{ - Elf64_Half vn_version; /* Version of structure */ - Elf64_Half vn_cnt; /* Number of associated aux entries */ - Elf64_Word vn_file; /* Offset of filename for this - dependency */ - Elf64_Word vn_aux; /* Offset in bytes to vernaux array */ - Elf64_Word vn_next; /* Offset in bytes to next verneed - entry */ -} Elf64_Verneed; - - -/* Legal values for vn_version (version revision). */ -#define VER_NEED_NONE 0 /* No version */ -#define VER_NEED_CURRENT 1 /* Current version */ -#define VER_NEED_NUM 2 /* Given version number */ - -/* Auxiliary needed version information. */ - -typedef struct -{ - Elf32_Word vna_hash; /* Hash value of dependency name */ - Elf32_Half vna_flags; /* Dependency specific information */ - Elf32_Half vna_other; /* Unused */ - Elf32_Word vna_name; /* Dependency name string offset */ - Elf32_Word vna_next; /* Offset in bytes to next vernaux - entry */ -} Elf32_Vernaux; - -typedef struct -{ - Elf64_Word vna_hash; /* Hash value of dependency name */ - Elf64_Half vna_flags; /* Dependency specific information */ - Elf64_Half vna_other; /* Unused */ - Elf64_Word vna_name; /* Dependency name string offset */ - Elf64_Word vna_next; /* Offset in bytes to next vernaux - entry */ -} Elf64_Vernaux; - - -/* Legal values for vna_flags. */ -#define VER_FLG_WEAK 0x2 /* Weak version identifier */ - - -/* Auxiliary vector. */ - -/* This vector is normally only used by the program interpreter. The - usual definition in an ABI supplement uses the name auxv_t. The - vector is not usually defined in a standard file, but it - can't hurt. We rename it to avoid conflicts. The sizes of these - types are an arrangement between the exec server and the program - interpreter, so we don't fully specify them here. */ - -typedef struct -{ - int a_type; /* Entry type */ - union - { - long int a_val; /* Integer value */ - void *a_ptr; /* Pointer value */ - void (*a_fcn) (void); /* Function pointer value */ - } a_un; -} Elf32_auxv_t; - -typedef struct -{ - long int a_type; /* Entry type */ - union - { - long int a_val; /* Integer value */ - void *a_ptr; /* Pointer value */ - void (*a_fcn) (void); /* Function pointer value */ - } a_un; -} Elf64_auxv_t; - -/* Legal values for a_type (entry type). */ - -#define AT_NULL 0 /* End of vector */ -#define AT_IGNORE 1 /* Entry should be ignored */ -#define AT_EXECFD 2 /* File descriptor of program */ -#define AT_PHDR 3 /* Program headers for program */ -#define AT_PHENT 4 /* Size of program header entry */ -#define AT_PHNUM 5 /* Number of program headers */ -#define AT_PAGESZ 6 /* System page size */ -#define AT_BASE 7 /* Base address of interpreter */ -#define AT_FLAGS 8 /* Flags */ -#define AT_ENTRY 9 /* Entry point of program */ -#define AT_NOTELF 10 /* Program is not ELF */ -#define AT_UID 11 /* Real uid */ -#define AT_EUID 12 /* Effective uid */ -#define AT_GID 13 /* Real gid */ -#define AT_EGID 14 /* Effective gid */ -#define AT_CLKTCK 17 /* Frequency of times() */ - -/* Some more special a_type values describing the hardware. */ -#define AT_PLATFORM 15 /* String identifying platform. */ -#define AT_HWCAP 16 /* Machine dependent hints about - processor capabilities. */ - -/* This entry gives some information about the FPU initialization - performed by the kernel. */ -#define AT_FPUCW 18 /* Used FPU control word. */ - -/* Cache block sizes. */ -#define AT_DCACHEBSIZE 19 /* Data cache block size. */ -#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */ -#define AT_UCACHEBSIZE 21 /* Unified cache block size. */ - -/* A special ignored value for PPC, used by the kernel to control the - interpretation of the AUXV. Must be > 16. */ -#define AT_IGNOREPPC 22 /* Entry should be ignored. */ - -#define AT_SECURE 23 /* Boolean, was exec setuid-like? */ - -/* Pointer to the global system page used for system calls and other - nice things. */ -#define AT_SYSINFO 32 -#define AT_SYSINFO_EHDR 33 - -/* Shapes of the caches. Bits 0-3 contains associativity; bits 4-7 contains - log2 of line size; mask those to get cache size. */ -#define AT_L1I_CACHESHAPE 34 -#define AT_L1D_CACHESHAPE 35 -#define AT_L2_CACHESHAPE 36 -#define AT_L3_CACHESHAPE 37 - -/* Note section contents. Each entry in the note section begins with - a header of a fixed form. */ - -typedef struct -{ - Elf32_Word n_namesz; /* Length of the note's name. */ - Elf32_Word n_descsz; /* Length of the note's descriptor. */ - Elf32_Word n_type; /* Type of the note. */ -} Elf32_Nhdr; - -typedef struct -{ - Elf64_Word n_namesz; /* Length of the note's name. */ - Elf64_Word n_descsz; /* Length of the note's descriptor. */ - Elf64_Word n_type; /* Type of the note. */ -} Elf64_Nhdr; - -/* Known names of notes. */ - -/* Solaris entries in the note section have this name. */ -#define ELF_NOTE_SOLARIS "SUNW Solaris" - -/* Note entries for GNU systems have this name. */ -#define ELF_NOTE_GNU "GNU" - - -/* Defined types of notes for Solaris. */ - -/* Value of descriptor (one word) is desired pagesize for the binary. */ -#define ELF_NOTE_PAGESIZE_HINT 1 - - -/* Defined note types for GNU systems. */ - -/* ABI information. The descriptor consists of words: - word 0: OS descriptor - word 1: major version of the ABI - word 2: minor version of the ABI - word 3: subminor version of the ABI -*/ -#define ELF_NOTE_ABI 1 - -/* Known OSes. These value can appear in word 0 of an ELF_NOTE_ABI - note section entry. */ -#define ELF_NOTE_OS_LINUX 0 -#define ELF_NOTE_OS_GNU 1 -#define ELF_NOTE_OS_SOLARIS2 2 -#define ELF_NOTE_OS_FREEBSD 3 - - -/* Move records. */ -typedef struct -{ - Elf32_Xword m_value; /* Symbol value. */ - Elf32_Word m_info; /* Size and index. */ - Elf32_Word m_poffset; /* Symbol offset. */ - Elf32_Half m_repeat; /* Repeat count. */ - Elf32_Half m_stride; /* Stride info. */ -} Elf32_Move; - -typedef struct -{ - Elf64_Xword m_value; /* Symbol value. */ - Elf64_Xword m_info; /* Size and index. */ - Elf64_Xword m_poffset; /* Symbol offset. */ - Elf64_Half m_repeat; /* Repeat count. */ - Elf64_Half m_stride; /* Stride info. */ -} Elf64_Move; - -/* Macro to construct move records. */ -#define ELF32_M_SYM(info) ((info) >> 8) -#define ELF32_M_SIZE(info) ((unsigned char) (info)) -#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size)) - -#define ELF64_M_SYM(info) ELF32_M_SYM (info) -#define ELF64_M_SIZE(info) ELF32_M_SIZE (info) -#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) - - -/* Motorola 68k specific definitions. */ - -/* Values for Elf32_Ehdr.e_flags. */ -#define EF_CPU32 0x00810000 - -/* m68k relocs. */ - -#define R_68K_NONE 0 /* No reloc */ -#define R_68K_32 1 /* Direct 32 bit */ -#define R_68K_16 2 /* Direct 16 bit */ -#define R_68K_8 3 /* Direct 8 bit */ -#define R_68K_PC32 4 /* PC relative 32 bit */ -#define R_68K_PC16 5 /* PC relative 16 bit */ -#define R_68K_PC8 6 /* PC relative 8 bit */ -#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */ -#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */ -#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */ -#define R_68K_GOT32O 10 /* 32 bit GOT offset */ -#define R_68K_GOT16O 11 /* 16 bit GOT offset */ -#define R_68K_GOT8O 12 /* 8 bit GOT offset */ -#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */ -#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */ -#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */ -#define R_68K_PLT32O 16 /* 32 bit PLT offset */ -#define R_68K_PLT16O 17 /* 16 bit PLT offset */ -#define R_68K_PLT8O 18 /* 8 bit PLT offset */ -#define R_68K_COPY 19 /* Copy symbol at runtime */ -#define R_68K_GLOB_DAT 20 /* Create GOT entry */ -#define R_68K_JMP_SLOT 21 /* Create PLT entry */ -#define R_68K_RELATIVE 22 /* Adjust by program base */ -/* Keep this the last entry. */ -#define R_68K_NUM 23 - -/* Intel 80386 specific definitions. */ - -/* i386 relocs. */ - -#define R_386_NONE 0 /* No reloc */ -#define R_386_32 1 /* Direct 32 bit */ -#define R_386_PC32 2 /* PC relative 32 bit */ -#define R_386_GOT32 3 /* 32 bit GOT entry */ -#define R_386_PLT32 4 /* 32 bit PLT address */ -#define R_386_COPY 5 /* Copy symbol at runtime */ -#define R_386_GLOB_DAT 6 /* Create GOT entry */ -#define R_386_JMP_SLOT 7 /* Create PLT entry */ -#define R_386_RELATIVE 8 /* Adjust by program base */ -#define R_386_GOTOFF 9 /* 32 bit offset to GOT */ -#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */ -#define R_386_32PLT 11 -#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */ -#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS - block offset */ -#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block - offset */ -#define R_386_TLS_LE 17 /* Offset relative to static TLS - block */ -#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of - general dynamic thread local data */ -#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of - local dynamic thread local data - in LE code */ -#define R_386_16 20 -#define R_386_PC16 21 -#define R_386_8 22 -#define R_386_PC8 23 -#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic - thread local data */ -#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */ -#define R_386_TLS_GD_CALL 26 /* Relocation for call to - __tls_get_addr() */ -#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */ -#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic - thread local data in LE code */ -#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */ -#define R_386_TLS_LDM_CALL 30 /* Relocation for call to - __tls_get_addr() in LDM code */ -#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */ -#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */ -#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS - block offset */ -#define R_386_TLS_LE_32 34 /* Negated offset relative to static - TLS block */ -#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */ -#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */ -#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */ -/* Keep this the last entry. */ -#define R_386_NUM 38 - -/* SUN SPARC specific definitions. */ - -/* Legal values for ST_TYPE subfield of st_info (symbol type). */ - -#define STT_SPARC_REGISTER 13 /* Global register reserved to app. */ - -/* Values for Elf64_Ehdr.e_flags. */ - -#define EF_SPARCV9_MM 3 -#define EF_SPARCV9_TSO 0 -#define EF_SPARCV9_PSO 1 -#define EF_SPARCV9_RMO 2 -#define EF_SPARC_LEDATA 0x800000 /* little endian data */ -#define EF_SPARC_EXT_MASK 0xFFFF00 -#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */ -#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */ -#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */ -#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */ - -/* SPARC relocs. */ - -#define R_SPARC_NONE 0 /* No reloc */ -#define R_SPARC_8 1 /* Direct 8 bit */ -#define R_SPARC_16 2 /* Direct 16 bit */ -#define R_SPARC_32 3 /* Direct 32 bit */ -#define R_SPARC_DISP8 4 /* PC relative 8 bit */ -#define R_SPARC_DISP16 5 /* PC relative 16 bit */ -#define R_SPARC_DISP32 6 /* PC relative 32 bit */ -#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */ -#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */ -#define R_SPARC_HI22 9 /* High 22 bit */ -#define R_SPARC_22 10 /* Direct 22 bit */ -#define R_SPARC_13 11 /* Direct 13 bit */ -#define R_SPARC_LO10 12 /* Truncated 10 bit */ -#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */ -#define R_SPARC_GOT13 14 /* 13 bit GOT entry */ -#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */ -#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */ -#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */ -#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */ -#define R_SPARC_COPY 19 /* Copy symbol at runtime */ -#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */ -#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */ -#define R_SPARC_RELATIVE 22 /* Adjust by program base */ -#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */ - -/* Additional Sparc64 relocs. */ - -#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */ -#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */ -#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */ -#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */ -#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */ -#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */ -#define R_SPARC_10 30 /* Direct 10 bit */ -#define R_SPARC_11 31 /* Direct 11 bit */ -#define R_SPARC_64 32 /* Direct 64 bit */ -#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */ -#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */ -#define R_SPARC_HM10 35 /* High middle 10 bits of ... */ -#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */ -#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */ -#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */ -#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */ -#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */ -#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */ -#define R_SPARC_7 43 /* Direct 7 bit */ -#define R_SPARC_5 44 /* Direct 5 bit */ -#define R_SPARC_6 45 /* Direct 6 bit */ -#define R_SPARC_DISP64 46 /* PC relative 64 bit */ -#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */ -#define R_SPARC_HIX22 48 /* High 22 bit complemented */ -#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */ -#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */ -#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */ -#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */ -#define R_SPARC_REGISTER 53 /* Global register usage */ -#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */ -#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */ -#define R_SPARC_TLS_GD_HI22 56 -#define R_SPARC_TLS_GD_LO10 57 -#define R_SPARC_TLS_GD_ADD 58 -#define R_SPARC_TLS_GD_CALL 59 -#define R_SPARC_TLS_LDM_HI22 60 -#define R_SPARC_TLS_LDM_LO10 61 -#define R_SPARC_TLS_LDM_ADD 62 -#define R_SPARC_TLS_LDM_CALL 63 -#define R_SPARC_TLS_LDO_HIX22 64 -#define R_SPARC_TLS_LDO_LOX10 65 -#define R_SPARC_TLS_LDO_ADD 66 -#define R_SPARC_TLS_IE_HI22 67 -#define R_SPARC_TLS_IE_LO10 68 -#define R_SPARC_TLS_IE_LD 69 -#define R_SPARC_TLS_IE_LDX 70 -#define R_SPARC_TLS_IE_ADD 71 -#define R_SPARC_TLS_LE_HIX22 72 -#define R_SPARC_TLS_LE_LOX10 73 -#define R_SPARC_TLS_DTPMOD32 74 -#define R_SPARC_TLS_DTPMOD64 75 -#define R_SPARC_TLS_DTPOFF32 76 -#define R_SPARC_TLS_DTPOFF64 77 -#define R_SPARC_TLS_TPOFF32 78 -#define R_SPARC_TLS_TPOFF64 79 -/* Keep this the last entry. */ -#define R_SPARC_NUM 80 - -/* For Sparc64, legal values for d_tag of Elf64_Dyn. */ - -#define DT_SPARC_REGISTER 0x70000001 -#define DT_SPARC_NUM 2 - -/* Bits present in AT_HWCAP, primarily for Sparc32. */ - -#define HWCAP_SPARC_FLUSH 1 /* The cpu supports flush insn. */ -#define HWCAP_SPARC_STBAR 2 -#define HWCAP_SPARC_SWAP 4 -#define HWCAP_SPARC_MULDIV 8 -#define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */ -#define HWCAP_SPARC_ULTRA3 32 - -/* MIPS R3000 specific definitions. */ - -/* Legal values for e_flags field of Elf32_Ehdr. */ - -#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */ -#define EF_MIPS_PIC 2 /* Contains PIC code */ -#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */ -#define EF_MIPS_XGOT 8 -#define EF_MIPS_64BIT_WHIRL 16 -#define EF_MIPS_ABI2 32 -#define EF_MIPS_ABI_ON32 64 -#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */ - -/* Legal values for MIPS architecture level. */ - -#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ -#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ -#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ -#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ -#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ -#define EF_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */ -#define EF_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */ - -/* The following are non-official names and should not be used. */ - -#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ -#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ -#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ -#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ -#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ -#define E_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */ -#define E_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */ - -/* Special section indices. */ - -#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */ -#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */ -#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */ -#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */ -#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */ - -/* Legal values for sh_type field of Elf32_Shdr. */ - -#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */ -#define SHT_MIPS_MSYM 0x70000001 -#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */ -#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */ -#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */ -#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/ -#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */ -#define SHT_MIPS_PACKAGE 0x70000007 -#define SHT_MIPS_PACKSYM 0x70000008 -#define SHT_MIPS_RELD 0x70000009 -#define SHT_MIPS_IFACE 0x7000000b -#define SHT_MIPS_CONTENT 0x7000000c -#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */ -#define SHT_MIPS_SHDR 0x70000010 -#define SHT_MIPS_FDESC 0x70000011 -#define SHT_MIPS_EXTSYM 0x70000012 -#define SHT_MIPS_DENSE 0x70000013 -#define SHT_MIPS_PDESC 0x70000014 -#define SHT_MIPS_LOCSYM 0x70000015 -#define SHT_MIPS_AUXSYM 0x70000016 -#define SHT_MIPS_OPTSYM 0x70000017 -#define SHT_MIPS_LOCSTR 0x70000018 -#define SHT_MIPS_LINE 0x70000019 -#define SHT_MIPS_RFDESC 0x7000001a -#define SHT_MIPS_DELTASYM 0x7000001b -#define SHT_MIPS_DELTAINST 0x7000001c -#define SHT_MIPS_DELTACLASS 0x7000001d -#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */ -#define SHT_MIPS_DELTADECL 0x7000001f -#define SHT_MIPS_SYMBOL_LIB 0x70000020 -#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */ -#define SHT_MIPS_TRANSLATE 0x70000022 -#define SHT_MIPS_PIXIE 0x70000023 -#define SHT_MIPS_XLATE 0x70000024 -#define SHT_MIPS_XLATE_DEBUG 0x70000025 -#define SHT_MIPS_WHIRL 0x70000026 -#define SHT_MIPS_EH_REGION 0x70000027 -#define SHT_MIPS_XLATE_OLD 0x70000028 -#define SHT_MIPS_PDR_EXCEPTION 0x70000029 - -/* Legal values for sh_flags field of Elf32_Shdr. */ - -#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */ -#define SHF_MIPS_MERGE 0x20000000 -#define SHF_MIPS_ADDR 0x40000000 -#define SHF_MIPS_STRINGS 0x80000000 -#define SHF_MIPS_NOSTRIP 0x08000000 -#define SHF_MIPS_LOCAL 0x04000000 -#define SHF_MIPS_NAMES 0x02000000 -#define SHF_MIPS_NODUPE 0x01000000 - - -/* Symbol tables. */ - -/* MIPS specific values for `st_other'. */ -#define STO_MIPS_DEFAULT 0x0 -#define STO_MIPS_INTERNAL 0x1 -#define STO_MIPS_HIDDEN 0x2 -#define STO_MIPS_PROTECTED 0x3 -#define STO_MIPS_SC_ALIGN_UNUSED 0xff - -/* MIPS specific values for `st_info'. */ -#define STB_MIPS_SPLIT_COMMON 13 - -/* Entries found in sections of type SHT_MIPS_GPTAB. */ - -typedef union -{ - struct - { - Elf32_Word gt_current_g_value; /* -G value used for compilation */ - Elf32_Word gt_unused; /* Not used */ - } gt_header; /* First entry in section */ - struct - { - Elf32_Word gt_g_value; /* If this value were used for -G */ - Elf32_Word gt_bytes; /* This many bytes would be used */ - } gt_entry; /* Subsequent entries in section */ -} Elf32_gptab; - -/* Entry found in sections of type SHT_MIPS_REGINFO. */ - -typedef struct -{ - Elf32_Word ri_gprmask; /* General registers used */ - Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */ - Elf32_Sword ri_gp_value; /* $gp register value */ -} Elf32_RegInfo; - -/* Entries found in sections of type SHT_MIPS_OPTIONS. */ - -typedef struct -{ - unsigned char kind; /* Determines interpretation of the - variable part of descriptor. */ - unsigned char size; /* Size of descriptor, including header. */ - Elf32_Section section; /* Section header index of section affected, - 0 for global options. */ - Elf32_Word info; /* Kind-specific information. */ -} Elf_Options; - -/* Values for `kind' field in Elf_Options. */ - -#define ODK_NULL 0 /* Undefined. */ -#define ODK_REGINFO 1 /* Register usage information. */ -#define ODK_EXCEPTIONS 2 /* Exception processing options. */ -#define ODK_PAD 3 /* Section padding options. */ -#define ODK_HWPATCH 4 /* Hardware workarounds performed */ -#define ODK_FILL 5 /* record the fill value used by the linker. */ -#define ODK_TAGS 6 /* reserve space for desktop tools to write. */ -#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */ -#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */ - -/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */ - -#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */ -#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */ -#define OEX_PAGE0 0x10000 /* page zero must be mapped. */ -#define OEX_SMM 0x20000 /* Force sequential memory mode? */ -#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */ -#define OEX_PRECISEFP OEX_FPDBUG -#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */ - -#define OEX_FPU_INVAL 0x10 -#define OEX_FPU_DIV0 0x08 -#define OEX_FPU_OFLO 0x04 -#define OEX_FPU_UFLO 0x02 -#define OEX_FPU_INEX 0x01 - -/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */ - -#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */ -#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */ -#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */ -#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */ - -#define OPAD_PREFIX 0x1 -#define OPAD_POSTFIX 0x2 -#define OPAD_SYMBOL 0x4 - -/* Entry found in `.options' section. */ - -typedef struct -{ - Elf32_Word hwp_flags1; /* Extra flags. */ - Elf32_Word hwp_flags2; /* Extra flags. */ -} Elf_Options_Hw; - -/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */ - -#define OHWA0_R4KEOP_CHECKED 0x00000001 -#define OHWA1_R4KEOP_CLEAN 0x00000002 - -/* MIPS relocs. */ - -#define R_MIPS_NONE 0 /* No reloc */ -#define R_MIPS_16 1 /* Direct 16 bit */ -#define R_MIPS_32 2 /* Direct 32 bit */ -#define R_MIPS_REL32 3 /* PC relative 32 bit */ -#define R_MIPS_26 4 /* Direct 26 bit shifted */ -#define R_MIPS_HI16 5 /* High 16 bit */ -#define R_MIPS_LO16 6 /* Low 16 bit */ -#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ -#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ -#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ -#define R_MIPS_PC16 10 /* PC relative 16 bit */ -#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ -#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ - -#define R_MIPS_SHIFT5 16 -#define R_MIPS_SHIFT6 17 -#define R_MIPS_64 18 -#define R_MIPS_GOT_DISP 19 -#define R_MIPS_GOT_PAGE 20 -#define R_MIPS_GOT_OFST 21 -#define R_MIPS_GOT_HI16 22 -#define R_MIPS_GOT_LO16 23 -#define R_MIPS_SUB 24 -#define R_MIPS_INSERT_A 25 -#define R_MIPS_INSERT_B 26 -#define R_MIPS_DELETE 27 -#define R_MIPS_HIGHER 28 -#define R_MIPS_HIGHEST 29 -#define R_MIPS_CALL_HI16 30 -#define R_MIPS_CALL_LO16 31 -#define R_MIPS_SCN_DISP 32 -#define R_MIPS_REL16 33 -#define R_MIPS_ADD_IMMEDIATE 34 -#define R_MIPS_PJUMP 35 -#define R_MIPS_RELGOT 36 -#define R_MIPS_JALR 37 -/* Keep this the last entry. */ -#define R_MIPS_NUM 38 - -/* Legal values for p_type field of Elf32_Phdr. */ - -#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */ -#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */ -#define PT_MIPS_OPTIONS 0x70000002 - -/* Special program header types. */ - -#define PF_MIPS_LOCAL 0x10000000 - -/* Legal values for d_tag field of Elf32_Dyn. */ - -#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */ -#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */ -#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */ -#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */ -#define DT_MIPS_FLAGS 0x70000005 /* Flags */ -#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */ -#define DT_MIPS_MSYM 0x70000007 -#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */ -#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */ -#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */ -#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */ -#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */ -#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */ -#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */ -#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */ -#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */ -#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */ -#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */ -#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in - DT_MIPS_DELTA_CLASS. */ -#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */ -#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in - DT_MIPS_DELTA_INSTANCE. */ -#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */ -#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in - DT_MIPS_DELTA_RELOC. */ -#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta - relocations refer to. */ -#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in - DT_MIPS_DELTA_SYM. */ -#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the - class declaration. */ -#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in - DT_MIPS_DELTA_CLASSSYM. */ -#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */ -#define DT_MIPS_PIXIE_INIT 0x70000023 -#define DT_MIPS_SYMBOL_LIB 0x70000024 -#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 -#define DT_MIPS_LOCAL_GOTIDX 0x70000026 -#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 -#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 -#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */ -#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */ -#define DT_MIPS_DYNSTR_ALIGN 0x7000002b -#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */ -#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve - function stored in GOT. */ -#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added - by rld on dlopen() calls. */ -#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */ -#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */ -#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */ -#define DT_MIPS_NUM 0x32 - -/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */ - -#define RHF_NONE 0 /* No flags */ -#define RHF_QUICKSTART (1 << 0) /* Use quickstart */ -#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */ -#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */ -#define RHF_NO_MOVE (1 << 3) -#define RHF_SGI_ONLY (1 << 4) -#define RHF_GUARANTEE_INIT (1 << 5) -#define RHF_DELTA_C_PLUS_PLUS (1 << 6) -#define RHF_GUARANTEE_START_INIT (1 << 7) -#define RHF_PIXIE (1 << 8) -#define RHF_DEFAULT_DELAY_LOAD (1 << 9) -#define RHF_REQUICKSTART (1 << 10) -#define RHF_REQUICKSTARTED (1 << 11) -#define RHF_CORD (1 << 12) -#define RHF_NO_UNRES_UNDEF (1 << 13) -#define RHF_RLD_ORDER_SAFE (1 << 14) - -/* Entries found in sections of type SHT_MIPS_LIBLIST. */ - -typedef struct -{ - Elf32_Word l_name; /* Name (string table index) */ - Elf32_Word l_time_stamp; /* Timestamp */ - Elf32_Word l_checksum; /* Checksum */ - Elf32_Word l_version; /* Interface version */ - Elf32_Word l_flags; /* Flags */ -} Elf32_Lib; - -typedef struct -{ - Elf64_Word l_name; /* Name (string table index) */ - Elf64_Word l_time_stamp; /* Timestamp */ - Elf64_Word l_checksum; /* Checksum */ - Elf64_Word l_version; /* Interface version */ - Elf64_Word l_flags; /* Flags */ -} Elf64_Lib; - - -/* Legal values for l_flags. */ - -#define LL_NONE 0 -#define LL_EXACT_MATCH (1 << 0) /* Require exact match */ -#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */ -#define LL_REQUIRE_MINOR (1 << 2) -#define LL_EXPORTS (1 << 3) -#define LL_DELAY_LOAD (1 << 4) -#define LL_DELTA (1 << 5) - -/* Entries found in sections of type SHT_MIPS_CONFLICT. */ - -typedef Elf32_Addr Elf32_Conflict; - - -/* HPPA specific definitions. */ - -/* Legal values for e_flags field of Elf32_Ehdr. */ - -#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */ -#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */ -#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */ -#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */ -#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch - prediction. */ -#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */ -#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */ - -/* Defined values for `e_flags & EF_PARISC_ARCH' are: */ - -#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */ -#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */ -#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */ - -/* Additional section indeces. */ - -#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared - symbols in ANSI C. */ -#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */ - -/* Legal values for sh_type field of Elf32_Shdr. */ - -#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */ -#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */ -#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */ - -/* Legal values for sh_flags field of Elf32_Shdr. */ - -#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */ -#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */ -#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */ - -/* Legal values for ST_TYPE subfield of st_info (symbol type). */ - -#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */ - -#define STT_HP_OPAQUE (STT_LOOS + 0x1) -#define STT_HP_STUB (STT_LOOS + 0x2) - -/* HPPA relocs. */ - -#define R_PARISC_NONE 0 /* No reloc. */ -#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */ -#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */ -#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */ -#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */ -#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */ -#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */ -#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */ -#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */ -#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */ -#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */ -#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */ -#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */ -#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */ -#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */ -#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */ -#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */ -#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */ -#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */ -#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */ -#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */ -#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */ -#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */ -#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */ -#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */ -#define R_PARISC_FPTR64 64 /* 64 bits function address. */ -#define R_PARISC_PLABEL32 65 /* 32 bits function address. */ -#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */ -#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */ -#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */ -#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */ -#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */ -#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */ -#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */ -#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */ -#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */ -#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */ -#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */ -#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */ -#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */ -#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */ -#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */ -#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */ -#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */ -#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */ -#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */ -#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */ -#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */ -#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */ -#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */ -#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */ -#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */ -#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */ -#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */ -#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */ -#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */ -#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */ -#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */ -#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */ -#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */ -#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */ -#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */ -#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */ -#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */ -#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */ -#define R_PARISC_LORESERVE 128 -#define R_PARISC_COPY 128 /* Copy relocation. */ -#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */ -#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */ -#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */ -#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */ -#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */ -#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */ -#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/ -#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */ -#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */ -#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */ -#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */ -#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */ -#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */ -#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */ -#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */ -#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/ -#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/ -#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */ -#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */ -#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */ -#define R_PARISC_HIRESERVE 255 - -/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */ - -#define PT_HP_TLS (PT_LOOS + 0x0) -#define PT_HP_CORE_NONE (PT_LOOS + 0x1) -#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) -#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) -#define PT_HP_CORE_COMM (PT_LOOS + 0x4) -#define PT_HP_CORE_PROC (PT_LOOS + 0x5) -#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) -#define PT_HP_CORE_STACK (PT_LOOS + 0x7) -#define PT_HP_CORE_SHM (PT_LOOS + 0x8) -#define PT_HP_CORE_MMF (PT_LOOS + 0x9) -#define PT_HP_PARALLEL (PT_LOOS + 0x10) -#define PT_HP_FASTBIND (PT_LOOS + 0x11) -#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) -#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) -#define PT_HP_STACK (PT_LOOS + 0x14) - -#define PT_PARISC_ARCHEXT 0x70000000 -#define PT_PARISC_UNWIND 0x70000001 - -/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */ - -#define PF_PARISC_SBP 0x08000000 - -#define PF_HP_PAGE_SIZE 0x00100000 -#define PF_HP_FAR_SHARED 0x00200000 -#define PF_HP_NEAR_SHARED 0x00400000 -#define PF_HP_CODE 0x01000000 -#define PF_HP_MODIFY 0x02000000 -#define PF_HP_LAZYSWAP 0x04000000 -#define PF_HP_SBP 0x08000000 - - -/* Alpha specific definitions. */ - -/* Legal values for e_flags field of Elf64_Ehdr. */ - -#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */ -#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */ - -/* Legal values for sh_type field of Elf64_Shdr. */ - -/* These two are primerily concerned with ECOFF debugging info. */ -#define SHT_ALPHA_DEBUG 0x70000001 -#define SHT_ALPHA_REGINFO 0x70000002 - -/* Legal values for sh_flags field of Elf64_Shdr. */ - -#define SHF_ALPHA_GPREL 0x10000000 - -/* Legal values for st_other field of Elf64_Sym. */ -#define STO_ALPHA_NOPV 0x80 /* No PV required. */ -#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */ - -/* Alpha relocs. */ - -#define R_ALPHA_NONE 0 /* No reloc */ -#define R_ALPHA_REFLONG 1 /* Direct 32 bit */ -#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */ -#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */ -#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */ -#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */ -#define R_ALPHA_GPDISP 6 /* Add displacement to GP */ -#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */ -#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */ -#define R_ALPHA_SREL16 9 /* PC relative 16 bit */ -#define R_ALPHA_SREL32 10 /* PC relative 32 bit */ -#define R_ALPHA_SREL64 11 /* PC relative 64 bit */ -#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */ -#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */ -#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */ -#define R_ALPHA_COPY 24 /* Copy symbol at runtime */ -#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */ -#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */ -#define R_ALPHA_RELATIVE 27 /* Adjust by program base */ -#define R_ALPHA_TLS_GD_HI 28 -#define R_ALPHA_TLSGD 29 -#define R_ALPHA_TLS_LDM 30 -#define R_ALPHA_DTPMOD64 31 -#define R_ALPHA_GOTDTPREL 32 -#define R_ALPHA_DTPREL64 33 -#define R_ALPHA_DTPRELHI 34 -#define R_ALPHA_DTPRELLO 35 -#define R_ALPHA_DTPREL16 36 -#define R_ALPHA_GOTTPREL 37 -#define R_ALPHA_TPREL64 38 -#define R_ALPHA_TPRELHI 39 -#define R_ALPHA_TPRELLO 40 -#define R_ALPHA_TPREL16 41 -/* Keep this the last entry. */ -#define R_ALPHA_NUM 46 - -/* Magic values of the LITUSE relocation addend. */ -#define LITUSE_ALPHA_ADDR 0 -#define LITUSE_ALPHA_BASE 1 -#define LITUSE_ALPHA_BYTOFF 2 -#define LITUSE_ALPHA_JSR 3 -#define LITUSE_ALPHA_TLS_GD 4 -#define LITUSE_ALPHA_TLS_LDM 5 - - -/* PowerPC specific declarations */ - -/* Values for Elf32/64_Ehdr.e_flags. */ -#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ - -/* Cygnus local bits below */ -#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/ -#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib - flag */ - -/* PowerPC relocations defined by the ABIs */ -#define R_PPC_NONE 0 -#define R_PPC_ADDR32 1 /* 32bit absolute address */ -#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ -#define R_PPC_ADDR16 3 /* 16bit absolute address */ -#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ -#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ -#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ -#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ -#define R_PPC_ADDR14_BRTAKEN 8 -#define R_PPC_ADDR14_BRNTAKEN 9 -#define R_PPC_REL24 10 /* PC relative 26 bit */ -#define R_PPC_REL14 11 /* PC relative 16 bit */ -#define R_PPC_REL14_BRTAKEN 12 -#define R_PPC_REL14_BRNTAKEN 13 -#define R_PPC_GOT16 14 -#define R_PPC_GOT16_LO 15 -#define R_PPC_GOT16_HI 16 -#define R_PPC_GOT16_HA 17 -#define R_PPC_PLTREL24 18 -#define R_PPC_COPY 19 -#define R_PPC_GLOB_DAT 20 -#define R_PPC_JMP_SLOT 21 -#define R_PPC_RELATIVE 22 -#define R_PPC_LOCAL24PC 23 -#define R_PPC_UADDR32 24 -#define R_PPC_UADDR16 25 -#define R_PPC_REL32 26 -#define R_PPC_PLT32 27 -#define R_PPC_PLTREL32 28 -#define R_PPC_PLT16_LO 29 -#define R_PPC_PLT16_HI 30 -#define R_PPC_PLT16_HA 31 -#define R_PPC_SDAREL16 32 -#define R_PPC_SECTOFF 33 -#define R_PPC_SECTOFF_LO 34 -#define R_PPC_SECTOFF_HI 35 -#define R_PPC_SECTOFF_HA 36 - -/* PowerPC relocations defined for the TLS access ABI. */ -#define R_PPC_TLS 67 /* none (sym+add)@tls */ -#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */ -#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */ -#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ -#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ -#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ -#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */ -#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */ -#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ -#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ -#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ -#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */ -#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ -#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ -#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ -#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ -#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ -#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ -#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ -#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ -#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */ -#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */ -#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ -#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ -#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */ -#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */ -#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */ -#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */ - -/* Keep this the last entry. */ -#define R_PPC_NUM 95 - -/* The remaining relocs are from the Embedded ELF ABI, and are not - in the SVR4 ELF ABI. */ -#define R_PPC_EMB_NADDR32 101 -#define R_PPC_EMB_NADDR16 102 -#define R_PPC_EMB_NADDR16_LO 103 -#define R_PPC_EMB_NADDR16_HI 104 -#define R_PPC_EMB_NADDR16_HA 105 -#define R_PPC_EMB_SDAI16 106 -#define R_PPC_EMB_SDA2I16 107 -#define R_PPC_EMB_SDA2REL 108 -#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */ -#define R_PPC_EMB_MRKREF 110 -#define R_PPC_EMB_RELSEC16 111 -#define R_PPC_EMB_RELST_LO 112 -#define R_PPC_EMB_RELST_HI 113 -#define R_PPC_EMB_RELST_HA 114 -#define R_PPC_EMB_BIT_FLD 115 -#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */ - -/* Diab tool relocations. */ -#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */ -#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */ -#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */ -#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */ -#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */ -#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */ - -/* This is a phony reloc to handle any old fashioned TOC16 references - that may still be in object files. */ -#define R_PPC_TOC16 255 - - -/* PowerPC64 relocations defined by the ABIs */ -#define R_PPC64_NONE R_PPC_NONE -#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address */ -#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned */ -#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address */ -#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of address */ -#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of address. */ -#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */ -#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned */ -#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN -#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN -#define R_PPC64_REL24 R_PPC_REL24 /* PC-rel. 26 bit, word aligned */ -#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit */ -#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN -#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN -#define R_PPC64_GOT16 R_PPC_GOT16 -#define R_PPC64_GOT16_LO R_PPC_GOT16_LO -#define R_PPC64_GOT16_HI R_PPC_GOT16_HI -#define R_PPC64_GOT16_HA R_PPC_GOT16_HA - -#define R_PPC64_COPY R_PPC_COPY -#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT -#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT -#define R_PPC64_RELATIVE R_PPC_RELATIVE - -#define R_PPC64_UADDR32 R_PPC_UADDR32 -#define R_PPC64_UADDR16 R_PPC_UADDR16 -#define R_PPC64_REL32 R_PPC_REL32 -#define R_PPC64_PLT32 R_PPC_PLT32 -#define R_PPC64_PLTREL32 R_PPC_PLTREL32 -#define R_PPC64_PLT16_LO R_PPC_PLT16_LO -#define R_PPC64_PLT16_HI R_PPC_PLT16_HI -#define R_PPC64_PLT16_HA R_PPC_PLT16_HA - -#define R_PPC64_SECTOFF R_PPC_SECTOFF -#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO -#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI -#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA -#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2 */ -#define R_PPC64_ADDR64 38 /* doubleword64 S + A */ -#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A) */ -#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */ -#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */ -#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A) */ -#define R_PPC64_UADDR64 43 /* doubleword64 S + A */ -#define R_PPC64_REL64 44 /* doubleword64 S + A - P */ -#define R_PPC64_PLT64 45 /* doubleword64 L + A */ -#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P */ -#define R_PPC64_TOC16 47 /* half16* S + A - .TOC */ -#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.) */ -#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.) */ -#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.) */ -#define R_PPC64_TOC 51 /* doubleword64 .TOC */ -#define R_PPC64_PLTGOT16 52 /* half16* M + A */ -#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A) */ -#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A) */ -#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A) */ - -#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2 */ -#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2 */ -#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2 */ -#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2 */ -#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2 */ -#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2 */ -#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2 */ -#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2 */ -#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2 */ -#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2 */ -#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2 */ - -/* PowerPC64 relocations defined for the TLS access ABI. */ -#define R_PPC64_TLS 67 /* none (sym+add)@tls */ -#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */ -#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */ -#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ -#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ -#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ -#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */ -#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */ -#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ -#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ -#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ -#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */ -#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ -#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ -#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ -#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ -#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ -#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ -#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ -#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ -#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */ -#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */ -#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ -#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ -#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */ -#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */ -#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */ -#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */ -#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */ -#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */ -#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */ -#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */ -#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */ -#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */ -#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */ -#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */ -#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */ -#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */ -#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */ -#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */ - -/* Keep this the last entry. */ -#define R_PPC64_NUM 107 - -/* PowerPC64 specific values for the Dyn d_tag field. */ -#define DT_PPC64_GLINK (DT_LOPROC + 0) -#define DT_PPC64_OPD (DT_LOPROC + 1) -#define DT_PPC64_OPDSZ (DT_LOPROC + 2) -#define DT_PPC64_NUM 3 - - -/* ARM specific declarations */ - -/* Processor specific flags for the ELF header e_flags field. */ -#define EF_ARM_RELEXEC 0x01 -#define EF_ARM_HASENTRY 0x02 -#define EF_ARM_INTERWORK 0x04 -#define EF_ARM_APCS_26 0x08 -#define EF_ARM_APCS_FLOAT 0x10 -#define EF_ARM_PIC 0x20 -#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */ -#define EF_ARM_NEW_ABI 0x80 -#define EF_ARM_OLD_ABI 0x100 - -/* Other constants defined in the ARM ELF spec. version B-01. */ -/* NB. These conflict with values defined above. */ -#define EF_ARM_SYMSARESORTED 0x04 -#define EF_ARM_DYNSYMSUSESEGIDX 0x08 -#define EF_ARM_MAPSYMSFIRST 0x10 -#define EF_ARM_EABIMASK 0XFF000000 - -#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK) -#define EF_ARM_EABI_UNKNOWN 0x00000000 -#define EF_ARM_EABI_VER1 0x01000000 -#define EF_ARM_EABI_VER2 0x02000000 - -/* Additional symbol types for Thumb */ -#define STT_ARM_TFUNC 0xd - -/* ARM-specific values for sh_flags */ -#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */ -#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined - in the input to a link step */ - -/* ARM-specific program header flags */ -#define PF_ARM_SB 0x10000000 /* Segment contains the location - addressed by the static base */ - -/* ARM relocs. */ -#define R_ARM_NONE 0 /* No reloc */ -#define R_ARM_PC24 1 /* PC relative 26 bit branch */ -#define R_ARM_ABS32 2 /* Direct 32 bit */ -#define R_ARM_REL32 3 /* PC relative 32 bit */ -#define R_ARM_PC13 4 -#define R_ARM_ABS16 5 /* Direct 16 bit */ -#define R_ARM_ABS12 6 /* Direct 12 bit */ -#define R_ARM_THM_ABS5 7 -#define R_ARM_ABS8 8 /* Direct 8 bit */ -#define R_ARM_SBREL32 9 -#define R_ARM_THM_PC22 10 -#define R_ARM_THM_PC8 11 -#define R_ARM_AMP_VCALL9 12 -#define R_ARM_SWI24 13 -#define R_ARM_THM_SWI8 14 -#define R_ARM_XPC25 15 -#define R_ARM_THM_XPC22 16 -#define R_ARM_COPY 20 /* Copy symbol at runtime */ -#define R_ARM_GLOB_DAT 21 /* Create GOT entry */ -#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */ -#define R_ARM_RELATIVE 23 /* Adjust by program base */ -#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */ -#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */ -#define R_ARM_GOT32 26 /* 32 bit GOT entry */ -#define R_ARM_PLT32 27 /* 32 bit PLT address */ -#define R_ARM_ALU_PCREL_7_0 32 -#define R_ARM_ALU_PCREL_15_8 33 -#define R_ARM_ALU_PCREL_23_15 34 -#define R_ARM_LDR_SBREL_11_0 35 -#define R_ARM_ALU_SBREL_19_12 36 -#define R_ARM_ALU_SBREL_27_20 37 -#define R_ARM_GNU_VTENTRY 100 -#define R_ARM_GNU_VTINHERIT 101 -#define R_ARM_THM_PC11 102 /* thumb unconditional branch */ -#define R_ARM_THM_PC9 103 /* thumb conditional branch */ -#define R_ARM_RXPC25 249 -#define R_ARM_RSBREL32 250 -#define R_ARM_THM_RPC22 251 -#define R_ARM_RREL32 252 -#define R_ARM_RABS22 253 -#define R_ARM_RPC24 254 -#define R_ARM_RBASE 255 -/* Keep this the last entry. */ -#define R_ARM_NUM 256 - -/* IA-64 specific declarations. */ - -/* Processor specific flags for the Ehdr e_flags field. */ -#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */ -#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */ -#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */ - -/* Processor specific values for the Phdr p_type field. */ -#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */ -#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */ -#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12) -#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13) -#define PT_IA_64_HP_STACK (PT_LOOS + 0x14) - -/* Processor specific flags for the Phdr p_flags field. */ -#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */ - -/* Processor specific values for the Shdr sh_type field. */ -#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */ -#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */ - -/* Processor specific flags for the Shdr sh_flags field. */ -#define SHF_IA_64_SHORT 0x10000000 /* section near gp */ -#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */ - -/* Processor specific values for the Dyn d_tag field. */ -#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) -#define DT_IA_64_NUM 1 - -/* IA-64 relocations. */ -#define R_IA64_NONE 0x00 /* none */ -#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */ -#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */ -#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */ -#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */ -#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */ -#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */ -#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */ -#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */ -#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */ -#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */ -#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */ -#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */ -#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */ -#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */ -#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */ -#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */ -#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */ -#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */ -#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */ -#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */ -#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */ -#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */ -#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */ -#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */ -#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */ -#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */ -#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */ -#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */ -#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */ -#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */ -#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */ -#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */ -#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */ -#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */ -#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */ -#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */ -#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */ -#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */ -#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */ -#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */ -#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */ -#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */ -#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */ -#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */ -#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */ -#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */ -#define R_IA64_REL32MSB 0x6c /* data 4 + REL */ -#define R_IA64_REL32LSB 0x6d /* data 4 + REL */ -#define R_IA64_REL64MSB 0x6e /* data 8 + REL */ -#define R_IA64_REL64LSB 0x6f /* data 8 + REL */ -#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */ -#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */ -#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */ -#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */ -#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */ -#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */ -#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */ -#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */ -#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */ -#define R_IA64_COPY 0x84 /* copy relocation */ -#define R_IA64_SUB 0x85 /* Addend and symbol difference */ -#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */ -#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */ -#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */ -#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */ -#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */ -#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */ -#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */ -#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */ -#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */ -#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */ -#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */ -#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */ -#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */ -#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */ -#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */ -#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */ -#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */ -#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */ -#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */ - -/* SH specific declarations */ - -/* SH relocs. */ -#define R_SH_NONE 0 -#define R_SH_DIR32 1 -#define R_SH_REL32 2 -#define R_SH_DIR8WPN 3 -#define R_SH_IND12W 4 -#define R_SH_DIR8WPL 5 -#define R_SH_DIR8WPZ 6 -#define R_SH_DIR8BP 7 -#define R_SH_DIR8W 8 -#define R_SH_DIR8L 9 -#define R_SH_SWITCH16 25 -#define R_SH_SWITCH32 26 -#define R_SH_USES 27 -#define R_SH_COUNT 28 -#define R_SH_ALIGN 29 -#define R_SH_CODE 30 -#define R_SH_DATA 31 -#define R_SH_LABEL 32 -#define R_SH_SWITCH8 33 -#define R_SH_GNU_VTINHERIT 34 -#define R_SH_GNU_VTENTRY 35 -#define R_SH_TLS_GD_32 144 -#define R_SH_TLS_LD_32 145 -#define R_SH_TLS_LDO_32 146 -#define R_SH_TLS_IE_32 147 -#define R_SH_TLS_LE_32 148 -#define R_SH_TLS_DTPMOD32 149 -#define R_SH_TLS_DTPOFF32 150 -#define R_SH_TLS_TPOFF32 151 -#define R_SH_GOT32 160 -#define R_SH_PLT32 161 -#define R_SH_COPY 162 -#define R_SH_GLOB_DAT 163 -#define R_SH_JMP_SLOT 164 -#define R_SH_RELATIVE 165 -#define R_SH_GOTOFF 166 -#define R_SH_GOTPC 167 -/* Keep this the last entry. */ -#define R_SH_NUM 256 - -/* Additional s390 relocs */ - -#define R_390_NONE 0 /* No reloc. */ -#define R_390_8 1 /* Direct 8 bit. */ -#define R_390_12 2 /* Direct 12 bit. */ -#define R_390_16 3 /* Direct 16 bit. */ -#define R_390_32 4 /* Direct 32 bit. */ -#define R_390_PC32 5 /* PC relative 32 bit. */ -#define R_390_GOT12 6 /* 12 bit GOT offset. */ -#define R_390_GOT32 7 /* 32 bit GOT offset. */ -#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */ -#define R_390_COPY 9 /* Copy symbol at runtime. */ -#define R_390_GLOB_DAT 10 /* Create GOT entry. */ -#define R_390_JMP_SLOT 11 /* Create PLT entry. */ -#define R_390_RELATIVE 12 /* Adjust by program base. */ -#define R_390_GOTOFF32 13 /* 32 bit offset to GOT. */ -#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */ -#define R_390_GOT16 15 /* 16 bit GOT offset. */ -#define R_390_PC16 16 /* PC relative 16 bit. */ -#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */ -#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */ -#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */ -#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */ -#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */ -#define R_390_64 22 /* Direct 64 bit. */ -#define R_390_PC64 23 /* PC relative 64 bit. */ -#define R_390_GOT64 24 /* 64 bit GOT offset. */ -#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */ -#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */ -#define R_390_GOTOFF16 27 /* 16 bit offset to GOT. */ -#define R_390_GOTOFF64 28 /* 64 bit offset to GOT. */ -#define R_390_GOTPLT12 29 /* 12 bit offset to jump slot. */ -#define R_390_GOTPLT16 30 /* 16 bit offset to jump slot. */ -#define R_390_GOTPLT32 31 /* 32 bit offset to jump slot. */ -#define R_390_GOTPLT64 32 /* 64 bit offset to jump slot. */ -#define R_390_GOTPLTENT 33 /* 32 bit rel. offset to jump slot. */ -#define R_390_PLTOFF16 34 /* 16 bit offset from GOT to PLT. */ -#define R_390_PLTOFF32 35 /* 32 bit offset from GOT to PLT. */ -#define R_390_PLTOFF64 36 /* 16 bit offset from GOT to PLT. */ -#define R_390_TLS_LOAD 37 /* Tag for load insn in TLS code. */ -#define R_390_TLS_GDCALL 38 /* Tag for function call in general - dynamic TLS code. */ -#define R_390_TLS_LDCALL 39 /* Tag for function call in local - dynamic TLS code. */ -#define R_390_TLS_GD32 40 /* Direct 32 bit for general dynamic - thread local data. */ -#define R_390_TLS_GD64 41 /* Direct 64 bit for general dynamic - thread local data. */ -#define R_390_TLS_GOTIE12 42 /* 12 bit GOT offset for static TLS - block offset. */ -#define R_390_TLS_GOTIE32 43 /* 32 bit GOT offset for static TLS - block offset. */ -#define R_390_TLS_GOTIE64 44 /* 64 bit GOT offset for static TLS - block offset. */ -#define R_390_TLS_LDM32 45 /* Direct 32 bit for local dynamic - thread local data in LE code. */ -#define R_390_TLS_LDM64 46 /* Direct 64 bit for local dynamic - thread local data in LE code. */ -#define R_390_TLS_IE32 47 /* 32 bit address of GOT entry for - negated static TLS block offset. */ -#define R_390_TLS_IE64 48 /* 64 bit address of GOT entry for - negated static TLS block offset. */ -#define R_390_TLS_IEENT 49 /* 32 bit rel. offset to GOT entry for - negated static TLS block offset. */ -#define R_390_TLS_LE32 50 /* 32 bit negated offset relative to - static TLS block. */ -#define R_390_TLS_LE64 51 /* 64 bit negated offset relative to - static TLS block. */ -#define R_390_TLS_LDO32 52 /* 32 bit offset relative to TLS - block. */ -#define R_390_TLS_LDO64 53 /* 64 bit offset relative to TLS - block. */ -#define R_390_TLS_DTPMOD 54 /* ID of module containing symbol. */ -#define R_390_TLS_DTPOFF 55 /* Offset in TLS block. */ -#define R_390_TLS_TPOFF 56 /* Negated offset in static TLS - block. */ -#define R_390_20 57 /* Direct 20 bit. */ -#define R_390_GOT20 58 /* 20 bit GOT offset. */ -#define R_390_GOTPLT20 59 /* 20 bit offset to jump slot. */ -#define R_390_TLS_GOTIE20 60 /* 20 bit GOT offset for static TLS - block offset. */ -/* Keep this the last entry. */ -#define R_390_NUM 61 - - -/* CRIS relocations. */ -#define R_CRIS_NONE 0 -#define R_CRIS_8 1 -#define R_CRIS_16 2 -#define R_CRIS_32 3 -#define R_CRIS_8_PCREL 4 -#define R_CRIS_16_PCREL 5 -#define R_CRIS_32_PCREL 6 -#define R_CRIS_GNU_VTINHERIT 7 -#define R_CRIS_GNU_VTENTRY 8 -#define R_CRIS_COPY 9 -#define R_CRIS_GLOB_DAT 10 -#define R_CRIS_JUMP_SLOT 11 -#define R_CRIS_RELATIVE 12 -#define R_CRIS_16_GOT 13 -#define R_CRIS_32_GOT 14 -#define R_CRIS_16_GOTPLT 15 -#define R_CRIS_32_GOTPLT 16 -#define R_CRIS_32_GOTREL 17 -#define R_CRIS_32_PLT_GOTREL 18 -#define R_CRIS_32_PLT_PCREL 19 - -#define R_CRIS_NUM 20 - - -/* AMD x86-64 relocations. */ -#define R_X86_64_NONE 0 /* No reloc */ -#define R_X86_64_64 1 /* Direct 64 bit */ -#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ -#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ -#define R_X86_64_PLT32 4 /* 32 bit PLT address */ -#define R_X86_64_COPY 5 /* Copy symbol at runtime */ -#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ -#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ -#define R_X86_64_RELATIVE 8 /* Adjust by program base */ -#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative - offset to GOT */ -#define R_X86_64_32 10 /* Direct 32 bit zero extended */ -#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ -#define R_X86_64_16 12 /* Direct 16 bit zero extended */ -#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ -#define R_X86_64_8 14 /* Direct 8 bit sign extended */ -#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ -#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */ -#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */ -#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */ -#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset - to two GOT entries for GD symbol */ -#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset - to two GOT entries for LD symbol */ -#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */ -#define R_X86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset - to GOT entry for IE symbol */ -#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */ - -#define R_X86_64_NUM 24 - - -/* AM33 relocations. */ -#define R_MN10300_NONE 0 /* No reloc. */ -#define R_MN10300_32 1 /* Direct 32 bit. */ -#define R_MN10300_16 2 /* Direct 16 bit. */ -#define R_MN10300_8 3 /* Direct 8 bit. */ -#define R_MN10300_PCREL32 4 /* PC-relative 32-bit. */ -#define R_MN10300_PCREL16 5 /* PC-relative 16-bit signed. */ -#define R_MN10300_PCREL8 6 /* PC-relative 8-bit signed. */ -#define R_MN10300_GNU_VTINHERIT 7 /* Ancient C++ vtable garbage... */ -#define R_MN10300_GNU_VTENTRY 8 /* ... collection annotation. */ -#define R_MN10300_24 9 /* Direct 24 bit. */ -#define R_MN10300_GOTPC32 10 /* 32-bit PCrel offset to GOT. */ -#define R_MN10300_GOTPC16 11 /* 16-bit PCrel offset to GOT. */ -#define R_MN10300_GOTOFF32 12 /* 32-bit offset from GOT. */ -#define R_MN10300_GOTOFF24 13 /* 24-bit offset from GOT. */ -#define R_MN10300_GOTOFF16 14 /* 16-bit offset from GOT. */ -#define R_MN10300_PLT32 15 /* 32-bit PCrel to PLT entry. */ -#define R_MN10300_PLT16 16 /* 16-bit PCrel to PLT entry. */ -#define R_MN10300_GOT32 17 /* 32-bit offset to GOT entry. */ -#define R_MN10300_GOT24 18 /* 24-bit offset to GOT entry. */ -#define R_MN10300_GOT16 19 /* 16-bit offset to GOT entry. */ -#define R_MN10300_COPY 20 /* Copy symbol at runtime. */ -#define R_MN10300_GLOB_DAT 21 /* Create GOT entry. */ -#define R_MN10300_JMP_SLOT 22 /* Create PLT entry. */ -#define R_MN10300_RELATIVE 23 /* Adjust by program base. */ - -#define R_MN10300_NUM 24 - - -/* M32R relocs. */ -#define R_M32R_NONE 0 /* No reloc. */ -#define R_M32R_16 1 /* Direct 16 bit. */ -#define R_M32R_32 2 /* Direct 32 bit. */ -#define R_M32R_24 3 /* Direct 24 bit. */ -#define R_M32R_10_PCREL 4 /* PC relative 10 bit shifted. */ -#define R_M32R_18_PCREL 5 /* PC relative 18 bit shifted. */ -#define R_M32R_26_PCREL 6 /* PC relative 26 bit shifted. */ -#define R_M32R_HI16_ULO 7 /* High 16 bit with unsigned low. */ -#define R_M32R_HI16_SLO 8 /* High 16 bit with signed low. */ -#define R_M32R_LO16 9 /* Low 16 bit. */ -#define R_M32R_SDA16 10 /* 16 bit offset in SDA. */ -#define R_M32R_GNU_VTINHERIT 11 -#define R_M32R_GNU_VTENTRY 12 -/* M32R relocs use SHT_RELA. */ -#define R_M32R_16_RELA 33 /* Direct 16 bit. */ -#define R_M32R_32_RELA 34 /* Direct 32 bit. */ -#define R_M32R_24_RELA 35 /* Direct 24 bit. */ -#define R_M32R_10_PCREL_RELA 36 /* PC relative 10 bit shifted. */ -#define R_M32R_18_PCREL_RELA 37 /* PC relative 18 bit shifted. */ -#define R_M32R_26_PCREL_RELA 38 /* PC relative 26 bit shifted. */ -#define R_M32R_HI16_ULO_RELA 39 /* High 16 bit with unsigned low */ -#define R_M32R_HI16_SLO_RELA 40 /* High 16 bit with signed low */ -#define R_M32R_LO16_RELA 41 /* Low 16 bit */ -#define R_M32R_SDA16_RELA 42 /* 16 bit offset in SDA */ -#define R_M32R_RELA_GNU_VTINHERIT 43 -#define R_M32R_RELA_GNU_VTENTRY 44 - -#define R_M32R_GOT24 48 /* 24 bit GOT entry */ -#define R_M32R_26_PLTREL 49 /* 26 bit PC relative to PLT shifted */ -#define R_M32R_COPY 50 /* Copy symbol at runtime */ -#define R_M32R_GLOB_DAT 51 /* Create GOT entry */ -#define R_M32R_JMP_SLOT 52 /* Create PLT entry */ -#define R_M32R_RELATIVE 53 /* Adjust by program base */ -#define R_M32R_GOTOFF 54 /* 24 bit offset to GOT */ -#define R_M32R_GOTPC24 55 /* 24 bit PC relative offset to GOT */ -#define R_M32R_GOT16_HI_ULO 56 /* High 16 bit GOT entry with unsigned - low */ -#define R_M32R_GOT16_HI_SLO 57 /* High 16 bit GOT entry with signed - low */ -#define R_M32R_GOT16_LO 58 /* Low 16 bit GOT entry */ -#define R_M32R_GOTPC_HI_ULO 59 /* High 16 bit PC relative offset to - GOT with unsigned low */ -#define R_M32R_GOTPC_HI_SLO 60 /* High 16 bit PC relative offset to - GOT with signed low */ -#define R_M32R_GOTPC_LO 61 /* Low 16 bit PC relative offset to - GOT */ -#define R_M32R_GOTOFF_HI_ULO 62 /* High 16 bit offset to GOT - with unsigned low */ -#define R_M32R_GOTOFF_HI_SLO 63 /* High 16 bit offset to GOT - with signed low */ -#define R_M32R_GOTOFF_LO 64 /* Low 16 bit offset to GOT */ -#define R_M32R_NUM 256 /* Keep this the last entry. */ - - -struct rusage { - struct timeval ru_utime; /* user time used */ - struct timeval ru_stime; /* system time used */ - long ru_maxrss; /* maximum resident set size */ - long ru_ixrss; /* integral shared memory size */ - long ru_idrss; /* integral unshared data size */ - long ru_isrss; /* integral unshared stack size */ - long ru_minflt; /* page reclaims */ - long ru_majflt; /* page faults */ - long ru_nswap; /* swaps */ - long ru_inblock; /* block input operations */ - long ru_oublock; /* block output operations */ - long ru_msgsnd; /* messages sent */ - long ru_msgrcv; /* messages received */ - long ru_nsignals; /* signals received */ - long ru_nvcsw; /* voluntary context switches */ - long ru_nivcsw; /* involuntary context switches */ -}; - -/** OpenBSD only ? for getdirentries **/ - -#define MAXNAMLEN 255 -struct bsd_dirent { - uint32_t d_fileno; - uint16_t d_reclen; - uint8_t d_type; - uint8_t d_namlen; - char d_name[MAXNAMLEN + 1]; -}; - -/* semop system calls takes an array of these. */ -struct sembuf { - unsigned short sem_num; /* semaphore index in array */ - short sem_op; /* semaphore operation */ - short sem_flg; /* operation flags */ -}; - diff --git a/dest/include/librz/sflib/darwin-arm-64/sflib.h b/dest/include/librz/sflib/darwin-arm-64/sflib.h deleted file mode 100644 index 4eccee4257e..00000000000 --- a/dest/include/librz/sflib/darwin-arm-64/sflib.h +++ /dev/null @@ -1,213 +0,0 @@ -// SPDX-FileCopyrightText: 2004 Philippe Biondi -// SPDX-License-Identifier: LGPL-2.1-only - -/* - * sflib.h --- SFLib syscall library for OpenBSD/i386 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - -/* - * Automatically generated by gensflib.py - * Fri Nov 25 15:52:34 2011 - */ - -#ifndef SFLIB_H -#define SFLIB_H - -#include "sfsysnr.h" -#include "sfsyscall.h" -#include "../common/sftypes.h" - -// syscall -static inline _sfsyscall1(void, exit, int, status) -static inline _sfsyscall0(pid_t, fork) -static inline _sfsyscall3(ssize_t, read, int, fd, void *, buf, size_t, count) -static inline _sfsyscall3(ssize_t, write, int, fd, const void *, buf, size_t, count) -static inline _sfsyscall3(int, open, const char *, pathname, int, flags, mode_t, mode) -static inline _sfsyscall1(int, close, int, fd) -static inline _sfsyscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, struct rusage *, rusage) -static inline _sfsyscall2(int, link, const char *, oldpath, const char *, newpath) -static inline _sfsyscall1(int, unlink, const char *, pathname) -static inline _sfsyscall1(int, chdir, const char *, path) -// fchdir -static inline _sfsyscall3(int, mknod, const char *, pathname, mode_t, mode, dev_t, dev) -static inline _sfsyscall2(int, chmod, const char *, path, mode_t, mode) -static inline _sfsyscall3(int, chown, const char *, path, uid_t, owner, gid_t, group) -// break -static inline _sfsyscall0(pid_t, getpid) -// mount -// unmount -// setuid -static inline _sfsyscall1(int, setuid, uid_t, uid) -static inline _sfsyscall1(int, setgid, gid_t, gid) -static inline _sfsyscall0(uid_t, getuid) -static inline _sfsyscall0(uid_t, geteuid) -static inline _sfsyscall4(long, ptrace, int, request, pid_t, pid, void *, addr, void *, data) -// recvmsg -// sendmsg -static inline _sfsyscall6(ssize_t, recvfrom, int, s, void *, buf, size_t, len, int, flags, struct sockaddr *, from, socklen_t *, fromlen) -static inline _sfsyscall3(int, accept, int, s, struct sockaddr *, addr, socklen_t *, addrlen); -// getpeername -// getsockname -static inline _sfsyscall2(int, access, const char *, pathname, int, mode) -// chflags -// fchflags -static inline _sfsyscall0(int, sync) -static inline _sfsyscall2(int, kill, pid_t, pid, int, sig) -static inline _sfsyscall0(pid_t, getppid) -static inline _sfsyscall1(int, dup, int, oldfd) -// opipe -static inline _sfsyscall0(gid_t, getegid) -// profil -// ktrace -// sigaction -static inline _sfsyscall0(gid_t, getgid) -// sigprocmask -// getlogin -// setlogin -static inline _sfsyscall1(int, acct, const char *, filename) -static inline _sfsyscall1(int, sigpending, sigset_t *, set) -// sigaltstack -static inline _sfsyscall4(int, ioctl, int, d, int, request, char *, argp, int, len) -// reboot -// revoke -static inline _sfsyscall2(int, symlink, const char *, oldpath, const char *, newpath) -static inline _sfsyscall3(int, readlink, const char *, path, char *, buf, size_t, bufsiz) -static inline _sfsyscall3(int, execve, char *, s, char **, argv, char **, envp) -static inline _sfsyscall1(mode_t, umask, mode_t, mask) -static inline _sfsyscall1(int, chroot, const char *, path) -// omsync -static inline _sfsyscall0(pid_t, vfork) -// sbrk -// sstk -// vadvise -static inline _sfsyscall2(int, munmap, void *, start, size_t, length) -static inline _sfsyscall3(int, mprotect, const void *, addr, size_t, len, int, prot) -// madvise -// mincore -// getgroups -static inline _sfsyscall2(int, setgroups, size_t, size, const gid_t *, list) -static inline _sfsyscall0(pid_t, getpgrp) -static inline _sfsyscall2(int, setpgid, pid_t, pid, pid_t, pgid) -// setitimer -static inline _sfsyscall2(int, swapon, const char *, path, int, swapflags) -// getitimer -static inline _sfsyscall2(int, dup2, int, oldfd, int, newfd) -static inline _sfsyscall3(int, fcntl, int, fd, int, cmd, long, arg) -static inline _sfsyscall5(int, select, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout) -static inline _sfsyscall1(int, fsync, int, fd) -static inline _sfsyscall3(int, setpriority, int, which, int, who, int, prio) -static inline _sfsyscall3(int, socket, int, domain, int, type, int, protocol) -static inline _sfsyscall3(int, connect, int, sockfd, const struct sockaddr *, serv_addr, socklen_t, addrlen) -static inline _sfsyscall2(int, getpriority, int, which, int, who) -static inline _sfsyscall1(int, sigreturn, unsigned long, __unused) -static inline _sfsyscall3(int, bind, int, sockfd, struct sockaddr *, my_addr, socklen_t, addrlen) -static inline _sfsyscall5(int, setsockopt, int, s, int, level, int, optname, void *, optval, socklen_t, optlen) -static inline _sfsyscall2(int, listen, int, s, int, backlog) -static inline _sfsyscall1(int, sigsuspend, const sigset_t *, mask) -static inline _sfsyscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz) -// getrusage -// getsockopt -static inline _sfsyscall3(int, readv, int, fd, const struct iovec *, vector, int, count) -static inline _sfsyscall3(int, writev, int, fd, const struct iovec *, vector, int, count) -// settimeofday -static inline _sfsyscall3(int, fchown, int, fd, uid_t, owner, gid_t, group) -static inline _sfsyscall2(int, fchmod, int, fildes, mode_t, mode) -static inline _sfsyscall2(int, rename, const char *, oldpath, const char *, newpath) -// flock -// mkfifo -static inline _sfsyscall6(ssize_t, sendto, int, s, const void *, msg, size_t, len, int, flags, const struct sockaddr *, to, socklen_t, tolen) -// shutdown -// socketpair -static inline _sfsyscall2(int, mkdir, const char *, pathname, mode_t, mode) -static inline _sfsyscall1(int, rmdir, const char *, pathname) -// utimes -// adjtime -static inline _sfsyscall0(pid_t, setsid) -// quotactl -// nfssvc -// getfh -// sysarch -static inline _sfsyscall4(ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset) -// pwrite -// setgid -// setegid -// seteuid -// lfs_bmapv -// lfs_markv -// lfs_segclean -// lfs_segwait -static inline _sfsyscall2(int, stat, const char *, file_name, struct stat *, buf) -static inline _sfsyscall2(int, fstat, int, filedes, struct stat *, buf) -static inline _sfsyscall2(int, lstat, const char *, file_name, struct stat *, buf) -// pathconf -// fpathconf -// swapctl -// getrlimit -// setrlimit -static inline _sfsyscall4(int, getdirentries, int, fd, void *, buf, int, nbytes, long *, basep) -static inline _sfsyscall6(void *, mmap, void *, start, size_t, length, int, prot, int, flags, int, fd, off_t, offset) -static inline _sfsyscall3(off_t, lseek, int, fildes, off_t, offset, int, whence) -static inline _sfsyscall2(int, truncate, const char *, path, off_t, length) -static inline _sfsyscall2(int, ftruncate, int, fd, off_t, length) -static inline _sfsyscall2(int, mlock, const void *, addr, size_t, len) -static inline _sfsyscall2(int, munlock, const void *, addr, size_t, len) -// undelete -// futimes -static inline _sfsyscall1(pid_t, getpgid, pid_t, pid) -// xfspioctl -static inline _sfsyscall3(int, semget, long, key, int, nsems, int, semflg) -static inline _sfsyscall3(int, semop, int, semid, struct sembuf *, sops, unsigned, nsops) -// msgget -// msgsnd -// msgrcv -static inline _sfsyscall3(void *, shmat, int, shmid, const void *, shmaddr, int, shmflg) -// shmdt -static inline _sfsyscall3(int, shmget, long, key, int, size, int, flags) -// clock_gettime -// clock_settime -// clock_getres -static inline _sfsyscall2(int, nanosleep, const struct timespec *, req, struct timespec *, rem) -// minherit -// rfork -static inline _sfsyscall3(int, poll, struct pollfd *, ufds, unsigned int, nfds, int, timeout) -// issetugid -static inline _sfsyscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group) -static inline _sfsyscall1(pid_t, getsid, pid_t, pid) -static inline _sfsyscall3(int, msync, const void *, start, size_t, length, int, flags) -// shmctl -// msgctl -// getfsstat -static inline _sfsyscall2(int, statfs, const char *, path, struct statfs *, buf) -static inline _sfsyscall2(int, fstatfs, int, fd, struct statfs *, buf) -static inline _sfsyscall1(int, pipe, unsigned long *, filedes) -// fhopen -// fhstat -// fhstatfs -// preadv -// pwritev -// kqueue -// kevent -static inline _sfsyscall1(int, mlockall, int, flags) -static inline _sfsyscall0(int, munlockall) -// getpeereid -// extattrctl -// extattr_set_file -// extattr_get_file -// extattr_delete_file -// extattr_set_fd -// extattr_get_fd -// extattr_delete_fd - -#endif /* SFLIB_H */ \ No newline at end of file diff --git a/dest/include/librz/sflib/darwin-arm-64/sfsyscall.h b/dest/include/librz/sflib/darwin-arm-64/sfsyscall.h deleted file mode 100644 index 50d5189dfd5..00000000000 --- a/dest/include/librz/sflib/darwin-arm-64/sfsyscall.h +++ /dev/null @@ -1,158 +0,0 @@ -// SPDX-FileCopyrightText: 2004 Philippe Biondi -// SPDX-License-Identifier: LGPL-2.1-only - -// ssed on the registers rdi, rsi, rdx, r10, r8 and r9 -/* - * sfsyscall.h --- SFLib syscall macros for OpenBSD/i386 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - -#ifndef SFSYSCALL_H -#define SFSYSCALL_H - -#ifdef SF_USE_ERRNO -/* Remove errno stuff */ -int errno; -#error "SF_USER_ERRNO not supported yet" -#else -#define __sfsyscall_return(type, res) \ - do { \ - return (type)(res); \ - } while (0) -#endif - -/* syscall macros */ -// x16 holds syscallnumber - -#define _sfsyscall0(type, name) \ - type name(void) { \ - long __res; \ - __asm__ volatile( \ - "movz x16, %1\n" \ - "svc 0x80" \ - : "=r"(__res) \ - : "K"(__NR_##name)); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall1(type, name, type1, arg1) \ - type name(type1 arg1) { \ - long __res; \ - __asm__ volatile( \ - "movz x16, %1\n" \ - "ldr x0, %2\n\t" \ - "svc 0x80\n\t" \ - : "=r"(__res) \ - : "g"(__NR_##name), "g"((long)(arg1))); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall2(type, name, type1, arg1, type2, arg2) \ - type name(type1 arg1, type2 arg2) { \ - long __res; \ - __asm__ volatile( \ - "ldr x0, %2\n\t" \ - "ldr x1, %3\n\t" \ - "mov x16, %1\n\t" \ - "svc 0x80\n\t" \ - : "=r"(__res) \ - : "I"(__NR_##name), "g"((long)(arg1)), "g"((long)(arg2))); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall3ipi(type, name, type1, arg1, type2, arg2, type3, arg3) \ - type name(type1 arg1, type2 arg2, type3 arg3) { \ - long __res; \ - __asm__ volatile( \ - "movz x0, %2\n\t" \ - "ldr x1, %3\n\t" \ - "mov x2, %4\n\t" \ - "mov x16, %1\n\t" \ - "svc 0x80\n\t" \ - : "=r"(__res) \ - : "S"(__NR_##name), \ - "r"(arg1), \ - "S"(arg2), \ - "g"((long)(arg3))); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ - type name(type1 arg1, type2 arg2, type3 arg3) { \ - long __res; \ - __asm__ volatile( \ - "movz x0, %2\n\t" \ - "ldr x1, %3\n\t" \ - "movz x2, %4\n\t" \ - "ldr x16, %1\n\t" \ - "svc 0x80\n\t" \ - : "=r"(__res) \ - : "I"(__NR_##name), "g"((long)(arg1)), "g"((long)(arg2)), \ - "g"((long)(arg3))); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall4(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ - long __res; \ - __asm__ volatile( \ - "mov x0, %2\n\t" \ - "mov x1, %3\n\t" \ - "mov x2, %4\n\t" \ - "mov x3, %5\n\t" \ - "mov x16, %1\n\t" \ - "svc 0x80\n\t" \ - : "=r"(__res) \ - : "I"(__NR_##name), "g"((long)(arg1)), "r"((long)(arg2)), \ - "r"((long)(arg3)), "S"((long)(arg4))); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall5(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, \ - type5, arg5) \ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \ - long __res; \ - __asm__ volatile("mov x0, %2\n\t" \ - "mov x1, %3\n\t" \ - "mov x2, %4\n\t" \ - "mov x3, %5\n\t" \ - "mov x4, %6\n\t" \ - "mov x16, %1\n\t" \ - "svc 0x80\n\t" \ - : "=r"(__res) \ - : "I"(__NR_##name), "g"((long)(arg1)), "g"((long)(arg2)), \ - "g"((long)(arg3)), "g"((long)(arg4)), "g"((long)(arg5))); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall6(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, \ - type5, arg5, type6, arg6) \ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) { \ - long __res; \ - __asm__ volatile("mov x0, %2\n\t" \ - "mov x1, %3\n\t" \ - "mov x2, %4\n\t" \ - "mov x3, %5\n\t" \ - "mov x4, %6\n\t" \ - "mov x5, %7\n\t" \ - "mov x16, %1\n\t" \ - "svc 0x80\n\t" \ - : "=r"(__res) \ - : "I"(__NR_##name), "g"((long)(arg1)), "g"((long)(arg2)), \ - "g"((long)(arg3)), "g"((long)(arg4)), "g"((long)(arg5)), \ - "g"((long)(arg6))); \ - __sfsyscall_return(type, __res); \ - } - -#endif /* SFSYSCALL_H */ diff --git a/dest/include/librz/sflib/darwin-arm-64/sfsysnr.h b/dest/include/librz/sflib/darwin-arm-64/sfsysnr.h deleted file mode 100644 index d79908709b5..00000000000 --- a/dest/include/librz/sflib/darwin-arm-64/sfsysnr.h +++ /dev/null @@ -1,684 +0,0 @@ -// SPDX-FileCopyrightText: 2004 Philippe Biondi -// SPDX-License-Identifier: LGPL-2.1-only - -/* - * sfsysnr.h --- SFLib syscall numbers for OpenBSD/i386 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - -/* - * Automatically generated by gensflib.py - * Fri Nov 25 15:52:34 2011 - */ - -#ifndef SFSYSNR_H -#define SFSYSNR_H - -/* $Id$ */ - -/* - * Modified from /usr/include/sys/syscall.h - * created from OpenBSD: syscalls.master,v 1.50 2002/07/06 19:14:20 nordin Exp - */ - -/* syscall: "syscall" ret: "int" args: "int" "..." */ -#define __NR_syscall 0 - -/* syscall: "exit" ret: "void" args: "int" */ -#define __NR_exit 1 - -/* syscall: "fork" ret: "int" args: */ -#define __NR_fork 2 - -/* syscall: "read" ret: "ssize_t" args: "int" "void *" "size_t" */ -#define __NR_read 3 - -/* syscall: "write" ret: "ssize_t" args: "int" "const void *" "size_t" */ -#define __NR_write 4 - -/* syscall: "open" ret: "int" args: "const char *" "int" "..." */ -#define __NR_open 5 - -/* syscall: "close" ret: "int" args: "int" */ -#define __NR_close 6 - -/* syscall: "wait4" ret: "int" args: "int" "int *" "int" "struct rusage *" */ -#define __NR_wait4 7 - -/* 8 is compat_43 ocreat */ - -/* syscall: "link" ret: "int" args: "const char *" "const char *" */ -#define __NR_link 9 - -/* syscall: "unlink" ret: "int" args: "const char *" */ -#define __NR_unlink 10 - -/* 11 is obsolete execv */ -/* syscall: "chdir" ret: "int" args: "const char *" */ -#define __NR_chdir 12 - -/* syscall: "fchdir" ret: "int" args: "int" */ -#define __NR_fchdir 13 - -/* syscall: "mknod" ret: "int" args: "const char *" "int" "dev_t" */ -#define __NR_mknod 14 - -/* syscall: "chmod" ret: "int" args: "const char *" "int" */ -#define __NR_chmod 15 - -/* syscall: "chown" ret: "int" args: "const char *" "uid_t" "gid_t" */ -#define __NR_chown 16 - -/* syscall: "break" ret: "int" args: "char *" */ -#define __NR_break 17 - -/* 18 is compat_25 ogetfsstat */ - -/* 19 is compat_43 olseek */ - -/* syscall: "getpid" ret: "pid_t" args: */ -#define __NR_getpid 20 - -/* syscall: "mount" ret: "int" args: "const char *" "const char *" "int" "void *" */ -#define __NR_mount 21 - -/* syscall: "unmount" ret: "int" args: "const char *" "int" */ -#define __NR_unmount 22 - -/* syscall: "setuid" ret: "int" args: "uid_t" */ -#define __NR_setuid 23 - -/* syscall: "getuid" ret: "uid_t" args: */ -#define __NR_getuid 24 - -/* syscall: "geteuid" ret: "uid_t" args: */ -#define __NR_geteuid 25 - -/* syscall: "ptrace" ret: "int" args: "int" "pid_t" "caddr_t" "int" */ -#define __NR_ptrace 26 - -/* syscall: "recvmsg" ret: "ssize_t" args: "int" "struct msghdr *" "int" */ -#define __NR_recvmsg 27 - -/* syscall: "sendmsg" ret: "ssize_t" args: "int" "const struct msghdr *" "int" */ -#define __NR_sendmsg 28 - -/* syscall: "recvfrom" ret: "ssize_t" args: "int" "void *" "size_t" "int" "struct sockaddr *" "socklen_t *" */ -#define __NR_recvfrom 29 - -/* syscall: "accept" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ -#define __NR_accept 30 - -/* syscall: "getpeername" ret: "int" args: "int" "struct sockaddr *" "int *" */ -#define __NR_getpeername 31 - -/* syscall: "getsockname" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ -#define __NR_getsockname 32 - -/* syscall: "access" ret: "int" args: "const char *" "int" */ -#define __NR_access 33 - -/* syscall: "chflags" ret: "int" args: "const char *" "u_int" */ -#define __NR_chflags 34 - -/* syscall: "fchflags" ret: "int" args: "int" "u_int" */ -#define __NR_fchflags 35 - -/* syscall: "sync" ret: "void" args: */ -#define __NR_sync 36 - -/* syscall: "kill" ret: "int" args: "int" "int" */ -#define __NR_kill 37 - -/* 38 is compat_43 ostat */ - -/* syscall: "getppid" ret: "pid_t" args: */ -#define __NR_getppid 39 - -/* 40 is compat_43 olstat */ - -/* syscall: "dup" ret: "int" args: "int" */ -#define __NR_dup 41 - -/* syscall: "opipe" ret: "int" args: */ -#define __NR_opipe 42 - -/* syscall: "getegid" ret: "gid_t" args: */ -#define __NR_getegid 43 - -/* syscall: "profil" ret: "int" args: "caddr_t" "size_t" "u_long" "u_int" */ -#define __NR_profil 44 - -/* syscall: "ktrace" ret: "int" args: "const char *" "int" "int" "pid_t" */ -#define __NR_ktrace 45 - -/* syscall: "sigaction" ret: "int" args: "int" "const struct sigaction *" "struct sigaction *" */ -#define __NR_sigaction 46 - -/* syscall: "getgid" ret: "gid_t" args: */ -#define __NR_getgid 47 - -/* syscall: "sigprocmask" ret: "int" args: "int" "sigset_t" */ -#define __NR_sigprocmask 48 - -/* syscall: "getlogin" ret: "int" args: "char *" "u_int" */ -#define __NR_getlogin 49 - -/* syscall: "setlogin" ret: "int" args: "const char *" */ -#define __NR_setlogin 50 - -/* syscall: "acct" ret: "int" args: "const char *" */ -#define __NR_acct 51 - -/* syscall: "sigpending" ret: "int" args: */ -#define __NR_sigpending 52 - -/* syscall: "sigaltstack" ret: "int" args: "const struct sigaltstack *" "struct sigaltstack *" */ -#define __NR_sigaltstack 53 - -/* syscall: "ioctl" ret: "int" args: "int" "u_long" "..." */ -#define __NR_ioctl 54 - -/* syscall: "reboot" ret: "int" args: "int" */ -#define __NR_reboot 55 - -/* syscall: "revoke" ret: "int" args: "const char *" */ -#define __NR_revoke 56 - -/* syscall: "symlink" ret: "int" args: "const char *" "const char *" */ -#define __NR_symlink 57 - -/* syscall: "readlink" ret: "int" args: "const char *" "char *" "size_t" */ -#define __NR_readlink 58 - -/* syscall: "execve" ret: "int" args: "const char *" "char *const *" "char *const *" */ -#define __NR_execve 59 - -/* syscall: "umask" ret: "int" args: "int" */ -#define __NR_umask 60 - -/* syscall: "chroot" ret: "int" args: "const char *" */ -#define __NR_chroot 61 - -/* 62 is compat_43 ofstat */ - -/* 63 is compat_43 ogetkerninfo */ - -/* 64 is compat_43 ogetpagesize */ - -/* syscall: "omsync" ret: "int" args: "caddr_t" "size_t" */ -#define __NR_omsync 65 - -/* syscall: "vfork" ret: "int" args: */ -#define __NR_vfork 66 - -/* 67 is obsolete vread */ -/* 68 is obsolete vwrite */ -/* syscall: "sbrk" ret: "int" args: "int" */ -#define __NR_sbrk 69 - -/* syscall: "sstk" ret: "int" args: "int" */ -#define __NR_sstk 70 - -/* 71 is compat_43 ommap */ - -/* syscall: "vadvise" ret: "int" args: "int" */ -#define __NR_vadvise 72 - -/* syscall: "munmap" ret: "int" args: "void *" "size_t" */ -#define __NR_munmap 73 - -/* syscall: "mprotect" ret: "int" args: "void *" "size_t" "int" */ -#define __NR_mprotect 74 - -/* syscall: "madvise" ret: "int" args: "void *" "size_t" "int" */ -#define __NR_madvise 75 - -/* 76 is obsolete vhangup */ -/* 77 is obsolete vlimit */ -/* syscall: "mincore" ret: "int" args: "void *" "size_t" "char *" */ -#define __NR_mincore 78 - -/* syscall: "getgroups" ret: "int" args: "int" "gid_t *" */ -#define __NR_getgroups 79 - -/* syscall: "setgroups" ret: "int" args: "int" "const gid_t *" */ -#define __NR_setgroups 80 - -/* syscall: "getpgrp" ret: "int" args: */ -#define __NR_getpgrp 81 - -/* syscall: "setpgid" ret: "int" args: "pid_t" "int" */ -#define __NR_setpgid 82 - -/* syscall: "setitimer" ret: "int" args: "int" "const struct itimerval *" "struct itimerval *" */ -#define __NR_setitimer 83 - -/* 84 is compat_43 owait */ - -/* syscall: "swapon" ret: "int" args: "const char *" */ -#define __NR_swapon 85 - -/* syscall: "getitimer" ret: "int" args: "int" "struct itimerval *" */ -#define __NR_getitimer 86 - -/* 87 is compat_43 ogethostname */ - -/* 88 is compat_43 osethostname */ - -/* 89 is compat_43 ogetdtablesize */ - -/* syscall: "dup2" ret: "int" args: "int" "int" */ -#define __NR_dup2 90 - -/* syscall: "fcntl" ret: "int" args: "int" "int" "..." */ -#define __NR_fcntl 92 - -/* syscall: "select" ret: "int" args: "int" "fd_set *" "fd_set *" "fd_set *" "struct timeval *" */ -#define __NR_select 93 - -/* syscall: "fsync" ret: "int" args: "int" */ -#define __NR_fsync 95 - -/* syscall: "setpriority" ret: "int" args: "int" "int" "int" */ -#define __NR_setpriority 96 - -/* syscall: "socket" ret: "int" args: "int" "int" "int" */ -#define __NR_socket 97 - -/* syscall: "connect" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */ -#define __NR_connect 98 - -/* 99 is compat_43 oaccept */ - -/* syscall: "getpriority" ret: "int" args: "int" "int" */ -#define __NR_getpriority 100 - -/* 101 is compat_43 osend */ - -/* 102 is compat_43 orecv */ - -/* syscall: "sigreturn" ret: "int" args: "struct sigcontext *" */ -#define __NR_sigreturn 103 - -/* syscall: "bind" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */ -#define __NR_bind 104 - -/* syscall: "setsockopt" ret: "int" args: "int" "int" "int" "const void *" "socklen_t" */ -#define __NR_setsockopt 105 - -/* syscall: "listen" ret: "int" args: "int" "int" */ -#define __NR_listen 106 - -/* 107 is obsolete vtimes */ -/* 108 is compat_43 osigvec */ - -/* 109 is compat_43 osigblock */ - -/* 110 is compat_43 osigsetmask */ - -/* syscall: "sigsuspend" ret: "int" args: "int" */ -#define __NR_sigsuspend 111 - -/* 112 is compat_43 osigstack */ - -/* 113 is compat_43 orecvmsg */ - -/* 114 is compat_43 osendmsg */ - -/* 115 is obsolete vtrace */ -/* syscall: "gettimeofday" ret: "int" args: "struct timeval *" "struct timezone *" */ -#define __NR_gettimeofday 116 - -/* syscall: "getrusage" ret: "int" args: "int" "struct rusage *" */ -#define __NR_getrusage 117 - -/* syscall: "getsockopt" ret: "int" args: "int" "int" "int" "void *" "socklen_t *" */ -#define __NR_getsockopt 118 - -/* 119 is obsolete resuba */ -/* syscall: "readv" ret: "ssize_t" args: "int" "const struct iovec *" "int" */ -#define __NR_readv 120 - -/* syscall: "writev" ret: "ssize_t" args: "int" "const struct iovec *" "int" */ -#define __NR_writev 121 - -/* syscall: "settimeofday" ret: "int" args: "const struct timeval *" "const struct timezone *" */ -#define __NR_settimeofday 122 - -/* syscall: "fchown" ret: "int" args: "int" "uid_t" "gid_t" */ -#define __NR_fchown 123 - -/* syscall: "fchmod" ret: "int" args: "int" "int" */ -#define __NR_fchmod 124 - -/* 125 is compat_43 orecvfrom */ - -/* 126 is compat_43 osetreuid */ - -/* 127 is compat_43 osetregid */ - -/* syscall: "rename" ret: "int" args: "const char *" "const char *" */ -#define __NR_rename 128 - -/* 129 is compat_43 otruncate */ - -/* 130 is compat_43 oftruncate */ - -/* syscall: "flock" ret: "int" args: "int" "int" */ -#define __NR_flock 131 - -/* syscall: "mkfifo" ret: "int" args: "const char *" "int" */ -#define __NR_mkfifo 132 - -/* syscall: "sendto" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "const struct sockaddr *" "socklen_t" */ -#define __NR_sendto 133 - -/* syscall: "shutdown" ret: "int" args: "int" "int" */ -#define __NR_shutdown 134 - -/* syscall: "socketpair" ret: "int" args: "int" "int" "int" "int *" */ -#define __NR_socketpair 135 - -/* syscall: "mkdir" ret: "int" args: "const char *" "int" */ -#define __NR_mkdir 136 - -/* syscall: "rmdir" ret: "int" args: "const char *" */ -#define __NR_rmdir 137 - -/* syscall: "utimes" ret: "int" args: "const char *" "const struct timeval *" */ -#define __NR_utimes 138 - -/* 139 is obsolete 4.2 sigreturn */ -/* syscall: "adjtime" ret: "int" args: "const struct timeval *" "struct timeval *" */ -#define __NR_adjtime 140 - -/* 141 is compat_43 ogetpeername */ - -/* 142 is compat_43 ogethostid */ - -/* 143 is compat_43 osethostid */ - -/* 144 is compat_43 ogetrlimit */ - -/* 145 is compat_43 osetrlimit */ - -/* 146 is compat_43 okillpg */ - -/* syscall: "setsid" ret: "int" args: */ -#define __NR_setsid 147 - -/* syscall: "quotactl" ret: "int" args: "const char *" "int" "int" "char *" */ -#define __NR_quotactl 148 - -/* 149 is compat_43 oquota */ - -/* 150 is compat_43 ogetsockname */ - -/* syscall: "nfssvc" ret: "int" args: "int" "void *" */ -#define __NR_nfssvc 155 - -/* 156 is compat_43 ogetdirentries */ - -/* 157 is compat_25 ostatfs */ - -/* 158 is compat_25 ostatfs */ - -/* syscall: "getfh" ret: "int" args: "const char *" "fhandle_t *" */ -#define __NR_getfh 161 - -/* 162 is compat_09 ogetdomainname */ - -/* 163 is compat_09 osetdomainname */ - -/* 164 is compat_09 ouname */ - -/* syscall: "sysarch" ret: "int" args: "int" "void *" */ -#define __NR_sysarch 165 - -/* 169 is compat_10 osemsys */ - -/* 170 is compat_10 omsgsys */ - -/* 171 is compat_10 oshmsys */ - -/* syscall: "pread" ret: "ssize_t" args: "int" "void *" "size_t" "int" "off_t" */ -#define __NR_pread 173 - -/* syscall: "pwrite" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "off_t" */ -#define __NR_pwrite 174 - -/* syscall: "setgid" ret: "int" args: "gid_t" */ -#define __NR_setgid 181 - -/* syscall: "setegid" ret: "int" args: "gid_t" */ -#define __NR_setegid 182 - -/* syscall: "seteuid" ret: "int" args: "uid_t" */ -#define __NR_seteuid 183 - -/* syscall: "lfs_bmapv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */ -#define __NR_lfs_bmapv 184 - -/* syscall: "lfs_markv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */ -#define __NR_lfs_markv 185 - -/* syscall: "lfs_segclean" ret: "int" args: "fsid_t *" "u_long" */ -#define __NR_lfs_segclean 186 - -/* syscall: "lfs_segwait" ret: "int" args: "fsid_t *" "struct timeval *" */ -#define __NR_lfs_segwait 187 - -/* syscall: "stat" ret: "int" args: "const char *" "struct stat *" */ -#define __NR_stat 188 - -/* syscall: "fstat" ret: "int" args: "int" "struct stat *" */ -#define __NR_fstat 189 - -/* syscall: "lstat" ret: "int" args: "const char *" "struct stat *" */ -#define __NR_lstat 190 - -/* syscall: "pathconf" ret: "long" args: "const char *" "int" */ -#define __NR_pathconf 191 - -/* syscall: "fpathconf" ret: "long" args: "int" "int" */ -#define __NR_fpathconf 192 - -/* syscall: "swapctl" ret: "int" args: "int" "const void *" "int" */ -#define __NR_swapctl 193 - -/* syscall: "getrlimit" ret: "int" args: "int" "struct rlimit *" */ -#define __NR_getrlimit 194 - -/* syscall: "setrlimit" ret: "int" args: "int" "const struct rlimit *" */ -#define __NR_setrlimit 195 - -/* syscall: "getdirentries" ret: "int" args: "int" "char *" "int" "long *" */ -#define __NR_getdirentries 196 - -/* syscall: "mmap" ret: "void *" args: "void *" "size_t" "int" "int" "int" "long" "off_t" */ -#define __NR_mmap 197 - -/* syscall: "__syscall" ret: "quad_t" args: "quad_t" "..." */ -#define __NR___syscall 198 - -/* syscall: "lseek" ret: "off_t" args: "int" "int" "off_t" "int" */ -#define __NR_lseek 199 - -/* syscall: "truncate" ret: "int" args: "const char *" "int" "off_t" */ -#define __NR_truncate 200 - -/* syscall: "ftruncate" ret: "int" args: "int" "int" "off_t" */ -#define __NR_ftruncate 201 - -/* syscall: "__sysctl" ret: "int" args: "int *" "u_int" "void *" "size_t *" "void *" "size_t" */ -#define __NR___sysctl 202 - -/* syscall: "mlock" ret: "int" args: "const void *" "size_t" */ -#define __NR_mlock 203 - -/* syscall: "munlock" ret: "int" args: "const void *" "size_t" */ -#define __NR_munlock 204 - -/* syscall: "undelete" ret: "int" args: "const char *" */ -#define __NR_undelete 205 - -/* syscall: "futimes" ret: "int" args: "int" "const struct timeval *" */ -#define __NR_futimes 206 - -/* syscall: "getpgid" ret: "pid_t" args: "pid_t" */ -#define __NR_getpgid 207 - -/* syscall: "xfspioctl" ret: "int" args: "int" "char *" "int" "struct ViceIoctl *" "int" */ -#define __NR_xfspioctl 208 - -/* 220 is compat_23 __osemctl */ - -/* syscall: "semget" ret: "int" args: "key_t" "int" "int" */ -#define __NR_semget 221 - -/* syscall: "semop" ret: "int" args: "int" "struct sembuf *" "u_int" */ -#define __NR_semop 222 - -/* 223 is obsolete sys_semconfig */ -/* 224 is compat_23 omsgctl */ - -/* syscall: "msgget" ret: "int" args: "key_t" "int" */ -#define __NR_msgget 225 - -/* syscall: "msgsnd" ret: "int" args: "int" "const void *" "size_t" "int" */ -#define __NR_msgsnd 226 - -/* syscall: "msgrcv" ret: "int" args: "int" "void *" "size_t" "long" "int" */ -#define __NR_msgrcv 227 - -/* syscall: "shmat" ret: "void *" args: "int" "const void *" "int" */ -#define __NR_shmat 228 - -/* 229 is compat_23 oshmctl */ - -/* syscall: "shmdt" ret: "int" args: "const void *" */ -#define __NR_shmdt 230 - -/* syscall: "shmget" ret: "int" args: "key_t" "int" "int" */ -#define __NR_shmget 231 - -/* syscall: "clock_gettime" ret: "int" args: "clockid_t" "struct timespec *" */ -#define __NR_clock_gettime 232 - -/* syscall: "clock_settime" ret: "int" args: "clockid_t" "const struct timespec *" */ -#define __NR_clock_settime 233 - -/* syscall: "clock_getres" ret: "int" args: "clockid_t" "struct timespec *" */ -#define __NR_clock_getres 234 - -/* syscall: "nanosleep" ret: "int" args: "const struct timespec *" "struct timespec *" */ -#define __NR_nanosleep 240 - -/* syscall: "minherit" ret: "int" args: "void *" "size_t" "int" */ -#define __NR_minherit 250 - -/* syscall: "rfork" ret: "int" args: "int" */ -#define __NR_rfork 251 - -/* syscall: "poll" ret: "int" args: "struct pollfd *" "unsigned long" "int" */ -#define __NR_poll 252 - -/* syscall: "issetugid" ret: "int" args: */ -#define __NR_issetugid 253 - -/* syscall: "lchown" ret: "int" args: "const char *" "uid_t" "gid_t" */ -#define __NR_lchown 254 - -/* syscall: "getsid" ret: "pid_t" args: "pid_t" */ -#define __NR_getsid 255 - -/* syscall: "msync" ret: "int" args: "void *" "size_t" "int" */ -#define __NR_msync 256 - -/* syscall: "__semctl" ret: "int" args: "int" "int" "int" "union semun *" */ -#define __NR___semctl 257 - -/* syscall: "shmctl" ret: "int" args: "int" "int" "struct shmid_ds *" */ -#define __NR_shmctl 258 - -/* syscall: "msgctl" ret: "int" args: "int" "int" "struct msqid_ds *" */ -#define __NR_msgctl 259 - -/* syscall: "getfsstat" ret: "int" args: "struct statfs *" "size_t" "int" */ -#define __NR_getfsstat 260 - -/* syscall: "statfs" ret: "int" args: "const char *" "struct statfs *" */ -#define __NR_statfs 261 - -/* syscall: "fstatfs" ret: "int" args: "int" "struct statfs *" */ -#define __NR_fstatfs 262 - -/* syscall: "pipe" ret: "int" args: "int *" */ -#define __NR_pipe 263 - -/* syscall: "fhopen" ret: "int" args: "const fhandle_t *" "int" */ -#define __NR_fhopen 264 - -/* syscall: "fhstat" ret: "int" args: "const fhandle_t *" "struct stat *" */ -#define __NR_fhstat 265 - -/* syscall: "fhstatfs" ret: "int" args: "const fhandle_t *" "struct statfs *" */ -#define __NR_fhstatfs 266 - -/* syscall: "preadv" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */ -#define __NR_preadv 267 - -/* syscall: "pwritev" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */ -#define __NR_pwritev 268 - -/* syscall: "kqueue" ret: "int" args: */ -#define __NR_kqueue 269 - -/* syscall: "kevent" ret: "int" args: "int" "const struct kevent *" "int" "struct kevent *" "int" "const struct timespec *" */ -#define __NR_kevent 270 - -/* syscall: "mlockall" ret: "int" args: "int" */ -#define __NR_mlockall 271 - -/* syscall: "munlockall" ret: "int" args: */ -#define __NR_munlockall 272 - -/* syscall: "getpeereid" ret: "int" args: "int" "uid_t *" "gid_t *" */ -#define __NR_getpeereid 273 - -/* syscall: "extattrctl" ret: "int" args: "const char *" "int" "const char *" "int" "const char *" */ -#define __NR_extattrctl 274 - -/* syscall: "extattr_set_file" ret: "int" args: "const char *" "int" "const char *" "void *" "size_t" */ -#define __NR_extattr_set_file 275 - -/* syscall: "extattr_get_file" ret: "ssize_t" args: "const char *" "int" "const char *" "void *" "size_t" */ -#define __NR_extattr_get_file 276 - -/* syscall: "extattr_delete_file" ret: "int" args: "const char *" "int" "const char *" */ -#define __NR_extattr_delete_file 277 - -/* syscall: "extattr_set_fd" ret: "int" args: "int" "int" "const char *" "void *" "size_t" */ -#define __NR_extattr_set_fd 278 - -/* syscall: "extattr_get_fd" ret: "ssize_t" args: "int" "int" "const char *" "void *" "size_t" */ -#define __NR_extattr_get_fd 279 - -/* syscall: "extattr_delete_fd" ret: "int" args: "int" "int" "const char *" */ -#define __NR_extattr_delete_fd 280 - -#define __NR_MAXSYSCALL 281 - -#endif /* SFSYSNR_H */ \ No newline at end of file diff --git a/dest/include/librz/sflib/darwin-x86-32/sflib.h b/dest/include/librz/sflib/darwin-x86-32/sflib.h deleted file mode 100644 index 76471976878..00000000000 --- a/dest/include/librz/sflib/darwin-x86-32/sflib.h +++ /dev/null @@ -1,210 +0,0 @@ -/* - * sflib.h --- SFLib syscall library for Darwin/i386 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - - -/* - * Automatically generated by gensflib.py - * Tue Apr 25 20:10:54 2023 - */ - -#ifndef SFLIB_H -#define SFLIB_H - - -#include "sfsysnr.h" -#include "sfsyscall.h" -#include "../common/sftypes.h" - -// syscall -static inline _sfsyscall1(void, exit, int, status) -static inline _sfsyscall0( pid_t, fork ) -static inline _sfsyscall3( ssize_t, read, int, fd, void *, buf, size_t, count ) -static inline _sfsyscall3( ssize_t, write, int, fd, const void *, buf, size_t, count ) -static inline _sfsyscall3( int, open, const char *, pathname, int, flags, mode_t, mode ) -static inline _sfsyscall1( int, close, int, fd ) -static inline _sfsyscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, struct rusage *, rusage) -static inline _sfsyscall2( int, link, const char *, oldpath, const char *, newpath ) -static inline _sfsyscall1( int, unlink, const char *, pathname ) -static inline _sfsyscall1( int, chdir, const char *, path ) -// fchdir -static inline _sfsyscall3( int, mknod, const char *, pathname, mode_t, mode, dev_t, dev ) -static inline _sfsyscall2( int, chmod, const char *, path, mode_t, mode ) -static inline _sfsyscall3( int, chown, const char *, path, uid_t, owner, gid_t, group ) -// break -static inline _sfsyscall0( pid_t, getpid ) -// mount -// unmount -// setuid -static inline _sfsyscall0( uid_t, getuid ) -static inline _sfsyscall0( uid_t, geteuid ) -static inline _sfsyscall4(long, ptrace, int, request, pid_t, pid, void *,addr, void *,data) -// recvmsg -// sendmsg -static inline _sfsyscall6(ssize_t, recvfrom, int, s, void * , buf, size_t, len, int, flags, struct sockaddr * , from, socklen_t * , fromlen) -static inline _sfsyscall3(int, accept, int,s, struct sockaddr *,addr, socklen_t,addrlen); -// getpeername -// getsockname -static inline _sfsyscall2( int, access, const char *, pathname, int, mode ) -// chflags -// fchflags -static inline _sfsyscall0( int, sync ) -static inline _sfsyscall2( int, kill, pid_t, pid, int, sig ) -static inline _sfsyscall0( pid_t, getppid ) -static inline _sfsyscall1( int, dup, int, oldfd ) -// opipe -static inline _sfsyscall0( gid_t, getegid ) -// profil -// ktrace -// sigaction -static inline _sfsyscall0( gid_t, getgid ) -// sigprocmask -// getlogin -// setlogin -static inline _sfsyscall1( int, acct, const char *, filename ) -static inline _sfsyscall1( int, sigpending, sigset_t *, set ) -// sigaltstack -static inline _sfsyscall4(int, ioctl, int,d, int,request, char *,argp, int,len) -// reboot -// revoke -static inline _sfsyscall2( int, symlink, const char *, oldpath, const char *, newpath ) -static inline _sfsyscall3( int, readlink, const char *, path, char *, buf, size_t, bufsiz ) -static inline _sfsyscall3(int, execve, char *, s, char **, argv, char **,envp) -static inline _sfsyscall1( mode_t, umask, mode_t, mask ) -static inline _sfsyscall1( int, chroot, const char *, path ) -// omsync -static inline _sfsyscall0( pid_t, vfork ) -// sbrk -// sstk -// vadvise -static inline _sfsyscall2( int, munmap, void *, start, size_t, length ) -static inline _sfsyscall3( int, mprotect, const void *, addr, size_t, len, int, prot ) -// madvise -// mincore -// getgroups -static inline _sfsyscall2( int, setgroups, size_t, size, const gid_t *, list ) -static inline _sfsyscall0( pid_t, getpgrp ) -static inline _sfsyscall2( int, setpgid, pid_t, pid, pid_t, pgid ) -// setitimer -static inline _sfsyscall2( int, swapon, const char *, path, int, swapflags ) -// getitimer -static inline _sfsyscall2( int, dup2, int, oldfd, int, newfd ) -static inline _sfsyscall3( int, fcntl, int, fd, int, cmd, long, arg ) -static inline _sfsyscall5( int, select, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout) -static inline _sfsyscall1( int, fsync, int, fd ) -static inline _sfsyscall3( int, setpriority, int, which, int, who, int, prio ) -static inline _sfsyscall3(int, socket, int,domain, int,type, int,protocol) -static inline _sfsyscall3(int,connect, int,sockfd, const struct sockaddr *,serv_addr, socklen_t,addrlen) -static inline _sfsyscall2( int, getpriority, int, which, int, who ) -static inline _sfsyscall1( int, sigreturn, unsigned long, __unused ) -static inline _sfsyscall3(int, bind, int,sockfd, struct sockaddr *,my_addr, socklen_t,addrlen) -static inline _sfsyscall5(int, setsockopt, int, s, int, level, int, optname, void *, optval, socklen_t, optlen) -static inline _sfsyscall2(int,listen,int,s, int,backlog) -static inline _sfsyscall1( int, sigsuspend, const sigset_t *, mask ) -static inline _sfsyscall2( int, gettimeofday, struct timeval *, tv, struct timezone *, tz ) -// getrusage -// getsockopt -static inline _sfsyscall3( int, readv, int, fd, const struct iovec *, vector, int, count ) -static inline _sfsyscall3( int, writev, int, fd, const struct iovec *, vector, int, count ) -// settimeofday -static inline _sfsyscall3( int, fchown, int, fd, uid_t, owner, gid_t, group ) -static inline _sfsyscall2( int, fchmod, int, fildes, mode_t, mode ) -static inline _sfsyscall2( int, rename, const char *, oldpath, const char *, newpath ) -// flock -// mkfifo -static inline _sfsyscall6(ssize_t, sendto, int, s, const void *, msg, size_t, len, int, flags, const struct sockaddr *, to, socklen_t, tolen) -// shutdown -// socketpair -static inline _sfsyscall2( int, mkdir, const char *, pathname, mode_t, mode ) -static inline _sfsyscall1( int, rmdir, const char *, pathname ) -// utimes -// adjtime -static inline _sfsyscall0( pid_t, setsid ) -// quotactl -// nfssvc -// getfh -// sysarch -static inline _sfsyscall4( ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset ) -// pwrite -// setgid -// setegid -// seteuid -// lfs_bmapv -// lfs_markv -// lfs_segclean -// lfs_segwait -static inline _sfsyscall2( int, stat, const char *, file_name, struct stat *, buf ) -static inline _sfsyscall2( int, fstat, int, filedes, struct stat *, buf ) -static inline _sfsyscall2( int, lstat, const char *, file_name, struct stat *, buf ) -// pathconf -// fpathconf -// swapctl -// getrlimit -// setrlimit -static inline _sfsyscall4( int,getdirentries, int,fd, void *,buf, int,nbytes, long *,basep) -static inline _sfsyscall6(void *,mmap, void *,start, size_t,length, int,prot , int,flags, int,fd, off_t,offset) -static inline _sfsyscall3( off_t, lseek, int, fildes, off_t, offset, int, whence ) -static inline _sfsyscall2( int, truncate, const char *, path, off_t, length ) -static inline _sfsyscall2( int, ftruncate, int, fd, off_t, length ) -static inline _sfsyscall2( int, mlock, const void *, addr, size_t, len ) -static inline _sfsyscall2( int, munlock, const void *, addr, size_t, len ) -// undelete -// futimes -static inline _sfsyscall1( pid_t, getpgid, pid_t, pid ) -// xfspioctl -static inline _sfsyscall3(int, semget, long, key, int, nsems, int, semflg) -static inline _sfsyscall3(int, semop, int, semid, struct sembuf *, sops, unsigned, nsops) -// msgget -// msgsnd -// msgrcv -static inline _sfsyscall3(void *, shmat, int, shmid, const void *, shmaddr, int, shmflg ) -// shmdt -static inline _sfsyscall3(int, shmget, long, key, int, size, int, flags ) -// clock_gettime -// clock_settime -// clock_getres -static inline _sfsyscall2( int, nanosleep, const struct timespec *, req, struct timespec *, rem ) -// minherit -// rfork -static inline _sfsyscall3( int, poll, struct pollfd *, ufds, unsigned int, nfds, int, timeout ) -// issetugid -static inline _sfsyscall3( int, lchown, const char *, path, uid_t, owner, gid_t, group ) -static inline _sfsyscall1( pid_t, getsid, pid_t, pid ) -static inline _sfsyscall3( int, msync, const void *, start, size_t, length, int, flags ) -// shmctl -// msgctl -// getfsstat -static inline _sfsyscall2( int, statfs, const char *, path, struct statfs *, buf ) -static inline _sfsyscall2( int, fstatfs, int, fd, struct statfs *, buf ) -static inline _sfsyscall1( int, pipe, unsigned long *, filedes) -// fhopen -// fhstat -// fhstatfs -// preadv -// pwritev -// kqueue -// kevent -static inline _sfsyscall1( int, mlockall, int, flags ) -static inline _sfsyscall0( int, munlockall ) -// getpeereid -// extattrctl -// extattr_set_file -// extattr_get_file -// extattr_delete_file -// extattr_set_fd -// extattr_get_fd -// extattr_delete_fd - -#endif /* SFLIB_H */ diff --git a/dest/include/librz/sflib/darwin-x86-32/sfsyscall.h b/dest/include/librz/sflib/darwin-x86-32/sfsyscall.h deleted file mode 100644 index 10855e6c5cd..00000000000 --- a/dest/include/librz/sflib/darwin-x86-32/sfsyscall.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * sfsyscall.h --- SFLib syscall macros for Darwin/i386 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - - -/* - * Automatically generated by gensflib.py - * Tue Apr 25 20:10:54 2023 - */ - -#ifndef SFSYSCALL_H -#define SFSYSCALL_H - - -/* $Id$ */ - -#ifdef SF_USE_ERRNO -/* Remove errno stuff */ -int errno; -#error "SF_USER_ERRNO not supported yet" -#else -#define __sfsyscall_return(type, res) \ -do { \ - return (type) (res); \ -} while (0) -#endif - - -/* syscall macros */ - -#define _sfsyscall0(type,name) \ -type name(void) \ -{ \ -long __res; \ -__asm__ volatile ("int $0x80" \ - : "=a" (__res) \ - : "0" (__NR_##name)); \ -__sfsyscall_return(type,__res); \ -} - -#define _sfsyscall1(type,name,type1,arg1) \ -type name(type1 arg1) \ -{ \ -long __res; \ -__asm__ volatile ("pushl %2\n\t" \ - "pushl %%eax\n\t" \ - "int $0x80\n\t" \ - "add $8, %%esp" \ - : "=a" (__res) \ - : "0" (__NR_##name),"r" ((long)(arg1))); \ -__sfsyscall_return(type,__res); \ -} - -#define _sfsyscall2(type,name,type1,arg1,type2,arg2) \ -type name(type1 arg1,type2 arg2) \ -{ \ -long __res; \ -__asm__ volatile ("pushl %3\n\t" \ - "pushl %2\n\t" \ - "pushl %%eax\n\t" \ - "int $0x80\n\t" \ - "add $12, %%esp" \ - : "=a" (__res) \ - : "0" (__NR_##name),"r" ((long)(arg1)),"r" ((long)(arg2)) ); \ -__sfsyscall_return(type,__res); \ -} - -#define _sfsyscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ -type name(type1 arg1,type2 arg2,type3 arg3) \ -{ \ -long __res; \ -__asm__ volatile ("pusha; pushl %4\n\t" \ - "pushl %3\n\t" \ - "pushl %2\n\t" \ - "pushl %%eax\n\t" \ - "int $0x80\n\t" \ - "add $16, %%esp\n\t" \ - "popa" \ - : "=a" (__res) \ - : "0" (__NR_##name),"r" ((long)(arg1)),"r" ((long)(arg2)), \ - "r" ((long)(arg3)) ); \ -__sfsyscall_return(type,__res); \ -} - -#define _sfsyscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ -type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ -{ \ -long __res; \ -__asm__ volatile ("pushl %5\n\t" \ - "pushl %4\n\t" \ - "pushl %3\n\t" \ - "pushl %2\n\t" \ - "pushl %%eax\n\t" \ - "int $0x80\n\t" \ - "add $20, %%esp" \ - : "=a" (__res) \ - : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \ - "d" ((long)(arg3)),"S" ((long)(arg4)) ); \ -__sfsyscall_return(type,__res); \ -} - -#define _sfsyscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ - type5,arg5) \ -type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ -{ \ -long __res; \ -__asm__ volatile ("pushl %6\n\t" \ - "pushl %5\n\t" \ - "pushl %4\n\t" \ - "pushl %3\n\t" \ - "pushl %2\n\t" \ - "pushl %%eax\n\t" \ - "int $0x80\n\t" \ - "add $24, %%esp" \ - : "=a" (__res) \ - : "0" (__NR_##name),"r" ((long)(arg1)),"r" ((long)(arg2)), \ - "r" ((long)(arg3)),"r" ((long)(arg4)),"r" ((long)(arg5))); \ -__sfsyscall_return(type,__res); \ -} - -#define _sfsyscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ - type5,arg5,type6,arg6) \ -type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \ -{ \ -long __res; \ -__asm__ volatile ("pushl %7\n\t" \ - "pushl %6\n\t" \ - "pushl %5\n\t" \ - "pushl %4\n\t" \ - "pushl %3\n\t" \ - "pushl %2\n\t" \ - "pushl %%eax\n\t" \ - "int $0x80\n\t" \ - "add $28, %%esp" \ - : "=a" (__res) \ - : "0" (__NR_##name),"r" ((long)(arg1)),"r" ((long)(arg2)), \ - "r" ((long)(arg3)),"r" ((long)(arg4)),"r" ((long)(arg5)), \ - "r" ((long)(arg6))); \ -__sfsyscall_return(type,__res); \ -} - -#endif /* SFSYSCALL_H */ diff --git a/dest/include/librz/sflib/darwin-x86-32/sfsysnr.h b/dest/include/librz/sflib/darwin-x86-32/sfsysnr.h deleted file mode 100644 index 16f386ba0c5..00000000000 --- a/dest/include/librz/sflib/darwin-x86-32/sfsysnr.h +++ /dev/null @@ -1,684 +0,0 @@ -/* - * sfsysnr.h --- SFLib syscall numbers for Darwin/i386 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - - -/* - * Automatically generated by gensflib.py - * Tue Apr 25 20:10:54 2023 - */ - -#ifndef SFSYSNR_H -#define SFSYSNR_H - - -/* $Id$ */ - -/* - * Modified from /usr/include/sys/syscall.h - * created from OpenBSD: syscalls.master,v 1.50 2002/07/06 19:14:20 nordin Exp - */ - - -/* syscall: "syscall" ret: "int" args: "int" "..." */ -#define __NR_syscall 0 - -/* syscall: "exit" ret: "void" args: "int" */ -#define __NR_exit 1 - -/* syscall: "fork" ret: "int" args: */ -#define __NR_fork 2 - -/* syscall: "read" ret: "ssize_t" args: "int" "void *" "size_t" */ -#define __NR_read 3 - -/* syscall: "write" ret: "ssize_t" args: "int" "const void *" "size_t" */ -#define __NR_write 4 - -/* syscall: "open" ret: "int" args: "const char *" "int" "..." */ -#define __NR_open 5 - -/* syscall: "close" ret: "int" args: "int" */ -#define __NR_close 6 - -/* syscall: "wait4" ret: "int" args: "int" "int *" "int" "struct rusage *" */ -#define __NR_wait4 7 - - /* 8 is compat_43 ocreat */ - -/* syscall: "link" ret: "int" args: "const char *" "const char *" */ -#define __NR_link 9 - -/* syscall: "unlink" ret: "int" args: "const char *" */ -#define __NR_unlink 10 - - /* 11 is obsolete execv */ -/* syscall: "chdir" ret: "int" args: "const char *" */ -#define __NR_chdir 12 - -/* syscall: "fchdir" ret: "int" args: "int" */ -#define __NR_fchdir 13 - -/* syscall: "mknod" ret: "int" args: "const char *" "int" "dev_t" */ -#define __NR_mknod 14 - -/* syscall: "chmod" ret: "int" args: "const char *" "int" */ -#define __NR_chmod 15 - -/* syscall: "chown" ret: "int" args: "const char *" "uid_t" "gid_t" */ -#define __NR_chown 16 - -/* syscall: "break" ret: "int" args: "char *" */ -#define __NR_break 17 - - /* 18 is compat_25 ogetfsstat */ - - /* 19 is compat_43 olseek */ - -/* syscall: "getpid" ret: "pid_t" args: */ -#define __NR_getpid 20 - -/* syscall: "mount" ret: "int" args: "const char *" "const char *" "int" "void *" */ -#define __NR_mount 21 - -/* syscall: "unmount" ret: "int" args: "const char *" "int" */ -#define __NR_unmount 22 - -/* syscall: "setuid" ret: "int" args: "uid_t" */ -#define __NR_setuid 23 - -/* syscall: "getuid" ret: "uid_t" args: */ -#define __NR_getuid 24 - -/* syscall: "geteuid" ret: "uid_t" args: */ -#define __NR_geteuid 25 - -/* syscall: "ptrace" ret: "int" args: "int" "pid_t" "caddr_t" "int" */ -#define __NR_ptrace 26 - -/* syscall: "recvmsg" ret: "ssize_t" args: "int" "struct msghdr *" "int" */ -#define __NR_recvmsg 27 - -/* syscall: "sendmsg" ret: "ssize_t" args: "int" "const struct msghdr *" "int" */ -#define __NR_sendmsg 28 - -/* syscall: "recvfrom" ret: "ssize_t" args: "int" "void *" "size_t" "int" "struct sockaddr *" "socklen_t *" */ -#define __NR_recvfrom 29 - -/* syscall: "accept" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ -#define __NR_accept 30 - -/* syscall: "getpeername" ret: "int" args: "int" "struct sockaddr *" "int *" */ -#define __NR_getpeername 31 - -/* syscall: "getsockname" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ -#define __NR_getsockname 32 - -/* syscall: "access" ret: "int" args: "const char *" "int" */ -#define __NR_access 33 - -/* syscall: "chflags" ret: "int" args: "const char *" "u_int" */ -#define __NR_chflags 34 - -/* syscall: "fchflags" ret: "int" args: "int" "u_int" */ -#define __NR_fchflags 35 - -/* syscall: "sync" ret: "void" args: */ -#define __NR_sync 36 - -/* syscall: "kill" ret: "int" args: "int" "int" */ -#define __NR_kill 37 - - /* 38 is compat_43 ostat */ - -/* syscall: "getppid" ret: "pid_t" args: */ -#define __NR_getppid 39 - - /* 40 is compat_43 olstat */ - -/* syscall: "dup" ret: "int" args: "int" */ -#define __NR_dup 41 - -/* syscall: "opipe" ret: "int" args: */ -#define __NR_opipe 42 - -/* syscall: "getegid" ret: "gid_t" args: */ -#define __NR_getegid 43 - -/* syscall: "profil" ret: "int" args: "caddr_t" "size_t" "u_long" "u_int" */ -#define __NR_profil 44 - -/* syscall: "ktrace" ret: "int" args: "const char *" "int" "int" "pid_t" */ -#define __NR_ktrace 45 - -/* syscall: "sigaction" ret: "int" args: "int" "const struct sigaction *" "struct sigaction *" */ -#define __NR_sigaction 46 - -/* syscall: "getgid" ret: "gid_t" args: */ -#define __NR_getgid 47 - -/* syscall: "sigprocmask" ret: "int" args: "int" "sigset_t" */ -#define __NR_sigprocmask 48 - -/* syscall: "getlogin" ret: "int" args: "char *" "u_int" */ -#define __NR_getlogin 49 - -/* syscall: "setlogin" ret: "int" args: "const char *" */ -#define __NR_setlogin 50 - -/* syscall: "acct" ret: "int" args: "const char *" */ -#define __NR_acct 51 - -/* syscall: "sigpending" ret: "int" args: */ -#define __NR_sigpending 52 - -/* syscall: "sigaltstack" ret: "int" args: "const struct sigaltstack *" "struct sigaltstack *" */ -#define __NR_sigaltstack 53 - -/* syscall: "ioctl" ret: "int" args: "int" "u_long" "..." */ -#define __NR_ioctl 54 - -/* syscall: "reboot" ret: "int" args: "int" */ -#define __NR_reboot 55 - -/* syscall: "revoke" ret: "int" args: "const char *" */ -#define __NR_revoke 56 - -/* syscall: "symlink" ret: "int" args: "const char *" "const char *" */ -#define __NR_symlink 57 - -/* syscall: "readlink" ret: "int" args: "const char *" "char *" "size_t" */ -#define __NR_readlink 58 - -/* syscall: "execve" ret: "int" args: "const char *" "char *const *" "char *const *" */ -#define __NR_execve 59 - -/* syscall: "umask" ret: "int" args: "int" */ -#define __NR_umask 60 - -/* syscall: "chroot" ret: "int" args: "const char *" */ -#define __NR_chroot 61 - - /* 62 is compat_43 ofstat */ - - /* 63 is compat_43 ogetkerninfo */ - - /* 64 is compat_43 ogetpagesize */ - -/* syscall: "omsync" ret: "int" args: "caddr_t" "size_t" */ -#define __NR_omsync 65 - -/* syscall: "vfork" ret: "int" args: */ -#define __NR_vfork 66 - - /* 67 is obsolete vread */ - /* 68 is obsolete vwrite */ -/* syscall: "sbrk" ret: "int" args: "int" */ -#define __NR_sbrk 69 - -/* syscall: "sstk" ret: "int" args: "int" */ -#define __NR_sstk 70 - - /* 71 is compat_43 ommap */ - -/* syscall: "vadvise" ret: "int" args: "int" */ -#define __NR_vadvise 72 - -/* syscall: "munmap" ret: "int" args: "void *" "size_t" */ -#define __NR_munmap 73 - -/* syscall: "mprotect" ret: "int" args: "void *" "size_t" "int" */ -#define __NR_mprotect 74 - -/* syscall: "madvise" ret: "int" args: "void *" "size_t" "int" */ -#define __NR_madvise 75 - - /* 76 is obsolete vhangup */ - /* 77 is obsolete vlimit */ -/* syscall: "mincore" ret: "int" args: "void *" "size_t" "char *" */ -#define __NR_mincore 78 - -/* syscall: "getgroups" ret: "int" args: "int" "gid_t *" */ -#define __NR_getgroups 79 - -/* syscall: "setgroups" ret: "int" args: "int" "const gid_t *" */ -#define __NR_setgroups 80 - -/* syscall: "getpgrp" ret: "int" args: */ -#define __NR_getpgrp 81 - -/* syscall: "setpgid" ret: "int" args: "pid_t" "int" */ -#define __NR_setpgid 82 - -/* syscall: "setitimer" ret: "int" args: "int" "const struct itimerval *" "struct itimerval *" */ -#define __NR_setitimer 83 - - /* 84 is compat_43 owait */ - -/* syscall: "swapon" ret: "int" args: "const char *" */ -#define __NR_swapon 85 - -/* syscall: "getitimer" ret: "int" args: "int" "struct itimerval *" */ -#define __NR_getitimer 86 - - /* 87 is compat_43 ogethostname */ - - /* 88 is compat_43 osethostname */ - - /* 89 is compat_43 ogetdtablesize */ - -/* syscall: "dup2" ret: "int" args: "int" "int" */ -#define __NR_dup2 90 - -/* syscall: "fcntl" ret: "int" args: "int" "int" "..." */ -#define __NR_fcntl 92 - -/* syscall: "select" ret: "int" args: "int" "fd_set *" "fd_set *" "fd_set *" "struct timeval *" */ -#define __NR_select 93 - -/* syscall: "fsync" ret: "int" args: "int" */ -#define __NR_fsync 95 - -/* syscall: "setpriority" ret: "int" args: "int" "int" "int" */ -#define __NR_setpriority 96 - -/* syscall: "socket" ret: "int" args: "int" "int" "int" */ -#define __NR_socket 97 - -/* syscall: "connect" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */ -#define __NR_connect 98 - - /* 99 is compat_43 oaccept */ - -/* syscall: "getpriority" ret: "int" args: "int" "int" */ -#define __NR_getpriority 100 - - /* 101 is compat_43 osend */ - - /* 102 is compat_43 orecv */ - -/* syscall: "sigreturn" ret: "int" args: "struct sigcontext *" */ -#define __NR_sigreturn 103 - -/* syscall: "bind" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */ -#define __NR_bind 104 - -/* syscall: "setsockopt" ret: "int" args: "int" "int" "int" "const void *" "socklen_t" */ -#define __NR_setsockopt 105 - -/* syscall: "listen" ret: "int" args: "int" "int" */ -#define __NR_listen 106 - - /* 107 is obsolete vtimes */ - /* 108 is compat_43 osigvec */ - - /* 109 is compat_43 osigblock */ - - /* 110 is compat_43 osigsetmask */ - -/* syscall: "sigsuspend" ret: "int" args: "int" */ -#define __NR_sigsuspend 111 - - /* 112 is compat_43 osigstack */ - - /* 113 is compat_43 orecvmsg */ - - /* 114 is compat_43 osendmsg */ - - /* 115 is obsolete vtrace */ -/* syscall: "gettimeofday" ret: "int" args: "struct timeval *" "struct timezone *" */ -#define __NR_gettimeofday 116 - -/* syscall: "getrusage" ret: "int" args: "int" "struct rusage *" */ -#define __NR_getrusage 117 - -/* syscall: "getsockopt" ret: "int" args: "int" "int" "int" "void *" "socklen_t *" */ -#define __NR_getsockopt 118 - - /* 119 is obsolete resuba */ -/* syscall: "readv" ret: "ssize_t" args: "int" "const struct iovec *" "int" */ -#define __NR_readv 120 - -/* syscall: "writev" ret: "ssize_t" args: "int" "const struct iovec *" "int" */ -#define __NR_writev 121 - -/* syscall: "settimeofday" ret: "int" args: "const struct timeval *" "const struct timezone *" */ -#define __NR_settimeofday 122 - -/* syscall: "fchown" ret: "int" args: "int" "uid_t" "gid_t" */ -#define __NR_fchown 123 - -/* syscall: "fchmod" ret: "int" args: "int" "int" */ -#define __NR_fchmod 124 - - /* 125 is compat_43 orecvfrom */ - - /* 126 is compat_43 osetreuid */ - - /* 127 is compat_43 osetregid */ - -/* syscall: "rename" ret: "int" args: "const char *" "const char *" */ -#define __NR_rename 128 - - /* 129 is compat_43 otruncate */ - - /* 130 is compat_43 oftruncate */ - -/* syscall: "flock" ret: "int" args: "int" "int" */ -#define __NR_flock 131 - -/* syscall: "mkfifo" ret: "int" args: "const char *" "int" */ -#define __NR_mkfifo 132 - -/* syscall: "sendto" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "const struct sockaddr *" "socklen_t" */ -#define __NR_sendto 133 - -/* syscall: "shutdown" ret: "int" args: "int" "int" */ -#define __NR_shutdown 134 - -/* syscall: "socketpair" ret: "int" args: "int" "int" "int" "int *" */ -#define __NR_socketpair 135 - -/* syscall: "mkdir" ret: "int" args: "const char *" "int" */ -#define __NR_mkdir 136 - -/* syscall: "rmdir" ret: "int" args: "const char *" */ -#define __NR_rmdir 137 - -/* syscall: "utimes" ret: "int" args: "const char *" "const struct timeval *" */ -#define __NR_utimes 138 - - /* 139 is obsolete 4.2 sigreturn */ -/* syscall: "adjtime" ret: "int" args: "const struct timeval *" "struct timeval *" */ -#define __NR_adjtime 140 - - /* 141 is compat_43 ogetpeername */ - - /* 142 is compat_43 ogethostid */ - - /* 143 is compat_43 osethostid */ - - /* 144 is compat_43 ogetrlimit */ - - /* 145 is compat_43 osetrlimit */ - - /* 146 is compat_43 okillpg */ - -/* syscall: "setsid" ret: "int" args: */ -#define __NR_setsid 147 - -/* syscall: "quotactl" ret: "int" args: "const char *" "int" "int" "char *" */ -#define __NR_quotactl 148 - - /* 149 is compat_43 oquota */ - - /* 150 is compat_43 ogetsockname */ - -/* syscall: "nfssvc" ret: "int" args: "int" "void *" */ -#define __NR_nfssvc 155 - - /* 156 is compat_43 ogetdirentries */ - - /* 157 is compat_25 ostatfs */ - - /* 158 is compat_25 ostatfs */ - -/* syscall: "getfh" ret: "int" args: "const char *" "fhandle_t *" */ -#define __NR_getfh 161 - - /* 162 is compat_09 ogetdomainname */ - - /* 163 is compat_09 osetdomainname */ - - /* 164 is compat_09 ouname */ - -/* syscall: "sysarch" ret: "int" args: "int" "void *" */ -#define __NR_sysarch 165 - - /* 169 is compat_10 osemsys */ - - /* 170 is compat_10 omsgsys */ - - /* 171 is compat_10 oshmsys */ - -/* syscall: "pread" ret: "ssize_t" args: "int" "void *" "size_t" "int" "off_t" */ -#define __NR_pread 173 - -/* syscall: "pwrite" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "off_t" */ -#define __NR_pwrite 174 - -/* syscall: "setgid" ret: "int" args: "gid_t" */ -#define __NR_setgid 181 - -/* syscall: "setegid" ret: "int" args: "gid_t" */ -#define __NR_setegid 182 - -/* syscall: "seteuid" ret: "int" args: "uid_t" */ -#define __NR_seteuid 183 - -/* syscall: "lfs_bmapv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */ -#define __NR_lfs_bmapv 184 - -/* syscall: "lfs_markv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */ -#define __NR_lfs_markv 185 - -/* syscall: "lfs_segclean" ret: "int" args: "fsid_t *" "u_long" */ -#define __NR_lfs_segclean 186 - -/* syscall: "lfs_segwait" ret: "int" args: "fsid_t *" "struct timeval *" */ -#define __NR_lfs_segwait 187 - -/* syscall: "stat" ret: "int" args: "const char *" "struct stat *" */ -#define __NR_stat 188 - -/* syscall: "fstat" ret: "int" args: "int" "struct stat *" */ -#define __NR_fstat 189 - -/* syscall: "lstat" ret: "int" args: "const char *" "struct stat *" */ -#define __NR_lstat 190 - -/* syscall: "pathconf" ret: "long" args: "const char *" "int" */ -#define __NR_pathconf 191 - -/* syscall: "fpathconf" ret: "long" args: "int" "int" */ -#define __NR_fpathconf 192 - -/* syscall: "swapctl" ret: "int" args: "int" "const void *" "int" */ -#define __NR_swapctl 193 - -/* syscall: "getrlimit" ret: "int" args: "int" "struct rlimit *" */ -#define __NR_getrlimit 194 - -/* syscall: "setrlimit" ret: "int" args: "int" "const struct rlimit *" */ -#define __NR_setrlimit 195 - -/* syscall: "getdirentries" ret: "int" args: "int" "char *" "int" "long *" */ -#define __NR_getdirentries 196 - -/* syscall: "mmap" ret: "void *" args: "void *" "size_t" "int" "int" "int" "long" "off_t" */ -#define __NR_mmap 197 - -/* syscall: "__syscall" ret: "quad_t" args: "quad_t" "..." */ -#define __NR___syscall 198 - -/* syscall: "lseek" ret: "off_t" args: "int" "int" "off_t" "int" */ -#define __NR_lseek 199 - -/* syscall: "truncate" ret: "int" args: "const char *" "int" "off_t" */ -#define __NR_truncate 200 - -/* syscall: "ftruncate" ret: "int" args: "int" "int" "off_t" */ -#define __NR_ftruncate 201 - -/* syscall: "__sysctl" ret: "int" args: "int *" "u_int" "void *" "size_t *" "void *" "size_t" */ -#define __NR___sysctl 202 - -/* syscall: "mlock" ret: "int" args: "const void *" "size_t" */ -#define __NR_mlock 203 - -/* syscall: "munlock" ret: "int" args: "const void *" "size_t" */ -#define __NR_munlock 204 - -/* syscall: "undelete" ret: "int" args: "const char *" */ -#define __NR_undelete 205 - -/* syscall: "futimes" ret: "int" args: "int" "const struct timeval *" */ -#define __NR_futimes 206 - -/* syscall: "getpgid" ret: "pid_t" args: "pid_t" */ -#define __NR_getpgid 207 - -/* syscall: "xfspioctl" ret: "int" args: "int" "char *" "int" "struct ViceIoctl *" "int" */ -#define __NR_xfspioctl 208 - - /* 220 is compat_23 __osemctl */ - -/* syscall: "semget" ret: "int" args: "key_t" "int" "int" */ -#define __NR_semget 221 - -/* syscall: "semop" ret: "int" args: "int" "struct sembuf *" "u_int" */ -#define __NR_semop 222 - - /* 223 is obsolete sys_semconfig */ - /* 224 is compat_23 omsgctl */ - -/* syscall: "msgget" ret: "int" args: "key_t" "int" */ -#define __NR_msgget 225 - -/* syscall: "msgsnd" ret: "int" args: "int" "const void *" "size_t" "int" */ -#define __NR_msgsnd 226 - -/* syscall: "msgrcv" ret: "int" args: "int" "void *" "size_t" "long" "int" */ -#define __NR_msgrcv 227 - -/* syscall: "shmat" ret: "void *" args: "int" "const void *" "int" */ -#define __NR_shmat 228 - - /* 229 is compat_23 oshmctl */ - -/* syscall: "shmdt" ret: "int" args: "const void *" */ -#define __NR_shmdt 230 - -/* syscall: "shmget" ret: "int" args: "key_t" "int" "int" */ -#define __NR_shmget 231 - -/* syscall: "clock_gettime" ret: "int" args: "clockid_t" "struct timespec *" */ -#define __NR_clock_gettime 232 - -/* syscall: "clock_settime" ret: "int" args: "clockid_t" "const struct timespec *" */ -#define __NR_clock_settime 233 - -/* syscall: "clock_getres" ret: "int" args: "clockid_t" "struct timespec *" */ -#define __NR_clock_getres 234 - -/* syscall: "nanosleep" ret: "int" args: "const struct timespec *" "struct timespec *" */ -#define __NR_nanosleep 240 - -/* syscall: "minherit" ret: "int" args: "void *" "size_t" "int" */ -#define __NR_minherit 250 - -/* syscall: "rfork" ret: "int" args: "int" */ -#define __NR_rfork 251 - -/* syscall: "poll" ret: "int" args: "struct pollfd *" "unsigned long" "int" */ -#define __NR_poll 252 - -/* syscall: "issetugid" ret: "int" args: */ -#define __NR_issetugid 253 - -/* syscall: "lchown" ret: "int" args: "const char *" "uid_t" "gid_t" */ -#define __NR_lchown 254 - -/* syscall: "getsid" ret: "pid_t" args: "pid_t" */ -#define __NR_getsid 255 - -/* syscall: "msync" ret: "int" args: "void *" "size_t" "int" */ -#define __NR_msync 256 - -/* syscall: "__semctl" ret: "int" args: "int" "int" "int" "union semun *" */ -#define __NR___semctl 257 - -/* syscall: "shmctl" ret: "int" args: "int" "int" "struct shmid_ds *" */ -#define __NR_shmctl 258 - -/* syscall: "msgctl" ret: "int" args: "int" "int" "struct msqid_ds *" */ -#define __NR_msgctl 259 - -/* syscall: "getfsstat" ret: "int" args: "struct statfs *" "size_t" "int" */ -#define __NR_getfsstat 260 - -/* syscall: "statfs" ret: "int" args: "const char *" "struct statfs *" */ -#define __NR_statfs 261 - -/* syscall: "fstatfs" ret: "int" args: "int" "struct statfs *" */ -#define __NR_fstatfs 262 - -/* syscall: "pipe" ret: "int" args: "int *" */ -#define __NR_pipe 263 - -/* syscall: "fhopen" ret: "int" args: "const fhandle_t *" "int" */ -#define __NR_fhopen 264 - -/* syscall: "fhstat" ret: "int" args: "const fhandle_t *" "struct stat *" */ -#define __NR_fhstat 265 - -/* syscall: "fhstatfs" ret: "int" args: "const fhandle_t *" "struct statfs *" */ -#define __NR_fhstatfs 266 - -/* syscall: "preadv" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */ -#define __NR_preadv 267 - -/* syscall: "pwritev" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */ -#define __NR_pwritev 268 - -/* syscall: "kqueue" ret: "int" args: */ -#define __NR_kqueue 269 - -/* syscall: "kevent" ret: "int" args: "int" "const struct kevent *" "int" "struct kevent *" "int" "const struct timespec *" */ -#define __NR_kevent 270 - -/* syscall: "mlockall" ret: "int" args: "int" */ -#define __NR_mlockall 271 - -/* syscall: "munlockall" ret: "int" args: */ -#define __NR_munlockall 272 - -/* syscall: "getpeereid" ret: "int" args: "int" "uid_t *" "gid_t *" */ -#define __NR_getpeereid 273 - -/* syscall: "extattrctl" ret: "int" args: "const char *" "int" "const char *" "int" "const char *" */ -#define __NR_extattrctl 274 - -/* syscall: "extattr_set_file" ret: "int" args: "const char *" "int" "const char *" "void *" "size_t" */ -#define __NR_extattr_set_file 275 - -/* syscall: "extattr_get_file" ret: "ssize_t" args: "const char *" "int" "const char *" "void *" "size_t" */ -#define __NR_extattr_get_file 276 - -/* syscall: "extattr_delete_file" ret: "int" args: "const char *" "int" "const char *" */ -#define __NR_extattr_delete_file 277 - -/* syscall: "extattr_set_fd" ret: "int" args: "int" "int" "const char *" "void *" "size_t" */ -#define __NR_extattr_set_fd 278 - -/* syscall: "extattr_get_fd" ret: "ssize_t" args: "int" "int" "const char *" "void *" "size_t" */ -#define __NR_extattr_get_fd 279 - -/* syscall: "extattr_delete_fd" ret: "int" args: "int" "int" "const char *" */ -#define __NR_extattr_delete_fd 280 - -#define __NR_MAXSYSCALL 281 - -#endif /* SFSYSNR_H */ diff --git a/dest/include/librz/sflib/darwin-x86-64/sflib.h b/dest/include/librz/sflib/darwin-x86-64/sflib.h deleted file mode 100644 index d0c5540ff8b..00000000000 --- a/dest/include/librz/sflib/darwin-x86-64/sflib.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * sflib.h --- SFLib syscall library for OpenBSD/i386 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - -/* - * Automatically generated by gensflib.py - * Fri Nov 25 15:52:34 2011 - */ - -#ifndef SFLIB_H -#define SFLIB_H - -#include "sfsysnr.h" -#include "sfsyscall.h" -#include "../common/sftypes.h" - -// syscall -static inline _sfsyscall1(void, exit, int, status) static inline _sfsyscall0(pid_t, fork) static inline _sfsyscall3(ssize_t, read, int, fd, void *, buf, size_t, count) static inline _sfsyscall3ipi(ssize_t, write, int, fd, const void *, buf, size_t, count) static inline _sfsyscall3(int, open, const char *, pathname, int, flags, mode_t, mode) static inline _sfsyscall1(int, close, int, fd) static inline _sfsyscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, struct rusage *, rusage) static inline _sfsyscall2(int, link, const char *, oldpath, const char *, newpath) static inline _sfsyscall1(int, unlink, const char *, pathname) static inline _sfsyscall1(int, chdir, const char *, path) - // fchdir - static inline _sfsyscall3(int, mknod, const char *, pathname, mode_t, mode, dev_t, dev) static inline _sfsyscall2(int, chmod, const char *, path, mode_t, mode) static inline _sfsyscall3(int, chown, const char *, path, uid_t, owner, gid_t, group) - // break - static inline _sfsyscall0(pid_t, getpid) - // mount - // unmount - // setuid - static inline _sfsyscall0(uid_t, getuid) static inline _sfsyscall0(uid_t, geteuid) static inline _sfsyscall4(long, ptrace, int, request, pid_t, pid, void *, addr, void *, data) - // recvmsg - // sendmsg - static inline _sfsyscall6(ssize_t, recvfrom, int, s, void *, buf, size_t, len, int, flags, struct sockaddr *, from, socklen_t *, fromlen) static inline _sfsyscall3(int, accept, int, s, struct sockaddr *, addr, socklen_t *, addrlen); -// getpeername -// getsockname -static inline _sfsyscall2(int, access, const char *, pathname, int, mode) - // chflags - // fchflags - static inline _sfsyscall0(int, sync) static inline _sfsyscall2(int, kill, pid_t, pid, int, sig) static inline _sfsyscall0(pid_t, getppid) static inline _sfsyscall1(int, dup, int, oldfd) - // opipe - static inline _sfsyscall0(gid_t, getegid) - // profil - // ktrace - // sigaction - static inline _sfsyscall0(gid_t, getgid) - // sigprocmask - // getlogin - // setlogin - static inline _sfsyscall1(int, acct, const char *, filename) static inline _sfsyscall1(int, sigpending, sigset_t *, set) - // sigaltstack - static inline _sfsyscall4(int, ioctl, int, d, int, request, char *, argp, int, len) - // reboot - // revoke - static inline _sfsyscall2(int, symlink, const char *, oldpath, const char *, newpath) static inline _sfsyscall3(int, readlink, const char *, path, char *, buf, size_t, bufsiz) static inline _sfsyscall3(int, execve, char *, s, char **, argv, char **, envp) static inline _sfsyscall1(mode_t, umask, mode_t, mask) static inline _sfsyscall1(int, chroot, const char *, path) - // omsync - static inline _sfsyscall0(pid_t, vfork) - // sbrk - // sstk - // vadvise - static inline _sfsyscall2(int, munmap, void *, start, size_t, length) static inline _sfsyscall3(int, mprotect, const void *, addr, size_t, len, int, prot) - // madvise - // mincore - // getgroups - static inline _sfsyscall2(int, setgroups, size_t, size, const gid_t *, list) static inline _sfsyscall0(pid_t, getpgrp) static inline _sfsyscall2(int, setpgid, pid_t, pid, pid_t, pgid) - // setitimer - static inline _sfsyscall2(int, swapon, const char *, path, int, swapflags) - // getitimer - static inline _sfsyscall2(int, dup2, int, oldfd, int, newfd) static inline _sfsyscall3(int, fcntl, int, fd, int, cmd, long, arg) static inline _sfsyscall5(int, select, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout) static inline _sfsyscall1(int, fsync, int, fd) static inline _sfsyscall3(int, setpriority, int, which, int, who, int, prio) static inline _sfsyscall3(int, socket, int, domain, int, type, int, protocol) static inline _sfsyscall3(int, connect, int, sockfd, const struct sockaddr *, serv_addr, socklen_t, addrlen) static inline _sfsyscall2(int, getpriority, int, which, int, who) static inline _sfsyscall1(int, sigreturn, unsigned long, __unused) static inline _sfsyscall3(int, bind, int, sockfd, struct sockaddr *, my_addr, socklen_t, addrlen) static inline _sfsyscall5(int, setsockopt, int, s, int, level, int, optname, void *, optval, socklen_t, optlen) static inline _sfsyscall2(int, listen, int, s, int, backlog) static inline _sfsyscall1(int, sigsuspend, const sigset_t *, mask) static inline _sfsyscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz) - // getrusage - // getsockopt - static inline _sfsyscall3(int, readv, int, fd, const struct iovec *, vector, int, count) static inline _sfsyscall3(int, writev, int, fd, const struct iovec *, vector, int, count) - // settimeofday - static inline _sfsyscall3(int, fchown, int, fd, uid_t, owner, gid_t, group) static inline _sfsyscall2(int, fchmod, int, fildes, mode_t, mode) static inline _sfsyscall2(int, rename, const char *, oldpath, const char *, newpath) - // flock - // mkfifo - static inline _sfsyscall6(ssize_t, sendto, int, s, const void *, msg, size_t, len, int, flags, const struct sockaddr *, to, socklen_t, tolen) - // shutdown - // socketpair - static inline _sfsyscall2(int, mkdir, const char *, pathname, mode_t, mode) static inline _sfsyscall1(int, rmdir, const char *, pathname) - // utimes - // adjtime - static inline _sfsyscall0(pid_t, setsid) - // quotactl - // nfssvc - // getfh - // sysarch - static inline _sfsyscall4(ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset) - // pwrite - // setgid - // setegid - // seteuid - // lfs_bmapv - // lfs_markv - // lfs_segclean - // lfs_segwait - static inline _sfsyscall2(int, stat, const char *, file_name, struct stat *, buf) static inline _sfsyscall2(int, fstat, int, filedes, struct stat *, buf) static inline _sfsyscall2(int, lstat, const char *, file_name, struct stat *, buf) - // pathconf - // fpathconf - // swapctl - // getrlimit - // setrlimit - static inline _sfsyscall4(int, getdirentries, int, fd, void *, buf, int, nbytes, long *, basep) static inline _sfsyscall6(void *, mmap, void *, start, size_t, length, int, prot, int, flags, int, fd, off_t, offset) static inline _sfsyscall3(off_t, lseek, int, fildes, off_t, offset, int, whence) static inline _sfsyscall2(int, truncate, const char *, path, off_t, length) static inline _sfsyscall2(int, ftruncate, int, fd, off_t, length) static inline _sfsyscall2(int, mlock, const void *, addr, size_t, len) static inline _sfsyscall2(int, munlock, const void *, addr, size_t, len) - // undelete - // futimes - static inline _sfsyscall1(pid_t, getpgid, pid_t, pid) - // xfspioctl - static inline _sfsyscall3(int, semget, long, key, int, nsems, int, semflg) static inline _sfsyscall3(int, semop, int, semid, struct sembuf *, sops, unsigned, nsops) - // msgget - // msgsnd - // msgrcv - static inline _sfsyscall3(void *, shmat, int, shmid, const void *, shmaddr, int, shmflg) - // shmdt - static inline _sfsyscall3(int, shmget, long, key, int, size, int, flags) - // clock_gettime - // clock_settime - // clock_getres - static inline _sfsyscall2(int, nanosleep, const struct timespec *, req, struct timespec *, rem) - // minherit - // rfork - static inline _sfsyscall3(int, poll, struct pollfd *, ufds, unsigned int, nfds, int, timeout) - // issetugid - static inline _sfsyscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group) static inline _sfsyscall1(pid_t, getsid, pid_t, pid) static inline _sfsyscall3(int, msync, const void *, start, size_t, length, int, flags) - // shmctl - // msgctl - // getfsstat - static inline _sfsyscall2(int, statfs, const char *, path, struct statfs *, buf) static inline _sfsyscall2(int, fstatfs, int, fd, struct statfs *, buf) static inline _sfsyscall1(int, pipe, unsigned long *, filedes) - // fhopen - // fhstat - // fhstatfs - // preadv - // pwritev - // kqueue - // kevent - static inline _sfsyscall1(int, mlockall, int, flags) static inline _sfsyscall0(int, munlockall) -// getpeereid -// extattrctl -// extattr_set_file -// extattr_get_file -// extattr_delete_file -// extattr_set_fd -// extattr_get_fd -// extattr_delete_fd - -#endif /* SFLIB_H */ diff --git a/dest/include/librz/sflib/darwin-x86-64/sfsyscall.h b/dest/include/librz/sflib/darwin-x86-64/sfsyscall.h deleted file mode 100644 index 27268ed7a10..00000000000 --- a/dest/include/librz/sflib/darwin-x86-64/sfsyscall.h +++ /dev/null @@ -1,138 +0,0 @@ -// ssed on the registers rdi, rsi, rdx, r10, r8 and r9 -/* - * sfsyscall.h --- SFLib syscall macros for OpenBSD/i386 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - -#ifndef SFSYSCALL_H -#define SFSYSCALL_H - -#ifdef SF_USE_ERRNO -/* Remove errno stuff */ -int errno; -#error "SF_USER_ERRNO not supported yet" -#else -#define __sfsyscall_return(type, res) \ - do { \ - return (type)(res); \ - } while (0) -#endif - -/* syscall macros */ - -#define _sfsyscall0(type, name) \ - type name(void) { \ - long __res; \ - __asm__ volatile("syscall" \ - : "=a"(__res) \ - : "0"(0x2000000 | __NR_##name)); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall1(type, name, type1, arg1) \ - type name(type1 arg1) { \ - long __res; \ - __asm__ volatile("mov %2, %%rdi\n\t" \ - "syscall\n\t" \ - : "=a"(__res) \ - : "0"(0x2000000 | __NR_##name), "g"((long)(arg1))); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall2(type, name, type1, arg1, type2, arg2) \ - type name(type1 arg1, type2 arg2) { \ - long __res; \ - __asm__ volatile("mov %2, %%rdi\n\t" \ - "mov %3, %%rsi\n\t" \ - "syscall\n\t" \ - : "=a"(__res) \ - : "0"(0x2000000 | __NR_##name), "g"((long)(arg1)), "g"((long)(arg2))); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall3ipi(type, name, type1, arg1, type2, arg2, type3, arg3) \ - type name(type1 arg1, type2 arg2, type3 arg3) { \ - long __res; \ - __asm__ volatile("mov %4, %%rdx\n\t" \ - "syscall\n\t" \ - : "=a"(__res) \ - : "0"(0x2000000 | __NR_##name), \ - "D"(arg1), \ - "S"(arg2), \ - "g"((long)(arg3))); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ - type name(type1 arg1, type2 arg2, type3 arg3) { \ - long __res; \ - __asm__ volatile("mov %2, %%rdi\n\t" \ - "mov %3, %%rsi\n\t" \ - "mov %4, %%rdx\n\t" \ - "syscall\n\t" \ - : "=a"(__res) \ - : "0"(0x2000000 | __NR_##name), "g"((long)(arg1)), "g"((long)(arg2)), \ - "g"((long)(arg3))); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall4(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ - long __res; \ - __asm__ volatile("mov %2, %%rdi\n\t" \ - "mov %3, %%rsi\n\t" \ - "mov %4, %%rdx\n\t" \ - "mov %5, %%r10\n\t" \ - "syscall\n\t" \ - : "=a"(__res) \ - : "0"(0x2000000 | __NR_##name), "g"((long)(arg1)), "c"((long)(arg2)), \ - "d"((long)(arg3)), "S"((long)(arg4))); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall5(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, \ - type5, arg5) \ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \ - long __res; \ - __asm__ volatile("mov %2, %%rdi\n\t" \ - "mov %3, %%rsi\n\t" \ - "mov %4, %%rdx\n\t" \ - "mov %5, %%r10\n\t" \ - "mov %6, %%r8\n\t" \ - "syscall\n\t" \ - : "=a"(__res) \ - : "0"(0x2000000 | __NR_##name), "g"((long)(arg1)), "g"((long)(arg2)), \ - "g"((long)(arg3)), "g"((long)(arg4)), "g"((long)(arg5))); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall6(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, \ - type5, arg5, type6, arg6) \ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) { \ - long __res; \ - __asm__ volatile("mov %2, %%rdi\n\t" \ - "mov %3, %%rsi\n\t" \ - "mov %4, %%rdx\n\t" \ - "mov %5, %%r10\n\t" \ - "mov %6, %%r8\n\t" \ - "mov %7, %%r9\n\t" \ - "syscall\n\t" \ - : "=a"(__res) \ - : "0"(0x2000000 | __NR_##name), "g"((long)(arg1)), "g"((long)(arg2)), \ - "g"((long)(arg3)), "g"((long)(arg4)), "g"((long)(arg5)), \ - "g"((long)(arg6))); \ - __sfsyscall_return(type, __res); \ - } - -#endif /* SFSYSCALL_H */ diff --git a/dest/include/librz/sflib/darwin-x86-64/sfsysnr.h b/dest/include/librz/sflib/darwin-x86-64/sfsysnr.h deleted file mode 100644 index 184beb327d0..00000000000 --- a/dest/include/librz/sflib/darwin-x86-64/sfsysnr.h +++ /dev/null @@ -1,681 +0,0 @@ -/* - * sfsysnr.h --- SFLib syscall numbers for OpenBSD/i386 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - -/* - * Automatically generated by gensflib.py - * Fri Nov 25 15:52:34 2011 - */ - -#ifndef SFSYSNR_H -#define SFSYSNR_H - -/* $Id$ */ - -/* - * Modified from /usr/include/sys/syscall.h - * created from OpenBSD: syscalls.master,v 1.50 2002/07/06 19:14:20 nordin Exp - */ - -/* syscall: "syscall" ret: "int" args: "int" "..." */ -#define __NR_syscall 0 - -/* syscall: "exit" ret: "void" args: "int" */ -#define __NR_exit 1 - -/* syscall: "fork" ret: "int" args: */ -#define __NR_fork 2 - -/* syscall: "read" ret: "ssize_t" args: "int" "void *" "size_t" */ -#define __NR_read 3 - -/* syscall: "write" ret: "ssize_t" args: "int" "const void *" "size_t" */ -#define __NR_write 4 - -/* syscall: "open" ret: "int" args: "const char *" "int" "..." */ -#define __NR_open 5 - -/* syscall: "close" ret: "int" args: "int" */ -#define __NR_close 6 - -/* syscall: "wait4" ret: "int" args: "int" "int *" "int" "struct rusage *" */ -#define __NR_wait4 7 - -/* 8 is compat_43 ocreat */ - -/* syscall: "link" ret: "int" args: "const char *" "const char *" */ -#define __NR_link 9 - -/* syscall: "unlink" ret: "int" args: "const char *" */ -#define __NR_unlink 10 - -/* 11 is obsolete execv */ -/* syscall: "chdir" ret: "int" args: "const char *" */ -#define __NR_chdir 12 - -/* syscall: "fchdir" ret: "int" args: "int" */ -#define __NR_fchdir 13 - -/* syscall: "mknod" ret: "int" args: "const char *" "int" "dev_t" */ -#define __NR_mknod 14 - -/* syscall: "chmod" ret: "int" args: "const char *" "int" */ -#define __NR_chmod 15 - -/* syscall: "chown" ret: "int" args: "const char *" "uid_t" "gid_t" */ -#define __NR_chown 16 - -/* syscall: "break" ret: "int" args: "char *" */ -#define __NR_break 17 - -/* 18 is compat_25 ogetfsstat */ - -/* 19 is compat_43 olseek */ - -/* syscall: "getpid" ret: "pid_t" args: */ -#define __NR_getpid 20 - -/* syscall: "mount" ret: "int" args: "const char *" "const char *" "int" "void *" */ -#define __NR_mount 21 - -/* syscall: "unmount" ret: "int" args: "const char *" "int" */ -#define __NR_unmount 22 - -/* syscall: "setuid" ret: "int" args: "uid_t" */ -#define __NR_setuid 23 - -/* syscall: "getuid" ret: "uid_t" args: */ -#define __NR_getuid 24 - -/* syscall: "geteuid" ret: "uid_t" args: */ -#define __NR_geteuid 25 - -/* syscall: "ptrace" ret: "int" args: "int" "pid_t" "caddr_t" "int" */ -#define __NR_ptrace 26 - -/* syscall: "recvmsg" ret: "ssize_t" args: "int" "struct msghdr *" "int" */ -#define __NR_recvmsg 27 - -/* syscall: "sendmsg" ret: "ssize_t" args: "int" "const struct msghdr *" "int" */ -#define __NR_sendmsg 28 - -/* syscall: "recvfrom" ret: "ssize_t" args: "int" "void *" "size_t" "int" "struct sockaddr *" "socklen_t *" */ -#define __NR_recvfrom 29 - -/* syscall: "accept" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ -#define __NR_accept 30 - -/* syscall: "getpeername" ret: "int" args: "int" "struct sockaddr *" "int *" */ -#define __NR_getpeername 31 - -/* syscall: "getsockname" ret: "int" args: "int" "struct sockaddr *" "socklen_t *" */ -#define __NR_getsockname 32 - -/* syscall: "access" ret: "int" args: "const char *" "int" */ -#define __NR_access 33 - -/* syscall: "chflags" ret: "int" args: "const char *" "u_int" */ -#define __NR_chflags 34 - -/* syscall: "fchflags" ret: "int" args: "int" "u_int" */ -#define __NR_fchflags 35 - -/* syscall: "sync" ret: "void" args: */ -#define __NR_sync 36 - -/* syscall: "kill" ret: "int" args: "int" "int" */ -#define __NR_kill 37 - -/* 38 is compat_43 ostat */ - -/* syscall: "getppid" ret: "pid_t" args: */ -#define __NR_getppid 39 - -/* 40 is compat_43 olstat */ - -/* syscall: "dup" ret: "int" args: "int" */ -#define __NR_dup 41 - -/* syscall: "opipe" ret: "int" args: */ -#define __NR_opipe 42 - -/* syscall: "getegid" ret: "gid_t" args: */ -#define __NR_getegid 43 - -/* syscall: "profil" ret: "int" args: "caddr_t" "size_t" "u_long" "u_int" */ -#define __NR_profil 44 - -/* syscall: "ktrace" ret: "int" args: "const char *" "int" "int" "pid_t" */ -#define __NR_ktrace 45 - -/* syscall: "sigaction" ret: "int" args: "int" "const struct sigaction *" "struct sigaction *" */ -#define __NR_sigaction 46 - -/* syscall: "getgid" ret: "gid_t" args: */ -#define __NR_getgid 47 - -/* syscall: "sigprocmask" ret: "int" args: "int" "sigset_t" */ -#define __NR_sigprocmask 48 - -/* syscall: "getlogin" ret: "int" args: "char *" "u_int" */ -#define __NR_getlogin 49 - -/* syscall: "setlogin" ret: "int" args: "const char *" */ -#define __NR_setlogin 50 - -/* syscall: "acct" ret: "int" args: "const char *" */ -#define __NR_acct 51 - -/* syscall: "sigpending" ret: "int" args: */ -#define __NR_sigpending 52 - -/* syscall: "sigaltstack" ret: "int" args: "const struct sigaltstack *" "struct sigaltstack *" */ -#define __NR_sigaltstack 53 - -/* syscall: "ioctl" ret: "int" args: "int" "u_long" "..." */ -#define __NR_ioctl 54 - -/* syscall: "reboot" ret: "int" args: "int" */ -#define __NR_reboot 55 - -/* syscall: "revoke" ret: "int" args: "const char *" */ -#define __NR_revoke 56 - -/* syscall: "symlink" ret: "int" args: "const char *" "const char *" */ -#define __NR_symlink 57 - -/* syscall: "readlink" ret: "int" args: "const char *" "char *" "size_t" */ -#define __NR_readlink 58 - -/* syscall: "execve" ret: "int" args: "const char *" "char *const *" "char *const *" */ -#define __NR_execve 59 - -/* syscall: "umask" ret: "int" args: "int" */ -#define __NR_umask 60 - -/* syscall: "chroot" ret: "int" args: "const char *" */ -#define __NR_chroot 61 - -/* 62 is compat_43 ofstat */ - -/* 63 is compat_43 ogetkerninfo */ - -/* 64 is compat_43 ogetpagesize */ - -/* syscall: "omsync" ret: "int" args: "caddr_t" "size_t" */ -#define __NR_omsync 65 - -/* syscall: "vfork" ret: "int" args: */ -#define __NR_vfork 66 - -/* 67 is obsolete vread */ -/* 68 is obsolete vwrite */ -/* syscall: "sbrk" ret: "int" args: "int" */ -#define __NR_sbrk 69 - -/* syscall: "sstk" ret: "int" args: "int" */ -#define __NR_sstk 70 - -/* 71 is compat_43 ommap */ - -/* syscall: "vadvise" ret: "int" args: "int" */ -#define __NR_vadvise 72 - -/* syscall: "munmap" ret: "int" args: "void *" "size_t" */ -#define __NR_munmap 73 - -/* syscall: "mprotect" ret: "int" args: "void *" "size_t" "int" */ -#define __NR_mprotect 74 - -/* syscall: "madvise" ret: "int" args: "void *" "size_t" "int" */ -#define __NR_madvise 75 - -/* 76 is obsolete vhangup */ -/* 77 is obsolete vlimit */ -/* syscall: "mincore" ret: "int" args: "void *" "size_t" "char *" */ -#define __NR_mincore 78 - -/* syscall: "getgroups" ret: "int" args: "int" "gid_t *" */ -#define __NR_getgroups 79 - -/* syscall: "setgroups" ret: "int" args: "int" "const gid_t *" */ -#define __NR_setgroups 80 - -/* syscall: "getpgrp" ret: "int" args: */ -#define __NR_getpgrp 81 - -/* syscall: "setpgid" ret: "int" args: "pid_t" "int" */ -#define __NR_setpgid 82 - -/* syscall: "setitimer" ret: "int" args: "int" "const struct itimerval *" "struct itimerval *" */ -#define __NR_setitimer 83 - -/* 84 is compat_43 owait */ - -/* syscall: "swapon" ret: "int" args: "const char *" */ -#define __NR_swapon 85 - -/* syscall: "getitimer" ret: "int" args: "int" "struct itimerval *" */ -#define __NR_getitimer 86 - -/* 87 is compat_43 ogethostname */ - -/* 88 is compat_43 osethostname */ - -/* 89 is compat_43 ogetdtablesize */ - -/* syscall: "dup2" ret: "int" args: "int" "int" */ -#define __NR_dup2 90 - -/* syscall: "fcntl" ret: "int" args: "int" "int" "..." */ -#define __NR_fcntl 92 - -/* syscall: "select" ret: "int" args: "int" "fd_set *" "fd_set *" "fd_set *" "struct timeval *" */ -#define __NR_select 93 - -/* syscall: "fsync" ret: "int" args: "int" */ -#define __NR_fsync 95 - -/* syscall: "setpriority" ret: "int" args: "int" "int" "int" */ -#define __NR_setpriority 96 - -/* syscall: "socket" ret: "int" args: "int" "int" "int" */ -#define __NR_socket 97 - -/* syscall: "connect" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */ -#define __NR_connect 98 - -/* 99 is compat_43 oaccept */ - -/* syscall: "getpriority" ret: "int" args: "int" "int" */ -#define __NR_getpriority 100 - -/* 101 is compat_43 osend */ - -/* 102 is compat_43 orecv */ - -/* syscall: "sigreturn" ret: "int" args: "struct sigcontext *" */ -#define __NR_sigreturn 103 - -/* syscall: "bind" ret: "int" args: "int" "const struct sockaddr *" "socklen_t" */ -#define __NR_bind 104 - -/* syscall: "setsockopt" ret: "int" args: "int" "int" "int" "const void *" "socklen_t" */ -#define __NR_setsockopt 105 - -/* syscall: "listen" ret: "int" args: "int" "int" */ -#define __NR_listen 106 - -/* 107 is obsolete vtimes */ -/* 108 is compat_43 osigvec */ - -/* 109 is compat_43 osigblock */ - -/* 110 is compat_43 osigsetmask */ - -/* syscall: "sigsuspend" ret: "int" args: "int" */ -#define __NR_sigsuspend 111 - -/* 112 is compat_43 osigstack */ - -/* 113 is compat_43 orecvmsg */ - -/* 114 is compat_43 osendmsg */ - -/* 115 is obsolete vtrace */ -/* syscall: "gettimeofday" ret: "int" args: "struct timeval *" "struct timezone *" */ -#define __NR_gettimeofday 116 - -/* syscall: "getrusage" ret: "int" args: "int" "struct rusage *" */ -#define __NR_getrusage 117 - -/* syscall: "getsockopt" ret: "int" args: "int" "int" "int" "void *" "socklen_t *" */ -#define __NR_getsockopt 118 - -/* 119 is obsolete resuba */ -/* syscall: "readv" ret: "ssize_t" args: "int" "const struct iovec *" "int" */ -#define __NR_readv 120 - -/* syscall: "writev" ret: "ssize_t" args: "int" "const struct iovec *" "int" */ -#define __NR_writev 121 - -/* syscall: "settimeofday" ret: "int" args: "const struct timeval *" "const struct timezone *" */ -#define __NR_settimeofday 122 - -/* syscall: "fchown" ret: "int" args: "int" "uid_t" "gid_t" */ -#define __NR_fchown 123 - -/* syscall: "fchmod" ret: "int" args: "int" "int" */ -#define __NR_fchmod 124 - -/* 125 is compat_43 orecvfrom */ - -/* 126 is compat_43 osetreuid */ - -/* 127 is compat_43 osetregid */ - -/* syscall: "rename" ret: "int" args: "const char *" "const char *" */ -#define __NR_rename 128 - -/* 129 is compat_43 otruncate */ - -/* 130 is compat_43 oftruncate */ - -/* syscall: "flock" ret: "int" args: "int" "int" */ -#define __NR_flock 131 - -/* syscall: "mkfifo" ret: "int" args: "const char *" "int" */ -#define __NR_mkfifo 132 - -/* syscall: "sendto" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "const struct sockaddr *" "socklen_t" */ -#define __NR_sendto 133 - -/* syscall: "shutdown" ret: "int" args: "int" "int" */ -#define __NR_shutdown 134 - -/* syscall: "socketpair" ret: "int" args: "int" "int" "int" "int *" */ -#define __NR_socketpair 135 - -/* syscall: "mkdir" ret: "int" args: "const char *" "int" */ -#define __NR_mkdir 136 - -/* syscall: "rmdir" ret: "int" args: "const char *" */ -#define __NR_rmdir 137 - -/* syscall: "utimes" ret: "int" args: "const char *" "const struct timeval *" */ -#define __NR_utimes 138 - -/* 139 is obsolete 4.2 sigreturn */ -/* syscall: "adjtime" ret: "int" args: "const struct timeval *" "struct timeval *" */ -#define __NR_adjtime 140 - -/* 141 is compat_43 ogetpeername */ - -/* 142 is compat_43 ogethostid */ - -/* 143 is compat_43 osethostid */ - -/* 144 is compat_43 ogetrlimit */ - -/* 145 is compat_43 osetrlimit */ - -/* 146 is compat_43 okillpg */ - -/* syscall: "setsid" ret: "int" args: */ -#define __NR_setsid 147 - -/* syscall: "quotactl" ret: "int" args: "const char *" "int" "int" "char *" */ -#define __NR_quotactl 148 - -/* 149 is compat_43 oquota */ - -/* 150 is compat_43 ogetsockname */ - -/* syscall: "nfssvc" ret: "int" args: "int" "void *" */ -#define __NR_nfssvc 155 - -/* 156 is compat_43 ogetdirentries */ - -/* 157 is compat_25 ostatfs */ - -/* 158 is compat_25 ostatfs */ - -/* syscall: "getfh" ret: "int" args: "const char *" "fhandle_t *" */ -#define __NR_getfh 161 - -/* 162 is compat_09 ogetdomainname */ - -/* 163 is compat_09 osetdomainname */ - -/* 164 is compat_09 ouname */ - -/* syscall: "sysarch" ret: "int" args: "int" "void *" */ -#define __NR_sysarch 165 - -/* 169 is compat_10 osemsys */ - -/* 170 is compat_10 omsgsys */ - -/* 171 is compat_10 oshmsys */ - -/* syscall: "pread" ret: "ssize_t" args: "int" "void *" "size_t" "int" "off_t" */ -#define __NR_pread 173 - -/* syscall: "pwrite" ret: "ssize_t" args: "int" "const void *" "size_t" "int" "off_t" */ -#define __NR_pwrite 174 - -/* syscall: "setgid" ret: "int" args: "gid_t" */ -#define __NR_setgid 181 - -/* syscall: "setegid" ret: "int" args: "gid_t" */ -#define __NR_setegid 182 - -/* syscall: "seteuid" ret: "int" args: "uid_t" */ -#define __NR_seteuid 183 - -/* syscall: "lfs_bmapv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */ -#define __NR_lfs_bmapv 184 - -/* syscall: "lfs_markv" ret: "int" args: "fsid_t *" "struct block_info *" "int" */ -#define __NR_lfs_markv 185 - -/* syscall: "lfs_segclean" ret: "int" args: "fsid_t *" "u_long" */ -#define __NR_lfs_segclean 186 - -/* syscall: "lfs_segwait" ret: "int" args: "fsid_t *" "struct timeval *" */ -#define __NR_lfs_segwait 187 - -/* syscall: "stat" ret: "int" args: "const char *" "struct stat *" */ -#define __NR_stat 188 - -/* syscall: "fstat" ret: "int" args: "int" "struct stat *" */ -#define __NR_fstat 189 - -/* syscall: "lstat" ret: "int" args: "const char *" "struct stat *" */ -#define __NR_lstat 190 - -/* syscall: "pathconf" ret: "long" args: "const char *" "int" */ -#define __NR_pathconf 191 - -/* syscall: "fpathconf" ret: "long" args: "int" "int" */ -#define __NR_fpathconf 192 - -/* syscall: "swapctl" ret: "int" args: "int" "const void *" "int" */ -#define __NR_swapctl 193 - -/* syscall: "getrlimit" ret: "int" args: "int" "struct rlimit *" */ -#define __NR_getrlimit 194 - -/* syscall: "setrlimit" ret: "int" args: "int" "const struct rlimit *" */ -#define __NR_setrlimit 195 - -/* syscall: "getdirentries" ret: "int" args: "int" "char *" "int" "long *" */ -#define __NR_getdirentries 196 - -/* syscall: "mmap" ret: "void *" args: "void *" "size_t" "int" "int" "int" "long" "off_t" */ -#define __NR_mmap 197 - -/* syscall: "__syscall" ret: "quad_t" args: "quad_t" "..." */ -#define __NR___syscall 198 - -/* syscall: "lseek" ret: "off_t" args: "int" "int" "off_t" "int" */ -#define __NR_lseek 199 - -/* syscall: "truncate" ret: "int" args: "const char *" "int" "off_t" */ -#define __NR_truncate 200 - -/* syscall: "ftruncate" ret: "int" args: "int" "int" "off_t" */ -#define __NR_ftruncate 201 - -/* syscall: "__sysctl" ret: "int" args: "int *" "u_int" "void *" "size_t *" "void *" "size_t" */ -#define __NR___sysctl 202 - -/* syscall: "mlock" ret: "int" args: "const void *" "size_t" */ -#define __NR_mlock 203 - -/* syscall: "munlock" ret: "int" args: "const void *" "size_t" */ -#define __NR_munlock 204 - -/* syscall: "undelete" ret: "int" args: "const char *" */ -#define __NR_undelete 205 - -/* syscall: "futimes" ret: "int" args: "int" "const struct timeval *" */ -#define __NR_futimes 206 - -/* syscall: "getpgid" ret: "pid_t" args: "pid_t" */ -#define __NR_getpgid 207 - -/* syscall: "xfspioctl" ret: "int" args: "int" "char *" "int" "struct ViceIoctl *" "int" */ -#define __NR_xfspioctl 208 - -/* 220 is compat_23 __osemctl */ - -/* syscall: "semget" ret: "int" args: "key_t" "int" "int" */ -#define __NR_semget 221 - -/* syscall: "semop" ret: "int" args: "int" "struct sembuf *" "u_int" */ -#define __NR_semop 222 - -/* 223 is obsolete sys_semconfig */ -/* 224 is compat_23 omsgctl */ - -/* syscall: "msgget" ret: "int" args: "key_t" "int" */ -#define __NR_msgget 225 - -/* syscall: "msgsnd" ret: "int" args: "int" "const void *" "size_t" "int" */ -#define __NR_msgsnd 226 - -/* syscall: "msgrcv" ret: "int" args: "int" "void *" "size_t" "long" "int" */ -#define __NR_msgrcv 227 - -/* syscall: "shmat" ret: "void *" args: "int" "const void *" "int" */ -#define __NR_shmat 228 - -/* 229 is compat_23 oshmctl */ - -/* syscall: "shmdt" ret: "int" args: "const void *" */ -#define __NR_shmdt 230 - -/* syscall: "shmget" ret: "int" args: "key_t" "int" "int" */ -#define __NR_shmget 231 - -/* syscall: "clock_gettime" ret: "int" args: "clockid_t" "struct timespec *" */ -#define __NR_clock_gettime 232 - -/* syscall: "clock_settime" ret: "int" args: "clockid_t" "const struct timespec *" */ -#define __NR_clock_settime 233 - -/* syscall: "clock_getres" ret: "int" args: "clockid_t" "struct timespec *" */ -#define __NR_clock_getres 234 - -/* syscall: "nanosleep" ret: "int" args: "const struct timespec *" "struct timespec *" */ -#define __NR_nanosleep 240 - -/* syscall: "minherit" ret: "int" args: "void *" "size_t" "int" */ -#define __NR_minherit 250 - -/* syscall: "rfork" ret: "int" args: "int" */ -#define __NR_rfork 251 - -/* syscall: "poll" ret: "int" args: "struct pollfd *" "unsigned long" "int" */ -#define __NR_poll 252 - -/* syscall: "issetugid" ret: "int" args: */ -#define __NR_issetugid 253 - -/* syscall: "lchown" ret: "int" args: "const char *" "uid_t" "gid_t" */ -#define __NR_lchown 254 - -/* syscall: "getsid" ret: "pid_t" args: "pid_t" */ -#define __NR_getsid 255 - -/* syscall: "msync" ret: "int" args: "void *" "size_t" "int" */ -#define __NR_msync 256 - -/* syscall: "__semctl" ret: "int" args: "int" "int" "int" "union semun *" */ -#define __NR___semctl 257 - -/* syscall: "shmctl" ret: "int" args: "int" "int" "struct shmid_ds *" */ -#define __NR_shmctl 258 - -/* syscall: "msgctl" ret: "int" args: "int" "int" "struct msqid_ds *" */ -#define __NR_msgctl 259 - -/* syscall: "getfsstat" ret: "int" args: "struct statfs *" "size_t" "int" */ -#define __NR_getfsstat 260 - -/* syscall: "statfs" ret: "int" args: "const char *" "struct statfs *" */ -#define __NR_statfs 261 - -/* syscall: "fstatfs" ret: "int" args: "int" "struct statfs *" */ -#define __NR_fstatfs 262 - -/* syscall: "pipe" ret: "int" args: "int *" */ -#define __NR_pipe 263 - -/* syscall: "fhopen" ret: "int" args: "const fhandle_t *" "int" */ -#define __NR_fhopen 264 - -/* syscall: "fhstat" ret: "int" args: "const fhandle_t *" "struct stat *" */ -#define __NR_fhstat 265 - -/* syscall: "fhstatfs" ret: "int" args: "const fhandle_t *" "struct statfs *" */ -#define __NR_fhstatfs 266 - -/* syscall: "preadv" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */ -#define __NR_preadv 267 - -/* syscall: "pwritev" ret: "ssize_t" args: "int" "const struct iovec *" "int" "int" "off_t" */ -#define __NR_pwritev 268 - -/* syscall: "kqueue" ret: "int" args: */ -#define __NR_kqueue 269 - -/* syscall: "kevent" ret: "int" args: "int" "const struct kevent *" "int" "struct kevent *" "int" "const struct timespec *" */ -#define __NR_kevent 270 - -/* syscall: "mlockall" ret: "int" args: "int" */ -#define __NR_mlockall 271 - -/* syscall: "munlockall" ret: "int" args: */ -#define __NR_munlockall 272 - -/* syscall: "getpeereid" ret: "int" args: "int" "uid_t *" "gid_t *" */ -#define __NR_getpeereid 273 - -/* syscall: "extattrctl" ret: "int" args: "const char *" "int" "const char *" "int" "const char *" */ -#define __NR_extattrctl 274 - -/* syscall: "extattr_set_file" ret: "int" args: "const char *" "int" "const char *" "void *" "size_t" */ -#define __NR_extattr_set_file 275 - -/* syscall: "extattr_get_file" ret: "ssize_t" args: "const char *" "int" "const char *" "void *" "size_t" */ -#define __NR_extattr_get_file 276 - -/* syscall: "extattr_delete_file" ret: "int" args: "const char *" "int" "const char *" */ -#define __NR_extattr_delete_file 277 - -/* syscall: "extattr_set_fd" ret: "int" args: "int" "int" "const char *" "void *" "size_t" */ -#define __NR_extattr_set_fd 278 - -/* syscall: "extattr_get_fd" ret: "ssize_t" args: "int" "int" "const char *" "void *" "size_t" */ -#define __NR_extattr_get_fd 279 - -/* syscall: "extattr_delete_fd" ret: "int" args: "int" "int" "const char *" */ -#define __NR_extattr_delete_fd 280 - -#define __NR_MAXSYSCALL 281 - -#endif /* SFSYSNR_H */ diff --git a/dest/include/librz/sflib/linux-arm-32/sflib.h b/dest/include/librz/sflib/linux-arm-32/sflib.h deleted file mode 100644 index 20bee69d3ea..00000000000 --- a/dest/include/librz/sflib/linux-arm-32/sflib.h +++ /dev/null @@ -1,272 +0,0 @@ -/* - * sflib.h --- SFLib syscall library for Linux/ARM - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - - -/* - * Automatically generated by gensflib.py - * Mon Mar 21 13:23:31 2022 - */ - -#ifndef SFLIB_H -#define SFLIB_H - - -#include "sfsysnr.h" -#include "sfsyscall.h" -#include "../common/sftypes.h" - -static inline _sfsyscall1(int, exit, int, status) -static inline _sfsyscall0( pid_t, fork ) -static inline _sfsyscall3( ssize_t, read, int, fd, void *, buf, size_t, count ) -static inline _sfsyscall3( ssize_t, write, int, fd, const void *, buf, size_t, count ) -static inline _sfsyscall3( int, open, const char *, pathname, int, flags, mode_t, mode ) -static inline _sfsyscall1( int, close, int, fd ) -static inline _sfsyscall2( int, creat, const char *, pathname, mode_t, mode ) -static inline _sfsyscall2( int, link, const char *, oldpath, const char *, newpath ) -static inline _sfsyscall1( int, unlink, const char *, pathname ) -static inline _sfsyscall3(int, execve, char *, s, char **, argv, char **,envp) -static inline _sfsyscall1( int, chdir, const char *, path ) -static inline _sfsyscall1( time_t, time, time_t *, t ) -static inline _sfsyscall3( int, mknod, const char *, pathname, mode_t, mode, dev_t, dev ) -static inline _sfsyscall2( int, chmod, const char *, path, mode_t, mode ) -static inline _sfsyscall3( int, lchown, const char *, path, uid_t, owner, gid_t, group ) -// break -static inline _sfsyscall3( off_t, lseek, int, fildes, off_t, offset, int, whence ) -static inline _sfsyscall0( pid_t, getpid ) -// mount -static inline _sfsyscall1( int, umount, const char *, dir ) -// setuid -static inline _sfsyscall0( uid_t, getuid ) -static inline _sfsyscall1( int, stime, time_t *, t ) -static inline _sfsyscall4(long, ptrace, int, request, pid_t, pid, void *,addr, void *,data) -static inline _sfsyscall1( unsigned int, alarm, unsigned int, seconds ) -static inline _sfsyscall0( int, pause ) -static inline _sfsyscall2( int, utime, const char *, filename, struct utimbuf *, buf ) -// stty -// gtty -static inline _sfsyscall2( int, access, const char *, pathname, int, mode ) -static inline _sfsyscall1( int, nice, int, inc ) -// ftime -static inline _sfsyscall0( int, sync ) -static inline _sfsyscall2( int, kill, pid_t, pid, int, sig ) -static inline _sfsyscall2( int, rename, const char *, oldpath, const char *, newpath ) -static inline _sfsyscall2( int, mkdir, const char *, pathname, mode_t, mode ) -static inline _sfsyscall1( int, rmdir, const char *, pathname ) -static inline _sfsyscall1( int, dup, int, oldfd ) -static inline _sfsyscall1( int, pipe, unsigned long *, filedes) -static inline _sfsyscall1( clock_t, times, struct tms *, buf ) -// prof -static inline _sfsyscall1( int, brk, void *, end_data_segment ) -// setgid -static inline _sfsyscall0( gid_t, getgid ) -static inline _sfsyscall2( sighandler_t, signal, int, signum, sighandler_t, handler ) -static inline _sfsyscall0( uid_t, geteuid ) -static inline _sfsyscall0( gid_t, getegid ) -static inline _sfsyscall1( int, acct, const char *, filename ) -// umount2 -// lock -static inline _sfsyscall4(int, ioctl, int,d, int,request, char *,argp, int,len) -static inline _sfsyscall3( int, fcntl, int, fd, int, cmd, long, arg ) -// mpx -static inline _sfsyscall2( int, setpgid, pid_t, pid, pid_t, pgid ) -// ulimit -static inline _sfsyscall1( mode_t, umask, mode_t, mask ) -static inline _sfsyscall1( int, chroot, const char *, path ) -static inline _sfsyscall2( int, ustat, dev_t, dev, struct ustat *, ubuf ) -static inline _sfsyscall2( int, dup2, int, oldfd, int, newfd ) -static inline _sfsyscall0( pid_t, getppid ) -static inline _sfsyscall0( pid_t, getpgrp ) -static inline _sfsyscall0( pid_t, setsid ) -// sigaction -// sgetmask -// ssetmask -static inline _sfsyscall2( int, setreuid, uid_t, ruid, uid_t, euid ) -static inline _sfsyscall2( int, setregid, gid_t, rgid, gid_t, egid ) -static inline _sfsyscall1( int, sigsuspend, const sigset_t *, mask ) -static inline _sfsyscall1( int, sigpending, sigset_t *, set ) -static inline _sfsyscall2( int, sethostname, const char *, name, size_t, len ) -// setrlimit -// getrlimit -// getrusage -static inline _sfsyscall2( int, gettimeofday, struct timeval *, tv, struct timezone *, tz ) -// settimeofday -// getgroups -static inline _sfsyscall2( int, setgroups, size_t, size, const gid_t *, list ) -static inline _sfsyscall5( int, select, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout) -static inline _sfsyscall2( int, symlink, const char *, oldpath, const char *, newpath ) -static inline _sfsyscall3( int, readlink, const char *, path, char *, buf, size_t, bufsiz ) -static inline _sfsyscall1( int, uselib, const char *, library ) -static inline _sfsyscall2( int, swapon, const char *, path, int, swapflags ) -// reboot -static inline _sfsyscall3( int, readdir, unsigned int, fd, struct dirent *, dirp, unsigned int, count ) -static inline _sfsyscall6(void *,mmap, void *,start, size_t,length, int,prot , int,flags, int,fd, off_t,offset) -static inline _sfsyscall2( int, munmap, void *, start, size_t, length ) -static inline _sfsyscall2( int, truncate, const char *, path, off_t, length ) -static inline _sfsyscall2( int, ftruncate, int, fd, off_t, length ) -static inline _sfsyscall2( int, fchmod, int, fildes, mode_t, mode ) -static inline _sfsyscall3( int, fchown, int, fd, uid_t, owner, gid_t, group ) -static inline _sfsyscall2( int, getpriority, int, which, int, who ) -static inline _sfsyscall3( int, setpriority, int, which, int, who, int, prio ) -// profil -static inline _sfsyscall2( int, statfs, const char *, path, struct statfs *, buf ) -static inline _sfsyscall2( int, fstatfs, int, fd, struct statfs *, buf ) -static inline _sfsyscall3( int, ioperm, unsigned long, from, unsigned long, num, int, turn_on ) -static inline _sfsyscall2( int, socketcall, int, call, unsigned long *,args); -static inline _sfsyscall3( int, syslog, int, type, char *, bufp, int, len ) -// setitimer -// getitimer -static inline _sfsyscall2( int, stat, const char *, file_name, struct stat *, buf ) -static inline _sfsyscall2( int, lstat, const char *, file_name, struct stat *, buf ) -static inline _sfsyscall2( int, fstat, int, filedes, struct stat *, buf ) -static inline _sfsyscall0( int, vhangup ) -static inline _sfsyscall0( int, idle ) -// syscall -static inline _sfsyscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, struct rusage *, rusage) -static inline _sfsyscall1( int, swapoff, const char *, path ) -static inline _sfsyscall1( int, sysinfo, struct sysinfo *, info ) -// ipc -static inline _sfsyscall1( int, fsync, int, fd ) -static inline _sfsyscall1( int, sigreturn, unsigned long, __unused ) -// clone -static inline _sfsyscall2( int, setdomainname, const char *, name, size_t, len ) -static inline _sfsyscall1( int, uname, struct utsname *, buf ) -// modify_ldt -// adjtimex -static inline _sfsyscall3( int, mprotect, const void *, addr, size_t, len, int, prot ) -// sigprocmask -static inline _sfsyscall2( caddr_t, create_module, const char *, name, size_t, size ) -static inline _sfsyscall2( int, init_module, const char *, name, struct module *, image ) -static inline _sfsyscall1( int, delete_module, const char *, name ) -static inline _sfsyscall1( int, get_kernel_syms, struct kernel_sym *, table ) -// quotactl -static inline _sfsyscall1( pid_t, getpgid, pid_t, pid ) -// fchdir -// bdflush -static inline _sfsyscall3( int, sysfs, int, option, unsigned int, fs_index, char *, buf ) -static inline _sfsyscall1( int, personality, unsigned long, persona ) -// afs_syscall -static inline _sfsyscall1( int, setfsuid, uid_t, fsuid ) -static inline _sfsyscall1( int, setfsgid, uid_t, fsgid ) -static inline _sfsyscall3( int, getdents, unsigned int, fd, struct dirent *, dirp, unsigned int, count ) -// flock -static inline _sfsyscall3( int, msync, const void *, start, size_t, length, int, flags ) -static inline _sfsyscall3( int, readv, int, fd, const struct iovec *, vector, int, count ) -static inline _sfsyscall3( int, writev, int, fd, const struct iovec *, vector, int, count ) -static inline _sfsyscall1( pid_t, getsid, pid_t, pid ) -static inline _sfsyscall1( int, fdatasync, int, fd ) -static inline _sfsyscall2( int, mlock, const void *, addr, size_t, len ) -static inline _sfsyscall2( int, munlock, const void *, addr, size_t, len ) -static inline _sfsyscall1( int, mlockall, int, flags ) -static inline _sfsyscall0( int, munlockall ) -static inline _sfsyscall2( int, sched_setparam, pid_t, pid, const struct sched_param *, p ) -static inline _sfsyscall2( int, sched_getparam, pid_t, pid, struct sched_param *, p ) -// sched_setscheduler -static inline _sfsyscall1( int, sched_getscheduler, pid_t, pid ) -static inline _sfsyscall0( int, sched_yield ) -static inline _sfsyscall1( int, sched_get_priority_max, int, policy ) -static inline _sfsyscall1( int, sched_get_priority_min, int, policy ) -static inline _sfsyscall2( int, sched_rr_get_interval, pid_t, pid, struct timespec *, tp ) -static inline _sfsyscall2( int, nanosleep, const struct timespec *, req, struct timespec *, rem ) -// mremap -static inline _sfsyscall3( int, setresuid, uid_t, ruid, uid_t, euid, uid_t, suid ) -static inline _sfsyscall3( int, getresuid, uid_t *, ruid, uid_t *, euid, uid_t *, suid ) -static inline _sfsyscall2( int, vm86, unsigned long, fn, struct vm86plus_struct *, v86 ) -// query_module -static inline _sfsyscall3( int, poll, struct pollfd *, ufds, unsigned int, nfds, int, timeout ) -// nfsservctl -// setresgid -// getresgid -// prctl -// rt_sigreturn -// rt_sigaction -// rt_sigprocmask -// rt_sigpending -// rt_sigtimedwait -// rt_sigqueueinfo -// rt_sigsuspend -static inline _sfsyscall4( ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset ) -// pwrite -static inline _sfsyscall3( int, chown, const char *, path, uid_t, owner, gid_t, group ) -// getcwd -static inline _sfsyscall2( int, capget, cap_user_header_t, header, cap_user_data_t, data ) -//static inline _sfsyscall2( int, capset, cap_user_header_t, header, const cap_user_data_t, data ) -// sigaltstack -// sendfile -static inline _sfsyscall0( pid_t, vfork ) -// ugetrlimit -// mmap2 -// truncate64 -// ftruncate64 -// stat64 -// lstat64 -// fstat64 -// lchown32 -// getuid32 -// getgid32 -// geteuid32 -// getegid32 -// setreuid32 -// setregid32 -// getgroups32 -// setgroups32 -// fchown32 -// setresuid32 -// getresuid32 -// setresgid32 -// getresgid32 -// chown32 -// setuid32 -// setgid32 -// setfsuid32 -// setfsgid32 -// getdents64 -// pivot_root -// mincore -// madvise -// fcntl64 -// security -// gettid -// readahead -// setxattr -// lsetxattr -// fsetxattr -// getxattr -// lgetxattr -// fgetxattr -// listxattr -// llistxattr -// flistxattr -// removexattr -// lremovexattr -// fremovexattr -// tkill -// sendfile64 -// futex -// sched_setaffinity -// sched_getaffinity -// io_setup -// io_destroy -// io_getevents -// io_submit -// io_cancel -// exit_group -// lookup_dcookie -// epoll_create -// epoll_ctl -// epoll_wait -// remap_file_pages - -#endif /* SFLIB_H */ diff --git a/dest/include/librz/sflib/linux-arm-32/sfsyscall.h b/dest/include/librz/sflib/linux-arm-32/sfsyscall.h deleted file mode 100644 index baad4fd5aef..00000000000 --- a/dest/include/librz/sflib/linux-arm-32/sfsyscall.h +++ /dev/null @@ -1,174 +0,0 @@ -/* sfsyscall.h --- SFLib syscall macros for Linux/arm64 - pancake */ - -#ifndef SFSYSCALL_H -#define SFSYSCALL_H - -/* $Id$ */ - -#ifdef SF_USE_ERRNO - -static int errno = 1234; - -#define __sfsyscall_return(type, res) \ - do { \ - if ((unsigned long)(res) >= (unsigned long)(-125)) { \ - errno = -(res); \ - res = -1; \ - } \ - return (type)(res); \ - } while (0) - -#else /* SF_USE_ERRNO */ - -#define __sfsyscall_return(type, res) \ - do { \ - return (type)(res); \ - } while (0) - -#endif /* SF_USE_ERRNO */ - -/* syscall macros */ - -#define _sfsyscall0(type, name) \ - type name(void) { \ - long __res; \ - __asm__ volatile("###> " #name " <###\n\t" \ - "svc 0" \ - : "=a"(__res) \ - : "0"(__NR_##name) \ - : "memory", "cc"); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall1(type, name, type1, arg1) \ - type name(type1 arg1) { \ - long __res; \ - register type1 r1 asm("r0"); \ - r1 = arg1; \ - asm volatile("###> " #name "(%2) <###\n\t" \ - "mov r7, %0\n\t" \ - "svc 0" \ - : "=g"(__res) \ - : "0"(__NR_##name), "r"(r1)); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall2(type, name, type1, arg1, type2, arg2) \ - type name(type1 arg1, type2 arg2) { \ - long __res; \ - register type1 r1 asm("r1"); \ - register type2 r2 asm("r2"); \ - r1 = arg1; \ - r2 = arg2; \ - __asm__ volatile("###> " #name "(%2, %3) <###\n\t" \ - "svc 0" \ - : "=g"(__res) \ - : "0"(__NR_##name), \ - "r"(r1), \ - "r"(r2)); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ - type name(type1 arg1, type2 arg2, type3 arg3) { \ - long __res; \ - register type1 r0 asm("r0"); \ - register type2 r1 asm("r1"); \ - register type3 r2 asm("r2"); \ - r0 = arg1; \ - r1 = arg2; \ - r2 = arg3; \ - __asm__ __volatile__("###> " #name "(%2, %3, %4) <###\n\t" \ - "mov r7, %1\n\t" \ - "svc 0" \ - : "=g"(__res) \ - : "0"(__NR_##name), \ - "r"(r0), \ - "r"(r1), \ - "r"(r2) \ - : "memory", "cc"); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall4(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ - long __res; \ - register type1 r1 asm("r1"); \ - ; \ - register type2 r2 asm("r2"); \ - register type3 r3 asm("r3"); \ - register type4 r4 asm("r4"); \ - r1 = arg1; \ - r2 = arg2; \ - r3 = arg3; \ - r4 = arg4; \ - asm volatile("###> " #name "(%2, %3, %4, %5) <###\n\t" \ - "svc 0" \ - : "=g"(__res) \ - : "0"(__NR_##name), \ - "r"(r1), \ - "r"(r2), \ - "r"(r3), \ - "r"(r4) \ - : "memory", "cc"); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall5(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) \ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ - type5 arg5) { \ - long __res; \ - register type1 r1 asm("r1"); \ - register type2 r2 asm("r2"); \ - register type3 r3 asm("r3"); \ - register type4 r4 asm("r4"); \ - register type5 r5 asm("r5"); \ - r1 = arg1; \ - r2 = arg2; \ - r3 = arg3; \ - r4 = arg4; \ - r5 = arg5; \ - asm volatile("###> " #name "(%2, %3, %4, %5, %6) <###\n\t" \ - "svc 0" \ - : "=g"(__res) \ - : "0"(__NR_##name), \ - "r"(r1), \ - "r"(r2), \ - "r"(r3), \ - "r"(r4), \ - "r"(r5) \ - : "memory", "cc"); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall6(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ - type5 arg5, type6 arg6) { \ - long __res; \ - register type1 r1 asm("r1"); \ - register type2 r2 asm("r2"); \ - register type3 r3 asm("r3"); \ - register type4 r4 asm("r4"); \ - register type5 r5 asm("r5"); \ - register type6 r6 asm("r6"); \ - r1 = arg1; \ - r2 = arg2; \ - r3 = arg3; \ - r4 = arg4; \ - r5 = arg5; \ - r6 = arg6; \ - asm volatile("###> " #name "(%2, %3, %4, %5, %6, %7) <###\n\t" \ - "svc 0" \ - : "=a"(__res) \ - : "0"(__NR_##name), \ - "r"(r1), \ - "r"(r2), \ - "r"(r3), \ - "r"(r4), \ - "r"(r5), \ - "r"(r6) \ - : "memory", "cc"); \ - __sfsyscall_return(type, __res); \ - } - -#endif /* SFSYSCALL_H */ diff --git a/dest/include/librz/sflib/linux-arm-32/sfsysnr.h b/dest/include/librz/sflib/linux-arm-32/sfsysnr.h deleted file mode 100644 index c1967a280e9..00000000000 --- a/dest/include/librz/sflib/linux-arm-32/sfsysnr.h +++ /dev/null @@ -1,316 +0,0 @@ -/* - * sfsysnr.h --- SFLib syscall numbers for Linux/ARM - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - - -/* - * Automatically generated by gensflib.py - * Mon Mar 21 13:23:31 2022 - */ - -#ifndef SFSYSNR_H -#define SFSYSNR_H - - -/* $Id$ */ - -/* - * From linux/include/asm-arm/unistd.h - * Copyright (C) 2001-2002 Russell King - */ - - -#if defined(__thumb__) -#define __NR_SYSCALL_BASE 0 -#else -#define __NR_SYSCALL_BASE 0x900000 -#endif - -/* - * This file contains the system call numbers. - */ - -#define __NR_exit (__NR_SYSCALL_BASE+ 1) -#define __NR_fork (__NR_SYSCALL_BASE+ 2) -#define __NR_read (__NR_SYSCALL_BASE+ 3) -#define __NR_write (__NR_SYSCALL_BASE+ 4) -#define __NR_open (__NR_SYSCALL_BASE+ 5) -#define __NR_close (__NR_SYSCALL_BASE+ 6) -/*#define __NR_waitpid (__NR_SYSCALL_BASE+ 7) debian bug #201989 ARM doesnt have this syscall and its define breaks glibc*/ -#define __NR_creat (__NR_SYSCALL_BASE+ 8) -#define __NR_link (__NR_SYSCALL_BASE+ 9) -#define __NR_unlink (__NR_SYSCALL_BASE+ 10) -#define __NR_execve (__NR_SYSCALL_BASE+ 11) -#define __NR_chdir (__NR_SYSCALL_BASE+ 12) -#define __NR_time (__NR_SYSCALL_BASE+ 13) -#define __NR_mknod (__NR_SYSCALL_BASE+ 14) -#define __NR_chmod (__NR_SYSCALL_BASE+ 15) -#define __NR_lchown (__NR_SYSCALL_BASE+ 16) -#define __NR_break (__NR_SYSCALL_BASE+ 17) - -#define __NR_lseek (__NR_SYSCALL_BASE+ 19) -#define __NR_getpid (__NR_SYSCALL_BASE+ 20) -#define __NR_mount (__NR_SYSCALL_BASE+ 21) -#define __NR_umount (__NR_SYSCALL_BASE+ 22) -#define __NR_setuid (__NR_SYSCALL_BASE+ 23) -#define __NR_getuid (__NR_SYSCALL_BASE+ 24) -#define __NR_stime (__NR_SYSCALL_BASE+ 25) -#define __NR_ptrace (__NR_SYSCALL_BASE+ 26) -#define __NR_alarm (__NR_SYSCALL_BASE+ 27) - -#define __NR_pause (__NR_SYSCALL_BASE+ 29) -#define __NR_utime (__NR_SYSCALL_BASE+ 30) -#define __NR_stty (__NR_SYSCALL_BASE+ 31) -#define __NR_gtty (__NR_SYSCALL_BASE+ 32) -#define __NR_access (__NR_SYSCALL_BASE+ 33) -#define __NR_nice (__NR_SYSCALL_BASE+ 34) -#define __NR_ftime (__NR_SYSCALL_BASE+ 35) -#define __NR_sync (__NR_SYSCALL_BASE+ 36) -#define __NR_kill (__NR_SYSCALL_BASE+ 37) -#define __NR_rename (__NR_SYSCALL_BASE+ 38) -#define __NR_mkdir (__NR_SYSCALL_BASE+ 39) -#define __NR_rmdir (__NR_SYSCALL_BASE+ 40) -#define __NR_dup (__NR_SYSCALL_BASE+ 41) -#define __NR_pipe (__NR_SYSCALL_BASE+ 42) -#define __NR_times (__NR_SYSCALL_BASE+ 43) -#define __NR_prof (__NR_SYSCALL_BASE+ 44) -#define __NR_brk (__NR_SYSCALL_BASE+ 45) -#define __NR_setgid (__NR_SYSCALL_BASE+ 46) -#define __NR_getgid (__NR_SYSCALL_BASE+ 47) -#define __NR_signal (__NR_SYSCALL_BASE+ 48) -#define __NR_geteuid (__NR_SYSCALL_BASE+ 49) -#define __NR_getegid (__NR_SYSCALL_BASE+ 50) -#define __NR_acct (__NR_SYSCALL_BASE+ 51) -#define __NR_umount2 (__NR_SYSCALL_BASE+ 52) -#define __NR_lock (__NR_SYSCALL_BASE+ 53) -#define __NR_ioctl (__NR_SYSCALL_BASE+ 54) -#define __NR_fcntl (__NR_SYSCALL_BASE+ 55) -#define __NR_mpx (__NR_SYSCALL_BASE+ 56) -#define __NR_setpgid (__NR_SYSCALL_BASE+ 57) -#define __NR_ulimit (__NR_SYSCALL_BASE+ 58) - -#define __NR_umask (__NR_SYSCALL_BASE+ 60) -#define __NR_chroot (__NR_SYSCALL_BASE+ 61) -#define __NR_ustat (__NR_SYSCALL_BASE+ 62) -#define __NR_dup2 (__NR_SYSCALL_BASE+ 63) -#define __NR_getppid (__NR_SYSCALL_BASE+ 64) -#define __NR_getpgrp (__NR_SYSCALL_BASE+ 65) -#define __NR_setsid (__NR_SYSCALL_BASE+ 66) -#define __NR_sigaction (__NR_SYSCALL_BASE+ 67) -#define __NR_sgetmask (__NR_SYSCALL_BASE+ 68) -#define __NR_ssetmask (__NR_SYSCALL_BASE+ 69) -#define __NR_setreuid (__NR_SYSCALL_BASE+ 70) -#define __NR_setregid (__NR_SYSCALL_BASE+ 71) -#define __NR_sigsuspend (__NR_SYSCALL_BASE+ 72) -#define __NR_sigpending (__NR_SYSCALL_BASE+ 73) -#define __NR_sethostname (__NR_SYSCALL_BASE+ 74) -#define __NR_setrlimit (__NR_SYSCALL_BASE+ 75) -#define __NR_getrlimit (__NR_SYSCALL_BASE+ 76) /* Back compat 2GB limited rlimit */ -#define __NR_getrusage (__NR_SYSCALL_BASE+ 77) -#define __NR_gettimeofday (__NR_SYSCALL_BASE+ 78) -#define __NR_settimeofday (__NR_SYSCALL_BASE+ 79) -#define __NR_getgroups (__NR_SYSCALL_BASE+ 80) -#define __NR_setgroups (__NR_SYSCALL_BASE+ 81) -#define __NR_select (__NR_SYSCALL_BASE+ 82) -#define __NR_symlink (__NR_SYSCALL_BASE+ 83) - -#define __NR_readlink (__NR_SYSCALL_BASE+ 85) -#define __NR_uselib (__NR_SYSCALL_BASE+ 86) -#define __NR_swapon (__NR_SYSCALL_BASE+ 87) -#define __NR_reboot (__NR_SYSCALL_BASE+ 88) -#define __NR_readdir (__NR_SYSCALL_BASE+ 89) -#define __NR_mmap (__NR_SYSCALL_BASE+ 90) -#define __NR_munmap (__NR_SYSCALL_BASE+ 91) -#define __NR_truncate (__NR_SYSCALL_BASE+ 92) -#define __NR_ftruncate (__NR_SYSCALL_BASE+ 93) -#define __NR_fchmod (__NR_SYSCALL_BASE+ 94) -#define __NR_fchown (__NR_SYSCALL_BASE+ 95) -#define __NR_getpriority (__NR_SYSCALL_BASE+ 96) -#define __NR_setpriority (__NR_SYSCALL_BASE+ 97) -#define __NR_profil (__NR_SYSCALL_BASE+ 98) -#define __NR_statfs (__NR_SYSCALL_BASE+ 99) -#define __NR_fstatfs (__NR_SYSCALL_BASE+100) -#define __NR_ioperm (__NR_SYSCALL_BASE+101) -#define __NR_socketcall (__NR_SYSCALL_BASE+102) -#define __NR_syslog (__NR_SYSCALL_BASE+103) -#define __NR_setitimer (__NR_SYSCALL_BASE+104) -#define __NR_getitimer (__NR_SYSCALL_BASE+105) -#define __NR_stat (__NR_SYSCALL_BASE+106) -#define __NR_lstat (__NR_SYSCALL_BASE+107) -#define __NR_fstat (__NR_SYSCALL_BASE+108) - - -#define __NR_vhangup (__NR_SYSCALL_BASE+111) -#define __NR_idle (__NR_SYSCALL_BASE+112) -#define __NR_syscall (__NR_SYSCALL_BASE+113) /* syscall to call a syscall! */ -#define __NR_wait4 (__NR_SYSCALL_BASE+114) -#define __NR_swapoff (__NR_SYSCALL_BASE+115) -#define __NR_sysinfo (__NR_SYSCALL_BASE+116) -#define __NR_ipc (__NR_SYSCALL_BASE+117) -#define __NR_fsync (__NR_SYSCALL_BASE+118) -#define __NR_sigreturn (__NR_SYSCALL_BASE+119) -#define __NR_clone (__NR_SYSCALL_BASE+120) -#define __NR_setdomainname (__NR_SYSCALL_BASE+121) -#define __NR_uname (__NR_SYSCALL_BASE+122) -#define __NR_modify_ldt (__NR_SYSCALL_BASE+123) -#define __NR_adjtimex (__NR_SYSCALL_BASE+124) -#define __NR_mprotect (__NR_SYSCALL_BASE+125) -#define __NR_sigprocmask (__NR_SYSCALL_BASE+126) -#define __NR_create_module (__NR_SYSCALL_BASE+127) -#define __NR_init_module (__NR_SYSCALL_BASE+128) -#define __NR_delete_module (__NR_SYSCALL_BASE+129) -#define __NR_get_kernel_syms (__NR_SYSCALL_BASE+130) -#define __NR_quotactl (__NR_SYSCALL_BASE+131) -#define __NR_getpgid (__NR_SYSCALL_BASE+132) -#define __NR_fchdir (__NR_SYSCALL_BASE+133) -#define __NR_bdflush (__NR_SYSCALL_BASE+134) -#define __NR_sysfs (__NR_SYSCALL_BASE+135) -#define __NR_personality (__NR_SYSCALL_BASE+136) -#define __NR_afs_syscall (__NR_SYSCALL_BASE+137) /* Syscall for Andrew File System */ -#define __NR_setfsuid (__NR_SYSCALL_BASE+138) -#define __NR_setfsgid (__NR_SYSCALL_BASE+139) -#define __NR__llseek (__NR_SYSCALL_BASE+140) -#define __NR_getdents (__NR_SYSCALL_BASE+141) -#define __NR__newselect (__NR_SYSCALL_BASE+142) -#define __NR_flock (__NR_SYSCALL_BASE+143) -#define __NR_msync (__NR_SYSCALL_BASE+144) -#define __NR_readv (__NR_SYSCALL_BASE+145) -#define __NR_writev (__NR_SYSCALL_BASE+146) -#define __NR_getsid (__NR_SYSCALL_BASE+147) -#define __NR_fdatasync (__NR_SYSCALL_BASE+148) -#define __NR__sysctl (__NR_SYSCALL_BASE+149) -#define __NR_mlock (__NR_SYSCALL_BASE+150) -#define __NR_munlock (__NR_SYSCALL_BASE+151) -#define __NR_mlockall (__NR_SYSCALL_BASE+152) -#define __NR_munlockall (__NR_SYSCALL_BASE+153) -#define __NR_sched_setparam (__NR_SYSCALL_BASE+154) -#define __NR_sched_getparam (__NR_SYSCALL_BASE+155) -#define __NR_sched_setscheduler (__NR_SYSCALL_BASE+156) -#define __NR_sched_getscheduler (__NR_SYSCALL_BASE+157) -#define __NR_sched_yield (__NR_SYSCALL_BASE+158) -#define __NR_sched_get_priority_max (__NR_SYSCALL_BASE+159) -#define __NR_sched_get_priority_min (__NR_SYSCALL_BASE+160) -#define __NR_sched_rr_get_interval (__NR_SYSCALL_BASE+161) -#define __NR_nanosleep (__NR_SYSCALL_BASE+162) -#define __NR_mremap (__NR_SYSCALL_BASE+163) -#define __NR_setresuid (__NR_SYSCALL_BASE+164) -#define __NR_getresuid (__NR_SYSCALL_BASE+165) -#define __NR_vm86 (__NR_SYSCALL_BASE+166) -#define __NR_query_module (__NR_SYSCALL_BASE+167) -#define __NR_poll (__NR_SYSCALL_BASE+168) -#define __NR_nfsservctl (__NR_SYSCALL_BASE+169) -#define __NR_setresgid (__NR_SYSCALL_BASE+170) -#define __NR_getresgid (__NR_SYSCALL_BASE+171) -#define __NR_prctl (__NR_SYSCALL_BASE+172) -#define __NR_rt_sigreturn (__NR_SYSCALL_BASE+173) -#define __NR_rt_sigaction (__NR_SYSCALL_BASE+174) -#define __NR_rt_sigprocmask (__NR_SYSCALL_BASE+175) -#define __NR_rt_sigpending (__NR_SYSCALL_BASE+176) -#define __NR_rt_sigtimedwait (__NR_SYSCALL_BASE+177) -#define __NR_rt_sigqueueinfo (__NR_SYSCALL_BASE+178) -#define __NR_rt_sigsuspend (__NR_SYSCALL_BASE+179) -#define __NR_pread (__NR_SYSCALL_BASE+180) -#define __NR_pwrite (__NR_SYSCALL_BASE+181) -#define __NR_chown (__NR_SYSCALL_BASE+182) -#define __NR_getcwd (__NR_SYSCALL_BASE+183) -#define __NR_capget (__NR_SYSCALL_BASE+184) -#define __NR_capset (__NR_SYSCALL_BASE+185) -#define __NR_sigaltstack (__NR_SYSCALL_BASE+186) -#define __NR_sendfile (__NR_SYSCALL_BASE+187) - /* 188 reserved */ - /* 189 reserved */ -#define __NR_vfork (__NR_SYSCALL_BASE+190) -#define __NR_ugetrlimit (__NR_SYSCALL_BASE+191) /* SuS compliant getrlimit */ -#define __NR_mmap2 (__NR_SYSCALL_BASE+192) -#define __NR_truncate64 (__NR_SYSCALL_BASE+193) -#define __NR_ftruncate64 (__NR_SYSCALL_BASE+194) -#define __NR_stat64 (__NR_SYSCALL_BASE+195) -#define __NR_lstat64 (__NR_SYSCALL_BASE+196) -#define __NR_fstat64 (__NR_SYSCALL_BASE+197) -#define __NR_lchown32 (__NR_SYSCALL_BASE+198) -#define __NR_getuid32 (__NR_SYSCALL_BASE+199) -#define __NR_getgid32 (__NR_SYSCALL_BASE+200) -#define __NR_geteuid32 (__NR_SYSCALL_BASE+201) -#define __NR_getegid32 (__NR_SYSCALL_BASE+202) -#define __NR_setreuid32 (__NR_SYSCALL_BASE+203) -#define __NR_setregid32 (__NR_SYSCALL_BASE+204) -#define __NR_getgroups32 (__NR_SYSCALL_BASE+205) -#define __NR_setgroups32 (__NR_SYSCALL_BASE+206) -#define __NR_fchown32 (__NR_SYSCALL_BASE+207) -#define __NR_setresuid32 (__NR_SYSCALL_BASE+208) -#define __NR_getresuid32 (__NR_SYSCALL_BASE+209) -#define __NR_setresgid32 (__NR_SYSCALL_BASE+210) -#define __NR_getresgid32 (__NR_SYSCALL_BASE+211) -#define __NR_chown32 (__NR_SYSCALL_BASE+212) -#define __NR_setuid32 (__NR_SYSCALL_BASE+213) -#define __NR_setgid32 (__NR_SYSCALL_BASE+214) -#define __NR_setfsuid32 (__NR_SYSCALL_BASE+215) -#define __NR_setfsgid32 (__NR_SYSCALL_BASE+216) -#define __NR_getdents64 (__NR_SYSCALL_BASE+217) -#define __NR_pivot_root (__NR_SYSCALL_BASE+218) -#define __NR_mincore (__NR_SYSCALL_BASE+219) -#define __NR_madvise (__NR_SYSCALL_BASE+220) -#define __NR_fcntl64 (__NR_SYSCALL_BASE+221) - /* 222 for tux */ -#define __NR_security (__NR_SYSCALL_BASE+223) -#define __NR_gettid (__NR_SYSCALL_BASE+224) -#define __NR_readahead (__NR_SYSCALL_BASE+225) -#if 0 /* allocated in 2.5 */ -#define __NR_setxattr (__NR_SYSCALL_BASE+226) -#define __NR_lsetxattr (__NR_SYSCALL_BASE+227) -#define __NR_fsetxattr (__NR_SYSCALL_BASE+228) -#define __NR_getxattr (__NR_SYSCALL_BASE+229) -#define __NR_lgetxattr (__NR_SYSCALL_BASE+230) -#define __NR_fgetxattr (__NR_SYSCALL_BASE+231) -#define __NR_listxattr (__NR_SYSCALL_BASE+232) -#define __NR_llistxattr (__NR_SYSCALL_BASE+233) -#define __NR_flistxattr (__NR_SYSCALL_BASE+234) -#define __NR_removexattr (__NR_SYSCALL_BASE+235) -#define __NR_lremovexattr (__NR_SYSCALL_BASE+236) -#define __NR_fremovexattr (__NR_SYSCALL_BASE+237) -#endif -#define __NR_tkill (__NR_SYSCALL_BASE+238) -#if 0 /* allocated in 2.5 */ -#define __NR_sendfile64 (__NR_SYSCALL_BASE+239) -#define __NR_futex (__NR_SYSCALL_BASE+240) -#define __NR_sched_setaffinity (__NR_SYSCALL_BASE+241) -#define __NR_sched_getaffinity (__NR_SYSCALL_BASE+242) -#define __NR_io_setup (__NR_SYSCALL_BASE+243) -#define __NR_io_destroy (__NR_SYSCALL_BASE+244) -#define __NR_io_getevents (__NR_SYSCALL_BASE+245) -#define __NR_io_submit (__NR_SYSCALL_BASE+246) -#define __NR_io_cancel (__NR_SYSCALL_BASE+247) -#define __NR_exit_group (__NR_SYSCALL_BASE+248) -#define __NR_lookup_dcookie (__NR_SYSCALL_BASE+249) -#define __NR_epoll_create (__NR_SYSCALL_BASE+250) -#define __NR_epoll_ctl (__NR_SYSCALL_BASE+251) -#define __NR_epoll_wait (__NR_SYSCALL_BASE+252) -#define __NR_remap_file_pages (__NR_SYSCALL_BASE+253) - /* 254 for set_thread_area */ - /* 255 for get_thread_area */ - /* 256 for set_tid_address */ -#endif - -/* - * The following SWIs are ARM private. - */ -#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000) -#define __ARM_NR_breakpoint (__ARM_NR_BASE+1) -#define __ARM_NR_cacheflush (__ARM_NR_BASE+2) -#define __ARM_NR_usr26 (__ARM_NR_BASE+3) -#define __ARM_NR_usr32 (__ARM_NR_BASE+4) - - -#endif /* SFSYSNR_H */ diff --git a/dest/include/librz/sflib/linux-arm-64/sflib.h b/dest/include/librz/sflib/linux-arm-64/sflib.h deleted file mode 100644 index 20bee69d3ea..00000000000 --- a/dest/include/librz/sflib/linux-arm-64/sflib.h +++ /dev/null @@ -1,272 +0,0 @@ -/* - * sflib.h --- SFLib syscall library for Linux/ARM - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - - -/* - * Automatically generated by gensflib.py - * Mon Mar 21 13:23:31 2022 - */ - -#ifndef SFLIB_H -#define SFLIB_H - - -#include "sfsysnr.h" -#include "sfsyscall.h" -#include "../common/sftypes.h" - -static inline _sfsyscall1(int, exit, int, status) -static inline _sfsyscall0( pid_t, fork ) -static inline _sfsyscall3( ssize_t, read, int, fd, void *, buf, size_t, count ) -static inline _sfsyscall3( ssize_t, write, int, fd, const void *, buf, size_t, count ) -static inline _sfsyscall3( int, open, const char *, pathname, int, flags, mode_t, mode ) -static inline _sfsyscall1( int, close, int, fd ) -static inline _sfsyscall2( int, creat, const char *, pathname, mode_t, mode ) -static inline _sfsyscall2( int, link, const char *, oldpath, const char *, newpath ) -static inline _sfsyscall1( int, unlink, const char *, pathname ) -static inline _sfsyscall3(int, execve, char *, s, char **, argv, char **,envp) -static inline _sfsyscall1( int, chdir, const char *, path ) -static inline _sfsyscall1( time_t, time, time_t *, t ) -static inline _sfsyscall3( int, mknod, const char *, pathname, mode_t, mode, dev_t, dev ) -static inline _sfsyscall2( int, chmod, const char *, path, mode_t, mode ) -static inline _sfsyscall3( int, lchown, const char *, path, uid_t, owner, gid_t, group ) -// break -static inline _sfsyscall3( off_t, lseek, int, fildes, off_t, offset, int, whence ) -static inline _sfsyscall0( pid_t, getpid ) -// mount -static inline _sfsyscall1( int, umount, const char *, dir ) -// setuid -static inline _sfsyscall0( uid_t, getuid ) -static inline _sfsyscall1( int, stime, time_t *, t ) -static inline _sfsyscall4(long, ptrace, int, request, pid_t, pid, void *,addr, void *,data) -static inline _sfsyscall1( unsigned int, alarm, unsigned int, seconds ) -static inline _sfsyscall0( int, pause ) -static inline _sfsyscall2( int, utime, const char *, filename, struct utimbuf *, buf ) -// stty -// gtty -static inline _sfsyscall2( int, access, const char *, pathname, int, mode ) -static inline _sfsyscall1( int, nice, int, inc ) -// ftime -static inline _sfsyscall0( int, sync ) -static inline _sfsyscall2( int, kill, pid_t, pid, int, sig ) -static inline _sfsyscall2( int, rename, const char *, oldpath, const char *, newpath ) -static inline _sfsyscall2( int, mkdir, const char *, pathname, mode_t, mode ) -static inline _sfsyscall1( int, rmdir, const char *, pathname ) -static inline _sfsyscall1( int, dup, int, oldfd ) -static inline _sfsyscall1( int, pipe, unsigned long *, filedes) -static inline _sfsyscall1( clock_t, times, struct tms *, buf ) -// prof -static inline _sfsyscall1( int, brk, void *, end_data_segment ) -// setgid -static inline _sfsyscall0( gid_t, getgid ) -static inline _sfsyscall2( sighandler_t, signal, int, signum, sighandler_t, handler ) -static inline _sfsyscall0( uid_t, geteuid ) -static inline _sfsyscall0( gid_t, getegid ) -static inline _sfsyscall1( int, acct, const char *, filename ) -// umount2 -// lock -static inline _sfsyscall4(int, ioctl, int,d, int,request, char *,argp, int,len) -static inline _sfsyscall3( int, fcntl, int, fd, int, cmd, long, arg ) -// mpx -static inline _sfsyscall2( int, setpgid, pid_t, pid, pid_t, pgid ) -// ulimit -static inline _sfsyscall1( mode_t, umask, mode_t, mask ) -static inline _sfsyscall1( int, chroot, const char *, path ) -static inline _sfsyscall2( int, ustat, dev_t, dev, struct ustat *, ubuf ) -static inline _sfsyscall2( int, dup2, int, oldfd, int, newfd ) -static inline _sfsyscall0( pid_t, getppid ) -static inline _sfsyscall0( pid_t, getpgrp ) -static inline _sfsyscall0( pid_t, setsid ) -// sigaction -// sgetmask -// ssetmask -static inline _sfsyscall2( int, setreuid, uid_t, ruid, uid_t, euid ) -static inline _sfsyscall2( int, setregid, gid_t, rgid, gid_t, egid ) -static inline _sfsyscall1( int, sigsuspend, const sigset_t *, mask ) -static inline _sfsyscall1( int, sigpending, sigset_t *, set ) -static inline _sfsyscall2( int, sethostname, const char *, name, size_t, len ) -// setrlimit -// getrlimit -// getrusage -static inline _sfsyscall2( int, gettimeofday, struct timeval *, tv, struct timezone *, tz ) -// settimeofday -// getgroups -static inline _sfsyscall2( int, setgroups, size_t, size, const gid_t *, list ) -static inline _sfsyscall5( int, select, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout) -static inline _sfsyscall2( int, symlink, const char *, oldpath, const char *, newpath ) -static inline _sfsyscall3( int, readlink, const char *, path, char *, buf, size_t, bufsiz ) -static inline _sfsyscall1( int, uselib, const char *, library ) -static inline _sfsyscall2( int, swapon, const char *, path, int, swapflags ) -// reboot -static inline _sfsyscall3( int, readdir, unsigned int, fd, struct dirent *, dirp, unsigned int, count ) -static inline _sfsyscall6(void *,mmap, void *,start, size_t,length, int,prot , int,flags, int,fd, off_t,offset) -static inline _sfsyscall2( int, munmap, void *, start, size_t, length ) -static inline _sfsyscall2( int, truncate, const char *, path, off_t, length ) -static inline _sfsyscall2( int, ftruncate, int, fd, off_t, length ) -static inline _sfsyscall2( int, fchmod, int, fildes, mode_t, mode ) -static inline _sfsyscall3( int, fchown, int, fd, uid_t, owner, gid_t, group ) -static inline _sfsyscall2( int, getpriority, int, which, int, who ) -static inline _sfsyscall3( int, setpriority, int, which, int, who, int, prio ) -// profil -static inline _sfsyscall2( int, statfs, const char *, path, struct statfs *, buf ) -static inline _sfsyscall2( int, fstatfs, int, fd, struct statfs *, buf ) -static inline _sfsyscall3( int, ioperm, unsigned long, from, unsigned long, num, int, turn_on ) -static inline _sfsyscall2( int, socketcall, int, call, unsigned long *,args); -static inline _sfsyscall3( int, syslog, int, type, char *, bufp, int, len ) -// setitimer -// getitimer -static inline _sfsyscall2( int, stat, const char *, file_name, struct stat *, buf ) -static inline _sfsyscall2( int, lstat, const char *, file_name, struct stat *, buf ) -static inline _sfsyscall2( int, fstat, int, filedes, struct stat *, buf ) -static inline _sfsyscall0( int, vhangup ) -static inline _sfsyscall0( int, idle ) -// syscall -static inline _sfsyscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, struct rusage *, rusage) -static inline _sfsyscall1( int, swapoff, const char *, path ) -static inline _sfsyscall1( int, sysinfo, struct sysinfo *, info ) -// ipc -static inline _sfsyscall1( int, fsync, int, fd ) -static inline _sfsyscall1( int, sigreturn, unsigned long, __unused ) -// clone -static inline _sfsyscall2( int, setdomainname, const char *, name, size_t, len ) -static inline _sfsyscall1( int, uname, struct utsname *, buf ) -// modify_ldt -// adjtimex -static inline _sfsyscall3( int, mprotect, const void *, addr, size_t, len, int, prot ) -// sigprocmask -static inline _sfsyscall2( caddr_t, create_module, const char *, name, size_t, size ) -static inline _sfsyscall2( int, init_module, const char *, name, struct module *, image ) -static inline _sfsyscall1( int, delete_module, const char *, name ) -static inline _sfsyscall1( int, get_kernel_syms, struct kernel_sym *, table ) -// quotactl -static inline _sfsyscall1( pid_t, getpgid, pid_t, pid ) -// fchdir -// bdflush -static inline _sfsyscall3( int, sysfs, int, option, unsigned int, fs_index, char *, buf ) -static inline _sfsyscall1( int, personality, unsigned long, persona ) -// afs_syscall -static inline _sfsyscall1( int, setfsuid, uid_t, fsuid ) -static inline _sfsyscall1( int, setfsgid, uid_t, fsgid ) -static inline _sfsyscall3( int, getdents, unsigned int, fd, struct dirent *, dirp, unsigned int, count ) -// flock -static inline _sfsyscall3( int, msync, const void *, start, size_t, length, int, flags ) -static inline _sfsyscall3( int, readv, int, fd, const struct iovec *, vector, int, count ) -static inline _sfsyscall3( int, writev, int, fd, const struct iovec *, vector, int, count ) -static inline _sfsyscall1( pid_t, getsid, pid_t, pid ) -static inline _sfsyscall1( int, fdatasync, int, fd ) -static inline _sfsyscall2( int, mlock, const void *, addr, size_t, len ) -static inline _sfsyscall2( int, munlock, const void *, addr, size_t, len ) -static inline _sfsyscall1( int, mlockall, int, flags ) -static inline _sfsyscall0( int, munlockall ) -static inline _sfsyscall2( int, sched_setparam, pid_t, pid, const struct sched_param *, p ) -static inline _sfsyscall2( int, sched_getparam, pid_t, pid, struct sched_param *, p ) -// sched_setscheduler -static inline _sfsyscall1( int, sched_getscheduler, pid_t, pid ) -static inline _sfsyscall0( int, sched_yield ) -static inline _sfsyscall1( int, sched_get_priority_max, int, policy ) -static inline _sfsyscall1( int, sched_get_priority_min, int, policy ) -static inline _sfsyscall2( int, sched_rr_get_interval, pid_t, pid, struct timespec *, tp ) -static inline _sfsyscall2( int, nanosleep, const struct timespec *, req, struct timespec *, rem ) -// mremap -static inline _sfsyscall3( int, setresuid, uid_t, ruid, uid_t, euid, uid_t, suid ) -static inline _sfsyscall3( int, getresuid, uid_t *, ruid, uid_t *, euid, uid_t *, suid ) -static inline _sfsyscall2( int, vm86, unsigned long, fn, struct vm86plus_struct *, v86 ) -// query_module -static inline _sfsyscall3( int, poll, struct pollfd *, ufds, unsigned int, nfds, int, timeout ) -// nfsservctl -// setresgid -// getresgid -// prctl -// rt_sigreturn -// rt_sigaction -// rt_sigprocmask -// rt_sigpending -// rt_sigtimedwait -// rt_sigqueueinfo -// rt_sigsuspend -static inline _sfsyscall4( ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset ) -// pwrite -static inline _sfsyscall3( int, chown, const char *, path, uid_t, owner, gid_t, group ) -// getcwd -static inline _sfsyscall2( int, capget, cap_user_header_t, header, cap_user_data_t, data ) -//static inline _sfsyscall2( int, capset, cap_user_header_t, header, const cap_user_data_t, data ) -// sigaltstack -// sendfile -static inline _sfsyscall0( pid_t, vfork ) -// ugetrlimit -// mmap2 -// truncate64 -// ftruncate64 -// stat64 -// lstat64 -// fstat64 -// lchown32 -// getuid32 -// getgid32 -// geteuid32 -// getegid32 -// setreuid32 -// setregid32 -// getgroups32 -// setgroups32 -// fchown32 -// setresuid32 -// getresuid32 -// setresgid32 -// getresgid32 -// chown32 -// setuid32 -// setgid32 -// setfsuid32 -// setfsgid32 -// getdents64 -// pivot_root -// mincore -// madvise -// fcntl64 -// security -// gettid -// readahead -// setxattr -// lsetxattr -// fsetxattr -// getxattr -// lgetxattr -// fgetxattr -// listxattr -// llistxattr -// flistxattr -// removexattr -// lremovexattr -// fremovexattr -// tkill -// sendfile64 -// futex -// sched_setaffinity -// sched_getaffinity -// io_setup -// io_destroy -// io_getevents -// io_submit -// io_cancel -// exit_group -// lookup_dcookie -// epoll_create -// epoll_ctl -// epoll_wait -// remap_file_pages - -#endif /* SFLIB_H */ diff --git a/dest/include/librz/sflib/linux-arm-64/sfsyscall.h b/dest/include/librz/sflib/linux-arm-64/sfsyscall.h deleted file mode 100644 index 34b43f1c2c2..00000000000 --- a/dest/include/librz/sflib/linux-arm-64/sfsyscall.h +++ /dev/null @@ -1,174 +0,0 @@ -/* sfsyscall.h --- SFLib syscall macros for Linux/arm64 - pancake */ - -#ifndef SFSYSCALL_H -#define SFSYSCALL_H - -/* $Id$ */ - -#ifdef SF_USE_ERRNO - -static int errno = 1234; - -#define __sfsyscall_return(type, res) \ - do { \ - if ((unsigned long)(res) >= (unsigned long)(-125)) { \ - errno = -(res); \ - res = -1; \ - } \ - return (type)(res); \ - } while (0) - -#else /* SF_USE_ERRNO */ - -#define __sfsyscall_return(type, res) \ - do { \ - return (type)(res); \ - } while (0) - -#endif /* SF_USE_ERRNO */ - -/* syscall macros */ - -#define _sfsyscall0(type, name) \ - type name(void) { \ - long __res; \ - __asm__ volatile("###> " #name " <###\n\t" \ - "svc 0" \ - : "=a"(__res) \ - : "0"(__NR_##name) \ - : "memory", "cc"); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall1(type, name, type1, arg1) \ - type name(type1 arg1) { \ - long __res; \ - register type1 x1 asm("x0"); \ - x1 = arg1; \ - asm volatile("###> " #name "(%2) <###\n\t" \ - "mov x8, %0\n\t" \ - "svc 0" \ - : "=g"(__res) \ - : "0"(__NR_##name), "r"(x1)); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall2(type, name, type1, arg1, type2, arg2) \ - type name(type1 arg1, type2 arg2) { \ - long __res; \ - register type1 x1 asm("x1"); \ - register type2 x2 asm("x2"); \ - x1 = arg1; \ - x2 = arg2; \ - __asm__ volatile("###> " #name "(%2, %3) <###\n\t" \ - "svc 0" \ - : "=g"(__res) \ - : "0"(__NR_##name), \ - "r"(x1), \ - "r"(x2)); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ - type name(type1 arg1, type2 arg2, type3 arg3) { \ - long __res; \ - register type1 x0 asm("x0"); \ - register type2 x1 asm("x1"); \ - register type3 x2 asm("x2"); \ - x0 = arg1; \ - x1 = arg2; \ - x2 = arg3; \ - __asm__ __volatile__("###> " #name "(%2, %3, %4) <###\n\t" \ - "mov x8, %1\n\t" \ - "svc 0" \ - : "=g"(__res) \ - : "0"(__NR_##name), \ - "r"(x0), \ - "r"(x1), \ - "r"(x2) \ - : "memory", "cc"); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall4(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ - long __res; \ - register type1 x1 asm("x1"); \ - ; \ - register type2 x2 asm("x2"); \ - register type3 x3 asm("x3"); \ - register type4 x4 asm("x4"); \ - x1 = arg1; \ - x2 = arg2; \ - x3 = arg3; \ - x4 = arg4; \ - asm volatile("###> " #name "(%2, %3, %4, %5) <###\n\t" \ - "svc 0" \ - : "=g"(__res) \ - : "0"(__NR_##name), \ - "r"(x1), \ - "r"(x2), \ - "r"(x3), \ - "r"(x4) \ - : "memory", "cc"); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall5(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) \ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ - type5 arg5) { \ - long __res; \ - register type1 x1 asm("x1"); \ - register type2 x2 asm("x2"); \ - register type3 x3 asm("x3"); \ - register type4 x4 asm("x4"); \ - register type5 x5 asm("x5"); \ - x1 = arg1; \ - x2 = arg2; \ - x3 = arg3; \ - x4 = arg4; \ - x5 = arg5; \ - asm volatile("###> " #name "(%2, %3, %4, %5, %6) <###\n\t" \ - "svc 0" \ - : "=g"(__res) \ - : "0"(__NR_##name), \ - "r"(x1), \ - "r"(x2), \ - "r"(x3), \ - "r"(x4), \ - "r"(x5) \ - : "memory", "cc"); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall6(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ - type5 arg5, type6 arg6) { \ - long __res; \ - register type1 x1 asm("x1"); \ - register type2 x2 asm("x2"); \ - register type3 x3 asm("x3"); \ - register type4 x4 asm("x4"); \ - register type5 x5 asm("x5"); \ - register type6 x6 asm("x6"); \ - x1 = arg1; \ - x2 = arg2; \ - x3 = arg3; \ - x4 = arg4; \ - x5 = arg5; \ - x6 = arg6; \ - asm volatile("###> " #name "(%2, %3, %4, %5, %6, %7) <###\n\t" \ - "svc 0" \ - : "=a"(__res) \ - : "0"(__NR_##name), \ - "r"(x1), \ - "r"(x2), \ - "r"(x3), \ - "r"(x4), \ - "r"(x5), \ - "r"(x6) \ - : "memory", "cc"); \ - __sfsyscall_return(type, __res); \ - } - -#endif /* SFSYSCALL_H */ diff --git a/dest/include/librz/sflib/linux-arm-64/sfsysnr.h b/dest/include/librz/sflib/linux-arm-64/sfsysnr.h deleted file mode 100644 index c1967a280e9..00000000000 --- a/dest/include/librz/sflib/linux-arm-64/sfsysnr.h +++ /dev/null @@ -1,316 +0,0 @@ -/* - * sfsysnr.h --- SFLib syscall numbers for Linux/ARM - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - - -/* - * Automatically generated by gensflib.py - * Mon Mar 21 13:23:31 2022 - */ - -#ifndef SFSYSNR_H -#define SFSYSNR_H - - -/* $Id$ */ - -/* - * From linux/include/asm-arm/unistd.h - * Copyright (C) 2001-2002 Russell King - */ - - -#if defined(__thumb__) -#define __NR_SYSCALL_BASE 0 -#else -#define __NR_SYSCALL_BASE 0x900000 -#endif - -/* - * This file contains the system call numbers. - */ - -#define __NR_exit (__NR_SYSCALL_BASE+ 1) -#define __NR_fork (__NR_SYSCALL_BASE+ 2) -#define __NR_read (__NR_SYSCALL_BASE+ 3) -#define __NR_write (__NR_SYSCALL_BASE+ 4) -#define __NR_open (__NR_SYSCALL_BASE+ 5) -#define __NR_close (__NR_SYSCALL_BASE+ 6) -/*#define __NR_waitpid (__NR_SYSCALL_BASE+ 7) debian bug #201989 ARM doesnt have this syscall and its define breaks glibc*/ -#define __NR_creat (__NR_SYSCALL_BASE+ 8) -#define __NR_link (__NR_SYSCALL_BASE+ 9) -#define __NR_unlink (__NR_SYSCALL_BASE+ 10) -#define __NR_execve (__NR_SYSCALL_BASE+ 11) -#define __NR_chdir (__NR_SYSCALL_BASE+ 12) -#define __NR_time (__NR_SYSCALL_BASE+ 13) -#define __NR_mknod (__NR_SYSCALL_BASE+ 14) -#define __NR_chmod (__NR_SYSCALL_BASE+ 15) -#define __NR_lchown (__NR_SYSCALL_BASE+ 16) -#define __NR_break (__NR_SYSCALL_BASE+ 17) - -#define __NR_lseek (__NR_SYSCALL_BASE+ 19) -#define __NR_getpid (__NR_SYSCALL_BASE+ 20) -#define __NR_mount (__NR_SYSCALL_BASE+ 21) -#define __NR_umount (__NR_SYSCALL_BASE+ 22) -#define __NR_setuid (__NR_SYSCALL_BASE+ 23) -#define __NR_getuid (__NR_SYSCALL_BASE+ 24) -#define __NR_stime (__NR_SYSCALL_BASE+ 25) -#define __NR_ptrace (__NR_SYSCALL_BASE+ 26) -#define __NR_alarm (__NR_SYSCALL_BASE+ 27) - -#define __NR_pause (__NR_SYSCALL_BASE+ 29) -#define __NR_utime (__NR_SYSCALL_BASE+ 30) -#define __NR_stty (__NR_SYSCALL_BASE+ 31) -#define __NR_gtty (__NR_SYSCALL_BASE+ 32) -#define __NR_access (__NR_SYSCALL_BASE+ 33) -#define __NR_nice (__NR_SYSCALL_BASE+ 34) -#define __NR_ftime (__NR_SYSCALL_BASE+ 35) -#define __NR_sync (__NR_SYSCALL_BASE+ 36) -#define __NR_kill (__NR_SYSCALL_BASE+ 37) -#define __NR_rename (__NR_SYSCALL_BASE+ 38) -#define __NR_mkdir (__NR_SYSCALL_BASE+ 39) -#define __NR_rmdir (__NR_SYSCALL_BASE+ 40) -#define __NR_dup (__NR_SYSCALL_BASE+ 41) -#define __NR_pipe (__NR_SYSCALL_BASE+ 42) -#define __NR_times (__NR_SYSCALL_BASE+ 43) -#define __NR_prof (__NR_SYSCALL_BASE+ 44) -#define __NR_brk (__NR_SYSCALL_BASE+ 45) -#define __NR_setgid (__NR_SYSCALL_BASE+ 46) -#define __NR_getgid (__NR_SYSCALL_BASE+ 47) -#define __NR_signal (__NR_SYSCALL_BASE+ 48) -#define __NR_geteuid (__NR_SYSCALL_BASE+ 49) -#define __NR_getegid (__NR_SYSCALL_BASE+ 50) -#define __NR_acct (__NR_SYSCALL_BASE+ 51) -#define __NR_umount2 (__NR_SYSCALL_BASE+ 52) -#define __NR_lock (__NR_SYSCALL_BASE+ 53) -#define __NR_ioctl (__NR_SYSCALL_BASE+ 54) -#define __NR_fcntl (__NR_SYSCALL_BASE+ 55) -#define __NR_mpx (__NR_SYSCALL_BASE+ 56) -#define __NR_setpgid (__NR_SYSCALL_BASE+ 57) -#define __NR_ulimit (__NR_SYSCALL_BASE+ 58) - -#define __NR_umask (__NR_SYSCALL_BASE+ 60) -#define __NR_chroot (__NR_SYSCALL_BASE+ 61) -#define __NR_ustat (__NR_SYSCALL_BASE+ 62) -#define __NR_dup2 (__NR_SYSCALL_BASE+ 63) -#define __NR_getppid (__NR_SYSCALL_BASE+ 64) -#define __NR_getpgrp (__NR_SYSCALL_BASE+ 65) -#define __NR_setsid (__NR_SYSCALL_BASE+ 66) -#define __NR_sigaction (__NR_SYSCALL_BASE+ 67) -#define __NR_sgetmask (__NR_SYSCALL_BASE+ 68) -#define __NR_ssetmask (__NR_SYSCALL_BASE+ 69) -#define __NR_setreuid (__NR_SYSCALL_BASE+ 70) -#define __NR_setregid (__NR_SYSCALL_BASE+ 71) -#define __NR_sigsuspend (__NR_SYSCALL_BASE+ 72) -#define __NR_sigpending (__NR_SYSCALL_BASE+ 73) -#define __NR_sethostname (__NR_SYSCALL_BASE+ 74) -#define __NR_setrlimit (__NR_SYSCALL_BASE+ 75) -#define __NR_getrlimit (__NR_SYSCALL_BASE+ 76) /* Back compat 2GB limited rlimit */ -#define __NR_getrusage (__NR_SYSCALL_BASE+ 77) -#define __NR_gettimeofday (__NR_SYSCALL_BASE+ 78) -#define __NR_settimeofday (__NR_SYSCALL_BASE+ 79) -#define __NR_getgroups (__NR_SYSCALL_BASE+ 80) -#define __NR_setgroups (__NR_SYSCALL_BASE+ 81) -#define __NR_select (__NR_SYSCALL_BASE+ 82) -#define __NR_symlink (__NR_SYSCALL_BASE+ 83) - -#define __NR_readlink (__NR_SYSCALL_BASE+ 85) -#define __NR_uselib (__NR_SYSCALL_BASE+ 86) -#define __NR_swapon (__NR_SYSCALL_BASE+ 87) -#define __NR_reboot (__NR_SYSCALL_BASE+ 88) -#define __NR_readdir (__NR_SYSCALL_BASE+ 89) -#define __NR_mmap (__NR_SYSCALL_BASE+ 90) -#define __NR_munmap (__NR_SYSCALL_BASE+ 91) -#define __NR_truncate (__NR_SYSCALL_BASE+ 92) -#define __NR_ftruncate (__NR_SYSCALL_BASE+ 93) -#define __NR_fchmod (__NR_SYSCALL_BASE+ 94) -#define __NR_fchown (__NR_SYSCALL_BASE+ 95) -#define __NR_getpriority (__NR_SYSCALL_BASE+ 96) -#define __NR_setpriority (__NR_SYSCALL_BASE+ 97) -#define __NR_profil (__NR_SYSCALL_BASE+ 98) -#define __NR_statfs (__NR_SYSCALL_BASE+ 99) -#define __NR_fstatfs (__NR_SYSCALL_BASE+100) -#define __NR_ioperm (__NR_SYSCALL_BASE+101) -#define __NR_socketcall (__NR_SYSCALL_BASE+102) -#define __NR_syslog (__NR_SYSCALL_BASE+103) -#define __NR_setitimer (__NR_SYSCALL_BASE+104) -#define __NR_getitimer (__NR_SYSCALL_BASE+105) -#define __NR_stat (__NR_SYSCALL_BASE+106) -#define __NR_lstat (__NR_SYSCALL_BASE+107) -#define __NR_fstat (__NR_SYSCALL_BASE+108) - - -#define __NR_vhangup (__NR_SYSCALL_BASE+111) -#define __NR_idle (__NR_SYSCALL_BASE+112) -#define __NR_syscall (__NR_SYSCALL_BASE+113) /* syscall to call a syscall! */ -#define __NR_wait4 (__NR_SYSCALL_BASE+114) -#define __NR_swapoff (__NR_SYSCALL_BASE+115) -#define __NR_sysinfo (__NR_SYSCALL_BASE+116) -#define __NR_ipc (__NR_SYSCALL_BASE+117) -#define __NR_fsync (__NR_SYSCALL_BASE+118) -#define __NR_sigreturn (__NR_SYSCALL_BASE+119) -#define __NR_clone (__NR_SYSCALL_BASE+120) -#define __NR_setdomainname (__NR_SYSCALL_BASE+121) -#define __NR_uname (__NR_SYSCALL_BASE+122) -#define __NR_modify_ldt (__NR_SYSCALL_BASE+123) -#define __NR_adjtimex (__NR_SYSCALL_BASE+124) -#define __NR_mprotect (__NR_SYSCALL_BASE+125) -#define __NR_sigprocmask (__NR_SYSCALL_BASE+126) -#define __NR_create_module (__NR_SYSCALL_BASE+127) -#define __NR_init_module (__NR_SYSCALL_BASE+128) -#define __NR_delete_module (__NR_SYSCALL_BASE+129) -#define __NR_get_kernel_syms (__NR_SYSCALL_BASE+130) -#define __NR_quotactl (__NR_SYSCALL_BASE+131) -#define __NR_getpgid (__NR_SYSCALL_BASE+132) -#define __NR_fchdir (__NR_SYSCALL_BASE+133) -#define __NR_bdflush (__NR_SYSCALL_BASE+134) -#define __NR_sysfs (__NR_SYSCALL_BASE+135) -#define __NR_personality (__NR_SYSCALL_BASE+136) -#define __NR_afs_syscall (__NR_SYSCALL_BASE+137) /* Syscall for Andrew File System */ -#define __NR_setfsuid (__NR_SYSCALL_BASE+138) -#define __NR_setfsgid (__NR_SYSCALL_BASE+139) -#define __NR__llseek (__NR_SYSCALL_BASE+140) -#define __NR_getdents (__NR_SYSCALL_BASE+141) -#define __NR__newselect (__NR_SYSCALL_BASE+142) -#define __NR_flock (__NR_SYSCALL_BASE+143) -#define __NR_msync (__NR_SYSCALL_BASE+144) -#define __NR_readv (__NR_SYSCALL_BASE+145) -#define __NR_writev (__NR_SYSCALL_BASE+146) -#define __NR_getsid (__NR_SYSCALL_BASE+147) -#define __NR_fdatasync (__NR_SYSCALL_BASE+148) -#define __NR__sysctl (__NR_SYSCALL_BASE+149) -#define __NR_mlock (__NR_SYSCALL_BASE+150) -#define __NR_munlock (__NR_SYSCALL_BASE+151) -#define __NR_mlockall (__NR_SYSCALL_BASE+152) -#define __NR_munlockall (__NR_SYSCALL_BASE+153) -#define __NR_sched_setparam (__NR_SYSCALL_BASE+154) -#define __NR_sched_getparam (__NR_SYSCALL_BASE+155) -#define __NR_sched_setscheduler (__NR_SYSCALL_BASE+156) -#define __NR_sched_getscheduler (__NR_SYSCALL_BASE+157) -#define __NR_sched_yield (__NR_SYSCALL_BASE+158) -#define __NR_sched_get_priority_max (__NR_SYSCALL_BASE+159) -#define __NR_sched_get_priority_min (__NR_SYSCALL_BASE+160) -#define __NR_sched_rr_get_interval (__NR_SYSCALL_BASE+161) -#define __NR_nanosleep (__NR_SYSCALL_BASE+162) -#define __NR_mremap (__NR_SYSCALL_BASE+163) -#define __NR_setresuid (__NR_SYSCALL_BASE+164) -#define __NR_getresuid (__NR_SYSCALL_BASE+165) -#define __NR_vm86 (__NR_SYSCALL_BASE+166) -#define __NR_query_module (__NR_SYSCALL_BASE+167) -#define __NR_poll (__NR_SYSCALL_BASE+168) -#define __NR_nfsservctl (__NR_SYSCALL_BASE+169) -#define __NR_setresgid (__NR_SYSCALL_BASE+170) -#define __NR_getresgid (__NR_SYSCALL_BASE+171) -#define __NR_prctl (__NR_SYSCALL_BASE+172) -#define __NR_rt_sigreturn (__NR_SYSCALL_BASE+173) -#define __NR_rt_sigaction (__NR_SYSCALL_BASE+174) -#define __NR_rt_sigprocmask (__NR_SYSCALL_BASE+175) -#define __NR_rt_sigpending (__NR_SYSCALL_BASE+176) -#define __NR_rt_sigtimedwait (__NR_SYSCALL_BASE+177) -#define __NR_rt_sigqueueinfo (__NR_SYSCALL_BASE+178) -#define __NR_rt_sigsuspend (__NR_SYSCALL_BASE+179) -#define __NR_pread (__NR_SYSCALL_BASE+180) -#define __NR_pwrite (__NR_SYSCALL_BASE+181) -#define __NR_chown (__NR_SYSCALL_BASE+182) -#define __NR_getcwd (__NR_SYSCALL_BASE+183) -#define __NR_capget (__NR_SYSCALL_BASE+184) -#define __NR_capset (__NR_SYSCALL_BASE+185) -#define __NR_sigaltstack (__NR_SYSCALL_BASE+186) -#define __NR_sendfile (__NR_SYSCALL_BASE+187) - /* 188 reserved */ - /* 189 reserved */ -#define __NR_vfork (__NR_SYSCALL_BASE+190) -#define __NR_ugetrlimit (__NR_SYSCALL_BASE+191) /* SuS compliant getrlimit */ -#define __NR_mmap2 (__NR_SYSCALL_BASE+192) -#define __NR_truncate64 (__NR_SYSCALL_BASE+193) -#define __NR_ftruncate64 (__NR_SYSCALL_BASE+194) -#define __NR_stat64 (__NR_SYSCALL_BASE+195) -#define __NR_lstat64 (__NR_SYSCALL_BASE+196) -#define __NR_fstat64 (__NR_SYSCALL_BASE+197) -#define __NR_lchown32 (__NR_SYSCALL_BASE+198) -#define __NR_getuid32 (__NR_SYSCALL_BASE+199) -#define __NR_getgid32 (__NR_SYSCALL_BASE+200) -#define __NR_geteuid32 (__NR_SYSCALL_BASE+201) -#define __NR_getegid32 (__NR_SYSCALL_BASE+202) -#define __NR_setreuid32 (__NR_SYSCALL_BASE+203) -#define __NR_setregid32 (__NR_SYSCALL_BASE+204) -#define __NR_getgroups32 (__NR_SYSCALL_BASE+205) -#define __NR_setgroups32 (__NR_SYSCALL_BASE+206) -#define __NR_fchown32 (__NR_SYSCALL_BASE+207) -#define __NR_setresuid32 (__NR_SYSCALL_BASE+208) -#define __NR_getresuid32 (__NR_SYSCALL_BASE+209) -#define __NR_setresgid32 (__NR_SYSCALL_BASE+210) -#define __NR_getresgid32 (__NR_SYSCALL_BASE+211) -#define __NR_chown32 (__NR_SYSCALL_BASE+212) -#define __NR_setuid32 (__NR_SYSCALL_BASE+213) -#define __NR_setgid32 (__NR_SYSCALL_BASE+214) -#define __NR_setfsuid32 (__NR_SYSCALL_BASE+215) -#define __NR_setfsgid32 (__NR_SYSCALL_BASE+216) -#define __NR_getdents64 (__NR_SYSCALL_BASE+217) -#define __NR_pivot_root (__NR_SYSCALL_BASE+218) -#define __NR_mincore (__NR_SYSCALL_BASE+219) -#define __NR_madvise (__NR_SYSCALL_BASE+220) -#define __NR_fcntl64 (__NR_SYSCALL_BASE+221) - /* 222 for tux */ -#define __NR_security (__NR_SYSCALL_BASE+223) -#define __NR_gettid (__NR_SYSCALL_BASE+224) -#define __NR_readahead (__NR_SYSCALL_BASE+225) -#if 0 /* allocated in 2.5 */ -#define __NR_setxattr (__NR_SYSCALL_BASE+226) -#define __NR_lsetxattr (__NR_SYSCALL_BASE+227) -#define __NR_fsetxattr (__NR_SYSCALL_BASE+228) -#define __NR_getxattr (__NR_SYSCALL_BASE+229) -#define __NR_lgetxattr (__NR_SYSCALL_BASE+230) -#define __NR_fgetxattr (__NR_SYSCALL_BASE+231) -#define __NR_listxattr (__NR_SYSCALL_BASE+232) -#define __NR_llistxattr (__NR_SYSCALL_BASE+233) -#define __NR_flistxattr (__NR_SYSCALL_BASE+234) -#define __NR_removexattr (__NR_SYSCALL_BASE+235) -#define __NR_lremovexattr (__NR_SYSCALL_BASE+236) -#define __NR_fremovexattr (__NR_SYSCALL_BASE+237) -#endif -#define __NR_tkill (__NR_SYSCALL_BASE+238) -#if 0 /* allocated in 2.5 */ -#define __NR_sendfile64 (__NR_SYSCALL_BASE+239) -#define __NR_futex (__NR_SYSCALL_BASE+240) -#define __NR_sched_setaffinity (__NR_SYSCALL_BASE+241) -#define __NR_sched_getaffinity (__NR_SYSCALL_BASE+242) -#define __NR_io_setup (__NR_SYSCALL_BASE+243) -#define __NR_io_destroy (__NR_SYSCALL_BASE+244) -#define __NR_io_getevents (__NR_SYSCALL_BASE+245) -#define __NR_io_submit (__NR_SYSCALL_BASE+246) -#define __NR_io_cancel (__NR_SYSCALL_BASE+247) -#define __NR_exit_group (__NR_SYSCALL_BASE+248) -#define __NR_lookup_dcookie (__NR_SYSCALL_BASE+249) -#define __NR_epoll_create (__NR_SYSCALL_BASE+250) -#define __NR_epoll_ctl (__NR_SYSCALL_BASE+251) -#define __NR_epoll_wait (__NR_SYSCALL_BASE+252) -#define __NR_remap_file_pages (__NR_SYSCALL_BASE+253) - /* 254 for set_thread_area */ - /* 255 for get_thread_area */ - /* 256 for set_tid_address */ -#endif - -/* - * The following SWIs are ARM private. - */ -#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000) -#define __ARM_NR_breakpoint (__ARM_NR_BASE+1) -#define __ARM_NR_cacheflush (__ARM_NR_BASE+2) -#define __ARM_NR_usr26 (__ARM_NR_BASE+3) -#define __ARM_NR_usr32 (__ARM_NR_BASE+4) - - -#endif /* SFSYSNR_H */ diff --git a/dest/include/librz/sflib/linux-x86-32/sflib.h b/dest/include/librz/sflib/linux-x86-32/sflib.h deleted file mode 100644 index a757995493d..00000000000 --- a/dest/include/librz/sflib/linux-x86-32/sflib.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - * sflib.h --- SFLib syscall library for Linux/i386 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - - -/* - * Automatically generated by gensflib.py - * Tue Apr 25 19:39:23 2023 - */ - -#ifndef SFLIB_H -#define SFLIB_H - - -#include "sfsysnr.h" -#include "sfsyscall.h" -#include "../common/sftypes.h" - - -static inline _sfsyscall1(int, exit, int, status) -static inline _sfsyscall0( pid_t, fork ) -static inline _sfsyscall3( ssize_t, read, int, fd, void *, buf, size_t, count ) -static inline _sfsyscall3( ssize_t, write, int, fd, const void *, buf, size_t, count ) -static inline _sfsyscall3( int, open, const char *, pathname, int, flags, mode_t, mode ) -static inline _sfsyscall1( int, close, int, fd ) -static inline _sfsyscall3( pid_t, waitpid, pid_t, pid, int *, status, int, options ) -static inline _sfsyscall2( int, creat, const char *, pathname, mode_t, mode ) -static inline _sfsyscall2( int, link, const char *, oldpath, const char *, newpath ) -static inline _sfsyscall1( int, unlink, const char *, pathname ) -static inline _sfsyscall3(int, execve, char *, s, char **, argv, char **,envp) -static inline _sfsyscall1( int, chdir, const char *, path ) -static inline _sfsyscall1( time_t, time, time_t *, t ) -static inline _sfsyscall3( int, mknod, const char *, pathname, mode_t, mode, dev_t, dev ) -static inline _sfsyscall2( int, chmod, const char *, path, mode_t, mode ) -static inline _sfsyscall3( int, lchown, const char *, path, uid_t, owner, gid_t, group ) -// break -// oldstat -static inline _sfsyscall3( off_t, lseek, int, fildes, off_t, offset, int, whence ) -static inline _sfsyscall0( pid_t, getpid ) -// mount -static inline _sfsyscall1( int, umount, const char *, dir ) -// setuid -static inline _sfsyscall0( uid_t, getuid ) -static inline _sfsyscall1( int, stime, time_t *, t ) -static inline _sfsyscall4(long, ptrace, int, request, pid_t, pid, void *,addr, void *,data) -static inline _sfsyscall1( unsigned int, alarm, unsigned int, seconds ) -// oldfstat -static inline _sfsyscall0( int, pause ) -static inline _sfsyscall2( int, utime, const char *, filename, struct utimbuf *, buf ) -// stty -// gtty -static inline _sfsyscall2( int, access, const char *, pathname, int, mode ) -static inline _sfsyscall1( int, nice, int, inc ) -// ftime -static inline _sfsyscall0( int, sync ) -static inline _sfsyscall2( int, kill, pid_t, pid, int, sig ) -static inline _sfsyscall2( int, rename, const char *, oldpath, const char *, newpath ) -static inline _sfsyscall2( int, mkdir, const char *, pathname, mode_t, mode ) -static inline _sfsyscall1( int, rmdir, const char *, pathname ) -static inline _sfsyscall1( int, dup, int, oldfd ) -static inline _sfsyscall1( int, pipe, unsigned long *, filedes) -static inline _sfsyscall1( clock_t, times, struct tms *, buf ) -// prof -static inline _sfsyscall1( int, brk, void *, end_data_segment ) -// setgid -static inline _sfsyscall0( gid_t, getgid ) -static inline _sfsyscall2( sighandler_t, signal, int, signum, sighandler_t, handler ) -static inline _sfsyscall0( uid_t, geteuid ) -static inline _sfsyscall0( gid_t, getegid ) -static inline _sfsyscall1( int, acct, const char *, filename ) -// umount2 -// lock -static inline _sfsyscall4(int, ioctl, int,d, int,request, char *,argp, int,len) -static inline _sfsyscall3( int, fcntl, int, fd, int, cmd, long, arg ) -// mpx -static inline _sfsyscall2( int, setpgid, pid_t, pid, pid_t, pgid ) -// ulimit -// oldolduname -static inline _sfsyscall1( mode_t, umask, mode_t, mask ) -static inline _sfsyscall1( int, chroot, const char *, path ) -static inline _sfsyscall2( int, ustat, dev_t, dev, struct ustat *, ubuf ) -static inline _sfsyscall2( int, dup2, int, oldfd, int, newfd ) -static inline _sfsyscall0( pid_t, getppid ) -static inline _sfsyscall0( pid_t, getpgrp ) -static inline _sfsyscall0( pid_t, setsid ) -// sigaction -// sgetmask -// ssetmask -static inline _sfsyscall2( int, setreuid, uid_t, ruid, uid_t, euid ) -static inline _sfsyscall2( int, setregid, gid_t, rgid, gid_t, egid ) -static inline _sfsyscall1( int, sigsuspend, const sigset_t *, mask ) -static inline _sfsyscall1( int, sigpending, sigset_t *, set ) -static inline _sfsyscall2( int, sethostname, const char *, name, size_t, len ) -// setrlimit -// oldgetrlimit -// getrusage -static inline _sfsyscall2( int, gettimeofday, struct timeval *, tv, struct timezone *, tz ) -// settimeofday -// getgroups -static inline _sfsyscall2( int, setgroups, size_t, size, const gid_t *, list ) -static inline _sfsyscall5( int, select, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout) -static inline _sfsyscall2( int, symlink, const char *, oldpath, const char *, newpath ) -// oldlstat -static inline _sfsyscall3( int, readlink, const char *, path, char *, buf, size_t, bufsiz ) -static inline _sfsyscall1( int, uselib, const char *, library ) -static inline _sfsyscall2( int, swapon, const char *, path, int, swapflags ) -// reboot -static inline _sfsyscall3( int, readdir, unsigned int, fd, struct dirent *, dirp, unsigned int, count ) -// oldmmap -static inline _sfsyscall2( int, munmap, void *, start, size_t, length ) -static inline _sfsyscall2( int, truncate, const char *, path, off_t, length ) -static inline _sfsyscall2( int, ftruncate, int, fd, off_t, length ) -static inline _sfsyscall2( int, fchmod, int, fildes, mode_t, mode ) -static inline _sfsyscall3( int, fchown, int, fd, uid_t, owner, gid_t, group ) -static inline _sfsyscall2( int, getpriority, int, which, int, who ) -static inline _sfsyscall3( int, setpriority, int, which, int, who, int, prio ) -// profil -static inline _sfsyscall2( int, statfs, const char *, path, struct statfs *, buf ) -static inline _sfsyscall2( int, fstatfs, int, fd, struct statfs *, buf ) -static inline _sfsyscall3( int, ioperm, unsigned long, from, unsigned long, num, int, turn_on ) -static inline _sfsyscall2( int, socketcall, int, call, unsigned long *,args); -static inline _sfsyscall3( int, syslog, int, type, char *, bufp, int, len ) -// setitimer -// getitimer -static inline _sfsyscall2( int, stat, const char *, file_name, struct stat *, buf ) -static inline _sfsyscall2( int, lstat, const char *, file_name, struct stat *, buf ) -static inline _sfsyscall2( int, fstat, int, filedes, struct stat *, buf ) -// olduname -static inline _sfsyscall1( int, iopl, int, level ) -static inline _sfsyscall0( int, vhangup ) -static inline _sfsyscall0( int, idle ) -// vm86old -static inline _sfsyscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, struct rusage *, rusage) -static inline _sfsyscall1( int, swapoff, const char *, path ) -static inline _sfsyscall1( int, sysinfo, struct sysinfo *, info ) -// ipc -static inline _sfsyscall1( int, fsync, int, fd ) -static inline _sfsyscall1( int, sigreturn, unsigned long, __unused ) -// clone -static inline _sfsyscall2( int, setdomainname, const char *, name, size_t, len ) -static inline _sfsyscall1( int, uname, struct utsname *, buf ) -// modify_ldt -// adjtimex -static inline _sfsyscall3( int, mprotect, const void *, addr, size_t, len, int, prot ) -// sigprocmask -static inline _sfsyscall2( caddr_t, create_module, const char *, name, size_t, size ) -static inline _sfsyscall2( int, init_module, const char *, name, struct module *, image ) -static inline _sfsyscall1( int, delete_module, const char *, name ) -static inline _sfsyscall1( int, get_kernel_syms, struct kernel_sym *, table ) -// quotactl -static inline _sfsyscall1( pid_t, getpgid, pid_t, pid ) -// fchdir -// bdflush -static inline _sfsyscall3( int, sysfs, int, option, unsigned int, fs_index, char *, buf ) -static inline _sfsyscall1( int, personality, unsigned long, persona ) -// afs_syscall -static inline _sfsyscall1( int, setfsuid, uid_t, fsuid ) -static inline _sfsyscall1( int, setfsgid, uid_t, fsgid ) -static inline _sfsyscall3( int, getdents, unsigned int, fd, struct dirent *, dirp, unsigned int, count ) -// flock -static inline _sfsyscall3( int, msync, const void *, start, size_t, length, int, flags ) -static inline _sfsyscall3( int, readv, int, fd, const struct iovec *, vector, int, count ) -static inline _sfsyscall3( int, writev, int, fd, const struct iovec *, vector, int, count ) -static inline _sfsyscall1( pid_t, getsid, pid_t, pid ) -static inline _sfsyscall1( int, fdatasync, int, fd ) -static inline _sfsyscall2( int, mlock, const void *, addr, size_t, len ) -static inline _sfsyscall2( int, munlock, const void *, addr, size_t, len ) -static inline _sfsyscall1( int, mlockall, int, flags ) -static inline _sfsyscall0( int, munlockall ) -static inline _sfsyscall2( int, sched_setparam, pid_t, pid, const struct sched_param *, p ) -static inline _sfsyscall2( int, sched_getparam, pid_t, pid, struct sched_param *, p ) -// sched_setscheduler -static inline _sfsyscall1( int, sched_getscheduler, pid_t, pid ) -static inline _sfsyscall0( int, sched_yield ) -static inline _sfsyscall1( int, sched_get_priority_max, int, policy ) -static inline _sfsyscall1( int, sched_get_priority_min, int, policy ) -static inline _sfsyscall2( int, sched_rr_get_interval, pid_t, pid, struct timespec *, tp ) -static inline _sfsyscall2( int, nanosleep, const struct timespec *, req, struct timespec *, rem ) -// mremap -static inline _sfsyscall3( int, setresuid, uid_t, ruid, uid_t, euid, uid_t, suid ) -static inline _sfsyscall3( int, getresuid, uid_t *, ruid, uid_t *, euid, uid_t *, suid ) -static inline _sfsyscall2( int, vm86, unsigned long, fn, struct vm86plus_struct *, v86 ) -// query_module -static inline _sfsyscall3( int, poll, struct pollfd *, ufds, unsigned int, nfds, int, timeout ) -// nfsservctl -// setresgid -// getresgid -// prctl -// rt_sigreturn -// rt_sigaction -// rt_sigprocmask -// rt_sigpending -// rt_sigtimedwait -// rt_sigqueueinfo -// rt_sigsuspend -static inline _sfsyscall4( ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset ) -// pwrite -static inline _sfsyscall3( int, chown, const char *, path, uid_t, owner, gid_t, group ) -// getcwd -static inline _sfsyscall2( int, capget, cap_user_header_t, header, cap_user_data_t, data ) -//static inline _sfsyscall2( int, capset, cap_user_header_t, header, const cap_user_data_t, data ) -// sigaltstack -// sendfile -// getpmsg -// putpmsg -static inline _sfsyscall0( pid_t, vfork ) -// getrlimit -static inline _sfsyscall6(void *,mmap, void *,start, size_t,length, int,prot , int,flags, int,fd, off_t,offset) - - -#include "../common/sfsocketcall.h" - - -#endif /* SFLIB_H */ diff --git a/dest/include/librz/sflib/linux-x86-32/sfsyscall.h b/dest/include/librz/sflib/linux-x86-32/sfsyscall.h deleted file mode 100644 index d1f6126afd8..00000000000 --- a/dest/include/librz/sflib/linux-x86-32/sfsyscall.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * sfsyscall.h --- SFLib syscall macros for Linux/i386 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - - -/* - * Automatically generated by gensflib.py - * Tue Apr 25 19:39:23 2023 - */ - -#ifndef SFSYSCALL_H -#define SFSYSCALL_H - - -/* $Id$ */ - -#ifdef SF_USE_ERRNO - -static int errno=1234; - -#define __sfsyscall_return(type, res) \ -do { \ - if ((unsigned long)(res) >= (unsigned long)(-125)) { \ - errno = -(res); \ - res = -1; \ - } \ - return (type) (res); \ -} while (0) - -#else /* SF_USE_ERRNO */ - -#define __sfsyscall_return(type, res) \ -do { \ - return (type) (res); \ -} while (0) - -#endif /* SF_USE_ERRNO */ - - -/* syscall macros */ - -#define _sfsyscall0(type,name) \ -type name(void) \ -{ \ -long __res; \ -__asm__ volatile ("###> " #name "() <###\n\t" \ - "int $0x80" \ - : "=a" (__res) \ - : "0" (__NR_##name)); \ -__sfsyscall_return(type,__res); \ -} - -#define _sfsyscall1(type,name,type1,arg1) \ -type name(type1 arg1) \ -{ \ -long __res; \ -__asm__ volatile ("###> " #name "(%2) <###\n\t" \ - "pushl %%ebx\n\t" \ - "mov %2,%%ebx\n\t" \ - "int $0x80\n\t" \ - "popl %%ebx" \ - : "=a" (__res) \ - : "0" (__NR_##name),"r" ((long)(arg1))); \ -__sfsyscall_return(type,__res); \ -} - -#define _sfsyscall2(type,name,type1,arg1,type2,arg2) \ -type name(type1 arg1,type2 arg2) \ -{ \ -long __res; \ -__asm__ volatile ("###> " #name "(%2, %3) <###\n\t" \ - "pushl %%ebx\n\t" \ - "mov %2,%%ebx\n\t" \ - "int $0x80\n\t" \ - "popl %%ebx" \ - : "=a" (__res) \ - : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)) ); \ -__sfsyscall_return(type,__res); \ -} - -#define _sfsyscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ -type name(type1 arg1,type2 arg2,type3 arg3) \ -{ \ -long __res; \ -__asm__ volatile ("###> " #name "(%2, %3, %4) <###\n\t" \ - "pushl %%ebx\n\t" \ - "mov %2,%%ebx\n\t" \ - "int $0x80\n\t" \ - "popl %%ebx" \ - : "=a" (__res) \ - : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \ - "d" ((long)(arg3)) ); \ -__sfsyscall_return(type,__res); \ -} - -#define _sfsyscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ -type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ -{ \ -long __res; \ -__asm__ volatile ("###> " #name "(%2, %3, %4, %5) <###\n\t" \ - "pushl %%ebx\n\t" \ - "mov %2,%%ebx\n\t" \ - "int $0x80\n\t" \ - "popl %%ebx" \ - : "=a" (__res) \ - : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \ - "d" ((long)(arg3)),"S" ((long)(arg4)) ); \ -__sfsyscall_return(type,__res); \ -} - -#define _sfsyscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ - type5,arg5) \ -type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ -{ \ -long __res; \ -__asm__ volatile ("###> " #name "(%2, %3, %4, %5, %6) <###\n\t" \ - "pushl %%ebx\n\t" \ - "mov %2,%%ebx\n\t" \ - "int $0x80\n\t" \ - "popl %%ebx" \ - : "=a" (__res) \ - : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \ - "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \ -__sfsyscall_return(type,__res); \ -} - -#define _sfsyscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ - type5,arg5,type6,arg6) \ -type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \ -{ \ -long __res; \ -__asm__ volatile ("##> " #name "(%2, %3, %4, %5, %6, %7) <###\n\t" \ - "pushl %%ebx\n\t" \ - "pushl %%ebp\n\t" \ - "movl %2,%%ebx\n\t" \ - "movl %7,%%ebp\n\t" \ - "int $0x80\n\t" \ - "popl %%ebp\n\t" \ - "popl %%ebx" \ - : "=a" (__res) \ - : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \ - "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)), \ - "r" ((long)(arg6))); \ -__sfsyscall_return(type,__res); \ -} - - -#define _sfoldsyscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ - type5,arg5,type6,arg6) \ -type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \ -{ \ -long __res; \ -__asm__ volatile ("pushl %%ebx\n\t" \ - "pushl %7\n\t" \ - "pushl %6\n\t" \ - "pushl %5\n\t" \ - "pushl %4\n\t" \ - "pushl %3\n\t" \ - "pushl %2\n\t" \ - "movl %%esp, %%ebx\n\t" \ - "int $0x80\n\t" \ - "add $0x18,%%esp\n\t" \ - "popl %%ebx" \ - : "=a" (__res) \ - : "0" (__NR_##name),"r" ((long)(arg1)),"r" ((long)(arg2)), \ - "r" ((long)(arg3)),"r" ((long)(arg4)),"r" ((long)(arg5)), \ - "r" ((long)(arg6))); \ -__sfsyscall_return(type,__res); \ -} - - -#endif /* SFSYSCALL_H */ diff --git a/dest/include/librz/sflib/linux-x86-32/sfsysnr.h b/dest/include/librz/sflib/linux-x86-32/sfsysnr.h deleted file mode 100644 index f0ae56dc794..00000000000 --- a/dest/include/librz/sflib/linux-x86-32/sfsysnr.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - * sfsysnr.h --- SFLib syscall numbers for Linux/i386 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - - -/* - * Automatically generated by gensflib.py - * Tue Apr 25 19:39:23 2023 - */ - -#ifndef SFSYSNR_H -#define SFSYSNR_H - - -/* $Id$ */ - -#define __NR_exit 1 -#define __NR_fork 2 -#define __NR_read 3 -#define __NR_write 4 -#define __NR_open 5 -#define __NR_close 6 -#define __NR_waitpid 7 -#define __NR_creat 8 -#define __NR_link 9 -#define __NR_unlink 10 -#define __NR_execve 11 -#define __NR_chdir 12 -#define __NR_time 13 -#define __NR_mknod 14 -#define __NR_chmod 15 -#define __NR_lchown 16 -#define __NR_break 17 -#define __NR_oldstat 18 -#define __NR_lseek 19 -#define __NR_getpid 20 -#define __NR_mount 21 -#define __NR_umount 22 -#define __NR_setuid 23 -#define __NR_getuid 24 -#define __NR_stime 25 -#define __NR_ptrace 26 -#define __NR_alarm 27 -#define __NR_oldfstat 28 -#define __NR_pause 29 -#define __NR_utime 30 -#define __NR_stty 31 -#define __NR_gtty 32 -#define __NR_access 33 -#define __NR_nice 34 -#define __NR_ftime 35 -#define __NR_sync 36 -#define __NR_kill 37 -#define __NR_rename 38 -#define __NR_mkdir 39 -#define __NR_rmdir 40 -#define __NR_dup 41 -#define __NR_pipe 42 -#define __NR_times 43 -#define __NR_prof 44 -#define __NR_brk 45 -#define __NR_setgid 46 -#define __NR_getgid 47 -#define __NR_signal 48 -#define __NR_geteuid 49 -#define __NR_getegid 50 -#define __NR_acct 51 -#define __NR_umount2 52 -#define __NR_lock 53 -#define __NR_ioctl 54 -#define __NR_fcntl 55 -#define __NR_mpx 56 -#define __NR_setpgid 57 -#define __NR_ulimit 58 -#define __NR_oldolduname 59 -#define __NR_umask 60 -#define __NR_chroot 61 -#define __NR_ustat 62 -#define __NR_dup2 63 -#define __NR_getppid 64 -#define __NR_getpgrp 65 -#define __NR_setsid 66 -#define __NR_sigaction 67 -#define __NR_sgetmask 68 -#define __NR_ssetmask 69 -#define __NR_setreuid 70 -#define __NR_setregid 71 -#define __NR_sigsuspend 72 -#define __NR_sigpending 73 -#define __NR_sethostname 74 -#define __NR_setrlimit 75 -#define __NR_oldgetrlimit 76 -#define __NR_getrusage 77 -#define __NR_gettimeofday 78 -#define __NR_settimeofday 79 -#define __NR_getgroups 80 -#define __NR_setgroups 81 -#define __NR_select 142 -#define __NR_symlink 83 -#define __NR_oldlstat 84 -#define __NR_readlink 85 -#define __NR_uselib 86 -#define __NR_swapon 87 -#define __NR_reboot 88 -#define __NR_readdir 89 -#define __NR_oldmmap 90 -#define __NR_munmap 91 -#define __NR_truncate 92 -#define __NR_ftruncate 93 -#define __NR_fchmod 94 -#define __NR_fchown 95 -#define __NR_getpriority 96 -#define __NR_setpriority 97 -#define __NR_profil 98 -#define __NR_statfs 99 -#define __NR_fstatfs 100 -#define __NR_ioperm 101 -#define __NR_socketcall 102 -#define __NR_syslog 103 -#define __NR_setitimer 104 -#define __NR_getitimer 105 -#define __NR_stat 106 -#define __NR_lstat 107 -#define __NR_fstat 108 -#define __NR_olduname 109 -#define __NR_iopl 110 -#define __NR_vhangup 111 -#define __NR_idle 112 -#define __NR_vm86old 113 -#define __NR_wait4 114 -#define __NR_swapoff 115 -#define __NR_sysinfo 116 -#define __NR_ipc 117 -#define __NR_fsync 118 -#define __NR_sigreturn 119 -#define __NR_clone 120 -#define __NR_setdomainname 121 -#define __NR_uname 122 -#define __NR_modify_ldt 123 -#define __NR_adjtimex 124 -#define __NR_mprotect 125 -#define __NR_sigprocmask 126 -#define __NR_create_module 127 -#define __NR_init_module 128 -#define __NR_delete_module 129 -#define __NR_get_kernel_syms 130 -#define __NR_quotactl 131 -#define __NR_getpgid 132 -#define __NR_fchdir 133 -#define __NR_bdflush 134 -#define __NR_sysfs 135 -#define __NR_personality 136 -#define __NR_afs_syscall 137 /* Syscall for Andrew File System */ -#define __NR_setfsuid 138 -#define __NR_setfsgid 139 -#define __NR__llseek 140 -#define __NR_getdents 141 -#define __NR__newselect 142 -#define __NR_flock 143 -#define __NR_msync 144 -#define __NR_readv 145 -#define __NR_writev 146 -#define __NR_getsid 147 -#define __NR_fdatasync 148 -#define __NR__sysctl 149 -#define __NR_mlock 150 -#define __NR_munlock 151 -#define __NR_mlockall 152 -#define __NR_munlockall 153 -#define __NR_sched_setparam 154 -#define __NR_sched_getparam 155 -#define __NR_sched_setscheduler 156 -#define __NR_sched_getscheduler 157 -#define __NR_sched_yield 158 -#define __NR_sched_get_priority_max 159 -#define __NR_sched_get_priority_min 160 -#define __NR_sched_rr_get_interval 161 -#define __NR_nanosleep 162 -#define __NR_mremap 163 -#define __NR_setresuid 164 -#define __NR_getresuid 165 -#define __NR_vm86 166 -#define __NR_query_module 167 -#define __NR_poll 168 -#define __NR_nfsservctl 169 -#define __NR_setresgid 170 -#define __NR_getresgid 171 -#define __NR_prctl 172 -#define __NR_rt_sigreturn 173 -#define __NR_rt_sigaction 174 -#define __NR_rt_sigprocmask 175 -#define __NR_rt_sigpending 176 -#define __NR_rt_sigtimedwait 177 -#define __NR_rt_sigqueueinfo 178 -#define __NR_rt_sigsuspend 179 -#define __NR_pread 180 -#define __NR_pwrite 181 -#define __NR_chown 182 -#define __NR_getcwd 183 -#define __NR_capget 184 -#define __NR_capset 185 -#define __NR_sigaltstack 186 -#define __NR_sendfile 187 -#define __NR_getpmsg 188 /* some people actually want streams */ -#define __NR_putpmsg 189 /* some people actually want streams */ -#define __NR_vfork 190 -#define __NR_getrlimit 191 -#define __NR_mmap 192 - - -#endif /* SFSYSNR_H */ diff --git a/dest/include/librz/sflib/linux-x86-64/sflib.h b/dest/include/librz/sflib/linux-x86-64/sflib.h deleted file mode 100644 index 0a8649dc277..00000000000 --- a/dest/include/librz/sflib/linux-x86-64/sflib.h +++ /dev/null @@ -1,334 +0,0 @@ -/* - * sflib.h --- SFLib syscall library for Linux/amd64 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - - -/* - * Automatically generated by gensflib.py - * Mon Mar 21 13:23:31 2022 - */ - -#ifndef SFLIB_H -#define SFLIB_H - - -#include "sfsysnr.h" -#include "sfsyscall.h" -#include "../common/sftypes.h" - - -static inline _sfsyscall3( ssize_t, read, int, fd, void *, buf, size_t, count ) -static inline _sfsyscall3( ssize_t, write, int, fd, const void *, buf, size_t, count ) -static inline _sfsyscall3( int, open, const char *, pathname, int, flags, mode_t, mode ) -static inline _sfsyscall1( int, close, int, fd ) -static inline _sfsyscall2( int, stat, const char *, file_name, struct stat *, buf ) -static inline _sfsyscall2( int, fstat, int, filedes, struct stat *, buf ) -static inline _sfsyscall2( int, lstat, const char *, file_name, struct stat *, buf ) -static inline _sfsyscall3( int, poll, struct pollfd *, ufds, unsigned int, nfds, int, timeout ) -static inline _sfsyscall3( off_t, lseek, int, fildes, off_t, offset, int, whence ) -static inline _sfsyscall6(void *,mmap, void *,start, size_t,length, int,prot , int,flags, int,fd, off_t,offset) -static inline _sfsyscall3( int, mprotect, const void *, addr, size_t, len, int, prot ) -static inline _sfsyscall2( int, munmap, void *, start, size_t, length ) -static inline _sfsyscall1( int, brk, void *, end_data_segment ) -// rt_sigaction -// rt_sigprocmask -// rt_sigreturn -static inline _sfsyscall4(int, ioctl, int,d, int,request, char *,argp, int,len) -// pread64 -// pwrite64 -static inline _sfsyscall3( int, readv, int, fd, const struct iovec *, vector, int, count ) -static inline _sfsyscall3( int, writev, int, fd, const struct iovec *, vector, int, count ) -static inline _sfsyscall2( int, access, const char *, pathname, int, mode ) -static inline _sfsyscall1( int, pipe, unsigned long *, filedes) -static inline _sfsyscall5( int, select, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout) -static inline _sfsyscall0( int, sched_yield ) -// mremap -static inline _sfsyscall3( int, msync, const void *, start, size_t, length, int, flags ) -// mincore -// madvise -static inline _sfsyscall3(int, shmget, long, key, int, size, int, flags ) -static inline _sfsyscall3(void *, shmat, int, shmid, const void *, shmaddr, int, shmflg ) -// shmctl -static inline _sfsyscall1( int, dup, int, oldfd ) -static inline _sfsyscall2( int, dup2, int, oldfd, int, newfd ) -static inline _sfsyscall0( int, pause ) -static inline _sfsyscall2( int, nanosleep, const struct timespec *, req, struct timespec *, rem ) -// getitimer -static inline _sfsyscall1( unsigned int, alarm, unsigned int, seconds ) -// setitimer -static inline _sfsyscall0( pid_t, getpid ) -// sendfile -static inline _sfsyscall3(int, socket, int,domain, int,type, int,protocol) -static inline _sfsyscall3(int,connect, int,sockfd, const struct sockaddr *,serv_addr, socklen_t,addrlen) -static inline _sfsyscall3(int, accept, int,s, struct sockaddr *,addr, socklen_t,addrlen); -static inline _sfsyscall6(ssize_t, sendto, int, s, const void *, msg, size_t, len, int, flags, const struct sockaddr *, to, socklen_t, tolen) -static inline _sfsyscall6(ssize_t, recvfrom, int, s, void * , buf, size_t, len, int, flags, struct sockaddr * , from, socklen_t * , fromlen) -// sendmsg -// recvmsg -// shutdown -static inline _sfsyscall3(int, bind, int,sockfd, struct sockaddr *,my_addr, socklen_t,addrlen) -static inline _sfsyscall2(int,listen,int,s, int,backlog) -// getsockname -// getpeername -// socketpair -static inline _sfsyscall5(int, setsockopt, int, s, int, level, int, optname, void *, optval, socklen_t, optlen) -// getsockopt -// clone -static inline _sfsyscall0( pid_t, fork ) -static inline _sfsyscall0( pid_t, vfork ) -static inline _sfsyscall3(int, execve, char *, s, char **, argv, char **,envp) -static inline _sfsyscall1(int, exit, int, status) -static inline _sfsyscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, struct rusage *, rusage) -static inline _sfsyscall2( int, kill, pid_t, pid, int, sig ) -static inline _sfsyscall1( int, uname, struct utsname *, buf ) -static inline _sfsyscall3(int, semget, long, key, int, nsems, int, semflg) -static inline _sfsyscall3(int, semop, int, semid, struct sembuf *, sops, unsigned, nsops) -// semctl -// shmdt -// msgget -// msgsnd -// msgrcv -// msgctl -static inline _sfsyscall3( int, fcntl, int, fd, int, cmd, long, arg ) -// flock -static inline _sfsyscall1( int, fsync, int, fd ) -static inline _sfsyscall1( int, fdatasync, int, fd ) -static inline _sfsyscall2( int, truncate, const char *, path, off_t, length ) -static inline _sfsyscall2( int, ftruncate, int, fd, off_t, length ) -static inline _sfsyscall3( int, getdents, unsigned int, fd, struct dirent *, dirp, unsigned int, count ) -// getcwd -static inline _sfsyscall1( int, chdir, const char *, path ) -// fchdir -static inline _sfsyscall2( int, rename, const char *, oldpath, const char *, newpath ) -static inline _sfsyscall2( int, mkdir, const char *, pathname, mode_t, mode ) -static inline _sfsyscall1( int, rmdir, const char *, pathname ) -static inline _sfsyscall2( int, creat, const char *, pathname, mode_t, mode ) -static inline _sfsyscall2( int, link, const char *, oldpath, const char *, newpath ) -static inline _sfsyscall1( int, unlink, const char *, pathname ) -static inline _sfsyscall2( int, symlink, const char *, oldpath, const char *, newpath ) -static inline _sfsyscall3( int, readlink, const char *, path, char *, buf, size_t, bufsiz ) -static inline _sfsyscall2( int, chmod, const char *, path, mode_t, mode ) -static inline _sfsyscall2( int, fchmod, int, fildes, mode_t, mode ) -static inline _sfsyscall3( int, chown, const char *, path, uid_t, owner, gid_t, group ) -static inline _sfsyscall3( int, fchown, int, fd, uid_t, owner, gid_t, group ) -static inline _sfsyscall3( int, lchown, const char *, path, uid_t, owner, gid_t, group ) -static inline _sfsyscall1( mode_t, umask, mode_t, mask ) -static inline _sfsyscall2( int, gettimeofday, struct timeval *, tv, struct timezone *, tz ) -// getrlimit -// getrusage -static inline _sfsyscall1( int, sysinfo, struct sysinfo *, info ) -static inline _sfsyscall1( clock_t, times, struct tms *, buf ) -static inline _sfsyscall4(long, ptrace, int, request, pid_t, pid, void *,addr, void *,data) -static inline _sfsyscall0( uid_t, getuid ) -static inline _sfsyscall3( int, syslog, int, type, char *, bufp, int, len ) -static inline _sfsyscall0( gid_t, getgid ) -// setuid -// setgid -static inline _sfsyscall0( uid_t, geteuid ) -static inline _sfsyscall0( gid_t, getegid ) -static inline _sfsyscall2( int, setpgid, pid_t, pid, pid_t, pgid ) -static inline _sfsyscall0( pid_t, getppid ) -static inline _sfsyscall0( pid_t, getpgrp ) -static inline _sfsyscall0( pid_t, setsid ) -static inline _sfsyscall2( int, setreuid, uid_t, ruid, uid_t, euid ) -static inline _sfsyscall2( int, setregid, gid_t, rgid, gid_t, egid ) -// getgroups -static inline _sfsyscall2( int, setgroups, size_t, size, const gid_t *, list ) -static inline _sfsyscall3( int, setresuid, uid_t, ruid, uid_t, euid, uid_t, suid ) -static inline _sfsyscall3( int, getresuid, uid_t *, ruid, uid_t *, euid, uid_t *, suid ) -// setresgid -// getresgid -static inline _sfsyscall1( pid_t, getpgid, pid_t, pid ) -static inline _sfsyscall1( int, setfsuid, uid_t, fsuid ) -static inline _sfsyscall1( int, setfsgid, uid_t, fsgid ) -static inline _sfsyscall1( pid_t, getsid, pid_t, pid ) -static inline _sfsyscall2( int, capget, cap_user_header_t, header, cap_user_data_t, data ) -//static inline _sfsyscall2( int, capset, cap_user_header_t, header, const cap_user_data_t, data ) -// rt_sigpending -// rt_sigtimedwait -// rt_sigqueueinfo -// rt_sigsuspend -// sigaltstack -static inline _sfsyscall2( int, utime, const char *, filename, struct utimbuf *, buf ) -static inline _sfsyscall3( int, mknod, const char *, pathname, mode_t, mode, dev_t, dev ) -static inline _sfsyscall1( int, uselib, const char *, library ) -static inline _sfsyscall1( int, personality, unsigned long, persona ) -static inline _sfsyscall2( int, ustat, dev_t, dev, struct ustat *, ubuf ) -static inline _sfsyscall2( int, statfs, const char *, path, struct statfs *, buf ) -static inline _sfsyscall2( int, fstatfs, int, fd, struct statfs *, buf ) -static inline _sfsyscall3( int, sysfs, int, option, unsigned int, fs_index, char *, buf ) -static inline _sfsyscall2( int, getpriority, int, which, int, who ) -static inline _sfsyscall3( int, setpriority, int, which, int, who, int, prio ) -static inline _sfsyscall2( int, sched_setparam, pid_t, pid, const struct sched_param *, p ) -static inline _sfsyscall2( int, sched_getparam, pid_t, pid, struct sched_param *, p ) -// sched_setscheduler -static inline _sfsyscall1( int, sched_getscheduler, pid_t, pid ) -static inline _sfsyscall1( int, sched_get_priority_max, int, policy ) -static inline _sfsyscall1( int, sched_get_priority_min, int, policy ) -static inline _sfsyscall2( int, sched_rr_get_interval, pid_t, pid, struct timespec *, tp ) -static inline _sfsyscall2( int, mlock, const void *, addr, size_t, len ) -static inline _sfsyscall2( int, munlock, const void *, addr, size_t, len ) -static inline _sfsyscall1( int, mlockall, int, flags ) -static inline _sfsyscall0( int, munlockall ) -static inline _sfsyscall0( int, vhangup ) -// modify_ldt -// pivot_root -// prctl -// arch_prctl -// adjtimex -// setrlimit -static inline _sfsyscall1( int, chroot, const char *, path ) -static inline _sfsyscall0( int, sync ) -static inline _sfsyscall1( int, acct, const char *, filename ) -// settimeofday -// mount -// umount2 -static inline _sfsyscall2( int, swapon, const char *, path, int, swapflags ) -static inline _sfsyscall1( int, swapoff, const char *, path ) -// reboot -static inline _sfsyscall2( int, sethostname, const char *, name, size_t, len ) -static inline _sfsyscall2( int, setdomainname, const char *, name, size_t, len ) -static inline _sfsyscall1( int, iopl, int, level ) -static inline _sfsyscall3( int, ioperm, unsigned long, from, unsigned long, num, int, turn_on ) -static inline _sfsyscall2( caddr_t, create_module, const char *, name, size_t, size ) -static inline _sfsyscall2( int, init_module, const char *, name, struct module *, image ) -static inline _sfsyscall1( int, delete_module, const char *, name ) -static inline _sfsyscall1( int, get_kernel_syms, struct kernel_sym *, table ) -// query_module -// quotactl -// nfsservctl -// getpmsg -// putpmsg -// afs_syscall -// tuxcall -// security -// gettid -// readahead -// setxattr -// lsetxattr -// fsetxattr -// getxattr -// lgetxattr -// fgetxattr -// listxattr -// llistxattr -// flistxattr -// removexattr -// lremovexattr -// fremovexattr -// tkill -static inline _sfsyscall1( time_t, time, time_t *, t ) -// futex -// sched_setaffinity -// sched_getaffinity -// set_thread_area -// io_setup -// io_destroy -// io_getevents -// io_submit -// io_cancel -// get_thread_area -// lookup_dcookie -// epoll_create -// epoll_ctl_old -// epoll_wait_old -// remap_file_pages -// getdents64 -// set_tid_address -// restart_syscall -// semtimedop -// fadvise64 -// timer_create -// timer_settime -// timer_gettime -// timer_getoverrun -// timer_delete -// clock_settime -// clock_gettime -// clock_getres -// clock_nanosleep -// exit_group -// epoll_wait -// epoll_ctl -// tgkill -// utimes -// vserver -// mbind -// set_mempolicy -// get_mempolicy -// mq_open -// mq_unlink -// mq_timedsend -// mq_timedreceive -// mq_notify -// mq_getsetattr -// kexec_load -// waitid -// add_key -// request_key -// keyctl -// ioprio_set -// ioprio_get -// inotify_init -// inotify_add_watch -// inotify_rm_watch -// migrate_pages -// openat -// mkdirat -// mknodat -// fchownat -// futimesat -// newfstatat -// unlinkat -// renameat -// linkat -// symlinkat -// readlinkat -// fchmodat -// faccessat -// pselect6 -// ppoll -// unshare -// set_robust_list -// get_robust_list -// splice -// tee -// sync_file_range -// vmsplice -// move_pages -// utimensat -// getcpu -// epoll_pwait -// signalfd -// timerfd_create -// eventfd -// fallocate -// timerfd_settime -// timerfd_gettime -// accept4 -// signalfd4 -// eventfd2 -// epoll_create1 -// dup3 -// pipe2 -// inotify_init1 -// preadv -// pwritev - - -//#include "../common/sfsocketcall.h" - - -#endif /* SFLIB_H */ diff --git a/dest/include/librz/sflib/linux-x86-64/sfsyscall.h b/dest/include/librz/sflib/linux-x86-64/sfsyscall.h deleted file mode 100644 index 700d0f97995..00000000000 --- a/dest/include/librz/sflib/linux-x86-64/sfsyscall.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * sfsyscall.h --- SFLib syscall macros for Linux/amd64 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - - -/* - * Automatically generated by gensflib.py - * Mon Mar 21 13:23:31 2022 - */ - -#ifndef SFSYSCALL_H -#define SFSYSCALL_H - - -/* $Id$ */ - -#ifdef SF_USE_ERRNO - -static int errno=1234; - -#define __sfsyscall_return(type, res) \ -do { \ - if ((unsigned long)(res) >= (unsigned long)(-125)) { \ - errno = -(res); \ - res = -1; \ - } \ - return (type) (res); \ -} while (0) - -#else /* SF_USE_ERRNO */ - -#define __sfsyscall_return(type, res) \ -do { \ - return (type) (res); \ -} while (0) - -#endif /* SF_USE_ERRNO */ - - -/* syscall macros */ - -#define _sfsyscall0(type, name) \ -type name(void) { \ - long __res; \ - __asm__ volatile("###> " #name " <###\n\t" \ - "syscall" \ - : "=a" (__res) \ - : "0" (__NR_##name) \ - : "memory", "rcx", "r11", "cc" \ - ); \ - __sfsyscall_return(type,__res); \ -} - -#define _sfsyscall1(type, name, type1, arg1) \ -type name(type1 arg1) { \ - long __res; \ - register type1 rdi asm("rdi"); \ - rdi = arg1; \ - asm volatile("###> " #name "(%2) <###\n\t" \ - "syscall" \ - : "=a" (__res) \ - : "0" (__NR_##name), \ - "r" (rdi) \ - : "memory", "rcx", "r11", "cc" \ - ); \ - __sfsyscall_return(type,__res); \ -} - -#define _sfsyscall2(type, name, type1, arg1, type2, arg2) \ - type name(type1 arg1, type2 arg2) { \ - long __res; \ - register type1 rdi asm("rdi"); \ - register type2 rsi asm("rsi"); \ - rdi = arg1; \ - rsi = arg2; \ - __asm__ volatile("###> " #name "(%2, %3) <###\n\t" \ - "syscall" \ - : "=a" (__res) \ - : "0" (__NR_##name), \ - "r" (rdi), \ - "r" (rsi) \ - : "memory", "rcx", "r11", "cc" \ - ); \ - __sfsyscall_return(type, __res); \ -} - -#define _sfsyscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ - type name(type1 arg1, type2 arg2, type3 arg3) { \ - long __res; \ - register type1 rdi asm("rdi"); \ - register type2 rsi asm("rsi"); \ - register type3 rdx asm("rdx"); \ - rdi = arg1; \ - rsi = arg2; \ - rdx = arg3; \ - asm volatile("###> " #name "(%2, %3, %4) <###\n\t" \ - "syscall" \ - : "=a" (__res) \ - : "0" (__NR_##name), \ - "r" (rdi), \ - "r" (rsi), \ - "r" (rdx) \ - : "memory", "rcx", "r11", "cc" \ - ); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall4(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ - long __res; \ - register type1 rdi asm("rdi"); \ - register type2 rsi asm("rsi"); \ - register type3 rdx asm("rdx"); \ - register type4 r10 asm("r10"); \ - rdi = arg1; \ - rsi = arg2; \ - rdx = arg3; \ - r10 = arg4; \ - asm volatile("###> " #name "(%2, %3, %4, %5) <###\n\t" \ - "syscall" \ - : "=a" (__res) \ - : "0" (__NR_##name), \ - "r" (rdi), \ - "r" (rsi), \ - "r" (rdx), \ - "r" (r10) \ - : "memory", "rcx", "r11", "cc" \ - ); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall5(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) \ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ - type5 arg5) { \ - long __res; \ - register type1 rdi asm("rdi"); \ - register type2 rsi asm("rsi"); \ - register type3 rdx asm("rdx"); \ - register type4 r10 asm("r10"); \ - register type5 r8 asm("r8"); \ - rdi = arg1; \ - rsi = arg2; \ - rdx = arg3; \ - r10 = arg4; \ - r8 = arg5; \ - asm volatile("###> " #name "(%2, %3, %4, %5, %6) <###\n\t" \ - "syscall" \ - : "=a" (__res) \ - : "0" (__NR_##name), \ - "r" (rdi), \ - "r" (rsi), \ - "r" (rdx), \ - "r" (r10), \ - "r" (r8) \ - : "memory", "rcx", "r11", "cc" \ - ); \ - __sfsyscall_return(type, __res); \ - } - -#define _sfsyscall6(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5, type6, arg6)\ - type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ - type5 arg5, type6 arg6) { \ - long __res; \ - register type1 rdi asm("rdi"); \ - register type2 rsi asm("rsi"); \ - register type3 rdx asm("rdx"); \ - register type4 r10 asm("r10"); \ - register type5 r8 asm("r8"); \ - register type6 r9 asm("r9"); \ - rdi = arg1; \ - rsi = arg2; \ - rdx = arg3; \ - r10 = arg4; \ - r8 = arg5; \ - r9 = arg6; \ - asm volatile("###> " #name "(%2, %3, %4, %5, %6, %7) <###\n\t" \ - "syscall" \ - : "=a" (__res) \ - : "0" (__NR_##name), \ - "r" (rdi), \ - "r" (rsi), \ - "r" (rdx), \ - "r" (r10), \ - "r" (r8), \ - "r" (r9) \ - : "memory", "rcx", "r11", "cc" \ - ); \ - __sfsyscall_return(type, __res); \ - } - -#endif /* SFSYSCALL_H */ diff --git a/dest/include/librz/sflib/linux-x86-64/sfsysnr.h b/dest/include/librz/sflib/linux-x86-64/sfsysnr.h deleted file mode 100644 index c9a62201217..00000000000 --- a/dest/include/librz/sflib/linux-x86-64/sfsysnr.h +++ /dev/null @@ -1,332 +0,0 @@ -/* - * sfsysnr.h --- SFLib syscall numbers for Linux/amd64 - * see http://www.secdev.org/projects/shellforge.html for more informations - * - * Copyright (C) 2004 Philippe Biondi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - - -/* - * Automatically generated by gensflib.py - * Mon Mar 21 13:23:31 2022 - */ - -#ifndef SFSYSNR_H -#define SFSYSNR_H - -/* $Id$ */ - -#define __NR_read 0 -#define __NR_write 1 -#define __NR_open 2 -#define __NR_close 3 -#define __NR_stat 4 -#define __NR_fstat 5 -#define __NR_lstat 6 -#define __NR_poll 7 -#define __NR_lseek 8 -#define __NR_mmap 9 -#define __NR_mprotect 10 -#define __NR_munmap 11 -#define __NR_brk 12 -#define __NR_rt_sigaction 13 -#define __NR_rt_sigprocmask 14 -#define __NR_rt_sigreturn 15 -#define __NR_ioctl 16 -#define __NR_pread64 17 -#define __NR_pwrite64 18 -#define __NR_readv 19 -#define __NR_writev 20 -#define __NR_access 21 -#define __NR_pipe 22 -#define __NR_select 23 -#define __NR_sched_yield 24 -#define __NR_mremap 25 -#define __NR_msync 26 -#define __NR_mincore 27 -#define __NR_madvise 28 -#define __NR_shmget 29 -#define __NR_shmat 30 -#define __NR_shmctl 31 -#define __NR_dup 32 -#define __NR_dup2 33 -#define __NR_pause 34 -#define __NR_nanosleep 35 -#define __NR_getitimer 36 -#define __NR_alarm 37 -#define __NR_setitimer 38 -#define __NR_getpid 39 -#define __NR_sendfile 40 -#define __NR_socket 41 -#define __NR_connect 42 -#define __NR_accept 43 -#define __NR_sendto 44 -#define __NR_recvfrom 45 -#define __NR_sendmsg 46 -#define __NR_recvmsg 47 -#define __NR_shutdown 48 -#define __NR_bind 49 -#define __NR_listen 50 -#define __NR_getsockname 51 -#define __NR_getpeername 52 -#define __NR_socketpair 53 -#define __NR_setsockopt 54 -#define __NR_getsockopt 55 -#define __NR_clone 56 -#define __NR_fork 57 -#define __NR_vfork 58 -#define __NR_execve 59 -#define __NR_exit 60 -#define __NR_wait4 61 -#define __NR_kill 62 -#define __NR_uname 63 -#define __NR_semget 64 -#define __NR_semop 65 -#define __NR_semctl 66 -#define __NR_shmdt 67 -#define __NR_msgget 68 -#define __NR_msgsnd 69 -#define __NR_msgrcv 70 -#define __NR_msgctl 71 -#define __NR_fcntl 72 -#define __NR_flock 73 -#define __NR_fsync 74 -#define __NR_fdatasync 75 -#define __NR_truncate 76 -#define __NR_ftruncate 77 -#define __NR_getdents 78 -#define __NR_getcwd 79 -#define __NR_chdir 80 -#define __NR_fchdir 81 -#define __NR_rename 82 -#define __NR_mkdir 83 -#define __NR_rmdir 84 -#define __NR_creat 85 -#define __NR_link 86 -#define __NR_unlink 87 -#define __NR_symlink 88 -#define __NR_readlink 89 -#define __NR_chmod 90 -#define __NR_fchmod 91 -#define __NR_chown 92 -#define __NR_fchown 93 -#define __NR_lchown 94 -#define __NR_umask 95 -#define __NR_gettimeofday 96 -#define __NR_getrlimit 97 -#define __NR_getrusage 98 -#define __NR_sysinfo 99 -#define __NR_times 100 -#define __NR_ptrace 101 -#define __NR_getuid 102 -#define __NR_syslog 103 -/* at the very end the stuff that never runs during the benchmarks */ -#define __NR_getgid 104 -#define __NR_setuid 105 -#define __NR_setgid 106 -#define __NR_geteuid 107 -#define __NR_getegid 108 -#define __NR_setpgid 109 -#define __NR_getppid 110 -#define __NR_getpgrp 111 -#define __NR_setsid 112 -#define __NR_setreuid 113 -#define __NR_setregid 114 -#define __NR_getgroups 115 -#define __NR_setgroups 116 -#define __NR_setresuid 117 -#define __NR_getresuid 118 -#define __NR_setresgid 119 -#define __NR_getresgid 120 -#define __NR_getpgid 121 -#define __NR_setfsuid 122 -#define __NR_setfsgid 123 -#define __NR_getsid 124 -#define __NR_capget 125 -#define __NR_capset 126 -#define __NR_rt_sigpending 127 -#define __NR_rt_sigtimedwait 128 -#define __NR_rt_sigqueueinfo 129 -#define __NR_rt_sigsuspend 130 -#define __NR_sigaltstack 131 -#define __NR_utime 132 -#define __NR_mknod 133 -/* Only needed for a.out */ -#define __NR_uselib 134 -#define __NR_personality 135 -#define __NR_ustat 136 -#define __NR_statfs 137 -#define __NR_fstatfs 138 -#define __NR_sysfs 139 -#define __NR_getpriority 140 -#define __NR_setpriority 141 -#define __NR_sched_setparam 142 -#define __NR_sched_getparam 143 -#define __NR_sched_setscheduler 144 -#define __NR_sched_getscheduler 145 -#define __NR_sched_get_priority_max 146 -#define __NR_sched_get_priority_min 147 -#define __NR_sched_rr_get_interval 148 -#define __NR_mlock 149 -#define __NR_munlock 150 -#define __NR_mlockall 151 -#define __NR_munlockall 152 -#define __NR_vhangup 153 -#define __NR_modify_ldt 154 -#define __NR_pivot_root 155 -#define __NR__sysctl 156 -#define __NR_prctl 157 -#define __NR_arch_prctl 158 -#define __NR_adjtimex 159 -#define __NR_setrlimit 160 -#define __NR_chroot 161 -#define __NR_sync 162 -#define __NR_acct 163 -#define __NR_settimeofday 164 -#define __NR_mount 165 -#define __NR_umount2 166 -#define __NR_swapon 167 -#define __NR_swapoff 168 -#define __NR_reboot 169 -#define __NR_sethostname 170 -#define __NR_setdomainname 171 -#define __NR_iopl 172 -#define __NR_ioperm 173 -#define __NR_create_module 174 -#define __NR_init_module 175 -#define __NR_delete_module 176 -#define __NR_get_kernel_syms 177 -#define __NR_query_module 178 -#define __NR_quotactl 179 -#define __NR_nfsservctl 180 -/* reserved for LiS/STREAMS */ -#define __NR_getpmsg 181 -#define __NR_putpmsg 182 -/* reserved for AFS */ -#define __NR_afs_syscall 183 -/* reserved for tux */ -#define __NR_tuxcall 184 -#define __NR_security 185 -#define __NR_gettid 186 -#define __NR_readahead 187 -#define __NR_setxattr 188 -#define __NR_lsetxattr 189 -#define __NR_fsetxattr 190 -#define __NR_getxattr 191 -#define __NR_lgetxattr 192 -#define __NR_fgetxattr 193 -#define __NR_listxattr 194 -#define __NR_llistxattr 195 -#define __NR_flistxattr 196 -#define __NR_removexattr 197 -#define __NR_lremovexattr 198 -#define __NR_fremovexattr 199 -#define __NR_tkill 200 -#define __NR_time 201 -#define __NR_futex 202 -#define __NR_sched_setaffinity 203 -#define __NR_sched_getaffinity 204 -#define __NR_set_thread_area 205 -#define __NR_io_setup 206 -#define __NR_io_destroy 207 -#define __NR_io_getevents 208 -#define __NR_io_submit 209 -#define __NR_io_cancel 210 -#define __NR_get_thread_area 211 -#define __NR_lookup_dcookie 212 -#define __NR_epoll_create 213 -#define __NR_epoll_ctl_old 214 -#define __NR_epoll_wait_old 215 -#define __NR_remap_file_pages 216 -#define __NR_getdents64 217 -#define __NR_set_tid_address 218 -#define __NR_restart_syscall 219 -#define __NR_semtimedop 220 -#define __NR_fadvise64 221 -#define __NR_timer_create 222 -#define __NR_timer_settime 223 -#define __NR_timer_gettime 224 -#define __NR_timer_getoverrun 225 -#define __NR_timer_delete 226 -#define __NR_clock_settime 227 -#define __NR_clock_gettime 228 -#define __NR_clock_getres 229 -#define __NR_clock_nanosleep 230 -#define __NR_exit_group 231 -#define __NR_epoll_wait 232 -#define __NR_epoll_ctl 233 -#define __NR_tgkill 234 -#define __NR_utimes 235 -#define __NR_vserver 236 -#define __NR_mbind 237 -#define __NR_set_mempolicy 238 -#define __NR_get_mempolicy 239 -#define __NR_mq_open 240 -#define __NR_mq_unlink 241 -#define __NR_mq_timedsend 242 -#define __NR_mq_timedreceive 243 -#define __NR_mq_notify 244 -#define __NR_mq_getsetattr 245 -#define __NR_kexec_load 246 -#define __NR_waitid 247 -#define __NR_add_key 248 -#define __NR_request_key 249 -#define __NR_keyctl 250 -#define __NR_ioprio_set 251 -#define __NR_ioprio_get 252 -#define __NR_inotify_init 253 -#define __NR_inotify_add_watch 254 -#define __NR_inotify_rm_watch 255 -#define __NR_migrate_pages 256 -#define __NR_openat 257 -#define __NR_mkdirat 258 -#define __NR_mknodat 259 -#define __NR_fchownat 260 -#define __NR_futimesat 261 -#define __NR_newfstatat 262 -#define __NR_unlinkat 263 -#define __NR_renameat 264 -#define __NR_linkat 265 -#define __NR_symlinkat 266 -#define __NR_readlinkat 267 -#define __NR_fchmodat 268 -#define __NR_faccessat 269 -#define __NR_pselect6 270 -#define __NR_ppoll 271 -#define __NR_unshare 272 -#define __NR_set_robust_list 273 -#define __NR_get_robust_list 274 -#define __NR_splice 275 -#define __NR_tee 276 -#define __NR_sync_file_range 277 -#define __NR_vmsplice 278 -#define __NR_move_pages 279 -#define __NR_utimensat 280 -#define __IGNORE_getcpu /* implemented as a vsyscall */ -#define __NR_epoll_pwait 281 -#define __NR_signalfd 282 -#define __NR_timerfd_create 283 -#define __NR_eventfd 284 -#define __NR_fallocate 285 -#define __NR_timerfd_settime 286 -#define __NR_timerfd_gettime 287 -#define __NR_accept4 288 -#define __NR_signalfd4 289 -#define __NR_eventfd2 290 -#define __NR_epoll_create1 291 -#define __NR_dup3 292 -#define __NR_pipe2 293 -#define __NR_inotify_init1 294 -#define __NR_preadv 295 -#define __NR_pwritev 296 - -#endif /* SFSYSNR_H */ diff --git a/dest/share/cons/ayu b/dest/share/cons/ayu deleted file mode 100644 index 9d1c57b946b..00000000000 --- a/dest/share/cons/ayu +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-FileCopyrightText: 2018 securisec -# SPDX-License-Identifier: LGPL-3.0-only - -ec ai.exec rgb:6d6 -ec ai.read rgb:66d -ec ai.write rgb:d66 -ec args rgb:2bc -ec b0x00 rgb:738699 # 00 bytes -ec b0x7f rgb:677 -ec b0xff rgb:abb0b6 # ff bytes -ec btext rgb:5de # text section opcode? first byte of opcode -ec comment rgb:95e6cb # rizin renerated comments -ec creg rgb:ff7733 # modified registries -ec flag rgb:5ccfe6 # flags. usually apprears above the current seek -ec fline rgb:55b4d4 # function line. the boundary of a function -ec flow rgb:c2d94c # lines that show jump destinations -ec flow2 rgb:ddd -ec fname rgb:ff6a00 # function name -ec graph.traced rgb:2eb -ec graph.box rgb:5c6773 # unselected boxes in visual graph mode -ec graph.box2 rgb:ff6a00 # currently selected box in visual graph mode -ec graph.box3 rgb:66d9ef -ec graph.box4 rgb:66d9ef -ec graph.current rgb:fff -ec graph.false rgb:f07178 # false line on visual graph mode -ec graph.true rgb:bae67e # true line on visual graph mode -ec graph.ujump rgb:55b4d4 # lines in graph that does not have true or false -ec help rgb:c2d94c # color of help explanation text -ec input rgb:888 -ec jmp rgb:c2d94c # jmp instructions -ec label rgb:66d9ef -ec linehl rgb:42505e # highlight color when using asm.highlight -ec mov rgb:d9d8d7 # mov instructions -ec nop rgb:a37acc # nop instructions -ec num rgb:f28779 # numbers -ec offset rgb:ed9366 # offset in visual mode -ec other rgb:888 -ec prompt rgb:5de # color for main rizin prompt -ec call rgb:ff7733 # push instructions -ec reg rgb:e6e1cf # register names -ec ret rgb:d66 # ret opcode -ec swi rgb:d66 -ec trap rgb:d66 -ec cmp rgb:5de -ec push rgb:5de -ec math rgb:5de -ec bin rgb:5de -ec pop rgb:5de -ec cjmp rgb:c2d94c # je, jg, etc -ec ucall rgb:5ccfe6 -ec ujmp rgb:c2d94c -ec usrcmt rgb:fa6e32 # user comment - -ec func_var rgb:95e6cb -ec func_var_type rgb:ffd580 -ec func_var_addr rgb:f28779 - -ec widget_bg rgb:888 rgb:000 -ec widget_sel rgb:5de rgb:333 diff --git a/dest/share/cons/basic b/dest/share/cons/basic deleted file mode 100644 index 423d11e94aa..00000000000 --- a/dest/share/cons/basic +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-FileCopyrightText: 2015 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -# optimized for windows -ecd -k one=cyan -k two=white -ec fname `k one` -ec label `k one` -ec fline `k one` -ec flag `k one` -ec offset `k two` -ec comment red -ec usrcmt green -ec flow green -ec flow2 green -ec b0x00 white -ec b0xff red -ec bin cyan -ec b0x7f white -ec other gray -ec btext cyan -ec invalid red -ec trap red -ec ucall cyan -ec ujmp green -ec args green -ec help yellow -ec prompt cyan -ec mov gray -ec math gray -ec push yellow -ec reg white -ec creg white -ec num cyan -ec invalid red -ec swi cyan -ec cmp yellow -ec call cyan -ec cjmp green -ec jmp green -ec pop yellow -ec linehl rgb:004 -ec graph.true green -ec graph.false red -ec graph.ujump blue -ec graph.current blue -ec graph.traced blue -ec graph.box gray -ec graph.box2 blue -ec graph.box3 gray -ec graph.box4 gray - -ec func_var white -ec func_var_type blue -ec func_var_addr cyan - -ec widget_bg white gray -ec widget_sel black cyan diff --git a/dest/share/cons/behelit b/dest/share/cons/behelit deleted file mode 100644 index ea57c8c8205..00000000000 --- a/dest/share/cons/behelit +++ /dev/null @@ -1,69 +0,0 @@ -# SPDX-FileCopyrightText: 2016 oblique -# SPDX-License-Identifier: LGPL-3.0-only - -ec b0x7f rgb:ff5f5f -ec b0xff rgb:ff005f -ec b0x00 rgb:262626 -ec btext rgb:af87ff -ec other rgb:4e4e4e -ec offset rgb:4e4e4e -ec flow rgb:5f87ff -ec flow2 rgb:5f87ff -ec input rgb:5fff5f -ec prompt rgb:5f87ff -ec args rgb:ff005f -ec help rgb:af87d7 -ec comment rgb:ff005f -ec usrcmt rgb:000000 rgb:5f87ff -ec flag rgb:5f87ff -ec fline rgb:af87ff -ec fname rgb:5f87ff -ec floc rgb:5f87ff -ec label rgb:5f87ff -ec mov rgb:5f87ff -ec call rgb:000000 rgb:00ff5f -ec jmp rgb:000000 rgb:5f5fff -ec cjmp rgb:000000 rgb:5f87ff -ec cmp rgb:ff005f -ec nop rgb:4e4e4e -ec math rgb:ffff5f -ec bin rgb:ff5f5f -ec ret rgb:ff005f -ec push rgb:af87ff -ec pop rgb:af87ff -ec swi rgb:8787ff -ec crypto rgb:000000 rgb:ff5f5f -ec trap rgb:000000 rgb:ff005f -ec ucall rgb:000000 rgb:00ff5f -ec ujmp rgb:000000 rgb:5f87ff - -ec invalid rgb:000000 rgb:ff005f -ec num rgb:af87ff rgb:121212 -ec reg rgb:5fff5f rgb:121212 -ec creg rgb:5f87ff -ec ai.read rgb:00ff5f -ec ai.write rgb:5f87ff -ec ai.exec rgb:ff005f -ec ai.seq rgb:af87ff -ec ai.ascii rgb:ff5f5f -ec graph.box rgb:00ff5f -ec graph.box2 rgb:5f87ff -ec graph.box3 rgb:af87ff -ec graph.box4 rgb:ff005f -ec graph.true rgb:00ff5f -ec graph.false rgb:ff005f -ec graph.ujump rgb:5f87ff -ec graph.current rgb:5f87ff -ec graph.traced rgb:ffff5f -ec linehl rgb:1f1f1f - -# background of the terminal must be #121212 -# foreground of the terminal must be #5fff5f -# xterm -bg rgb:12/12/12 -fg rgb:5f/ff/5f - -ec func_var rgb:ff005f -ec func_var_type blue -ec func_var_addr rgb:5f87ff - -ec widget_bg rgb:68f rgb:555 -ec widget_sel black rgb:0f6 diff --git a/dest/share/cons/bold b/dest/share/cons/bold deleted file mode 100644 index 5488f948f1b..00000000000 --- a/dest/share/cons/bold +++ /dev/null @@ -1,76 +0,0 @@ -# SPDX-FileCopyrightText: 2018 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -ec b0x00 rgb:ccc -ec b0x7f rgb:ccc -ec b0xff red -ec btext rgb:fff . bold - -ec args white -ec bin white -ec cmp white -ec usrcmt black white bold -ec reg green . bold -ec creg rgb:f72 -ec flag yellow . bold -ec fline white - -ec flow yellow -ec flow2 white - -ec fname black green bold -ec help yellow . bold -ec input yellow . bold -ec label white . bold -ec math white -ec mov white -ec nop rgb:ccc - -ec comment yellow . bold -ec call black green bold -ec ucall black green bold -ec num rgb:fff . bold -ec jmp yellow . bold -ec cjmp yellow . bold -ec ujmp yellow . bold - -ec offset white . bold -ec other rgb:999 -ec pop rgb:999 - -ec prompt black yellow bold - -ec graph.box white -ec graph.box2 green -ec graph.box3 rgb:000 -ec graph.box4 rgb:000 - -ec graph.true green . bold -ec graph.false red - -ec push white -ec ret rgb:777 -ec swi black red bold -ec trap red -ec graph.ujump rgb:ddd -ec graph.current rgb:f72 -ec graph.traced rgb:f00 -ec gui.cflow rgb:f72 -ec gui.dataoffset rgb:f72 -ec crypto rgb:f72 -ec floc rgb:777 -ec invalid red -ec linehl rgb:008 - -ec func_var yellow . bold -ec func_var_type blue . bold -ec func_var_addr cyan . bold - -ec ai.read white . bold -ec ai.write white . bold -ec ai.exec red . bold -ec ai.seq green . bold -ec ai.ascii yellow . bold - -ec widget_bg yellow black -ec widget_sel black yellow diff --git a/dest/share/cons/bright b/dest/share/cons/bright deleted file mode 100644 index de5164fcb0d..00000000000 --- a/dest/share/cons/bright +++ /dev/null @@ -1,75 +0,0 @@ -# SPDX-FileCopyrightText: 2019 Khairul Azhar Kasmiran -# SPDX-License-Identifier: LGPL-3.0-only - -# rizin default palette but with bright colors for all - -ec b0x00 rgb:00ff00 -ec b0x7f rgb:00ffff -ec b0xff rgb:ff0000 -ec args rgb:ffff00 -ec bin rgb:00ffff -ec btext rgb:ffff00 -ec call rgb:00ff00 . bold -ec cjmp rgb:00ff00 -ec cmp rgb:00ffff -ec comment rgb:ff0000 -ec usrcmt rgb:ffffff -ec creg rgb:00ffff -ec flag rgb:00ffff -ec fline rgb:00ffff -ec floc rgb:00ffff -ec flow rgb:00ffff -ec flow2 rgb:0000ff -ec fname rgb:ff0000 -ec help rgb:00ff00 -ec input rgb:ffffff -ec invalid rgb:ff0000 . bold -ec jmp rgb:00ff00 -ec label rgb:00ffff -ec math rgb:ffff00 -ec mov rgb:ffffff -ec nop rgb:0000ff -ec num rgb:ffff00 -ec offset rgb:00ff00 -ec other rgb:ffffff -ec pop rgb:ff00ff . bold -ec prompt rgb:ffff00 -ec push rgb:ff00ff -ec crypto rgb:ffff00 -ec reg rgb:00ffff -ec ret rgb:ff0000 -ec swi rgb:ff00ff -ec trap rgb:ff0000 . bold -ec ucall rgb:00ff00 -ec ujmp rgb:00ff00 - -ec ai.read rgb:00ff00 -ec ai.write rgb:0000ff -ec ai.exec rgb:ff0000 -ec ai.seq rgb:ff00ff -ec ai.ascii rgb:ffff00 - -ec gui.cflow rgb:ffff00 -ec gui.dataoffset rgb:ffff00 -ec gui.background rgb:000000 -ec gui.alt_background rgb:ffffff -ec gui.border rgb:000000 -ec wordhl rgb:ff0000 -ec linehl rgb:000080 - -ec func_var rgb:ffffff -ec func_var_type rgb:ffff00 -ec func_var_addr rgb:00ffff - -ec widget_bg rgb:303030 -ec widget_sel rgb:ff0000 - -ec graph.box rgb:0000ff -ec graph.box2 rgb:00ff00 -ec graph.box3 rgb:ff00ff -ec graph.box4 rgb:808080 -ec graph.true rgb:00ff00 -ec graph.false rgb:ff0000 -ec graph.ujump rgb:0000ff # single jump -ec graph.traced rgb:ffff00 -ec graph.current rgb:0000ff diff --git a/dest/share/cons/cga b/dest/share/cons/cga deleted file mode 100644 index 08e422766ca..00000000000 --- a/dest/share/cons/cga +++ /dev/null @@ -1,75 +0,0 @@ -# SPDX-FileCopyrightText: 2016 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -ec comment rgb:0ff -ec usrcmt rgb:f0f -ec mov white -ec fname rgb:f00 -ec args white -ec floc rgb:f0f -ec fline rgb:f0f -ec flag rgb:f0f -ec invalid rgb:f0f -ec trap rgb:f0f -ec swi rgb:f0f -ec ret rgb:f0f -ec input rgb:0ff -ec fname rgb:f0f -ec label rgb:f0f -ec flow rgb:f0f -ec flow2 rgb:f0f -ec prompt rgb:0ff -ec offset rgb:0ff -ec other rgb:fff -ec b0x00 rgb:fff -ec b0x7f rgb:f0f -ec b0xff rgb:0ff -ec math rgb:f0f -ec crypto rgb:f0f -ec bin rgb:f0f -ec btext rgb:f0f -ec push rgb:0ff -ec pop rgb:0ff -ec jmp rgb:f0f -ec cjmp rgb:f0f -ec call rgb:f0f -ec nop rgb:0ff -ec trap rgb:f0f -ec cmp rgb:0ff -ec reg rgb:f0f -ec creg rgb:f0f -ec num rgb:0ff -ec help rgb:0ff -ec trap rgb:000 rgb:f0f -ec ucall rgb:f0f -ec ujmp rgb:f0f -ec linehl rgb:008 - -ec graph.box rgb:f0f -ec graph.box2 rgb:f0f -ec graph.box3 rgb:f0f -ec graph.box4 rgb:f0f -ec graph.true rgb:f0f -ec graph.false rgb:0ff -ec graph.ujump rgb:f0f -ec graph.current rgb:0ff -ec graph.traced rgb:f0f - -ec gui.cflow rgb:0ff -ec gui.dataoffset rgb:0ff -ec gui.background rgb:0ff -ec gui.alt_background rgb:0ff -ec gui.border rgb:0ff - -ec ai.read rgb:0ff -ec ai.write rgb:f0f -ec ai.exec rgb:f0f -ec ai.seq rgb:f0f -ec ai.ascii rgb:f0f - -ec func_var rgb:f0f -ec func_var_type rgb:f0f -ec func_var_addr rgb:0ff - -ec widget_bg rgb:f0f rgb:000 -ec widget_sel rgb:0ff rgb:000 diff --git a/dest/share/cons/consonance b/dest/share/cons/consonance deleted file mode 100644 index 2ad43c4d9a3..00000000000 --- a/dest/share/cons/consonance +++ /dev/null @@ -1,67 +0,0 @@ -# SPDX-FileCopyrightText: 2014 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -# background of the terminal must be 134 o 033 -# xterm -fn 10x20 -bg rgb:20/20/20 -fg rgb:d0/d0/d0 -# ref: https://github.com/eugeneching/ida-consonance/blob/master/ida-consonance.clr - -ec b0x00 rgb:9aa -ec b0x7f rgb:577 -ec b0xff rgb:8cf -ec bin rgb:fff -ec btext rgb:fff -ec ucall rgb:2fa -ec call rgb:f2a -ec ujmp rgb:4cf -ec cjmp rgb:4cf -ec jmp rgb:4cf -ec cmp rgb:fff -ec comment rgb:fcc -ec usrcmt rgb:f2a -ec ret rgb:4cf -ec fline rgb:fff -ec flow rgb:789 -ec flow2 rgb:888 -ec fname rgb:ee0 -ec label rgb:ee0 -ec math rgb:fff -ec mov rgb:fff -ec nop rgb:888 -ec num rgb:fff -ec offset rgb:888 -ec other rgb:577 -ec pop rgb:fff -ec prompt rgb:4cf -ec push rgb:fff -ec reg rgb:789 -ec args rgb:789 -ec help rgb:ee0 -ec input rgb:c41 -ec trap rgb:d41 -ec swi rgb:f2a -ec creg rgb:789 -ec flag rgb:4cf -ec linehl rgb:004 - -ec graph.box rgb:789 -ec graph.box2 rgb:d41 -ec graph.box3 rgb:af2 -ec graph.box4 rgb:af2 -ec graph.true rgb:4f2 -ec graph.false rgb:d41 -ec graph.ujump rgb:4cf -ec graph.current rgb:af2 -ec graph.traced rgb:090 - -ec func_var rgb:fcc -ec func_var_type rgb:f2a -ec func_var_addr white - -ec ai.read rgb:fcc -ec ai.write rgb:f2a -ec ai.exec rgb:f2a -ec ai.seq rgb:f0f -ec ai.ascii rgb:fff - -ec widget_bg rgb:4cf rgb:344 -ec widget_sel black rgb:4cf diff --git a/dest/share/cons/cutter b/dest/share/cons/cutter deleted file mode 100644 index 4fb8cec03af..00000000000 --- a/dest/share/cons/cutter +++ /dev/null @@ -1,71 +0,0 @@ -# SPDX-FileCopyrightText: 2017 xarkes -# SPDX-License-Identifier: LGPL-3.0-only - -ec comment rgb:8e8c8b -ec usrcmt rgb:8e8c8b -ec args rgb:20b0c0 -ec fname rgb:0693c9 -ec floc rgb:00ffff -ec fline rgb:5f8700 -ec flag rgb:0a8ab0 0 bold -ec label rgb:0068bd -ec help rgb:005f87 -ec flow rgb:5f8700 -ec flow2 rgb:5f8700 -ec prompt rgb:000000 -ec offset rgb:8e8c8b -ec input rgb:000000 -ec invalid rgb:e03030 -ec other rgb:005f87 -ec b0x00 rgb:707070 -ec b0x7f rgb:7f7f7f -ec b0xff rgb:e03030 -ec math rgb:005f87 -ec bin rgb:005f87 -ec btext rgb:000000 -ec push rgb:da3192 -ec pop rgb:da3192 -ec crypto rgb:d03080 -ec jmp rgb:5f8700 -ec cjmp rgb:5f8700 -ec ujmp rgb:5f8700 -ec call rgb:0693c9 -ec ucall rgb:0693c9 -ec nop rgb:005f87 -ec ret rgb:0693c9 -ec trap rgb:0693c9 -ec swi rgb:5f8700 -ec cmp rgb:da3192 -ec reg rgb:005f87 -ec creg rgb:005f87 -ec num rgb:ef5919 -ec mov rgb:da3192 -ec func_var rgb:d03080 -ec func_var_type rgb:876ac1 -ec func_var_addr rgb:b0b0b0 -ec widget_bg rgb:303030 -ec widget_sel rgb:ff0000 -ec ai.read rgb:1080d0 -ec ai.write rgb:005f87 -ec ai.exec rgb:b08000 -ec ai.seq rgb:d03080 -ec ai.ascii rgb:000000 -ec graph.box rgb:005f87 -ec graph.box2 rgb:5f8700 -ec graph.box3 rgb:e03030 -ec graph.box4 rgb:005f87 -ec graph.true rgb:5f8700 -ec graph.false rgb:e03030 -ec graph.ujump rgb:005f87 -ec graph.current rgb:00f0f0 -ec graph.traced rgb:e03030 -ec gui.cflow rgb:ffff00 -ec gui.dataoffset rgb:ffff00 -ec gui.background rgb:000000 -ec gui.alt_background rgb:ffffff -ec gui.border rgb:000000 -ec wordhl rgb:ff0000 -ec linehl rgb:efefef - -ec widget_bg rgb:4cf rgb:058 -ec widget_sel black rgb:d39 diff --git a/dest/share/cons/dark b/dest/share/cons/dark deleted file mode 100644 index f074ead4dde..00000000000 --- a/dest/share/cons/dark +++ /dev/null @@ -1,63 +0,0 @@ -# SPDX-FileCopyrightText: 2013 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -ec b0x00 rgb:444 -ec help rgb:366 -ec comment rgb:99a -ec usrcmt rgb:368 -ec input rgb:bbb -ec b0x7f rgb:555 -ec b0xff rgb:666 -ec bin rgb:f90 -ec btext rgb:366 -ec call rgb:44f rgb:123 -ec cjmp rgb:368 -ec cmp rgb:666 -ec fline rgb:366 -ec flag rgb:99a -ec flow rgb:bbb -ec flow2 rgb:99a -ec jmp rgb:368 -ec fname rgb:99a -ec label rgb:99a -ec math rgb:366 -ec bin rgb:366 -ec crypto rgb:366 -ec mov rgb:666 -ec nop rgb:444 -ec num rgb:99a -ec offset rgb:366 -ec other rgb:bbb -ec prompt rgb:366 -ec push rgb:99a -ec pop rgb:99a -ec reg rgb:368 -ec creg rgb:368 -ec trap rgb:000 rgb: -ec swi rgb:99a -ec ucall rgb:44f rgb:123 -ec ujmp rgb:368 -ec invalid rgb:rgb:44f rgb:123 -ec linehl rgb:004 -ec graph.box rgb:040 -ec graph.box2 rgb:040 -ec graph.box3 rgb:040 -ec graph.box4 rgb:040 -ec graph.true rgb:06c -ec graph.false rgb:035 -ec graph.ujump rgb:06c -ec graph.current rgb:99a -ec graph.traced rgb:bbb - -ec func_var rgb:99a -ec func_var_type rgb:636 -ec func_var_addr rgb:366 - -ec ai.read rgb:266 -ec ai.write rgb:366 -ec ai.exec rgb:368 -ec ai.seq rgb:d38 -ec ai.ascii rgb:99a - -ec widget_bg rgb:366 black -ec widget_sel rgb:44f rgb:123 diff --git a/dest/share/cons/darkda b/dest/share/cons/darkda deleted file mode 100644 index 03d37662822..00000000000 --- a/dest/share/cons/darkda +++ /dev/null @@ -1,64 +0,0 @@ -# SPDX-FileCopyrightText: 2018 securisec -# SPDX-License-Identifier: LGPL-3.0-only - -ec b0x00 rgb:7c7c61 -ec b0x7f rgb:aaff00 -ec b0xff rgb:aaff00 -ec other rgb:ff7f00 -ec bin rgb:ff5afd -ec btext rgb:617c7c -ec call rgb:ffd200 -ec cjmp rgb:9dd600 -ec jmp rgb:9dd600 -ec cmp rgb:00ffff -ec comment rgb:82607e -ec usrcmt rgb:f3c5ff -ec ret rgb:ffaa7f -ec num rgb:d25032 -ec fline rgb:2bc -ec flow rgb:00b1ab -ec flow2 rgb:ddd -ec fname rgb:00ffff -ec label rgb:66d9ef -ec math rgb:ffffff -ec mov rgb:ffffff -ec nop rgb:FFE792 -ec offset rgb:ababab -ec prompt rgb:fc0 -ec pop rgb:ef8d1a -ec push rgb:df077e -ec reg rgb:009d9d -ec args rgb:ffd200 -ec help rgb:009d9d -ec input rgb:888 -ec trap rgb:d66 -ec ucall rgb:ffd200 -ec ujmp rgb:9dd600 -ec swi rgb:df077e -ec creg rgb:69d200 -ec flag rgb:00b1ab -ec linehl rgb:00007f -ec ai.read rgb:66d -ec ai.write rgb:d66 -ec ai.exec rgb:6d6 -ec graph.box rgb:5202f0 -ec graph.box2 rgb:ffcc00 -ec graph.box3 rgb:66d9ef -ec graph.box4 rgb:66d9ef -ec graph.true rgb:009100 -ec graph.false rgb:bc0000 -ec graph.ujump rgb:0043cb -ec graph.current rgb:fff - -ec func_var rgb:99a -ec func_var_type rgb:df077e -ec func_var_addr rgb:ababab - -ec ai.read rgb:be077e -ec ai.write rgb:df077e -ec ai.exec rgb:9dd600 -ec ai.seq rgb:9dd600 -ec ai.ascii rgb:d25032 - -ec widget_bg rgb:099 rgb:444 -ec widget_sel rgb:000 yellow diff --git a/dest/share/cons/defragger b/dest/share/cons/defragger deleted file mode 100644 index 9e905ce85d7..00000000000 --- a/dest/share/cons/defragger +++ /dev/null @@ -1,74 +0,0 @@ -# SPDX-FileCopyrightText: 2018 Rene Laemmert -# SPDX-License-Identifier: LGPL-3.0-only - -ec call rgb:ffff00 -ec ucall rgb:ffff00 -ec comment rgb:32302f -ec usrcmt rgb:ffc5f3 -ec ret rgb:fb4934 -ec args rgb:a89984 -ec fname rgb:fad200 -ec fline rgb:458588 -ec floc rgb:00ffff -ec flag rgb:d75f00 -ec label rgb:8787d7 -ec help rgb:ff5f87 -ec flow2 rgb:0000ff -ec prompt rgb:d75f00 -ec offset rgb:afafaf -ec input rgb:d75f00 -ec invalid rgb:001f00 -ec other rgb:5f8787 -ec b0x00 rgb:005f5f -ec b0x7f rgb:005f5f -ec b0xff rgb:5f8787 -ec math rgb:00afd7 -ec bin rgb:87afaf -ec btext rgb:afafaf -ec push rgb:ff5f87 -ec pop rgb:87afaf -ec crypto rgb:0000ff -ec jmp rgb:ff5f87 -ec cjmp rgb:afaf00 -ec ujmp rgb:ff5f87 -ec nop rgb:5f8787 -ec trap rgb:ff0000 -ec swi rgb:ff0000 -ec cmp rgb:d75f00 -ec reg rgb:73adad -ec creg rgb:73adad -ec num rgb:d25032 -ec mov rgb:ebebeb -ec linehl rgb:00003f -ec ai.read rgb:00ff00 -ec ai.write rgb:0000ff -ec ai.exec rgb:ff0000 -ec ai.seq rgb:ff00ff -ec ai.ascii rgb:ffff00 -ec graph.box rgb:9e9e9e -ec graph.box2 rgb:5f87d7 -ec graph.box3 rgb:af5f87 -ec graph.box4 rgb:303030 -ec graph.ujump rgb:005fff -ec graph.current rgb:c68e00 -ec graph.true rgb:009100 -ec graph.false rgb:bc0000 -ec graph.traced rgb:ffff00 -ec gui.cflow rgb:ffff00 -ec gui.dataoffset rgb:ffff00 -ec gui.background rgb:303030 -ec gui.alt_background rgb:ffffff -ec gui.border rgb:5fd700 - -ec func_var rgb:64604f -ec func_var_type rgb:00afd7 -ec func_var_addr rgb:afafaf - -ec ai.read rgb:a55f00 -ec ai.write rgb:d75f00 -ec ai.exec rgb:ff5f87 -ec ai.seq rgb:9dd600 -ec ai.ascii rgb:d25032 - -ec widget_bg rgb:099 rgb:444 -ec widget_sel rgb:000 yellow diff --git a/dest/share/cons/durian b/dest/share/cons/durian deleted file mode 100644 index 130de995af2..00000000000 --- a/dest/share/cons/durian +++ /dev/null @@ -1,62 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Florian Märkl -# SPDX-License-Identifier: LGPL-3.0-only - -# Based on Armin Ronacher's summerfruit.vim -# https://www.vim.org/scripts/script.php?script_id=1872 - -ec ai.exec "" -ec ai.read "" -ec ai.write "" -ec args rgb:0086d2 -ec b0x00 rgb:70796b -ec b0x7f rgb:70796b -ec b0xff rgb:abb0b6 -ec btext rgb:fb660a -ec creg rgb:fb660a -ec flag rgb:ff0086 -ec fline rgb:70796b -ec flow rgb:70796b -ec flow2 rgb:70796b -ec fname rgb:fb660a -ec graph.traced rgb:2eb -ec graph.box rgb:70796b -ec graph.box2 rgb:ff6a00 -ec graph.box3 rgb:66d9ef -ec graph.box4 rgb:66d9ef -ec graph.current rgb:fff -ec graph.false rgb:ff0086 -ec graph.true rgb:22a21f -ec graph.ujump rgb:0086d2 -ec help rgb:22a21f -ec input rgb:fb660a -ec jmp rgb:ff7733 -ec label rgb:ff0086 -ec linehl rgb:f00 rgb:b7dce8 -ec mov rgb:0086f7 -ec nop rgb:70796b -ec num rgb:0086f7 -ec offset rgb:0086d2 -ec other rgb:70796b -ec prompt rgb:0086d2 -ec call rgb:ff7733 "" bold -ec reg "" -ec ret rgb:fb660a -ec swi rgb:0086f7 -ec trap rgb:ff0086 -ec cmp rgb:0086f7 -ec push rgb:0086f7 -ec math rgb:0086f7 -ec bin rgb:0086f7 -ec pop rgb:0086f7 -ec cjmp rgb:ff7733 -ec ucall rgb:ff7733 "" bold -ec ujmp rgb:ff7733 -ec comment rgb:22a21f -ec usrcmt rgb:22a21f - -ec func_var rgb:22a21f -ec func_var_type rgb:fd8900 -ec func_var_addr rgb:0086d2 - -ec widget_bg rgb:888 rgb:000 -ec widget_sel rgb:5de rgb:333 diff --git a/dest/share/cons/focus b/dest/share/cons/focus deleted file mode 100644 index 5a3ef83bddc..00000000000 --- a/dest/share/cons/focus +++ /dev/null @@ -1,64 +0,0 @@ -# SPDX-FileCopyrightText: 2014 condret -# SPDX-License-Identifier: LGPL-3.0-only - -ec fname rgb:0cf rgb:000 -ec label rgb:0cf rgb:000 -ec math rgb:ccc -ec bin rgb:f90 -ec call rgb:ff0 rgb:00f -ec ucall rgb:000 rgb:ff0 -ec jmp rgb:ff0 rgb:00f -ec cjmp rgb:ff0 -ec ujmp rgb:ff3 -ec ret rgb:f00 -ec trap rgb:000 rgb:f00 -ec offset rgb:fff -ec prompt byellow -ec comment rgb:0cf -ec usrcmt rgb:ff0 rgb:06f -ec push rgb:f3f -ec pop rgb:f3f bold -ec cmp rgb:ff0 rgb:060 -ec nop rgb:000 -ec b0x00 green -ec b0x7f cyan -ec b0xff red -ec btext yellow -ec other rgb:666 -ec num rgb:ff0 -ec reg rgb:6f0 rgb:000 -ec fline rgb:fc0 -ec flow rgb:ff3 -ec flow2 rgb:fff -ec mov rgb:888 -ec swi rgb:000 rgb:fff -ec floc rgb:af2 -ec linehl rgb:222 -ec ai.read green -ec ai.write blue -ec ai.exec red -ec ai.seq rgb:ff00ff -ec ai.ascii rgb:ffff00 - -ec graph.box blue -ec graph.box2 yellow -ec graph.box3 blue -ec graph.box4 blue -ec graph.true green -ec graph.false red -ec graph.ujump blue -ec graph.current blue -ec graph.traced red - -ec func_var cyan -ec func_var_type rgb:f3f -ec func_var_addr white - -ec ai.read rgb:8f0 -ec ai.write rgb:6f0 -ec ai.exec rgb:f3f -ec ai.seq white -ec ai.ascii yellow - -ec widget_bg rgb:ff0 rgb:000 -ec widget_sel rgb:000 rgb:0f0 diff --git a/dest/share/cons/gb b/dest/share/cons/gb deleted file mode 100644 index c4140d50c4d..00000000000 --- a/dest/share/cons/gb +++ /dev/null @@ -1,74 +0,0 @@ -# SPDX-FileCopyrightText: 2019 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -ec comment rgb:86c06c -ec usrcmt rgb:86c06c -ec mov rgb:306850 -ec fname rgb:e0f8cf -ec args white -ec floc rgb:86c06c -ec fline rgb:e0f8cf -ec flag rgb:e0f8cf -ec invalid rgb:306850 -ec input rgb:e0f8cf -ec label rgb:86c06c -ec flow rgb:86c06c -ec flow2 rgb:86c06c -ec prompt rgb:e0f8cf -ec offset rgb:306850 -ec other rgb:306850 -ec b0x00 rgb:306850 -ec b0x7f rgb:86c06c -ec b0xff rgb:e0f8cf -ec math rgb:86c06c -ec crypto rgb:86c06c -ec bin rgb:86c06c -ec btext rgb:86c06c -ec push rgb:86c06c -ec pop rgb:86c06c -ec jmp rgb:e0f8cf -ec cjmp rgb:e0f8cf -ec ujmp rgb:e0f8cf -ec call rgb:e0f8cf -ec trap rgb:e0f8cf -ec swi rgb:e0f8cf -ec ret rgb:e0f8cf -ec cmp rgb:86c06c -ec nop rgb:306850 -ec trap rgb:86c06c -ec reg rgb:e0f8cf -ec creg rgb:e8f8cf -ec num rgb:e0f8cf -ec help rgb:e0f8cf -ec trap rgb:000 rgb:86c06c -ec ucall rgb:86c06c -ec linehl rgb:306850 - -ec graph.box rgb:86c06c -ec graph.box2 rgb:86c06c -ec graph.box3 rgb:86c06c -ec graph.box4 rgb:86c06c -ec graph.true rgb:86c06c -ec graph.false rgb:e0f8cf -ec graph.ujump rgb:86c06c -ec graph.current rgb:e0f8cf -ec graph.traced rgb:86c06c - -ec gui.cflow rgb:e0f8cf -ec gui.dataoffset rgb:e0f8cf -ec gui.background rgb:e0f8cf -ec gui.alt_background rgb:e0f8cf -ec gui.border rgb:e0f8cf - -ec ai.read rgb:e0f8cf -ec ai.write rgb:86c06c -ec ai.exec rgb:86c06c -ec ai.seq rgb:86c06c -ec ai.ascii rgb:86c06c - -ec func_var rgb:86c06c -ec func_var_type rgb:86c06c -ec func_var_addr rgb:e0f8cf - -ec widget_bg rgb:86c06c rgb:000 -ec widget_sel rgb:e0f8cf rgb:000 diff --git a/dest/share/cons/gentoo b/dest/share/cons/gentoo deleted file mode 100644 index 3a11254c2b7..00000000000 --- a/dest/share/cons/gentoo +++ /dev/null @@ -1,71 +0,0 @@ -# SPDX-FileCopyrightText: 2019 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -ec comment cyan -ec usrcmt cyan -ec args cyan -ec fname green -ec floc yellow -ec fline blue -ec flag green -ec label yellow -ec help cyan -ec flow cyan -ec flow2 blue -ec prompt green -ec offset yellow -ec input rgb:f03030 -ec invalid red -ec other rgb:c0c0c0 -ec b0x00 rgb:808080 -ec b0x7f rgb:c0c0c0 -ec b0xff cyan -ec math white -ec bin rgb:f0f0f0 -ec btext rgb:009000 -ec push yellow -ec pop yellow -ec crypto cyan -ec call green -ec ucall green -ec nop rgb:3030f0 -ec ret rgb:30f030 -ec trap rgb:f03030 -ec ujmp rgb:009000 -ec jmp rgb:009000 -ec cjmp rgb:009000 -ec swi black yellow -ec cmp cyan -ec reg rgb:f0f0f0 -ec creg yellow -ec num yellow -ec mov rgb:d0d0d0 -ec func_var white -ec func_var_type yellow -ec func_var_addr white -ec widget_bg rgb:303030 -ec widget_sel rgb:ff0000 -ec ai.read rgb:e0e0e0 -ec ai.write rgb:d0d0d0 -ec ai.exec rgb:f0f0f0 -ec ai.seq rgb:f03030 -ec ai.ascii rgb:f03030 -ec graph.box rgb:3030f0 -ec graph.box2 cyan -ec graph.box3 rgb:30f030 -ec graph.box4 rgb:30f030 -ec graph.true rgb:30f030 -ec graph.false rgb:f03030 -ec graph.ujump rgb:3030f0 -ec graph.current rgb:f03030 -ec graph.traced rgb:f00000 -ec gui.cflow rgb:f03030 -ec gui.dataoffset rgb:3030f0 -ec gui.background rgb:000000 -ec gui.alt_background rgb:ffffff -ec gui.border rgb:000000 -ec wordhl rgb:ff0000 -ec linehl rgb:101010 - -ec widget_bg cyan rgb:3030f0 -ec widget_sel yellow rgb:090 diff --git a/dest/share/cons/lima b/dest/share/cons/lima deleted file mode 100644 index 19d77a96f70..00000000000 --- a/dest/share/cons/lima +++ /dev/null @@ -1,68 +0,0 @@ -# SPDX-FileCopyrightText: 2013 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -ec comment rgb:af2 -ec usrcmt rgb:af2 rgb:140 -ec mov rgb:090 -ec fname rgb:27a -ec args white -ec floc rgb:af2 -ec fline rgb:af2 -ec flag rgb:af2 -ec fname rgb:af2 -ec label rgb:af2 -ec flow rgb:af2 -ec flow2 rgb:af2 -ec prompt rgb:090 -ec offset rgb:ef0 -ec input rgb:7d5 -ec other rgb:090 -ec b0x00 rgb:040 -ec b0x7f rgb:090 -ec b0xff rgb:af2 -ec math rgb:090 -ec crypto rgb:090 -ec bin rgb:ef0 -ec btext rgb:ef0 -ec push rgb:ef0 -ec pop rgb:ef0 -ec jmp rgb:af2 -ec cjmp rgb:af2 -ec ujmp rgb:af2 -ec call rgb:fff -ec ucall rgb:fff -ec nop rgb:2da -ec ret rgb:5d5 -ec trap rgb:a7a -ec swi rgb:dd5 -ec cmp rgb:0a0 -ec reg rgb:af2 -ec creg rgb:af2 -ec num rgb:ef0 -ec help rgb:af2 -ec invalid rgb:ef0 -ec trap rgb:000 rgb:af2 -ec linehl rgb:140 - -ec graph.box rgb:af2 -ec graph.box2 rgb:0a0 -ec graph.box3 rgb:444 -ec graph.box4 rgb:444 -ec graph.true rgb:ef2 -ec graph.false rgb:5d5 -ec graph.ujump rgb:af2 -ec graph.current rgb:af2 -ec graph.traced rgb:090 - -ec func_var yellow -ec func_var_type green -ec func_var_addr yellow - -ec ai.read rgb:8e2 -ec ai.write rgb:9e2 -ec ai.exec rgb:af2 -ec ai.seq rgb:ef0 -ec ai.ascii rgb:ef0 - -ec widget_bg rgb:ef0 rgb:060 -ec widget_sel black rgb:af2 diff --git a/dest/share/cons/mars b/dest/share/cons/mars deleted file mode 100644 index 2966dd102d6..00000000000 --- a/dest/share/cons/mars +++ /dev/null @@ -1,65 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Anton Kochkov -# SPDX-License-Identifier: LGPL-3.0-only - -ec b0x00 rgb:4f2526 -ec b0x7f rgb:727069 -ec b0xff rgb:443d35 -ec bin rgb:988c77 -ec btext rgb:abb0ce - -ec call rgb:f48d20 -ec ucall rgb:f07019 -ec jmp rgb:ee320b -ec ujmp rgb:a01a0a -ec cjmp rgb:871a0a - -ec args rgb:8e735c -ec cmp rgb:a0a0a0 -ec comment rgb:7f1609 -ec usrcmt rgb:d0e0b0 -ec reg rgb:fdf4cb -ec creg rgb:d0e0a0 -ec flag rgb:b0270e -ec fline rgb:dd0045 -ec flow rgb:f72 -ec flow2 rgb:fff -ec fname rgb:de0008 -ec help rgb:9a2813 -ec input rgb:f72 -ec label rgb:d20009 -ec math rgb:777 -ec mov rgb:ded0d0 -ec nop rgb:544 -ec num rgb:d10007 -ec offset rgb:686660 -ec other rgb:4c4040 -ec pop rgb:99300f -ec prompt rgb:8b1409 -ec push rgb:99300f -ec ret rgb:f55521 -ec swi rgb:ff7020 -ec trap rgb:f07020 -ec linehl rgb:111 - -ec graph.true rgb:e99e35 -ec graph.false rgb:9b260c -ec graph.ujump rgb:bf614a -ec graph.current rgb:fff862 -ec graph.traced rgb:f00005 -ec graph.box rgb:de3a0b -ec graph.box2 rgb:7c0003 -ec graph.box3 rgb:370001 -ec graph.box4 rgb:370001 - -ec func_var rgb:d18066 -ec func_var_type rgb:f07020 -ec func_var_addr rgb:82260e - -ec ai.read rgb:e0c0c0 -ec ai.write rgb:e0b0b0 -ec ai.exec rgb:e0a0a0 -ec ai.seq rgb:e09090 -ec ai.ascii rgb:f06050 - -ec widget_bg rgb:f07020 rgb:333 -ec widget_sel rgb:333 rgb:f07020 diff --git a/dest/share/cons/matrix b/dest/share/cons/matrix deleted file mode 100644 index af929acaa11..00000000000 --- a/dest/share/cons/matrix +++ /dev/null @@ -1,64 +0,0 @@ -# SPDX-FileCopyrightText: 2015 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -ec b0x00 rgb:030 -ec b0x7f rgb:0f0 -ec b0xff rgb:050 -ec bin rgb:0f0 -ec crypto rgb:0f0 -ec other rgb:0a0 -ec btext rgb:0b0 -ec ucall rgb:0b0 -ec call rgb:0b0 -ec ujmp rgb:2f2 -ec cjmp rgb:2f2 -ec jmp rgb:2f2 -ec cmp rgb:191 -ec comment rgb:060 -ec usrcmt rgb:3f3 -ec ret rgb:0b0 -ec fline rgb:0a0 -ec flow bgreen -ec flow2 green -ec fname rgb:0b0 -ec label rgb:0f0 -ec math rgb:040 -ec invalid rgb:060 -ec mov rgb:383 -ec nop rgb:030 -ec num rgb:3f3 -ec offset rgb:383 -ec pop rgb:040 -ec prompt rgb:080 -ec push rgb:060 -ec reg rgb:1a1 -ec args rgb:0b0 -ec help rgb:0b0 -ec input rgb:0a0 -ec trap rgb:040 -ec swi rgb:0b0 -ec creg rgb:080 -ec flag rgb:0f0 -ec linehl rgb:020 -ec graph.box green -ec graph.box2 rgb:060 -ec graph.box3 rgb:ff0000 -ec graph.box4 rgb:0000ff -ec graph.true green -ec graph.false rgb:050 -ec graph.ujump green -ec graph.current green -ec graph.traced rgb:060 - -ec func_var rgb:060 -ec func_var_type rgb:383 -ec func_var_addr rgb:060 - -ec ai.read rgb:0a1 -ec ai.write rgb:1a1 -ec ai.exec rgb:383 -ec ai.seq rgb:3f3 -ec ai.ascii rgb:3f3 - -ec widget_bg rgb:0b0 rgb:000 -ec widget_sel black rgb:0c0 diff --git a/dest/share/cons/monokai b/dest/share/cons/monokai deleted file mode 100644 index 58795353940..00000000000 --- a/dest/share/cons/monokai +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-FileCopyrightText: 2018 securisec -# SPDX-License-Identifier: LGPL-3.0-only - -ec b0x00 rgb:555 -ec b0x7f rgb:fff -ec b0xff rgb:eee -ec other rgb:888 -ec bin rgb:FFE792 -ec btext rgb:a398e5 -ec ucall rgb:f1c40f -ec call rgb:f1c40f -ec ujmp rgb:A6df2E -ec cjmp rgb:A6df2E -ec jmp rgb:A6df2E -ec cmp rgb:ef8d1a -ec comment rgb:66d9ef -ec usrcmt rgb:f92672 -ec ret rgb:d66 -ec num rgb:a398e5 -ec fline rgb:2bc -ec flow rgb:A6df2E -ec flow2 rgb:ddd -ec fname rgb:66d9ef -ec label rgb:66d9ef -ec math rgb:ddd -ec mov rgb:ddd -ec nop rgb:FFE792 -ec offset rgb:f92672 -ec prompt rgb:ef8d1a -ec pop rgb:ef8d1a -ec push rgb:ef8d1a -ec reg rgb:fff -ec args rgb:2bc -ec help rgb:ef8d1a -ec input rgb:888 -ec trap rgb:d66 -ec swi rgb:d66 -ec creg rgb:df7 -ec flag rgb:ef8d1a -ec linehl rgb:008 -ec ai.read rgb:66d -ec ai.write rgb:d66 -ec ai.exec rgb:6d6 -ec ai.ascii rgb:a398e5 -ec graph.box rgb:66d9ef -ec graph.box2 rgb:ef8d1a -ec graph.box3 rgb:66d9ef -ec graph.box4 rgb:66d9ef -ec graph.true rgb:A6df2E -ec graph.false rgb:f92672 -ec graph.ujump rgb:a398e5 -ec graph.current rgb:fff - -ec func_var cyan -ec func_var_type rgb:a398e5 -ec func_var_addr rgb:f92672 - -ec widget_bg rgb:f1c40f rgb:555 -ec widget_sel white rgb:f92672 diff --git a/dest/share/cons/nord b/dest/share/cons/nord deleted file mode 100644 index 87972ef750b..00000000000 --- a/dest/share/cons/nord +++ /dev/null @@ -1,63 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Anton Kochkov -# SPDX-License-Identifier: LGPL-3.0-only - -ec b0x00 rgb:6c768a -ec b0x7f rgb:81a1c1 -ec b0xff rgb:aba2a2 -ec bin rgb:eceff4 -ec btext rgb:ecefd4 -ec ucall rgb:bf604a -ec call rgb:bf616a -ec ujmp rgb:88c0df -ec cjmp rgb:88d0f0 -ec jmp rgb:88c0d0 -ec cmp rgb:5e81ac -ec comment rgb:b48ead -ec usrcmt rgb:a1a1c1 -ec ret rgb:81a1c1 -ec fline rgb:d8dee9 -ec flow rgb:88d0e0 -ec flow2 rgb:888 -ec fname rgb:8fbcbb -ec label rgb:ebcb8b -ec math rgb:d8dee9 -ec mov rgb:eceff4 -ec nop rgb:4c566a -ec num rgb:a3be97 -ec offset rgb:6c767a -ec other rgb:91b1d0 -ec pop rgb:e5e9f0 -ec prompt rgb:81a1c1 -ec push rgb:e5e9f0 -ec reg rgb:68e0e2 -ec args rgb:88d0f2 -ec help rgb:ebcb8c -ec input rgb:eeb366 -ec trap rgb:b47ead -ec swi rgb:b47ead -ec creg rgb:ed9366 -ec flag rgb:b3ceac -ec linehl rgb:004 - -ec graph.box rgb:d8dee9 -ec graph.box2 rgb:bf614a -ec graph.box3 rgb:4c566a -ec graph.box4 rgb:4c566a -ec graph.true rgb:a3be8c -ec graph.false rgb:bf616a -ec graph.ujump rgb:88c0df -ec graph.current rgb:81a1c1 -ec graph.traced rgb:93ae80 - -ec func_var rgb:d08770 -ec func_var_type rgb:ebcb8b -ec func_var_addr rgb:d8dee9 - -ec ai.read rgb:a97e9d -ec ai.write rgb:c07e9d -ec ai.exec rgb:e08ead -ec ai.seq rgb:f98ead -ec ai.ascii rgb:f9ceed - -ec widget_bg rgb:4cf rgb:344 -ec widget_sel black rgb:4cf diff --git a/dest/share/cons/ogray b/dest/share/cons/ogray deleted file mode 100644 index 4288694b046..00000000000 --- a/dest/share/cons/ogray +++ /dev/null @@ -1,66 +0,0 @@ -# SPDX-FileCopyrightText: 2014 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -ec b0x00 rgb:ccc -ec b0x7f rgb:777 -ec b0xff rgb:333 -ec args rgb:fff -ec bin rgb:fff -ec btext rgb:fff -ec call rgb:f72 rgb:333 -ec cjmp rgb:f72 -ec cmp rgb:aaa -ec comment rgb:f72 -ec usrcmt rgb:000 rgb:f72 -ec reg rgb:fff -ec creg rgb:f72 -ec flag rgb:f72 -ec fline rgb:aaa -ec flow rgb:f72 -ec flow2 rgb:fff -ec fname rgb:f72 -ec help rgb:f72 -ec input rgb:f72 -ec jmp rgb:f72 -ec label rgb:f72 -ec math rgb:777 -ec mov rgb:ddd -ec nop rgb:333 -ec num rgb:f72 -ec offset rgb:555 -ec other rgb:999 -ec pop rgb:999 -ec prompt rgb:f72 -ec push rgb:ddd -ec ret rgb:777 -ec swi rgb:f72 -ec trap rgb:f72 -ec ucall rgb:f72 rgb:333 -ec ujmp rgb:f72 -ec graph.true rgb:f72 -ec graph.false rgb:777 -ec graph.ujump rgb:ddd -ec graph.current rgb:f72 -ec graph.traced rgb:f00 -ec graph.box rgb:fff -ec graph.box2 rgb:f72 -ec graph.box3 rgb:000 -ec graph.box4 rgb:000 -ec gui.cflow rgb:f72 -ec gui.dataoffset rgb:f72 -ec crypto rgb:f72 -ec floc rgb:777 -ec linehl rgb:111 - -ec func_var rgb:f72 -ec func_var_type rgb:777 -ec func_var_addr rgb:555 - -ec ai.read rgb:eee -ec ai.write rgb:ddd -ec ai.exec rgb:fff -ec ai.seq rgb:f72 -ec ai.ascii rgb:f72 - -ec widget_bg rgb:f72 rgb:333 -ec widget_sel rgb:333 rgb:f72 diff --git a/dest/share/cons/onedark b/dest/share/cons/onedark deleted file mode 100644 index d8e1ed26db9..00000000000 --- a/dest/share/cons/onedark +++ /dev/null @@ -1,70 +0,0 @@ -# SPDX-FileCopyrightText: 2018 d4em0n -# SPDX-License-Identifier: LGPL-3.0-only - -#Inspired by onedark.vim -# e scr.color = 3 // to enable 16m color -ec func_var_type white -ec func_var rgb:61afef -ec func_var_addr rgb:4b5263 -ec b0x00 rgb:c678dd -ec b0xff rgb:be5046 -ec prompt rgb:d19a66 -ec fname rgb:56b6c2 -ec label rgb:0f3 -ec math rgb:660 -ec bin rgb:e5c07b -ec btext rgb:e5c07b -ec call rgb:e06c75 -ec ucall rgb:e06c75 -ec jmp rgb:c678dd -ec cjmp rgb:c678dd -ec ujmp rgb:c678dd -ec offset rgb:366 -ec comment rgb:56b6c2 -ec usrcmt rgb:ff0 -ec push rgb:61afef -ec pop rgb:61afef -ec cmp rgb:060 -ec nop rgb:abb2bf -ec num rgb:be5046 -ec reg rgb:e5c07b -ec fline rgb:fc0 -ec flow rgb:98c379 -ec flow2 rgb:98c379 -ec args rgb:d19a66 -ec floc rgb:fc0 -ec flag rgb:56b6c2 -ec label rgb:56b6c2 -ec help rgb:98c379 -ec input white -ec invalid rgb:e06c75 -ec crypto rgb:0000ff -ec ret rgb:be5046 -ec trap rgb:e06c75 -ec swi rgb:e06c75 -ec mov rgb:98c379 -ec creg rgb:e5c07b -ec ai.read rgb:98c379 -ec ai.write rgb:61afef -ec ai.exec rgb:e06c75 -ec ai.seq rgb:ff00ff -ec ai.ascii rgb:ffff00 -ec gui.cflow rgb:d19a66 -ec gui.dataoffset rgb:d19a66 -ec gui.background black -ec gui.alt_background white -ec gui.border black -ec linehl rgb:61afef -ec graph.box rgb:d19a66 -ec graph.box2 rgb:61afef -ec graph.box3 rgb:c678dd -ec graph.box4 rgb:000000 -ec graph.true rgb:98c379 -ec graph.false rgb:e06c75 -ec graph.ujump rgb:61afef -ec graph.current rgb:61afef -ec graph.traced rgb:d19a66 -ec linehl rgb:5c6370 - -ec widget_bg rgb:ec7 rgb:366 -ec widget_sel black rgb:98c379 diff --git a/dest/share/cons/pink b/dest/share/cons/pink deleted file mode 100644 index b138b4e7baf..00000000000 --- a/dest/share/cons/pink +++ /dev/null @@ -1,67 +0,0 @@ -# SPDX-FileCopyrightText: 2013 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -ec comment rgb:72d -ec help rgb:f5d -ec fname rgb:f5d -ec fline rgb:afd -ec flag rgb:f5d -ec label rgb:f5d -ec flow rgb:f5d -ec flow2 rgb:72d -ec prompt rgb:f5d -ec offset rgb:72d -ec input rgb:f5d -ec other rgb:d5a -ec b0x00 rgb:a27 -ec b0x7f rgb:55d -ec b0xff rgb:f5d -ec mov rgb:fff -ec bin rgb:fff -ec math rgb:fff -ec btext rgb:72d -ec push rgb:75a -ec pop rgb:75a -ec jmp rgb:f5d -ec cjmp rgb:f5d -ec ujmp rgb:f5d -ec usrcmt rgb:f5d rgb:502 -ec call rgb:000 rgb:faf -ec ucall rgb:000 rgb:faf -ec nop rgb:fa5 -ec ret rgb:ffa -ec trap rgb:a22 -ec swi rgb:255 -ec cmp rgb:a7f -ec reg rgb:f5d -ec creg rgb:f5d -ec num rgb:72d -ec crypto rgb:75d -ec linehl rgb:fdf -ec graph.true rgb:f5d -ec graph.false rgb:715 -ec graph.ujump rgb:f5d -ec graph.current rgb:f5d -ec graph.traced rgb:a7f -ec graph.box rgb:f5d -ec graph.box2 rgb:f5d -ec graph.box3 rgb:f5d -ec graph.box4 rgb:f5d -ec gui.cflow rgb:f5d -ec gui.dataoffset rgb:f5d -ec gui.background black -## gui.alt_background -## gui.border - -ec func_var rgb:72d -ec func_var_type blue -ec func_var_addr rgb:72d - -ec ai.read rgb:f6e -ec ai.write rgb:f5d -ec ai.exec rgb:75a -ec ai.seq rgb:72d -ec ai.ascii rgb:72d - -ec widget_bg rgb:72d rgb:222 -ec widget_sel white rgb:f5d diff --git a/dest/share/cons/rasta b/dest/share/cons/rasta deleted file mode 100644 index 3a54c3825e8..00000000000 --- a/dest/share/cons/rasta +++ /dev/null @@ -1,68 +0,0 @@ -# SPDX-FileCopyrightText: 2014 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -ec comment green -ec usrcmt yellow -ec fname yellow -ec fline green -ec flag green -ec label yellow -ec flow green -ec flow2 yellow -ec floc green -ec prompt green -ec offset yellow -ec input green -ec other green -ec b0x00 yellow -ec b0x7f green -ec b0xff red -ec math yellow -ec bin green -ec btext red -ec push yellow -ec pop green -ec jmp red -ec cjmp red -ec ujmp red -ec call red -ec ucall red -ec nop red -ec ret yellow -ec trap green -ec swi red -ec cmp yellow -ec reg green -ec num red -ec mov yellow -ec crypto yellow -ec args green -ec help yellow -ec input green -ec trap red -ec swi red -ec creg green -ec flag yellow -ec linehl rgb:008 -ec graph.box yellow -ec graph.box2 green -ec graph.box3 red -ec graph.box4 red -ec graph.true green -ec graph.false red -ec graph.ujump green -ec graph.current green -ec graph.traced yellow - -ec func_var green -ec func_var_type red -ec func_var_addr yellow - -ec ai.read green -ec ai.write green -ec ai.exec yellow -ec ai.seq red -ec ai.ascii red - -ec widget_bg yellow black -ec widget_sel black green diff --git a/dest/share/cons/sepia b/dest/share/cons/sepia deleted file mode 100644 index d126bc31af1..00000000000 --- a/dest/share/cons/sepia +++ /dev/null @@ -1,81 +0,0 @@ -# SPDX-FileCopyrightText: 2018 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -# requires e scr.color=3 - -ec b0x00 rgb:431 -ec b0x7f rgb:fd9 -ec b0xff rgb:960 -ec bin rgb:fec -ec crypto rgb:0000ff -ec other rgb:ba6 -ec btext rgb:fec -ec ucall rgb:ffffff -ec call rgb:ffffff -ec ujmp rgb:fec -ec cjmp rgb:fec -ec jmp rgb:fec -ec cmp rgb:ca6 -ec comment rgb:fd9 -ec usrcmt rgb:fff -ec ret rgb:ab7 -ec fline rgb:ca6 -ec floc rgb:00ffff -ec flow rgb:ca6 -ec flow2 rgb:fec -ec fname rgb:bb7 -ec label rgb:788 -ec math rgb:db7 -ec invalid rgb:c64 -ec mov rgb:db7 -ec nop rgb:788 -ec num rgb:960 -ec offset rgb:960 -ec pop rgb:bb7 -ec prompt rgb:960 -ec push rgb:db7 -ec reg rgb:ca6 -ec args rgb:bb7 -ec help rgb:ab7 -ec input rgb:ca6 -ec trap rgb:431 -ec swi rgb:bb7 -ec creg rgb:960 -ec flag rgb:ffd -ec wordhl rgb:ff0000 -ec linehl rgb:210 -ec meta rgb:767676 -ec graph.true rgb:fd9 -ec graph.false rgb:431 -ec graph.ujump rgb:fd9 -ec graph.current rgb:0000ff -ec graph.traced rgb:0000ff -ec graph.box rgb:431 -ec graph.box2 rgb:ca6 -ec graph.box3 rgb:ca6 -ec graph.box4 rgb:ca6 -ec gui.cflow rgb:ffff00 -ec gui.dataoffset rgb:ffff00 -ec gui.alt_background rgb:ffffff -ec gui.background rgb:000000 -ec gui.border rgb:000000 - -ec func_var rgb:fd9 -ec func_var_type rgb:850 -ec func_var_addr rgb:960 - -ec ai.read rgb:cb7 -ec ai.write rgb:ca6 -ec ai.exec rgb:db7 -ec ai.seq rgb:960 -ec ai.ascii rgb:fec - -ec widget_bg rgb:db7 rgb:000000 -ec widget_sel rgb:000000 rgb:fec - -# Linux default colors (need to be sepiaized) - -ec diff.unknown rgb:881798 -ec diff.new rgb:c50f1f -ec diff.match rgb:767676 -ec diff.unmatch rgb:c19c00 diff --git a/dest/share/cons/smyck b/dest/share/cons/smyck deleted file mode 100644 index b12ec7f4164..00000000000 --- a/dest/share/cons/smyck +++ /dev/null @@ -1,61 +0,0 @@ -# SPDX-FileCopyrightText: 2014 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -# ref: http://color.smyck.org/ -ec b0x00 rgb:222 -ec b0x7f rgb:fff -ec b0xff rgb:eee -ec other rgb:888 -ec bin rgb:888 -ec btext white -ec ucall rgb:9f4 -ec call rgb:9f4 -ec ujmp rgb:9c4 -ec cjmp rgb:9c4 -ec jmp rgb:9c4 -ec cmp rgb:888 -ec comment rgb:9df -ec usrcmt rgb:9f4 -ec ret rgb:d66 -ec num rgb:bb5 -ec fline rgb:2bc -ec flow rgb:888 -ec flow2 rgb:ddd -ec fname rgb:9df -ec label rgb:9df -ec math rgb:ddd -ec mov rgb:ddd -ec nop rgb:444 -ec offset rgb:bb5 -ec prompt rgb:bb5 -ec pop rgb:fd6 -ec push rgb:fd6 -ec reg rgb:fff -ec args rgb:2bc -ec help rgb:fd6 -ec input rgb:888 -ec trap rgb:d66 -ec swi rgb:d66 -ec creg rgb:df7 -ec flag rgb:9df -ec linehl rgb:004 -ec ai.read rgb:66d -ec ai.write rgb:d66 -ec ai.exec rgb:6d6 -ec ai.seq rgb:fd6 -ec ai.ascii white -ec graph.box rgb:9df -ec graph.box2 rgb:9df -ec graph.box3 rgb:9df -ec graph.box4 rgb:9df -ec graph.true rgb:9c4 -ec graph.false rgb:d66 -ec graph.ujump rgb:9c4 -ec graph.current rgb:fff - -ec func_var rgb:9df -ec func_var_type rgb:fd6 -ec func_var_addr rgb:bb5 - -ec widget_bg rgb:bb5 rgb:222 -ec widget_sel black rgb:9c4 diff --git a/dest/share/cons/solarized b/dest/share/cons/solarized deleted file mode 100644 index ad5f92fbc56..00000000000 --- a/dest/share/cons/solarized +++ /dev/null @@ -1,66 +0,0 @@ -# SPDX-FileCopyrightText: 2014 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -ec b0x00 rgb:033 -ec b0x7f rgb:033 -ec b0xff rgb:577 -ec bin rgb:688 -ec btext rgb:899 -ec ucall rgb:890 -ec call rgb:890 #b80 -ec ujmp rgb:890 -ec cjmp rgb:890 # b80 #ee8 -ec jmp rgb:e37 -ec cmp rgb:c41 # ffe -ec comment rgb:28d -ec usrcmt rgb:890 -ec ret rgb:899 -ec fline rgb:b80 -ec flow rgb:3a9 -ec flow2 rgb:577 -ec fname rgb:d33 -ec label rgb:77c -ec math rgb:28d -ec mov rgb:3a9 -ec nop rgb:577 -ec num rgb:eee -ec offset rgb:9aa -ec other rgb:577 -ec pop rgb:688 -ec prompt rgb:c41 -ec push rgb:e37 -ec reg rgb:de8 -ec args rgb:de8 -ec help rgb:e37 -ec input rgb:c41 -ec trap rgb:f00 -ec swi rgb:f00 -ec creg rgb:de8 -ec flag rgb:c41 -ec linehl rgb:004 - -ec graph.box rgb:033 -ec graph.box2 rgb:de8 -ec graph.box3 rgb:033 -ec graph.box4 rgb:033 -ec graph.true rgb:890 -ec graph.false rgb:c41 -ec graph.ujump rgb:899 -ec graph.current rgb:f00 -ec graph.traced red - -ec func_var rgb:28d -ec func_var_type rgb:cc8 -ec func_var_addr rgb:9aa - -ec ai.read rgb:39e -ec ai.write rgb:577 -ec ai.exec rgb:ab4 -ec ai.seq rgb:899 -ec ai.ascii rgb:899 - -# background of the terminal must be 134 o 033 -# xterm -fn 10x20 -bg rgb:00/30/30 -fg rgb:e0/e0/e0 -e "rizin -c 'eco solarized' /bin/ls" - -ec widget_bg rgb:bb5 rgb:033 -ec widget_sel white rgb:c41 diff --git a/dest/share/cons/tango b/dest/share/cons/tango deleted file mode 100644 index b5548c95e02..00000000000 --- a/dest/share/cons/tango +++ /dev/null @@ -1,81 +0,0 @@ -# SPDX-FileCopyrightText: 2014 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -# background of the terminal must be 134 o 033 -# xterm -fn 10x20 -bg rgb:20/20/20 -fg rgb:d0/d0/d0 -# ref: https://github.com/eugeneching/ida-consonance/blob/master/ida-consonance.clr - -# LIGHT MEDIUM DARK -# Butter fe5 ed0 ca0 -# Orange fa3 f70 c50 -# Chocolate eb6 c71 950 -# Chameleon 8e3 7d1 590 -# Sky Blue 79c 36a 248 -# Plum a7a 757 536 -# Scarlet Red e22 c00 a00 -# Aluminium eee ddd bbb -# DarkAluminium 888 555 333 - -# DARK THEME - -ec b0x00 rgb:757 -ec b0x7f rgb:c50 -ec b0xff rgb:950 -ec btext rgb:ca0 - -ec bin rgb:bbb -ec ucall rgb:7d1 -ec call rgb:7d1 -ec ujmp rgb:370 -ec cjmp rgb:370 -ec jmp rgb:370 -ec cmp rgb:bbb -ec comment rgb:370 -ec usrcmt rgb:7d1 -ec ret rgb:248 -ec fline rgb:950 -ec flow rgb:248 -ec flow2 rgb:248 -ec fname rgb:ca0 -ec label rgb:c50 -ec math rgb:bbb -ec mov rgb:bbb -ec nop rgb:333 -ec num rgb:ca0 -ec offset rgb:bbb -ec other rgb:950 -ec pop rgb:757 -ec prompt rgb:950 -ec push rgb:757 -ec reg rgb:c50 -ec args rgb:ca0 -ec help rgb:ddd -ec input rgb:ca0 -ec trap rgb:a00 -ec swi rgb:950 -ec creg rgb:590 -ec flag rgb:950 -ec linehl rgb:004 - -ec graph.true rgb:370 -ec graph.false rgb:a00 -ec graph.ujump rgb:bbb -ec graph.current rgb:7d1 -ec graph.traced rgb:f00 -ec graph.box rgb:950 -ec graph.box2 rgb:7d1 -ec graph.box3 rgb:950 -ec graph.box4 rgb:950 - -ec func_var rgb:370 -ec func_var_type rgb:a41 -ec func_var_addr rgb:aaa - -ec ai.read rgb:a81 -ec ai.write rgb:a41 -ec ai.exec rgb:c50 -ec ai.seq rgb:ca0 -ec ai.ascii rgb:ca0 - -ec widget_bg rgb:bb5 rgb:030 -ec widget_sel black rgb:840 diff --git a/dest/share/cons/twilight b/dest/share/cons/twilight deleted file mode 100644 index 973963593c1..00000000000 --- a/dest/share/cons/twilight +++ /dev/null @@ -1,67 +0,0 @@ -# SPDX-FileCopyrightText: 2014 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -# background of the terminal must be 134 o 033 -# xterm -fn 10x20 -bg rgb:14/14/14 -fg rgb:fe/ff/d3 -# ref: https://github.com/eugeneching/ida-consonance/blob/master/ida-consonance.clr - -ec b0x00 rgb:446 -ec b0x7f rgb:c64 -ec b0xff rgb:c64 -ec bin rgb:ffd -ec other rgb:aaa -ec btext rgb:bb7 -ec ucall rgb:9b7 -ec call rgb:9b7 -ec ujmp rgb:788 -ec cjmp rgb:788 -ec jmp rgb:788 -ec cmp rgb:ffd -ec comment rgb:c64 -ec usrcmt rgb:9b7 -ec ret rgb:ab7 -ec fline rgb:ca6 -ec flow rgb:446 -ec flow2 rgb:446 -ec fname rgb:bb7 -ec label rgb:788 -ec math rgb:ffd -ec invalid rgb:c64 -ec mov rgb:ffd -ec nop rgb:445 -ec num rgb:ffd -ec offset rgb:788 -ec pop rgb:bb7 -ec prompt rgb:788 -ec push rgb:ffd -ec reg rgb:ca6 -ec args rgb:bb7 -ec help rgb:ab7 -ec input rgb:ca6 -ec trap rgb:445 -ec swi rgb:bb7 -ec creg rgb:788 -ec flag rgb:ffd -ec linehl rgb:004 -ec graph.true rgb:9b7 -ec graph.false rgb:b97 -ec graph.ujump rgb:64c -ec graph.current blue -ec graph.traced blue -ec graph.box rgb:9b7 -ec graph.box2 rgb:b97 -ec graph.box3 rgb:b97 -ec graph.box4 rgb:b97 - -ec func_var rgb:c64 -ec func_var_type rgb:aa6 -ec func_var_addr rgb:788 - -ec ai.read rgb:db7 -ec ai.write rgb:ca6 -ec ai.exec rgb:ffd -ec ai.seq rgb:bb7 -ec ai.ascii rgb:bb7 - -ec widget_bg rgb:ffd rgb:344 -ec widget_sel black rgb:ca6 diff --git a/dest/share/cons/white b/dest/share/cons/white deleted file mode 100644 index 1e58611cf07..00000000000 --- a/dest/share/cons/white +++ /dev/null @@ -1,62 +0,0 @@ -# SPDX-FileCopyrightText: 2013 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -ec label rgb:c60 -ec help blue -ec math blue -ec bin blue -ec crypto magenta -ec other blue -ec push black -ec pop black -ec cmp magenta -ec nop black -ec jmp blue -ec cjmp magenta -ec ujmp green -ec call magenta white bold -ec ucall magenta white bold -ec input black -ec fline green -ec prompt black -ec flag blue -ec fname blue -ec comment magenta -ec usrcmt green -ec reg blue -ec creg blue -ec trap red -ec swi green -ec num blue -ec b0x7f gray -ec b0xff red -ec b0x00 rgb:777 -ec btext black -ec offset black -ec flow blue -ec flow2 green -ec mov black -ec invalid red -ec linehl rgb:ff0 -ec graph.box blue -ec graph.box2 green -ec graph.box3 red -ec graph.box4 blue -ec graph.true green -ec graph.false red -ec graph.ujump blue -ec graph.current rgb:0ff -ec graph.traced red - -ec func_var magenta -ec func_var_type blue -ec func_var_addr magenta - -ec ai.read magenta -ec ai.write magenta -ec ai.exec blue -ec ai.seq black -ec ai.ascii black - -ec widget_bg blue white -ec widget_sel black yellow diff --git a/dest/share/cons/white2 b/dest/share/cons/white2 deleted file mode 100644 index 41ae34c124d..00000000000 --- a/dest/share/cons/white2 +++ /dev/null @@ -1,58 +0,0 @@ -# SPDX-FileCopyrightText: 2018 securisec -# SPDX-License-Identifier: LGPL-3.0-only - -ec ai.exec rgb:6d6 -ec ai.read rgb:66d -ec ai.write rgb:d66 -ec args rgb:2bc -ec b0x00 rgb:878585 # 00 bytes -ec b0x7f rgb:fff -ec b0xff rgb:abb0b6 # ff bytes -ec bin rgb:4F1900 0 bold # operations like xor -ec btext rgb:66737f # text section opcode? first byte of opcode -ec call rgb:A63A00 0 bold # call instructions -ec cjmp rgb:376B4C 0 bold underline # je, jg, etc -ec cmp rgb:F92672 0 bold # cmp instructions -ec comment rgb:001296 0 italic # rizin renerated comments -ec creg rgb:025F49 rgb:BFFFCB # modified registries -ec flag rgb:912D3A 0 bold # flags. usually apprears above the current seek -ec fline rgb:8D0004 # function line. the boundary of a function -ec flow rgb:376B4C # lines that show jump destinations -ec flow2 rgb:ddd -ec fname rgb:8D0004 0 bold italic # function name -ec graph.box rgb:007D96 # unselected boxes in visual graph mode -ec graph.box2 rgb:D100A7 # currently selected box in visual graph mode -ec graph.box3 rgb:66d9ef -ec graph.box4 rgb:66d9ef -ec graph.current rgb:fff -ec graph.false rgb:990000 # false line on visual graph mode -ec graph.true rgb:376B4C # true line on visual graph mode -ec graph.ujump rgb:007D96 # lines in graph that does not have true or false -ec help rgb:2F6F9F 0 italic # color of help explanation text -ec input rgb:888 -ec jmp rgb:376B4C 0 bold underline # jmp instructions -ec label rgb:66d9ef -ec linehl rgb:42505e # highlight color when using asm.highlight -ec math rgb:761B48 0 bold # math instructions like sub, add -ec mov black -ec nop rgb:a37acc # nop instructions -ec num rgb:761B48 # numbers -ec offset rgb:2F6F9F # offset in visual mode -ec other rgb:4D4D4D -ec pop rgb:ff7733 # pop instructions -ec prompt rgb:2F6F9F 0 bold # color for main rizin prompt -ec push rgb:ff7733 # push instructions -ec reg rgb:400080 # register names -ec ret rgb:F92672 0 bold # ret opcode -ec swi rgb:d66 -ec trap rgb:d66 -ec ucall rgb:A63A00 0 bold -ec ujmp rgb:376B4C 0 bold underline -ec usrcmt rgb:007D96 0 bold # user comment - -ec func_var rgb:400080 # var name in function -ec func_var_type rgb:305F65 0 italic # function variable -ec func_var_addr magenta - -ec widget_bg rgb:2f6f9f white -ec widget_sel white rgb:f73 bold diff --git a/dest/share/cons/xvilka b/dest/share/cons/xvilka deleted file mode 100644 index 67952be764a..00000000000 --- a/dest/share/cons/xvilka +++ /dev/null @@ -1,70 +0,0 @@ -# SPDX-FileCopyrightText: 2013 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -ec prompt yellow -ec fname rgb:0cf -ec label rgb:0f3 -ec math rgb:660 -ec bin rgb:f90 -ec call red -ec ucall red -ec jmp rgb:03f -ec cjmp rgb:33c -ec ujmp rgb:330 -ec offset rgb:366 -ec comment rgb:0cf -ec usrcmt rgb:ff0 rgb:06f -ec push rgb:0c0 -ec pop rgb:0c0 -ec cmp rgb:060 -ec nop rgb:777 -ec b0x00 rgb:444 -ec b0x7f rgb:555 -ec b0xff rgb:666 -ec btext rgb:777 -ec other rgb:bbb -ec num rgb:f03 -ec reg rgb:6f0 -ec fline rgb:fc0 -ec flow rgb:0f0 -ec flow2 rgb:0f0 -ec args yellow -ec floc rgb:fc0 -ec flag rgb:0cf -ec label rgb:0cf -ec help green -ec input white -ec invalid red -ec crypto rgb:0000ff -ec ret rgb:ff0000 -ec trap red -ec swi red -ec mov white -ec creg rgb:6f0 -ec linehl rgb:004 -ec ai.read green -ec ai.write blue -ec ai.exec red -ec ai.seq rgb:ff00ff -ec ai.ascii rgb:ffff00 -ec graph.box yellow -ec graph.box2 blue -ec graph.box3 magenta -ec graph.box4 rgb:000000 -ec graph.true green -ec graph.false red -ec graph.ujump blue -ec graph.current blue -ec graph.traced yellow -ec gui.cflow yellow -ec gui.dataoffset yellow -ec gui.background black -ec gui.alt_background white -ec gui.border black - -ec func_var rgb:0cf -ec func_var_type rgb:0c0 -ec func_var_addr rgb:366 - -ec widget_bg green rgb:255 -ec widget_sel white rgb:336 bold diff --git a/dest/share/cons/zenburn b/dest/share/cons/zenburn deleted file mode 100644 index 4370ec231a6..00000000000 --- a/dest/share/cons/zenburn +++ /dev/null @@ -1,67 +0,0 @@ -# SPDX-FileCopyrightText: 2014 pancake -# SPDX-License-Identifier: LGPL-3.0-only - -# background of the terminal must be 134 o 033 # xterm -fn 10x20 -bg rgb:20/20/20 -fg rgb:ff/ff/c7 -# ref: https://github.com/eugeneching/ida-consonance/blob/master/ida-consonance.clr - -ec b0x00 rgb:8a8 -ec b0x7f rgb:aaa -ec b0xff rgb:8a8 -ec bin rgb:fcb -ec other rgb:aaa -ec btext rgb:ddc -ec ucall rgb:d52 -ec call rgb:d52 -ec ujmp rgb:d52 -ec cjmp rgb:d52 -ec jmp rgb:d52 -ec cmp rgb:ff8 -ec comment rgb:7a7 -ec usrcmt rgb:d52 -ec ret rgb:ff8 -ec fline rgb:ddc -ec flow rgb:d50 -ec flow2 rgb:d50 -ec fname rgb:d50 -ec label rgb:d50 -ec math rgb:daa -ec invalid rgb:ff8 -ec mov rgb:cd9 -ec nop rgb:8a8 -ec num rgb:c88 -ec offset rgb:aaa -ec pop rgb:ffc -ec prompt rgb:d50 -ec push rgb:ffc -ec reg rgb:8dd -ec args rgb:7a7 -ec help rgb:ffc -ec input rgb:da8 -ec trap rgb:d22 -ec swi rgb:d22 -ec creg rgb:ccc -ec flag rgb:d50 -ec linehl rgb:004 - -ec graph.box rgb:aaa -ec graph.box2 rgb:d52 -ec graph.box3 rgb:aaa -ec graph.box4 rgb:aaa -ec graph.true rgb:aaa -ec graph.false rgb:d52 -ec graph.ujump rgb:aaa -ec graph.current blue -ec graph.traced red - -ec func_var rgb:7a7 -ec func_var_type rgb:eec -ec func_var_addr rgb:aaa - -ec ai.read rgb:f87 -ec ai.write rgb:c88 -ec ai.exec rgb:cd9 -ec ai.seq rgb:ddc -ec ai.ascii rgb:ddc - -ec widget_bg rgb:8dd rgb:333 -ec widget_sel white rgb:b52 bold diff --git a/dest/share/flag/tags.rz b/dest/share/flag/tags.rz deleted file mode 100644 index bd233e2aefc..00000000000 --- a/dest/share/flag/tags.rz +++ /dev/null @@ -1,10 +0,0 @@ -ft dylib dlopen dlsym dlclose mmap LoadLibrary GetProcAddress -ft alloc malloc free$ calloc kalloc realloc -ft time settimeofday gettimeofday time adjtime ctime timed date$ sleep Sleep usleep clock_nanosleep localtime asctime difftime gmtime mktime timelocal timegm tzfile tzset -ft env getenv putenv unsetenv setenv GetEnvironmentVariable SetEnvironmentVariable ExpandEnvironmentStrings -ft fs open$ close read$ write CloseHandle FindFirstFileW _wfopen _wstat ftruncate lseek _chsize GetFullPathName realpath RemoveDirectory DeleteFile CreateFile WriteFile UnmapViewOfFile CreateFileMapping MapViewOfFile readlink chmod fchmod chown stat fstat lstat fstatat lstat64 stat64 chflags fchflags lchflags -ft network socket connect bind$ listen accept sendto recvfrom gethostbyname htons ntohs -ft threads pthread_create pthread_mutex_init pthread_cond_init CreateThread TerminateThread WaitForSingleObject GetCurrentThreadId -ft process getpid getppid kill exit abort assert gethostid sethostid sysctl -ft stdout ^printf puts write -ft string strcat strcpy strncpy strlen strtok strstr strlcpy asprintf sprintf snprintf diff --git a/dest/share/format/elf32 b/dest/share/format/elf32 deleted file mode 100644 index 5780890b9f6..00000000000 --- a/dest/share/format/elf32 +++ /dev/null @@ -1,5 +0,0 @@ -pfo elf_enums -pfn elf_ident "[4]z[1]E[1]E[1]E.:: magic (elf_class)class (elf_data)data (elf_hdr_version)version" -pfn elf_header "?[2]E[2]E[4]ExxxxN2N2N2N2N2N2 (elf_ident)ident (elf_type)type (elf_machine)machine (elf_obj_version)version entry phoff shoff flags ehsize phentsize phnum shentsize shnum shstrndx" -pfn elf_phdr "[4]Exxxxx[4]Ex (elf_p_type)type offset vaddr paddr filesz memsz (elf_p_flags)flags align" -pfn elf_shdr "x[4]E[4]Exxxxxxx name (elf_s_type)type (elf_s_flags_32)flags addr offset size link info addralign entsize" diff --git a/dest/share/format/elf64 b/dest/share/format/elf64 deleted file mode 100644 index aca563c394f..00000000000 --- a/dest/share/format/elf64 +++ /dev/null @@ -1,5 +0,0 @@ -pfo elf_enums -pfn elf_ident "[4]z[1]E[1]E[1]E.:: magic (elf_class)class (elf_data)data (elf_hdr_version)version" -pfn elf_header "?[2]E[2]E[4]EqqqxN2N2N2N2N2N2 (elf_ident)ident (elf_type)type (elf_machine)machine (elf_obj_version)version entry phoff shoff flags ehsize phentsize phnum shentsize shnum shstrndx" -pfn elf_phdr "[4]E[4]Eqqqqqq (elf_p_type)type (elf_p_flags)flags offset vaddr paddr filesz memsz align" -pfn elf_shdr "x[4]E[8]Eqqqxxqq name (elf_s_type)type (elf_s_flags_64)flags addr offset size link info addralign entsize" diff --git a/dest/share/format/elf_enums b/dest/share/format/elf_enums deleted file mode 100644 index bd24164b44a..00000000000 --- a/dest/share/format/elf_enums +++ /dev/null @@ -1,15 +0,0 @@ -td "enum elf_type {ET_NONE=0, ET_REL=1, ET_EXEC=2, ET_DYN=3, ET_CORE=4, ET_LOOS=0xfe00, ET_HIOS=0xfeff, ET_LOPROC=0xff00, ET_HIPROC=0xffff};" -td "enum elf_machine {EM_NONE=0, EM_M32=1, EM_SPARC=2, EM_386=3, EM_68K=4, EM_88K=5, EM_IAMCU=6, EM_860=7, EM_MIPS=8, EM_S370=9, EM_MIPS_RS3_LE=10, EM_RS6000=11, EM_PARISC=15, EM_nCUBE=16, EM_VPP500=17, EM_SPARC32PLUS=18, EM_960=19, EM_PPC=20, EM_PPC64=21, EM_S390=22, EM_SPU=23, EM_V800=36, EM_FR20=37, EM_RH32=38, EM_RCE=39, EM_ARM=40, EM_ALPHA=41, EM_SH=42, EM_SPARCV9=43, EM_TRICORE=44, EM_ARC=45, EM_H8_300=46, EM_H8_300H=47, EM_H8S=48, EM_H8_500=49, EM_IA_64=50, EM_MIPS_X=51, EM_COLDFIRE=52, EM_68HC12=53, EM_MMA=54, EM_PCP=55, EM_NCPU=56, EM_NDR1=57, EM_STARCORE=58, EM_ME16=59, EM_ST100=60, EM_TINYJ=61, EM_X86_64=62, EM_PDSP=63, EM_PDP10=64, EM_PDP11=65, EM_FX66=66, EM_ST9PLUS=67, EM_ST7=68, EM_68HC16=69, EM_68HC11=70, EM_68HC08=71, EM_68HC05=72, EM_SVX=73, EM_ST19=74, EM_VAX=75, EM_CRIS=76, EM_JAVELIN=77, EM_FIREPATH=78, EM_ZSP=79, EM_MMIX=80, EM_HUANY=81, EM_PRISM=82, EM_AVR=83, EM_FR30=84, EM_D10V=85, EM_D30V=86, EM_V850=87, EM_M32R=88, EM_MN10300=89, EM_MN10200=90, EM_PJ=91, EM_OPENRISC=92, EM_ARC_COMPACT=93, EM_XTENSA=94, EM_VIDEOCORE=95, EM_TMM_GPP=96, EM_NS32K=97, EM_TPC=98, EM_SNP1K=99, EM_ST200=100, EM_IP2K=101, EM_MAX=102, EM_CR=103, EM_F2MC16=104, EM_MSP430=105, EM_BLACKFIN=106, EM_SE_C33=107, EM_SEP=108, EM_ARCA=109, EM_UNICORE=110, EM_EXCESS=111, EM_DXP=112, EM_ALTERA_NIOS2=113, EM_CRX=114, EM_XGATE=115, EM_C166=116, EM_M16C=117, EM_DSPIC30F=118, EM_CE=119, EM_M32C=120, EM_TSK3000=131, EM_RS08=132, EM_SHARC=133, EM_ECOG2=134, EM_SCORE7=135, EM_DSP24=136, EM_VIDEOCORE3=137, EM_LATTICEMICO32=138, EM_SE_C17=139, EM_TI_C6000=140, EM_TI_C2000=141, EM_TI_C5500=142, EM_TI_ARP32=143, EM_TI_PRU=144, EM_MMDSP_PLUS=160, EM_CYPRESS_M8C=161, EM_R32C=162, EM_TRIMEDIA=163, EM_HEXAGON=164, EM_8051=165, EM_STXP7X=166, EM_NDS32=167, EM_ECOG1X=168, EM_MAXQ30=169, EM_XIMO16=170, EM_MANIK=171, EM_CRAYNV2=172, EM_RX=173, EM_METAG=174, EM_MCST_ELBRUS=175, EM_ECOG16=176, EM_CR16=177, EM_ETPU=178, EM_SLE9X=179, EM_L10M=180, EM_K10M=181, EM_AARCH64=183, EM_AVR32=185, EM_STM8=186, EM_TILE64=187, EM_TILEPRO=188, EM_CUDA=190, EM_TILEGX=191, EM_CLOUDSHIELD=192, EM_COREA_1ST=193, EM_COREA_2ND=194, EM_ARC_COMPACT2=195, EM_OPEN8=196, EM_RL78=197, EM_VIDEOCORE5=198, EM_78KOR=199, EM_56800EX=200, EM_BA1=201, EM_BA2=202, EM_XCORE=203, EM_MCHP_PIC=204, EM_INTEL205=205, EM_INTEL206=206, EM_INTEL207=207, EM_INTEL208=208, EM_INTEL209=209, EM_KM32=210, EM_KMX32=211, EM_KMX16=212, EM_KMX8=213, EM_KVARC=214, EM_CDP=215, EM_COGE=216, EM_COOL=217, EM_NORC=218, EM_CSR_KALIMBA=219, EM_AMDGPU=224, EM_RISCV=243, EM_LANAI=244, EM_BPF=247, EM_CSKY=252, EM_KVX=256};" -td "enum elf_class {ELFCLASSNONE=0, ELFCLASS32=1, ELFCLASS64=2};" -td "enum elf_data {ELFDATANONE=0, ELFDATA2LSB=1, ELFDATA2MSB=2};" -td "enum elf_hdr_version {EV_NONE=0, EV_CURRENT=1};" -td "enum elf_osabi {ELFOSABI_NONE=0,ELFOSABI_HPUX=1, ELFOSABI_NETBSD=2,ELFOSABI_SOLARIS=6,ELFOSABI_AIX=7,ELFOSABI_IRIX=8,ELFOSABI_FREEBSD=9,ELFOSABI_TRU64=10,ELFOSABI_MODESTO=11,ELFOSABI_OPENBSD=12,ELFOSABI_OPENVMS=13,ELFOSABI_NSK=14,ELFOSABI_AROS=15};" -td "enum elf_obj_version {EV_NONE=0, EV_CURRENT=1};" -td "enum elf_p_type {PT_NULL=0,PT_LOAD=1,PT_DYNAMIC=2,PT_INTERP=3,PT_NOTE=4,PT_SHLIB=5,PT_PHDR=6,PT_LOOS=0x60000000,PT_HIOS=0x6fffffff,PT_LOPROC=0x70000000,PT_HIPROC=0x7fffffff};" -td "enum elf_p_flags {PF_None=0,PF_Exec=1,PF_Write=2,PF_Write_Exec=3,PF_Read=4,PF_Read_Exec=5,PF_Read_Write=6,PF_Read_Write_Exec=7};" -td "enum elf_s_name {SHN_UNDEF=0,SHN_LORESERVE=0xff00,SHN_LOPROC=0xff00,SHN_HIPROC=0xff1f,SHN_LOOS=0xff20,SHN_HIOS=0xff3f,SHN_ABS=0xfff1,SHN_COMMON=0xfff2,SHN_HIRESERVE=0xffff};" -td "enum elf_s_type {SHT_NULL=0,SHT_PROGBITS=1,SHT_SYMTAB=2,SHT_STRTAB=3,SHT_RELA=4,SHT_HASH=5,SHT_DYNAMIC=6,SHT_NOTE=7,SHT_NOBITS=8,SHT_REL=9,SHT_SHLIB=10,SHT_DYNSYM=11,SHT_LOOS=0x60000000,SHT_HIOS=0x6fffffff,SHT_LOPROC=0x70000000,SHT_HIPROC=0x7fffffff};" -td "enum elf_s_flags_32 {SF32_None=0,SF32_Exec=1,SF32_Alloc=2,SF32_Alloc_Exec=3,SF32_Write=4,SF32_Write_Exec=5,SF32_Write_Alloc=6,SF32_Write_Alloc_Exec=7};" -td "enum elf_s_flags_64 {SF64_None=0,SF64_Exec=1,SF64_Alloc=2,SF64_Alloc_Exec=3,SF64_Write=4,SF64_Write_Exec=5,SF64_Write_Alloc=6,SF64_Write_Alloc_Exec=7};" -td "enum elf_sym_info_bind_e {STB_LOCAL=0,STB_GLOBAL=1,STB_WEAK=2,STB_OS_1=10,STB_OS_2=11,STB_OS_3=12,STB_PROC_1=13,STB_PROC_2=14,STB_PROC_3=15};" -td "enum elf_sym_info_type_e {STT_NOTYPE=0,STT_OBJECT=1,STT_FUNC=2,STT_SECTION=3,STT_FILE=4,STT_OS_1=10,STT_OS_2=11,STT_OS_3=12,STT_PROC_1=13,STT_PROC_2=14,STT_PROC_3=15};" diff --git a/dest/share/format/mz b/dest/share/format/mz deleted file mode 100644 index 4a48ff0046e..00000000000 --- a/dest/share/format/mz +++ /dev/null @@ -1 +0,0 @@ -pfn dos_header "[2]zwwwwwwwwwwwww[4]www[10]wx e_magic e_cblp e_cp e_crlc e_cparhdr e_minalloc e_maxalloc e_ss e_sp e_csum e_ip e_cs e_lfarlc e_ovno e_res e_oemid e_oeminfo e_res2 e_lfanew" diff --git a/dest/share/format/pe32 b/dest/share/format/pe32 deleted file mode 100644 index fb3062786ee..00000000000 --- a/dest/share/format/pe32 +++ /dev/null @@ -1,5 +0,0 @@ -pfo mz -pfn pe_nt_image_headers32 "[4]z?? signature (pe_image_file_header)fileHeader (pe_image_optional_header32)optionalHeader" -pfn pe_image_optional_header32 "[2]Ebbxxxxxxxxxwwwwwwxxxx[2]E[2]Bxxxxxx[16]? (pe_magic)magic majorLinkerVersion minorLinkerVersion sizeOfCode sizeOfInitializedData sizeOfUninitializedData addressOfEntryPoint baseOfCode baseOfData imageBase sectionAlignment fileAlignment majorOperatingSystemVersion minorOperatingSystemVersion majorImageVersion minorImageVersion majorSubsystemVersion minorSubsystemVersion win32VersionValue sizeOfImage sizeOfHeaders checkSum (pe_subsystem)subsystem (pe_dllcharacteristics)dllCharacteristics sizeOfStackReserve sizeOfStackCommit sizeOfHeapReserve sizeOfHeapCommit loaderFlags numberOfRvaAndSizes (pe_image_data_directory)dataDirectory" -pfn pe_image_file_header "[2]Ewtxxw[2]B (pe_machine)machine numberOfSections timeDateStamp pointerToSymbolTable numberOfSymbols sizeOfOptionalHeader (pe_characteristics)characteristics" -pfn pe_image_data_directory "xx virtualAddress size" diff --git a/dest/share/format/zip b/dest/share/format/zip deleted file mode 100644 index 5f51e4c940e..00000000000 --- a/dest/share/format/zip +++ /dev/null @@ -1,6 +0,0 @@ -pfn zip_local_file_hdr "xwwwwwxxxww magic extract flags compression last_mod_time last_mod_date crc32 compressed_size uncompressed_size namlen extras" -pfn zip_data_desc "xxx crc32 compressed_size uncompressed_size" -pfn zip_central_directory_hdr "xwwwwwwxxxwwwwwxx magic encoder extract flags compression last_mod_time last_mod_date crc32 compressed_size uncompressed_size namlen extras comment diskstart filetype filemode offset" -pfn zip_end_central_dir "xwwwwxxw magic disk finaldisk entries finalentries rootsize rootseek comment" -pfn zip64_end_central_dir "xqwwxxqqqq magic size encoder extract disk finaldisk entries finalentries rootsize rootseek" -pfn zip64_end_central_dir_loc "xxqx magic disk rootseek disks" diff --git a/dest/share/fortunes/fortunes.fun b/dest/share/fortunes/fortunes.fun deleted file mode 100644 index 813fae0bb9a..00000000000 --- a/dest/share/fortunes/fortunes.fun +++ /dev/null @@ -1,231 +0,0 @@ -No disassemble!!! -Deltify your life with rizin -What do you want to debug today? -I love the smell of bugs in the morning. -I'm in your source securing your bits. -rizin contributes to the One Byte Per Child foundation. -I did it for the pwnz. -If you send the program you are debugging to 15 friends in 143 minutes and then step three times on the same opcode you will get the name of the person who loves you. -To remove this message, put `dbxenv suppress_startup_message 7.5' in your .dbxrc -Heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it. -rizin is for lulzhats -Microloft Visual Rizin.NET 2008. Now OOXML Powered! -A C program is like a fast dance on a newly waxed dance floor by people carrying razors - Waldi Ravens -rizin is like windows 7 but even better. -rizin-built farm beats the facebook one. -Thank you for using rizin. Have a nice night! -Your rizin was built 20h ago. TOO OLD! -Use rizin! Lemons included! -rz-ax -s 20e296b20ae296b220e296b20a -Connection lost with the license server, your rizin session will terminate in 30 minutes. -This is amazing ... -I love gradients. -Wait a moment ... -No such file or directory. -Default scripting languages are NodeJS and Python. --bash: rizin: command not found -Press any key to continue ... -Ilo ni li pona li pali e lipu. mi wile e ni: sina kama jo e musi -rizin for FideOS, now with extra potato -Your project name should contain an uppercase letter, 8 vowels, some numbers, and the first 5 characters of your private bitcoin key. -This computer has gone to sleep. -Welcome back, lazy human! ----8<--------------------8<------------------8<-----------------8<------ -I accidentally the kernel with rizin. -I endians swap. -This page intentionally left blank. -Here be dragons. -Trust no one, nor a zero. Both lie. -EIP = 0x41414141 -/dev/brain: No such file or directory. -Virtual machines are great, but you lose the ability to kick the hardware. -Charlie! We are here. -The door is everything ... -The door controls time and space. -The door can see into your soul. -I am Pentium of Borg. Division is futile. You will be approximated. -Don't look at the code. Don't look. -Warning, your trial license is about to expire. -Please register your copy of rizin today! Only £29.90! -Welcome to IDA 10.0. -It's not you, it's me. -This software comes with no brain included. Please use your own. -rm: /: Permission denied. -That's embarrassing. -Wow, my cat knows rizin hotkeys better than me! -PEBCAK ERROR: Documentation not found. -License server overloaded (ETOOMUCHCASH) -Error: cannot yank negative sleep -If you're not satisfied by our product, we'll be happy to refund you. -Already up-to-date. -How about a nice game of chess? -THE ONLY WINNING MOVE IS NOT TO PLAY. -SHALL WE PLAY A GAME? -I nodejs so hard my exams. What a nodejs! -Now featuring NoSQL! -One does not simply write documentation. -Everything up-to-date. -Sharing your latest session to Facebook ... -This should be documented, since it's not that obvious. -The Hard ROP Cafe -Wait a minute! I found a bug, self-fixing ... OK -Hold on, this should never happen! -Well this is embarrassing ... -THIS IS NOT FUNNY -♥ -- -Can you stand on your head? -May the segfault be with you. -I script in C, because I can. -Initial frame selected; you cannot go up. -Unk, unk, unk, unk -This is just an existentialist experiment. -Nothing to see here. Move along. -I accidentally rizind my filesystem today. -No fix, no sleep -You see it, you fix it! -V is for Visual -rizin-goverity: found corruption - please eliminate! -Stop debugging me! -THIS IS NOT A BUG -Do you want to print 333.5K chars? (y/N) -Now with more better English! -:(){ :|:& };: -All your base are belong to rizin -Ask not what rizin can do for you - ask what you can do for rizin -Try with ASAN, and be amazed -bash: rizin2: command not found -rizin loves everyone, even Java coders, but less than others -It's not a bug, it's a work in progress -Stop swearing! -Wrong argument -For a full list of commands see `strings /dev/urandom` -Good morning, pal *<:-) -Of course rizin runs FreeBSD -Reverser by Birth, rizin by Choice -rizin, what else? -This incident will be reported -command not found: calc.exe -See you at the defcon CTF -Don't waste your time -getdruid to get eclectic uid -Welcome to "IDA - the roguelike" -255 shades of (truecolor) grey -When you sold that exploit, what they really bought, was your silence. -Greetings, human. -nothing personal, just bitness -Too old to crash -Insert coin to continue ... -See you in shell -Mess with the best, die like the rest. -Log On. Hack In. Go Anywhere. Get Everything. -Did you know that rizin can decompile to assembly? -Are you still there? -Follow the white rabbit -Do not try to sploit that binary - that's impossible. Instead, only try to realize the truth: there is no binary. -Hello Mr. Anderson -What has been executed cannot be unexecuted -What about taking a break? Here, have this nice 0xCC. -rizin is meant to be read by machines. -Prove you are a robot to continue ... -This is fine. -Using rizin to generate intelligence ... -Taking the file and moving it somewhere else -It's the year of desktop on rizin -💺 -It's the year of rizin on the desktop -A git pull a day keeps the segfault away -Are you a wizard? -rizin is a great OS, but a terrible hex editor -THE CAKE IS A PIE -Have you seen the latest rizin TV spot? -scp ~/.idapro/ida.key rizin.org:/var/www/rizin.org/pub/losers/ -Too bad there is no gif support in rizin. Yet. -Almost 5am, maybe you should go to bed. -Jingle sploits, jingle sploits, ropchain all the way. -256 colors ought to be enough for anybody -Run a command with unspecified long sequence of 'a', a developer will be summoned and do the analysis for you. -rizin is WYSIWYF - what you see is what you fix -Your endian swaps -*(ut64*)buffer ought to be illegal -There is no F5 key in rizin yet -Beer in mind. -Don’t feed the bugs! (except delicious stacktraces)! -Feed the bugs! -You haxor! Me jane? -rizin talks to you. tries to make you feel well. -Now i'm like an evil engineer. MUAHAHAH -We only have bugs, features are an unintended side-effect -Quantum disassemble: it's there as long as you don't observe it -Ceci n'est pas une rzpipe -(gdb) ^D -((fn [f s n] (str (f f s n) "zin")) (fn [f s n] (pr s) (if (> n 0) (f f (str s "ri") (dec n)) s)) "" (/ 1.0 0)) -There's no way you could crash rizin. No. Way. -When in doubt, try 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; pd;' -.-. .- -.. .- .-. . ..--- -You crackme up! -Search returned no hits. Did you mean 'Misassemble'? -We fix bugs while you sleep. -You find bugs while we sleep. -Come here, we are relatively friendly -Don't wait for Travis -Your problems are solved in an abandoned branch somewhere -aaaa is experimental -We feed trolls -Mind the tab -You have been designated for disassembly -What is the most complex rizin command? q - then you have to deal with real life /o\ -If you're having fun using rizin, odds are that you're doing something wrong. -Don't trust what can't be compiled -Coffee time! -Can you you challenge a perfect immortal machine? -Congratulations! You got the segfault 1.000.000! Click [here] to win a prize! -Well, it looks like it's working. -git pull now -git checkout hamster -Noot noot -This is an unregistered copy. -10 reasons you want to bt on all threads - you will be shocked by number 3! -Place a cat on your keyboard while running rizin, you'll not believe what will happen next -Help subcommand will be eventually removed. -Carpe noctum. -Your mouse has moved. Rizin NT must be restarted for the change to take effect. Reboot now? [ OK ] -There is only one binary, and we are all just reversing pieces of it. -Order pizza for $12.48? [Y/n] -rizinOS rizinpad 0.1 SMP GENERIC rizin_64 GNU/rizinOS -AHHHHH!!!! ASSEMBLY CODE!!!!!! HOLD ME I'M SCARED!!!!!!!!!! -In Rizin we trust -We don't make mistakes... just happy little segfaults. -rizin is for the people -Use headphones for best experience. -Starting bitcoin miner in background... -Downloading and verifying the blockchain... -The anti-virus database has been updated. -The motion picture contained in this videodisc is protected under the copyright laws. -This software is sold for home use only and all other rights are expressly reversed by the copyleft owner. -Any commercial use or duplication of this copylefted material without prior licensing is forbidden. -OpenBSD might pledge rizin but rizin unveils OpenBSD. -Error: There's a missing space before the opening parenthesis '(' -This accessory is not supported by this version of rizin. -When can we have an official anime mascot for rizin? -Sorry, rizin has experienced an internal error. -Segmentation fault (core dumped) -Use rz-bin to discover the real TRUTH -==1337== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) -**** COMMODORE 64 RIZIN V2 **** 64K RAM SYSTEM 38911 DISASM BYTES FREE READY. -Most likely your core dump fell into a blackhole, can't see it. -Long time no C -Come to C me! -Unable to locate package gdb -You C it, you fix it! -How good is your C? -You will soon have an out of memory experience. -This binary no good. Try another. -BSOD! -Mind the trap. -For a full documentation see `rizin -qc iz /lib/librz_core.so` -99 bugs, take one down pass it around. 100 bugs... -Now 8-bit clean with better ASCII! -Please insert disc 2 and press any key to continue... -You aren't losing functionality, you are losing the illusion that you ever had anything reliable. -- Darren J. Moffat, OpenSolaris developer -DOOM all the things! -Rizin is the vegan pineapple pizza of reverse engineering tools. diff --git a/dest/share/fortunes/fortunes.tips b/dest/share/fortunes/fortunes.tips deleted file mode 100644 index 14b9650ced0..00000000000 --- a/dest/share/fortunes/fortunes.tips +++ /dev/null @@ -1,86 +0,0 @@ -Tweak the disassembly output with `e asm.` -You can add commands into your ~/.rizinrc to customize your experience with Rizin -In visual mode press 'c' to toggle the cursor mode. Use tab to navigate -You can mark an offset in visual mode with the cursor and the ',' key. Later press '.' to go back -You can debug a program from the graph view ('ag') using standard rizin commands -Use the '[' and ']' keys in visual mode to adjust the screen width -Select your architecture with: 'e asm.arch=' or rizin -a from the shell -Move between your search hits in visual mode using the 'f' and 'F' keys -Save your projects with 'Ps ' and restore then with 'Po ' -Enable asm.trace to see the tracing information inside the disassembly -Change the registers of the child process in this way: 'dr eax=0x333' -Check your IO plugins with 'rizin -L' -Change the size of the file with the 'r' (resize) command -Calculate checksums for the current block with the commands starting with 'ph' ('ph md5', 'ph crc32', ..) -Use +,-,*,/ to change the size of the block -Change the block size with 'b '. In visual mode you can also enter rizin command pressing the ':' key (like vi does) -If you want to open the file in read-write mode, invoke rizin with '-w' -Print the contents of the current block with the 'p' command -Command layout is: ' @ '. For example: '3x 20 @ 0x33' will show 3 hexdumps of 20 bytes at 0x33 -Press 'c' in visual mode to toggle the cursor mode -Press 'C' in visual mode to toggle colors -You can 'copy/paste' bytes using the cursor in visual mode 'c' and using the 'y' and 'Y' keys -Move around the bytes with h,j,k,l! Arrow keys are neither portable nor efficient -Seek at relative offsets with 's +' or 's -' -Invert the block bytes using the 'I' key in visual mode -Switch between print modes using the 'p' and 'P' keys in visual mode -Add comments using the ';' key in visual mode or the 'CC' command from the rizin shell -Assemble opcodes with the 'a' and 'A' keys in visual mode, which are bindings to the 'wa' and 'wA' commands -Find expanded AES keys in memory with '/ca' -Find wide-char strings with the '/w ' command -Control the signal handlers of the child process with the 'dk' command -Get a free shell with 'rz-gg -i exec -x' -Interpret rizin scripts with '. '. Similar to the bash source alias command. -Most of commands accept '?' as a suffix. Use it to understand how they work :) -Find hexpairs with '/x a0 cc 33' -Step through your seek history with the commands 'u' (undo) and 'U' (redo) -Use zoom.byte=entropy and press 'z' in visual mode to zoom out to see the entropy of the whole file -Use 'zoom.byte=printable' in zoom mode ('z' in Visual mode) to find strings -Add colors to your screen with 'e scr.color=X' where 1 is 16 colors, 2 is 256 colors and 3 is 16M colors -Move the comments to the right changing their margin with asm.cmt.margin -Execute a command on the visual prompt with cmd.vprompt -Reduce the delta where flag resolving by address is used with cfg.delta -Disable these messages with 'e cfg.fortunes=false' in your ~/.rizinrc -Change your fortune types with 'e cfg.fortunes.file=fun,tips' in your ~/.rizinrc -Execute a command every time a breakpoint is hit with 'e cmd.bp=!my-program' -Disassemble in intel syntax with 'e asm.syntax=intel'. -Change the UID of the debugged process with child.uid (requires root) -Enhance your graphs by increasing the size of the block and graph.depth eval variable. -Control the height of the terminal on serial consoles with e scr.height -Use `rizin -B 0x123456 /bin/ls` option to set the base address of a PIE file. -Bindiff two files with '$ rz-diff -H /bin/true /bin/false' -Execute commands on a temporary offset by appending '@ offset' to your command. -Temporally drop the verbosity prefixing the commands with ':' -Change the graph block definition with graph.callblocks, graph.jmpblocks, graph.flagblocks -Use scr.accel to browse the file faster! -Use the 'id' command to see the source line related to the current seek -Analyze socket connections with the socket plugin: 'rizin socket://www.foo.com:80'. Use 'w' to send data -Setup dbg.fpregs to true to visualize the fpu registers in the debugger view. -To debug a program, you can call rizin with 'dbg://' or '-d ' -Use 'e' and 't' in Visual mode to edit configuration and track flags. -Use 'rz-bin -ris' to get the import/export symbols of any binary. -Remember to maintain your `$(rizin -H RZ_CACHEHOME)/history` file! -Enable the PAGER with 'e scr.pager=less -R' -Use 'e asm.offset=true' to show offsets in 16bit segment addressing mode. -The '%' command can be used to evaluate math expressions. Like this: '% (0x34+22)*4' -Set 'e bin.dbginfo=true' to load debug information at startup. -Rename a function using the 'afr @ ' command. -You can redefine descriptive commands in the hud file and using the 'V_' command. -Pass '-j' to rz-bin to get the information of the binary in JSON format. -Use rz-run to launch your programs with a predefined environment. -You are probably using an old version of rizin, go checkout the git! -Use '-e bin.strings=false' to disable automatic string search when loading the binary. -The unix-like reverse engineering framework. -This code was intentionally left blank, try 'e asm.arch=ws' -Thanks for using rizin! -give | and > a try piping and redirection -Run .dmm* to load the flags of the symbols of all modules loaded in the debugger -Use V! to enter into the visual panels mode (dwm style) -Toggle between disasm and graph with the space key -The more 'a' you add after 'aa' the more analysis steps are executed. -Review all the subcommands of aa to see better ways to analyze your targets. -Use /m to carve for known magic headers. speedup with search. -You can use registers in math expressions. For example: 'wx 1234 @ esp - 2' -For HTTP authentication 'e http.auth=1', 'e http.authfile=' -Save your project in compressed format with 'e prj.compress=true' -Use 'avg?' to know how you can use global variables in rizin diff --git a/dest/share/gittip b/dest/share/gittip deleted file mode 100644 index ef85fee4c66..00000000000 --- a/dest/share/gittip +++ /dev/null @@ -1 +0,0 @@ -2fe648f54139e201cf17fbe1e611934d80e92c16 \ No newline at end of file diff --git a/dest/share/hud/main b/dest/share/hud/main deleted file mode 100644 index 635b4828204..00000000000 --- a/dest/share/hud/main +++ /dev/null @@ -1,38 +0,0 @@ -add comment;%i Comment;CC `ys` -list comments;CC;%ik -change block size;%i block size;b `ys` -analyze all;aa -analyze function;af -analyze preludes;ap -continue process execution;dc;%i -disable colors;e scr.color=0 -enable colors (ANSI 16);e scr.color=1 -enable colors (256);e scr.color=2 -enable colors (16M);e scr.color=3 -randomize colors;ecr -hide bytes in disassembly;e asm.bytes=false -show bytes in disassembly;e asm.bytes=true -list imports ;ii;%ik -list sections;iS;%ik -list symbols;is;%ik -list processes;dp*;%ik -run command;%i cmd;`ys`;%ik -seek to entrypoint;s entry0 -seek to main;s main -set breakpoint;db;%i new breakpoint address;db `ys` -remove breakpoint %i delete breakpoint at given address;db-`ys` -show backtrace;dbt;%ik -show bytes in disassembly;e asm.bytes=1 -show debugger register values;dr;%ik -show process memory maps;dm;%ik -step instruction;sr PC;pd 1;ds;%ik -step over call;sr PC;pd 1;dso;%ik -write string;%i string;w `ys` -write hexadecimal data in current offset;%i hexpairs;wx `ys` -xor current block with hexpair key;%i hexpair key;wox `ys` -edit eval configuration;Veq -calculator;%i enter math expression;? `ys`;%ik -disassemble 1024 bytes and pipe to less(1);b 1024;pd|less -R -rename function;%i New name;afn `ys` -set flag;%i Flag name;f `ys` -unset flag;%i Flag name to delete;f-`ys` diff --git a/dest/share/magic/apple b/dest/share/magic/apple deleted file mode 100644 index 23e3b409089..00000000000 --- a/dest/share/magic/apple +++ /dev/null @@ -1,377 +0,0 @@ -#------------------------------------------------------------------------------ -# $File: macintosh,v 1.22 2011/05/17 17:40:31 rrt Exp $ -# macintosh description -# -# BinHex is the Macintosh ASCII-encoded file format (see also "apple") -# Daniel Quinlan, quinlan@yggdrasil.com -#11 string must\ be\ converted\ with\ BinHex BinHex binary text -#!:mime application/mac-binhex40 -#>41 string x \b, version %.3s - -# Macintosh Applications and Installation binaries (franklsm@tuns.ca) -# GRR: Too weak -#0 string APPL Macintosh Application (data) -#>2 string x \b: %s - -# Macintosh System files (franklsm@tuns.ca) -# GRR: Too weak -#0 string zsys Macintosh System File (data) -#0 string FNDR Macintosh Finder (data) -#0 string librz Macintosh Library (data) -#>2 string x : %s -#0 string shlb Macintosh Shared Library (data) -#>2 string x : %s -#0 string cdev Macintosh Control Panel (data) -#>2 string x : %s -#0 string INIT Macintosh Extension (data) -#>2 string x : %s -#0 string FFIL Macintosh Truetype Font (data) -#>2 string x : %s -#0 string LWFN Macintosh Postscript Font (data) -#>2 string x : %s - -# Additional Macintosh Files (franklsm@tuns.ca) -# GRR: Too weak -#0 string PACT Macintosh Compact Pro Archive (data) -#>2 string x : %s -#0 string ttro Macintosh TeachText File (data) -#>2 string x : %s -#0 string TEXT Macintosh TeachText File (data) -#>2 string x : %s -#0 string PDF Macintosh PDF File (data) -#>2 string x : %s - -# MacBinary format (Eric Fischer, enf@pobox.com) -# -# Unfortunately MacBinary doesn't really have a magic number prior -# to the MacBinary III format. The checksum is really the way to -# do it, but the magic file format isn't up to the challenge. -# -# 0 byte 0 -# 1 byte # filename length -# 2 string # filename -# 65 string # file type -# 69 string # file creator -# 73 byte # Finder flags -# 74 byte 0 -# 75 beshort # vertical posn in window -# 77 beshort # horiz posn in window -# 79 beshort # window or folder ID -# 81 byte # protected? -# 82 byte 0 -# 83 belong # length of data segment -# 87 belong # length of resource segment -# 91 belong # file creation date -# 95 belong # file modification date -# 99 beshort # length of comment after resource -# 101 byte # new Finder flags -# 102 string mBIN # (only in MacBinary III) -# 106 byte # char. code of file name -# 107 byte # still more Finder flags -# 116 belong # total file length -# 120 beshort # length of add'l header -# 122 byte 129 # for MacBinary II -# 122 byte 130 # for MacBinary III -# 123 byte 129 # minimum version that can read fmt -# 124 beshort # checksum -# -# This attempts to use the version numbers as a magic number, requiring -# that the first one be 0x80, 0x81, 0x82, or 0x83, and that the second -# be 0x81. This works for the files I have, but maybe not for everyone's. - -# Unfortunately, this magic is quite weak - MPi -#122 beshort&0xFCFF 0x8081 Macintosh MacBinary data - -# MacBinary I doesn't have the version number field at all, but MacBinary II -# has been in use since 1987 so I hope there aren't many really old files -# floating around that this will miss. The original spec calls for using -# the nulls in 0, 74, and 82 as the magic number. -# -# Another possibility, that would also work for MacBinary I, is to use -# the assumption that 65-72 will all be ASCII (0x20-0x7F), that 73 will -# have bits 1 (changed), 2 (busy), 3 (bozo), and 6 (invisible) unset, -# and that 74 will be 0. So something like -# -# 71 belong&0x80804EFF 0x00000000 Macintosh MacBinary data -# -# >73 byte&0x01 0x01 \b, inited -# >73 byte&0x02 0x02 \b, changed -# >73 byte&0x04 0x04 \b, busy -# >73 byte&0x08 0x08 \b, bozo -# >73 byte&0x10 0x10 \b, system -# >73 byte&0x10 0x20 \b, bundle -# >73 byte&0x10 0x40 \b, invisible -# >73 byte&0x10 0x80 \b, locked - -#>65 string x \b, type "%4.4s" - -#>65 string 8BIM (PhotoShop) -#>65 string ALB3 (PageMaker 3) -#>65 string ALB4 (PageMaker 4) -#>65 string ALT3 (PageMaker 3) -#>65 string APPL (application) -#>65 string AWWP (AppleWorks word processor) -#>65 string CIRC (simulated circuit) -#>65 string DRWG (MacDraw) -#>65 string EPSF (Encapsulated PostScript) -#>65 string FFIL (font suitcase) -#>65 string FKEY (function key) -#>65 string FNDR (Macintosh Finder) -#>65 string GIFf (GIF image) -#>65 string Gzip (GNU gzip) -#>65 string INIT (system extension) -#>65 string LIB\ (library) -#>65 string LWFN (PostScript font) -#>65 string MSBC (Microsoft BASIC) -#>65 string PACT (Compact Pro archive) -#>65 string PDF\ (Portable Document Format) -#>65 string PICT (picture) -#>65 string PNTG (MacPaint picture) -#>65 string PREF (preferences) -#>65 string PROJ (Think C project) -#>65 string QPRJ (Think Pascal project) -#>65 string SCFL (Defender scores) -#>65 string SCRN (startup screen) -#>65 string SITD (StuffIt Deluxe) -#>65 string SPn3 (SuperPaint) -#>65 string STAK (HyperCard stack) -#>65 string Seg\ (StuffIt segment) -#>65 string TARF (Unix tar archive) -#>65 string TEXT (ASCII) -#>65 string TIFF (TIFF image) -#>65 string TOVF (Eudora table of contents) -#>65 string WDBN (Microsoft Word word processor) -#>65 string WORD (MacWrite word processor) -#>65 string XLS\ (Microsoft Excel) -#>65 string ZIVM (compress (.Z)) -#>65 string ZSYS (Pre-System 7 system file) -#>65 string acf3 (Aldus FreeHand) -#>65 string cdev (control panel) -#>65 string dfil (Desk Acessory suitcase) -#>65 string librz (library) -#>65 string nX^d (WriteNow word processor) -#>65 string nX^w (WriteNow dictionary) -#>65 string rsrc (resource) -#>65 string scbk (Scrapbook) -#>65 string shlb (shared library) -#>65 string ttro (SimpleText read-only) -#>65 string zsys (system file) - -#>69 string x \b, creator "%4.4s" - -# Somewhere, Apple has a repository of registered Creator IDs. These are -# just the ones that I happened to have files from and was able to identify. - -#>69 string 8BIM (Adobe Photoshop) -#>69 string ALD3 (PageMaker 3) -#>69 string ALD4 (PageMaker 4) -#>69 string ALFA (Alpha editor) -#>69 string APLS (Apple Scanner) -#>69 string APSC (Apple Scanner) -#>69 string BRKL (Brickles) -#>69 string BTFT (BitFont) -#>69 string CCL2 (Common Lisp 2) -#>69 string CCL\ (Common Lisp) -#>69 string CDmo (The Talking Moose) -#>69 string CPCT (Compact Pro) -#>69 string CSOm (Eudora) -#>69 string DMOV (Font/DA Mover) -#>69 string DSIM (DigSim) -#>69 string EDIT (Macintosh Edit) -#>69 string ERIK (Macintosh Finder) -#>69 string EXTR (self-extracting archive) -#>69 string Gzip (GNU gzip) -#>69 string KAHL (Think C) -#>69 string LWFU (LaserWriter Utility) -#>69 string LZIV (compress) -#>69 string MACA (MacWrite) -#>69 string MACS (Macintosh operating system) -#>69 string MAcK (MacKnowledge terminal emulator) -#>69 string MLND (Defender) -#>69 string MPNT (MacPaint) -#>69 string MSBB (Microsoft BASIC (binary)) -#>69 string MSWD (Microsoft Word) -#>69 string NCSA (NCSA Telnet) -#>69 string PJMM (Think Pascal) -#>69 string PSAL (Hunt the Wumpus) -#>69 string PSI2 (Apple File Exchange) -#>69 string R*ch (BBEdit) -#>69 string RMKR (Resource Maker) -#>69 string RSED (Resource Editor) -#>69 string Rich (BBEdit) -#>69 string SIT! (StuffIt) -#>69 string SPNT (SuperPaint) -#>69 string Unix (NeXT Mac filesystem) -#>69 string VIM! (Vim editor) -#>69 string WILD (HyperCard) -#>69 string XCEL (Microsoft Excel) -#>69 string aCa2 (Fontographer) -#>69 string aca3 (Aldus FreeHand) -#>69 string dosa (Macintosh MS-DOS file system) -#>69 string movr (Font/DA Mover) -#>69 string nX^n (WriteNow) -#>69 string pdos (Apple ProDOS file system) -#>69 string scbk (Scrapbook) -#>69 string ttxt (SimpleText) -#>69 string ufox (Foreign File Access) - -# Just in case... - -102 string mBIN MacBinary III data with surprising version number - -# sas magic from Bruce Foster (bef@nwu.edu) -# -#0 string SAS SAS -#>8 string x %s -#0 string SAS SAS ->24 string DATA data file ->24 string CATALOG catalog ->24 string INDEX data file index ->24 string VIEW data view -# sas 7+ magic from Reinhold Koch (reinhold.koch@roche.com) -# -#0x54 string SAS SAS 7+ ->0x9C string DATA data file ->0x9C string CATALOG catalog ->0x9C string INDEX data file index ->0x9C string VIEW data view - -# spss magic for SPSS system and portable files, -# from Bruce Foster (bef@nwu.edu). - -0 long 0xc1e2c3c9 SPSS Portable File ->40 string x %s - -0 string $FL2 SPSS System File ->24 string x %s - -0 string $FL3 SPSS System File ->24 string x %s - -# Macintosh filesystem data -# From "Tom N Harris" -# Fixed HFS+ and Partition map magic: Ethan Benson -# The MacOS epoch begins on 1 Jan 1904 instead of 1 Jan 1970, so these -# entries depend on the data arithmetic added after v.35 -# There's also some Pascal strings in here, ditto... - -# The boot block signature, according to IM:Files, is -# "for HFS volumes, this field always contains the value 0x4C4B." -# But if this is true for MFS or HFS+ volumes, I don't know. -# Alternatively, the boot block is supposed to be zeroed if it's -# unused, so a simply >0 should suffice. - -#0x400 beshort 0xD2D7 Macintosh MFS data -#>0 beshort 0x4C4B (bootable) -#>0x40a beshort &0x8000 (locked) -#>0x402 beldate-0x7C25B080 x created: %s, -#>0x406 beldate-0x7C25B080 >0 last backup: %s, -#>0x414 belong x block size: %d, -#>0x412 beshort x number of blocks: %d, -#>0x424 pstring x volume name: %s - -# "BD" gives many false positives -#0x400 beshort 0x4244 Macintosh HFS data -#>0 beshort 0x4C4B (bootable) -#>0x40a beshort &0x8000 (locked) -#>0x40a beshort ^0x0100 (mounted) -#>0x40a beshort &0x0200 (spared blocks) -#>0x40a beshort &0x0800 (unclean) -#>0x47C beshort 0x482B (Embedded HFS+ Volume) -#>0x402 beldate-0x7C25B080 x created: %s, -#>0x406 beldate-0x7C25B080 x last modified: %s, -#>0x440 beldate-0x7C25B080 >0 last backup: %s, -#>0x414 belong x block size: %d, -#>0x412 beshort x number of blocks: %d, -#>0x424 pstring x volume name: %s - -# disabled because it produces many false positives :( -#0x400 beshort 0x482B Macintosh HFS Extended -#>&0 beshort x version %d data -#>0 beshort 0x4C4B (bootable) -#>0x404 belong ^0x00000100 (mounted) -#>&2 belong &0x00000200 (spared blocks) -#>&2 belong &0x00000800 (unclean) -#>&2 belong &0x00008000 (locked) -#>&6 string x last mounted by: '%.4s', -## really, that should be treated as a belong and we print a string -## based on the value. TN1150 only mentions '8.10' for "MacOS 8.1" -#>&14 beldate-0x7C25B080 x created: %s, -## only the creation date is local time, all other timestamps in HFS+ are UTC. -#>&18 bedate-0x7C25B080 x last modified: %s, -#>&22 bedate-0x7C25B080 >0 last backup: %s, -#>&26 bedate-0x7C25B080 >0 last checked: %s, -#>&38 belong x block size: %d, -#>&42 belong x number of blocks: %d, -#>&46 belong x free blocks: %d - -# I don't think this is really necessary since it doesn't do much and -# anything with a valid driver descriptor will also have a valid -# partition map -#0 beshort 0x4552 Apple Device Driver data -#>&24 beshort =1 \b, MacOS - -# Is that the partition type a cstring or a pstring? Well, IM says "strings -# shorter than 32 bytes must be terminated with NULL" so I'll treat it as a -# cstring. Of course, partitions can contain more than four entries, but -# what're you gonna do? -# GRR: This magic is too weak, it is just "PM" -#0x200 beshort 0x504D Apple Partition data -#>0x2 beshort x (block size: %d): -#>0x230 string x first type: %s, -#>0x210 string x name: %s, -#>0x254 belong x number of blocks: %d, -#>0x400 beshort 0x504D -#>>0x430 string x second type: %s, -#>>0x410 string x name: %s, -#>>0x454 belong x number of blocks: %d, -#>>0x600 beshort 0x504D -#>>>0x630 string x third type: %s, -#>>>0x610 string x name: %s, -#>>>0x654 belong x number of blocks: %d, -#>>0x800 beshort 0x504D -#>>>0x830 string x fourth type: %s, -#>>>0x810 string x name: %s, -#>>>0x854 belong x number of blocks: %d, -#>>>0xa00 beshort 0x504D -#>>>>0xa30 string x fifth type: %s, -#>>>>0xa10 string x name: %s, -#>>>>0xa54 belong x number of blocks: %d -#>>>0xc00 beshort 0x504D -#>>>>0xc30 string x sixth type: %s, -#>>>>0xc10 string x name: %s, -#>>>>0xc54 belong x number of blocks: %d -## AFAIK, only the signature is different -#0x200 beshort 0x5453 Apple Old Partition data -#>0x2 beshort x block size: %d, -#>0x230 string x first type: %s, -#>0x210 string x name: %s, -#>0x254 belong x number of blocks: %d, -#>0x400 beshort 0x504D -#>>0x430 string x second type: %s, -#>>0x410 string x name: %s, -#>>0x454 belong x number of blocks: %d, -#>>0x800 beshort 0x504D -#>>>0x830 string x third type: %s, -#>>>0x810 string x name: %s, -#>>>0x854 belong x number of blocks: %d, -#>>>0xa00 beshort 0x504D -#>>>>0xa30 string x fourth type: %s, -#>>>>0xa10 string x name: %s, -#>>>>0xa54 belong x number of blocks: %d - -# From: Remi Mommsen -0 string BOMStore Mac OS X bill of materials (BOM) file - - -0 lelong 0x0b17c0de ->4 lelong 0 LLVM BitCode - -0 belong 0x4243c0de ->6 byte 0 LLVM IR bitcode - -0 lelong 0xff01ff02 ->4 lelong 1 ->8 lelong -1 XCode Symbols file - -0 string BCSymbolMap BitCode symbol map file diff --git a/dest/share/magic/archive b/dest/share/magic/archive deleted file mode 100644 index 78136223f29..00000000000 --- a/dest/share/magic/archive +++ /dev/null @@ -1,262 +0,0 @@ -# $OpenBSD: archive,v 1.6 2009/04/24 18:54:34 chl Exp $ - -#------------------------------------------------------------------------------ -# archive: file(1) magic for archive formats (see also "msdos" for self- -# extracting compressed archives) -# -# cpio, ar, arc, arj, hpack, lha/lharc, rar, squish, uc2, zip, zoo, etc. -# pre-POSIX "tar" archives are handled in the C code. - -# POSIX tar archives -257 string ustar\0 POSIX tar archive -!:mime application/x-tar # encoding: posix -257 string ustar\040\040\0 GNU tar archive -!:mime application/x-tar # encoding: gnu - -# cpio archives -# - -# Debian package (needs to go before regular portable archives) -# -0 string =!\ndebian ->8 string debian-split part of multipart Debian package -!:mime application/vnd.debian.binary-package ->8 string debian-binary Debian binary package -!:mime application/vnd.debian.binary-package ->8 string !debian ->68 string >\0 (format %s) -# These next two lines do not work, because a bzip2 Debian archive -# still uses gzip for the control.tar (first in the archive). Only -# data.tar varies, and the location of its filename varies too. -# file/libmagic does not current have support for ascii-string based -# (offsets) as of 2005-09-15. -#>81 string bz2 \b, uses bzip2 compression -#>84 string gz \b, uses gzip compression -#>136 ledate x created: %s - -# MIPS archive (needs to go before regular portable archives) -# -0 string =!\n__________E MIPS archive ->20 string U with MIPS Ucode members ->21 string L with MIPSEL members ->21 string B with MIPSEB members ->19 string L and an EL hash table ->19 string B and an EB hash table ->22 string X -- out of date - -0 search/1 -h- Software Tools format archive text - -# -# XXX - why are there multiple thingies? Note that 0x213c6172 is -# "! current ar archive -# 0 long 0x213c6172 archive file -# -# and for SVR1 archives, we have: -# -# 0 string \ System V Release 1 ar archive -# 0 string = archive -# -# XXX - did Aegis really store shared libraries, breakpointed modules, -# and absolute code program modules in the same format as new-style -# "ar" archives? -# -0 string =! current ar archive -!:mime application/x-archive ->8 string __.SYMDEF random library ->0 belong =65538 - pre SR9.5 ->0 belong =65539 - post SR9.5 ->0 beshort 2 - object archive ->0 beshort 3 - shared library module ->0 beshort 4 - debug break-pointed module ->0 beshort 5 - absolute code program module -0 string \ System V Release 1 ar archive -0 string = archive -# - -# MS Compress -4 string \x88\xf0\x27 MS Compress archive data -# updated by Joerg Jenderek ->9 string \0 ->>0 string KWAJ ->>>7 string \321\003 MS Compress archive data ->>>>14 ulong >0 \b, original size: %d byte(s) ->>>>18 ubyte >0x65 ->>>>>18 string x \b, was %.8s ->>>>>(10.b-4) string x \b.%.3s - -# JAR archiver (.j), this is the successor to ARJ, not Java's JAR (which is essentially ZIP) -0xe string \x1aJar\x1b JAR (ARJ Software, Inc.) archive data -0 string JARCS JAR (ARJ Software, Inc.) archive data - -# RAR archiver (Greg Roelofs, newt@uchicago.edu) -0 string Rar! RAR archive data, -!:mime application/x-rar ->44 byte x v%0x, ->10 byte >0 flags: ->>10 byte &0x01 Archive volume, ->>10 byte &0x02 Commented, ->>10 byte &0x04 Locked, ->>10 byte &0x08 Solid, ->>10 byte &0x20 Authenticated, ->35 byte 0 os: MS-DOS ->35 byte 1 os: OS/2 ->35 byte 2 os: Win32 ->35 byte 3 os: Unix -# some old version? idarc says: -0 string RE\x7e\x5e RAR archive data - -# SQUISH archiver (Greg Roelofs, newt@uchicago.edu) -0 string SQSH squished archive data (Acorn RISCOS) - -# UC2 archiver (Greg Roelofs, newt@uchicago.edu) -# [JW] see exe section for self-extracting version -0 string UC2\x1a UC2 archive data - -# ZIP archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu) -0 string PK\003\004 ZIP ->4 byte 0x00 Zip archive data -!:mime application/zip ->4 byte 0x09 Zip archive data, at least v0.9 to extract -!:mime application/zip ->4 byte 0x0a Zip archive data, at least v1.0 to extract -!:mime application/zip ->4 byte 0x0b Zip archive data, at least v1.1 to extract -!:mime application/zip ->0x161 string WINZIP Zip archive data, WinZIP self-extracting -!:mime application/zip ->4 byte 0x14 ->>30 ubelong !0x6d696d65 Zip archive data, at least v2.0 to extract -!:mime application/zip - -# ZIP footer -0 string PK\005\006 End of Zip archive - -# OpenOffice.org / KOffice / StarOffice documents -# From: Abel Cheung -# Listed here because they are basically zip files ->>30 string mimetype - -# KOffice (1.2 or above) formats ->>>50 string vnd.kde. KOffice (>=1.2) ->>>>58 string karbon Karbon document ->>>>58 string kchart KChart document ->>>>58 string kformula KFormula document ->>>>58 string kivio Kivio document ->>>>58 string kontour Kontour document ->>>>58 string kpresenter KPresenter document ->>>>58 string kspread KSpread document ->>>>58 string kword KWord document - -# OpenOffice formats (for OpenOffice 1.x / StarOffice 6/7) ->>>50 string vnd.sun.xml. OpenOffice.org 1.x ->>>>62 string writer Writer ->>>>>68 byte !0x2e document ->>>>>68 string .template template ->>>>>68 string .global global document ->>>>62 string calc Calc ->>>>>66 byte !0x2e spreadsheet ->>>>>66 string .template template ->>>>62 string draw Draw ->>>>>66 byte !0x2e document ->>>>>66 string .template template ->>>>62 string impress Impress ->>>>>69 byte !0x2e presentation ->>>>>69 string .template template ->>>>62 string math Math document - -# OpenDocument formats (for OpenOffice 2.x / StarOffice >= 8) -# http://lists.oasis-open.org/archives/office/200505/msg00006.html ->>>50 string vnd.oasis.opendocument. OpenDocument ->>>>73 string text ->>>>>77 byte !0x2d Text -!:mime application/vnd.oasis.opendocument.text ->>>>>77 string -template Text Template ->>>>>77 string -web HTML Document Template ->>>>>77 string -master Master Document ->>>>73 string graphics Drawing ->>>>>81 string -template Template ->>>>73 string presentation Presentation ->>>>>85 string -template Template ->>>>73 string spreadsheet Spreadsheet ->>>>>84 string -template Template ->>>>73 string chart Chart ->>>>>78 string -template Template ->>>>73 string formula Formula ->>>>>80 string -template Template ->>>>73 string database Database ->>>>73 string image Image - -# Zoo archiver -20 lelong 0xfdc4a7dc Zoo archive data -!:mime application/x-zoo ->4 byte >48 \b, v%c. ->>6 byte >47 \b%c ->>>7 byte >47 \b%c ->32 byte >0 \b, modify: v%d ->>33 byte x \b.%d+ ->42 lelong 0xfdc4a7dc \b, ->>70 byte >0 extract: v%d ->>>71 byte x \b.%d+ - -# Shell archives -10 string #\ This\ is\ a\ shell\ archive shell archive text -!:mime application/octet-stream - -# -# LBR. NB: May conflict with the questionable -# "binary Computer Graphics Metafile" format. -# -0 string \0\ \ \ \ \ \ \ \ \ \ \ \0\0 LBR archive data -# -# PMA (CP/M derivative of LHA) -# -2 string -pm0- PMarc archive data [pm0] -2 string -pm1- PMarc archive data [pm1] -2 string -pm2- PMarc archive data [pm2] -2 string -pms- PMarc SFX archive (CP/M, DOS) -5 string -pc1- PopCom compressed executable (CP/M) - -# Microsoft cabinets -# by David Necas (Yeti) -#0 string MSCF\0\0\0\0 Microsoft cabinet file data, -#>25 byte x v%d -#>24 byte x \b.%d -# MPi: All CABs have version 1.3, so this is pointless. - -# Felix von Leitner -0 string d8:announce BitTorrent file -!:mime application/x-bittorrent - -# Alternate ZIP string (amc@arwen.cs.berkeley.edu) -0 string PK00PK\003\004 Zip archive data - -# rzip archives -0 string RZIP rzip compressed data ->4 byte x - version %d ->5 byte x \b.%d ->6 belong x (%d byte(s)) - -# From: Dirk Jagdmann -# xar archive format: http://code.google.com/p/xar/ -0 string xar! xar archive ->6 beshort x - version %d - -# From: "Nelson A. de Oliveira" -# .kgb -0 string KGB_arch KGB Archiver file ->10 string x with compression level %.1s - -# xar (eXtensible ARchiver) archive -# From: "David Remahl" -0 string xar! xar archive -#>4 beshort x header size %d ->6 beshort x version %d, -#>8 quad x compressed TOC: %d, -#>16 quad x uncompressed TOC: %d, ->24 belong 0 no checksum ->24 belong 1 SHA-1 checksum ->24 belong 2 MD5 checksum - -0 lelong 0x0a02d40a protobuf: Google's protocol-buffer file diff --git a/dest/share/magic/cafebabe b/dest/share/magic/cafebabe deleted file mode 100644 index 9d5acfb9fb5..00000000000 --- a/dest/share/magic/cafebabe +++ /dev/null @@ -1,29 +0,0 @@ -# $OpenBSD: cafebabe,v 1.3 2009/04/24 18:54:34 chl Exp $ - -#------------------------------------------------------------------------------ -# Cafe Babes unite! -# -# Since Java bytecode and Mach-O fat-files have the same magic number, the test -# must be performed in the same "magic" sequence to get both right. The long -# at offset 4 in a mach-O fat file tells the number of architectures; the short at -# offset 4 in a Java bytecode file is the JVM minor version and the -# short at offset 6 is the JVM major version. Since there are only -# only 18 labeled Mach-O architectures at current, and the first released -# Java class format was version 43.0, we can safely choose any number -# between 18 and 39 to test the number of architectures against -# (and use as a hack). Let's not use 18, because the Mach-O people -# might add another one or two as time goes by... -# -0 beshort 0xcafe ->2 beshort 0xbabe -#>4 belong >30 compiled Java class data, -#>4 belong >30 -# !:mime application/x-java-applet ->>6 beshort <20 ->>>6 beshort x version %d. ->>>4 beshort x \b%d ->>>4 belong 1 Mach-O fat file with 1 architecture ->>>4 belong >1 ->>>>4 belong <20 Mach-O fat file with %d architectures ->2 beshort 0xd00d JAR compressed with pack200 -!:mime application/x-java-pack200 diff --git a/dest/share/magic/code b/dest/share/magic/code deleted file mode 100644 index 3f331f72ba7..00000000000 --- a/dest/share/magic/code +++ /dev/null @@ -1,5 +0,0 @@ -0 string #include C source code -0 string import java. JAVA source code -0 string #!/usr/bin/env python Python script -0 string #!/usr/bin/python Python script -0 string #!/usr/bin/perl PERL script diff --git a/dest/share/magic/compressed b/dest/share/magic/compressed deleted file mode 100644 index 7e9da4de383..00000000000 --- a/dest/share/magic/compressed +++ /dev/null @@ -1,128 +0,0 @@ - -#------------------Compression Formats----------------------------- - - -# bzip2 -0 string BZh91AY&SY bzip2 compressed data, block size = 900k -0 string BZh81AY&SY bzip2 compressed data, block size = 800k -0 string BZh71AY&SY bzip2 compressed data, block size = 700k -0 string BZh61AY&SY bzip2 compressed data, block size = 600k -0 string BZh51AY&SY bzip2 compressed data, block size = 500k -0 string BZh41AY&SY bzip2 compressed data, block size = 400k -0 string BZh31AY&SY bzip2 compressed data, block size = 300k -0 string BZh21AY&SY bzip2 compressed data, block size = 200k -0 string BZh11AY&SY bzip2 compressed data, block size = 100k - -# LZO -0 string \211LZO\000\015\012\032\012 LZO compressed data - -# 7-zip archiver, from Thomas Klausner (wiz@danbala.tuwien.ac.at) -# http://www.7-zip.org or DOC/7zFormat.txt -# -0 string 7z\274\257\047\034 7-zip archive data, ->6 byte <0 invalid ->6 byte 0 ->>7 byte 0 invalid ->6 byte >20 invalid ->6 byte x version %d ->7 byte x \b.%d - -# standard unix compress -# Implemented in the compress binwalk plugin. -#0 string \x1f\x9d\x90 compress'd data, 16 bits - -# http://tukaani.org/xz/xz-file-format.txt -0 string \xFD\x37\x7a\x58\x5a\x00 xz compressed data - -# gzip (GNU zip, not to be confused with Info-ZIP or PKWARE zip archiver) -# Edited by Chris Chittleborough , March 2002 -# * Original filename is only at offset 10 if "extra field" absent -# * Produce shorter output - notably, only report compression methods -# other than 8 ("deflate", the only method defined in RFC 1952). -#0 string \037\213\x08 gzip compressed data -0 string \x1f\x8b\x08 gzip compressed data ->3 byte &0x01 \b, ASCII ->3 byte&0xE0 !0x00 \b, invalid reserved flag bits ->8 byte 2 \b, maximum compression ->8 byte 4 \b, fastest compression ->8 byte 1 \b, invalid extra flags ->8 byte 3 \b, invalid extra flags ->8 byte >4 \b, invalid extra flags ->3 byte &0x02 \b, has header CRC ->3 byte&0x04 0x04 ->>10 leshort x \b, has %d byte(s) of extra data ->3 byte&0xC =0x08 \b, has original file name ->>10 string x \b{file-name:%s} ->>10 string x \b: "%s" ->3 byte &0x10 \b, has comment ->>3 byte&0xC 0 ->>>10 string x \b: "%s" ->9 byte =0x00 \b, from FAT filesystem (MS-DOS, OS/2, NT) ->9 byte =0x01 \b, from Amiga ->9 byte =0x02 \b, from VMS ->9 byte =0x03 \b, from Unix ->9 byte =0x04 \b, from VM/CMS ->9 byte =0x05 \b, from Atari ->9 byte =0x06 \b, from HPFS filesystem (OS/2, NT) ->9 byte =0x07 \b, from MacOS ->9 byte =0x08 \b, from Z-System ->9 byte =0x09 \b, from CP/M ->9 byte =0x0A \b, from TOPS/20 ->9 byte =0x0B \b, from NTFS filesystem (NT) ->9 byte =0x0C \b, from QDOS ->9 byte =0x0D \b, from Acorn RISCOS -#>9 byte =0xFF \b, from ZyNOS -#>9 byte >0x0D \b, invalid -#>>9 byte x source: 0x%.2X -#>9 byte <0 \b, invalid -#>>9 byte x source: 0x%.2X ->3 byte &0x20 \b, encrypted (invalid) -# Dates before 1992 are invalid, unless of course you're DD-WRT in which -# case you don't know how to set a date in your gzip files. Brilliant. ->4 lelong =0 \b, NULL date ->4 lelong <0 \b, invalid date ->4 lelong >0 ->>4 lelong <694224000 \b, invalid date ->>4 lelong =694224000 \b, invalid date ->>4 lelong >694224000 \b, last modified ->>4 ledate x %s - -# Zlib signatures -# Too short to be useful on their own; see: -# -# o src/binwalk/magic/zlib -# o src/binwalk/plugins/zlib.py -# -#0 beshort 0x789C zlib compressed data -#0 beshort 0x78DA zlib compressed data -#0 beshort 0x7801 zlib compressed data - - -# JAR -0 belong 0xcafed00d JAR compressed with pack200, ->5 byte x version %d. ->4 byte x \b%d - -# New LZMA format signature -# See lzma file for LZMA signatures -0 string \xFFLZMA\x00 LZMA compressed data (new), ->6 byte&0x10 0 single-block stream ->6 byte&0x10 0x10 multi-block stream - -## Classic LZMA signature -0 byte >0x5a ->0 byte <0x5e ->>5 belong 0xffffffff ->>>1 belong >0 ->>>>1 belong <0xfffff ->>>>>1 belong x LZMA BE compressed data dictionary size: %d bytes, - -#0 string \xff\x06\x00\x00\x73\x4e\x61\x50\x70\x59 Snappy compression, stream identifier - -#0 string \x1f\x9d\x90 compress'd data, 16 bits - -#0 beshort 0x7801 Zlib header, no compression -#0 beshort 0x789c Zlib compressed data, default compression -#0 beshort 0x78da Zlib compressed data, best compression -#0 beshort 0x785e Zlib compressed data, compressed - diff --git a/dest/share/magic/database b/dest/share/magic/database deleted file mode 100644 index 90cbc38e52c..00000000000 --- a/dest/share/magic/database +++ /dev/null @@ -1,240 +0,0 @@ -# $OpenBSD: database,v 1.6 2009/04/24 18:54:34 chl Exp $ - -#------------------------------------------------------------------------------ -# database: file(1) magic for various databases -# -# extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk) -# -# -# GDBM magic numbers -# Will be maintained as part of the GDBM distribution in the future. -# -0 belong 0x13579ace GNU dbm 1.x or ndbm database, big endian -!:mime application/x-gdbm -0 lelong 0x13579ace GNU dbm 1.x or ndbm database, little endian -!:mime application/x-gdbm -0 string GDBM GNU dbm 2.x database -!:mime application/x-gdbm -# -# Berkeley DB -# -# Ian Darwin's file /etc/magic files: big/little-endian version. -# -# Hash 1.85/1.86 databases store metadata in network byte order. -# Btree 1.85/1.86 databases store the metadata in host byte order. -# Hash and Btree 2.X and later databases store the metadata in host byte order. - -0 long 0x00061561 Berkeley DB -!:mime application/x-dbm ->8 belong 4321 ->>4 belong >2 1.86 ->>4 belong <3 1.85 ->>4 belong >0 (Hash, version %d, native byte-order) ->8 belong 1234 ->>4 belong >2 1.86 ->>4 belong <3 1.85 ->>4 belong >0 (Hash, version %d, little-endian) - -0 belong 0x00061561 Berkeley DB ->8 belong 4321 ->>4 belong >2 1.86 ->>4 belong <3 1.85 ->>4 belong >0 (Hash, version %d, big-endian) ->8 belong 1234 ->>4 belong >2 1.86 ->>4 belong <3 1.85 ->>4 belong >0 (Hash, version %d, native byte-order) - -0 long 0x00053162 Berkeley DB 1.85/1.86 ->4 long >0 (Btree, version %d, native byte-order) -0 belong 0x00053162 Berkeley DB 1.85/1.86 ->4 belong >0 (Btree, version %d, big-endian) -0 lelong 0x00053162 Berkeley DB 1.85/1.86 ->4 lelong >0 (Btree, version %d, little-endian) - -12 long 0x00061561 Berkeley DB ->16 long >0 (Hash, version %d, native byte-order) -12 belong 0x00061561 Berkeley DB ->16 belong >0 (Hash, version %d, big-endian) -12 lelong 0x00061561 Berkeley DB ->16 lelong >0 (Hash, version %d, little-endian) - -12 long 0x00053162 Berkeley DB ->16 long >0 (Btree, version %d, native byte-order) -12 belong 0x00053162 Berkeley DB ->16 belong >0 (Btree, version %d, big-endian) -12 lelong 0x00053162 Berkeley DB ->16 lelong >0 (Btree, version %d, little-endian) - -12 long 0x00042253 Berkeley DB ->16 long >0 (Queue, version %d, native byte-order) -12 belong 0x00042253 Berkeley DB ->16 belong >0 (Queue, version %d, big-endian) -12 lelong 0x00042253 Berkeley DB ->16 lelong >0 (Queue, version %d, little-endian) - -# From Max Bowsher. -12 long 0x00040988 Berkeley DB ->16 long >0 (Log, version %d, native byte-order) -12 belong 0x00040988 Berkeley DB ->16 belong >0 (Log, version %d, big-endian) -12 lelong 0x00040988 Berkeley DB ->16 lelong >0 (Log, version %d, little-endian) - -# -# -# Round Robin Database Tool by Tobias Oetiker -#0 string RRD RRDTool DB -#>4 string x version %s -#---------------------------------------------------------------------- -# ROOT: file(1) magic for ROOT databases -# -#0 string root\0 ROOT file -#>4 belong x Version %d -#>33 belong x (Compression: %d) - -# XXX: Weak magic. -# Alex Ott -## Paradox file formats -#2 leshort 0x0800 Paradox -#>0x39 byte 3 v. 3.0 -#>0x39 byte 4 v. 3.5 -#>0x39 byte 9 v. 4.x -#>0x39 byte 10 v. 5.x -#>0x39 byte 11 v. 5.x -#>0x39 byte 12 v. 7.x -#>>0x04 byte 0 indexed .DB data file -#>>0x04 byte 1 primary index .PX file -#>>0x04 byte 2 non-indexed .DB data file -#>>0x04 byte 3 non-incrementing secondary index .Xnn file -#>>0x04 byte 4 secondary index .Ynn file -#>>0x04 byte 5 incrementing secondary index .Xnn file -#>>0x04 byte 6 non-incrementing secondary index .XGn file -#>>0x04 byte 7 secondary index .YGn file -#>>>0x04 byte 8 incrementing secondary index .XGn file - -## XBase database files -#0 byte 0x02 -#>8 leshort >0 -#>>12 leshort 0 FoxBase -#!:mime application/x-dbf -#>>>0x04 lelong 0 (no records) -#>>>0x04 lelong >0 (%ld records) -# -#0 byte 0x03 -#!:mime application/x-dbf -#>8 leshort >0 -#>>12 leshort 0 FoxBase+, FoxPro, dBaseIII+, dBaseIV, no memo -#>>>0x04 lelong 0 (no records) -#>>>0x04 lelong >0 (%ld records) -# -#0 byte 0x04 -#!:mime application/x-dbf -#>8 leshort >0 -#>>12 leshort 0 dBASE IV no memo file -#>>>0x04 lelong 0 (no records) -#>>>0x04 lelong >0 (%ld records) -# -#0 byte 0x05 -#!:mime application/x-dbf -#>8 leshort >0 -#>>12 leshort 0 dBASE V no memo file -#>>>0x04 lelong 0 (no records) -#>>>0x04 lelong >0 (%ld records) -# -#0 byte 0x30 -#!:mime application/x-dbf -#>8 leshort >0 -#>>12 leshort 0 Visual FoxPro -#>>>0x04 lelong 0 (no records) -#>>>0x04 lelong >0 (%ld records) -# -#0 byte 0x43 -#!:mime application/x-dbf -#>8 leshort >0 -#>>12 leshort 0 FlagShip with memo var size -#>>>0x04 lelong 0 (no records) -#>>>0x04 lelong >0 (%ld records) -# -#0 byte 0x7b -#!:mime application/x-dbf -#>8 leshort >0 -#>>12 leshort 0 dBASEIV with memo -#>>>0x04 lelong 0 (no records) -#>>>0x04 lelong >0 (%ld records) -# -#0 byte 0x83 -#!:mime application/x-dbf -#>8 leshort >0 -#>>12 leshort 0 FoxBase+, dBaseIII+ with memo -#>>>0x04 lelong 0 (no records) -#>>>0x04 lelong >0 (%ld records) -# -#0 byte 0x8b -#!:mime application/x-dbf -#>8 leshort >0 -#>>12 leshort 0 dBaseIV with memo -#>>>0x04 lelong 0 (no records) -#>>>0x04 lelong >0 (%ld records) -# -#0 byte 0x8e -#!:mime application/x-dbf -#>8 leshort >0 -#>>12 leshort 0 dBaseIV with SQL Table -#>>>0x04 lelong 0 (no records) -#>>>0x04 lelong >0 (%ld records) -# -#0 byte 0xb3 -#!:mime application/x-dbf -#>8 leshort >0 -#>>12 leshort 0 FlagShip with .dbt memo -#>>>0x04 lelong 0 (no records) -#>>>0x04 lelong >0 (%ld records) -# -#0 byte 0xf5 -#!:mime application/x-dbf -#>8 leshort >0 -#>>12 leshort 0 FoxPro with memo -#>>>0x04 lelong 0 (no records) -#>>>0x04 lelong >0 (%ld records) -# -#0 leshort 0x0006 DBase 3 index file - -# MS Access database -4 string Standard\ Jet\ DB Microsoft Access Database -!:mime application/x-msaccess - -# SE Linux policy database -#0 lelong 0xf97cff8c SE Linux policy -#>16 lelong x v%d -#>20 lelong 1 MLS -#>24 lelong x %d symbols -#>28 lelong x %d ocons - -# ICE authority file data (Wolfram Kleff) -#2 string ICE ICE authority data - -# X11 Xauthority file (Wolfram Kleff) -10 string MIT-MAGIC-COOKIE-1 X11 Xauthority data -11 string MIT-MAGIC-COOKIE-1 X11 Xauthority data -12 string MIT-MAGIC-COOKIE-1 X11 Xauthority data -13 string MIT-MAGIC-COOKIE-1 X11 Xauthority data -14 string MIT-MAGIC-COOKIE-1 X11 Xauthority data -15 string MIT-MAGIC-COOKIE-1 X11 Xauthority data -16 string MIT-MAGIC-COOKIE-1 X11 Xauthority data -17 string MIT-MAGIC-COOKIE-1 X11 Xauthority data -18 string MIT-MAGIC-COOKIE-1 X11 Xauthority data - -# From: Maxime Henrion -# PostgreSQL's custom dump format, Maxime Henrion -0 string PGDMP PostgreSQL custom database dump ->5 byte x - v%d ->6 byte x \b.%d ->5 beshort <0x101 \b-0 ->5 beshort >0x100 ->>7 byte x \b-%d - -# Type: Advanced Data Format (ADF) database -# URL: http://www.grc.nasa.gov/WWW/cgns/adf/ -# From: Nicolas Chauvat -#0 string @(#)ADF\ Database CGNS Advanced Data Format diff --git a/dest/share/magic/elf b/dest/share/magic/elf deleted file mode 100644 index 1058ab4c225..00000000000 --- a/dest/share/magic/elf +++ /dev/null @@ -1,255 +0,0 @@ -# $OpenBSD: elf,v 1.17 2009/04/24 18:54:34 chl Exp $ - -#------------------------------------------------------------------------------ -# elf: file(1) magic for ELF executables -# -# We have to check the byte order flag to see what byte order all the -# other stuff in the header is in. -# -# What're the correct byte orders for the nCUBE and the Fujitsu VPP500? -# -# updated by Daniel Quinlan (quinlan@yggdrasil.com) -0 string \177ELF ELF ->4 byte 0 invalid class ->4 byte 1 32-bit ->4 byte 2 64-bit ->5 byte 0 invalid byte order ->5 byte 1 LSB ->>16 leshort 0 no file type, -!:mime application/octet-stream ->>16 leshort 1 relocatable, -!:mime application/x-object ->>16 leshort 2 executable, -!:mime application/x-executable ->>16 leshort 3 shared object, -!:mime application/x-sharedlib -# Core handling from Peter Tobias -# corrections by Christian 'Dr. Disk' Hechelmann ->>16 leshort 4 core file -!:mime application/x-coredump -# Core file detection is not reliable. -#>>>(0x38+0xcc) string >\0 of '%s' -#>>>(0x38+0x10) lelong >0 (signal %d), ->>16 leshort &0xff00 processor-specific, ->>18 leshort 0 no machine, ->>18 leshort 1 AT&T WE32100 - invalid byte order, ->>18 leshort 2 SPARC - invalid byte order, ->>18 leshort 3 Intel 80386, ->>18 leshort 4 Motorola ->>>36 lelong &0x01000000 68000 - invalid byte order, ->>>36 lelong &0x00810000 CPU32 - invalid byte order, ->>>36 lelong 0 68020 - invalid byte order, ->>18 leshort 5 Motorola 88000 - invalid byte order, ->>18 leshort 6 Intel 80486, ->>18 leshort 7 Intel 80860, -# The official e_machine number for MIPS is now #8, regardless of endianness. -# The second number (#10) will be deprecated later. For now, we still -# say something if #10 is encountered, but only gory details for #8. ->>18 leshort 8 MIPS, ->>>36 lelong &0x20 N32 ->>18 leshort 10 MIPS, ->>>36 lelong &0x20 N32 ->>18 leshort 8 -# only for 32-bit ->>>4 byte 1 ->>>>36 lelong&0xf0000000 0x00000000 MIPS-I ->>>>36 lelong&0xf0000000 0x10000000 MIPS-II ->>>>36 lelong&0xf0000000 0x20000000 MIPS-III ->>>>36 lelong&0xf0000000 0x30000000 MIPS-IV ->>>>36 lelong&0xf0000000 0x40000000 MIPS-V ->>>>36 lelong&0xf0000000 0x50000000 MIPS32 ->>>>36 lelong&0xf0000000 0x60000000 MIPS64 ->>>>36 lelong&0xf0000000 0x70000000 MIPS32 rel2 ->>>>36 lelong&0xf0000000 0x80000000 MIPS64 rel2 -# only for 64-bit ->>>4 byte 2 ->>>>48 lelong&0xf0000000 0x00000000 MIPS-I ->>>>48 lelong&0xf0000000 0x10000000 MIPS-II ->>>>48 lelong&0xf0000000 0x20000000 MIPS-III ->>>>48 lelong&0xf0000000 0x30000000 MIPS-IV ->>>>48 lelong&0xf0000000 0x40000000 MIPS-V ->>>>48 lelong&0xf0000000 0x50000000 MIPS32 ->>>>48 lelong&0xf0000000 0x60000000 MIPS64 ->>>>48 lelong&0xf0000000 0x70000000 MIPS32 rel2 ->>>>48 lelong&0xf0000000 0x80000000 MIPS64 rel2 ->>18 leshort 9 Amdahl - invalid byte order, ->>18 leshort 10 MIPS (deprecated), ->>18 leshort 11 RS6000 - invalid byte order, ->>18 leshort 15 PA-RISC - invalid byte order, ->>>50 leshort 0x0214 2.0 ->>>48 leshort &0x0008 (LP64), ->>18 leshort 16 nCUBE, ->>18 leshort 17 Fujitsu VPP500, ->>18 leshort 18 SPARC32PLUS, ->>18 leshort 20 PowerPC, ->>18 leshort 22 IBM S/390, ->>18 leshort 36 NEC V800, ->>18 leshort 37 Fujitsu FR20, ->>18 leshort 38 TRW RH-32, ->>18 leshort 39 Motorola RCE, ->>18 leshort 40 ARM, ->>18 leshort 41 Alpha, ->>18 leshort 0xa390 IBM S/390 (obsolete), ->>18 leshort 42 Renesas SH, ->>18 leshort 43 SPARC V9 - invalid byte order, ->>18 leshort 44 Siemens Tricore Embedded Processor, ->>18 leshort 45 Argonaut RISC Core, Argonaut Technologies Inc., ->>18 leshort 46 Renesas H8/300, ->>18 leshort 47 Renesas H8/300H, ->>18 leshort 48 Renesas H8S, ->>18 leshort 49 Renesas H8/500, ->>18 leshort 50 IA-64, ->>18 leshort 51 Stanford MIPS-X, ->>18 leshort 52 Motorola Coldfire, ->>18 leshort 53 Motorola M68HC12, ->>18 leshort 54 Fujitsu MMA, ->>18 leshort 55 Siemens PCP, ->>18 leshort 56 Sony nCPU, ->>18 leshort 57 Denso NDR1, ->>18 leshort 58 Start*Core, ->>18 leshort 59 Toyota ME16, ->>18 leshort 60 ST100, ->>18 leshort 61 Tinyj emb., ->>18 leshort 62 x86-64, ->>18 leshort 63 Sony DSP, ->>18 leshort 66 FX66, ->>18 leshort 67 ST9+ 8/16 bit, ->>18 leshort 68 ST7 8 bit, ->>18 leshort 69 MC68HC16, ->>18 leshort 70 MC68HC11, ->>18 leshort 71 MC68HC08, ->>18 leshort 72 MC68HC05, ->>18 leshort 73 SGI SVx, ->>18 leshort 74 ST19 8 bit, ->>18 leshort 75 Digital VAX, ->>18 leshort 76 Axis cris, ->>18 leshort 77 Infineon 32-bit embedded, ->>18 leshort 78 Element 14 64-bit DSP, ->>18 leshort 79 LSI Logic 16-bit DSP, ->>18 leshort 80 MMIX, ->>18 leshort 81 Harvard machine-independent, ->>18 leshort 82 SiTera Prism, ->>18 leshort 83 Atmel AVR 8-bit, ->>18 leshort 84 Fujitsu FR30, ->>18 leshort 85 Mitsubishi D10V, ->>18 leshort 86 Mitsubishi D30V, ->>18 leshort 87 NEC v850, ->>18 leshort 88 Renesas M32R, ->>18 leshort 89 Matsushita MN10300, ->>18 leshort 90 Matsushita MN10200, ->>18 leshort 91 picoJava, ->>18 leshort 92 OpenRISC, ->>18 leshort 93 ARC Cores Tangent-A5, ->>18 leshort 0x3426 OpenRISC (obsolete), ->>18 leshort 0x8472 OpenRISC (obsolete), ->>18 leshort 94 Tensilica Xtensa, ->>18 leshort 97 NatSemi 32k, ->>18 leshort 106 Analog Devices Blackfin, ->>18 leshort 0x9026 Alpha (unofficial), ->>20 lelong 0 invalid version ->>20 lelong 1 version 1 ->>36 lelong 1 MathCoPro/FPU/MAU Required ->5 byte 2 MSB ->>16 beshort 0 no file type, -!:mime application/octet-stream ->>16 beshort 1 relocatable, -!:mime application/x-object ->>16 beshort 2 executable, -!:mime application/x-executable ->>16 beshort 3 shared object, -!:mime application/x-sharedlib ->>16 beshort 4 core file, -!:mime application/x-coredump -#>>>(0x38+0xcc) string >\0 of '%s' -#>>>(0x38+0x10) belong >0 (signal %d), ->>16 beshort &0xff00 processor-specific, ->>18 beshort 0 no machine, ->>18 beshort 1 AT&T WE32100, ->>18 beshort 2 SPARC, ->>18 beshort 3 Intel 80386 - invalid byte order, ->>18 beshort 4 Motorola ->>>36 belong &0x01000000 68000, ->>>36 belong &0x00810000 CPU32, ->>>36 belong 0 68020, ->>18 beshort 5 Motorola 88000, ->>18 beshort 6 Intel 80486 - invalid byte order, ->>18 beshort 7 Intel 80860, -# only for MIPS - see comment in little-endian section above. ->>18 beshort 8 MIPS, ->>>36 belong &0x20 N32 ->>18 beshort 10 MIPS, ->>>36 belong &0x20 N32 ->>18 beshort 8 -# only for 32-bit ->>>4 byte 1 ->>>>36 belong&0xf0000000 0x00000000 MIPS-I ->>>>36 belong&0xf0000000 0x10000000 MIPS-II ->>>>36 belong&0xf0000000 0x20000000 MIPS-III ->>>>36 belong&0xf0000000 0x30000000 MIPS-IV ->>>>36 belong&0xf0000000 0x40000000 MIPS-V ->>>>36 belong&0xf0000000 0x50000000 MIPS32 ->>>>36 belong&0xf0000000 0x60000000 MIPS64 ->>>>36 belong&0xf0000000 0x70000000 MIPS32 rel2 ->>>>36 belong&0xf0000000 0x80000000 MIPS64 rel2 -# only for 64-bit ->>>4 byte 2 ->>>>48 belong&0xf0000000 0x00000000 MIPS-I ->>>>48 belong&0xf0000000 0x10000000 MIPS-II ->>>>48 belong&0xf0000000 0x20000000 MIPS-III ->>>>48 belong&0xf0000000 0x30000000 MIPS-IV ->>>>48 belong&0xf0000000 0x40000000 MIPS-V ->>>>48 belong&0xf0000000 0x50000000 MIPS32 ->>>>48 belong&0xf0000000 0x60000000 MIPS64 ->>>>48 belong&0xf0000000 0x70000000 MIPS32 rel2 ->>>>48 belong&0xf0000000 0x80000000 MIPS64 rel2 ->>18 beshort 9 Amdahl, ->>18 beshort 10 MIPS (deprecated), ->>18 beshort 11 RS6000, ->>18 beshort 15 PA-RISC ->>>50 beshort 0x0214 2.0 ->>>48 beshort &0x0008 (LP64) ->>18 beshort 16 nCUBE, ->>18 beshort 17 Fujitsu VPP500, ->>18 beshort 18 SPARC32PLUS, ->>>36 belong&0xffff00 &0x000100 V8+ Required, ->>>36 belong&0xffff00 &0x000200 Sun UltraSPARC1 Extensions Required, ->>>36 belong&0xffff00 &0x000400 HaL R1 Extensions Required, ->>>36 belong&0xffff00 &0x000800 Sun UltraSPARC3 Extensions Required, ->>18 beshort 20 PowerPC or cisco 4500, ->>18 beshort 21 64-bit PowerPC or cisco 7500, ->>18 beshort 22 IBM S/390, ->>18 beshort 23 Cell SPU, ->>18 beshort 24 cisco SVIP, ->>18 beshort 25 cisco 7200, ->>18 beshort 36 NEC V800 or cisco 12000, ->>18 beshort 37 Fujitsu FR20, ->>18 beshort 38 TRW RH-32, ->>18 beshort 39 Motorola RCE, ->>18 beshort 40 ARM, ->>18 beshort 41 Alpha, ->>18 beshort 42 Renesas SH, ->>18 beshort 43 SPARC V9, ->>18 beshort 44 Siemens Tricore Embedded Processor, ->>18 beshort 45 Argonaut RISC Core, Argonaut Technologies Inc., ->>18 beshort 46 Renesas H8/300, ->>18 beshort 47 Renesas H8/300H, ->>18 beshort 48 Renesas H8S, ->>18 beshort 49 Renesas H8/500, ->>18 beshort 50 IA-64, ->>18 beshort 51 Stanford MIPS-X, ->>18 beshort 52 Motorola Coldfire, ->>18 beshort 53 Motorola M68HC12, ->>18 beshort 73 Cray NV1, ->>18 beshort 75 Digital VAX, ->>18 beshort 88 Renesas M32R, ->>18 leshort 92 OpenRISC, ->>18 leshort 0x3426 OpenRISC (obsolete), ->>18 leshort 0x8472 OpenRISC (obsolete), ->>18 beshort 94 Tensilica Xtensa, ->>18 beshort 97 NatSemi 32k, ->>18 beshort 0x18ad AVR32 (unofficial), ->>18 beshort 0x9026 Alpha (unofficial), ->>18 beshort 0xa390 IBM S/390 (obsolete), ->>20 belong 0 invalid version ->>20 belong 1 version 1 ->>36 belong 1 MathCoPro/FPU/MAU Required diff --git a/dest/share/magic/filesystems b/dest/share/magic/filesystems deleted file mode 100644 index 7519b7d41d5..00000000000 --- a/dest/share/magic/filesystems +++ /dev/null @@ -1,1538 +0,0 @@ -# $OpenBSD: filesystems,v 1.5 2009/12/23 02:24:39 krw Exp $ - -#------------------------------------------------------------------------------ -# filesystems: file(1) magic for different filesystems -# -#0 string \366\366\366\366 PC formatted floppy with no filesystem -## Sun disk labels -## From /usr/include/sun/dklabel.h: -#0774 beshort 0xdabe -## modified by Joerg Jenderek, because original test -## succeeds for Cabinet archive dao360.dl_ with negative blocks -#>0770 long >0 Sun disk label -#>>0 string x '%s -#>>>31 string >\0 \b%s -#>>>>63 string >\0 \b%s -#>>>>>95 string >\0 \b%s -#>>0 string x \b' -#>>0734 short >0 %d rpm, -#>>0736 short >0 %d phys cys, -#>>0740 short >0 %d alts/cyl, -#>>0746 short >0 %d interleave, -#>>0750 short >0 %d data cyls, -#>>0752 short >0 %d alt cyls, -#>>0754 short >0 %d heads/partition, -#>>0756 short >0 %d sectors/track, -#>>0764 long >0 start cyl %ld, -#>>0770 long x %ld blocks -## Is there a boot block written 1 sector in? -#>512 belong&077777777 0600407 \b, boot block present -## Joerg Jenderek: Smart Boot Manager backup file is 41 byte header + first sectors of disc -## (http://btmgr.sourceforge.net/docs/user-guide-3.html) -#0 string SBMBAKUP_ Smart Boot Manager backup file -#>9 string x \b, version %-5.5s -#>>14 string =_ -#>>>15 string x %-.1s -#>>>>16 string =_ \b. -#>>>>>17 string x \b%-.1s -#>>>>>>18 string =_ \b. -#>>>>>>>19 string x \b%-.1s -#>>>22 ubyte 0 -#>>>>21 ubyte x \b, from drive 0x%x -#>>>22 ubyte >0 -#>>>>21 string x \b, from drive %s - -# Joerg Jenderek -# DOS Emulator image is 128 byte, null right padded header + harddisc image -0 string DOSEMU\0 ->0x27E leshort 0xAA55 -#offset is 128 ->>19 ubyte 128 ->>>(19.b-1) ubyte 0x0 DOS Emulator image ->>>>7 ulelong >0 \b, %u heads ->>>>11 ulelong >0 \b, %d sectors/track ->>>>15 ulelong >0 \b, %d cylinders - -# updated by Joerg Jenderek at Sep 2007 -# only for sector sizes with 512 or more Bytes -0x1FE leshort 0xAA55 x86 boot sector -# to do also for sectors < than 512 Bytes and some other files, GRR -#30 search/481 \x55\xAA x86 boot sector -# not for BeOS floppy 1440k, MBRs -#(11.s-2) uleshort 0xAA55 x86 boot sector ->2 string OSBS \b, OS/BS MBR -# J\xf6rg Jenderek ->0x8C string Invalid\ partition\ table \b, MS-DOS MBR -# dr-dos with some upper-, lowercase variants ->0x9D string Invalid\ partition\ table$ ->>181 string No\ Operating\ System$ ->>>201 string Operating\ System\ load\ error$ \b, DR-DOS MBR, Version 7.01 to 7.03 ->0x9D string Invalid\ partition\ table$ ->>181 string No\ operating\ system$ ->>>201 string Operating\ system\ load\ error$ \b, DR-DOS MBR, Version 7.01 to 7.03 ->342 string Invalid\ partition\ table$ ->>366 string No\ operating\ system$ ->>>386 string Operating\ system\ load\ error$ \b, DR-DOS MBR, version 7.01 to 7.03 ->295 string NEWLDR\0 ->>302 string Bad\ PT\ $ ->>>310 string No\ OS\ $ ->>>>317 string OS\ load\ err$ ->>>>>329 string Moved\ or\ missing\ IBMBIO.LDR\n\r ->>>>>>358 string Press\ any\ key\ to\ continue.\n\r$ ->>>>>>>387 string Copyright\ (c)\ 1984,1998 ->>>>>>>>411 string Caldera\ Inc.\0 \b, DR-DOS MBR (IBMBIO.LDR) ->0x10F string Ung\201ltige\ Partitionstabelle \b, MS-DOS MBR, german version 4.10.1998, 4.10.2222 ->>0x1B8 ubelong >0 \b, Serial 0x%-.4x ->0x8B string Ung\201ltige\ Partitionstabelle \b, MS-DOS MBR, german version 5.00 to 4.00.950 ->271 string Invalid\ partition\ table\0 ->>295 string Error\ loading\ operating\ system\0 ->>>326 string Missing\ operating\ system\0 \b, mbr -# ->139 string Invalid\ partition\ table\0 ->>163 string Error\ loading\ operating\ system\0 ->>>194 string Missing\ operating\ system\0 \b, Microsoft Windows XP mbr -# http://www.heise.de/ct/05/09/006/ page 184 -#HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices\DosDevices\?:=Serial4Bytes+8Bytes ->>>>0x1B8 ulelong >0 \b,Serial 0x%-.4x ->300 string Invalid\ partition\ table\0 ->>324 string Error\ loading\ operating\ system\0 ->>>355 string Missing\ operating\ system\0 \b, Microsoft Windows XP MBR -#??>>>389 string Invalid\ system\ disk ->>>>0x1B8 ulelong >0 \b, Serial 0x%-.4x ->300 string Ung\201ltige\ Partitionstabelle -#split string to avoid error: String too long ->>328 string Fehler\ beim\ Laden\ ->>>346 string des\ Betriebssystems ->>>>366 string Betriebssystem\ nicht\ vorhanden \b, Microsoft Windows XP MBR (german) ->>>>>0x1B8 ulelong >0 \b, Serial 0x%-.4x ->0x145 string Default:\ F \b, FREE-DOS MBR ->64 string no\ active\ partition\ found ->>96 string read\ error\ while\ reading\ drive \b, FREE-DOS Beta 0.9 MBR ->271 string Operating\ system\ loading ->>296 string error\r \b, SYSLINUX MBR (2.10) -# http://www.acronis.de/ ->362 string MBR\ Error\ \0\r ->>376 string ress\ any\ key\ to\ ->>>392 string boot\ from\ floppy...\0 \b, Acronis MBR -# added by Joerg Jenderek -# http://www.visopsys.org/ -# http://partitionlogic.org.uk/ ->309 string No\ bootable\ partition\ found\r ->>339 string I/O\ Error\ reading\ boot\ sector\r \b, Visopsys MBR ->349 string No\ bootable\ partition\ found\r ->>379 string I/O\ Error\ reading\ boot\ sector\r \b, simple Visopsys MBR -# bootloader, bootmanager ->0x40 string SBML -# label with 11 characters of FAT 12 bit filesystem ->>43 string SMART\ BTMGR ->>>430 string SBMK\ Bad!\r ->>>>3 string SBM \b, Smart Boot Manager ->>>>>6 string >\0 \b, version %s ->382 string XOSLLOADXCF \b, eXtended Operating System Loader ->6 string LILO \b, LInux i386 boot LOader ->>120 string LILO \b, version 22.3.4 SuSe ->>172 string LILO \b, version 22.5.8 Debian -# updated by Joerg Jenderek -# variables according to grub-0.97/stage1/stage1.S or -# http://www.gnu.org/software/grub/manual/grub.html#Embedded-data -# usual values are marked with comments to get only informations of strange GRUB loaders ->0 ulelong 0x009048EB ->>0x41 ubyte <2 ->>>0x3E ubyte >2 \b; GRand Unified Bootloader -# 0x3 for 0.5.95,0.93,0.94,0.96 0x4 for 1.90 ->>>>0x3E ubyte x \b, stage1 version 0x%x -#If it is 0xFF, use a drive passed by BIOS ->>>>0x40 ubyte <0xFF \b, boot drive 0x%x -# in most case 0,1,0x2e for GRUB 0.5.95 ->>>>0x41 ubyte >0 \b, LBA flag 0x%x ->>>>0x42 uleshort <0x8000 \b, stage2 address 0x%x -#>>>>0x42 uleshort =0x8000 \b, stage2 address 0x%x (usual) ->>>>0x42 uleshort >0x8000 \b, stage2 address 0x%x -#>>>>0x44 ulelong =1 \b, 1st sector stage2 0x%x (default) ->>>>0x44 ulelong >1 \b, 1st sector stage2 0x%x ->>>>0x48 uleshort <0x800 \b, stage2 segment 0x%x -#>>>>0x48 uleshort =0x800 \b, stage2 segment 0x%x (usual) ->>>>0x48 uleshort >0x800 \b, stage2 segment 0x%x ->>>>402 string Geom\0Hard\ Disk\0Read\0\ Error\0 ->>>>>394 string stage1 \b, GRUB version 0.5.95 ->>>>382 string Geom\0Hard\ Disk\0Read\0\ Error\0 ->>>>>376 string GRUB\ \0 \b, GRUB version 0.93 or 1.94 ->>>>383 string Geom\0Hard\ Disk\0Read\0\ Error\0 ->>>>>377 string GRUB\ \0 \b, GRUB version 0.94 ->>>>385 string Geom\0Hard\ Disk\0Read\0\ Error\0 ->>>>>379 string GRUB\ \0 \b, GRUB version 0.95 or 0.96 ->>>>391 string Geom\0Hard\ Disk\0Read\0\ Error\0 ->>>>>385 string GRUB\ \0 \b, GRUB version 0.97 -#unknown version ->>>343 string Geom\0Read\0\ Error\0 ->>>>321 string Loading\ stage1.5 \b, GRUB version x.y ->>>380 string Geom\0Hard\ Disk\0Read\0\ Error\0 ->>>>374 string GRUB\ \0 \b, GRUB version n.m -# http://syslinux.zytor.com/ ->478 string Boot\ failed\r ->>495 string LDLINUX\ SYS \b, SYSLINUX bootloader (1.62) ->480 string Boot\ failed\r ->>495 string LDLINUX\ SYS \b, SYSLINUX bootloader (2.06 or 2.11) ->484 string Boot\ error\r \b, SYSLINUX bootloader (3.11) ->395 string chksum\0\ ERROR!\0 \b, Gujin bootloader -# http://www.bcdwb.de/bcdw/index_e.htm ->3 string BCDL ->>498 string BCDL\ \ \ \ BIN \b, Bootable CD Loader (1.50Z) -# mbr partition table entries -# OEM-ID not Microsoft,SYSLINUX,or MTOOLs ->3 string !MS ->>3 string !SYSLINUX ->>>3 string !MTOOL -# not FAT (32 bit) ->>>>82 string !FAT32 -#not IO.SYS ->>>>>472 string !IO\ \ \ \ \ \ SYS ->>>>>>480 string !IO\ \ \ \ \ \ SYS -#not Linux kernel ->>>>>>>514 string !HdrS -#not BeOS ->>>>>>>>422 string !Be\ Boot\ Loader -# active flag 0 or 0x80 and type > 0 ->>>>>>>>>446 ubyte <0x81 ->>>>>>>>>>446 ubyte&0x7F 0 ->>>>>>>>>>>450 ubyte >0 \b; partition 1: ID=0x%x ->>>>>>>>>>>>446 ubyte 0x80 \b, active ->>>>>>>>>>>>447 ubyte x \b, starthead %u -#>>>>>>>>>>>>448 ubyte x \b, start C_S: 0x%x -#>>>>>>>>>>>>448 ubeshort&1023 x \b, startcylinder? %d ->>>>>>>>>>>>454 ulelong x \b, startsector %u ->>>>>>>>>>>>458 ulelong x \b, %u sectors -# ->>>>>>>>>462 ubyte <0x81 ->>>>>>>>>>462 ubyte&0x7F 0 ->>>>>>>>>>>466 ubyte >0 \b; partition 2: ID=0x%x ->>>>>>>>>>>>462 ubyte 0x80 \b, active ->>>>>>>>>>>>463 ubyte x \b, starthead %u -#>>>>>>>>>>>>464 ubyte x \b, start C_S: 0x%x -#>>>>>>>>>>>>464 ubeshort&1023 x \b, startcylinder? %d ->>>>>>>>>>>>470 ulelong x \b, startsector %u ->>>>>>>>>>>>474 ulelong x \b, %u sectors -# ->>>>>>>>>478 ubyte <0x81 ->>>>>>>>>>478 ubyte&0x7F 0 ->>>>>>>>>>>482 ubyte >0 \b; partition 3: ID=0x%x ->>>>>>>>>>>>478 ubyte 0x80 \b, active ->>>>>>>>>>>>479 ubyte x \b, starthead %u -#>>>>>>>>>>>>480 ubyte x \b, start C_S: 0x%x -#>>>>>>>>>>>>481 ubyte x \b, start C2S: 0x%x -#>>>>>>>>>>>>480 ubeshort&1023 x \b, startcylinder? %d ->>>>>>>>>>>>486 ulelong x \b, startsector %u ->>>>>>>>>>>>490 ulelong x \b, %u sectors -# ->>>>>>>>>494 ubyte <0x81 ->>>>>>>>>>494 ubyte&0x7F 0 ->>>>>>>>>>>498 ubyte >0 \b; partition 4: ID=0x%x ->>>>>>>>>>>>494 ubyte 0x80 \b, active ->>>>>>>>>>>>495 ubyte x \b, starthead %u -#>>>>>>>>>>>>496 ubyte x \b, start C_S: 0x%x -#>>>>>>>>>>>>496 ubeshort&1023 x \b, startcylinder? %d ->>>>>>>>>>>>502 ulelong x \b, startsector %u ->>>>>>>>>>>>506 ulelong x \b, %u sectors -# mbr partition table entries end -# http://www.acronis.de/ -#FAT label=ACRONIS\ SZ -#OEM-ID=BOOTWIZ0 ->442 string Non-system\ disk,\ ->>459 string press\ any\ key...\x7\0 \b, Acronis Startup Recovery Loader -# DOS names like F11.SYS are 8 right space padded bytes+3 bytes ->>>477 ubyte&0xDF >0 ->>>>477 string x \b %-.3s ->>>>>480 ubyte&0xDF >0 ->>>>>>480 string x \b%-.5s ->>>>485 ubyte&0xDF >0 ->>>>>485 string x \b.%-.3s -# ->185 string FDBOOT\ Version\ ->>204 string \rNo\ Systemdisk.\ ->>>220 string Booting\ from\ harddisk.\n\r ->>>245 string Cannot\ load\ from\ harddisk.\n\r ->>>>273 string Insert\ Systemdisk\ ->>>>>291 string and\ press\ any\ key.\n\r \b, FDBOOT harddisk Bootloader ->>>>>>200 string >\0 \b, version %-3s ->242 string Bootsector\ from\ C.H.\ Hochst\204 ->>278 string No\ Systemdisk.\ ->>>293 string Booting\ from\ harddisk.\n\r ->>>441 string Cannot\ load\ from\ harddisk.\n\r ->>>>469 string Insert\ Systemdisk\ ->>>>>487 string and\ press\ any\ key.\n\r \b, WinImage harddisk Bootloader ->>>>>>209 string >\0 \b, version %-4.4s ->(1.b+2) ubyte 0xe ->>(1.b+3) ubyte 0x1f ->>>(1.b+4) ubyte 0xbe ->>>>(1.b+5) ubyte 0x77 ->>>>(1.b+6) ubyte 0x7c ->>>>>(1.b+7) ubyte 0xac ->>>>>>(1.b+8) ubyte 0x22 ->>>>>>>(1.b+9) ubyte 0xc0 ->>>>>>>>(1.b+10) ubyte 0x74 ->>>>>>>>>(1.b+11) ubyte 0xb ->>>>>>>>>>(1.b+12) ubyte 0x56 ->>>>>>>>>>(1.b+13) ubyte 0xb4 \b, mkdosfs boot message display ->103 string This\ is\ not\ a\ bootable\ disk.\ ->>132 string Please\ insert\ a\ bootable\ ->>>157 string floppy\ and\r\n ->>>>169 string press\ any\ key\ to\ try\ again...\r \b, FREE-DOS message display -# ->66 string Solaris\ Boot\ Sector ->>99 string Incomplete\ MDBoot\ load. ->>>89 string Version \b, Sun Solaris Bootloader ->>>>97 byte x version %c -# ->408 string OS/2\ !!\ SYS01475\r\0 ->>429 string OS/2\ !!\ SYS02025\r\0 ->>>450 string OS/2\ !!\ SYS02027\r\0 ->>>469 string OS2BOOT\ \ \ \ \b, IBM OS/2 Warp bootloader -# ->409 string OS/2\ !!\ SYS01475\r\0 ->>430 string OS/2\ !!\ SYS02025\r\0 ->>>451 string OS/2\ !!\ SYS02027\r\0 ->>>470 string OS2BOOT\ \ \ \ \b, IBM OS/2 Warp Bootloader ->112 string This\ disk\ is\ not\ bootable\r ->>142 string If\ you\ wish\ to\ make\ it\ bootable ->>>176 string run\ the\ DOS\ program\ SYS\ ->>>200 string after\ the\r ->>>>216 string system\ has\ been\ loaded\r\n ->>>>>242 string Please\ insert\ a\ DOS\ diskette\ ->>>>>271 string into\r\n\ the\ drive\ and\ ->>>>>>292 string strike\ any\ key...\0 \b, IBM OS/2 Warp message display -# XP ->430 string NTLDR\ is\ missing\xFF\r\n ->>449 string Disk\ error\xFF\r\n ->>>462 string Press\ any\ key\ to\ restart\r \b, Microsoft Windows XP Bootloader -# DOS names like NTLDR,CMLDR,$LDR$ are 8 right space padded bytes+3 bytes ->>>>417 ubyte&0xDF >0 ->>>>>417 string x %-.5s ->>>>>>422 ubyte&0xDF >0 ->>>>>>>422 string x \b%-.3s ->>>>>425 ubyte&0xDF >0 ->>>>>>425 string >\ \b.%-.3s -# ->>>>371 ubyte >0x20 ->>>>>368 ubyte&0xDF >0 ->>>>>>368 string x %-.5s ->>>>>>>373 ubyte&0xDF >0 ->>>>>>>>373 string x \b%-.3s ->>>>>>376 ubyte&0xDF >0 ->>>>>>>376 string x \b.%-.3s -# ->430 string NTLDR\ nicht\ gefunden\xFF\r\n ->>453 string Datentr\204gerfehler\xFF\r\n ->>>473 string Neustart\ mit\ beliebiger\ Taste\r \b, Microsoft Windows XP Bootloader (german) ->>>>417 ubyte&0xDF >0 ->>>>>417 string x %-.5s ->>>>>>422 ubyte&0xDF >0 ->>>>>>>422 string x \b%-.3s ->>>>>425 ubyte&0xDF >0 ->>>>>>425 string >\ \b.%-.3s -# offset variant ->>>>379 string \0 ->>>>>368 ubyte&0xDF >0 ->>>>>>368 string x %-.5s ->>>>>>>373 ubyte&0xDF >0 ->>>>>>>>373 string x \b%-.3s -# ->430 string NTLDR\ fehlt\xFF\r\n ->>444 string Datentr\204gerfehler\xFF\r\n ->>>464 string Neustart\ mit\ beliebiger\ Taste\r \b, Microsoft Windows XP Bootloader (2.german) ->>>>417 ubyte&0xDF >0 ->>>>>417 string x %-.5s ->>>>>>422 ubyte&0xDF >0 ->>>>>>>422 string x \b%-.3s ->>>>>425 ubyte&0xDF >0 ->>>>>>425 string >\ \b.%-.3s -# variant ->>>>371 ubyte >0x20 ->>>>>368 ubyte&0xDF >0 ->>>>>>368 string x %-.5s ->>>>>>>373 ubyte&0xDF >0 ->>>>>>>>373 string x \b%-.3s ->>>>>>376 ubyte&0xDF >0 ->>>>>>>376 string x \b.%-.3s -# ->430 string NTLDR\ fehlt\xFF\r\n ->>444 string Medienfehler\xFF\r\n ->>>459 string Neustart:\ Taste\ dr\201cken\r \b, Microsoft Windows XP Bootloader (3.german) ->>>>371 ubyte >0x20 ->>>>>368 ubyte&0xDF >0 ->>>>>>368 string x %-.5s ->>>>>>>373 ubyte&0xDF >0 ->>>>>>>>373 string x \b%-.3s ->>>>>>376 ubyte&0xDF >0 ->>>>>>>376 string x \b.%-.3s -# variant ->>>>417 ubyte&0xDF >0 ->>>>>417 string x %-.5s ->>>>>>422 ubyte&0xDF >0 ->>>>>>>422 string x \b%-.3s ->>>>>425 ubyte&0xDF >0 ->>>>>>425 string >\ \b.%-.3s -# ->430 string Datentr\204ger\ entfernen\xFF\r\n ->>454 string Medienfehler\xFF\r\n ->>>469 string Neustart:\ Taste\ dr\201cken\r \b, Microsoft Windows XP Bootloader (4.german) ->>>>368 ubyte&0xDF >0 ->>>>>368 string x %-.5s ->>>>>>373 ubyte&0xDF >0 ->>>>>>>373 string x \b%-.3s ->>>>>376 ubyte&0xDF >0 ->>>>>>376 string x \b.%-.3s -#>3 string NTFS\ \ \ \ ->389 string Fehler\ beim\ Lesen\ ->>407 string des\ Datentr\204gers ->>>426 string NTLDR\ fehlt ->>>>440 string NTLDR\ ist\ komprimiert ->>>>>464 string Neustart\ mit\ Strg+Alt+Entf\r \b, Microsoft Windows XP Bootloader NTFS (german) -#>3 string NTFS\ \ \ \ ->313 string A\ disk\ read\ error\ occurred.\r ->>345 string A\ kernel\ file\ is\ missing\ ->>>370 string from\ the\ disk.\r ->>>>484 string NTLDR\ is\ compressed ->>>>>429 string Insert\ a\ system\ diskette\ ->>>>>>454 string and\ restart\r\nthe\ system.\r \b, Microsoft Windows XP Bootloader NTFS -# DOS loader variants different languages,offsets ->472 ubyte&0xDF >0 ->>389 string Invalid\ system\ disk\xFF\r\n ->>>411 string Disk\ I/O\ error ->>>>428 string Replace\ the\ disk,\ and\ ->>>>>455 string press\ any\ key \b, Microsoft Windows 98 Bootloader -#IO.SYS ->>>>>>472 ubyte&0xDF >0 ->>>>>>>472 string x \b %-.2s ->>>>>>>>474 ubyte&0xDF >0 ->>>>>>>>>474 string x \b%-.5s ->>>>>>>>>>479 ubyte&0xDF >0 ->>>>>>>>>>>479 string x \b%-.1s ->>>>>>>480 ubyte&0xDF >0 ->>>>>>>>480 string x \b.%-.3s -#MSDOS.SYS ->>>>>>>483 ubyte&0xDF >0 \b+ ->>>>>>>>483 string x \b%-.5s ->>>>>>>>>488 ubyte&0xDF >0 ->>>>>>>>>>488 string x \b%-.3s ->>>>>>>>491 ubyte&0xDF >0 ->>>>>>>>>491 string x \b.%-.3s -# ->>390 string Invalid\ system\ disk\xFF\r\n ->>>412 string Disk\ I/O\ error\xFF\r\n ->>>>429 string Replace\ the\ disk,\ and\ ->>>>>451 string then\ press\ any\ key\r \b, Microsoft Windows 98 Bootloader ->>388 string Ungueltiges\ System\ \xFF\r\n ->>>410 string E/A-Fehler\ \ \ \ \xFF\r\n ->>>>427 string Datentraeger\ wechseln\ und\ ->>>>>453 string Taste\ druecken\r \b, Microsoft Windows 95/98/ME Bootloader (german) -#WINBOOT.SYS only not spaces (0xDF) ->>>>>>497 ubyte&0xDF >0 ->>>>>>>497 string x %-.5s ->>>>>>>>502 ubyte&0xDF >0 ->>>>>>>>>502 string x \b%-.1s ->>>>>>>>>>503 ubyte&0xDF >0 ->>>>>>>>>>>503 string x \b%-.1s ->>>>>>>>>>>>504 ubyte&0xDF >0 ->>>>>>>>>>>>>504 string x \b%-.1s ->>>>>>505 ubyte&0xDF >0 ->>>>>>>505 string x \b.%-.3s -#IO.SYS ->>>>>>472 ubyte&0xDF >0 or ->>>>>>>472 string x \b %-.2s ->>>>>>>>474 ubyte&0xDF >0 ->>>>>>>>>474 string x \b%-.5s ->>>>>>>>>>479 ubyte&0xDF >0 ->>>>>>>>>>>479 string x \b%-.1s ->>>>>>>480 ubyte&0xDF >0 ->>>>>>>>480 string x \b.%-.3s -#MSDOS.SYS ->>>>>>>483 ubyte&0xDF >0 \b+ ->>>>>>>>483 string x \b%-.5s ->>>>>>>>>488 ubyte&0xDF >0 ->>>>>>>>>>488 string x \b%-.3s ->>>>>>>>491 ubyte&0xDF >0 ->>>>>>>>>491 string x \b.%-.3s -# ->>390 string Ungueltiges\ System\ \xFF\r\n ->>>412 string E/A-Fehler\ \ \ \ \xFF\r\n ->>>>429 string Datentraeger\ wechseln\ und\ ->>>>>455 string Taste\ druecken\r \b, Microsoft Windows 95/98/ME Bootloader (German) -#WINBOOT.SYS only not spaces (0xDF) ->>>>>>497 ubyte&0xDF >0 ->>>>>>>497 string x %-.7s ->>>>>>>>504 ubyte&0xDF >0 ->>>>>>>>>504 string x \b%-.1s ->>>>>>505 ubyte&0xDF >0 ->>>>>>>505 string x \b.%-.3s -#IO.SYS ->>>>>>472 ubyte&0xDF >0 or ->>>>>>>472 string x \b %-.2s ->>>>>>>>474 ubyte&0xDF >0 ->>>>>>>>>474 string x \b%-.6s ->>>>>>>480 ubyte&0xDF >0 ->>>>>>>>480 string x \b.%-.3s -#MSDOS.SYS ->>>>>>>483 ubyte&0xDF >0 \b+ ->>>>>>>>483 string x \b%-.5s ->>>>>>>>>488 ubyte&0xDF >0 ->>>>>>>>>>488 string x \b%-.3s ->>>>>>>>491 ubyte&0xDF >0 ->>>>>>>>>491 string x \b.%-.3s -# ->>389 string Ungueltiges\ System\ \xFF\r\n ->>>411 string E/A-Fehler\ \ \ \ \xFF\r\n ->>>>428 string Datentraeger\ wechseln\ und\ ->>>>>454 string Taste\ druecken\r \b, Microsoft Windows 95/98/ME Bootloader (GERMAN) -# DOS names like IO.SYS,WINBOOT.SYS,MSDOS.SYS,WINBOOT.INI are 8 right space padded bytes+3 bytes ->>>>>>472 string x %-.2s ->>>>>>>474 ubyte&0xDF >0 ->>>>>>>>474 string x \b%-.5s ->>>>>>>>479 ubyte&0xDF >0 ->>>>>>>>>479 string x \b%-.1s ->>>>>>480 ubyte&0xDF >0 ->>>>>>>480 string x \b.%-.3s ->>>>>>483 ubyte&0xDF >0 \b+ ->>>>>>>483 string x \b%-.5s ->>>>>>>488 ubyte&0xDF >0 ->>>>>>>>488 string x \b%-.2s ->>>>>>>>490 ubyte&0xDF >0 ->>>>>>>>>490 string x \b%-.1s ->>>>>>>491 ubyte&0xDF >0 ->>>>>>>>491 string x \b.%-.3s ->479 ubyte&0xDF >0 ->>416 string Kein\ System\ oder\ ->>>433 string Laufwerksfehler ->>>>450 string Wechseln\ und\ Taste\ dr\201cken \b, Microsoft DOS Bootloader (german) -#IO.SYS ->>>>>479 string x \b %-.2s ->>>>>>481 ubyte&0xDF >0 ->>>>>>>481 string x \b%-.6s ->>>>>487 ubyte&0xDF >0 ->>>>>>487 string x \b.%-.3s -#MSDOS.SYS ->>>>>>490 ubyte&0xDF >0 \b+ ->>>>>>>490 string x \b%-.5s ->>>>>>>>495 ubyte&0xDF >0 ->>>>>>>>>495 string x \b%-.3s ->>>>>>>498 ubyte&0xDF >0 ->>>>>>>>498 string x \b.%-.3s -# ->376 search/41 Non-System\ disk\ or\ ->>395 search/41 disk\ error\r ->>>407 search/41 Replace\ and\ ->>>>419 search/41 press\ \b, ->>>>419 search/41 strike\ \b, old ->>>>426 search/41 any\ key\ when\ ready\r MS or PC-DOS bootloader -#449 Disk\ Boot\ failure\r MS 3.21 -#466 Boot\ Failure\r MS 3.30 ->>>>>468 search/18 \0 -#IO.SYS,IBMBIO.COM ->>>>>>&0 string x \b %-.2s ->>>>>>>&-20 ubyte&0xDF >0 ->>>>>>>>&-1 string x \b%-.4s ->>>>>>>>>&-16 ubyte&0xDF >0 ->>>>>>>>>>&-1 string x \b%-.2s ->>>>>>&8 ubyte&0xDF >0 \b. ->>>>>>>&-1 string x \b%-.3s -#MSDOS.SYS,IBMDOS.COM ->>>>>>&11 ubyte&0xDF >0 \b+ ->>>>>>>&-1 string x \b%-.5s ->>>>>>>>&-6 ubyte&0xDF >0 ->>>>>>>>>&-1 string x \b%-.1s ->>>>>>>>>>&-5 ubyte&0xDF >0 ->>>>>>>>>>>&-1 string x \b%-.2s ->>>>>>>&7 ubyte&0xDF >0 \b. ->>>>>>>>&-1 string x \b%-.3s ->441 string Cannot\ load\ from\ harddisk.\n\r ->>469 string Insert\ Systemdisk\ ->>>487 string and\ press\ any\ key.\n\r \b, MS (2.11) DOS bootloader -#>43 string \224R-LOADER\ \ SYS =label ->54 string SYS ->>324 string VASKK ->>>495 string NEWLDR\0 \b, DR-DOS Bootloader (LOADER.SYS) -# ->98 string Press\ a\ key\ to\ retry\0\r ->>120 string Cannot\ find\ file\ \0\r ->>>139 string Disk\ read\ error\0\r ->>>>156 string Loading\ ...\0 \b, DR-DOS (3.41) Bootloader -#DRBIOS.SYS ->>>>>44 ubyte&0xDF >0 ->>>>>>44 string x \b %-.6s ->>>>>>>50 ubyte&0xDF >0 ->>>>>>>>50 string x \b%-.2s ->>>>>>52 ubyte&0xDF >0 ->>>>>>>52 string x \b.%-.3s -# ->70 string IBMBIO\ \ COM ->>472 string Cannot\ load\ DOS!\ ->>>489 string Any\ key\ to\ retry \b, DR-DOS Bootloader ->>471 string Cannot\ load\ DOS\ ->>487 string press\ key\ to\ retry \b, Open-DOS Bootloader ->444 string KERNEL\ \ SYS ->>314 string BOOT\ error! \b, FREE-DOS Bootloader ->499 string KERNEL\ \ SYS ->>305 string BOOT\ err!\0 \b, Free-DOS Bootloader ->449 string KERNEL\ \ SYS ->>319 string BOOT\ error! \b, FREE-DOS 0.5 Bootloader ->125 string Loading\ FreeDOS...\r ->>311 string BOOT\ error!\r \b, FREE-DOS bootloader ->>>441 ubyte&0xDF >0 ->>>>441 string x \b %-.6s ->>>>>447 ubyte&0xDF >0 ->>>>>>447 string x \b%-.1s ->>>>>>>448 ubyte&0xDF >0 ->>>>>>>>448 string x \b%-.1s ->>>>449 ubyte&0xDF >0 ->>>>>449 string x \b.%-.3s ->124 string FreeDOS\0 ->>331 string \ err\0 \b, FREE-DOS BETa 0.9 Bootloader -# DOS names like KERNEL.SYS,KERNEL16.SYS,KERNEL32.SYS,METAKERN.SYS are 8 right space padded bytes+3 bytes ->>>497 ubyte&0xDF >0 ->>>>497 string x \b %-.6s ->>>>>503 ubyte&0xDF >0 ->>>>>>503 string x \b%-.1s ->>>>>>>504 ubyte&0xDF >0 ->>>>>>>>504 string x \b%-.1s ->>>>505 ubyte&0xDF >0 ->>>>>505 string x \b.%-.3s ->>333 string \ err\0 \b, FREE-DOS BEta 0.9 Bootloader ->>>497 ubyte&0xDF >0 ->>>>497 string x \b %-.6s ->>>>>503 ubyte&0xDF >0 ->>>>>>503 string x \b%-.1s ->>>>>>>504 ubyte&0xDF >0 ->>>>>>>>504 string x \b%-.1s ->>>>505 ubyte&0xDF >0 ->>>>>505 string x \b.%-.3s ->>334 string \ err\0 \b, FREE-DOS Beta 0.9 Bootloader ->>>497 ubyte&0xDF >0 ->>>>497 string x \b %-.6s ->>>>>503 ubyte&0xDF >0 ->>>>>>503 string x \b%-.1s ->>>>>>>504 ubyte&0xDF >0 ->>>>>>>>504 string x \b%-.1s ->>>>505 ubyte&0xDF >0 ->>>>>505 string x \b.%-.3s ->336 string Error!\ ->>343 string Hit\ a\ key\ to\ reboot. \b, FREE-DOS Beta 0.9sr1 Bootloader ->>>497 ubyte&0xDF >0 ->>>>497 string x \b %-.6s ->>>>>503 ubyte&0xDF >0 ->>>>>>503 string x \b%-.1s ->>>>>>>504 ubyte&0xDF >0 ->>>>>>>>504 string x \b%-.1s ->>>>505 ubyte&0xDF >0 ->>>>>505 string x \b.%-.3s -# added by Joerg Jenderek -# http://www.visopsys.org/ -# http://partitionlogic.org.uk/ -# OEM-ID=Visopsys ->478 ulelong 0 ->>(1.b+326) string I/O\ Error\ reading\ ->>>(1.b+344) string Visopsys\ loader\r ->>>>(1.b+361) string Press\ any\ key\ to\ continue.\r \b, Visopsys loader -# http://alexfru.chat.ru/epm.html#bootprog ->494 ubyte >0x4D ->>495 string >E ->>>495 string >>>3 string BootProg -# It just looks for a program file name at the root directory -# and loads corresponding file with following execution. -# DOS names like STARTUP.BIN,STARTUPC.COM,STARTUPE.EXE are 8 right space padded bytes+3 bytes ->>>>499 ubyte&0xDF >0 \b, COM/EXE Bootloader ->>>>>499 string x \b %-.1s ->>>>>>500 ubyte&0xDF >0 ->>>>>>>500 string x \b%-.1s ->>>>>>>>501 ubyte&0xDF >0 ->>>>>>>>>501 string x \b%-.1s ->>>>>>>>>>502 ubyte&0xDF >0 ->>>>>>>>>>>502 string x \b%-.1s ->>>>>>>>>>>>503 ubyte&0xDF >0 ->>>>>>>>>>>>>503 string x \b%-.1s ->>>>>>>>>>>>>>504 ubyte&0xDF >0 ->>>>>>>>>>>>>>>504 string x \b%-.1s ->>>>>>>>>>>>>>>>505 ubyte&0xDF >0 ->>>>>>>>>>>>>>>>>505 string x \b%-.1s ->>>>>>>>>>>>>>>>>>506 ubyte&0xDF >0 ->>>>>>>>>>>>>>>>>>>506 string x \b%-.1s -#name extension ->>>>>507 ubyte&0xDF >0 \b. ->>>>>>507 string x \b%-.1s ->>>>>>>508 ubyte&0xDF >0 ->>>>>>>>508 string x \b%-.1s ->>>>>>>>>509 ubyte&0xDF >0 ->>>>>>>>>>509 string x \b%-.1s -#If the boot sector fails to read any other sector, -#it prints a very short message ("RE") to the screen and hangs the computer. -#If the boot sector fails to find needed program in the root directory, -#it also hangs with another message ("NF"). ->>>>>492 string RENF \b, FAT (12 bit) ->>>>>495 string RENF \b, FAT (16 bit) -# http://alexfru.chat.ru/epm.html#bootprog ->494 ubyte >0x4D ->>495 string >E ->>>495 string >>>3 string BootProg -# It just looks for a program file name at the root directory -# and loads corresponding file with following execution. -# DOS names like STARTUP.BIN,STARTUPC.COM,STARTUPE.EXE are 8 right space padded bytes+3 bytes ->>>>499 ubyte&0xDF >0 \b, COM/EXE Bootloader ->>>>>499 string x \b %-.1s ->>>>>>500 ubyte&0xDF >0 ->>>>>>>500 string x \b%-.1s ->>>>>>>>501 ubyte&0xDF >0 ->>>>>>>>>501 string x \b%-.1s ->>>>>>>>>>502 ubyte&0xDF >0 ->>>>>>>>>>>502 string x \b%-.1s ->>>>>>>>>>>>503 ubyte&0xDF >0 ->>>>>>>>>>>>>503 string x \b%-.1s ->>>>>>>>>>>>>>504 ubyte&0xDF >0 ->>>>>>>>>>>>>>>504 string x \b%-.1s ->>>>>>>>>>>>>>>>505 ubyte&0xDF >0 ->>>>>>>>>>>>>>>>>505 string x \b%-.1s ->>>>>>>>>>>>>>>>>>506 ubyte&0xDF >0 ->>>>>>>>>>>>>>>>>>>506 string x \b%-.1s -#name extension ->>>>>507 ubyte&0xDF >0 \b. ->>>>>>507 string x \b%-.1s ->>>>>>>508 ubyte&0xDF >0 ->>>>>>>>508 string x \b%-.1s ->>>>>>>>>509 ubyte&0xDF >0 ->>>>>>>>>>509 string x \b%-.1s -#If the boot sector fails to read any other sector, -#it prints a very short message ("RE") to the screen and hangs the computer. -#If the boot sector fails to find needed program in the root directory, -#it also hangs with another message ("NF"). ->>>>>492 string RENF \b, FAT (12 bit) ->>>>>495 string RENF \b, FAT (16 bit) -# added by Joerg Jenderek -# http://syslinux.zytor.com/iso.php -0 ulelong 0x7c40eafa isolinux Loader -# http://syslinux.zytor.com/pxe.php -0 ulelong 0x007c05ea pxelinux Loader -0 ulelong 0x60669c66 pxelinux Loader -# loader end -# updated by Joerg Jenderek at Sep 2007 ->3 ubyte 0 -#no active flag ->>446 ubyte 0 -# partition 1 not empty ->>>450 ubyte >0 -# partitions 3,4 empty ->>>>482 ubyte 0 ->>>>>498 ubyte 0 -# partition 2 ID=0,5,15 ->>>>>>466 ubyte <0x10 ->>>>>>>466 ubyte 0x05 \b, extended partition table ->>>>>>>466 ubyte 0x0F \b, extended partition table (LBA) ->>>>>>>466 ubyte 0x0 \b, extended partition table (last) -# JuMP short bootcodeoffset NOP assembler instructions will usually be EB xx 90 -# http://mirror.href.com/thestarman/asm/2bytejumps.htmm#FWD -# older drives may use Near JuMP instruction E9 xx xx ->0 lelong&0x009000EB 0x009000EB ->0 lelong&0x000000E9 0x000000E9 -# maximal short forward jump is 07fx ->1 ubyte <0xff \b, code offset 0x%x -# mtools-3.9.8/msdos.h -# usual values are marked with comments to get only informations of strange FAT systems -# valid sectorsize must be a power of 2 from 32 to 32768 ->>11 uleshort&0x000f x ->>>11 uleshort <32769 ->>>>11 uleshort >31 ->>>>>3 string >\0 \b, OEM-ID "%8.8s" -#http://mirror.href.com/thestarman/asm/debug/debug2.htm#IHC ->>>>>>8 string IHC \b cached by Windows 9M ->>>>>11 uleshort >512 \b, Bytes/sector %u -#>>>>>11 uleshort =512 \b, Bytes/sector %u=512 (usual) ->>>>>11 uleshort <512 \b, Bytes/sector %u ->>>>>13 ubyte >1 \b, sectors/cluster %u -#>>>>>13 ubyte =1 \b, sectors/cluster %u (usual on Floppies) ->>>>>14 uleshort >32 \b, reserved sectors %u -#>>>>>14 uleshort =32 \b, reserved sectors %u (usual Fat32) -#>>>>>14 uleshort >1 \b, reserved sectors %u -#>>>>>14 uleshort =1 \b, reserved sectors %u (usual FAT12,FAT16) ->>>>>14 uleshort <1 \b, reserved sectors %u ->>>>>16 ubyte >2 \b, FATs %u -#>>>>>16 ubyte =2 \b, FATs %u (usual) ->>>>>16 ubyte =1 \b, FAT %u ->>>>>16 ubyte >0 ->>>>>17 uleshort >0 \b, root entries %u -#>>>>>17 uleshort =0 \b, root entries %u=0 (usual Fat32) ->>>>>19 uleshort >0 \b, sectors %u (volumes <=32 MB) -#>>>>>19 uleshort =0 \b, sectors %u=0 (usual Fat32) ->>>>>21 ubyte >0xF0 \b, Media descriptor 0x%x -#>>>>>21 ubyte =0xF0 \b, Media descriptor 0x%x (usual floppy) ->>>>>21 ubyte <0xF0 \b, Media descriptor 0x%x ->>>>>22 uleshort >0 \b, sectors/FAT %u -#>>>>>22 uleshort =0 \b, sectors/FAT %u=0 (usual Fat32) ->>>>>26 ubyte >2 \b, heads %u -#>>>>>26 ubyte =2 \b, heads %u (usual floppy) ->>>>>26 ubyte =1 \b, heads %u -#skip for Digital Research DOS (version 3.41) 1440 kB Bootdisk ->>>>>38 ubyte !0x70 ->>>>>>28 ulelong >0 \b, hidden sectors %u -#>>>>>>28 ulelong =0 \b, hidden sectors %u (usual floppy) ->>>>>>32 ulelong >0 \b, sectors %u (volumes > 32 MB) -#>>>>>>32 ulelong =0 \b, sectors %u (volumes > 32 MB) -# FAT<32 specific ->>>>>82 string !FAT32 -#>>>>>>36 ubyte 0x80 \b, physical drive 0x%x=0x80 (usual harddisk) -#>>>>>>36 ubyte 0 \b, physical drive 0x%x=0 (usual floppy) ->>>>>>36 ubyte !0x80 ->>>>>>>36 ubyte !0 \b, physical drive 0x%x ->>>>>>37 ubyte >0 \b, reserved 0x%x -#>>>>>>37 ubyte =0 \b, reserved 0x%x ->>>>>>38 ubyte >0x29 \b, dos < 4.0 BootSector (0x%x) ->>>>>>38 ubyte <0x29 \b, dos < 4.0 BootSector (0x%x) ->>>>>>38 ubyte =0x29 ->>>>>>>39 ulelong x \b, serial number 0x%x ->>>>>>>43 string >>>>>>43 string >NO\ NAME \b, label: "%11.11s" ->>>>>>>43 string =NO\ NAME \b, unlabeled ->>>>>>54 string FAT \b, FAT ->>>>>>>54 string FAT12 \b (12 bit) ->>>>>>>54 string FAT16 \b (16 bit) -# FAT32 specific ->>>>>82 string FAT32 \b, FAT (32 bit) ->>>>>>36 ulelong x \b, sectors/FAT %u ->>>>>>40 uleshort >0 \b, extension flags %u -#>>>>>>40 uleshort =0 \b, extension flags %u ->>>>>>42 uleshort >0 \b, fsVersion %u -#>>>>>>42 uleshort =0 \b, fsVersion %u (usual) ->>>>>>44 ulelong >2 \b, rootdir cluster %u -#>>>>>>44 ulelong =2 \b, rootdir cluster %u -#>>>>>>44 ulelong =1 \b, rootdir cluster %u ->>>>>>48 uleshort >1 \b, infoSector %u -#>>>>>>48 uleshort =1 \b, infoSector %u (usual) ->>>>>>48 uleshort <1 \b, infoSector %u ->>>>>>50 uleshort >6 \b, Backup boot sector %u -#>>>>>>50 uleshort =6 \b, Backup boot sector %u (usual) ->>>>>>50 uleshort <6 \b, Backup boot sector %u ->>>>>>54 ulelong >0 \b, reserved1 0x%x ->>>>>>58 ulelong >0 \b, reserved2 0x%x ->>>>>>62 ulelong >0 \b, reserved3 0x%x -# same structure as FAT1X ->>>>>>64 ubyte >0x80 \b, physical drive 0x%x -#>>>>>>64 ubyte =0x80 \b, physical drive 0x%x=80 (usual harddisk) ->>>>>>64 ubyte&0x7F >0 \b, physical drive 0x%x -#>>>>>>64 ubyte =0 \b, physical drive 0x%x=0 (usual floppy) ->>>>>>65 ubyte >0 \b, reserved 0x%x ->>>>>>66 ubyte >0x29 \b, dos < 4.0 BootSector (0x%x) ->>>>>>66 ubyte <0x29 \b, dos < 4.0 BootSector (0x%x) ->>>>>>66 ubyte =0x29 ->>>>>>>67 ulelong x \b, serial number 0x%x ->>>>>>>71 string >>>>>71 string >NO\ NAME \b, label: "%11.11s" ->>>>>>71 string =NO\ NAME \b, unlabeled -### FATs end ->0x200 lelong 0x82564557 \b, BSD disklabel -# FATX -0 string FATX FATX filesystem data - - -# romfs filesystems - Juan Cespedes -0 string -rom1fs-\0 romfs filesystem, version 1 ->8 belong x %d byte(s), ->16 string x named %s. - -# netboot image - Juan Cespedes -0 lelong 0x1b031336L Netboot image, ->4 lelong&0xFFFFFF00 0 ->>4 lelong&0x100 0x000 mode 2 ->>4 lelong&0x100 0x100 mode 3 ->4 lelong&0xFFFFFF00 !0 unknown mode - -0x18b string OS/2 OS/2 Boot Manager - -# added by Joerg Jenderek -# In the second sector (+0x200) are variables according to grub-0.97/stage2/asm.S or -# grub-1.94/kern/i386/pc/startup.S -# http://www.gnu.org/software/grub/manual/grub.html#Embedded-data -# usual values are marked with comments to get only informations of strange GRUB loaders -0x200 uleshort 0x70EA -# found only version 3.{1,2} ->0x206 ubeshort >0x0300 -# GRUB version (0.5.)95,0.93,0.94,0.96,0.97 > "00" ->>0x212 ubyte >0x29 ->>>0x213 ubyte >0x29 -# not iso9660_stage1_5 -#>>>0 ulelong&0x00BE5652 0x00BE5652 ->>>>0x213 ubyte >0x29 GRand Unified Bootloader -# config_file for stage1_5 is 0xffffffff + default "/boot/grub/stage2" ->>>>0x217 ubyte 0xFF stage1_5 ->>>>0x217 ubyte <0xFF stage2 ->>>>0x206 ubyte x \b version %u ->>>>0x207 ubyte x \b.%u -# module_size for 1.94 ->>>>0x208 ulelong <0xffffff \b, installed partition %u -#>>>>0x208 ulelong =0xffffff \b, %u (default) ->>>>0x208 ulelong >0xffffff \b, installed partition %u -# GRUB 0.5.95 unofficial ->>>>0x20C ulelong&0x2E300000 0x2E300000 -# 0=stage2 1=ffs 2=e2fs 3=fat 4=minix 5=reiserfs ->>>>>0x20C ubyte x \b, identifier 0x%x -#>>>>>0x20D ubyte =0 \b, LBA flag 0x%x (default) ->>>>>0x20D ubyte >0 \b, LBA flag 0x%x -# GRUB version as string ->>>>>0x20E string >\0 \b, GRUB version %-s -# for stage1_5 is 0xffffffff + config_file "/boot/grub/stage2" default ->>>>>>0x215 ulong 0xffffffff ->>>>>>>0x219 string >\0 \b, configuration file %-s ->>>>>>0x215 ulong !0xffffffff ->>>>>>>0x215 string >\0 \b, configuration file %-s -# newer GRUB versions ->>>>0x20C ulelong&0x2E300000 !0x2E300000 -##>>>>>0x20C ulelong =0 \b, saved entry %d (usual) ->>>>>0x20C ulelong >0 \b, saved entry %d -# for 1.94 contains kernel image size -# for 0.93,0.94,0.96,0.97 -# 0=stage2 1=ffs 2=e2fs 3=fat 4=minix 5=reiserfs 6=vstafs 7=jfs 8=xfs 9=iso9660 a=ufs2 ->>>>>0x210 ubyte x \b, identifier 0x%x -# The flag for LBA forcing is in most cases 0 -#>>>>>0x211 ubyte =0 \b, LBA flag 0x%x (default) ->>>>>0x211 ubyte >0 \b, LBA flag 0x%x -# GRUB version as string ->>>>>0x212 string >\0 \b, GRUB version %-s -# for stage1_5 is 0xffffffff + config_file "/boot/grub/stage2" default ->>>>>0x217 ulong 0xffffffff ->>>>>>0x21b string >\0 \b, configuration file %-s ->>>>>0x217 ulong !0xffffffff ->>>>>>0x217 string >\0 \b, configuration file %-s - -9564 lelong 0x00011954 Unix Fast File system [v1] (little-endian), ->8404 string x last mounted on %s, -#>9504 ledate x last checked at %s, ->8224 ledate x last written at %s, ->8401 byte x clean flag %d, ->8228 lelong x number of blocks %d, ->8232 lelong x number of data blocks %d, ->8236 lelong x number of cylinder groups %d, ->8240 lelong x block size %d, ->8244 lelong x fragment size %d, ->8252 lelong x minimum percentage of free blocks %d, ->8256 lelong x rotational delay %dms, ->8260 lelong x disk rotational speed %drps, ->8320 lelong 0 TIME optimization ->8320 lelong 1 SPACE optimization - -42332 lelong 0x19540119 Unix Fast File system [v2] (little-endian) ->&-1164 string x last mounted on %s, ->&-696 string >\0 volume name %s, ->&-304 leqldate x last written at %s, ->&-1167 byte x clean flag %d, ->&-1168 byte x readonly flag %d, ->&-296 lequad x number of blocks %lld, ->&-288 lequad x number of data blocks %lld, ->&-1332 lelong x number of cylinder groups %d, ->&-1328 lelong x block size %d, ->&-1324 lelong x fragment size %d, ->&-180 lelong x average file size %d, ->&-176 lelong x average number of files in dir %d, ->&-272 lequad x pending blocks to free %lld, ->&-264 lelong x pending inodes to free %d, ->&-664 lequad x system-wide uuid %0llx, ->&-1316 lelong x minimum percentage of free blocks %d, ->&-1248 lelong 0 TIME optimization ->&-1248 lelong 1 SPACE optimization - -66908 lelong 0x19540119 Unix Fast File system [v2] (little-endian) ->&-1164 string x last mounted on %s, ->&-696 string >\0 volume name %s, ->&-304 leqldate x last written at %s, ->&-1167 byte x clean flag %d, ->&-1168 byte x readonly flag %d, ->&-296 lequad x number of blocks %lld, ->&-288 lequad x number of data blocks %lld, ->&-1332 lelong x number of cylinder groups %d, ->&-1328 lelong x block size %d, ->&-1324 lelong x fragment size %d, ->&-180 lelong x average file size %d, ->&-176 lelong x average number of files in dir %d, ->&-272 lequad x pending blocks to free %lld, ->&-264 lelong x pending inodes to free %d, ->&-664 lequad x system-wide uuid %0llx, ->&-1316 lelong x minimum percentage of free blocks %d, ->&-1248 lelong 0 TIME optimization ->&-1248 lelong 1 SPACE optimization - -9564 belong 0x00011954 Unix Fast File system [v1] (big-endian), ->7168 belong 0x4c41424c Apple UFS Volume ->>7186 string x named %s, ->>7176 belong x volume label version %d, ->>7180 bedate x created on %s, ->8404 string x last mounted on %s, -#>9504 bedate x last checked at %s, ->8224 bedate x last written at %s, ->8401 byte x clean flag %d, ->8228 belong x number of blocks %d, ->8232 belong x number of data blocks %d, ->8236 belong x number of cylinder groups %d, ->8240 belong x block size %d, ->8244 belong x fragment size %d, ->8252 belong x minimum percentage of free blocks %d, ->8256 belong x rotational delay %dms, ->8260 belong x disk rotational speed %drps, ->8320 belong 0 TIME optimization ->8320 belong 1 SPACE optimization - -42332 belong 0x19540119 Unix Fast File system [v2] (big-endian) ->&-1164 string x last mounted on %s, ->&-696 string >\0 volume name %s, ->&-304 beqldate x last written at %s, ->&-1167 byte x clean flag %d, ->&-1168 byte x readonly flag %d, ->&-296 bequad x number of blocks %lld, ->&-288 bequad x number of data blocks %lld, ->&-1332 belong x number of cylinder groups %d, ->&-1328 belong x block size %d, ->&-1324 belong x fragment size %d, ->&-180 belong x average file size %d, ->&-176 belong x average number of files in dir %d, ->&-272 bequad x pending blocks to free %lld, ->&-264 belong x pending inodes to free %d, ->&-664 bequad x system-wide uuid %0llx, ->&-1316 belong x minimum percentage of free blocks %d, ->&-1248 belong 0 TIME optimization ->&-1248 belong 1 SPACE optimization - -66908 belong 0x19540119 Unix Fast File system [v2] (big-endian) ->&-1164 string x last mounted on %s, ->&-696 string >\0 volume name %s, ->&-304 beqldate x last written at %s, ->&-1167 byte x clean flag %d, ->&-1168 byte x readonly flag %d, ->&-296 bequad x number of blocks %lld, ->&-288 bequad x number of data blocks %lld, ->&-1332 belong x number of cylinder groups %d, ->&-1328 belong x block size %d, ->&-1324 belong x fragment size %d, ->&-180 belong x average file size %d, ->&-176 belong x average number of files in dir %d, ->&-272 bequad x pending blocks to free %lld, ->&-264 belong x pending inodes to free %d, ->&-664 bequad x system-wide uuid %0llx, ->&-1316 belong x minimum percentage of free blocks %d, ->&-1248 belong 0 TIME optimization ->&-1248 belong 1 SPACE optimization - -# ext2/ext3 filesystems - Andreas Dilger -# ext4 filesystem - Eric Sandeen -0x438 leshort 0xEF53 Linux ->0x44c lelong x rev %d ->0x43e leshort x \b.%d -# No journal? ext2 ->0x45c lelong ^0x0000004 ext2 filesystem data ->>0x43a leshort ^0x0000001 (mounted or unclean) -# Has a journal? ext3 or ext4 ->0x45c lelong &0x0000004 -# and small INCOMPAT? ->>0x460 lelong <0x0000040 -# and small RO_COMPAT? ->>>0x464 lelong <0x0000008 ext3 filesystem data -# else large RO_COMPAT? ->>>0x464 lelong >0x0000007 ext4 filesystem data -# else large INCOMPAT? ->>0x460 lelong >0x000003f ext4 filesystem data -# General flags for any ext* fs ->0x460 lelong &0x0000004 (needs journal recovery) ->0x43a leshort &0x0000002 (errors) -# INCOMPAT flags ->0x460 lelong &0x0000001 (compressed) -#>0x460 lelong &0x0000002 (filetype) -#>0x460 lelong &0x0000010 (meta bg) ->0x460 lelong &0x0000040 (extents) ->0x460 lelong &0x0000080 (64bit) -#>0x460 lelong &0x0000100 (mmp) -#>0x460 lelong &0x0000200 (flex bg) -# RO_INCOMPAT flags -#>0x464 lelong &0x0000001 (sparse super) ->0x464 lelong &0x0000002 (large files) ->0x464 lelong &0x0000008 (huge files) -#>0x464 lelong &0x0000010 (gdt checksum) -#>0x464 lelong &0x0000020 (many subdirs) -#>0x463 lelong &0x0000040 (extra isize) - -# SGI disk labels - Nathan Scott -0 belong 0x0BE5A941 SGI disk label (volume header) - -# SGI XFS filesystem - Nathan Scott -0 belong 0x58465342 SGI XFS filesystem data ->0x4 belong x (blksz %d, ->0x68 beshort x inosz %d, ->0x64 beshort ^0x2004 v1 dirs) ->0x64 beshort &0x2004 v2 dirs) - -############################################################################ -# Minix-ST kernel floppy -0x800 belong 0x46fc2700 Atari-ST Minix kernel image ->19 string \240\5\371\5\0\011\0\2\0 \b, 720k floppy ->19 string \320\2\370\5\0\011\0\1\0 \b, 360k floppy - -############################################################################ -# Hmmm, is this a better way of detecting _standard_ floppy images ? -19 string \320\2\360\3\0\011\0\1\0 DOS floppy 360k ->0x1FE leshort 0xAA55 \b, x86 hard disk boot sector -19 string \240\5\371\3\0\011\0\2\0 DOS floppy 720k ->0x1FE leshort 0xAA55 \b, x86 hard disk boot sector -19 string \100\013\360\011\0\022\0\2\0 DOS floppy 1440k ->0x1FE leshort 0xAA55 \b, x86 hard disk boot sector - -19 string \240\5\371\5\0\011\0\2\0 DOS floppy 720k, IBM ->0x1FE leshort 0xAA55 \b, x86 hard disk boot sector -19 string \100\013\371\5\0\011\0\2\0 DOS floppy 1440k, mkdosfs ->0x1FE leshort 0xAA55 \b, x86 hard disk boot sector - -19 string \320\2\370\5\0\011\0\1\0 Atari-ST floppy 360k -19 string \240\5\371\5\0\011\0\2\0 Atari-ST floppy 720k - -# Valid media descriptor bytes for MS-DOS: -# -# Byte Capacity Media Size and Type -# ------------------------------------------------- -# -# F0 2.88 MB 3.5-inch, 2-sided, 36-sector -# F0 1.44 MB 3.5-inch, 2-sided, 18-sector -# F9 720K 3.5-inch, 2-sided, 9-sector -# F9 1.2 MB 5.25-inch, 2-sided, 15-sector -# FD 360K 5.25-inch, 2-sided, 9-sector -# FF 320K 5.25-inch, 2-sided, 8-sector -# FC 180K 5.25-inch, 1-sided, 9-sector -# FE 160K 5.25-inch, 1-sided, 8-sector -# FE 250K 8-inch, 1-sided, single-density -# FD 500K 8-inch, 2-sided, single-density -# FE 1.2 MB 8-inch, 2-sided, double-density -# F8 ----- Fixed disk -# -# FC xxxK Apricot 70x1x9 boot disk. -# -# Originally a bitmap: -# xxxxxxx0 Not two sided -# xxxxxxx1 Double sided -# xxxxxx0x Not 8 SPT -# xxxxxx1x 8 SPT -# xxxxx0xx Not Removable drive -# xxxxx1xx Removable drive -# 11111xxx Must be one. -# -# But now it's rather random: -# 111111xx Low density disk -# 00 SS, Not 8 SPT -# 01 DS, Not 8 SPT -# 10 SS, 8 SPT -# 11 DS, 8 SPT -# -# 11111001 Double density 3½ floppy disk, high density 5¼ -# 11110000 High density 3½ floppy disk -# 11111000 Hard disk any format -# - -# CDROM Filesystems -# Modified for UDF by gerardo.cacciari@gmail.com -32769 string CD001 ->38913 string !NSR0 ISO 9660 CD-ROM filesystem data -!:mime application/x-iso9660-image ->38913 string NSR0 UDF filesystem data -!:mime application/x-iso9660-image ->>38917 string 1 (version 1.0) ->>38917 string 2 (version 1.5) ->>38917 string 3 (version 2.0) ->>38917 byte >0x33 (unknown version, ID 0x%X) ->>38917 byte <0x31 (unknown version, ID 0x%X) -# "application id" which appears to be used as a volume label ->32808 string >\0 '%s' ->34816 string \000CD001\001EL\ TORITO\ SPECIFICATION (bootable) -37633 string CD001 ISO 9660 CD-ROM filesystem data (raw 2352 byte sectors) -!:mime application/x-iso9660-image -32776 string CDROM High Sierra CD-ROM filesystem data - -# cramfs filesystem - russell@coker.com.au -0 lelong 0x28cd3d45 Linux Compressed ROM File System data, little endian ->4 lelong x size %u ->8 lelong &1 version #2 ->8 lelong &2 sorted_dirs ->8 lelong &4 hole_support ->32 lelong x CRC 0x%x, ->36 lelong x edition %u, ->40 lelong x %u blocks, ->44 lelong x %u files - -0 belong 0x28cd3d45 Linux Compressed ROM File System data, big endian ->4 belong x size %u ->8 belong &1 version #2 ->8 belong &2 sorted_dirs ->8 belong &4 hole_support ->32 belong x CRC 0x%x, ->36 belong x edition %u, ->40 belong x %u blocks, ->44 belong x %u files - -# reiserfs - russell@coker.com.au -0x10034 string ReIsErFs ReiserFS V3.5 -0x10034 string ReIsEr2Fs ReiserFS V3.6 ->0x1002c leshort x block size %d ->0x10032 leshort &2 (mounted or unclean) ->0x10000 lelong x num blocks %d ->0x10040 lelong 1 tea hash ->0x10040 lelong 2 yura hash ->0x10040 lelong 3 r5 hash - -# JFFS - russell@coker.com.au -0 lelong 0x34383931 Linux Journalled Flash File system, little endian -0 belong 0x34383931 Linux Journalled Flash File system, big endian - -# EST flat binary format (which isn't, but anyway) -# From: Mark Brown -0 string ESTFBINR EST flat binary - -# Aculab VoIP firmware -# From: Mark Brown -0 string VoIP\ Startup\ and Aculab VoIP firmware ->35 string x format %s - -# u-boot/PPCBoot image file -# From: Mark Brown -0 belong 0x27051956 u-boot/PPCBoot image ->4 string PPCBoot ->>12 string x version %s - -# JFFS2 file system -#0 leshort 0x1984 Linux old jffs2 filesystem data little endian -#0 leshort 0x1985 Linux jffs2 filesystem data little endian - -# Squashfs -0 string sqsh Squashfs filesystem, big endian, ->28 beshort x version %d. ->30 beshort x \b%d, ->28 beshort <3 ->>8 belong x %d byte(s), ->28 beshort >2 ->>63 bequad x %lld bytes, -#>>67 belong x %d byte(s), ->4 belong x %d inodes, ->28 beshort <2 ->>32 beshort x blocksize: %d byte(s), ->28 beshort >1 ->>51 belong x blocksize: %d byte(s), ->39 bedate x created: %s - -0 string hsqs Squashfs filesystem, little endian, ->28 leshort x version %d. ->30 leshort x \b%d, ->28 leshort <3 ->>8 lelong x %d byte(s), ->28 leshort >2 ->>63 lequad x %lld bytes, -#>>63 lelong x %d byte(s), ->4 lelong x %d inodes, ->28 leshort <2 ->>32 leshort x blocksize: %d byte(s), ->28 leshort >1 ->>51 lelong x blocksize: %d byte(s), ->39 ledate x created: %s - -# Squashfs -0 string hsqt Squashfs filesystem, little endian, ->28 leshort x version %d. ->30 leshort x \b%d, ->28 leshort <3 ->>8 lelong x %d byte(s), ->28 leshort >2 ->>63 lequad x %lld bytes, -#>>63 lelong x %d byte(s), ->4 lelong x %d inodes, ->28 leshort <2 ->>32 leshort x blocksize: %d byte(s), ->28 leshort >1 ->>51 lelong x blocksize: %d byte(s), ->39 ledate x created: %s -0 string hsqt Squashfs filesystem, little endian, ->28 beshort x version %d. ->30 beshort x \b%d, ->28 beshort <3 ->>8 belong x %d byte(s), ->28 beshort >2 ->>63 bequad x %lld bytes, -#>>67 belong x %d byte(s), ->4 belong x %d inodes, ->28 beshort <2 ->>32 beshort x blocksize: %d byte(s), ->28 beshort >1 ->>51 belong x blocksize: %d byte(s), ->39 bedate x created: %s - -# 0 string hsqs Squashfs filesystem, little endian, -# >28 leshort x version %d. -# >30 leshort x \b%d, -# >28 leshort <3 -# >>8 lelong x %d byte(s), -# >28 leshort >2 -# >>63 lequad x %lld bytes, -# #>>63 lelong x %d byte(s), -# >4 lelong x %d inodes, -# >28 leshort <2 -# >>32 leshort x blocksize: %d byte(s), -# >28 leshort >1 -# >>51 lelong x blocksize: %d byte(s), -# >39 ledate x created: %s - -#0 string td\000 floppy image data (TeleDisk) - -# AFS Dump Magic -# From: Ty Sarna -0 string \x01\xb3\xa1\x13\x22 AFS Dump ->&0 belong x (v%d) ->>&0 byte 0x76 ->>>&0 belong x Vol %d, ->>>>&0 byte 0x6e ->>>>>&0 string x %s ->>>>>>&1 byte 0x74 ->>>>>>>&0 beshort 2 ->>>>>>>>&4 bedate x on: %s ->>>>>>>>&0 bedate =0 full dump ->>>>>>>>&0 bedate !0 incremental since: %s - -#---------------------------------------------------------- -# VMS backup savesets - gerardo.cacciari@gmail.com -# -4 string \x01\x00\x01\x00\x01\x00 ->(0.s+16) string \x01\x01 ->>&(&0.b+8) byte 0x42 OpenVMS backup saveset data ->>>40 lelong x (block size %d, ->>>49 string >\0 original name '%s', ->>>2 short 1024 VAX generated) ->>>2 short 2048 AXP generated) ->>>2 short 4096 I64 generated) - -# Compaq/HP RILOE floppy image -# From: Dirk Jagdmann -0 string CPQRFBLO Compaq/HP RILOE floppy image - -#------------------------------------------------------------------------------ -# Files-11 On-Disk Structure (OpenVMS file system) - gerardo.cacciari@gmail.com -# These bits come from LBN 1 (home block) of ODS-2 and ODS-5 volumes, which is -# mapped to VBN 2 of [000000]INDEXF.SYS;1 -# -1008 string DECFILE11B Files-11 On-Disk Structure ->525 byte x Level %d ->525 byte x (ODS-%d OpenVMS file system), ->984 string x volume label is '%-12.12s' - -# From: Thomas Klausner -# http://filext.com/file-extension/DAA -# describes the daa file format. The magic would be: -0 string DAA\x0\x0\x0\x0\x0 PowerISO Direct-Access-Archive - -# From Albert Cahalan -# really le32 operation,destination,payloadsize (but quite predictable) -# 01 00 00 00 00 00 00 c0 00 02 00 00 -0 string \1\0\0\0\0\0\0\300\0\2\0\0 Marvell Libertas firmware - - -# DOS x86 sector updated and separated from "DOS/MBR boot sector" by Joerg Jenderek at May 2011 -# JuMP short bootcodeoffset NOP assembler instructions will usually be EB xx 90 -# over BIOS parameter block (BPB) -# http://thestarman.pcministry.com/asm/2bytejumps.htm#FWD -# older drives may use Near JuMP instruction E9 xx xx -# minimal short forward jump found 0x29 for bootloaders or 0x0 -# maximal short forward jump is 0x7f -# OEM-ID is empty or contain readable bytes -0 ulelong&0x804000E9 0x000000E9 -# reduce false positives with this check ->54 string FAT -# !:strength +60 -# mtools-3.9.8/msdos.h -# usual values are marked with comments to get only informations of strange FAT systems -# valid sectorsize must be a power of 2 from 32 to 32768 -#>11 uleshort&0x001f 0 ->>11 uleshort <32769 ->>>11 uleshort >31 ->>>>21 ubyte&0xf0 0xF0 ->>>>>0 ubyte 0xEB DOS/MBR boot sector ->>>>>>1 ubyte x \b, code offset 0x%x+2 ->>>>>0 ubyte 0xE9 ->>>>>>1 uleshort x \b, code offset 0x%x+3 ->>>>>3 string >\0 \b, OEM-ID "%-.8s" -#http://mirror.href.com/thestarman/asm/debug/debug2.htm#IHC ->>>>>>8 string IHC \b cached by Windows 9M ->>>>>11 uleshort >512 \b, Bytes/sector %u -#>>>>>11 uleshort =512 \b, Bytes/sector %u=512 (usual) ->>>>>11 uleshort <512 \b, Bytes/sector %u ->>>>>13 ubyte >1 \b, sectors/cluster %u -#>>>>>13 ubyte =1 \b, sectors/cluster %u (usual on Floppies) -# for lazy FAT32 implementation like Transcend digital photo frame PF830 ->>>>>82 string/c fat32 ->>>>>>14 uleshort !32 \b, reserved sectors %u -#>>>>>>14 uleshort =32 \b, reserved sectors %u (usual Fat32) ->>>>>82 string/c !fat32 ->>>>>>14 uleshort >1 \b, reserved sectors %u -#>>>>>>14 uleshort =1 \b, reserved sectors %u (usual FAT12,FAT16) -#>>>>>>14 uleshort 0 \b, reserved sectors %u (usual NTFS) ->>>>>16 ubyte >2 \b, FATs %u -#>>>>>16 ubyte =2 \b, FATs %u (usual) ->>>>>16 ubyte =1 \b, FAT %u ->>>>>16 ubyte >0 ->>>>>17 uleshort >0 \b, root entries %u -#>>>>>17 uleshort =0 \b, root entries %hu=0 (usual Fat32) ->>>>>19 uleshort >0 \b, sectors %u (volumes <=32 MB) -#>>>>>19 uleshort =0 \b, sectors %hu=0 (usual Fat32) ->>>>>21 ubyte >0xF0 \b, Media descriptor 0x%x -#>>>>>21 ubyte =0xF0 \b, Media descriptor 0x%x (usual floppy) ->>>>>21 ubyte <0xF0 \b, Media descriptor 0x%x ->>>>>22 uleshort >0 \b, sectors/FAT %u -#>>>>>22 uleshort =0 \b, sectors/FAT %hu=0 (usual Fat32) ->>>>>24 uleshort x \b, sectors/track %u ->>>>>26 ubyte >2 \b, heads %u -#>>>>>26 ubyte =2 \b, heads %u (usual floppy) ->>>>>26 ubyte =1 \b, heads %u -# valid only for sector sizes with more then 32 Bytes ->>>>>11 uleshort >32 -# http://en.wikipedia.org/wiki/Design_of_the_FAT_file_system#Extended_BIOS_Parameter_Block -# skip for values 2,2Ah,70h,73h,DFh -# and continue for extended boot signature values 0,28h,29h,80h ->>>>>>38 ubyte&0x56 =0 ->>>>>>>28 ulelong >0 \b, hidden sectors %u -#>>>>>>>28 ulelong =0 \b, hidden sectors %u (usual floppy) ->>>>>>>32 ulelong >0 \b, sectors %u (volumes > 32 MB) -#>>>>>>>32 ulelong =0 \b, sectors %u (volumes > 32 MB) -# FAT<32 bit specific ->>>>>>>82 string/c !fat32 -#>>>>>>>>36 ubyte 0x80 \b, physical drive 0x%x=0x80 (usual harddisk) -#>>>>>>>>36 ubyte 0 \b, physical drive 0x%x=0 (usual floppy) ->>>>>>>>36 ubyte !0x80 ->>>>>>>>>36 ubyte !0 \b, physical drive 0x%x -# VGA-copy CRC or -# in Windows NT bit 0 is a dirty flag to request chkdsk at boot time. bit 1 requests surface scan too ->>>>>>>>37 ubyte >0 \b, reserved 0x%x -#>>>>>>>>37 ubyte =0 \b, reserved 0x%x -# extended boot signatur value is 0x80 for NTFS, 0x28 or 0x29 for others ->>>>>>>>38 ubyte !0x29 \b, dos < 4.0 BootSector (0x%x) ->>>>>>>>38 ubyte&0xFE =0x28 ->>>>>>>>>39 ulelong x \b, serial number 0x%x ->>>>>>>>38 ubyte =0x29 ->>>>>>>>>43 string >>>>>>>>43 string >NO\ NAME \b, label: "%11.11s" ->>>>>>>>>43 string =NO\ NAME \b, unlabeled -# there exist some old floppies without word FAT at offset 54 -# a word like "FATnm " is only a hint for a FAT size on nm-bits -# Normally the number of clusters is calculated by the values of BPP. -# if it is small enough FAT is 12 bit, if it is too big enough FAT is 32 bit, -# otherwise FAT is 16 bit. -# http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-fat-widths.html ->>>>>82 string/c !fat32 ->>>>>>54 string FAT12 \b, FAT (12 bit) ->>>>>>54 string FAT16 \b, FAT (16 bit) ->>>>>>54 default x -# determinate FAT bit size by media descriptor -# small floppies implies FAT12 ->>>>>>>21 ubyte <0xF0 \b, FAT (12 bit by descriptor) -# with media descriptor F0h floppy or maybe superfloppy with FAT16 ->>>>>>>21 ubyte =0xF0 -# superfloppy (many sectors) implies FAT16 ->>>>>>>>32 ulelong >0xFFFF \b, FAT (16 bit by descriptor+sectors) -# no superfloppy with media descriptor F0h implies FAT12 ->>>>>>>>32 default x \b, FAT (12 bit by descriptor+sectors) -# with media descriptor F8h floppy or hard disc with FAT12 or FAT16 ->>>>>>>21 ubyte =0xF8 -# 360 KiB with media descriptor F8h, 9 sectors per track ,single sided floppy implies FAT12 ->>>>>>>>19 ubequad 0xd002f80300090001 \b, FAT (12 bit by descriptor+geometry) -# hard disc with FAT12 or FAT16 ->>>>>>>>19 default x \b, FAT (1Y bit by descriptor) -# with media descriptor FAh floppy, RAM disc with FAT12 or FAT16 or Tandy hard disc ->>>>>>>21 ubyte =0xFA -# 320 KiB with media descriptor FAh, 8 sectors per track ,single sided floppy implies FAT12 ->>>>>>>>19 ubequad 0x8002fa0200080001 \b, FAT (12 bit by descriptor+geometry) -# RAM disc with FAT12 or FAT16 or Tandy hard disc ->>>>>>>>19 default x \b, FAT (1Y bit by descriptor) -# others are floppy ->>>>>>>21 default x \b, FAT (12 bit by descriptor) -# FAT32 bit specific ->>>>>82 string/c fat32 \b, FAT (32 bit) ->>>>>>36 ulelong x \b, sectors/FAT %u -# http://technet.microsoft.com/en-us/library/cc977221.aspx ->>>>>>40 uleshort >0 \b, extension flags 0x%x -#>>>>>>40 uleshort =0 \b, extension flags %hu ->>>>>>42 uleshort >0 \b, fsVersion %u -#>>>>>>42 uleshort =0 \b, fsVersion %u (usual) ->>>>>>44 ulelong >2 \b, rootdir cluster %u -#>>>>>>44 ulelong =2 \b, rootdir cluster %u -#>>>>>>44 ulelong =1 \b, rootdir cluster %u ->>>>>>48 uleshort >1 \b, infoSector %u -#>>>>>>48 uleshort =1 \b, infoSector %u (usual) ->>>>>>48 uleshort <1 \b, infoSector %u -# 0 or 0xFFFF instead of usual 6 means no backup sector ->>>>>>50 uleshort =0xFFFF \b, no Backup boot sector ->>>>>>50 uleshort =0 \b, no Backup boot sector -#>>>>>>50 uleshort =6 \b, Backup boot sector %u (usual) ->>>>>>50 default x ->>>>>>>50 uleshort x \b, Backup boot sector %u -# corrected by Joerg Jenderek at Feb 2011 according to http://thestarman.pcministry.com/asm/mbr/MSWIN41.htm#FSINFO ->>>>>>52 ulelong >0 \b, reserved1 0x%x ->>>>>>56 ulelong >0 \b, reserved2 0x%x ->>>>>>60 ulelong >0 \b, reserved3 0x%x -# same structure as FAT1X -#>>>>>>64 ubyte =0x80 \b, physical drive 0x%x=80 (usual harddisk) -#>>>>>>64 ubyte =0 \b, physical drive 0x%x=0 (usual floppy) ->>>>>>64 ubyte !0x80 ->>>>>>>64 ubyte >0 \b, physical drive 0x%x -# in Windows NT bit 0 is a dirty flag to request chkdsk at boot time. bit 1 requests surface scan too ->>>>>>65 ubyte >0 \b, reserved 0x%x ->>>>>>66 ubyte !0x29 \b, dos < 4.0 BootSector (0x%x) ->>>>>>66 ubyte =0x29 ->>>>>>>67 ulelong x \b, serial number 0x%x ->>>>>>>71 string >>>>>>71 string >NO\ NAME \b, label: "%11.11s" ->>>>>>>71 string =NO\ NAME \b, unlabeled -# additional tests for floppy image added by Joerg Jenderek -# no fixed disk ->>>>>21 ubyte !0xF8 -# floppy media with 12 bit FAT ->>>>>>54 string !FAT16 -# test for FAT after bootsector ->>>>>>>(11.s) ulelong&0x00ffffF0 0x00ffffF0 \b, followed by FAT -# floppy image -!:mime application/x-ima -# NTFS specific added by Joerg Jenderek at Mar 2011 according to http://thestarman.pcministry.com/asm/mbr/NTFSBR.htm -# and http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/bios-parameter-block.html -# 0 FATs ->>>>>16 ubyte =0 -# 0 root entries ->>>>>>17 uleshort =0 -# 0 DOS sectors ->>>>>>>19 uleshort =0 -# 0 sectors/FAT -# dos < 4.0 BootSector value found is 0x80 -#38 ubyte =0x80 \b, dos < 4.0 BootSector (0x%x) ->>>>>>>>22 uleshort =0 \b; NTFS ->>>>>>>>>24 uleshort >0 \b, sectors/track %u ->>>>>>>>>36 ulelong !0x800080 \b, physical drive 0x%x ->>>>>>>>>40 ulequad >0 \b, sectors %lld ->>>>>>>>>48 ulequad >0 \b, $MFT start cluster %lld ->>>>>>>>>56 ulequad >0 \b, $MFTMirror start cluster %lld -# Values 0 to 127 represent MFT record sizes of 0 to 127 clusters. -# Values 128 to 255 represent MFT record sizes of 2^(256-N) bytes. ->>>>>>>>>64 lelong <256 ->>>>>>>>>>64 lelong <128 \b, clusters/RecordSegment %d ->>>>>>>>>>64 ubyte >127 \b, bytes/RecordSegment 2^(-1*%i) -# Values 0 to 127 represent index block sizes of 0 to 127 clusters. -# Values 128 to 255 represent index block sizes of 2^(256-N) byte ->>>>>>>>>68 ulelong <256 ->>>>>>>>>>68 ulelong <128 \b, clusters/index block %d -#>>>>>>>>>>68 ulelong >127 \b, bytes/index block 2^(256-%d) ->>>>>>>>>>68 ubyte >127 \b, bytes/index block 2^(-1*%i) ->>>>>>>>>72 ulequad x \b, serial number 0%llx ->>>>>>>>>80 ulelong >0 \b, checksum 0x%x -#>>>>>>>>>80 ulelong =0 \b, checksum 0x%x=0 (usual) ->>>>>>>>>0x258 ulelong&0x00009090 =0x00009090 -#>>>>>>>>>>&-92 indirect x \b; contains -# For 2nd NTFS sector added by Joerg Jenderek at Jan 2013 -# http://thestarman.pcministry.com/asm/mbr/NTFSbrHexEd.htm -# unused assembler instructions JMP y2;NOP;NOP -0x056 ulelong&0xFFFF0FFF 0x909002EB -# unicode loadername terminated by CTRL-D ->(0.s*2) ulelong&0xFFFFFF00 0x00040000 -# loadernames are NTLDR,CMLDR,PELDR,$LDR$ or BOOTMGR ->>0x002 lestring16 x Microsoft Windows XP/VISTA bootloader %-5.5s ->>0x12 string $ ->>>0x0c lestring16 x \b%-2.2s diff --git a/dest/share/magic/firmware b/dest/share/magic/firmware deleted file mode 100644 index 19f6347e547..00000000000 --- a/dest/share/magic/firmware +++ /dev/null @@ -1 +0,0 @@ -0 string HDR0 TRX Firmware Header diff --git a/dest/share/magic/flash b/dest/share/magic/flash deleted file mode 100644 index ea3e6fb20e9..00000000000 --- a/dest/share/magic/flash +++ /dev/null @@ -1,22 +0,0 @@ -# $OpenBSD: flash,v 1.3 2009/04/24 18:54:34 chl Exp $ - -#------------------------------------------------------------------------------ -# flash: file(1) magic for Macromedia Flash file format -# -# See -# -# http://www.macromedia.com/software/flash/open/ -# -0 string FWS Macromedia Flash data, ->3 byte x version %d -!:mime application/x-shockwave-flash -0 string CWS Macromedia Flash data (compressed), -!:mime application/x-shockwave-flash ->3 byte x version %d -# From: Cal Peake -0 string FLV Macromedia Flash Video -!:mime video/x-flv - -# -# From Dave Wilson -0 string AGD4\xbe\xb8\xbb\xcb\x00 Macromedia Freehand 9 Document diff --git a/dest/share/magic/freebsd b/dest/share/magic/freebsd deleted file mode 100644 index 95ea7d122a3..00000000000 --- a/dest/share/magic/freebsd +++ /dev/null @@ -1,144 +0,0 @@ -# $OpenBSD: freebsd,v 1.2 2004/06/03 03:14:20 tedu Exp $ - -#------------------------------------------------------------------------------ -# freebsd: file(1) magic for FreeBSD objects -# -# All new-style FreeBSD magic numbers are in host byte order (i.e., -# little-endian on x86). -# -# XXX - this comes from the file "freebsd" in a recent FreeBSD version of -# "file"; it, and the NetBSD stuff in "netbsd", appear to use different -# schemes for distinguishing between executable images, shared libraries, -# and object files. -# -# FreeBSD says: -# -# Regardless of whether it's pure, demand-paged, or none of the -# above: -# -# if the entry point is < 4096, then it's a shared library if -# the "has run-time loader information" bit is set, and is -# position-independent if the "is position-independent" bit -# is set; -# -# if the entry point is >= 4096 (or >4095, same thing), then it's -# an executable, and is dynamically-linked if the "has run-time -# loader information" bit is set. -# -# On x86, NetBSD says: -# -# If it's neither pure nor demand-paged: -# -# if it has the "has run-time loader information" bit set, it's -# a dynamically-linked executable; -# -# if it doesn't have that bit set, then: -# -# if it has the "is position-independent" bit set, it's -# position-independent; -# -# if the entry point is non-zero, it's an executable, otherwise -# it's an object file. -# -# If it's pure: -# -# if it has the "has run-time loader information" bit set, it's -# a dynamically-linked executable, otherwise it's just an -# executable. -# -# If it's demand-paged: -# -# if it has the "has run-time loader information" bit set, -# then: -# -# if the entry point is < 4096, it's a shared library; -# -# if the entry point is = 4096 or > 4096 (i.e., >= 4096), -# it's a dynamically-linked executable); -# -# if it doesn't have the "has run-time loader information" bit -# set, then it's just an executable. -# -# (On non-x86, NetBSD does much the same thing, except that it uses -# 8192 on 68K - except for "68k4k", which is presumably "68K with 4K -# pages - SPARC, and MIPS, presumably because Sun-3's and Sun-4's -# had 8K pages; dunno about MIPS.) -# -# I suspect the two will differ only in perverse and uninteresting cases -# ("shared" libraries that aren't demand-paged and whose pages probably -# won't actually be shared, executables with entry points <4096). -# -# I leave it to those more familiar with FreeBSD and NetBSD to figure out -# what the right answer is (although using ">4095", FreeBSD-style, is -# probably better than separately checking for "=4096" and ">4096", -# NetBSD-style). (The old "netbsd" file analyzed FreeBSD demand paged -# executables using the NetBSD technique.) -# -0 lelong&0377777777 041400407 FreeBSD/i386 ->20 lelong <4096 ->>3 byte&0xC0 &0x80 shared library ->>3 byte&0xC0 0x40 PIC object ->>3 byte&0xC0 0x00 object ->20 lelong >4095 ->>3 byte&0x80 0x80 dynamically linked executable ->>3 byte&0x80 0x00 executable ->16 lelong >0 not stripped - -0 lelong&0377777777 041400410 FreeBSD/i386 pure ->20 lelong <4096 ->>3 byte&0xC0 &0x80 shared library ->>3 byte&0xC0 0x40 PIC object ->>3 byte&0xC0 0x00 object ->20 lelong >4095 ->>3 byte&0x80 0x80 dynamically linked executable ->>3 byte&0x80 0x00 executable ->16 lelong >0 not stripped - -0 lelong&0377777777 041400413 FreeBSD/i386 demand paged ->20 lelong <4096 ->>3 byte&0xC0 &0x80 shared library ->>3 byte&0xC0 0x40 PIC object ->>3 byte&0xC0 0x00 object ->20 lelong >4095 ->>3 byte&0x80 0x80 dynamically linked executable ->>3 byte&0x80 0x00 executable ->16 lelong >0 not stripped - -0 lelong&0377777777 041400314 FreeBSD/i386 compact demand paged ->20 lelong <4096 ->>3 byte&0xC0 &0x80 shared library ->>3 byte&0xC0 0x40 PIC object ->>3 byte&0xC0 0x00 object ->20 lelong >4095 ->>3 byte&0x80 0x80 dynamically linked executable ->>3 byte&0x80 0x00 executable ->16 lelong >0 not stripped - -# XXX gross hack to identify core files -# cores start with a struct tss; we take advantage of the following: -# byte 7: highest byte of the kernel stack pointer, always 0xfe -# 8/9: kernel (ring 0) ss value, always 0x0010 -# 10 - 27: ring 1 and 2 ss/esp, unused, thus always 0 -# 28: low order byte of the current PTD entry, always 0 since the -# PTD is page-aligned -# -7 string \357\020\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 FreeBSD/i386 a.out core file ->1039 string >\0 from '%s' - -# /var/run/ld.so.hints -# What are you laughing about? -0 lelong 011421044151 ld.so hints file (Little Endian ->4 lelong >0 \b, version %d) ->4 belong <1 \b) -0 belong 011421044151 ld.so hints file (Big Endian ->4 belong >0 \b, version %d) ->4 belong <1 \b) - -# -# Files generated by FreeBSD scrshot(1)/vidcontrol(1) utilities -# -0 string SCRSHOT_ scrshot(1) screenshot, ->8 byte x version %d, ->9 byte 2 %d byte(s) in header, ->>10 byte x %d chars wide by ->>11 byte x %d chars high diff --git a/dest/share/magic/gimp b/dest/share/magic/gimp deleted file mode 100644 index b31c1dfefa8..00000000000 --- a/dest/share/magic/gimp +++ /dev/null @@ -1,38 +0,0 @@ -# $OpenBSD: gimp,v 1.1 2004/06/03 03:14:20 tedu Exp $ - -#------------------------------------------------------------------------------ -# GIMP Gradient: file(1) magic for the GIMP's gradient data files -# by Federico Mena - -0 string GIMP\ Gradient GIMP gradient data - -#------------------------------------------------------------------------------ -# XCF: file(1) magic for the XCF image format used in the GIMP developed -# by Spencer Kimball and Peter Mattis -# ('Bucky' LaDieu, nega@vt.edu) - -0 string gimp\ xcf GIMP XCF image data, ->9 string file version 0, ->9 string v version ->>10 string >\0 %s, ->14 belong x %u x ->18 belong x %u, ->22 belong 0 RGB Color ->22 belong 1 Greyscale ->22 belong 2 Indexed Color ->22 belong >2 Unknown Image Type. - -#------------------------------------------------------------------------------ -# XCF: file(1) magic for the patterns used in the GIMP, developed -# by Spencer Kimball and Peter Mattis -# ('Bucky' LaDieu, nega@vt.edu) - -20 string GPAT GIMP pattern data, ->24 string x %s - -#------------------------------------------------------------------------------ -# XCF: file(1) magic for the brushes used in the GIMP, developed -# by Spencer Kimball and Peter Mattis -# ('Bucky' LaDieu, nega@vt.edu) - -20 string GIMP GIMP brush data diff --git a/dest/share/magic/gpg b/dest/share/magic/gpg deleted file mode 100644 index 6037a9fcf52..00000000000 --- a/dest/share/magic/gpg +++ /dev/null @@ -1,15 +0,0 @@ -0 string BEGIN\ PGP\ PRIVATE\ KEY\ BLOCK PGP Private key -0 string BEGIN\ PGP\ PUBLIC\ KEY\ BLOCK PGP Public key -0 string BEGIN\ PRIVATE\ KEY PGP Private key -0 string BEGIN\ PUBLIC\ KEY Public key -0 string \x8c\x0d\x04\x01\x03\x02 GPG-IDEA -0 string \x8c\x0d\x04\x02\x03\x02 GPG-3DES -0 string \x8c\x0d\x04\x03\x03\x02 GPG-CAST5 -0 string \x8c\x0d\x04\x04\x03\x02 GPG-BLOWFISH -0 string \x8c\x0d\x04\x07\x03\x02 GPG-AES128 -0 string \x8c\x0d\x04\x08\x03\x02 GPG-AES192 -0 string \x8c\x0d\x04\x09\x03\x02 GPG-AES256 -0 string \x8c\x0d\x04\x0a\x03\x02 GPG-TWOFISH -0 string \x8c\x0d\x04\x0b\x03\x02 GPG-CAMELLIA128 -0 string \x8c\x0d\x04\x0c\x03\x02 GPG-CAMELLIA192 -0 string \x8c\x0d\x04\x0d\x03\x02 GPG-CAMELLIA256 diff --git a/dest/share/magic/html b/dest/share/magic/html deleted file mode 100644 index 4f4419999c3..00000000000 --- a/dest/share/magic/html +++ /dev/null @@ -1,2 +0,0 @@ -0 string \74html\76 HTML document -0 string \74HTML\76 HTML document diff --git a/dest/share/magic/images b/dest/share/magic/images deleted file mode 100644 index 751ca95608b..00000000000 --- a/dest/share/magic/images +++ /dev/null @@ -1,182 +0,0 @@ -# $OpenBSD: images,v 1.10 2009/04/24 18:54:34 chl Exp $ - -#------------------------------------------------------------------------------ -# images: file(1) magic for image formats (see also "iff", and "c-lang" for -# XPM bitmaps) -# -# originally from jef@helios.ee.lbl.gov (Jef Poskanzer), -# additions by janl@ifi.uio.no as well as others. Jan also suggested -# merging several one- and two-line files into here. -# -# little magic: PCX (first byte is 0x0a) - -# Tag Image File Format, from Daniel Quinlan (quinlan@yggdrasil.com) -# The second word of TIFF files is the TIFF version number, 42, which has -# never changed. The TIFF specification recommends testing for it. -0 string MM\x00\x2a TIFF image data, big-endian -!:mime image/tiff -0 string II\x2a\x00 TIFF image data, little-endian -!:mime image/tiff - -# PNG [Portable Network Graphics, or "PNG's Not GIF"] images -# (Greg Roelofs, newt@uchicago.edu) -# (Albert Cahalan, acahalan@cs.uml.edu) -# -# 137 P N G \r \n ^Z \n [4-byte length] H E A D [HEAD data] [HEAD crc] ... -# -0 string \x89PNG PNG image data, -!:mime image/png ->4 belong !0x0d0a1a0a CORRUPTED, ->4 belong 0x0d0a1a0a ->>16 belong x %d x ->>20 belong x %d, ->>24 byte x %d-bit ->>25 byte 0 grayscale, ->>25 byte 2 \b/color RGB, ->>25 byte 3 colormap, ->>25 byte 4 gray+alpha, ->>25 byte 6 \b/color RGBA, -#>>26 byte 0 deflate/32K, ->>28 byte 0 non-interlaced ->>28 byte 1 interlaced -1 string PNG PNG image data, CORRUPTED - -# GIF -0 string GIF8 GIF image data -!:mime image/gif ->4 string 7a \b, version 8%s, ->4 string 9a \b, version 8%s, ->6 leshort >0 %d x ->8 leshort >0 %d -#>10 byte &0x80 color mapped, -#>10 byte&0x07 =0x00 2 colors -#>10 byte&0x07 =0x01 4 colors -#>10 byte&0x07 =0x02 8 colors -#>10 byte&0x07 =0x03 16 colors -#>10 byte&0x07 =0x04 32 colors -#>10 byte&0x07 =0x05 64 colors -#>10 byte&0x07 =0x06 128 colors -#>10 byte&0x07 =0x07 256 colors - -# ITC (CMU WM) raster files. It is essentially a byte-reversed Sun raster, -# 1 plane, no encoding. -0 string \361\0\100\273 CMU window manager raster image data ->4 lelong >0 %d x ->8 lelong >0 %d, ->12 lelong >0 %d-bit - -# Magick Image File Format -0 string id=ImageMagick MIFF image data - -# FIG (Facility for Interactive Generation of figures), an object-based format -0 search/1 #FIG FIG image text ->5 string x \b, version %.3s - -# XPM icons (Greg Roelofs, newt@uchicago.edu) -# note possible collision with C/REXX entry in c-lang; currently commented out -0 search/1 /*\ XPM\ */ X pixmap image text - -# Utah Raster Toolkit RLE images (janl@ifi.uio.no) -#0 leshort 0xcc52 RLE image data, -#>6 leshort x %d x -#>8 leshort x %d -#>2 leshort >0 \b, lower left corner: %d -#>4 leshort >0 \b, lower right corner: %d -#>10 byte&0x1 =0x1 \b, clear first -#>10 byte&0x2 =0x2 \b, no background -#>10 byte&0x4 =0x4 \b, alpha channel -#>10 byte&0x8 =0x8 \b, comment -#>11 byte >0 \b, %d color channels -#>12 byte >0 \b, %d bits per pixel -#>13 byte >0 \b, %d color map channels - -# -#2048 string PCD_IPI Kodak Photo CD image pack file -#>0xe02 byte&0x03 0x00 , landscape mode -#>0xe02 byte&0x03 0x01 , portrait mode -#>0xe02 byte&0x03 0x02 , landscape mode -#>0xe02 byte&0x03 0x03 , portrait mode -#0 string PCD_OPA Kodak Photo CD overview pack file - -# FITS format. Jeff Uphoff -# FITS is the Flexible Image Transport System, the de facto standard for -# data and image transfer, storage, etc., for the astronomical community. -# (FITS floating point formats are big-endian.) -0 string SIMPLE\ \ = FITS image data ->109 string 8 \b, 8-bit, character or unsigned binary integer ->108 string 16 \b, 16-bit, two's complement binary integer ->107 string \ 32 \b, 32-bit, two's complement binary integer ->107 string -32 \b, 32-bit, floating point, single precision ->107 string -64 \b, 64-bit, floating point, double precision - -# SMJPEG. A custom Motion JPEG format used by Loki Entertainment -# Software Torbjorn Andersson . -# -0 string \0\nSMJPEG SMJPEG ->8 belong x %d.x data -# According to the specification you could find any number of _TXT -# headers here, but I can't think of any way of handling that. None of -# the SMJPEG files I tried it on used this feature. Even if such a -# file is encountered the output should still be reasonable. ->16 string _SND \b, ->>24 beshort >0 %d Hz ->>26 byte 8 8-bit ->>26 byte 16 16-bit ->>28 string NONE uncompressed -# >>28 string APCM ADPCM compressed ->>27 byte 1 mono ->>28 byte 2 stereo -# Help! Isn't there any way to avoid writing this part twice? ->>32 string _VID \b, -# >>>48 string JFIF JPEG ->>>40 belong >0 %d frames ->>>44 beshort >0 (%d x ->>>46 beshort >0 %d) ->16 string _VID \b, -# >>32 string JFIF JPEG ->>24 belong >0 %d frames ->>28 beshort >0 (%d x ->>30 beshort >0 %d) - -0 string Paint\ Shop\ Pro\ Image\ File Paint Shop Pro Image File - -# "thumbnail file" (icon) -# descended from "xv", but in use by other applications as well (Wolfram Kleff) -0 string P7\ 332 XV "thumbnail file" (icon) data - -# partimage: file(1) magic for PartImage files (experimental, incomplete) -# Author: Hans-Joachim Baader -0 string PaRtImAgE-VoLuMe PartImage ->0x0020 string 0.6.1 file version %s ->>0x0060 lelong >-1 volume %d -#>>0x0064 8 byte identifier -#>>0x007c reserved ->>0x0200 string >\0 type %s ->>0x1400 string >\0 device %s, ->>0x1600 string >\0 original filename %s, -# Some fields omitted ->>0x2744 lelong 0 not compressed ->>0x2744 lelong 1 gzip compressed ->>0x2744 lelong 2 bzip2 compressed ->>0x2744 lelong >2 compressed with unknown algorithm ->0x0020 string >0.6.1 file version %s ->0x0020 string <0.6.1 file version %s - -# DCX is multi-page PCX, using a simple header of up to 1024 -# offsets for the respective PCX components. -# From: Joerg Wunsch -0 lelong 987654321 DCX multi-page PCX image data - -# Simon Walton -# Kodak Cineon format for scanned negatives -# http://www.kodak.com/US/en/motion/support/dlad/ -# 0 lelong 0xd75f2a80 Cineon image data -# >200 belong >0 \b, %ld x -# >204 belong >0 %ld - -#----------------------------------------------------------------------- -# From Albert Cahalan -# uncompressed 5:6:5 HighColor image for OLPC XO firmware icons -0 string C565 OLPC firmware icon image data ->4 leshort x %u x ->6 leshort x %u diff --git a/dest/share/magic/java b/dest/share/magic/java deleted file mode 100644 index 03ed78de4c9..00000000000 --- a/dest/share/magic/java +++ /dev/null @@ -1,49 +0,0 @@ -# $OpenBSD: java,v 1.5 2009/04/24 18:54:34 chl Exp $ - -#------------------------------------------------------------ -# Java ByteCode and Mach-O binaries (e.g., Mac OS X) use the -# same magic number, 0xcafebabe, so they are both handled -# in the entry called "cafebabe". -#------------------------------------------------------------ -# Java serialization -# From Martin Pool (m.pool@pharos.com.au) -#0 beshort 0xaced Java serialization data -#>2 beshort >0x0004 \b, version %d - -0 belong 0xfeedfeed Java KeyStore -!:mime application/x-java-keystore -# 0 belong 0xcececece Java JCE KeyStore -# !:mime application/x-java-jce-keystore - -# Android .dex format. http://retrodev.com/android/dexformat.html -# https://source.android.com/devices/tech/dalvik/dex-format.html -# From "Mike Fleming" -0 string dex\n ->0 regex dex\n[0-9][0-9][0-9]\0 Android DEX file ->4 string >000 version %s -0 string dey\n ->0 regex dey\n[0-9][0-9][0-9]\0 Android ODEX file ->4 string >000 version %s - -# Android .oat format -0 string oat\n ->0 regex oat\n[0-9][0-9][0-9]\0 Android OAT file ->4 string >000 version %s - -# Android .vdex format. -# https://android.googlesource.com/platform/art/+/master/runtime/vdex_file.h#114 -# http://romainthomas.fr/post/android-vdex/ -# https://github.com/anestisb/vdexExtractor/blob/master/src/vdex/vdex_common.h#L30 -0 string vdex ->0 regex vdex[0-9][0-9][0-9]\0 Android VDEX file ->4 string >000 version %s - -# Android .cdex format. https://android.googlesource.com/platform/art/+/android-9.0.0_r3/libdexfile/dex/compact_dex_file.h#29 -0 string cdex ->0 regex cdex[0-9][0-9][0-9]\0 Android CDEX file ->4 string >000 version %s - -# Android .art format. https://source.android.com/devices/tech/dalvik -0 string art\n ->0 regex art\n[0-9][0-9][0-9]\0 Android ART file ->4 string >000 version %s diff --git a/dest/share/magic/jpeg b/dest/share/magic/jpeg deleted file mode 100644 index c791e82864a..00000000000 --- a/dest/share/magic/jpeg +++ /dev/null @@ -1,166 +0,0 @@ -# $OpenBSD: jpeg,v 1.4 2009/04/24 18:54:34 chl Exp $ - -#------------------------------------------------------------------------------ -# JPEG images -# SunOS 5.5.1 had -# -# 0 string \377\330\377\340 JPEG file -# 0 string \377\330\377\356 JPG file -# -# both of which turn into "JPEG image data" here. -# -0 string \xff\xd8\xff JPEG image ->6 string JFIF , JFIF standard ->6 string Exif , EXIF standard - -# 0 beshort 0xffd8 -# !:mime image/jpeg -# >6 string JFIF JPEG image data\b, JFIF standard -# # The following added by Erik Rossen 1999-09-06 -# # in a vain attempt to add image size reporting for JFIF. Note that these -# # tests are not fool-proof since some perfectly valid JPEGs are currently -# # impossible to specify in magic(4) format. -# # First, a little JFIF version info: -# >>11 byte x \b %d. -# >>12 byte x \b%02d -# # Next, the resolution or aspect ratio of the image: -# #>>13 byte 0 \b, aspect ratio -# #>>13 byte 1 \b, resolution (DPI) -# #>>13 byte 2 \b, resolution (DPCM) -# #>>4 beshort x \b, segment length %d -# # Next, show thumbnail info, if it exists: -# >>18 byte !0 \b, thumbnail %dx -# >>>19 byte x \b%d -# -# # EXIF moved down here to avoid reporting a bogus version number, -# # and EXIF version number printing added. -# # - Patrik R=E5dman -# >6 string Exif JPEG image data\b, EXIF standard -# # Look for EXIF IFD offset in IFD 0, and then look for EXIF version tag in EXIF IFD. -# # All possible combinations of entries have to be enumerated, since no looping -# # is possible. And both endians are possible... -# # The combinations included below are from real-world JPEGs. -# # Little-endian -# >>12 string II -# # IFD 0 Entry #5: -# >>>70 leshort 0x8769 -# # EXIF IFD Entry #1: -# >>>>(78.l+14) leshort 0x9000 -# >>>>>(78.l+23) byte x %c -# >>>>>(78.l+24) byte x \b.%c -# >>>>>(78.l+25) byte !0x30 \b%c -# # IFD 0 Entry #9: -# >>>118 leshort 0x8769 -# # EXIF IFD Entry #3: -# >>>>(126.l+38) leshort 0x9000 -# >>>>>(126.l+47) byte x %c -# >>>>>(126.l+48) byte x \b.%c -# >>>>>(126.l+49) byte !0x30 \b%c -# # IFD 0 Entry #10 -# >>>130 leshort 0x8769 -# # EXIF IFD Entry #3: -# >>>>(138.l+38) leshort 0x9000 -# >>>>>(138.l+47) byte x %c -# >>>>>(138.l+48) byte x \b.%c -# >>>>>(138.l+49) byte !0x30 \b%c -# # EXIF IFD Entry #4: -# >>>>(138.l+50) leshort 0x9000 -# >>>>>(138.l+59) byte x %c -# >>>>>(138.l+60) byte x \b.%c -# >>>>>(138.l+61) byte !0x30 \b%c -# # EXIF IFD Entry #5: -# >>>>(138.l+62) leshort 0x9000 -# >>>>>(138.l+71) byte x %c -# >>>>>(138.l+72) byte x \b.%c -# >>>>>(138.l+73) byte !0x30 \b%c -# # IFD 0 Entry #11 -# >>>142 leshort 0x8769 -# # EXIF IFD Entry #3: -# >>>>(150.l+38) leshort 0x9000 -# >>>>>(150.l+47) byte x %c -# >>>>>(150.l+48) byte x \b.%c -# >>>>>(150.l+49) byte !0x30 \b%c -# # EXIF IFD Entry #4: -# >>>>(150.l+50) leshort 0x9000 -# >>>>>(150.l+59) byte x %c -# >>>>>(150.l+60) byte x \b.%c -# >>>>>(150.l+61) byte !0x30 \b%c -# # EXIF IFD Entry #5: -# >>>>(150.l+62) leshort 0x9000 -# >>>>>(150.l+71) byte x %c -# >>>>>(150.l+72) byte x \b.%c -# >>>>>(150.l+73) byte !0x30 \b%c -# # Big-endian -# >>12 string MM -# # IFD 0 Entry #9: -# >>>118 beshort 0x8769 -# # EXIF IFD Entry #1: -# >>>>(126.L+14) beshort 0x9000 -# >>>>>(126.L+23) byte x %c -# >>>>>(126.L+24) byte x \b.%c -# >>>>>(126.L+25) byte !0x30 \b%c -# # EXIF IFD Entry #3: -# >>>>(126.L+38) beshort 0x9000 -# >>>>>(126.L+47) byte x %c -# >>>>>(126.L+48) byte x \b.%c -# >>>>>(126.L+49) byte !0x30 \b%c -# # IFD 0 Entry #10 -# >>>130 beshort 0x8769 -# # EXIF IFD Entry #3: -# >>>>(138.L+38) beshort 0x9000 -# >>>>>(138.L+47) byte x %c -# >>>>>(138.L+48) byte x \b.%c -# >>>>>(138.L+49) byte !0x30 \b%c -# # EXIF IFD Entry #5: -# >>>>(138.L+62) beshort 0x9000 -# >>>>>(138.L+71) byte x %c -# >>>>>(138.L+72) byte x \b.%c -# >>>>>(138.L+73) byte !0x30 \b%c -# # IFD 0 Entry #11 -# >>>142 beshort 0x8769 -# # EXIF IFD Entry #4: -# >>>>(150.L+50) beshort 0x9000 -# >>>>>(150.L+59) byte x %c -# >>>>>(150.L+60) byte x \b.%c -# >>>>>(150.L+61) byte !0x30 \b%c -# # Here things get sticky. We can do ONE MORE marker segment with -# # indirect addressing, and that's all. It would be great if we could -# # do pointer arithemetic like in an assembler language. Christos? -# # And if there was some sort of looping construct to do searches, plus a few -# # named accumulators, it would be even more effective... -# # At least we can show a comment if no other segments got inserted before: -# >(4.S+5) byte 0xFE -# >>(4.S+8) string >\0 \b, comment: "%s" -# #>(4.S+5) byte 0xFE \b, comment -# #>>(4.S+6) beshort x \b length=%d -# #>>(4.S+8) string >\0 \b, "%s" -# # Or, we can show the encoding type (I've included only the three most common) -# # and image dimensions if we are lucky and the SOFn (image segment) is here: -# >(4.S+5) byte 0xC0 \b, baseline -# >>(4.S+6) byte x \b, precision %d -# >>(4.S+7) beshort x \b, %dx -# >>(4.S+9) beshort x \b%d -# >(4.S+5) byte 0xC1 \b, extended sequential -# >>(4.S+6) byte x \b, precision %d -# >>(4.S+7) beshort x \b, %dx -# >>(4.S+9) beshort x \b%d -# >(4.S+5) byte 0xC2 \b, progressive -# >>(4.S+6) byte x \b, precision %d -# >>(4.S+7) beshort x \b, %dx -# >>(4.S+9) beshort x \b%d -# # I've commented-out quantisation table reporting. I doubt anyone cares yet. -# #>(4.S+5) byte 0xDB \b, quantisation table -# #>>(4.S+6) beshort x \b length=%d -# #>14 beshort x \b, %d x -# #>16 beshort x \b %d -# -# # HSI is Handmade Software's proprietary JPEG encoding scheme -# #0 string hsi1 JPEG image data, HSI proprietary -# -# # From: David Santinoli -# 0 string \x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A JPEG 2000 image data -# -# # Type: JPEG 2000 codesream -# # From: Mathieu Malaterre -# 0 belong 0xff4fff51 JPEG 2000 codestream -# 45 beshort 0xff52 diff --git a/dest/share/magic/linux b/dest/share/magic/linux deleted file mode 100644 index 2ebba04319c..00000000000 --- a/dest/share/magic/linux +++ /dev/null @@ -1,227 +0,0 @@ -# $OpenBSD: linux,v 1.6 2009/04/24 18:54:34 chl Exp $ - -#------------------------------------------------------------------------------ -# linux: file(1) magic for Linux files -# -# Values for Linux/i386 binaries, from Daniel Quinlan -# The following basic Linux magic is useful for reference, but using -# "long" magic is a better practice in order to avoid collisions. -# -# 2 leshort 100 Linux/i386 -# >0 leshort 0407 impure executable (OMAGIC) -# >0 leshort 0410 pure executable (NMAGIC) -# >0 leshort 0413 demand-paged executable (ZMAGIC) -# >0 leshort 0314 demand-paged executable (QMAGIC) -# -0 lelong 0x00640107 Linux/i386 impure executable (OMAGIC) ->16 lelong 0 \b, stripped -0 lelong 0x00640108 Linux/i386 pure executable (NMAGIC) ->16 lelong 0 \b, stripped -0 lelong 0x0064010b Linux/i386 demand-paged executable (ZMAGIC) ->16 lelong 0 \b, stripped -0 lelong 0x006400cc Linux/i386 demand-paged executable (QMAGIC) ->16 lelong 0 \b, stripped -# -# 0 string \007\001\000 Linux/i386 object file -# >20 lelong >0x1020 \b, DLL library -# -# 0 string \01\03\020\20 Minix-386 impure executable -# >28 long !0 not stripped -# 0 string \01\03\040\20 Minix-386 executable -# >28 long !0 not stripped -# # core dump file, from Bill Reynolds -# 216 lelong 0421 Linux/i386 core file -# >220 string >\0 of '%s' -# >200 lelong >0 (signal %d) -# -# LILO boot/chain loaders, from Daniel Quinlan -# this can be overridden by the DOS executable (COM) entry -#2 string LILO Linux/i386 LILO boot/chain loader -# -# Linux swap file, from Daniel Quinlan -4086 string SWAP-SPACE Linux/i386 swap file -# From: Jeff Bailey -# Linux swap file with swsusp1 image, from Jeff Bailey -4076 string SWAPSPACE2S1SUSPEND Linux/i386 swap file (new style) with SWSUSP1 image -# according to man page of mkswap (8) March 1999 -4086 string SWAPSPACE2 Linux/i386 swap file (new style) ->0x400 long x %d (4K pages) ->0x404 long x size %d pages ->>4086 string SWAPSPACE2 ->>>1052 string >\0 Label %s -# Linux kernel boot images, from Albert Cahalan -# and others such as Axel Kohlmeyer -# and Nicol�s Lichtmaier -# All known start with: b8 c0 07 8e d8 b8 00 90 8e c0 b9 00 01 29 f6 29 -# Linux kernel boot images (i386 arch) (Wolfram Kleff) -514 string HdrS Linux kernel ->510 leshort 0xAA55 x86 boot executable ->>518 leshort >0x1ff ->>529 byte 0 zImage, ->>>529 byte 1 bzImage, ->>>(526.s+0x200) string >\0 version %s, ->>498 leshort 1 RO-rootFS, ->>498 leshort 0 RW-rootFS, ->>508 leshort >0 root_dev 0x%X, ->>502 leshort >0 swap_dev 0x%X, ->>504 leshort >0 RAMdisksize %u KB, ->>506 leshort 0xFFFF Normal VGA ->>506 leshort 0xFFFE Extended VGA ->>506 leshort 0xFFFD Prompt for Videomode ->>506 leshort >0 Video mode %d -# This also matches new kernels, which were caught above by "HdrS". -0 belong 0xb8c0078e Linux kernel ->0x1e3 string Loading version 1.3.79 or older ->0x1e9 string Loading from prehistoric times - -# System.map files - Nicol�s Lichtmaier -8 search/1 \ A\ _text Linux kernel symbol map text - -# LSM entries - Nicol�s Lichtmaier -0 search/1 Begin3 Linux Software Map entry text -0 search/1 Begin4 Linux Software Map entry text (new format) - -# From Matt Zimmerman, enhanced for v3 by Matthew Palmer -0 belong 0x4f4f4f4d User-mode Linux COW file ->4 belong <3 \b, version %d ->>8 string >\0 \b, backing file %s ->4 belong >2 \b, version %d ->>32 string >\0 \b, backing file %s - -############################################################################ -# Linux kernel versions - -0 string \xb8\xc0\x07\x8e\xd8\xb8\x00\x90 Linux ->497 leshort 0 x86 boot sector ->>514 belong 0x8e of a kernel from the dawn of time! ->>514 belong 0x908ed8b4 version 0.99-1.1.42 ->>514 belong 0x908ed8b8 for memtest86 - ->497 leshort !0 x86 kernel ->>504 leshort >0 RAMdisksize=%u KB ->>502 leshort >0 swap=0x%X ->>508 leshort >0 root=0x%X ->>>498 leshort 1 \b-ro ->>>498 leshort 0 \b-rw ->>506 leshort 0xFFFF vga=normal ->>506 leshort 0xFFFE vga=extended ->>506 leshort 0xFFFD vga=ask ->>506 leshort >0 vga=%d ->>514 belong 0x908ed881 version 1.1.43-1.1.45 ->>514 belong 0x15b281cd ->>>0xa8e belong 0x55AA5a5a version 1.1.46-1.2.13,1.3.0 ->>>0xa99 belong 0x55AA5a5a version 1.3.1,2 ->>>0xaa3 belong 0x55AA5a5a version 1.3.3-1.3.30 ->>>0xaa6 belong 0x55AA5a5a version 1.3.31-1.3.41 ->>>0xb2b belong 0x55AA5a5a version 1.3.42-1.3.45 ->>>0xaf7 belong 0x55AA5a5a version 1.3.46-1.3.72 ->>514 string HdrS ->>>518 leshort >0x1FF ->>>>529 byte 0 \b, zImage ->>>>529 byte 1 \b, bzImage ->>>>(526.s+0x200) string >\0 \b, version %s - -# Linux boot sector thefts. -0 belong 0xb8c0078e Linux ->0x1e6 belong 0x454c4b53 ELKS Kernel ->0x1e6 belong !0x454c4b53 style boot sector - -# 0 lelong&0xFF00FFFF 0x4000301 Linux-8086 executable -# >2 byte&0x01 !0 \b, unmapped zero page -# >2 byte&0x20 0 \b, impure -# >2 byte&0x20 !0 -# >>2 byte&0x10 !0 \b, A_EXEC -# >2 byte&0x02 !0 \b, A_PAL -# >2 byte&0x04 !0 \b, A_NSYM -# >2 byte&0x08 !0 \b, A_STAND -# >2 byte&0x40 !0 \b, A_PURE -# >2 byte&0x80 !0 \b, A_TOVLY -# >28 long !0 \b, not stripped -# >37 string . -# >>36 string >\0 \b, libc version %s - -# 0 lelong&0xFF00FFFF 0x10000301 ld86 I80386 executable -# 0 lelong&0xFF00FFFF 0xB000301 ld86 M68K executable -# 0 lelong&0xFF00FFFF 0xC000301 ld86 NS16K executable -# 0 lelong&0xFF00FFFF 0x17000301 ld86 SPARC executable - -# SYSLINUX boot logo files (from 'ppmtolss16' sources) -# http://syslinux.zytor.com/ -# -0 lelong =0x1413f33d SYSLINUX' LSS16 image data ->4 leshort x \b, width %d ->6 leshort x \b, height %d - -0 string OOOM User-Mode-Linux's Copy-On-Write disk image ->4 belong x version %d - -# SE Linux policy database -# From: Mike Frysinger -0 lelong 0xf97cff8c SE Linux policy ->16 lelong x v%d ->20 lelong 1 MLS ->24 lelong x %d symbols ->28 lelong x %d ocons - -# Linux Logical Volume Manager (LVM) -# Emmanuel VARAGNAT -# -# System ID, UUID and volume group name are 128 bytes long -# but they should never be full and initialized with zeros... -# -# LVM1 -# -0x0 string HM\001 LVM1 (Linux Logical Volume Manager), version 1 ->0x12c string >\0 , System ID: %s - -0x0 string HM\002 LVM1 (Linux Logical Volume Manager), version 2 ->0x12c string >\0 , System ID: %s - -# LVM2 -# -# It seems that the label header can be in one the four first sector -# of the disk... (from _find_labeller in lib/label/label.c of LVM2) -# -# 0x200 seems to be the common case - -0x218 string LVM2\ 001 LVM2 (Linux Logical Volume Manager) -# read the offset to add to the start of the header, and the header -# start in 0x200 ->(0x214.l+0x200) string >\0 , UUID: %s - -0x018 string LVM2\ 001 LVM2 (Linux Logical Volume Manager) ->(0x014.l) string >\0 , UUID: %s - -0x418 string LVM2\ 001 LVM2 (Linux Logical Volume Manager) ->(0x414.l+0x400) string >\0 , UUID: %s - -0x618 string LVM2\ 001 LVM2 (Linux Logical Volume Manager) ->(0x614.l+0x600) string >\0 , UUID: %s - -# SE Linux policy database -0 lelong 0xf97cff8c SE Linux policy ->16 lelong x v%d ->20 lelong 1 MLS ->24 lelong x %d symbols ->28 lelong x %d ocons - -# LUKS: Linux Unified Key Setup, On-Disk Format, http://luks.endorphin.org/spec -# Anthon van der Neut (anthon@mnt.org) -0 string LUKS\xba\xbe LUKS encrypted file, ->6 beshort x ver %d ->8 string x [%s, ->40 string x %s, ->72 string x %s] ->168 string x UUID: %s - -0 string #!/bin/sh Shellscript - - -############################################################################ -# Android - -# Android bootimg: -# https://android.googlesource.com/platform/system/tools/mkbootimg/+/refs/heads/master/include/bootimg/bootimg.h -0 string ANDROID! Android boot image -0 string VNDRBOOT Android vendor boot image - diff --git a/dest/share/magic/mach b/dest/share/magic/mach deleted file mode 100644 index ff9f8358bd3..00000000000 --- a/dest/share/magic/mach +++ /dev/null @@ -1,25 +0,0 @@ - -#------------------------------------------------------------ -# $File: mach,v 1.18 2014/03/29 15:40:34 christos Exp $ -# Mach has two magic numbers, 0xcafebabe and 0xfeedface. -# Unfortunately the first, cafebabe, is shared with -# Java ByteCode, so they are both handled in the file "cafebabe". -# The "feedface" ones are handled herein. -#------------------------------------------------------------ -# if set, it's for the 64-bit version of the architecture -# yes, this is separate from the low-order magic number bit -# it's also separate from the "64-bit libraries" bit in the -# upper 8 bits of the CPU subtype - - - -# -0 lelong&0xfffffffe 0xfeedface Mach-O - -0 belong&0xfffffffe 0xfeedface Mach-O -0 belong&0xfffffffe 0xcafebabe ->8 byte 0x00 Java CLASS ->8 byte !0x00 Fat-Mach-O - - -0 lelong&0xffffffff 0xc00cdefa MacOS Deteched Code Signature diff --git a/dest/share/magic/mail.news b/dest/share/magic/mail.news deleted file mode 100644 index d8902728c71..00000000000 --- a/dest/share/magic/mail.news +++ /dev/null @@ -1,55 +0,0 @@ -# $OpenBSD: mail.news,v 1.6 2009/04/24 18:54:34 chl Exp $ - -#------------------------------------------------------------------------------ -# mail.news: file(1) magic for mail and news -# -# Unfortunately, saved netnews also has From line added in some news software. -#0 string From mail text -# There are tests to ascmagic.c to cope with mail and news. -0 string Relay-Version: old news text -!:mime message/rfc822 -0 string #!\ rnews batched news text -!:mime message/rfc822 -0 string N#!\ rnews mailed, batched news text -!:mime message/rfc822 -0 string Forward\ to mail forwarding text -!:mime message/rfc822 -0 string Pipe\ to mail piping text -!:mime message/rfc822 -0 string Return-Path: smtp mail text -!:mime message/rfc822 -0 string Path: news text -!:mime message/news -0 string Xref: news text -!:mime message/news -0 string From: news or mail text -!:mime message/rfc822 -0 string Article saved news text -!:mime message/news -0 string BABYL Emacs RMAIL text -0 string Received: RFC 822 mail text -!:mime message/rfc822 -0 string MIME-Version: MIME entity text -#0 string Content- MIME entity text - -# TNEF files... -0 lelong 0x223E9F78 Transport Neutral Encapsulation Format - -# From: Kevin Sullivan -0 string *mbx* MBX mail folder - -# From: Simon Matter -0 string \241\002\213\015skiplist\ file\0\0\0 Cyrus skiplist DB - -# JAM(mbp) Fidonet message area databases -# JHR file -0 string JAM\0 JAM message area header file ->12 leshort >0 (%d messages) - -# Squish Fidonet message area databases -# SQD file (requires at least one message in the area) -# XXX: Weak magic -#256 leshort 0xAFAE4453 Squish message area data file -#>4 leshort >0 (%d messages) - -#0 string \