regarding getting the process ID in user and kernel space

Hi All,

I had a question regarding the user space process id and kernel space process id …

In user space we have a function which basically returns a number which is of type DWORD
DWORD GetProcessId( HANDLE Process);

and in kernel mode we have a function which return a HANDLE
HANDLE PsGetCurrentProcessId( VOID );

Does both the function return the same value…???

Consider the case were in a kernel mode module requires to know the process which invoked the function is the same as the one which registered for the kernel mode functionality …meaning

Application first makes a register call with a processid which it gets from user mode function…Then application makes the system call to kernel space module, in the kernel module i use PsGetCurrentProcessId to get the process id to validate if the process which requested a functionality from the kernel mode module is the same as the one registered to it …

can i do this …

Jagadish

> Does both the function return the same value…???

Sure…

Anton Bassov

> In user space we have a function which basically returns a number which is of
type

DWORD
DWORD GetProcessId( HANDLE Process);

and in kernel mode we have a function which return a HANDLE
HANDLE PsGetCurrentProcessId( VOID );

Does both the function return the same value…???

Yes. On x86, both types are 32bit. On x64, HANDLE is 64bit, but the upper 32
bits are never used.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com