Hi all.
I have a question regarding accessing EPROCESS structures in the kernel
(yes I know EPROCESS is undocumented, and yes I know not to depend on
certain offsets in the EPROCESS structure).
My basic question is this: Is there a way to obtain (for NT4/2K/XP) the
address of the EPROCESS structure for any given process that is *not* the
currently executing process (so using PsGetCurrentProcess is not an
option)?
I’m trying to do this because I want to call KeAttachProcess to attach to
a certain process (namely csrss.exe)…
The only semi-sane way that I can think to do this that should
(might?)work on NT4, 2K, and XP would be to have a user-land app obtain
the PID of the process I want to get the EPROCESS block for, and send the
PID down to the driver… then the driver could use
PsLookupProcessByProcessId to grab the EPROCESS structure’s address…
I had thought about using PsActiveProcessHead and iterating through the
list, comparing image filenames until I found the process I wanted, but
that would require using offsets to the beginning of the EPROCESS struct
and for accessing the image filename member (which would put in strict OS
version (and possibly even service-pack level) dependencies which would
suck…
Under XP I could even possibly iterate through all the various process
IDs, grabbing the EPROCESS for that ID and then using
PsGetProcessImageFileName to obtain the image name to compare with (ugly
but it should work), but this isn’t available in Win2k/NT4…
Also, if I go with the ‘userland finds pid, passes to driver for lookup’
approach, is it possible that the PID in the EPROCESS struct could change
after the userland app looks up the pid and before the driver queries it?
Any thoughts would be appreciated… (even if the only answer is “you’re
on crack. you can’t do this in a sane way. move on.”)
Thanks,
sean