WDK:通过name.exe获取processId
我正在 Windows Filtering Platform 中开发一个驱动程序,我需要另一个进程的进程 ID 来完成我需要做的事情。我只知道该进程的文件名(name.exe)。
在 win32 中,我可以使用函数 CreateToolhelp32Snapshot 来获取所有进程的列表,并且我可以在那里搜索 PID。 ( http://msdn.microsoft.com/en- us/library/ms684834(VS.85).aspx )
不幸的是在内核模式下这个东西不可用。有人知道如何通过内核空间仅知道二进制名称来获取 processID 吗?
I'm developing a driver in Windows Filtering Platform and I need the process ID of another process to do what I need to do. I know only the file name of that process (name.exe).
In win32 I could use the function CreateToolhelp32Snapshot to get the list of all processes and I could search the PID there. ( http://msdn.microsoft.com/en-us/library/ms684834(VS.85).aspx )
Unfortunately in kernel mode this stuff is not available. Anyone know how can I obtain the processID knowing only the binary name, by kernel space?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据时间的不同,您似乎可以使用您自己的
CreateProcessNotifyEx()
处理程序调用PsSetCreateProcessNotifyRoutineEx()
。然后,您的CreateProcessNotifyEx()
将收到一个指向PS_CREATE_NOTIFY_INFO
的指针。此结构中包含字段ImageFileName
和位FileOpenNameAvailable
。程序名称将位于
ImageFileName
指向的 Unicode 字符串中。如果FileOpenNameAvailable
,则该字符串将包含二进制文件的完全限定路径。否则,预计只能找到模块名称,可能没有扩展名。Depending on the timing, it seems that you could call
PsSetCreateProcessNotifyRoutineEx()
with your own handler forCreateProcessNotifyEx()
. YourCreateProcessNotifyEx()
will then receive a pointer to aPS_CREATE_NOTIFY_INFO
. In this struct is the fieldImageFileName
and also the bitFileOpenNameAvailable
.The program name will be in the Unicode string pointed to by
ImageFileName
. IfFileOpenNameAvailable
, then that string will contain the fully-qualified path to the binary. Otherwise, expect to find only the module name, possibly without the extension.可以使用进程快照、遍历进程、对比进程名的方法直接获取进程。
然后在主程序中加入如下代码:
You can use the method of taking a process snapshot, traversing the process and comparing the process name to directly obtain the process.
Then get the following code into the main program: