Commit graph

158 commits

Author SHA1 Message Date
Anton Kochkov
e7d3c258fb
Remove some more of sdb_fmt() calls (#4140) 2024-01-30 22:36:39 +08:00
Anton Kochkov
1f4befd24e Remove global RzLine instance 2024-01-07 22:40:25 +08:00
Giovanni
8fba9b4189
Force usage of RzList methods instead of direct access of the fields (#4036) 2023-12-18 21:05:57 +08:00
Rot127
86db4734cb
Change len parameter type to size_t in RzIO API (#4012)
* Add doc string to `rz_io_write_at()`
* Change length parameter type of IO read/write functions to `size_t`.
2023-12-03 19:28:16 +08:00
Riccardo Schirone
3b903caa96
librz: add some initial documentation (#3782) 2023-10-13 13:46:19 +08:00
Anton Kochkov
f29171ceb1
Remove rzk and gprobe IO plugins (#3654) 2023-07-12 00:21:43 +08:00
Siddharth Mishra
9ab709bc34
Improve cmd_help.yaml and fix random number generator (#3452)
* Improve cmd_help.yaml and fix a small bug
* Add support for 64bit random numbers
* Make a distinction between 32- and 64-bit PRNG
* Add documentation for new functions
* Change the RBTree test to use 32-bit random numbers
2023-04-07 20:22:01 +08:00
Riccardo Schirone
72e92fe81a io: fix iowhence2buf function
The function should convert the IO-specific whence enum to the
RzBuffer-specific whence enum, however it was doing the opposite.
Fortunately, it doesn't really affect anything because those two enums
have the same values.
2023-04-05 17:15:52 +08:00
Riccardo Schirone
65e4e9ebd1
Fix few sscanf issues reported by @yeggor (#3428) 2023-03-22 18:36:54 +08:00
Giovanni
c7dfbbcdcd
Fix ar naming and io read/write api (#3419) 2023-03-10 06:21:39 +00:00
Anton Kochkov
afa9aebc39 io_ptrace debugger fixes 2023-03-01 11:12:03 +08:00
Riccardo Schirone
c9d6ad9ee6
io: return error when reading/writing to unmapped memory (#3323)
* core: 'wow' command was replaced with 'wb'

* io: on_map_skyline returns false when nothing was done

Before this patch on_map_skyline returned true even when the callback
was not called on any part of the skyline. In other words,
reading/writing to an unmapped memory returned true.

This commit changes the behaviour to return false in those cases.

* analysis/esil: mem_read/mem_write were alway returning true

* use o malloc instead of oC

* librz: deal with seek errors
2023-02-11 11:36:27 +01:00
Florian Märkl
77a334a2af
Refactor srec reading to not use sscanf (#3321)
Parsing with sscanf turned out to cause an extreme slowdown. As only hex
values are being read, this can be done with RzUtil-provided
functionality. Relevant test cases exist in test/db/io/srec.
2023-01-25 16:42:46 +01:00
rizan21
cc18d675e6 Use clang-format 15 instead of 14 2023-01-25 22:02:26 +08:00
Riccardo Schirone
e933003b5b
librz: do not duplicate plugins (#3313)
* librz: do not duplicate plugins

Plugins structures are statically defined at the file scope and not
dynamically allocated. Plugins should not allocate them either as
RzLibPlugin keeps a reference to them anyway.
2023-01-23 12:51:09 +00:00
Riccardo Schirone
c4767cf1ac
Fix plugin removal and clean code (#3277)
* cmd: Fix summary of few "L" sub-commands
* util: start decluttering plugins handling

- Add Doxygen docs
- Remove unused API functions and make others internal only
- Use RzLibType enum for plugin type instead of int

* util: move dlopen/dlsym/dlclose to rz_sys
* util: make rz_lib_open/close return bool
* util: simplify rz_lib_add_handler and rz_lib_open*
* libs: implement rz_*_plugin_del to remove a plugin
* core: remove commands from RzCmd when removing plugins
* librz: call plugins 'fini' method when removing a plugin
* core/cmd: do not fail if the hashmap removal fails

When removing a group command, the inner command might have the same
name, thus it would result in trying to remove the same name twice.
Ignore it, as it is fine.

* librz: make RzCrypto plugins handling like the others
* librz/crypto: add rz_crypto_reset and use it
* librz: allocate the plugin structures before adding them
2023-01-16 13:32:46 +01:00
wargio
bc5eb09782 Removed rzbochs 2022-12-04 16:53:58 +01:00
wargio
18a4cb5582 Rewrite of bochs debugger and io plugin 2022-12-04 16:53:58 +01:00
Florian Märkl
68a06e69d2
Rewrite reading in io_mach (#3101)
The previous reading code was slow (performed too many
vm_region_recurse_64 calls) and broken, for example at boundaries of
memory maps. Details can be found in the code comments.
2022-10-17 09:15:59 +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
wargio
0eef58115b Rewritten (partially) rz_run_parseline 2022-08-22 13:50:39 +02:00
Florian Märkl
4e5857cacf
Meson refactor: collect modules in dict and centralize config (#2945)
Duplicated code for pkg-config and cmake configuration is avoided by
letting every rizin module register itself in a global dictionary
called "modules" which is then iterated in one place to perform any
shared logic, inspired by how qemu handles multiple targets in its meson
build system.

This is an almost pure refactor, so the resulting .pc/.cmake files
should be identical with the following exceptions:
- rz_reg.pc does not have plugindir anymore as rz_reg has no plugins.
- Some other modules have their dependencies in .pc files altered to be
  consistent with cmake.
2022-08-20 19:59:27 +02:00
Anton Kochkov
f8def2f0f5
Remove reduntant license entries and READMEs (#2875)
* Remove reduntant license entries and READMEs
* Do not use `make`
2022-08-08 08:04:26 +08:00
billow
df602944d7
rz_print_hexdump() refactoring (#2841)
* Move `rz_print_hexdump()` -> `rz_print_hexdump_str()`
2022-07-28 00:24:25 +08:00
GustavoLCR
d3446789c7 Windows: Various fixes
* Fix some XP incompatibility
* Use wide version of APIs
* Remove unused/unnecessary function pointers
2022-07-24 21:00:51 +08:00
Riccardo Schirone
a689f0a86e librz: refactor a bit how plugins are built
Rely on RZ_ARRAY_SIZE to add librz plugins instead of NULL terminators.
2022-07-20 22:04:02 +02:00
Riccardo Schirone
8939fdbd7d
Use add_global_arguments instead of passing cflags/ldflags all around (#2812)
See also 66a0e22293/docs/TESTING_WITH_SANITIZERS.md (clang)
2022-07-17 21:33:51 +08:00
Giovanni
2e0d490d2f
Add RzBaseFindOpt for custom thread status callback (#2768) 2022-07-06 11:34:00 +02:00
Riccardo Schirone
fdd7c6200c
Fix compilation on Termux and Haiku (#2671)
* build: fix compilation on Termux by using meson checks
* build: fix compilation on termux, which is recognized as linux

meson identifies termux as "linux" system, however pthread_sigmask is
not available there. Since pthread-fixes.c just defines
uv__pthread_sigmask we include it also in regular linux builds, because
the function is then used automatically instead of pthread_sigmask only
when __ANDROID__ is defined.

* subprojects/rzwinkd: define cc in meson.build before use
2022-06-07 23:44:41 +02:00
Riccardo Schirone
72c29e83d5 RzUtil: fix rz_path_prefix in case of portable build
Before this patch the function was using RZ_PREFIX even when IS_PORTABLE
was set, making the function not working well because RZ_PREFIX might
not exist in the system where the portable build is used (the path was
passed to realpath(), which requires an existing path).

This patch fixes the problem by searching for the BINDIR without using
realpath() on the RZ_PREFIX. Moreover, it avoid retrieving the same
prefix every time by saving it in a global variable.

* Add rz_constructor.h to allow defining constructors/destructors on
  multiple compilers.
2022-05-31 23:32:52 +08:00
Riccardo Schirone
ce6ac3e467 meson: use major/minor only in the lib soversion 2022-05-10 21:04:43 +02:00
GustavoLCR
7b8238d11d WinKD: Fix kernel address range not being mapped
* Fix winkd `__lseek(RZ_IO_SEEK_END)` to return `UT64_MAX`
2022-05-10 10:22:49 +08:00
GustavoLCR
31ba84fe69 WinKD: Fix reading from kernel virtual address 2022-05-10 10:22:49 +08:00
GustavoLCR
55fc4dfac1
Implement new rz_buf_fwd_scan() API (#2530) 2022-04-17 15:08:08 +02:00
Riccardo Schirone
abaf6c4323
IO: do not call plugin->system if cmd is empty (#2505)
* IO: do not call plugin->system if cmd is empty
* RzCore: use API instead of command handler
2022-04-06 10:36:06 +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
GustavoLCR
dd81b6629a
Implement getting a backtrace from a Windows Kernel Dump for x64 (#2387)
* PE: Add header to mappings
* PE: Add temp defs for unknown `UNWIND_CODE_OPS`
* Core Bind: Add `RzCoreBinApplyInfo` binding
* DMP/WinKD: Always add kernel modules to mod list
* Implement Windows x64 SEH backtracing
* Fix `ompb` not prioritizing maps
* Optimize `rz_io_map_priorize()`
* DMP: Implement backtrace for x64
2022-03-15 10:45:02 +01: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
wargio
7672170c00 Rename rz_str_hash to rz_str_djb2_hash 2022-03-06 16:29:03 +01:00
GustavoLCR
555c011165 WinKD/DMP: Reorder function parameters for consistency with RzIO 2022-03-03 21:52:41 +08:00
GustavoLCR
7c6810e2ee DMP: Read context from KPCRB if target is on a cpu
* Get `KiProcessorBlock` address from PDB
* Read KPCRBs and check if selected thread is running in one of the
  processors
* Read context from it if so
2022-03-03 21:52:41 +08:00
GustavoLCR
54af096151 WinKD/DMP: Add WindCtx->target_thread
* Make `WindCtx->target` a structure instead of a pointer
2022-03-03 21:52:41 +08:00
GustavoLCR
908ee644d1 DMP: Add dmp RzIO plugin 2022-03-03 21:52:41 +08:00
GustavoLCR
ed66d75d0a Make WindCtx structure more generic to support both kd and dmp 2022-03-03 21:52:41 +08:00
Giovanni
bfec86a12e
Add option to install sigdb systemwise and custom user location for additional signatures (#2328) 2022-02-28 14:32:38 +01:00
Riccardo Schirone
2a118ee413
Convert 'we' commands to rzshell (#2325) 2022-02-16 09:31:50 +00:00
Riccardo Schirone
52825a7a02
Convert 'wc' commands to rzshell (#2297)
Remove `wcr` because dup of `wc-*`.
2022-02-10 15:48:57 +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
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