I am making a program. How would I detect that a .exe file tries to run while the program is open and keep it from opening?
I am making a program. How would I detect that a .exe file tries to run while the program is open and keep it from opening?
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
Well, this is just an idea: at the beggining of the program, check what HINSTANCE's are currently active, and every once in a while, check them again, and if there is a new HINSTANCE, close it with CloseHandle() or something like that
Oskilian
Well, how do I check for a new HINSTANCE?
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
Another question is, how would you be able to distinguish between instance handles active in the OS. It would seem perilous to indiscriminately close detected instances. It's possible to start a new thread in the OS with CreateProcess(), but i don't think you will be able to "take it back".
A good question is why?
Do you want to detect other instances of your app? If so do a search for the code, I have posted it before.
Or do you want to stop the virus checker ect?
I was wanting to make my own program that will detect a specified file has tried to run, stop the execution, and ask for a password. Just a password protection program.
I have posted code for FileMapping before.
Look up the previous post to find it.
Get your progam to run the exe you are interested in and file map it. If 'someone' else in your PC runs it it you will be able to detect it and respond.
As usual I have been proven wrong, not only is it possible to terminate a process in the OS, there is a zip file with an .exe file that demonstrates it, and the source code is available with it also. Be fore warned though, it is coded in Win32 80x86 assembley. But with patience and care the source code could be abstracted to C/C++.
Go to the following link...
http://win32asm.rxsp.com/source1.html
Navigate to where it says "KillProc" by "Comrade", and click on it to download the zip file.
READ THE README FILE !!!! killproc.exe can potentially crash your system, though I myself have not experienced this yet while testing it.