阅读:2394回复:8
获取全路径问题.....没有上下文,不是当前进程.有processID,有sectionobject,有_EPROCESS
知道进程ID,也得到了EPROCESS结构.就是得不到进程的全路径..
不是在sfilter中获取.也不是在createsection中..而是在遍历系统进程中. zwopenprocess 用了 ObReferenceObjectByHandle也用了 还用了ObQueryNameString SectionObject也不行. 请指教.有没有一个万能方法 |
|
沙发#
发布于:2007-06-29 12:51
1 PEB?
2 EPROCESS 偏移0x1f4(xpsp2,其他系统没看)处有一个_SE_AUDIT_PROCESS_CREATION_INFO,貌似全路径名 |
|
板凳#
发布于:2007-06-29 14:00
我回去试试,还有没有不通过硬编码\偏移的方法.
今天虚拟机又坏了.说什么快照信息什么东东的.烦.下了个文件隐藏的工具.想测试一把.没想到.. |
|
地板#
发布于:2007-07-04 00:01
不行,偏移0x1f4,打印为空.
还有一点不明,我获取的进程ID正确.短文件名也正确.用softICE proc了一下.发现这个EPROCESS的地址不对哦.差了4个. 我获取到system的地址是817BD48C. 用SoftICE 得到的是817BD490.(xp-sp2) |
|
地下室#
发布于:2007-07-04 09:53
应该要进行搜索.我看到过的驱动中,用的中是下面的代码获得偏移量:
#define SYSNAME "System" //---------------------------------------------------------------------- // // GetProcessNameOffset // // In an effort to remain version-independent, rather than using a // hard-coded into the KPEB (Kernel Process Environment Block), we // scan the KPEB looking for the name, which should match that // of the system process. This is because we are in the system process' // context in DriverEntry, where this is called. // //---------------------------------------------------------------------- ULONG GetProcessNameOffset( VOID ) { PEPROCESS curproc; int i; curproc = PsGetCurrentProcess(); // // Scan for 12KB, hoping the KPEB never grows that big! // for( i = 0; i < 3*PAGE_SIZE; i++ ) { if( !strncmp( SYSNAME, (PCHAR) curproc + i, strlen(SYSNAME) )) { return i; } } // // Name not found - oh, well // return 0; } 用这来获得全路径: ProcessNameOffset = GetProcessNameOffset(); PCHAR GetProcess( PCHAR ProcessName, PHANDLE ProcID ) { PEPROCESS curproc; char *nameptr; ULONG i; // // We only do this if we determined the process name offset // if( ProcessNameOffset ) { // // Get a pointer to the current process block // curproc = PsGetCurrentProcess(); // // Dig into it to extract the name. Make sure to leave enough room // in the buffer for the appended process ID. // nameptr = (PCHAR) curproc + ProcessNameOffset; strncpy( ProcessName, nameptr, NT_PROCNAMELEN-1 ); ProcessName[NT_PROCNAMELEN-1] = 0; } else { strcpy( ProcessName, "???" ); } *ProcID = PsGetCurrentProcessId(); return ProcessName; } |
|
|
5楼#
发布于:2007-07-04 13:13
谢谢先
莫非这个偏移就是全路径..回去试一下. 能不能把你的EPROCESS结构发出来比较一下. 我是从网上下的一个XP的结构.为什么会和softICE查看得到的地址不对呢. |
|
6楼#
发布于:2007-07-04 13:28
最安全的做法是在ImageNotify的时候得到全路径,保存在表中,然后需要的时候查表即可
|
|
7楼#
发布于:2007-07-19 15:14
引用第4楼ceabie于2007-07-04 09:53发表的 : 这个好像只能取到 进程映像名 Not Full Path Name |
|
8楼#
发布于:2007-07-21 17:41
我的xp用GetProcessNameOffset();取得偏移怎么总是返回 0? 输出 "???"
|
|