How to prevent other program from renaming other top_level windows caption

Context: I'm making a parental control application.

My App enumerates all top-level windows on the screen, and terminate other processes by window caption using

[EnumWindows(EnumWindowsDelegate lpEnumFunc, IntPtr lParam)],

(https://learn.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-enumwindows)  

SetWindowText(hwnd, WindowText, WindowText.Capacity).

But My App has a gaping security hole.

User can rename window caption using SetWindowText(IntPtr hwnd, String lpString). Then, I try to run cmd.exe as administrator, SetWindowText doesn't work for it.

I want to solve the problem at its root.

To prevent the unauthorized program from renaming other program's window caption, How to grant write permission to all top-level windows or specific application in C#?

Upvotes: 0

Views: 253

Answers (0)

Related Questions