阅读:2087回复:6
获取进程名问题?(修改过了,大家给点指教)
我在sfcreate中加入如下代码获取打开文件的进程名:
#define ProcessNameOffset 372 PEPROCESS curproc=NULL; char *nameptr; char Name[17]=""; char Code[]="notepad.exe"; curproc = PsGetCurrentProcess(); nameptr = (PCHAR) curproc + ProcessNameOffset; strncpy( Name, nameptr, sizeof(Name)); KdPrint(( "进程名: %s\n",Name)); 但是当我打开一个文件时,打印出的相同进程名居然有30多条,有时候更多,这是为什么? 我想根据打开文件的进程来判断是否加解密,但是这么多的获取,我比较后,解密的文件就成了空白. 我哪里错了,或者还有什么其他方法.进来看的朋友请多多指教. 当我把KdPrint(( "进程名: %s\n",Name)); 放在sfwirte里面,打印出来的确是explorer.exe.这是为什么? |
|
|
沙发#
发布于:2007-05-15 09:19
这和获取进程名有什么关系呢?你不是已经得到进程名了嘛!
|
|
|
板凳#
发布于:2007-05-15 09:27
引用第1楼devia于2007-05-15 09:19发表的 : 当我打开一个文件,如txt. kdprint应该打印出一条语句,但是打印出确是30多条.为什么有这么多条? |
|
|
地板#
发布于:2007-05-16 11:21
只能通过进程来给文件名做标记,加密还是得根据文件名有没有标记来做的,
进程不总是准的,但是至少有一次是准的, |
|
地下室#
发布于:2007-05-16 12:52
引用第2楼天之出云于2007-05-15 09:27发表的 : 用FileMon跟踪一下,估计确实就是这么多! |
|
|
5楼#
发布于:2007-07-19 15:53
确实会有N多的请求
|
|
6楼#
发布于:2007-07-20 15:10
引用第2楼天之出云于2007-05-15 09:27发表的 : The I/O Request Packet (IRP) contains the context information for a single I/O operation. The NT I/O model does not inherently restrict any single device from handling multiple I/O operations simultaneously. Further, since a single file may be “opened” for access multiple times it is quite conceivable that multiple threads may be accessing a given file simultaneously. This is commonly true for heavily used directories (such as the “root” directory on a drive) or for databases (where multi-threading is used to improve performance.) |
|