jdannenb
12th December 2006 17:00 UTC
Get full path name for running process
Hi, maybe someone's got a solution for this problem:
I try to figure out the full path name of a running process.
FindProcDLL::FindProc just tells me if the process is running or not, nothing more.
I don't know C/C++, so I cannot extend this plugin. My guess is, that I need something that will make a call to the GetModuleFileNameEx of PSAPI.dll.
Maybe it's possible to use the System.dll plugin?
Help appreciated :)
Greez
Jens
kichik
12th December 2006 19:49 UTC
It's possible using the System plug-in. There's an example in the Wiki that calls OpenProcess. It's not a long way to GetModuleFileNameEx from there. You could also do it in a plug-in of your own.
jdannenb
13th December 2006 08:30 UTC
Tnx, I try to figure it out. Maybe it's a good reason to learn some C++ ...
BTW, MS VS Express 2005 C++ Edition can be extended with the Win SDK, so you can build Win32 dlls...no need to spend money on a full license.
See http://msdn.microsoft.com/vstudio/ex...alc/usingpsdk/
Greez
Jens
jdannenb
13th December 2006 12:41 UTC
Hi, me again...
I played around a little bit with C++ and finally
spawned this NSIS-plugin. It's more or less
a product of "copy and paste" from MSDN...
but surprisingly, it does what I want.
//Usage:
//FindProcPathByName::FindProcPathByName "processname.exe"
//pop $R0
//MessageBox MB_OK "$R0"
//;if found, $R0 contains full path, else nothing
If some of you NSIS wizards could take a look at
my code, I would be grateful. I guess it's full of
memory leaks and other C/C++ horror stuff.
Needs psapi.dll, so it won't work with NT, and I
doubt it will work under 95/98/ME.
Off topic: I came from InstallShield to NSIS, and I wonder why people/companies spend money on InstallSh*t.
Cheers
Jens
jdannenb
13th December 2006 15:25 UTC
Damn...doesnt' work properly under Win2000,
there it shows only the processname itself if found,
not the full path.
Someone's got an idea why this is so?
Greez
Jens
kichik
14th December 2006 20:12 UTC
Seems like the right code, especially seeing as it's almost a directory copy of EnumProcessModules' documentation ;) Try debugging it with some message boxes or OutputDebugString and DebugView.
A possible cause is that the module wasn't found and when you pop the result, you actually get something you pushed earlier on the stack. That's because you have no default case pushstring() call in your function. There's also a possibility that you'd get multiple pushes because you don't break the loop once you find your module.