if myprogram then
What is the best way to check "myprogram" is really my program?
Hash?? It can make system slower if the file size is big..
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.