Shoutbox

[?] Retrieving a process handle - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [?] Retrieving a process handle (/showthread.php?tid=89321)

[?] Retrieving a process handle by SmokingCookie on 02-21-2009 at 06:11 PM

Hi,

I'm looking for a way to retrieve a process handle to feed into WriteProcessMemory. I do not want to retrieve the Messenger process (which can be done by GetCurrentProcess).

Does anyone know how-to?


RE: [?] Retrieving a process handle by matty on 02-21-2009 at 06:56 PM

What handle are you trying to retrieve?


RE: [?] Retrieving a process handle by SmokingCookie on 02-21-2009 at 06:59 PM

The hProcess parameter to pass to WriteProcessMemory.


RE: [?] Retrieving a process handle by matty on 02-22-2009 at 03:53 PM

But are you trying to write to the Messenger process? If so GetCurrentProcess will work.


RE: [?] Retrieving a process handle by SmokingCookie on 02-22-2009 at 05:14 PM

As I said in the first post, I'm not trying to retrieve the Messenger process handle.

BTW, I know the window title, (and by using FindWindow(Ex) I can get the window handle) and the EXE name.


RE: [?] Retrieving a process handle by Mnjul on 02-22-2009 at 05:31 PM

If you know the window handle, then GetWindowThreadProcessId (returning a process id) and OpenProcess (returning a process handle from process id) should help.

However I don't know if you can write to arbitrary process's memory space :S...(I don't think you can :P)


RE: [?] Retrieving a process handle by SmokingCookie on 02-23-2009 at 09:16 AM

Well, it appears to work, except for the writing part. Access denied :S


RE: [?] Retrieving a process handle by -dt- on 02-23-2009 at 10:41 AM

quote:
Originally posted by SmokingCookie
Well, it appears to work, except for the writing part. Access denied :S
er, is your process higher than the one you're writing to?

with winamp i do
GetWindowThreadProcessId
then
OpenProcess with the PROCESS_ALL_ACCESS flag
then you should be able to call
VirtualAllocEx (if you want to allocate memory within its space)
then
WriteProcessMemory

RE: [?] Retrieving a process handle by SmokingCookie on 02-23-2009 at 03:33 PM

I can't seem to find PROCESS_ALL_ACCESS. I tried PROCESS_VM_WRITE instead. Still I receive the message "access denied".

Unless PROCESS_ALL_ACCESS is all these flags together (e.g. "FLAG1 | FLAG2" etc.), it's nowhere to be found.


Thanks mate :)