procdump -e 1 -x . drrun.exe -debug -- "C:\Users\hunte\source\repos\anti_x\x64\Release\anti_x_with_SEH.exe"
(I run it with procdump this time to see if there is any exception not handled by DR, does that make sense?)
drrun with -debug flag shows the following:
...
[ANTI-X] DR3: 0x0000000000000000
[ANTI-X] DR6 (status): 0x00000000
[ANTI-X] DR7 (control): 0x00000000
[ANTI-X] [SUCCESS] GetThreadContext: No hardware breakpoints detected. <==== last valid output of the target application
<curiosity: rex.w on OPSZ_6_irex10_short4!>
<Stopping application C:\Users\hunte\source\repos\anti_x\x64\Release\anti_x_with_SEH.exe (15020)>
[18:35:16] Process Exit: PID 10912, Exit Code 0xc0000005
[18:35:16] The process has exited.
[18:35:16] Dump count not reached.
It looks like it has an issue with this single step exception, simple default SEH code (see below) works fine, it does not break up.
If I comment out the
single step exception code, DR (even with a client) works fine:
--- snip ---
// Check for hardware breakpoint again with a different trick (this breaks DynamoRio)
//CONTEXT* ctx2;
//SIZE_T debugger_attached = 0;
//__try {
//
__writeeflags(__readeflags() | 0x100); // Set TF flag aka set CPU to single step
//
__nop();
// trigger exception in single step mode
//}
//__except (ctx2 = (GetExceptionInformation())->ContextRecord,
//
debugger_attached = (ctx2->ContextFlags & CONTEXT_DEBUG_REGISTERS) ?
//
ctx2->Dr0 | ctx2->Dr1 | ctx2->Dr2 | ctx2->Dr3 : 0,
//
EXCEPTION_EXECUTE_HANDLER)
//{
//
if (debugger_attached) {
//
printf("[ANTI-X] [INTEGRITY CHECK FAIL] Exception test: Hardware breakpoints detected!\n");
//
}
//
else {
//
printf("[ANTI-X] [SUCCESS] Exception test: No hardware breakpoints detected.\n");
//
}
//}
--- snip ---
Simple default SEH code that runs fine under drrun:
--- snip ---
printf("[ANTI-X] triggering an exception...\n");
__try {
char* p = NULL;
*p = 0; // This will cause an access violation exception
printf("[ANTI-X] This should never be reached due to the exception\n");
}
__except (EXCEPTION_EXECUTE_HANDLER) {
DWORD code = GetExceptionCode();
printf("[ANTI-X] Exception caught: %s (0x%08X)\n", DescribeException(code), code);
}
printf("[ANTI-X] Exception triggert.\n");
--- snip ---