Can anyone help me out with the code to get the process id of an application? I used SendMessage and got a pointer in eax to a string, but it turns out this string is stored within the other program's memory, so I think I need to use ReadProcessMemory to get the actual string using this pointer. If anyone could help with this, or point me in the right direction if I'm wrong, I'd appreciate it.
Posted on 2001-07-29 16:48:51 by mc`
Howdy!
If i were you i'd make intense use of the Toolhelp32 library of functions. They are a high level bunch of routines that makes your life easier when playing with processes related stuff.
Basically you take a 'snapshot' of the current processes and walk the list getting the info you need.
It's easy, its pure API calls :)
Check a nifty reference here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcesdkr/htm/_wcesdk_toolhelp_module.asp

I'm not sure but i think there is some ToolHelp at iczelion's.
Just peruse the Win32Asm world and you'll find a couple of sources. If you can't find anything i'll code a quick thingy for you.
Bye!

Latigo
Posted on 2001-07-29 17:16:02 by latigo
Holy Crap!
That link is for WinCE..but anyway the API names are the same :)
Posted on 2001-07-29 17:18:50 by latigo
Hey!
Aren't you the same one that had problems with winamp?
Let me say that you are FAR off from your solution.
You don't need ReadProcessMemory to get the name of the song that winamp provides!
Did you even pay attention to my suggestions yesterday?
Cos your .asm had a couple of mistakes.
Post the whole .asm file here please. I mean the whole project if it's not too big.
Posted on 2001-07-29 17:22:48 by latigo
I actually already fixed/finished the function. It looks like this..

GetWAFileName proc mWnd:DWORD,aWnd:DWORD,data:DWORD,parms:DWORD,show:DWORD,nopause:DWORD
local wahWnd:DWORD
local tTrack:DWORD
local tFile:DWORD
local tFileName:BYTE
local rawProc:DWORD
local waProc:DWORD
invoke FindWindow,addr waClass,0
mov wahWnd,eax
invoke GetWindowThreadProcessId,wahWnd,addr rawProc
invoke SendMessage,wahWnd,WM_USER,0,PL_POS
mov tTrack,eax
invoke SendMessage,wahWnd,WM_USER,tTrack,GET_FILE_NAME
mov tFile,eax
invoke OpenProcess,GENERIC_READ,FALSE,rawProc
mov waProc,eax
invoke ReadProcessMemory,waProc,tFile,addr tFileName,MAX_PATH,0
invoke CloseHandle,waProc
invoke lstrcpy,data,addr tFileName
mov eax,3
ret
GetWAFileName endp

I'm sure this probably isn't the best nor most efficient way of doing it, but it works well, so I'm happy with it.
Posted on 2001-07-29 21:12:28 by mc`