2014-01-07 81 views

回答

5

要想從使用WinAPI的外部進程的命令行,你必須訪問應用程序的PEB (Process Environment Block)。要獲得PEB,您可以使用NtQueryInformationProcess函數,也可以使用Win32_Process WMI類和CommandLine屬性。你可以在這篇文章"Two ways to get the command line of another process"上找到這兩種方法的樣本。同時請查看Raymond Chen的文章"How do I get the command line of another process?",該文章提供了有關命令行緩衝區可靠性的非常重要的信息。

+0

謝謝。嗯,NtQueryInformationProcess是不公開的,所以他們[微軟]說使用另一個公共職能。但是沒有獲取流程信息的功能。 – cybersoft

+0

你是什麼意思「NtQueryInformationProcess不公開」?是的。它從ntdll.dll中導出,使用'LoadLibrary()'和'GetProcAddress()'來訪問它,就像[documentation]一樣(http://msdn.microsoft.com/en-us/library/windows/desktop/ ms684280.aspx)說。 –

相關問題