Reputation: 23525
How can I detect the name of the application that created my application's process?
For example, if someone wanted, they could call CreateProcess and pass it the suspended flag and inject into my application.
Is there a way to block CreateProcess or to figure out what process created an instance of my application?
I've hooked loadlibrary, createthread and all the other easy stuff but CreateProcess seems like it can bypass that.
I'm doing it for fun and learning, not for real world use. I just haven't seen anything that detects CreateProcess..
Any ideas at all?
Upvotes: 0
Views: 406
Reputation: 613582
You can find the parent process ID using the tool help library:
CreateToolhelp32Snapshot
.Process32First
and Process32Next
to enumerate the processes.PROCESSENTRY32
struct for which th32ProcessID
is the process ID of your process.th32ParentProcessID
member to find the process ID of your parent.Be prepared for the parent process to have been terminated before you reach this point.
Upvotes: 1