Paso a dejar un ejemplo para detectar "breakpoints de hardware" que es lo que se suele usar en herramientas de cracking
Si el valor no devuelve 0 esque alguien nos esta intentando crackear
Código Delphi
[-]
function checkBP(): integer;
var
NumBps: integer;
Context: TContext;
hThread: Thandle;
begin
NumBps := 0;
ZeroMemory(@Context, sizeof(TContext));
Context.ContextFlags := CONTEXT_DEBUG_REGISTERS;
hThread := GetCurrentThread();
GetThreadContext(hThread, Context);
if (Context.Dr0 = 0) = false then
inc(NumBps);
if (Context.Dr1 = 0) = false then
inc(NumBps);
if (Context.Dr2 = 0) = false then
inc(NumBps);
if (Context.Dr3 = 0) = false then
inc(NumBps);
result := NumBps;
end;
Esto no cubre breakpoints en memoria o código.
Este tipo de breakpoint lo suele usar el cracker si se le complica la situación, como encontrarse con un anti-debugger.