Commit graph

26455 commits

Author SHA1 Message Date
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
Anton Kochkov
d5bac21207
Fix memleaks in librz/type/* (#1364)
* Fix memleaks in librz/type/*
* Use `goto fail` pattern

Co-authored-by: Paul I <pelijah@users.noreply.github.com>
2021-07-28 16:17:53 +08:00
GustavoLCR
56841703e1
Various debug fixes (#1359)
* Fix regression showing threads `rip` for `dpt` on Windows
* Improve `dpt` output
* Consider flags too when printing thread address
* Improve `RzCoreBind->getNameDelta` to use realname if `flags->realnames` is true
* Fix negative offsets
* Fix flagspace selection side-effects after calling `rz_core_bin_apply()` APIs
* Fix wrong register profile after attaching to a process with `dpa`
* Fix wrong base address when opening a process memory
* Fix wrong register profile after opening a process memory
* Implement `rz_debug_reg_profile_sync()`
* Fix diff tests
2021-07-27 15:03:08 +08:00
billow
61e317aab5
Fix FLIRT v5 file format decompression (#1352) 2021-07-27 14:43:12 +08: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
Paul I
919e8a0cd0 Use sdb_foreach_list_filter() in sdb_load_callables() 2021-07-26 21:12:25 +02:00
Heersin
6fb0b7e245
Reorganize ESIL code (#1360)
* Move esil code to new subdirectory
* Move esil in `canalysis.c` to `core/cil.c`
2021-07-26 18:42:33 +08:00
Paul I
11ed8f68d5
Replace SDB with HtPU in rz_bin_filter_name() (#1357) 2021-07-26 09:34:28 +02:00
Anton Kochkov
71bf245a9b
Fix some leaks in types and analysis code (#1351)
* Fix CID 316621, 316019

* Fix CID 352457

* Fix CID 352516

* Fix CID 352449

* Fix CID 352465

* Fix CID 352479

* Fix CID 352483

* Fix CID 352503

* Fix CID 352513

* Fix CID 352563
2021-07-24 20:31:16 +08:00
GustavoLCR
69611e103b
Remove RzDebug->user and use RzDebug->plugin_data instead (#1355)
* Remove doubled `rz_reg_set_profile_string()` call in `rz_debug_use()`
* Remove `RzDebug->user` and use `RzDebug->plugin_data` instead
* Fix crashes when switching between `native` and `windbg` debug plugins
2021-07-24 11:13:53 +02:00
Alexis Ehret
632b0f2b99 Add better warning messages librz/bin/format/elf/* 2021-07-23 15:11:34 +02:00
Anton Kochkov
f15ba97a76
Remove unused rz-pipe test (#1349) 2021-07-22 20:56:27 +02: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
Pulak Malhotra
ebd7b7b06b
Port dc commands to newshell (#1345) 2021-07-22 17:08:14 +08:00
Giovanni
f21be3b6d3
Fix various leaks (#1348)
* Fixed Leak in types code
* Fixed leak on `rz_cons_grep` in newshell
* Avoid flushing when cons is not used.
* Fixed memory leak in `rz_analysis_free`
* file_hashes is not used.
* `rz_bin_file_set_hashes` needs to be freed
* More timeout
2021-07-22 14:50:50 +08:00
Giovanni
615d04ca1f
[rz-diff] Optimize diffing functions. (#1346)
* Remove useless error message and optimize compare.
* Avoid useless calls when data is already known.
* Fixed test
* Calculate div based on min/max
* Ignore RzAnalysisFunction that are not FCN or SYM
* Simplified gdiff
2021-07-22 12:40:39 +08:00
Anton Kochkov
816d57111b
Do not offer ESIL if not actually support it (#1343) 2021-07-21 18:08:52 +08:00
GustavoLCR
0588a49312
Don't use commands to get necessary heap globals on for Windows heap parsing 2021-07-21 11:09:34 +08:00
Paul I
93be07803a
Fix some typedb related memleaks (#1339) 2021-07-21 01:51:54 +08:00
Anton Kochkov
570160ce2d Fix CID 352512 2021-07-20 21:39:31 +08:00
Anton Kochkov
3ee671f6ea Fix CID 352487 2021-07-20 21:39:31 +08:00
Anton Kochkov
ee45888639 Fix CID 352470 2021-07-20 21:39:31 +08:00
Anton Kochkov
bab1d8d8ce Fix CID 352460 2021-07-20 21:39:31 +08:00
Anton Kochkov
d6db764014 Fix CID 352458 2021-07-20 21:39:31 +08:00
Anton Kochkov
ef6634fae3 Fix CID 352454 2021-07-20 21:39:31 +08:00
Anton Kochkov
89222a753c Fix CID 352446 2021-07-20 21:39:31 +08:00
Anton Kochkov
de7099a3a0 Fix CID 317607 2021-07-20 21:39:31 +08:00
Anton Kochkov
17f10fe106 Add test for type print less than block 2021-07-20 20:50:07 +08:00
Anton Kochkov
495a24705e Add test fo pointers inside structures 2021-07-20 20:49:19 +08:00
Anton Kochkov
7ce60258bc Use RZ_LOG_INFO for debug messages 2021-07-20 17:36:25 +08:00
Anton Kochkov
ef9a93a57c Remove unused RzLang Vala tests 2021-07-20 01:49:21 +08: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
8a09fdcbd5
Convert pt to newshell ##newshell (#1319)
* Convert `pt` to newshell
* Remove the old shell code and handlers of `pt`
2021-07-19 22:55:54 +08:00
GustavoLCR
885c45a699
Refactor Windows debug code (#1318)
* Fix some handle leaks
* Fix some memory leaks
* Re-use handles if possible
* Avoid allocations inside loops in `w32_desc_list()`
* Use debug plugin functions instead of reimplementing logic in io_debug.c and io_w32dbg.c to maintain state consistency
* Remove unneeded code
* Rename some functions
2021-07-19 18:22:54 +08:00
Basstorm
27e699b255
Fix types and vars match in match_metrics (#1329) 2021-07-19 11:27:56 +02:00
GustavoLCR
21ae65b5f1
Move multiple pdb symbol server support from cmd handler to api (#1325) 2021-07-19 11:27:28 +02:00
Alexis Ehret
2e711a6946 Fix invalid value for type '_Bool' section->is_valid 2021-07-19 12:20:42 +08:00
Alexis Ehret
f43cc01b99 Refactor symbols and imports loading ##refactor 2021-07-19 12:20:42 +08:00
GustavoLCR
1b7f28044c
Fix #1317 - Fix dL handler printing a warning (#1321)
Return immediately after setting the debug handler instead of continuing to the printing code
2021-07-19 12:17:18 +08:00
Pulak Malhotra
254c5119e3
Refactor Tcache to use RzHeapBin (#1279)
* Add a new function to get tcache content

* Refactor to use the new tcache function

* Expose API for cutter

* Bug fix

* Fix mem leaks

* Use goto to reduce code

* Add API for writing a chunk

* Bug fix

* Minor changes

* Fixes #1088

* Fix tcache not working properly for 32 bit binaries

* Remove 32 bit members from malloc state struct, just use 64 bit members in all cases

* Added documentation

* Should fix clang cl warning

* Check if tcache was read successfully

* Remove debug string

Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
Co-authored-by: yossizap <yossizap@gmail.com>
2021-07-16 20:52:45 +08:00
GustavoLCR
ea11eb8222
Fix dmias creating new maps (#1315) 2021-07-16 19:59:47 +08:00
GustavoLCR
a241968730
Fix crash in rz_interpret_handler() (#1316) 2021-07-16 10:33:09 +02:00
Anton Kochkov
e2ffc1d8a2
Remove unnecessary dupfd test (#1312) 2021-07-16 12:55:29 +08:00
Alexis Ehret
432e4ba85f Fix warning when searching a section in a binary without any 2021-07-15 20:22:41 +02:00
Alexis Ehret
ae1cbe0d35 Fix memory corruption in create_section_from_phdr 2021-07-15 20:22:41 +02: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
Giovanni
05ae79cc5e
Load all dalvik files in an APK (#1303)
* Initial work on multidex
* Find the correct map location and map extra libs correctly based on sizes.
2021-07-15 12:23:08 +08:00
GustavoLCR
1ab628d83d
Fix some clang-cl warnings (#1298) 2021-07-15 12:15:17 +08:00
Anton Kochkov
703eab5405
Remove ESIL CFG and DFG (#1304) 2021-07-14 21:49:55 +02:00
Aswin C
258462bb8d
Import: Add new CPUs for PPC and honor asm.cpu for asm.arch=ppc.gnu (#1278)
* Add possible asm.ppc.cpu values
* Honor asm.cpu for asm.arch=ppc.gnu ##disasm (#18543)

Co-authored-by: pancake <pancake@nopcode.org>
2021-07-13 16:55:24 +08:00