For each Process ID:
use
OpenProcess()
to get aHANDLE
to the process.then use
QueryFullProcessImageName()
,GetProcessImageFileName()
, orGetModuleFileNameEx
to get the path and filename of the process.then use
NtQueryInformationProcess()
to retrieve the address of the process'sPEB
structure, which contains aProcessParameters
member containing the command-line arguments for the process (you can also get the image path from thePEB
as well). UseReadProcessMemory()
to read the contents of thePEB
.
Have a look at the following article for more details: