2011-07-04 19:52:53 +00:00
|
|
|
unit DebuggerInterfaceAPIWrapper;
|
|
|
|
|
{
|
|
|
|
|
This unit hold the DebuggerInterface currently used, and overrides the default windows debug api's so they make use of the DebuggerInterface's version
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{$mode delphi}
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
2022-06-01 13:10:34 +02:00
|
|
|
Classes, SysUtils, {$ifdef windows}windows,{$endif} debuggerinterface, newkernelhandler{$ifdef darwin}, macport, macportdefines{$endif};
|
2011-07-04 19:52:53 +00:00
|
|
|
|
|
|
|
|
function WaitForDebugEvent(var lpDebugEvent: TDebugEvent; dwMilliseconds: DWORD): BOOL;
|
|
|
|
|
function ContinueDebugEvent(dwProcessId: DWORD; dwThreadId: DWORD; dwContinueStatus: DWORD): BOOL;
|
2022-04-19 00:08:51 +02:00
|
|
|
function SetThreadContext(hThread: THandle; const lpContext: TContext; isFrozenThread: Boolean=false): BOOL; overload;
|
|
|
|
|
function SetThreadContext(hThread: THandle; const lpContext: TARMCONTEXT; isFrozenThread: Boolean=false): BOOL; overload;
|
|
|
|
|
function SetThreadContext(hThread: THandle; const lpContext: TARM64CONTEXT; isFrozenThread: Boolean=false): BOOL; overload;
|
2023-10-20 17:32:15 +02:00
|
|
|
function SetThreadContext(hThread: THandle; lpContext: pointer; isFrozenThread: Boolean=false): BOOL; overload;
|
2022-04-19 00:08:51 +02:00
|
|
|
function GetThreadContext(hThread: THandle; var lpContext: TContext; isFrozenThread: Boolean=false): BOOL; overload;
|
|
|
|
|
function GetThreadContext(hThread: THandle; var lpContext: TARMCONTEXT; isFrozenThread: Boolean=false): BOOL; overload;
|
|
|
|
|
function GetThreadContext(hThread: THandle; var lpContext: TARM64CONTEXT; isFrozenThread: Boolean=false): BOOL; overload;
|
2023-10-20 17:32:15 +02:00
|
|
|
function GetThreadContext(hThread: THandle; lpContext: pointer; isFrozenThread: Boolean=false): BOOL; overload;
|
2013-08-10 21:40:44 +00:00
|
|
|
function GetThreadContextArm(hThread: THandle; var lpContext: TARMCONTEXT; isFrozenThread: Boolean=false): BOOL;
|
2022-06-01 13:10:34 +02:00
|
|
|
function SetThreadContextArm(hThread: THandle; const lpContext: TARMCONTEXT; isFrozenThread: Boolean=false): BOOL;
|
2022-04-19 00:08:51 +02:00
|
|
|
function GetThreadContextArm64(hThread: THandle; var lpContext: TARM64CONTEXT; isFrozenThread: Boolean=false): BOOL;
|
2022-06-01 13:10:34 +02:00
|
|
|
function SetThreadContextArm64(hThread: THandle; const lpContext: TARM64CONTEXT; isFrozenThread: Boolean=false): BOOL;
|
2013-08-10 21:40:44 +00:00
|
|
|
|
2011-07-04 19:52:53 +00:00
|
|
|
function DebugActiveProcess(dwProcessId: DWORD): WINBOOL;
|
|
|
|
|
function DebugActiveProcessStop(dwProcessID: DWORD): WINBOOL;
|
|
|
|
|
|
|
|
|
|
var CurrentDebuggerInterface: TDebuggerInterface;
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
uses CEDebugger;
|
|
|
|
|
|
|
|
|
|
function WaitForDebugEvent(var lpDebugEvent: TDebugEvent; dwMilliseconds: DWORD): BOOL;
|
|
|
|
|
begin
|
|
|
|
|
if CurrentDebuggerInterface<>nil then
|
|
|
|
|
result:=CurrentDebuggerInterface.WaitForDebugEvent(lpDebugEvent, dwMilliseconds)
|
|
|
|
|
else
|
|
|
|
|
result:=false;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function ContinueDebugEvent(dwProcessId: DWORD; dwThreadId: DWORD; dwContinueStatus: DWORD): BOOL;
|
|
|
|
|
begin
|
|
|
|
|
if CurrentDebuggerInterface<>nil then
|
|
|
|
|
result:=CurrentDebuggerInterface.ContinueDebugEvent(dwProcessID, dwThreadID, dwContinueStatus)
|
|
|
|
|
else
|
|
|
|
|
result:=false;
|
|
|
|
|
end;
|
|
|
|
|
|
2022-04-19 00:08:51 +02:00
|
|
|
|
|
|
|
|
|
2011-07-04 19:52:53 +00:00
|
|
|
function SetThreadContext(hThread: THandle; const lpContext: TContext; isFrozenThread: Boolean=false): BOOL;
|
|
|
|
|
begin
|
|
|
|
|
if CurrentDebuggerInterface<>nil then
|
|
|
|
|
result:=CurrentDebuggerInterface.SetThreadContext(hThread, lpContext, isFrozenThread)
|
2013-08-12 00:32:01 +00:00
|
|
|
else
|
|
|
|
|
result:=NewKernelHandler.SetThreadContext(hThread, lpcontext);
|
|
|
|
|
end;
|
|
|
|
|
|
2023-10-20 17:32:15 +02:00
|
|
|
function SetThreadContext(hThread: THandle; lpContext: pointer; isFrozenThread: Boolean=false): BOOL;
|
|
|
|
|
begin
|
|
|
|
|
if CurrentDebuggerInterface<>nil then
|
|
|
|
|
result:=CurrentDebuggerInterface.SetThreadContext(hThread, lpContext, isFrozenThread)
|
|
|
|
|
else
|
|
|
|
|
result:=NewKernelHandler.SetThreadContext(hThread, PContext(lpcontext)^);
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
2022-04-19 00:08:51 +02:00
|
|
|
function SetThreadContext(hThread: THandle; const lpContext: TARMCONTEXT; isFrozenThread: Boolean=false): BOOL;
|
|
|
|
|
begin
|
|
|
|
|
result:=SetThreadContextArm(hThread, lpContext, isFrozenThread);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function SetThreadContext(hThread: THandle; const lpContext: TARM64CONTEXT; isFrozenThread: Boolean=false): BOOL;
|
|
|
|
|
begin
|
|
|
|
|
result:=SetThreadContextArm64(hThread, lpContext, isFrozenThread);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function GetThreadContextArm(hThread: THandle; var lpContext: TARMCONTEXT; isFrozenThread: Boolean=false): BOOL;
|
2013-08-12 00:32:01 +00:00
|
|
|
begin
|
|
|
|
|
if CurrentDebuggerInterface<>nil then
|
2022-04-19 00:08:51 +02:00
|
|
|
result:=CurrentDebuggerInterface.GetThreadContextArm(hThread, lpContext, isFrozenThread)
|
|
|
|
|
else
|
|
|
|
|
result:=false;
|
|
|
|
|
end;
|
|
|
|
|
|
2022-06-01 13:10:34 +02:00
|
|
|
function SetThreadContextArm(hThread: THandle; const lpContext: TARMCONTEXT; isFrozenThread: Boolean=false): BOOL;
|
|
|
|
|
begin
|
|
|
|
|
if CurrentDebuggerInterface<>nil then
|
|
|
|
|
result:=CurrentDebuggerInterface.SetThreadContextArm(hThread, lpContext, isFrozenThread)
|
|
|
|
|
else
|
|
|
|
|
result:=false; //not yet implemented. ceserver uses it's own setbreakpoint, for now , and I do not support arm32 for darwin(macos)
|
|
|
|
|
end;
|
|
|
|
|
|
2022-04-19 00:08:51 +02:00
|
|
|
function GetThreadContextArm64(hThread: THandle; var lpContext: TARM64CONTEXT; isFrozenThread: Boolean=false): BOOL;
|
|
|
|
|
begin
|
|
|
|
|
if CurrentDebuggerInterface<>nil then
|
|
|
|
|
result:=CurrentDebuggerInterface.GetThreadContextArm64(hThread, lpContext, isFrozenThread)
|
2011-07-04 19:52:53 +00:00
|
|
|
else
|
2022-06-01 13:10:34 +02:00
|
|
|
begin
|
|
|
|
|
{$ifdef darwin}
|
|
|
|
|
result:=macport.GetThreadContextArm64(hThread, lpContext);
|
|
|
|
|
{$else}
|
|
|
|
|
result:=false;
|
|
|
|
|
{$endif}
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function SetThreadContextArm64(hThread: THandle; const lpContext: TARM64CONTEXT; isFrozenThread: Boolean=false): BOOL;
|
|
|
|
|
begin
|
|
|
|
|
if CurrentDebuggerInterface<>nil then
|
|
|
|
|
result:=CurrentDebuggerInterface.SetThreadContextArm64(hThread, lpContext, isFrozenThread)
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
{$ifdef darwin}
|
|
|
|
|
result:=macport.SetThreadContextArm64(hThread, lpContext);
|
|
|
|
|
{$else}
|
2011-07-04 19:52:53 +00:00
|
|
|
result:=false;
|
2022-06-01 13:10:34 +02:00
|
|
|
{$endif}
|
|
|
|
|
end;
|
2011-07-04 19:52:53 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function GetThreadContext(hThread: THandle; var lpContext: TContext; isFrozenThread: Boolean=false): BOOL;
|
|
|
|
|
begin
|
|
|
|
|
if CurrentDebuggerInterface<>nil then
|
|
|
|
|
result:=CurrentDebuggerInterface.GetThreadContext(hThread, lpContext, isFrozenThread)
|
|
|
|
|
else
|
2013-08-12 00:32:01 +00:00
|
|
|
result:=NewKernelHandler.GetThreadContext(hThread, lpContext);
|
2011-07-04 19:52:53 +00:00
|
|
|
end;
|
|
|
|
|
|
2023-10-20 17:32:15 +02:00
|
|
|
function GetThreadContext(hThread: THandle; lpContext: pointer; isFrozenThread: Boolean=false): BOOL; overload;
|
|
|
|
|
begin
|
|
|
|
|
if CurrentDebuggerInterface<>nil then
|
|
|
|
|
result:=CurrentDebuggerInterface.GetThreadContext(hThread, lpContext, isFrozenThread)
|
|
|
|
|
else
|
|
|
|
|
result:=NewKernelHandler.GetThreadContext(hThread, PContext(lpContext)^);
|
|
|
|
|
end;
|
|
|
|
|
|
2022-04-19 00:08:51 +02:00
|
|
|
function GetThreadContext(hThread: THandle; var lpContext: TARMCONTEXT; isFrozenThread: Boolean=false): BOOL; overload;
|
2013-08-10 21:40:44 +00:00
|
|
|
begin
|
2022-04-19 00:08:51 +02:00
|
|
|
result:=GetThreadContextArm(hThread, lpContext, isFrozenThread);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function GetThreadContext(hThread: THandle; var lpContext: TARM64CONTEXT; isFrozenThread: Boolean=false): BOOL; overload;
|
|
|
|
|
begin
|
|
|
|
|
result:=GetThreadContextArm64(hThread, lpContext, isFrozenThread);
|
2013-08-10 21:40:44 +00:00
|
|
|
end;
|
|
|
|
|
|
2023-10-20 17:32:15 +02:00
|
|
|
|
|
|
|
|
|
2011-07-04 19:52:53 +00:00
|
|
|
function DebugActiveProcess(dwProcessId: DWORD): WINBOOL;
|
|
|
|
|
begin
|
|
|
|
|
if CurrentDebuggerInterface<>nil then
|
|
|
|
|
result:=CurrentDebuggerInterface.DebugActiveProcess(dwProcessID)
|
|
|
|
|
else
|
|
|
|
|
result:=false;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function DebugActiveProcessStop(dwProcessID: DWORD): WINBOOL;
|
|
|
|
|
begin
|
|
|
|
|
if CurrentDebuggerInterface<>nil then
|
|
|
|
|
result:=CurrentDebuggerInterface.DebugActiveProcessStop(dwProcessID)
|
|
|
|
|
else
|
2019-12-18 12:07:17 +01:00
|
|
|
{$ifdef windows}
|
2011-07-04 19:52:53 +00:00
|
|
|
result:=cedebugger.DebugActiveProcessStop(dwProcessID);
|
2019-12-18 12:07:17 +01:00
|
|
|
{$else}
|
|
|
|
|
result:=false;
|
|
|
|
|
{$endif}
|
2011-07-04 19:52:53 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end.
|
|
|
|
|
|