Commit graph

99 commits

Author SHA1 Message Date
Khairul Azhar Kasmiran
c1fc1419e4
Rename some rz_list funcs to rz_list_XXX_val (part 1) (#5671)
* Rename rz_list_find_ptr() to rz_list_find_val()
* Rename rz_list_delete_data() to rz_list_delete_val()
2025-12-25 22:01:49 +08:00
Khairul Azhar Kasmiran
b96202ad48
Rename rz_list_first() / rz_list_last() to rz_list_first_val() / rz_list_last_val() (#5654) 2025-12-20 17:08:59 +08:00
Giovanni
2f97762b09
librz/core: Remove rizin command output (#5540)
* Remove RIZIN command output for the old projects

* Fix cmeta.c

* Fix ik command

* Revert back pc*

* fix formatting cmd_descs_generate.py

* Fix rz_cons_pal_list_as_css

* Fill all info about colors for ec commands.

* Fix all tests
2025-11-28 23:41:47 +08:00
Rot127
e8c04e0cf9
Separate the setters for binfile objects and current binfile in RzBin. (#5342) 2025-09-07 12:19:29 +00:00
Anton Kochkov
58b0b3715b
Add FreeBSD x86_64 debug tests (#3273)
Co-authored-by: well-mannered-goat <takshformal@gmail.com>
Co-authored-by: Rot127 <45763064+Rot127@users.noreply.github.com>
2025-06-24 21:19:31 +08:00
Ahmed Kamal
93d914bd81
Remove Global/Static variables in path.c to make it thread safe (#5148) 2025-06-13 21:34:33 +08:00
NOT XVilka
30ae60a759
Remove RAP protocol (#5046)
Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2025-03-27 00:55:06 +08:00
Rot127
2f613ca84a
Remove Cd format calls with side effects, and handle section layout with the API. (#5025) 2025-03-23 22:52:07 +08:00
Florian Märkl
d596104659
librz/core+bin: Remove obr (bin rebase command) (#5001)
Rebase done by obr freed all vfiles in the RzBinObject, but did not free
the entire RzBinFile, so core was not notified about it, and it may
still have had references to vfiles in vfile:// mappings, thus causing
UAFs.
Unfortunately the entire obr command was not working properly, so we
remove it with obR (also not entirely working) and rb being possible
replacements depending on the use-case.
The possibly dangerous RzBin apis have been made private in the module
to prevent future misuse.
2025-03-14 20:33:38 +01:00
Rot127
3c7b8c86cc
shell: port R commands to RzShell (#4957)
* Move `R!` to RzShell.
* Port `Rg` commands to RzShell
* Port `Rh` commands to RzShell.

Drops support for background webservers, because they were never handled.
The 'RH' commands were merged into 'Rh'.

Browser

* Remove seemlessly useless command call.

* Remove dead code

* Apply suggestion

Co-authored-by: Giovanni <561184+wargio@users.noreply.github.com>
2025-03-05 23:18:20 +08:00
Giovanni
db1e4993a0
Replace strdup with rz_str_dup (#4634) 2024-09-15 19:12:07 +08:00
Anton Kochkov
9c5e97ded6
test/integration/open: check base address (#4597) 2024-08-29 11:21:23 +08:00
Anton Kochkov
3ceafb587a
core/file: add API for the oC command (#4531) 2024-06-04 10:38:32 +08:00
Florian Märkl
2cacf880c1
Add missing newlines to some RZ_LOG_* calls (#4439) 2024-04-18 00:04:38 +08:00
Giovanni
ef0ed21d9f
Convert basic block into RzPVector (#4349)
Co-authored-by: HN026 <plancksconstant01@gmail.com>
2024-03-10 15:59:15 +08:00
wargio
a80622bcc1 Remove old options and replace with new global ones for string search.
Removed options:
- `bin.maxstr`

Renamed options:
- `bin.minstr` is now `str.search.min_length`
- `bin.maxstrbuf` is now `str.search.buffer_size`
- `bin.str.enc` is now `str.search.encoding`

New options:
- `str.search.reload`
- `str.search.max_threads`
- `str.search.max_uni_blocks`
- `str.search.max_region_size`
- `str.search.raw_alignment`
- `str.search.check_ascii_freq`
- `str.search.mode`
2024-02-19 19:39:00 +08:00
Anton Kochkov
08272c0cec
Remove some of the sdb_fmt() calls (#4131) 2024-01-21 12:26:37 +08:00
Peiwei Hu
3a2148e1cd
Refactor sections in RzBinPlugin from list to pvector (#4089) 2024-01-11 12:19:22 +08:00
Peiwei Hu
32491012ee
Refactor the maps in RzBinPlugin from list to pvector (#4081) 2024-01-07 12:42:54 +08:00
Peiwei Hu
886dfa5c17
Transition from list to pvector for symbols in RzBinPlugin (#4077) 2024-01-06 19:54:19 +08:00
Peiwei Hu
c0f62c529b
Refactor <libs> from RzList to RzPVector in RzBinPlugin (#3961) 2023-11-08 15:51:41 +08:00
Riccardo Schirone
9d68e9614f
Fix old math commands (#3828)
* core/cmd: Adjust math commands

* shell: make `?x` commands a parsing failure

We have moved the `?x` commands to `%x`, thus now no command should
start with `?`. This patch makes the parser fail to parse `?x`
strings.

* core/tui: use APIs in panels

* There's no `%q` anymore, use `%=`
2023-09-14 08:53:25 +08:00
Florian Märkl
a80f4910f0
Remove warning about missing calling convention (#3846)
This warning turned out to be more misleading and spammy than actually
useful. For example, it speaks of a "file" when loading just a malloc,
and many architectures simply do not have any standardized calling
conventions, like 6502 or gb, in which case the analysis is fine without
any loaded cc info.
2023-09-12 09:55:03 +08:00
Peiwei Hu
a5780a3855
Refactor imports-related stuff from RzList to RzPVector (#3781)
+ Switch the member imports in RzBinPlugin from RzList to RzPVector
+ Also switch the member imports in RzBinObject from RzList to RzPVector to meet the refactor of RzBinPlugin
+ Modify the traverse and invocation related to the aforementioned changes
+ Remove the deprecated API rz_bin_get_imports
2023-08-24 16:14:32 +08:00
Hertatijanto Hartono
d1fd135df3 Reopening file should not be identified as an error 2023-07-25 11:02:11 +08:00
wargio
c85b1afa4c Rewrite how bins are loaded into RzBinObject
This commit rewrites completely how RzBinPlugin are used to load info
into the RzBinObject structure.

Main changes are:
- Avoid looping multiple times to set the same data:
  now the data is cycled only once to rebase addresses, demangle strings
  and to make each loaded structure similar to each other.

- rz_bin_demangle is now demangling only strings:
  the old implementation was a hack over a hack to add classes & methods
  into the RzBinObject while demangling a string.
  This allowed methods and classes to be added to RzBinObject when for
  example invoking `is` or other printing commands.
  This was meant to be an "optimization" to avoid looping and doing
  things on-the-fly.

- Now the demangling is done after guessing the language used in the bin.
  This is done to avoid looping to various demanglers hoping that a
  string is going to be correctly demangled.
  After each string is demangled, the string is given to the language
  related function which adds classes, methods and fields into the
  RzBinObject fields.

- Swift handling is a special case, since the demangler can be disabled
  via -Duse_swift_demangler.
  The issue with the swift demangler is that is not correctly demangling
  strings and outputting swift code, but instead is creating something
  that sometimes works, sometimes doesn't.
  Also the old code only added fields and never methods for "reasons",
  and the new code just uses what the old code was doing as is.

- The new code also takes advantage of the language detection, which now
  happens before the demangling of symbols, imports and relocs.
2023-06-01 23:16:09 +08:00
billow
abfa59c1a1 Fix rz_core_file_reopen_debug 2023-05-24 08:49:05 +08:00
Florian Märkl
d9950f7479
Replace bp/sp-vars by generic stack-based ones (#3167)
Variables on the stack are not identified by bp/sp+<offset> anymore, but
by their address from the bottom of the stack frame (RzStackAddr),
independent of how they are accessed.
So now there are only two kinds of variables: stack and register.

This required some major refactoring and other changes:
* RzAnalysisVar.isarg was removed. Whether a variable is an argument is
  now specified implicitly by its storage location.
* Varsub of struct fields had to be rewritten so fields can be queried
  by arbitrary stack addresses using the recently introduced sp
  tracking, as the old approach to fill a list with all fields would not
  work anymore.
* analysis.vars.stackname was removed, new behavior is more similar to
  this being true before.
* Variables will not be created at stack+0 now, because the return
  address is there. Before, vars were only created sometimes in such
  cases.
* Variables created from bp offsets in x86 are not deleted anymore if
  the function's bp_frame is false (see removed
  rz_analysis_function_delete_vars_by_kind(fcn,
  RZ_ANALYSIS_VAR_KIND_BPV); calls). This may lead to some
  false-positive detected variables. Whether this really is a practical
  issue is yet to be seen. At least there are no meaningful tests that
  are broken by this.
* Applying variables from dwarf needed some fixes for determining the
  correct stack locations of variables in order to write meaningful
  tests. The handling is still not entirely correct for all
  possibilities of dwarf info, but at least the changed/added test cases
  are right and serve as a reference for future changes.
* Projects version 11 is introduced.
* afvb commands have been removed, afvs now handles all stack vars.
2023-01-02 11:36:21 +08:00
Dean
59b38e6efa
Add /*<type>*/ comments everywhere (#2986)
Adds /*<type>*/ comments and a linter check from rz-bindgen to enforce
their existence and consistency

Also includes the following fixes made when adding the annotations:
* removed unused intern_table arguments in pyc_dis.c, pyc_dis.h, asm_pyc.c
* removed unused classes argument from place_nodes in agraph.c
* removed unused recurse and recurse_bb functions in canalysis.c
* removed unused vars field from RzPrint struct
* removed unused RzAnalysisType* structs from rz_analysis.h
* removed unused list field from RzEgg struct
* fixed bug in bp_plugin.c where duplication-checking logic iterates over the wrong list
* removed unused q_regs field from RzDebug struct
* removed unused backtrace field from RzDebugPlugin struct
* removed unused classes_list field from RzBinNXOObj struct
* removed unused methods_list and classes_list fields from RzBinZimgObj struct
2022-09-11 13:04:53 +08:00
Anton Kochkov
20792311b4 Move rz_core_file_*() API to the cfile.c 2022-09-08 07:41:18 +08:00
Florian Märkl
1d88af3c56
Refactor and replace .dm* calls with pure C (#2847)
This fixes the following minor issues:
* Errors like "Cannot create flag (...) because there is already (...)
  flag" during debug startup
* Unnecessary seeks during .dm* causing io reads and e.g. delays of up
  to 5s on x86 macOS during debug startup
* Flags are now created in the "maps" flagspace, rather than globally,
  making them easier to clean up later
* Flags now have the same size as the maps and not +1
2022-07-28 13:40:44 +02:00
billow
aaf08869cf
Expose APIs (#2710)
- `rz_core_bin_get_compile_time`
- `rz_core_analysis_coverage_count`
- `rz_core_analysis_code_count`
- `rz_core_analysis_calls_count`
- `rz_core_sym_name_init`
- `rz_core_sym_name_fini`
- `rz_core_sym_is_export`
- `rz_core_bin_whole_strings`
- `rz_core_analysis_coverage_count`
- `rz_core_analysis_code_count`
- `rz_core_analysis_calls_count`
- `rz_core_analysis_esil_deinit`
- `rz_core_analysis_esil_init_mem_del`
- `rz_core_types_as_c`
- `rz_type_list_c_nl_handler`
- `rz_core_file_open_load`
- `rz_core_config_in_space`

-  rename `SymName` -> `RzSymName`
2022-06-21 10:49:42 +08:00
billow
c282976716
Expose rz_core_debug_*(), rz_core_analysis_*(), rz_core_io_*() APIs 2022-05-24 19:35:29 +08:00
Anton Kochkov
f2a1e5e090 Remove unused macros 2022-05-19 12:17:53 +08:00
Anton Kochkov
2220612426 Improve error messages on file reopening 2022-05-19 12:17:53 +08:00
Anton Kochkov
4afa3ffe83 Fix CID 393024 - memory leak 2022-05-19 12:17:53 +08:00
Anton Kochkov
a013a17f5a Use API instead of o command call with rz_core_cmdf() 2022-05-15 23:52:15 +08:00
Paul I
9db3ed0670 Rename RzAnalysisXRefType enum members 2022-05-12 09:24:12 +02:00
Giovanni
f87025d1e8
Remove cb_printf() from RzBin (#2446)
* Remove `cb_printf()` from RzBin
* Removed `bin.rawstr` from `rz-bin`
* Dropping `izzz` since does the same as `izz`
* Fix PE one section executables
* Fix behaviour of BFLT, LE, and SMD bin plugins
2022-03-26 20:30:55 +08:00
Florian Märkl
88ec019514
Store back-references to core files in RzIOMap (#2408)
This allows tracing an io map back to the RzCoreFile and thus also its
bin file and other info. This is used in rz-ghidra to determine which
memory ranges can be considered readonly to enable constant propagation.
2022-03-14 10:09:14 +01:00
Riccardo Schirone
2c02457109
Convert o commands to rzshell (#2281) 2022-02-07 18:23:31 +01:00
Riccardo Schirone
6c2ee73fe7
Convert 'ob' commands to rzshell (#2201)
* Use API instead of 'oba' command in rizin.c
* Fix tests and use API instead of 'ob' commands
2022-01-14 08:45:16 +00:00
Florian Märkl
76eb7bf182 Refactor debug checks and flags from registers
* Added rz_core_is_debug() to check for debug mode instead of hard-coding "cfg.debug"
* rz_core_reg_default() uses the above to get the currently relevant RzReg
* rz_core_debug_regs2flags() -> rz_core_reg_update_flags() uses the above
  to update the flags.
2021-12-21 13:14:08 +01:00
Giovanni
bd7854d297
Fix multidex and open_many loading using proper base address (#2104) 2021-12-18 09:54:42 +01:00
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
3d6b7f0235
Cleanup dbl command handler; Remove rz_bp_list (#2012) 2021-11-25 22:33:24 +05:30
Dhruv Maroo
34d345d884 Format according to clang-format-13 2021-11-25 15:44:28 +08:00
Florian Märkl
289536cc04
Unscramble Register Printing and Flags Logic (#1920)
* Added rz_analysis_get_address_bits() instead of arch-specific hacks in core
* flags are only set for address-sized registers
* dr/ar show registers of any size by default, but hiding registers that are entirely
  covered by others
2021-11-17 11:44:14 +01:00
Riccardo Schirone
3925811c59 RzShell: convert ou command 2021-11-09 09:46:04 +01:00
Florian Märkl
8de3870d5c
Rewrite most of the bFLT bin plugin (#1863) 2021-10-23 17:45:54 +00:00