Commit graph

588 commits

Author SHA1 Message Date
Florian Märkl
c34ae1a7b5
Rename RZIL occurences to RZ_IL 2022-01-03 10:20:11 +01:00
Florian Märkl
9938a85c4b
[RzIL] Add RzReg/Variable Binding (#2155)
Plugins do not create register-based variables themselves anymore, but
they are derived from the register profile. However not all registers
may be bound and not all variables may be actual registers. The concrete
relations between an RzILVM and registers is described by an
RzILRegBinding object. It is simply a list of register names and
variables are created of the same names. When stepping with aezs, the
registers are synchronized automatically. From now on, aezv is primarily
useful for debugging, but interacting with emulation from the user side
should be done with ar.
2022-01-02 17:56:19 +00:00
Florian Märkl
7a8d5af180 [RzIL] Add rz_il_op_new_(unsigned|signed)() 2021-12-30 10:21:45 +01:00
Florian Märkl
86a7439519
Add IO/Map-based RzBuffer Implementation (#2147)
This adds an RzBuffer implementation that binds against RzIO's
rz_io_read_at/rz_io_write_at in order to access the mapped memory. This
is in contrast to the previous io RzBuffer, which has been renamed to
..._io_fd and which reads directly from a single file descriptor without
mapping.
To keep bf working, bin_bf now maps an area of zeroes because
otherwise the initial memory contents in RzIL would read as 0xff.
2021-12-29 10:28:55 +01:00
Florian Märkl
5d93ca3330
[RzIL] Flatten out all RzILOpArgs* structs (#2151)
This reduces heap usage and indirection.
2021-12-28 20:47:10 +00:00
Florian Märkl
aa80d2870f
[RzIL] Make cast work as in BAP (#2152) 2021-12-28 21:22:30 +01:00
Florian Märkl
d556d57d3f [RzIL] Fix minor leaks 2021-12-28 13:37:54 +01:00
Florian Märkl
6a09385746 [RzIL] Remove vector-oplists in favor of seq
The root type of a lifted op is now simply a single RzILOpEffect, which
can be for example a chain of seq ops. This is in line with what BAP
uses.
For convenient creation of sequences, `rz_il_op_new_seqn(ut32 n, ...)`
is a drop-in replacement for `rz_il_make_oplist(ut32 n, ...)`.
2021-12-28 13:37:54 +01:00
Florian Märkl
78025648ea
[RzIL] Make RzILOp statically typed (#2140) 2021-12-27 00:13:24 +08:00
Giovanni
5963da2bba
[RzIL] Add loadw/storew and bind memories against RzBuffer (#2105)
* [RzIL] Load/Store via RzIO and RzBuffer
* [RzIL] LoadW/StorWe via RzIO and RzBuffer
Co-authored-by: Florian Märkl <info@florianmaerkl.de>
2021-12-24 16:53:20 +01:00
wargio
d92a708541 [FLIRT] add info extraction 2021-12-23 17:06:55 +01:00
Florian Märkl
544905631c
[RzIL] Fix concept of Effects and Effect ops (#2109)
This brings our concept of effects in line with BAP and fixes issues
like values being evaluated prematurely in seq. The main point is that
ops themselves are the effects, rather than returning them to be
evaluated later.
2021-12-20 14:21:40 +00:00
Florian Märkl
17ef95aed8
Make rz_strbuf_slice() truncate on excessive len (#2115)
It is often useful to get a slice of some maximum len, also accepting
smaller results if the source is not large enough.
This also makes the function always operate on byte indices. Before,
it was inconsistently skipping ansi codes sometimes.
This also fixes potential oob writes in panels.c
2021-12-18 23:16:24 +01:00
Giovanni
57f83bd657
[FLIRT] Create signatures from RzAnalysis data (#2036)
Add pac and sig creation with options & compression via commands and via new rz-sign
Add missing arch (arc, pic, riscv, spc700 xtensa, and more)

Side note:
on other tools public functions and references are generated in a sequential 
way besides the first one which is the first to be assigned.
since we do not search for sequential references, then we can avoid to
add extra public or referenced functions

Extra:
* Refactoring rz_analysis_mask definition
* Add rz_str_startswith_const and rz_list_iter_get_next_data
2021-12-15 19:08:16 +01:00
wargio
8c2cb05af8 [RzIL] Add let, rewrite using RzPVector and various bugfixes 2021-12-14 12:34:55 +01:00
wargio
d288a24726 [RzIL] Refactor definitions and VM 2021-12-14 12:34:55 +01:00
Florian Märkl
96a85e573e Remove ESIL Pins (#2096)
ESIL Pins were an untested feature to run a command when emulation hit a
specific address. This can be solved in other ways, e.g. scripting.
Project version 7 has been introduced for this change.
2021-12-12 18:27:34 +01:00
Giovanni
bda1e9cfca
Disable GPL code and Add RISC-V support via Capstone 5 (#2087)
* -Duse_gpl=false is supported by rizin and added riscv_cs for capstone v5
* Added GPL build workflow in CI
2021-12-11 13:30:01 +01:00
Giovanni
c1c1fe05ec
[RzIL] refactored rz_il_op to expand new methods to rz_il_op_new_* (#2092) 2021-12-11 17:27:13 +08:00
Florian Märkl
4cb13c3183
Add rz_bv_set_from_bytes_le() (#2068)
Also make rz_bv_as_hex_string() always pad with the same number of 0s if
len % 4 != 0.
2021-12-06 12:28:26 +08:00
Dhruv Maroo
648c267bc7
Rename and refactor to use RzBitVector instead of RzILBitVector (#2048) 2021-12-01 14:28:04 +05:30
Riccardo Schirone
64469f2811
Changes in how paths are handled (#1997)
* Remove `RIZIN_EXTRAS` because useless

Extras plugin should be treated as any other regular plugin, they should
not have their own directory. I believe we did not have anyway any
plugin using that directory.

* Do not use `<version>` in `/usr/share`

Users can only install one version of Rizin at a time anyway, thus
splitting the `/usr/share/rizin` directories does not really bring
multi-version install possible. At the same time, we stick to what's
common for other tools, which do not use version in `/usr/share`

* Move plugin directory to `/usr/lib64/rizin/plugins`
* Remove `RZ_HOME_BIN` env var because not useful anymore
* Introduce `rz_util/rz_path` to provide rizin paths
* Use `rz_path_system_sdb_types` whenever it makes sense
* Use some others `rz_path_*` functions instead of custom ones
* Use `rz_path` APIs for themes, fortunes and signatures
* Remove `rz_sys_prefix`
* Reduce the number of defines needed to handle home and system paths
* Reduce the number of `rz_path` functions
* Make the lib debug depending on log level and `RZ_LOG_DEBUG`
* Refactor a bit how directory of plugins are loaded
* Keep supporting old plugins directory for at least 0.4.0
2021-11-30 13:36:38 +08:00
Dhruv Maroo
0801f7adf6
Port c commands to newshell (#1854)
Co-authored-by: Riccardo Schirone <ret2libc@users.noreply.github.com>
2021-11-25 17:55:08 +05:30
Dhruv Maroo
34d345d884 Format according to clang-format-13 2021-11-25 15:44:28 +08:00
billow
46533d41eb
EBCDIC character support (#1643) 2021-11-22 09:48:57 +08:00
Khairul Azhar Kasmiran
d6ba6b1ce8
Revert test/unit/cpp/meson.build (#2003) 2021-11-21 19:39:34 +08:00
Giovanni
446a56929b
[FLIRT] Improvements and added pac support & tests (#1992)
* Enforce architecture type on sig, files
* Added terminal output when calling zfs to display the number of matches 
* Added pac support
* Added tests
2021-11-18 18:47:29 +01:00
Khairul Azhar Kasmiran
906ece4211
Add asan build for clang (#1910) 2021-11-17 21:02:02 +08:00
OGRE
dfb6900366
[RzIL] Add concat, append handlers etc. (#1936) 2021-11-15 19:57:14 +01:00
wargio
5f7d85de8e Avoid heap for < 65 bits and simplified rz_il_bv_new_from_* methods 2021-11-15 14:56:15 +01:00
Giovanni
8f4620d043
Add thread pool and physical core number (#1973) 2021-11-14 12:06:19 +01:00
Giovanni
f41ea3c284
[FLIRT] Refactoring and create rz_sign library (#1960) 2021-11-11 20:29:59 +01:00
Riccardo Schirone
9ea989f58d Document rz_hex_str2bin and add unit tests 2021-11-09 12:01:41 +01:00
Giovanni
712f6cdabe
[RzIL] Refactoring, added bool xor and added bitv carry/borrow (#1930) 2021-11-04 19:48:10 +01:00
Giovanni
0d8d08951e
[RzIL] fix jmp & added bitvector type due limitation of int type (#1924)
Adds RZIL_OP_BITV and removes RZIL_OP_INT due host limitation
Fixed type RZIL_OP_JMP to work and apply effect.
Implemented rz_il_bv_new_from_st32 rz_il_bv_new_from_st64
2021-11-02 17:36:47 +01:00
Giovanni
4ca140a97b
[RzIL] implemented ao statement output (#1901)
* RzIL implemented il string and json representation
* Added json representation
* Fixed some memleaks on rz_il_free_op
* Implemented rz_il_op_stringify and rz_il_op_json
* RzIL Fixed memory leaks
2021-10-30 11:41:30 +08:00
Giovanni
8a036858df
[RzIL] Improvements (#1898)
Refactors the brainfuck RzIL code.
Implements aezv which returns the RzIL VM status and the output can be changed via rzil.status.compact=true/false
Refactors the oldshell help messages to clean some useless code
Refactors and optimize RzILBitVector methods
Fixes rz_il_bv_as_string, rz_il_bv_hash and implements rz_il_bv_as_hex_string and rz_il_bv_set_from_ut32/ut64
Assigns all the handlers to op_handler_table to avoid null derefs and to notify which operations are unimplemented
Implements rz_il_handler_logical_and, rz_il_handler_logical_or, rz_il_handler_logical_xor and rz_il_handler_cast
2021-10-28 19:02:19 +02:00
Riccardo Schirone
3e4660650c
RzShell: add autocompletion for @@ iterator operators, @@., @@=, etc. (#1896)
* RzShell: add autocompletion for @@ iterator operators, @@., @@=, etc.
* Update help for @@ii
* Fix test for @@?~?
2021-10-29 00:11:45 +08:00
Riccardo Schirone
9c3e6c15b4 Add few unit tests for @ autocompletion 2021-10-27 09:31:50 +02:00
Florian Märkl
3e7cdf58ed Remove strnlen() calls and replace by rz_str_nlen() 2021-10-26 10:50:22 +02:00
Riccardo Schirone
75fc447873
Fix some memleaks in unit tests (#1869)
* Cleanup RzAnalysisRzil when freeing RzAnalysis

* Fix str leaking in rz_core_write_string_at

* Fix buf leaking in rz_core_yank_paste

* Fix memleak in json unit tests

* Fix features leaking in RzBinInfo

* Fix features leaking in RzAsm

* Fix memleaks in RzTable

* Fix test_str_search memleaks

* Fix memleak in test_io.c

* Fix memleaks in RzBuf and test_buf.c

* Fix memleaks in test_cmd.c

* Fix memleaks in test_config.c

* Fix memleaks in RzCons

* Fix hashes leaking in test_bin.c

* Fix memleaks in test_id_storage.c

* Fix memleaks in test_il*.c and adjust APIs
2021-10-22 09:33:20 +08:00
Anton Kochkov
514f9fa75b
Remove unused RzBinheap API (#1865) 2021-10-21 15:14:57 +02:00
Anton Kochkov
c14a09f946 Remove unused RzFList 2021-10-21 16:45:09 +08:00
Riccardo Schirone
1172c4085c Re-design the way ? and ?? are used in rzshell
* `<cmd>?` allows to list the sub-commands of <cmd>. If <cmd> has no
  sub-commands, the full help of <cmd> is printed instead.
* `<cmd>??` allows to always list the full help of <cmd>. Useful when
  <cmd> is both the name of a group and a command itself.
* output modes are only listed as part of the full help and not
  considered as sub-commands.
* fix a bug where `<cmd><mode>?` was just printing the list of
  sub-commands of <cmd> instead of the full help of <cmd><mode>.
2021-10-18 11:57:17 +02:00
Khairul Azhar Kasmiran
637c192145
bin.str.enc: Rename latin1 to the more generic 8bit (#1847)
* Rename `rz_str_escape_latin1()` to `rz_str_escape_8bit()`
* test_serialize_analysis.c: Change string from "latin1" to "8bit"
* `bin.str.enc`: Rename `latin1` to the more generic `8bit`
2021-10-18 12:07:52 +08:00
Khairul Azhar Kasmiran
cb46249098
Rename Csa to Csb (#1844) 2021-10-16 15:50:59 +08:00
Anton Kochkov
39613b5c16
Port C (metainformation) commands to the rzshell (#1752)
* Do not escape strings during the search
* Port `C` (metainformation) commands to the rzshell
* Improve string autodetection
* Remove `Cr` and RZ_META_TYPE_RUN
* Escape `\x1b` as `\e` character in strings
* Move string encoding options to `RzStrEncOptions` struct
* Add `esc_double_quotes` option to `RzStrEncOptions`
* Do not filter out unprintable characters for uppercase check
* Use `esc_double_quotes` when printing the string between '"' in disasm
* Use signed chars on all platforms/architectures

Co-authored-by: Riccardo Schirone <sirmy15@gmail.com>
2021-10-15 16:48:18 +08:00
Heersin
e0d3d6bc66
New RZIL integration (#1663)
The new intermediate language is based on the BAP (Binary Analysis Platform) Core Theory.
It operates on SMT-like bitvectors and their arrays to represent values and memory.
Apart from that, it has also representation for the data and code side effects.
2021-10-09 18:14:44 +08:00
Basstorm
19a6a929f9
Rewrite PDB parser ##bin (#1517)
* Rewrite PDB parser to become endianess-independent
* Use type pretty-printing API
* Use `RzCmdStateOutput` instead of `RzOutputMode` to solve invalid JSON issue
* Move PDB-related print functions to `cpdb.c`
* Use flag API instead of calling commands from the code
* Separate printing from parsing and applying the type information
* Delete useless `main.c`
2021-10-09 16:57:29 +08:00
Riccardo Schirone
64be19f082 Move TSLanguage initialization into new rz_core_cmd_new API 2021-10-08 15:38:16 +02:00
Dhruv Maroo
4f8100cd97
Extend the pretty printing API for base types and other printers (#1781)
* Replace `rz_type_db_base_type_as_string` with `rz_type_db_base_type_as_pretty_string`

 * Use the new type pretty printing API to pretty print base types

* Add option to return newline terminated string by pretty printing API

 * Add `RZ_TYPE_PRINT_END_NEWLINE` option to RzTypePrintOpts

* Improve printing in cases of empty structs/unions/enums

 * Initially, the separator was printed between the curly breaces
   irrespective of whether the struct/union/enum is empty. Now the
   separator is not printed if the given type is empty

* Add pretty printing support for typedefs

 * Also, add another type printing option to show typedefs. To be used in
   `rz_cores_types_typedef_as_c`

* Refactor `.*_as_c` functions to use the new type pretty printing API

* Add tests for typedef and `unknown_t` for pretty printing API

* Add `rz_type_db_base_type_as_string` back. Update tests.

 * Use ternary operator to make expression more concise

* Add doxygen documentation for `rz_type_db_base_type_as_string`

* Use `rz_vector_len` to determine if empty, instead of convoluted logic

* Remove redundant `RZ_NONNULL` for RzTypeDB

* Fix integration tests for type printing

* Update Doxygen documentation

* Fix failint enum printing itegration tests

* Fix according to clang-format
2021-10-02 13:51:01 +05:30
Khairul Azhar Kasmiran
65cbec7267
Rename pj.h to rz_pj.h (#1783) 2021-10-01 21:35:39 +08:00
Anton Kochkov
8f1aab7243
Added crc32 and entropy values (#1774)
Co-authored-by: wargio <wargio@libero.it>
2021-10-01 16:35:10 +08:00
Dhruv Maroo
178701f721
Reduce registers shown in the output of dr and Vpp when analysing an ARM64 executable (#1739)
* Add function to check if a register is a system register

* Only checks for ARM64 system registers as of now

* Check for system registers in ARM64 when printing registers using "dr"

* Does not completely remove the unnecessary register, but removes a
  huge number of useless registers printed by "dr"

* Rename `RZ_REG_TYPE_ALL` to `RZ_REG_TYPE_ANY`

* ADd register types for "sys" and "pauth": `RZ_REG_TYPE_SYS` and
  `RZ_REG_TYPE_PAUTH` respectively

* Remove `rz_reg_is_system_reg`

* Add `sys` and `pauth` register profiles

* Update debug tests to account for new arenas and register profiles

* REplace "pauth" with "sec" reg profile

* Update integration tests to account for new register profiles: `sys`, `sec`
2021-09-28 23:49:55 +08:00
Dhruv Maroo
63ccf386f2
Type pretty printing API (#1678)
* Reduce duplicate code and use a single printing API for all sorts of
  printing requirements
2021-09-27 17:30:35 +00:00
Anton Kochkov
aac743beb1
Port y (yank) commands to the rzshell (#1734)
* Port `y` (yank) commands to the rzshell
* Add very basic yank unit tests

Co-authored-by: Riccardo Schirone <sirmy15@gmail.com>
2021-09-27 13:27:41 +08:00
Florian Märkl
cf7842e248 Fix sparse buffer size 2021-09-26 10:45:40 +02:00
Dhruv Maroo
a527b204d8
Add API function for RzBreakpointItem and fix breakpoint serialization tests (#1750) 2021-09-26 10:17:13 +02:00
Dhruv Maroo
0870fd7ae4
Close the test file opened in test_debug_serialize (#1747)
* Also, open only using read permissions to avoid any inadvertent file
  changes
2021-09-24 23:29:29 +08:00
Dhruv Maroo
2c48a91d13
Add serialization functionality for breakpoints (#1574)
* Migrate project from v5 to v6
* Add serialization for debug (RzDebug) instance (only for breakpoints as of now)
* Replace commit hash once the PR is merged into dev
* Add new namespaces added in v6
2021-09-24 12:30:28 +00:00
Riccardo Schirone
618ed4e0a8
Add separate test to check if C++ programs work with Rizin (#1743) 2021-09-24 10:15:59 +02:00
Luca Borzacchiello
f211163b70
UTF-16 be, UTF-32 be support (#1535)
* Refactored string search

string search logic moved from librz/bin/bfile.c to
librz/util/str_search.c

* UTF-16BE and UTF-32BE support

* Decoupled rz_str_search with rz_bin

* Changed parameter order in rz_scan_strings

* Fixed needle reset in rz_string_search

Now when the string search fails, needle is restored to original_needle+1,
i.e., we continue the searching process starting from the next byte.

* Changed heuristic for UTF BE detection

one more byte in for the detection (6 instead of 5)

* Fixed unit test in str_search

* Refactored rz_scan_strings and better UTF16-LE and UTF16-BE detection

Now if there is an ambiguity between UTF16-LE and UTF16-BE, we take the
longest one.

* Changed UTF BE heuristic

If there is any ambiguity about big-endian or little-endian, always
choose little endian

* Small format fixes in str_search

* Added preferred endianess switch in RzUtilStrScanOptions

* Fixed str_search regression tests
2021-09-17 16:37:35 +08:00
Florian Märkl
1e50bcfab2
Fix Leaks in Types string conversions 2021-09-16 21:52:48 +08:00
Florian Märkl
b87187b7b6
Fix Global Variable UAF after deleting flag manually (#1697) 2021-09-16 12:26:17 +08:00
Anton Kochkov
47b5f5a05f Fix toe command 2021-09-13 17:33:55 +08:00
Anton Kochkov
565bbf034d Add tests for rz_type*_as_string() functions 2021-09-10 16:54:42 +08:00
Anton Kochkov
358612a3ad Fix array printing in complex types 2021-09-10 08:27:41 +08:00
Anton Kochkov
c9f9aea292 Fix enum printing 2021-09-09 20:46:27 +08:00
Riccardo Schirone
5d6667abf5 Fix function pointers printing in complex types 2021-09-09 20:46:27 +08:00
Anton Kochkov
ecb5d4472e Bump Project version to 5, add unknown_t 2021-09-07 17:34:25 +08:00
Riccardo Schirone
1c78aee3cd
Convert i commands to rzshell (#1238)
* Start to create some RzBinObject specific API

Adding some unit tests

Fix for new relocs storage system

Fix test_bin unit test for oob-write

* Add `iA` command to newshell

Add `ie`/`iee` commands

Add support for `is`/`iE` commands

Add support for `ii` command

Add support for `il` command

Add support for `iM` command

Add support for `ir` command

Add support for `iS`/`iSS` commands

Add support for `iz` command

Add support for `i` command

Add support for `ic` command

Add support for `iC` command

Add support for `ih` and `iHH` commands

Add support for `iI` command

Add support for `iL` command

Fix descriptions of commands already converted

Add support for `idp` commands

Add support for `iD` command

Add support for `im` commands

Add support for `iR` command

Add support for `it` command

Add support for `iV` commands

Add support for `iw` command

Add support for `ix` commands

Add support for `iZ` command

Add support for `ik` command

Add support for `is.` command

Add support for `iS.` command

Reduce arguments in print_arch

Few Doxygen and ownership annotations

Add support for `iS=` command

Add support for `izz` and `izzz` commands

Add support for `ib` command

Add support for `ic*` command

Put section flags as the last field of the table

* Proper language detection.

* Rewritten blang.c

* implemented `icc/icm/icf <class name>`

* ignore blocks when printing langs

Remove num from `iA` output

* Fixed flags on java and added class column

Add support for `ia` commands

Fix `iCj` command

* RzBin: add rz_bin_object_sections_mapping_list API

* Fix rz-bin for new API

Remove unused va var in rz-bin.c

Fix `iA`/`-A` output

* implemented classdump_cpp

* Support namespaces

Use `icc`, `icl` does not exist anymore

Update output of broken tests for `icc`

Add `rz_return_*()` asserts in new `*_print()` functions

* Provide rz_core_bin_print API

* Select which parts to print also based on the mode

* Return bool from all `rz_core_bin_*_print()` API

* Use RzBinFile in new `rz_core_bin_*_print()` API

* Restore `dbg_dmi` test

* Remove oldshell handlers for `i` commands

* Remove `ieq` call in rizin, not needed

* Allow NULL `bf` in `rz_cmd_info_handler()`

* Re-add support for RZ_BIN_PREFIX for symbols/sections/segments/imports/relocs

* Move `ib` command to `obR`

* Show 'N/A' in `i` command when info are not available

* Assert on bf->o, just to be sure

* Make error messages clearer in `idp` commands

Co-authored-by: wargio <wargio@libero.it>
Co-authored-by: Giovanni <561184+wargio@users.noreply.github.com>
2021-09-04 22:37:05 +08:00
Riccardo Schirone
6aef990eef Fix few clang-cl warnings 2021-09-04 12:06:07 +02:00
Dhruv Maroo
aed6854bdf
Add autocomplete function and cmd arg type for global variables (#1577)
* Add autocomplete function and cmd arg type for global variables
* Add unit tests for global var auto completion

Co-authored-by: Riccardo Schirone <ret2libc@users.noreply.github.com>
2021-09-03 15:49:23 +08:00
Dhruv Maroo
3e5c8a1e23
Implement seeking for global variables (#1536)
* Add rz_analysis_var_global_*_flag functions
* Add init, destroy and update functions
* Incorporate flag handling functionality in the existing functions
* Add `avgm` command to remove global variable by name
* Add error logs when trying to find a non-existing global variable
* Add unit tests for flag functionality of global variables
2021-09-02 16:43:27 +08:00
Anton Kochkov
abc1d79f95
Add missing copyrights (#1570)
* Add missing SPDX copyrights

* Fix include headers
2021-09-02 16:39:50 +08:00
Riccardo Schirone
9c05850d85 Fix python linter 2021-08-30 17:31:09 +02:00
Riccardo Schirone
a5333f2a44 core/cmd_descs: add support for default_mode
Some commands might have one of the output modes as default one. If
that's the case, RzCmd should be aware of that so that it can
initializes everything needed for that default mode.

For example, if command `c` supports TABLE, JSON and QUIET and you want
to have `c`(with no suffix) print the TABLE mode, the parser would have
to initialize the RzTable data structures anyway, so it must be aware of
it.
2021-08-30 17:31:09 +02:00
Riccardo Schirone
c1bfebdc8f
test/unit: ignore OS byte in the gzip header when comparing deflated output (#1554) 2021-08-30 23:00:43 +08:00
Dhruv Maroo
a25ef4e9c6
Add rz_deflate* functions and save projects in compressed format (#1446) 2021-08-30 16:54:09 +08:00
Riccardo Schirone
2049360560 RzCmd: add some helper APIs for RzCmdStateOutput 2021-08-30 07:39:21 +02:00
Anton Kochkov
b9cb29ac90
Rename RNum to the RzNum (#1539) 2021-08-29 21:06:29 +02:00
Riccardo Schirone
4e6dc7fcee Fix test_rz_table_transpose unit test 2021-08-28 22:16:23 +08:00
Riccardo Schirone
e16a51e43c rz_util/rz_table: add rz_table_add_row_columnsf API to extend last row 2021-08-28 22:16:23 +08:00
Riccardo Schirone
0f177ea131 Use rz_cons_get_buffer_dup 2021-08-27 20:12:57 +02:00
GustavoLCR
b84158fd3e
Fixes for value analysis (#1520)
* Fill `op->reg` for ARM64 `br`/`blr` analysis
* This fixes software single-stepping on `br`/`blr` instructions on ARM64
* Fill `op->reg` for ARM `bx`/`blx` analysis
* This fixes software single-stepping on `bx`/`blx` instructions on ARM
* Set `bx` as `RZ_ANALYSIS_OP_TYPE_RJMP`
* Fill `RzAnalysisValue->type`
* Use only `RzAnalysisValue` in `rz_core_link_stroff()`
* Fill `op->ireg/disp/scale` for ARM `ldr` analysis
* This fixes software single-stepping for `ldr pc` on ARM
* Fix riscv inverted src/dst values for store instructions
* Fix riscv analysis with buffer of size 2
* Add unit tests for `RzAnalysisOp` and `RzAnalysisValue`

Co-authored-by: Giovanni <561184+wargio@users.noreply.github.com>
2021-08-27 22:07:39 +08:00
Aswin C
31d4143a93
Use str{l,n}cpy() in rz_str_ncpy() instead of a loop (#1395) 2021-08-25 18:21:45 +08:00
GustavoLCR
cfc504e1e9
Fix #1506 - Fix unsigned integer overflow in RzIO cache skyline (#1512)
* Fix #1506 - Fix unsigned integer overflow in RzIO cache skyline
* Add overflow check to `RzSkyline` APIs
2021-08-25 16:36:20 +08:00
Anton Kochkov
8eba1dcbc4 Add RzRun tests 2021-08-23 18:45:22 +08:00
Riccardo Schirone
dd38e70964
Add some SPDX headers (#1469)
* Add copyright and license to all librz/include/*.h files in dep5

* SPDX headers for most include files except bin/arch/debug

* Add SPDX headers in asm/arch/{8051,arm}

* Add SPDX header for shlr/gdb include files

* Add SPDX header for shlr/bochs include files

* Add SPDX header for librz/reg

* Add SPDX header for librz/debug/p/native/xnu

* Add SPDX header for librz/debug/p/native/windows

* Add SPDX header for librz/debug/p/native/reg include files

* Add SPDX header for librz/debug/p/native/maps include files

* Add SPDX header for librz/debug/p/native/linux include files
2021-08-17 18:27:03 +02:00
Anton Kochkov
19b12491d9
Add head and tail for RzVector and RzPVector (#1450) 2021-08-15 22:53:47 +08:00
Basstorm
8d54707ccf
New global variable concept (#1407)
* Add global var concept
* Doxygen & ownership & delete `delete_all` & argc check
* Use RBTree to manage the address of global variable
* Kill comment and access & use ht_pp_new
* Add unit test and regressions test
* Remove GlobalVarNode
* Implement global variable [de]serialization
* Moved `rz_cmd_state_output_array_start`
* Added complex type tests
* delete/get at or in address & convert type links to global variable & minor fix
* Remove `size` field
* Migration of typelinks to global var
* Use exists type parser
* Recover typelink unit test
2021-08-11 15:23:29 +02:00
Riccardo Schirone
3e41a97e7a
RzUtil: add unit tests for rz_str_ndup/nlen (#1419) 2021-08-10 21:48:06 +08:00
Pulak Malhotra
faac7e67d7
Resolve minor bug in rz_type_db_base_type_as_string (#1402) 2021-08-06 17:40:15 +08:00
Florian Märkl
bfecff9f36
Allow referring to structs/unions without specifiers (#1400) 2021-08-04 19:55:02 +08:00
Basstorm
8b065fc06c
Migrate the constrained type from RzAnalysis to RzType (#1397) 2021-08-04 16:08:54 +08:00
GustavoLCR
c9acf440cf
Reorganize map skyline segments 2021-08-03 22:44:38 +08:00
Basstorm
22fcc01fa6
Partly refactor PDB parser (#1173)
* Add more leaf_types for TPI parsing
* Get type list by its exact type index
* Print newly added LF_CLASS_19 and LF_STRUCTURE_19
* Newly added LF_CLASS_19 and LF_STRUCTURE_19 should also be formatted
* Newly added LF_CLASS_19 and LF_STRUCTURE_19 should also be parsed
* Fix wrong data type `Sval`, it should be `Numeric`
* Add LF_BCLASS LF_VBCLASS LF_IVBCLASS
* Add missing `LF_VFUNCTAB` leaf type
* Integrate PDB information into new types database

Co-authored-by: Basstorm <fuli114.ml@gmail.com>
2021-07-29 18:55:51 +08:00
Alexis Ehret
064e66bb51 Add configuration variables elf.load.sections 2021-07-28 16:40:14 +02:00
Alexis Ehret
0c1c9e0081 Change interface load_buffer RzBin (librz/bin) 2021-07-28 16:40:14 +02:00
Giovanni
8fe4d0b0a5
Convert ! commands to newshell (#1235)
* Updated core_plugin_example.c
* Removed RZ_BYTES and RZ_BLOCK
Co-authored-by: Riccardo Schirone <sirmy15@gmail.com>
Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2021-07-28 10:33:33 +02:00
Riccardo Schirone
ff2c350361
librz/util: Fix double free in buf when whole_buf is not allocated (#1362)
Inspired by
6fb0ba39ed

Co-authored-by: Giovanni <561184+wargio@users.noreply.github.com>
2021-07-27 12:52:42 +08:00
Giovanni
35558f4180
Pseudo refactoring (#1308)
* License fix
* Implemented common pseudo
* Refactored MIPS pseudo
* Refactored ARM pseudo
* Refactored AVR pseudo
* Refactored 6502 pseudo
* Refactored dalvik pseudo
* Refactored arm64 pseudo
* Refactored z80 pseudo
* Refactored TMS320 pseudo
* Refactored v850 pseudo
* Refactored SuperH pseudo
* Refactored Motorola 68K pseudo
* Avoid selecting a pseudo plugin when the arch is not found.
* rz_parse_parse -> rz_parse_pseudocode
2021-07-22 11:55:05 +02:00
Anton Kochkov
3c59df7e98
Refactor RzTypes to use structs instead of SDB + New Tree-Sitter based C Parser (#1047)
- Removed oldshell version of `t` (types) commands
- Removed `tk` command because types storage switched to the hashtable
- Added `tfc` command to show the calling convention of the function or set it
- Added `tsl` (RZ_OUTPUT_MODE_LONG) to show structure members' sizes and offsets
- Added `tul` (RZ_OUTPUT_MODE_LONG) to show union members' sizes
- Switched the types storage to the hashtable instead of SDB
- Added load and export from/to SDB for standard type libraries and serialization for Projects
- Changed all `char *type` occurences to the proper `RzType`
- Added `RzCallable` type for the function/class method types
- Changed all function types API to use the `RzCallable` API
- Switched the function types (`RzCallable`) storage to the hashtable instead of SDB
- Added a connection between `RzAnalysisFunction` and `RzCallable` - `rz_analysis_function_derive_type()` API function to derive new `RzCallable` type from the `RzAnalysisFunction` even if it doesn't exist in the RzTypeDB.
- Moved type links to the RzAnalysis where they belong
- Removed TCC and MPC-based parsers
- Added Tree-Sitter-based parser for C grammar (see `librz/type/parser/*`)
- Reworked type databases in `librz/analysis/d/` to be consistent with C standard, libc, platform-specific definitions
- Switched the type links from `char *` to `RzType`
- Switched the type links from SDB to the hashtable
- Added concept of the "type paths", e.g. `a.b[20].c` where `b` is a member of `a` (`a` is either structure or a union) and `c` is a member of `b`, and `b` is an array where we take 20-th element.
- Added concept of the typeclasses (a bit similar to Haskell) for numerical types: `None` (the most generic one), `Num` (includes `Integral` and `Floating`), `Integral` (includes `Signed Integral` and `Unsigned Integral`), `Floating`.
- Added concept of type equality (`rz_types_equal(a, b)` API function)
- Added Doxygen documentation to every API function in the `librz/type/*`.
- Updated the project format from **V2** to **V3**, added migration.
2021-07-20 01:46:45 +08:00
Aswin C
93defcfb4b
Fix the broken integration test for CPU profiles (#1307)
* Use resource packing and fix the broken integration test for CPU profiles
* Use `sizeof` to calculate size and run `clang-format`
* Use `rz_file_temp` to create a temporary SDB file rather than manually naming it
2021-07-15 10:13:57 +02:00
Anton Kochkov
703eab5405
Remove ESIL CFG and DFG (#1304) 2021-07-14 21:49:55 +02:00
Alexis Ehret
8e61ef212e Add function rz_buf_get_nstring 2021-07-07 12:01:17 +02:00
Riccardo Schirone
3a3e21ce2d Define rizin_exe also when using blob feature
Unit tests need the path of the rizin executable to properly run in some
cases, thus define rizin_exe variable both in regular build and when
rizin is built with -Dblob=true.
2021-07-05 09:26:54 +02:00
Florian Märkl
64223aeb60
Support self-unhooking of RzEvent Callbacks (#1255) 2021-06-30 19:49:30 +02:00
Riccardo Schirone
c8c98ecce3
Full table header line (#1239)
* Fully print last column header separator
* Fix table unit tests
* Fix tests
2021-06-28 17:25:25 +08:00
JunWei Song
ba1dd1c5ed
Using with for resource-allocating operations ##refactor 2021-06-28 17:24:39 +08:00
Sergei Trofimovich
67867e2484
test: use inplace 'rizin' binary for 'rzpipe' test 2021-06-14 18:32:40 +08:00
Florian Märkl
24c4f6cc09
Remove all PJEncodings (#1200) 2021-06-09 15:47:49 +02:00
Florian Märkl
a019616afd Add rz_buf_new_with_methods() 2021-05-30 10:53:13 +02:00
Florian Märkl
8e97bf218f Replace rz_buf_new() by rz_buf_new_with_bytes(NULL, 0) 2021-05-30 10:53:13 +02:00
Giovanni
d2fac299ed
Added details on pointer ownership (#1164) 2021-05-24 20:17:21 +02:00
Florian Märkl
58433a72ac Remove now-obsolete io.cache check for ELF Reloc Patching and add more Tests 2021-05-17 17:23:19 +08:00
Florian Märkl
a0729d4d80 Implement Full Reloc Patching for ELF in Virtual Files 2021-05-17 17:23:19 +08:00
Florian Märkl
7b63cb72ed Add RzBinVirtualFile 2021-05-17 17:23:19 +08:00
Florian Märkl
89b0738ce0 Add rz_buf_sparse_populated_in() 2021-05-17 17:23:19 +08:00
Theofilos Pechlivanis
07b937e235 Print the rizin plugin info in json ##print ##json
* Implement `aLj` in cmd_analysis.c ##print ##json
* Replace `,` with a `:` in `Loj` json ##test
* Replace `L` and `Lj` with `Ll` and `Llj` ##test
* Add tests for rz plugin json cmds ##print ##json
* List BinLdrPlugins for `Lij` ##print ##json
* Add spaces to represent no authors for `Li` ##test
* Convert `L` and `Ll` to newshell
* Convert `La` and `Laj` to newshell
* Move `Ll` handler to `clang.c`, rename `La` handler ##print ##json
* Convert `Lc` to newshell ##print ##json
* Convert `Ld` cmd to newshell ##print ##json
* Add `Laq` cmd test ##test
* Convert `Lh` to newshell and fix `La` check ##print ##json
* Fix `Lh` and convert `Li` cmd to newshell ##print ##json
* Convert `Lo` to newshell and modify `Lh` ##print ##json ##test
* Convert `Lp` to newshell ##print ##json ##test
* Use newshell cmd for `aL` ##print ##json
* Fix `Li`, lowercase json properties, add tests ##print ##json ##test
* Fix `Ld` and add `Lds` to set dbg backend ##print ##json ##test
* Revert `oL` and `aL` and replace `Lds` with `Ld` ##print ##json
* Use newshell for `obL`
* Replace `lang->cb_printf` with `rz_cons_printf`
* Replace `bin->cb_printf` with `rz_cons_printf` ##print
* Use `rz_lang_list()` instead of cmd0 ##print
* Set `Lo` and `Loj` tests as broken ##test
2021-05-17 13:38:11 +08:00
sandrabeme
bdface85a2 Switch iI command to use RzTable API
* Implement `rz_table_transpose()`
* Switch `iI` command to use RzTable API
2021-05-16 00:15:32 +08:00
Giovanni
6fec281af7
Rewrite rz-diff and internal diffing library (#1126) 2021-05-14 19:47:30 +08:00
Florian Märkl
63410b43df
Add Overlay Functionality to Sparse RzBuffer (#1124) 2021-05-12 12:52:46 +02:00
Anton Kochkov
50cbef66e9
New RzJson to string API (#1121) 2021-05-11 19:01:14 +02:00
Florian Märkl
2479f0c76a Fix ihex Write for >2 16bit Pages 2021-05-11 09:53:51 +02:00
Florian Märkl
de8767938f Rewrite Sparse RzBuffer for Efficient Reading 2021-05-11 09:53:51 +02:00
Florian Märkl
3c0ca68000 Add rz_vector_remove_range() 2021-05-11 09:53:51 +02:00
Florian Märkl
d285f108cc Add Tests for rz_vector_upper_bound() 2021-05-11 09:53:51 +02:00
0xfd000000
e6371c9e40
RzJson: support simple JSON paths ##json (#1115)
Add rz_json_get_path, which allows querying by paths like
'[0].sub.children[0].thing'
2021-05-10 13:20:56 +08:00
Florian Märkl
c61c4dd2cb Add Tests for Intel Hex and Fix some Edge Cases 2021-05-09 11:11:04 +02:00
Florian Märkl
fdc5a414f1 Add Tests to Fix 2021-05-08 13:04:10 +02:00
Florian Märkl
0959676695 Refactor RzBinFile Deletion API and add Events 2021-05-08 13:04:10 +02:00
Florian Märkl
9e949dfedd Refactor rz_bin_open* to return RzBinFile directly 2021-05-08 13:04:10 +02:00
Giovanni
cf56e35614
Fix Coverity issues (#1104) 2021-05-06 00:02:04 +08:00
Florian Märkl
88eaf90b9c Fix Confusion of Reloc Source and Target Addresses
old RzBinReloc.vaddr contained either the reloc address or
the target address, depending on how the bin was loaded.
Now there are two members and dedicated query function for each.
2021-05-05 21:54:36 +08:00
Florian Märkl
b1dd7cd5f4 Fix Vector Shrink to 0 under ASAN 2021-05-05 21:54:36 +08:00
Florian Märkl
8cbc9ae12e Use rz_array_upper_bound() in rz_bin_source_line_info_get_first_at() 2021-05-03 18:06:59 +02:00
Florian Märkl
16ba65b716 Add and Test rz_array_upper_bound() 2021-05-03 18:06:59 +02:00
Florian Märkl
e6090c574e Split rz_array_lower_bound from rz_pvector_lower_bound and test it 2021-05-03 18:06:59 +02:00
Florian Märkl
b38192bec9 Fix a leak and assert in test_vector 2021-05-03 18:06:59 +02:00
Giovanni
82e7917294
Refactoring Hash (#1082)
* Added authors and licenses and plugin access to crypto related files
* removed `rz_hash` and related files
* introduced `rz_msg_digest_*` with plugins
* updated all old methods with newer ones.
* added HMAC support to `rz-hash` (moved key option under `-K`)
* removed wrong algorithms on `woD`/`woE`
* fixed parity digest size
* fixed the behaviour on all hash functions
* added unit test for hash
* optimized code for HMAC key calculation
* removed hash legacy tests
2021-05-02 20:47:17 +08:00
Florian Märkl
be06cf0546 Track all related RzIOMaps and RzIODescs in RzCoreFile 2021-05-01 20:41:29 +02:00
Florian Märkl
6ed6e1cc93 Add Events for RzIODesc Close and RzIOMap Delete 2021-05-01 20:41:29 +02:00
Florian Märkl
b212b462d6 Clean up RzCoreFile 2021-05-01 20:41:29 +02:00
Florian Märkl
43bcdecf56 Add Unit Tests for Core RzBin Mapping 2021-05-01 20:41:29 +02:00
Florian Märkl
899483566d
Add rz_list_find_ptr() (#1092) 2021-04-30 10:07:39 +02:00
Anton Kochkov
e6fc65615f
Remove some irrelevant legacy unit tests (#1087) 2021-04-29 17:06:37 +08:00
Riccardo Schirone
cad4e0ae0f
Rename newshell to rzshell and parser commands to statements 2021-04-22 19:45:14 +08:00
Riccardo Schirone
0b66dc3b7d Simplify kill_word functions in dietline and fix META-D bug
* just use one kill_word/backward_kill_word function to reduce dupped
  code
* fix kill_word to correctly move buffer data
* add unit test for kill_word behaviour
2021-04-22 11:47:44 +02:00
Riccardo Schirone
4183cc4039 core/cmd: add new RzCmdDescType ARGV_STATE 2021-04-21 15:26:35 +02:00
seanachao
a2f8631b6c
Change -, --, = argument and = command meaning (#930)
* Swap = & - R (#615)&(#616)
* Fix R replace =
2021-04-21 16:20:24 +08:00
Anton Kochkov
16602984d9 New API to get vector of RzIO maps 2021-04-16 17:35:51 +08:00
Florian Märkl
a4f623ba25
Add RzIOMap return to rz_io_open_at() (#1012) 2021-04-14 20:41:05 +02:00
Anton Kochkov
4d7e79e511 Fix Coverity CID 317020 (UAF) 2021-04-13 19:06:20 +08:00
Anton Kochkov
cb2829d8f2 Fix Coverity CID 317125 (NULL DEREF) 2021-04-13 19:06:20 +08:00
Anton Kochkov
0e3cccb4ea New RzBaseType listing API 2021-04-13 11:17:15 +02:00
Florian Märkl
175849813e Implement Project Migrations with 1->2 2021-04-07 16:13:15 +02:00
Anton Kochkov
788fdb3d8e
Extracting types handling into RzType (librz/type) ##refactor (#896)
* RzType introduction
* Move format processing to RzTypes from RzUtil
* Rename RzType to RzTypeDB
* Join RzType and RzAnalysis noreturn functions
* Add noreturn column in `aflt` output
* Remove D (disassembly) pf tests
* Fix `tn` test
* Add function noreturn serialization
* Modify meaningless type test
* Fix wrongly written `Cf` test
* Fix `za t` (zignature type) command
* Fix signature type test
2021-04-06 18:04:00 +08:00
Riccardo Schirone
db04bed503
Fix autocompletion of rz- commands in rizin shell and rename wrong rz_ (#944) 2021-03-31 16:10:54 +02:00
Paul I
8649bebc54
Replace ref/xref with xref from/to 2021-03-30 15:33:31 +08:00
Florian Märkl
0103d14505 Make Dwarf emit RzBinSourceLineInfo 2021-03-30 13:07:05 +08:00
Florian Märkl
c07b04c92b Add new Line Data Structure 2021-03-30 13:07:05 +08:00
Florian Märkl
fa60048914
Remove all remaining SDB from Dwarf (#869) 2021-03-20 23:14:12 +08:00
Florian Märkl
8dae647a78 Split Dwarf Line Parsing in Parsing, Running and Printing 2021-03-19 18:24:40 +01:00
Florian Märkl
764be93b4b Rewrite Dwarf aranges Parsing 2021-03-19 18:24:40 +01:00
Florian Märkl
11426e1e4c Pull some Dwarf Printing from Bin to Core 2021-03-19 18:24:40 +01:00
Florian Märkl
a3fb364dae Make Dwarf Functions RzBinFile-local 2021-03-19 18:24:40 +01:00
Giovanni
7cfddb1da8
Java rewrite with LGPL license (#804)
* Rewritten RzBin java plugin (LGPL3)
* Rewritten java_core.c (LGPL3)
* Rewritten java RzAsm plugin (LGPL3)
* Rewritten java RzAnalysis plugin (LGPL3)
* Resolve constant_pool.<index> when rzbin is available.
* Updated tests with proper ones
* Support java <1.0.2 (i.e. OAK) file format
* Added constant pool resolver `javar`
* Added tests from java 1.7 to 15
2021-03-19 22:00:19 +08:00
Giovanni
e8af5a1320
Support rz_read_<endianness>_float/rz_read_<endianness>_double (#850)
* Support rz_read_<endianness>_float/rz_read_<endianness>_double
* Fix me encoding
* Added endian tests
2021-03-17 15:03:37 +01:00
Basstorm
31a2406f46
Pull Bin Classes into Analysis Classes in automated Analysis (#819) 2021-03-16 17:18:13 +00:00
Murphy
603edca005 Add support to rz_str_glob and add tests (#18420) 2021-03-16 16:57:32 +08:00
Florian Märkl
d14faa8f72 Add rz_vector_flush() 2021-03-12 09:02:11 +01:00
Florian Märkl
ee1dfffae5 Add rz_num_align_delta() 2021-03-12 08:14:24 +08:00
Khairul Azhar Kasmiran
7a4f9b3201
Set CI buildtypes to highest opt level possible and set default buildtype to debugoptimized (#260)
* Set default meson buildtype to debugoptimized
* Add separate Codecov build and remove linux-meson-gcc-build build
* Set test buildtypes to highest optimization level possible
* Run Codecov build only on dev branch
2021-03-10 18:00:56 +08:00
Riccardo Schirone
53bf5c497f SPDX Copyright text for all files based on history
- Add LICENSES directory
- Download additional licenses used
- Add .reuse directory
- Add doc about SPDX/reuse

Co-authored-by: Florian Märkl <info@florianmaerkl.de>
2021-03-05 19:39:15 +08:00
Riccardo Schirone
53be388b8f core: allow to sort subcommands of a command group 2021-03-02 08:44:44 +01:00
Riccardo Schirone
8baacdddf2 core: extract RzCorePlugins from RzCmd to RzCore 2021-03-02 08:44:44 +01:00
Riccardo Schirone
bdd7a990a7 core: RzCmd provides default_value to handler when specified 2021-02-26 12:36:39 +01:00
Anton Kochkov
450468f6c8 Use newshell for tn and td commands 2021-02-26 18:43:23 +08:00
Riccardo Schirone
42d3b01f09
core: retrieve parents details when not available (#724) 2021-02-26 12:59:43 +08:00
Riccardo Schirone
d6be0b26ca test/unit: we can't rely on the ordering stdout/stderr are captured
glibc-compiled rizin first finds the stderr output, then the stdout
output, while on musl-compiled rizin the stdout output is first (it's
also printed first by the program, so it makes more sense) then comes
the stderr output.

This is probably due to different buffering policies within glibc and
musl.
2021-02-25 19:41:38 +08:00
wargio
8005c480b2 Moving java from shlr to core
Removed unused code and comments.
Removed dead code
Moved print method outside class.c
Moved json method outside class.c
Removed yc_w_refs and i_mref which never worked.
Fixed set_flags method to work as intended.
Fixed various parsing errors.
Fixed many memory leaks.
Fixed "insecure" rz_cons_printf warning.
removed `#define V`, `#define U` and `#define _`
Implemented newshell calls.
Optimized code.
Refactoring rz_bin_java_get_field_offsets
Avoid loading static core plugins when not needed.
Removed useless `if 0`
2021-02-25 12:02:20 +01:00
Riccardo Schirone
10f72d818c
Implement rz_subprocess_start_opt API to choose pipes (#243) 2021-02-22 12:57:31 +00:00
Alexis Ehret
95acd6b151 Fix comparison of narrow type with wide type in loop condition test/unit/test_serialize_analysis.c 2021-02-21 22:25:50 +01:00
Alexis Ehret
77a965215d Fix pylint errors test/unit/legacy_unit/syscall/openbsd-gen.py 2021-02-15 10:24:46 +01:00
Alexis Ehret
8eae11ae4e Fix coding style python files (black, isort) 2021-02-15 10:24:46 +01:00
Alexis Ehret
8945da4a86 Fix dead assignment test/unit/test_id_storage.c 2021-02-09 10:37:25 -01:00
Alexis Ehret
55e3d3ebed Fix dead assignment test/unit/test_cmd.c 2021-02-09 10:37:25 -01:00
Florian Märkl
6f4336dcc4
Rename RJson to RzJson (#545) 2021-02-08 19:02:32 +00:00
wargio
8cfa9e31e3 Support in newshell for <cmd>?*[j] and j*[j] <command> 2021-02-08 01:53:32 +01:00
Florian Märkl
ed6d93d4d2 Make rz_base64_encode use the right types 2021-02-03 15:40:29 -01:00
Anton Kochkov
48d34e1571 Add rz_config_* API for booleans 2021-02-03 22:32:08 +08:00
Riccardo Schirone
e7ebbb22ba
Create API for .ar*, .dr*, aei, ar <reg>=<val> (#511)
* Move rz_debug_reg_list from RzDebug to RzCore and directly use rz_cons_printf
* rz_reg_get_list returns always the same list, so make it const RzList *
2021-02-03 21:58:36 +08:00
Fangrui Song
fa9db31b8c rz-diff: drop MODE_DIST
MODE_DIST (-s) is the same as MODE_DIST_LENVENSHTEIN (-ss) but much slower.
Drop it. Make MODE_DIST_MYERS (-sss, faster than MODE_DIST_LENVENSHTEIN) take its place (-s).

The original comment was incorrect (-s is not Eugene W. Myer's algorithm). It is correct now.

Co-authored-by: eagleoflqj and Maskray
2021-02-03 19:27:30 +08:00
Florian Märkl
e76c435565
Add rz_strf() Macro (#506) 2021-02-02 19:17:44 +01:00
Florian Märkl
1907784363 Use portable Format for Graph Metrics in Zignatures 2021-02-02 09:11:09 -01:00
Khairul Azhar Kasmiran
37d24d7f71
Fix -Wformat-truncation warnings (#493)
* Fix -Wformat-truncation warnings

* Don't evaluate macro parameters multiple times
2021-01-30 12:15:34 +08:00
Riccardo Schirone
c4906a2b68 Fix unit test tree 2021-01-28 11:57:28 +01:00
Riccardo Schirone
cee8d470c2 Remove Makefiles and many related scripts 2021-01-28 11:57:28 +01:00
Anton Kochkov
a0be4e2e64 Run clang-format 2021-01-21 22:05:44 +08:00
Riccardo Schirone
dfb9de8e70 Implement seek autocompletion 2021-01-21 11:15:13 +08:00
Riccardo Schirone
4eae6a0686 Add rz_cmd_desc_get_arg API 2021-01-21 11:15:13 +08:00
Riccardo Schirone
144ba639dc
Convert s commands to newshell (#375)
* Rename `sj`/`s*` and move them under `sH`. Remove `s=`
* Rename `s-*` to `sH-`
* Use `sd` for "seek delta", which moves relative to the current offset
* Enforce <cmd> <arg> syntax. So no more `s+16` but `s +16`. Command
  `sHr` is for redo history, `sHu` for undo history. If one wants to move
  relative to the current address, they need to do `sd +10`/`sd -10`.
* Remove `ss` commands in favour of `cmd.seek.silent`. This was anyway
  used mainly for scripts, so no need to replicate all `s` commands
  under `ss`.

Change a bit rz_core_seek API to avoid dupped entries in seek history.
2021-01-20 10:30:20 +08:00
Khairul Azhar Kasmiran
d5601cc2fe
Replace naked rz_sys_system/write/read/freopen calls with their wrapped counterparts (#388) 2021-01-19 00:07:19 +08:00
Khairul Azhar Kasmiran
e673afe71b
minunit.h: Use snprintf instead (#367)
* #define minunit buf size

* Use snprintf instead in minunit.h

* Use snprint_mem instead

Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2021-01-16 16:34:49 +08:00
Riccardo Schirone
0d7f7d1e01
Move seek history from RzIO to RzCore (#358)
* Remove undo write API, it was not used
* Move seek from IO to Core
* Remove IO undo files
* Fix cursor positionig in visual when doing undo/redo
* Add doxygen doc for rz_core_seek API
* Add cfg.seek.{histsize,silent} evals
* Add unit test for rz_[p]vector_foreach_prev
2021-01-15 13:27:57 +01:00
Florian Märkl
629305d567 Fix potential null-deref in rz_rbtree_cont_foreach() 2021-01-14 20:05:24 +08:00
Khairul Azhar Kasmiran
c10f78e9df
Fix minunit -Wformat-overflow= warning by increasing msg buf size (#355) 2021-01-14 17:35:51 +08:00
Riccardo Schirone
68c9388fb9
Shell error messages improvements (#339)
* Print proper error message when command does not exist

* Improve error messages on wrong arguments or wrong help

* Fix cmd_w test

* Check char * and avoid calling old input commands

* Fix english

* Check for NULLs and fix memleak
2021-01-13 00:28:58 +08:00
Riccardo Schirone
c734cbe560 Replace RzCons->line with the created one and just call rz_cons_free
rz_cons_free already calls rz_line_free on cons->line.
2021-01-07 18:59:43 +08:00
Riccardo Schirone
e7f9be7c3e Add rizin eval autocompletion ##newshell 2021-01-05 23:33:32 -06:00
Riccardo Schirone
0abb2c8bfc Convert 'e' commands to newshell ##newshell 2021-01-05 23:33:32 -06:00
Riccardo Schirone
296b64e2e9 Add flags to RzCmdArg to mark array, last, option args 2021-01-05 23:33:32 -06:00
Riccardo Schirone
ed8525e46f Rewrite rz_str_split functions with unit tests 2021-01-05 23:33:32 -06:00
Riccardo Schirone
40af504ec1 Fix memory leaks in test_cmd 2021-01-05 23:33:32 -06:00
Anton Kochkov
e9d91af698 More Rizin renames 2021-01-05 05:21:41 -06:00
Liumeo
58c21272ad Fix s390x test_agraph (#18172) 2021-01-05 05:21:41 -06:00
Liumeo
2f3297a245 Fix memleak in test_dwarf & test_skyline (#18169) 2021-01-05 05:21:41 -06:00
Liumeo
619a583acc Fix memleak in test_str & test_debug_session (#18164) 2021-01-05 05:21:41 -06:00
Liumeo
d50d0a43a9 Fix memleak in test_buf & test_cmd (#18162) 2021-01-05 05:21:41 -06:00
Qijia Liu
9aead1baeb Fix memleak in rizin and test_big 2021-01-05 05:21:41 -06:00
Liumeo
0b0b521c8c Fix memleak in test_analysis_block & test_io (#18153) 2021-01-05 05:21:41 -06:00
Anton Kochkov
f0e5db286c More Rizin renames 2021-01-05 00:45:10 -06:00
Riccardo Schirone
7316b71619 Simplify io_default with RzBuffer 2021-01-03 11:42:38 +01:00
Riccardo Schirone
0cf9979f42 Add fd to RzBuf and add mode to mmap RzBuf 2021-01-03 11:42:38 +01:00
Riccardo Schirone
d25cea5420 Rewrite rz_file_mmap API 2021-01-03 11:42:38 +01:00
Riccardo Schirone
dca021bab9 Fix hex unit test for windows 2021-01-03 11:42:38 +01:00
Riccardo Schirone
73080975d4 Fix autocompletion unit tests on Windows by using RZ_SYS_DIR 2021-01-03 11:42:38 +01:00
Riccardo Schirone
c97de6de1b Disable the entire test_rzpipe on Windows
Mark also the other rzpipe test as broken
2021-01-03 11:42:38 +01:00
Anton Kochkov
1d453a073b Rename test_r_* to test_rz_* 2021-01-03 11:42:38 +01:00
Riccardo Schirone
a7fd3fa3c6 Use mu_main to reduce boilerplate in unit tests
* Disable colors on Windows because terminal looks bad otherwise
* Use environment on Windows to set PATH and make sure unit tests use
  the compiled libraries and not the installed ones
* Define ssize_t on Windows as well by using SSIZE_T

Update test_analysis_block.c

Update test_intervaltree.c

Update test_unum.c
2021-01-03 11:42:38 +01:00
Liumeo
a512717767 Fix arm32 test_vector_fini (#18063) 2020-12-22 08:26:41 +08:00
Florian Märkl
da4703d757
Add Exclusions to RzConfig Loading (#223) 2020-12-21 14:26:31 +01:00
Anton Kochkov
5d07857260 Rename RBitmap to RzBitmap 2020-12-21 17:57:02 +08:00
Anton Kochkov
ecacfb9c8f Rename RTable to RzTable 2020-12-21 17:57:02 +08:00
Florian Märkl
f4181a8c87
Rename more Block API and remove hard-coded x86 logic ##analysis (#176) 2020-12-17 10:52:00 +01:00
Maijin
56c5f40ed7
Remove blocks and function folding feature (#201) 2020-12-17 10:27:25 +08:00
Florian Märkl
22b21242e6
Re-add Finished Callback to Cmd Tasks ##core (#196) 2020-12-15 17:14:33 +01:00
Florian Märkl
4037975ac0
Reduce Coupling between RzCore and Tasks ##core (#166) 2020-12-15 13:23:23 +01:00
Riccardo Schirone
5d6426508a Make rz_subprocess_lock/unlock private 2020-12-15 10:18:50 +01:00
Riccardo Schirone
286f930b93 Use O_CLOEXEC when creating pipes so they are closed on exec
By default, pipes file descriptors are not closed on exec. This means
they are inherited by the child process. However, this may be a problem
in particular in multi-threading programs (e.g. rz-test), because EOF is
not sent to a pipe until the last pipe file descriptor is closed.

This commit makes sure that by default pipes are created with O_CLOEXEC,
so they are closed whenever an exec syscall is executed. Usually pipe
file descriptors are duplicated to be stdin/stdout/stderr of the
children process and those dupped file descriptors won't be closed on
exec.

In case pipe2 is not available (e.g. MacOS), we do a pipe + fcntl, which
is in theory racy (see man open(2)). For this reason pipe, exec, system,
etc. are wrapped in rz_sys and they use a global mutex to make sure a
pipe is either created and set as O_CLOEXEC or not created at all before
an exec operation is done.

On very old systems, O_CLOEXEC may not be available at all. In those
cases, which should be rare, we just keep a list of file descriptors
created with rz_sys_pipe that we need to close before executing another
process.

Interaction with external libs may be tricky. We expect external libs to
create files/pipes that need to be closed on exec with the right flags
and we expect rizin code to manually close pipes file descriptors as
appropriate if the exec syscall is executed by an external library
(non-rizin code).

Make sure execl is found by acr/make
2020-12-15 10:18:50 +01:00
Riccardo Schirone
5ea4697402 Use RzSubprocess in rz_test 2020-12-15 10:18:50 +01:00
Riccardo Schirone
09d305ec10 Extract subprocess API used in rz-test into RzUtil 2020-12-15 10:18:50 +01:00
Riccardo Schirone
21175fa26b Fix unit tests: mock columns/rows console and reduce big time 2020-12-09 18:37:30 +01:00
Florian Märkl
d53d1e3845
Final Analysis Renaming (#124)
* Rename missing Analysis Defines
* Rename analysis config vars and other lower case stuff
* Rename test/db/analysis
* Fix analysis tests

Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2020-12-08 15:05:24 +08:00
Anton Kochkov
ad36954adb
More renames of *anal* to *analysis* (#123) 2020-12-07 13:20:29 +01:00
Anton Kochkov
041d73dce3
Change the "anal" abbreviation to "Analysis" in Code (#117) 2020-12-06 19:25:27 +01:00
Giovanni
35a9ef94c9
Code and comments cleanup (#108) 2020-12-04 18:11:51 +08:00
Florian Märkl
c5021f7c8a
Add High-Level Binary File Reference to Projects (#99) 2020-12-01 11:57:01 +01:00
GustavoLCR
cfd90b6dd3 Add unit tests for RSkyline (#17969) 2020-11-24 14:51:44 +01:00