Skip to content

Commit

Permalink
Merge branch 'code-rewriter-x86' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Nov 18, 2023
2 parents cf3839a + 747a25c commit 76844a6
Show file tree
Hide file tree
Showing 52 changed files with 44,524 additions and 170 deletions.
63 changes: 63 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions docs/dev/arch/arm64/code_relocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,12 @@ If the instruction is Prefetch `PRFM`, it is discarded if it can't be re-encoded
The `TBZ` instruction in ARM architectures tests a specified bit in a register and performs a conditional branch if the bit is zero. If the tested bit is not zero, the next sequential instruction is executed.

**Behaviour**:
The `TBZ` instruction is rewritten based on the distance to the new branch target. It is transformed into one of the following patterns:
- TBZ
- TBZ <skip> + B
- TBZ <skip> + ADRP + BR
- TBZ <skip> + ADRP + ADD + BR
- TBZ <skip> + MOV to Register + Branch Register
The `TBZ` instruction is rewritten based on the distance to the new branch target. It is transformed into one of the following patterns:
- TBZ
- TBZ <skip> + B
- TBZ <skip> + ADRP + BR
- TBZ <skip> + ADRP + ADD + BR
- TBZ <skip> + MOV to Register + Branch Register

Here, `<skip>` is used to indicate a conditional skip over a set of instructions if the tested bit is not zero. The specific transformation depends on the offset between the current position and the new branch target.

Expand Down
4 changes: 3 additions & 1 deletion docs/dev/arch/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ Lists currently supported architectures.
| Feature | x86 & x64 | ARM64 |
| ------------------------------------------------------------------------------- | --------- | ----- |
| [Basic Function Hooking](#basic-function-hooking) |||
| [Code Relocation](#code-relocation) | WIP ||
| [Code Relocation](#code-relocation) | * ||
| [Hook Stacking](#hook-stacking) |||
| [Calling Convention Wrapper Generation](#calling-convention-wrapper-generation) |||
| [Optimal Wrapper Generation](#optimal-wrapper-generation) |||

* x86 should work in all cases, but x64 isn't tested against all 5000+ instructions.

## Basic Function Hooking

!!! info "The ability to hook/detour existing application functions."
Expand Down
4 changes: 3 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ even in bare metal or embedded environments.
| Feature | x86 & x64 | ARM64 |
| ------------------------------------------------------------------------------------------------- | --------- | ----- |
| [Basic Function Hooking](./dev/arch/overview.md#basic-function-hooking) |||
| [Code Relocation](./dev/arch/overview.md#code-relocation) | WIP ||
| [Code Relocation](./dev/arch/overview.md#code-relocation) | * ||
| [Hook Stacking](./dev/arch/overview.md#hook-stacking) |||
| [Calling Convention Wrapper Generation](./dev/arch/overview.md#calling-convention-wrapper-generation) |||
| [Optimal Wrapper Generation](./dev/arch/overview.md#optimal-wrapper-generation) |||

Bootstrapping a new architecture is not a difficult job!!
Please see [Architecture Support Overview](./dev/arch/overview.md) for porting guidance.

* x86 should work in all cases, but x64 isn't tested against all 5000+ instructions.

## Feature Support

- Supports common OSes/platforms.
Expand Down
Loading

0 comments on commit 76844a6

Please sign in to comment.