forked from libdebug/libdebug
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request libdebug#101 from libdebug/dev
Provola
- Loading branch information
Showing
240 changed files
with
10,303 additions
and
976 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
24 changes: 24 additions & 0 deletions
24
libdebug/architectures/aarch64/aarch64_breakpoint_validator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# | ||
# This file is part of libdebug Python library (https://github.com/libdebug/libdebug). | ||
# Copyright (c) 2024 Roberto Alessandro Bertolini. All rights reserved. | ||
# Licensed under the MIT license. See LICENSE file in the project root for details. | ||
# | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from libdebug.data.breakpoint import Breakpoint | ||
|
||
|
||
def validate_breakpoint_aarch64(bp: Breakpoint) -> None: | ||
"""Validate a hardware breakpoint for the AARCH64 architecture.""" | ||
if bp.condition not in ["r", "w", "rw", "x"]: | ||
raise ValueError("Invalid condition for watchpoints. Supported conditions are 'r', 'w', 'rw', 'x'.") | ||
|
||
if not (1 <= bp.length <= 8): | ||
raise ValueError("Invalid length for watchpoints. Supported lengths are between 1 and 8.") | ||
|
||
if bp.condition != "x" and bp.address & 0x7: | ||
raise ValueError("Watchpoint address must be aligned to 8 bytes on aarch64. This is a kernel limitation.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# | ||
# This file is part of libdebug Python library (https://github.com/libdebug/libdebug). | ||
# Copyright (c) 2024 Roberto Alessandro Bertolini. All rights reserved. | ||
# Licensed under the MIT license. See LICENSE file in the project root for details. | ||
# | ||
|
||
from __future__ import annotations | ||
|
||
from libdebug.architectures.call_utilities_manager import CallUtilitiesManager | ||
|
||
|
||
class Aarch64CallUtilities(CallUtilitiesManager): | ||
"""Class that provides call utilities for the AArch64 architecture.""" | ||
|
||
def is_call(self: Aarch64CallUtilities, opcode_window: bytes) -> bool: | ||
"""Check if the current instruction is a call instruction.""" | ||
# Check for BL instruction | ||
if (opcode_window[3] & 0xFC) == 0x94: | ||
return True | ||
|
||
# Check for BLR instruction | ||
if opcode_window[3] == 0xD6 and (opcode_window[2] & 0x3F) == 0x3F: | ||
return True | ||
|
||
return False | ||
|
||
def compute_call_skip(self: Aarch64CallUtilities, opcode_window: bytes) -> int: | ||
"""Compute the instruction size of the current call instruction.""" | ||
# Check for BL instruction | ||
if self.is_call(opcode_window): | ||
return 4 | ||
|
||
return 0 | ||
|
||
def get_call_and_skip_amount(self: Aarch64CallUtilities, opcode_window: bytes) -> tuple[bool, int]: | ||
"""Check if the current instruction is a call instruction and compute the instruction size.""" | ||
skip = self.compute_call_skip(opcode_window) | ||
return skip != 0, skip |
Oops, something went wrong.