Determine own file from being closed

just write whatever you want

Determine own file from being closed

Postby ira » Thu Aug 26, 2010 3:09 pm

I am trying to prevent my program from being closed. So, I hooks TerminateProcess etc.

if myprogram then

What is the best way to check "myprogram" is really my program?
File name? :(
Hash?? It can make system slower if the file size is big..
Any idea?
Posts: 49
Joined: Mon Dec 14, 2009 6:29 am

Re: Determine own file from being closed

Postby madshi » Mon Nov 22, 2010 3:09 pm

Why is this in "fun talk"?

Anyway, this is a difficult question to answer because there's a lot of information missing. My first suggestion would be this:

(1) In your application, before injecting the hook dll, create a global file mapping (see "CreateGlobalFileMapping") and write your process ID into it.
(2) In your hook dll's initialization, open the global file mapping.
(3) In your TerminateProcess etc callback, check if the target process has the same process ID as your own process.
Site Admin
Posts: 10301
Joined: Sun Mar 21, 2004 5:25 pm

Return to fun talk

Who is online

Users browsing this forum: No registered users and 1 guest