Commit graph

40 commits

Author SHA1 Message Date
Anton Kochkov
4a037c2f2a
Convert dk commands to the rzshell (#3078) 2022-10-11 18:02:52 +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
Giovanni
c89b12a046
Removed plenty of eprintfs in rz_core (#2950) 2022-08-29 00:32:17 +08:00
Anton Kochkov
106a1049dc
Make all visual functions private (RZ_IPI) (#2985) 2022-08-27 22:13:12 +08:00
Riccardo Schirone
9ba89d8116 core/cmd: rewrite rz_cmd_macro API 2022-08-26 07:53:43 +08:00
Riccardo Schirone
544a907443 core/cmd: remove some unnecessary fields for macro handling 2022-08-26 07:53:43 +08:00
Riccardo Schirone
74df176f0f core/cmd: remove brk concept in macros because unused 2022-08-26 07:53:43 +08:00
Riccardo Schirone
02a0b7a1ad core/cmd: just store RzCore reference instead of void *data 2022-08-26 07:53:43 +08:00
Anton Kochkov
574607ee62 Convert some command calls to the API 2022-05-25 20:32:50 +08:00
Anton Kochkov
2220612426 Improve error messages on file reopening 2022-05-19 12:17:53 +08:00
Anton Kochkov
2188b4564d
Various Coverity fixes (#2615)
* Fix CID 392733 - memory leak

* Fix CID 392732 - memory leak

* Fix CID 392730 - memory leak

* Fix CID 392729 - memory leak

* Fix `rz_analysis_diff_free()` API function

* Fix CID 392685 - memory leak

* Fix CID 392012 - use after free

* Fix CID 391968 - uninitialized pointer read

* Fix CID 391966 - memory leak

* Fix CID 391964 - uninitialized pointer read

* Fix CID 390013 - memory leak

* Fix CID 389939 - memory leak

* Fix CID 379249 - memory leak

* Fix CID 378881 - uninitialized scalar variable

* Fix CID 378973 - uninitialized scalar variable

* Fix CID 378850 - uninitialized scalar variable

* Fix CID 371079 - memory leak

* Fix CID 367478 - memory leak

* Fix CID 366821 - memory leak

* Fix CID 366736 - memory leak

* Fix CID 361684 - uninitialized scalar value

* Fix CID 352581 - memory leak

* Fix CID 352557 - memory leak

* Fix CID 348937 - memory leak

* Fix CID 322229 - memory leak

* Fix CID 320122 - memory leak

* Fix CID 317611 - memory leak
2022-05-15 23:15:28 +08:00
Giovanni
0dcdc842a2
SDB usage cleanup within rz_bin 2022-05-10 10:27:33 +08:00
Riccardo Schirone
27e0d7ae82
RzBin: improve handling of addresses in ELF (#2591)
* RzBin/ELF: avoid the creation of useless flags at 0

Use UT64_MAX as an error value for addresses like symbols, imports,
sections, etc., and do not create flags for those because they are not
meaningful. This is useful for imports that do not have an address in
the virtual/file space and for non-alloc sections (e.g. .comment).
2022-05-10 10:17:35 +08:00
Riccardo Schirone
86d20b2d16
RzShell: Remove possibility to switch to oldshell (#2420)
Due to some commands/tests still using the legacy "..." commands, we
can't fully remove oldshell code yet, but with this patch we just hide
it from the end users. Rzshell is now the default and only shell and
rzshell autocompletion is the default and only autocompletion engine.
2022-03-17 14:49:34 +01:00
Riccardo Schirone
78bbf5ba80
RzCore: remove as many #include .c as possible in cmd.c (#2378) 2022-03-17 10:30:57 +08:00
GustavoLCR
170ab3eb3b
Remove windows.h include from rz_types.h (#2410)
* Create `rz_windows.h`
* Move `RzThread` structure definitions to internal header
* Create and use `rz_th_get_user()` API to avoid exposing `RzThread` layout in external header
* Make `rz_th_self()` an IPI
* Use `_wmkdir()` in `rz_sys_mkdir()` on Windows
* Remove unused `winkd_break_read` function
* Remove `RzIORap` definition from `rz_io.h`
* Remove include of `Windows.h` from `rz_types.h`
* Use `rz_windows.h` when necessary
* Remove `RzCoreRtrHost` definition from `rz_core.h`
* Remove `rz_socket.h` include from `rz_core.h`
2022-03-16 13:54:41 +01:00
Riccardo Schirone
d20b026ce2
Finish conversion of w commands to rzshell (#2412)
* Convert 'wz' to rzshell
* Remove 'wt' commands in favour of > operator
* Convert 'ww' command to rzshell
* Convert 'wm' command to rzshell
* Convert 'wd' command to rzshell
* Convert 'wu' command to rzshell
* Convert 'wo' commands to rzshell
* Fix 'w' tests
2022-03-16 11:20:29 +00:00
Peiwei Hu
babb7bf342
Remove command 0 (alias for s 0x...) 2022-03-09 22:10:13 +08:00
Riccardo Schirone
f745478fde
Improve suggestions when wrong command/args is used (#2365) 2022-03-02 10:39:33 +01:00
Riccardo Schirone
494f15d594
Fix error message of ?* command when arg is passed (#2364) 2022-02-28 16:21:16 +00:00
Riccardo Schirone
9df2994127
RzCmd: add support for dynamically generated details sections (#2361)
So far all the help sections were statically generated from the YAML
files, however sometimes you may want to list things in the help
messages that depend on what is loaded in Rizin (e.g. plugins, etc.).
This patch adds support for a details_cb that provides a dynamically
created RzCmdDescDetail array.
2022-02-25 09:25:15 +00:00
Riccardo Schirone
2c02457109
Convert o commands to rzshell (#2281) 2022-02-07 18:23:31 +01:00
Anton Kochkov
2f638cad1e Convert f commands to rzshell
* Changed behavior of `f` to only add flag if there is none
* Changed behavior of `f+` to add flag in any case
* Moved listing subcommands from `f` to `fl`
* Moved listing subcommands from `f.` to `f.l`
* Added subcommand `f.l*` to list all local flags in all functions
* Listing flags at the current offset became `fl.`
* Moved `f=` to `fl=`
* Old `fl` (flag length) now became `fL`
* Removed original `fe` commands
* Old `f?` (check if flag exists) now became `fe`
* Removed `fV` commands
* Removed `fn` commands in favor of `fl` and `asm.flags.real=true`
* Removed `fS` commands (`fSo` and `fSn`)
* `fo` became `fortune` and moved from "flags" to "shell" category
* Removed oldshell handlers of the `z` commands
2022-02-03 21:46:42 +08:00
Anton Kochkov
538ffe3739 Convert fs commands to rzshell 2022-01-15 09:11:40 +08:00
Florian Märkl
9b60670013 Prepare various RzReg accesses for splitting
Common accesses for both debug and analysis must not use
debug->reg or analysis->reg, but go through rz_core_reg_default().
2021-12-21 13:14:08 +01: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
Dhruv Maroo
a255ff57a2
Fix some more Coverity issues (#2044)
* C352467: Free the heap allocated string after appending to `RzStrBuf`

* Remove unused variable `nofail`

* C352453: Free `fieldstr` after appending to `format`

* C350836: Free `name` before returning inside the loop

* C349252, C349231: Free `ta` when breaking halfway through the loop

* C349248: Free `pj` before breaking from switch statement

* C366622: Check result of `strtok` (`fcnname_aux`) for `NULL`

* Free `RzList` before returning from macro `SYNC_READ`

  * Fixes Coverity issues 366625, 366624, 366623, 366621 and probably
    a few others as well

* C366620: Check `arg` for `NULL` before dereferncing in `strchr`

* C366618: Cleanup `parse_lis` and use `rz_str_*` API instead of C `str` API

* Fix `SYNC_` macros in `cmd_regs.c` to no return prematurely

* C365952: Check `x` for `NULL` before dereferencing

* C365936: Use a wider integer type for the bitshift

* C365808: Fix double free of `real_type`

* C365805: Remove redundant `NULL` check for `path`
2021-12-13 23:09:46 +08:00
Florian Märkl
3c2e4bf63a
Rewrite ar and dr with newshell (#2006)
* Show group-level details of commands

Details can be defined at either a group command or its subcommand of
the same name. If define on group-level it will also be shown in the
group help without needing ??.

* Fix > $ redirection for errored command and leak

* Rewrite ar and dr commands with newshell

Breaking changes:
ar* => arf, ar- => arf-, ar. => ar*
ar, => art, ar? => arq
ar0 => ara0, arb => arab, ars => araS
arC => arpC
arn => arR
art => arT
arf => arF
Removed: drm, aer
2021-12-06 19:02:43 +01:00
Dhruv Maroo
00c43df95d
Coverity scan fixes (mostly memory leaks) (#2037)
* Add `rz_goto_if_fail` macro
* Useful when one needs cleaning up before returning
* Coverity 364174: Free `alloc` before returning
* Coverity 364179: Return NULL before allocating ret to avoid memleak
* Coverity 364177: Return NULL before allocating ret to avoid memleak
* Coverity 364167: Free `ret` before returning prematurely
* Coverity 364165: Return NULL before allocating ret to avoid memleak
* Coverity 356612: Free list `dbg_maps_addrs` in the `err` goto
* Coverity 354023: Free `type` when cleaning up
* Cov. 352571, 352465: Goto `urnexit` so that `real_*` variables are freed
* C352564: Allocat `fmt` in every case, and free it before returning
* C352449, C352557, C352449: Don't leak `real_*` variables
2021-11-29 11:54:12 +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
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
Giovanni
87311c3759
Basefind (#1966)
Co-authored-by: gnole <olegbouchin@gmail.com>
2021-11-15 22:33:38 +01:00
Anton Kochkov
d461580b8f
Remove Newlisp and ES6 (Babel) support for RzLang (#1942) 2021-11-05 22:53:45 +08:00
Anton Kochkov
a7ebf7b10f
Remove oldshell version of s commands (#1895) 2021-10-27 20:59:12 +08:00
Riccardo Schirone
0a5b00edd2 Fix all db/cmd tests 2021-10-27 09:31:50 +02:00
Dhruv Maroo
48656fdb80
Port shell commands to new shell (#1875)
* Create new category for shell commands in new shell
* Port `env` and `exit`
* Port `ls`, `rm`, `sleep`, `uniq`, `uname` to new shell
* Rename `cname`s for shell commands
 * Port `cp`, `cp.` and `echo`
* Port `cd` to newshell
* Add `~` (paths relative to home) handling in `rz_sys_chdir`
* Add `RZ_NONNULL` for `rz_sys_chdir`
* Port `cat`
* Port `mv` and `mkdir` to new shell; Remove old handlers
* Port `pwd`
* Port `sort`
* Remove `cp.` command
* Add `RZ_NONNULL` for arguments of `rz_syscmd_*` functions
* Port `cls` and `clear`
* cd to home when no argument provided
* Fix `mkdir`
* Add alias handling for `cat`
* Fix `mv` command
2021-10-26 12:04:24 +08:00
Anton Kochkov
8fab461328
Port g (egg/shellcode) commands to the rzshell (#1744) 2021-10-25 22:15:38 +08:00
Giovanni
7653f69fd9
Fix types from config (#1871) 2021-10-22 09:33:45 +08:00
Anton Kochkov
036f1490d0 Move command handlers to librz/core/cmd 2021-10-18 18:00:17 +08:00
Renamed from librz/core/cmd.c (Browse further)