Detect debugger attached

Hi im trying to detect if a debugger is attached to a program
my example im trying to check if its attached to notepad

problem is its always showing false
even after i have attached ollydbg to notepad process.

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
#include "windows.h"
#include <stdio.h>


int main()
{
	while (true)
	{
		HWND hwnd = FindWindow(NULL, "Untitled - Notepad");
		if (hwnd)
		{
			printf("Window found \n");

			BOOL IsDbgPresent = FALSE;
			CheckRemoteDebuggerPresent(hwnd, &IsDbgPresent);

			if (IsDbgPresent)
				printf("Debugger attached = true \n");
			else
				printf("Debugger attached = false \n");

		}
		else
		{
			printf("Window not found \n");
		}

		Sleep(10000);

	}

	return 0;
}
Last edited on
Topic archived. No new replies allowed.