How can i get the process identifier of any dll? I want to use this value for the OpenProcess API function

HANDLE OpenProcess(

DWORD dwDesiredAccess, // access flag
BOOL bInheritHandle, // handle inheritance flag
DWORD dwProcessId // process identifier <---- Here is the problem!
);

I want to modify my dll by using the VirtualProtectEx function.

Regards,

Vortex
Posted on 2002-11-11 04:59:40 by Vortex
What are you trying to do? The only way I know to get the processID
is by using these api calls: CreateToolhelp32Snapshot, Process32First,
and Process32Next. (If you dont create it yourself that is...)

And the only time I have used those, was when I created a 'terminate process'
routine. The code below will enumerate all processe's running in the system.
Hope it can shed some light on your question.
TIP: lookup the following api calls: Module32First,Module32Next

Posted on 2002-11-11 06:08:39 by natas
How do you identify the dll? by HINSTANCE, probably? But HINSTANCE is process insensitive then. By process insensitive, I mean the HINSTANCE alone doesn't contain any information of the owner process, it's just a memory address.
Posted on 2002-11-11 06:23:43 by C.Z.
Process identifiers are for processes, not DLLs. HINSTANCE are to identify DLLs, and they will always be specific to process address space they are loaded in.
Posted on 2002-11-11 07:21:18 by comrade
Sorry frieds,It was just a misconception... The handle returned by the function GetCurrentProcessId is solving my problem.

Thanks for the replies,

Vortex
Posted on 2002-11-11 15:03:24 by Vortex