So... I need get the peb from the \"notepad.exe\" process, someone knows how to make it?
I was trying with the \"GetModuleHandle\" API, but... doesn\'t returns me th
Matt Pietrek described how to do that in a 1994 Under the Hood column. It was about how to get the environment variables of another process, where the first step is to get a pointer to the PEB. To do that, he says, call NtQueryInformationProcess. The PROCESS_BASIC_INFORMATION
structure it fills contains the base address of the PEB structure. (You'll need to use ReadProcessMemory
to read it since the address will be in the context of the external process's address space, not yours.)
To call NtQueryInformationProcess
, you'll need a handle to the process. If you started the process yourself (by calling CreateProcess
), then you already have a handle. Otherwise, you'll need to find the process ID and then call OpenProcess
. To get the process ID, search for the process you want with EnumProcesses
or Process32First
/Process32Next
. (I prefer the latter because it provides more information with less work.)