我在使用PowerShell直接从PEB读取指定进程的命令行时遇到了麻烦。我正在使用NtQueryInformationProcess获取PROCESS_BASIC_INFORMATION数据。没有WMI的进程命令行
# $proc - process handle
if ($NtQueryInformationProcess(
$proc, 0, $PROCESS_BASIC_INFORMATION, [Runtime.InteropServices.Marshal]::SizeOf(
$PROCESS_BASIC_INFORMATION
), [IntPtr]::Zero
))) -eq 0) {
# pointer to RTL_USER_PROCESS_PARAMETERS
$ptr = [Runtime.InteropServices.Marshal]::ReadIntPtr($PROCESS_BASIC_INFORMATION.PebBaseAddress, 0x10)
# pointer to CommandLine field of structure above
$ptr = [Runtime.InteropServices.Marshal]::ReadIntPtr($ptr, 0x40)
# how to get CommandLine field (UNICODE_STRING structure)?
}
所有的指针是正确的,但我不知道如何阅读带有元帅类型的CommandLine字段。有任何想法吗?
此示例感觉不完整。什么是'$ NtQuerInformationProcess'? '$'是用于变量而'()'用于方法? –
阅读http://stackoverflow.com/help/mcve –
如果您还没有回答有问题,请不要发布,请。 – kate