Windows C++ / Debug Registers, Hardware Breakpoints
Author | Lexsek |
Platform | Windows |
Language | C++ |
Technique | Debug Registers, Hardware Breakpoints |
Code
#include <windows.h>
#include <stdio.h>
int main() {
HANDLE thread = GetCurrentThread();
CONTEXT threadContext;
int errorCode;
memset(&threadContext, 0, sizeof(CONTEXT));
threadContext.ContextFlags = CONTEXT_ALL;
if( !GetThreadContext(thread, &threadContext) ){
errorCode = GetLastError();
puts("Could not get thread context");
return errorCode;
}
if( threadContext.Dr0 || threadContext.Dr1 || threadContext.Dr2 || threadContext.Dr3 ){
puts("Detected");
}
else{
puts("Undetected");
}
return 0;
}
Created
November 13, 2020
Last Revised
April 22, 2024