My Project
Loading...
Searching...
No Matches
md.h
Go to the documentation of this file.
1#ifndef X86_MATANEL_DEBUG_H
2#define X86_MATANEL_DEBUG_H
3
4/*++
5
6Module Name:
7
8 md.h
9
10Purpose:
11
12 This module contains the header files & prototypes required for the debugger of MatanelOS. This may include non-debugger functions as well, but those that are useful for runtime.
13
14Author:
15
16 slep (Matanel) 2025.
17
18Revision History:
19
20--*/
21
22#include "me.h"
23
25void*
27 void
28)
29
30/*++
31
32 Routine description : Retrieves the address of the RIP slot in the current stack frame, used for debugging a stack smashing where the return address get overwritten
33
34 Arguments:
35
36 None.
37
38 Return Values:
39
40 Address of RIP Slot in stack.
41
42--*/
43
44{
45 void** frame = (void**)__builtin_frame_address(0); // returns RBP
46 return (void*)(frame + 1); // address of saved RIP slot
47}
48
50void
52 void
53)
54
55// Description: Emit a debug break instruction. (INT3)
56
57{
58 __asm__ volatile("int3");
59}
60
61MTSTATUS MdSetHardwareBreakpoint(DebugCallback CallbackFunction, void* BreakpointAddress, DEBUG_ACCESS_MODE AccessMode, DEBUG_LENGTH Length);
63MTSTATUS MdClearHardwareBreakpointByAddress(void* BreakpointAddress);
65#endif
#define FORCEINLINE
Definition annotations.h:22
FORCEINLINE void MdDebugBreak(void)
Definition md.h:51
int find_available_debug_reg(void)
MTSTATUS MdClearHardwareBreakpointByIndex(int index)
MTSTATUS MdClearHardwareBreakpointByAddress(void *BreakpointAddress)
FORCEINLINE void * MdGetFunctionRipAddress(void)
Definition md.h:26
MTSTATUS MdSetHardwareBreakpoint(DebugCallback CallbackFunction, void *BreakpointAddress, DEBUG_ACCESS_MODE AccessMode, DEBUG_LENGTH Length)
enum _DEBUG_ACCESS_MODE DEBUG_ACCESS_MODE
void(* DebugCallback)(void *)
Definition me.h:139
enum _DEBUG_LENGTH DEBUG_LENGTH
uint32_t Length
Definition mh.h:6
int32_t MTSTATUS
Definition mtstatus.h:12