forked from cheat-engine/cheat-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebuggerInterface.pas
131 lines (103 loc) · 4.36 KB
/
DebuggerInterface.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
unit DebuggerInterface;
{
This unit contains the base class description for the debugger interface.
The other debugger interfaces are inherited from this
}
{$mode delphi}
interface
uses
Classes, SysUtils{$ifdef windows},windows{$endif},NewKernelHandler, debuggertypedefinitions{$ifdef darwin}, macport{$endif};
type
TDebuggerCapabilities=(dbcHardwareBreakpoint, dbcSoftwareBreakpoint, dbcExceptionBreakpoint, dbcBreakOnEntry);
TDebuggerCapabilitiesSet=set of TDebuggerCapabilities;
TDebuggerInterface=class
protected
fmaxInstructionBreakpointCount: integer;
fmaxWatchpointBreakpointCount: integer;
fmaxSharedBreakpointCount: integer;
fDebuggerCapabilities: TDebuggerCapabilitiesSet;
fErrorString: string;
noBreakList: array of thandle;
public
name: string;
function WaitForDebugEvent(var lpDebugEvent: TDebugEvent; dwMilliseconds: DWORD): BOOL; virtual; abstract;
function ContinueDebugEvent(dwProcessId: DWORD; dwThreadId: DWORD; dwContinueStatus: DWORD): BOOL; virtual; abstract;
function SetThreadContext(hThread: THandle; const lpContext: TContext; isFrozenThread: Boolean=false): BOOL; virtual;
function SetThreadContextArm(hThread: THandle; const lpContext: TARMCONTEXT; isFrozenThread: Boolean=false): BOOL; virtual;
function GetThreadContext(hThread: THandle; var lpContext: TContext; isFrozenThread: Boolean=false): BOOL; virtual;
function GetThreadContextArm(hThread: THandle; var lpContext: TARMCONTEXT; isFrozenThread: Boolean=false): BOOL; virtual;
function DebugActiveProcess(dwProcessId: DWORD): BOOL; virtual; abstract;
function DebugActiveProcessStop(dwProcessID: DWORD): BOOL; virtual;
function GetLastBranchRecords(lbr: pointer): integer; virtual;
function inNoBreakList(threadid: integer): boolean; virtual;
procedure AddToNoBreakList(threadid: integer); virtual;
procedure RemoveFromNoBreakList(threadid: integer); virtual;
function canReportExactDebugRegisterTrigger: boolean; virtual;
property DebuggerCapabilities: TDebuggerCapabilitiesSet read fDebuggerCapabilities;
property errorstring: string read ferrorstring;
property maxInstructionBreakpointCount: integer read fmaxInstructionBreakpointCount;
property maxWatchpointBreakpointCount: integer read fmaxWatchpointBreakpointCount;
property maxSharedBreakpointCount: integer read fmaxSharedBreakpointCount;
end;
implementation
function TDebuggerInterface. SetThreadContext(hThread: THandle; const lpContext: TContext; isFrozenThread: Boolean=false): BOOL;
begin
result:=false;
end;
function TDebuggerInterface.SetThreadContextArm(hThread: THandle; const lpContext: TARMCONTEXT; isFrozenThread: Boolean=false): BOOL;
begin
result:=false;
end;
function TDebuggerInterface.GetThreadContextArm(hThread: THandle; var lpContext: TARMCONTEXT; isFrozenThread: Boolean=false): BOOL;
begin
result:=false;
end;
function TDebuggerInterface.GetThreadContext(hThread: THandle; var lpContext: TContext; isFrozenThread: Boolean=false): BOOL;
begin
result:=false;
end;
function TDebuggerInterface.DebugActiveProcessStop(dwProcessID: DWORD): BOOL;
begin
//don't complain if not implemented
result:=true;
end;
function TDebuggerInterface.GetLastBranchRecords(lbr: pointer): integer;
begin
//if implemented fill in the lbr pointer with the lbr records (array of qwords) and return the count (max 16)
result:=-1;
end;
function TDebuggerInterface.inNoBreakList(threadid: integer): boolean;
var i: integer;
begin
result:=false;
for i:=0 to length(nobreaklist)-1 do
if nobreaklist[i]=threadid then
begin
result:=true;
exit;
end;
end;
procedure TDebuggerInterface.AddToNoBreakList(threadid: integer);
begin
if inNoBreaklist(threadid) then exit;
setlength(nobreaklist, length(nobreaklist)+1);
nobreaklist[length(nobreaklist)-1]:=threadid;
end;
procedure TDebuggerInterface.RemoveFromNoBreakList(threadid: integer);
var i,j: integer;
begin
for i:=0 to length(noBreakList)-1 do
begin
if nobreaklist[i]=threadid then
begin
for j:=i to length(nobreaklist)-2 do
nobreaklist[j]:=nobreaklist[j+1];
setlength(nobreaklist, length(nobreaklist)-1);
end;
end;
end;
function TDebuggerInterface.canReportExactDebugRegisterTrigger: boolean;
begin
result:=true;
end;
end.