A forum for reverse engineering, OS internals and malware analysis 

Ask your beginner questions here.
 #9994  by utsav.0202
 Tue Nov 29, 2011 12:22 pm
The EndTask function is called to forcibly close a specified window
How do I protect my window from this api?
I mean what routine do I hook?

Thanks and Regards
Utsav
 #10016  by utsav.0202
 Wed Nov 30, 2011 7:34 am
I hooked NtTerminateProcess
and tried to kill my process from "test.exe" that uses EndTask
The process that is calling NtTerminateProcess to kill my protected process is "csrss.exe" instead of "test.exe"
why is it so?
 #10017  by EP_X0FF
 Wed Nov 30, 2011 7:40 am
utsav.0202 wrote:I hooked NtTerminateProcess
and tried to kill my process from "test.exe" that uses EndTask
The process that is calling NtTerminateProcess to kill my protected process is "csrss.exe" instead of "test.exe"
why is it so?
Because internally EndTask results in CsrClientCallServer call to csrss special API port. Csrss gets the message and proceeds it.
 #10021  by Brock
 Wed Nov 30, 2011 8:37 am
IIRC in order to stop EndTask() you would need to hook NtTerminateProcess and deny it as well as handle the WM_CLOSE message that it gently sends to a window of your process, assuming there even is one. Basically, if the window cannot be closed it then tries to force the process to terminate via NtTerminateProcess from what I recall if the Force parameter is specified as True
 #10028  by utsav.0202
 Wed Nov 30, 2011 9:47 am
I hooked NtTerminateProcess and returned STATUS_ACCESS_DENIED for my process

this resulted in "error" dialog box for each window in my process that says:
"This program cannot be closed because it is locked by the system."

I don't want this. Is there any other way?
can I prevent CsrClientCallServer call?
 #10030  by newgre
 Wed Nov 30, 2011 12:02 pm
Have you tried you simply returning STATUS_SUCCESS without killing the process?