能力值:
( LV12,RANK:1010 )
|
-
-
2 楼
PID -> EPROCESS -> ProcessName
|
能力值:
( LV5,RANK:60 )
|
-
-
3 楼
NTKERNELAPI
NTSTATUS
PsLookupProcessByProcessId (
IN ULONG ProcessId,
OUT PEPROCESS *Process
);
UCHAR *
PsGetProcessImageFileName(
__in PEPROCESS Process
);
|
能力值:
( LV2,RANK:10 )
|
-
-
4 楼
楼上两位大侠的我在网上也找到过了,仍没有解决
就是关于这个偏移量的问题,
//--------------------------------------转载部分------------------------------------------------------
检查一下EProcess + 0x1FC里这个0x1FC这个偏移量是否和你的系统相同
不要随便拷贝来就用
另外,EPROCESS中的进程名好像是16个字节长度的字符串,它通常是文件名的前16个字符
刚刚学习驱动编程,实现一个hook ssdt中对ntopenrocess这个函数的hook,通过进程名判断是否ntopenprocess是否是对一个特定进程(以notepad.exe为例)进行打开操作,如果是,那么就返回null,不是就正常执行
在网上也查了一下,找到2种方法实现这种转换
1.通过PsLookupProcessByProcessId
NTSTATUS status=PsLookupProcessByProcessId((ULONG)pClientId,&EProcess);
LPTSTR ProcessName = (LPTSTR)EProcess + 0x1FC;
strlwr(ProcessName);//转换成小写
if(memcmp(ProcessName,L"notepad.exe",22)==0)
{
pProcessHandle=NULL;
rc=STATUS_Access_DENIED;
}
编译通过了,但是一start就蓝,调试中发现是在PsLookupProcessByProcessId一直循环
请教一下是为什么?
2.通过ZwQueryInformationProcess函数
这个不知怎么实现,希望高手能给出用这个函数实现由进程句柄得到进程名的源代码
//--------------------------------------转载部分------------------------------------------------------
谢了
|
能力值:
( LV9,RANK:610 )
|
-
-
5 楼
3楼的两个函数就可以解决问题,不用硬编码啊
|
能力值:
( LV2,RANK:10 )
|
-
-
6 楼
我去试一下,WIN32下什么都不是问题,但在RING0下,什么都是问题,关键我是用的DELPHI,很多函数和申明都要自己定义,晕,又不想去啃C++了,
|
能力值:
( LV2,RANK:10 )
|
-
-
7 楼
不错,答案正确,问题已解决!
感慨:感觉用Delphi写驱动真的是麻烦,特别是数据类型的定义我都差不多完全定义成C的形式了,在WIN32下哪有这么麻烦!Delphi自带的数据类型和内部函数在Ring0下几乎没有能用的了。谢谢看雪的大大们,这个地方不错,我喜欢!
|
能力值:
( LV5,RANK:60 )
|
-
-
8 楼
好像某人说过PsGetProcessImageFileName win2000下没有
|
能力值:
( LV2,RANK:10 )
|
-
-
9 楼
哇!Delphi写驱动? 我还是第一次见哦,不是贬义,确实罕见!牛!
|
能力值:
( LV12,RANK:1010 )
|
-
-
10 楼
你应该自己分配块内存,存放name,然后再进行大小写转换. 你上面这样写不蓝就奇怪了..
|
能力值:
( LV2,RANK:10 )
|
-
-
11 楼
呵呵,谢谢您的好意,上面的代码我是转的人家的,我是用Pascal写的,不过感觉写驱动的时候Pascal跟C区别不大了,我的理解,能看懂C应该也能看懂Pascal,那个EPROCESS结构的定义可不是好玩的,90个类型信息
PEPROCESS = ^EPROCESS;
EPROCESS = packed record
Pcb: KPROCESS; {000}
ExitStatus: NTSTATUS; {06C}
LockEvent: KEVENT; {070}
LockCount: DWORD; {080}
d084: DWORD; {084}
CreateTime: LARGE_INTEGER; {088}
ExitTime: LARGE_INTEGER; {090}
LockOwner: PVOID; {098}
UniqueProcessId: DWORD; {09C}
ActiveProcessLinks:LIST_ENTRY;{0A0}
QuotaPeakPoolUsage: array [0..1] of DWORD; {NP, P 0A8}
QuotaPoolUsage: array [0..1] of DWORD; {NP, P 0B0}
PagefileUsage: DWORD; {0B8}
CommitCharge: DWORD; {0BC}
PeakPagefileUsage: DWORD; {0C0}
PeakVirtualSize: DWORD; {0C4}
VirtualSize: LARGE_INTEGER; {0C8}
Vm: MMSUPPORT; {0D0}
SessionProcessLinks: LIST_ENTRY; {118}
DebugPort: PVOID; {120}
ExceptionPort: PVOID; {124}
ObjectTable: PVOID; {128}
Token: PVOID; {12C}
WorkingSetLock: FAST_MUTEX; {130}
WorkingSetPage: DWORD; {150}
ProcessOutswapEnabled:BOOLEAN;{154}
ProcessOutswapped: BOOLEAN; {155}
AddressSpaceInitialized: BOOLEAN; {156}
AddressSpaceDeleted: BOOLEAN; {157}
AddressCreationLock: FAST_MUTEX;{158}
HyperSpaceLock: DWORD; {178}
ForkInProgress: PVOID; {17C}
VmOperation: WORD; {180}
ForkWasSuccessful: BOOLEAN; {182}
MmAgressiveWsTrimMask: BYTE; {183}
VmOperationEvent: PVOID; {184}
PaeTop: PVOID; {188}
LastFaultCount: DWORD; {18C}
ModifiedPageCount: DWORD; {190}
VadRoot: PVOID; {194}
VadHint: PVOID; {198}
CloneRoot: PVOID; {19C}
NumberOfPrivatePages: DWORD; {1A0}
NumberOfLockedPages: DWORD; {1A4}
NextPageColor: WORD; {1A8}
ExitProcessCalled: BOOLEAN; {1AA}
CreateProcessReported:BOOLEAN;{1AB}
SectionHandle: PVOID; {1AC}
Peb: PVOID; {1B0}
SectionBaseAddress: PVOID; {1B4}
QuotaBlock: PVOID; {1B8}
LastThreadExitStatus:NTSTATUS;{1BC}
WorkingSetWatch: PVOID; {1C0}
Win32WindowStation: PVOID; {1C4}
InheritedFromUniqueProcessId: PVOID;{1C8}
GrantedAccess: DWORD; {1CC}
DefaultHardErrorProcessing: DWORD;{HEM_* 1D0}
LdtInformation: PVOID; {1D4}
VadFreeHint: PVOID; {1D8}
VdmObjects: PVOID; {1DC}
DeviceMap: PVOID; {1E0}
SessionId: DWORD; {1E4}
PhysicalVadList: LIST_ENTRY; {1E8}
Filter: QWORD;
PaePageDirectoryPage: DWORD; {1F8}
ImageFileName: array [0..15] of char;{1FC}
VmTrimFaultValue: DWORD; {20C}
SetTimerResolution: BYTE; {210}
PriorityClass: BYTE; {211}
SubSystemVersion: WORD; {212}
Win32Process: PVOID; {214}
Job: PVOID; {218 PTR EJOB}
JobStatus: DWORD; {21C}
JobLinks: LIST_ENTRY; {220}
LockedPagesList: PVOID; {228}
SecurityPort: PVOID; {22C}
Wow64Process: PVOID; {230 PTR WOW64_PROCESS}
ReadOperationCount: LARGE_INTEGER;{238}
WriteOperationCount: LARGE_INTEGER;{240}
OtherOperationCount: LARGE_INTEGER;{248}
ReadTransferCount: LARGE_INTEGER;{250}
WriteTransferCount: LARGE_INTEGER;{258}
OtherTransferCount: LARGE_INTEGER;{260}
CommitChargeLimit: DWORD; {268}
CommitChargePeak: DWORD; {26C}
ThreadListHead: LIST_ENTRY; {270}
VadPhysicalPagesBitMap: PVOID;{278 PTR RTL_BITMAP}
VadPhysicalPages: DWORD; {27C}
AweLock: DWORD; {280}
d284h: DWORD; {284 padding}
end;
|
能力值:
( LV12,RANK:420 )
|
-
-
12 楼
应该用ZwQuerySystemInformation -> SystemProcessesInformation
不标准方法,当然要蓝
|
能力值:
( LV2,RANK:10 )
|
-
-
13 楼
不是我蓝啊,兄弟看看上面,我是转的人家的帖子,蓝的人是用的VC,呵呵,
|
能力值:
( LV2,RANK:10 )
|
-
-
14 楼
@qihoocom
能否写出ZwQuerySystemInformation -> SystemProcessesInformation
的完整实现代码?让我们菜鸟也学习一下,谢谢!C的也可以,
|
能力值:
( LV2,RANK:10 )
|
-
-
15 楼
同意楼上的朋友
|
|
|