![]() |
Baseer 0.2.0
Baseer is an advanced binary analysis tool designed to provide deep insights into any file.
|
Core definitions, structs, and function prototypes for the debugger. More...
Go to the source code of this file.
Classes | |
struct | Cmd |
Represents a parsed user command. More... | |
struct | sym_list |
Represents a symbol entry (function name and address). More... | |
struct | bp_list |
A linked list of breakpoints. More... | |
struct | bp |
Represents a single breakpoint. More... | |
struct | func_list |
Represents a debugger command and its associated function. More... | |
struct | pos_name |
Maps a register/flag name to its position. More... | |
struct | context |
Holds debugger state and process information. More... |
Macros | |
#define | ERROR(str) |
Print an error message in red. | |
#define | INFO(str) |
Print an info message in blue. |
Typedefs | |
typedef struct bp_list | bp_list |
Forward declaration of debugger structs. | |
typedef struct bp | bp |
typedef struct sym_list | sym_list |
typedef struct context | context |
typedef struct func_list | func_list |
typedef struct pos_name | pos_name |
typedef bool(* | func_callback_t) (context *ctx, void *args) |
Callback type for command handler functions. |
Functions | |
void | destroy_bp_sym (context *ctx) |
Free all breakpoints and symbols in the context. | |
void | destroy_all (context *ctx) |
Destroy all context-related memory. | |
void | print_helpCMD () |
Print available debugger commands. | |
void | init_values (bparser *target, context *ctx) |
Initialize context values from target binary. | |
bool | b_debugger (bparser *target, void *arg) |
Launch and manage the debugger main loop. | |
void | dis_ctx (context *ctx) |
Display current registers, flags, disassembly, and stack. | |
void | handle_bpoint (context *ctx) |
Handle breakpoint hit logic. | |
bool | setBP (context *ctx, void *args) |
Set a breakpoint at an address or symbol. | |
bool | delBP (context *ctx, void *args) |
Delete a breakpoint by ID. | |
bool | step_over (context *ctx, void *args) |
Step over a function call. | |
bool | listBP (context *ctx, void *args) |
List all breakpoints. | |
bool | examin_mem (context *ctx, void *args) |
Examine memory at a given address. | |
bool | set_mem_reg (context *ctx, void *args) |
Modify memory or registers. | |
void | restore_all_BP (context *ctx, int opt) |
Restore all breakpoints (enable or disable). | |
bool | handle_action (context *ctx, void *args) |
Execute a user command. | |
void | parse_cmd (context *ctx) |
Parse and dispatch a command from the user. |
Core definitions, structs, and function prototypes for the debugger.
This header defines the main data structures (context, breakpoints, symbols), and function prototypes used to implement the debugger.
#define ERROR | ( | str | ) |
Print an error message in red.
#define INFO | ( | str | ) |
Print an info message in blue.
typedef bool(* func_callback_t) (context *ctx, void *args) |
Callback type for command handler functions.
ctx | The current debugger context. |
args | Additional arguments for the command. |
bool b_debugger | ( | bparser * | target, |
void * | arg ) |
Launch and manage the debugger main loop.
Launch and manage the debugger main loop.
Forks a child process, loads the binary via memfd_create, and sets an initial breakpoint. Then enters the main command loop for user interaction.
target | Pointer to binary parser structure with ELF data. |
arg | Arguments structure containing argc and argv. |
bool delBP | ( | context * | ctx, |
void * | args ) |
Delete a breakpoint by ID.
ctx | Pointer to debugger context. |
args | Breakpoint ID. |
void destroy_all | ( | context * | ctx | ) |
Destroy all context-related memory.
Destroy all context-related memory.
ctx | Pointer to debugger context. |
void destroy_bp_sym | ( | context * | ctx | ) |
Free all breakpoints and symbols in the context.
Free all breakpoints and symbols in the context.
ctx | Pointer to debugger context. |
void dis_ctx | ( | context * | ctx | ) |
Display current registers, flags, disassembly, and stack.
Display current registers, flags, disassembly, and stack.
ctx | Pointer to debugger context. |
bool examin_mem | ( | context * | ctx, |
void * | args ) |
Examine memory at a given address.
Examine memory at a given address.
Command format: x ADDR SIZE
ctx | Pointer to debugger context. |
args | Address and size arguments. |
bool handle_action | ( | context * | ctx, |
void * | args ) |
Execute a user command.
Execute a user command.
ctx | Pointer to debugger context. |
args | Optional arguments passed with the command. |
void handle_bpoint | ( | context * | ctx | ) |
Handle breakpoint hit logic.
Handle breakpoint hit logic.
ctx | Pointer to debugger context. |
Initialize context values from target binary.
Initialize context values from target binary.
Reads ELF headers and symbol tables to populate context values.
target | Pointer to binary parser structure with ELF data. |
ctx | Pointer to debugger context to initialize. |
bool listBP | ( | context * | ctx, |
void * | args ) |
List all breakpoints.
List all breakpoints.
ctx | Pointer to debugger context. |
args | Unused. |
void parse_cmd | ( | context * | ctx | ) |
Parse and dispatch a command from the user.
Parse and dispatch a command from the user.
Reads a command from stdin, splits it into operator and arguments, and executes the corresponding debugger function.
ctx | Pointer to debugger context structure containing process state. |
void print_helpCMD | ( | ) |
Print available debugger commands.
Print available debugger commands.
void restore_all_BP | ( | context * | ctx, |
int | opt ) |
Restore all breakpoints (enable or disable).
Restore all breakpoints (enable or disable).
ctx | Pointer to debugger context. |
opt | If 1, restore original instruction. If 0, reset breakpoint trap. |
bool set_mem_reg | ( | context * | ctx, |
void * | args ) |
Modify memory or registers.
Modify memory or registers.
Command format: $REG=VALUE or ADDR=VALUE
ctx | Pointer to debugger context. |
args | Command argument string. |
bool setBP | ( | context * | ctx, |
void * | args ) |
Set a breakpoint at an address or symbol.
Set a breakpoint at an address or symbol.
ctx | Pointer to debugger context. |
args | Address or symbol name. |
bool step_over | ( | context * | ctx, |
void * | args ) |
Step over a function call.
Step over a function call.
Inserts a temporary breakpoint after the call instruction and continues execution.
ctx | Pointer to debugger context. |
args | Unused. |