Commit graph

421 commits

Author SHA1 Message Date
Khairul Azhar Kasmiran
573aee5633
$: Revert code changes in #4293 (#4323) 2024-03-03 13:40:17 +08:00
Khairul Azhar Kasmiran
299454138b
$: Add rzshell façade (#4314) 2024-03-02 17:11:02 +08:00
Khairul Azhar Kasmiran
7cf3a9bbdb
$?: Update to rzshell syntax (#4309) 2024-03-01 00:03:47 +08:00
Peiwei Hu
58808b2756
Remove the deprecated API rz_bin_get_info (#4119) 2024-02-26 00:14:03 +08:00
Khairul Azhar Kasmiran
b61b951232
$: Fix $alias=$<backtick>cmd<backtick> (#4293) 2024-02-24 13:55:14 +08:00
Rot127
a6c7864198
Fix mismatch 'rz_cons_break_push' and 'rz_cons_break_pop' calls. (#4289)
If a function calls 'rz_cons_break_push()' but never calls 'rz_cons_break_pop()' before return,
the stack count of 'RzConsContext->break_stack' contains too many elements (each time one too much).

This in turn will lead to not resetting 'RzConsContext->breaked' flag.
Because the flag is only set to false, if 'rz_stack_is_empty(context->break_stack) == true'
(in 'rz_cons_context_break_push()').

This wasn't a problem so far, because 'RzConsContext->breaked' is simply never set to true
(exceptions are some timeout cases as far as I can see).
Also these cases when 'rz_cons_break_pop()' was forgetten to be called, were edge error cases.
So not often hit.

But if Rizin is usd by Cutter 'RzConsContext->breaked' is set to 'true',
if an `AnalysisTask` interrupt is handled (in 'AnalysisTask::interrupt()').
This interrupt is triggered for example, when the introduction dialog is closed
and the main Cutter window opens (after the optional 'aaa').

Now, if the binary file was analysed with 'aaa', and a lot of error cases were hit,
those error cases sometimes never called 'rz_cons_break_pop()' before returning from their function.
Although, of course, they should have to the `RzConsContext->break_stack` is in a proper state.

This means, when the main Cutter window opens binary files which trigger many error edge cases,
the `RzConsContext->break_stack` is not empty
(because of the not executed 'rz_cons_break_pop()').

This also means, that the last thing done, was setting 'RzConsContext->breaked = true'
(by 'AnalysisTask::interrupt()').

If Cutter wants to show some disassembly, it calls 'rz_core_print_disasm()' which checks
'RzConsContext == false' via 'rz_cons_is_breaked()'. This condition is never true, because
the flag was not reset to `false` because the stack was never empty.
So it returns before anything was disassembled.

Hence Cutter gets no disassembly text.

Fixes https://github.com/rizinorg/cutter/issues/2552
Fixes https://github.com/rizinorg/cutter/issues/3275
2024-02-23 23:50:11 +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
f98ab29273
Convert p2 and p8 commands to rzshell (#4250) 2024-02-17 21:59:20 +08:00
billow
8026d94b56
rzil: add analysis and evaluation integration test (#4241)
* Try to refactor rz_core_analysis_bytes_il
* Add the RzIterator
* Refactor rz_core_analysis_op_bytes with RzIterator
* Refactor rz_core_analysis_bytes with RzIterator
* Add test_analysis_il
* Fix AnalysisBytesContext_next
* Fix heap-buffer-overflow and UBSan
* Fix use-after-free
2024-02-16 21:10:44 +08:00
Anton Kochkov
28de08e320
core/cmd_print: remove unused oldshell code (#4243) 2024-02-16 13:44:49 +08:00
Anton Kochkov
ceefb5e114
Convert pf commands to rzshell (#3467) 2024-02-16 10:30:59 +08:00
Giovanni
ac63502f76
Fix aeA when rz_analysis_op fails. (#4240) 2024-02-15 20:55:52 +08:00
Giovanni
2886608d59
Rewrite how rz_cons_pipe_open/close behave to remove globals (#4223) 2024-02-14 09:05:17 +08:00
Anton Kochkov
3da3184284
core/disasm: remove static variables (#4214) 2024-02-12 23:34:24 +08:00
Anton Kochkov
25fd417a28
Add user pointer to RzListComparator (#4204) 2024-02-11 13:28:33 +08:00
Anton Kochkov
8e4faa3906
Remove scr.rainbow option (#4199)
* Remove scr.rainbow option
* Update librz/util/float/float.c
2024-02-10 12:02:50 +08:00
Anton Kochkov
24ecc7eb72
core/tui: use API instead of command calls (#4197) 2024-02-09 21:37:08 +08:00
Huzaifa
e82033d92c
Convert from rz_str_new to rz_str_dup (#4178) 2024-02-07 00:07:53 +08:00
Ultimator14
5e03fe8588
Fix usage hint for help on $variables (#4188) 2024-02-06 18:09:46 +08:00
Rot127
5afc51f0e2
Replace current regex engine with PCRE2 (#4185)
* Replace OpenBSD regex library with PCRE2.

PCRE2 has way better performance than the OpenBSD
library (something around 20 times faster).

The following flags are enabled for every pattern:

- PCRE2_UTF
- PCRE2_MATCH_INVALID_UTF
- PCRE2_NO_UTF_CHECK

All the others are optional.

Changes made:

- Adds PCRE2 as subproject.
- Changes the API away from POSIX to PCRE2.
- Edits many regex patterns because:
 - ' ' is skipped in patterns, if the EXTENDED flag is set for matching. '\s' must be set now.
 - '.' doesn't match newlines by default.
- Changes the API so matches and their groups are bundled into PVectors.
- Moves the regex component to rz_util.

* Fix cross build - add copy of PCRE2 dependecy

Meson currently doesn't support subprojects to be native and non-native at the same time.
See: https://github.com/mesonbuild/meson/issues/10947
Unfortunately, sdb depends on rz_util which in turn depends on PCRE2.
Excluding PCRE2 from the native build makes linking of rz_util not possible anymore.
Adding it, will make Meson complain that the dependencies cannot be mixed.

Hence, we compile a copy of PCRE2 for the native build if required.
2024-02-05 12:51:16 +08:00
Khairul Azhar Kasmiran
df6b6a9f17
In group help, indicate detailed help is provided (#4184) 2024-02-03 22:55:24 +08:00
billow
481777220f
Analysis: sort function by address while printing (#4179)
* analysis: sort function by addr when print (afl, aflm, afl=)
2024-02-02 23:50:34 +08:00
Anton Kochkov
e7d3c258fb
Remove some more of sdb_fmt() calls (#4140) 2024-01-30 22:36:39 +08:00
Giovanni
320182d2ea
Fix wrong help message in visual mode (#4162) 2024-01-26 23:24:51 +08:00
Anton Kochkov
564fb5595b
Remove some of sdb_fmt() calls in RzCore (#4134) 2024-01-21 23:06:36 +08:00
Anton Kochkov
e2581bc8da
Remove sdb_fmt() calls in RzBin (#4133) 2024-01-21 23:06:17 +08:00
billow
88f6c787cb
Add cache for source line (#4129)
* Fix DWARF source line file path

* Add cache for source line

* Fix cache for source line

* Optimization

* revert formatting
2024-01-20 15:48:19 +08:00
Rot127
9ea0b64372
Enable CFG generation. (#4037)
* Add CFG generation function.
* Document rz_analysis_op()
* Set type annotation to NONNULL
* Add command to generate CFG.
* Add note about not following calls.
* Add tests and simplify check.
2024-01-15 07:51:35 +08:00
billow
ce88bbed49
RzIL TriCore Support (#3478)
* RzIL TriCore Support
2024-01-13 13:59:55 +08:00
Anton Kochkov
1b69ae6ec7
Do not throw warning on empty RzIL (#4097) 2024-01-13 12:09:50 +08:00
Marco Grassi
cc696d3c70
search: resolve some signed int issues in json output (#4094) 2024-01-11 19:17:17 +08:00
Peiwei Hu
3a2148e1cd
Refactor sections in RzBinPlugin from list to pvector (#4089) 2024-01-11 12:19:22 +08:00
sohail
c40d246e5c small typo in the output of aai command 2024-01-10 09:11:13 +01:00
wargio
e092b3a14e Fix prc command. 2024-01-07 22:40:25 +08:00
Anton Kochkov
1f4befd24e Remove global RzLine instance 2024-01-07 22:40:25 +08:00
wargio
f7589feb05 introduce user pointer in comparator to remove globals in table.c 2024-01-06 23:30:07 +08:00
wargio
a9131cede7 Remove hidden static in rz_str_pad 2024-01-06 23:30:07 +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
b43fe31877
Transition of strings in RzBinPlugin (from RzList to RzPVector) (#4052) 2024-01-04 22:23:31 +08:00
Anton Kochkov
2b0de30f7f Remove static and global varibles in cmd_analysis.c 2024-01-04 01:14:57 +08:00
Peiwei Hu
8fba56bdb7
Use internal API instead of command (#4053) 2024-01-03 19:16:06 +08:00
byteninjaa0
8c275bfa8b
Make it clear the "details" of command are available (#3890) 2023-12-26 07:41:23 +08:00
Peiwei Hu
3b7f2730f2
Remove the deprecated API rz_core_handle_backwards_disasm (#4041)
* Remove the deprecated API rz_core_handle_backwards_disasm
* Also, mitigate the dependency on core->block
2023-12-26 06:45:07 +08:00
Peiwei Hu
4f7e0e177f
Remove the dependency of core->block in pi/pI (#4023) 2023-12-20 19:46:44 +08:00
Rot127
9b227eb3c1
Make AArch64/ARM analysis and asm plugins Capstone v6 compatible. (#4011)
This commit refactors the AArch64 and partially the ARM
plugin to make it Capstone v6 compatible.
Due to the big API changes in Capstone v6 several changes
had to be made.

Because we need to be compatible to Capstone v4 and v5
many include guards are added as well.

Overview of changes done:

**ARM**

- Instruction alias were introduced. This leads to different
decoding and analysis paths taken for certain instructions.
Some alias have their IL code generated like the real
instruction now (no special handling needed anymore).
This change is responsible for many changes you'll encounter.

- The operand details of each instruction are now always the
one of the real instruction. Also for alias.
For example, if "MOV <Wd>, #<imm>" is an alias for `ORR <Wd>, WZR, #<imm>`,
the details by CS hold all three operands of "ORR".
Before, they held only the two of "MOV".

- Several bugs in variable and argument generation
were fixed. Especially the default variable width
for ARM Thumb was changed to 32bit instead of the 16bit.

**AArch64/ARM64**

The changes listed above for ARM, also apply to AArch64.

Additionally:

- Capstone v6 changed the name ARM64 now everywhere to AArch64.
To be compatible with Capstone v4/v5 AArch64 names must be wrapped
into macros which resolve the name, depending on the CS version used.

- Capstone v6 is now more consistent with
register real and alias names.
From now on we use the register alias by default.

**List squashed commit messages:**

[AArch64 CS v6 BEGIN] Change subproject config to use cs-auto-sync-aarch64 branch

Replace ARM64 with version sensitive macros.

Exclude alias if CS version >= 6

Update access to writeback member

Exclude instr alias from inclusion

Update memory operand printing to json.

Enable real instr. detail only for AArch64

Set correct arch name in meson.build for CS

Fix U/SBFM instructions and their alias.

Mark parameters with RZ_OUt/BORROW

Optimize register extension to skip some, if the width already matches.

Adapt width and lsb of U/SBFM alias instructions (ImmR and ImmS are from U/SBFM).

Fix tests correct semantic buy bad syntax

Pass alias MOV instructions to mov()

Handle CSET and CSETM alias

Fix lsl, lsr and asr by handling them as alias.

Fix mov alias.

Handle TST alias

Fix CNEG, CINV alias

Fix bfi and bfxil alias.

Fix sign extensions.

Fix compare instructions.

Fix NEG, NGC, NGCS, NEGS, MVN

Fix CINC

Fix multiply instructions.

Fix ROR

Run clang-format

Handle CMP for ESIL

Handle new position of memory disponents of post index operands.

Fix post-index operations.

Add missing writeback checks for Post and preindex

Handle UBFM and SBFM alias

Handl BFM alias

Handle CMP, CSET and CINC alias

Update meson file of for cs-aarch64 branch

Fix asm tests. Use reg alias now.

Fix condition confusion and incorrect operand usage.

Fix plf test.

Run clang-format

Use register alias in tests

Add support for fp and lr reg alias assembly.

Use reg alias in test

Rename cond tranlate functions r2 -> rz

Fix condition check which assume 0 == invalid.

Fix issues intruduced by rebase

Set CS commit to current next branch.

Rename ARM64 -> AArch64

Add missing source file to meson.build

Remove DisassemblerExtension.c file for CS v5

Update to newest capstone next branch

Bump up CS version

REVERT ME: Get Capstone v4/v5 via git clone until new tars are released.

Wrap setting of CS_DETAIL_REAL into CS version check

Add maybe-unitialized to Capstone C args.

Fix CS pre v6 build by adding guards.

Use reg alias now printed by default by CS.

Bump CS version to most recent next.

Fix build errors due to stircter alias handling in ARM.

Fix RzIL tests introduced by alias introduction to ARM.

Fix ESIL bugs introduced with ARM alias introduction.

- stackptr hasn't been set for POP and PUSH

Add support again for Thumb1 pop/push

Handle PUSHW and POPW alias

Update test case

Add more POP and PUSH alias and enrich detail for other versions of them.

Fix incorrect mem access width guesses for ARM thumb.

Set POP return info if it writes to PC

Fix tests about default var size and POP mem write direction.

Bump CS version to newest next.

Fix incorrect tests.

- TriCore: Functions were in ro section.
- Default arg width in ARM thumb is 32bit.

Revert check for a set stackptr.

stackptr is used in different ways:
1. Safes the offset from the stack frame base.
2. Is interpreted as somthing else for x86 and I cannot find out what, in a reasonably time.

Hence we cannot use it here consistently.

Remove check for non existing ARM_GRP_RET in CSv5

Fix incorrect stack offsets of variables.

'push <reg-list>' instructions for which the second register was the FP,
reset the stackptr variable to 0. This led to wrong bp offsets in the variable names.
In this case it was +0xc.

Bump CS version.

Add copy of meta-programming macros for capstone-sys build.

Update capstone-next.wrap

Use bracket-less met-programming macro to fix Windows build warnings.

Update wrap files for Capstone with branch names

Add new meta-programming macro

Add workaround for MSVC pre-processor bug.
2023-12-20 01:00:31 +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
c0abdb87e8
Enable generation of inter-procedual control flow graph. (#4001) 2023-12-14 22:34:43 +08:00
Huzaifa Naseer
4edd1680c1
Modify pr command to not stop printing at null byte (#3987) 2023-12-03 19:49:17 +08:00
Anton Kochkov
c21e19ee0c
X-Refs to global variable - avgx (#4017) 2023-12-03 13:53:11 +08:00
Anton Kochkov
efb31b9191
Print value of global variable - avgp (#4014) 2023-12-02 21:49:46 +08:00