找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
查看: 9681|回复: 6

关于NtGetNextProcess

 火.. [复制链接]

857

主题

2632

回帖

2

精华

管理员

此生无悔入华夏,  长居日耳曼尼亚。  

积分
36130
发表于 2010-12-8 14:41:12 | 显示全部楼层 |阅读模式
这个东西好像最早出现在Windows 2003上,可以绕过OpenProcess/DuplicateHandle实现打开进程。
以下是老外写的VB.NET代码:
  1.         Private Shared Function GetProcessHandleWById(ByVal pid As Integer, ByVal access As Security.ProcessAccess) As IntPtr
  2.             ' ===== Try standard way
  3.             Dim hProc As IntPtr = GetProcessHandleById(pid, access)
  4.             If hProc.IsNotNull Then
  5.                 Return hProc
  6.             End If
  7.             ' ===== Use NtOpenProcess (if OpenProcess is hooked and not NtOpenProcess)
  8.             Dim _oa As NativeStructs.ObjectAttributes
  9.             Dim _clientId As New NativeStructs.ClientId(pid, 0)
  10.             NativeFunctions.NtOpenProcess(hProc, access, _oa, _clientId)
  11.             If hProc.IsNotNull Then
  12.                 Return hProc
  13.             End If
  14.             ' ===== Try another way (using NtGetNextProcess, VISTA ONLY)
  15.             If cEnvironment.SupportsGetNextThreadProcessFunctions Then
  16.                 ' Open handle to our process
  17.                 Dim curHandle As IntPtr = GetProcessHandleById(NativeFunctions.GetCurrentProcessId, access)
  18.                 ' Define access to use
  19.                 Dim theAccess As Security.ProcessAccess
  20.                 If (access And Security.ProcessAccess.QueryLimitedInformation) <> Security.ProcessAccess.QueryLimitedInformation AndAlso _
  21.                         (access And Security.ProcessAccess.QueryInformation) <> Security.ProcessAccess.QueryInformation Then
  22.                     theAccess = access Or Security.ProcessAccess.QueryLimitedInformation
  23.                 Else
  24.                     theAccess = access
  25.                 End If
  26.                 ' Try to find a handle using NtGetNextProcess
  27.                 Dim i As Integer = 0        ' Watchdog
  28.                 Do While True
  29.                     NativeFunctions.NtGetNextProcess(curHandle, access, 0, 0, curHandle)
  30.                     ' Get process Id of this handle
  31.                     If curHandle.IsNotNull Then
  32.                         Dim thePid As Integer = NativeFunctions.GetProcessId(curHandle)
  33.                         If thePid = pid Then
  34.                             Return curHandle
  35.                         End If
  36.                     End If
  37.                     i += 1
  38.                     ' We assume there are less than 800 processes...
  39.                     If i > 800 Then
  40.                         Exit Do
  41.                     End If
  42.                 Loop
  43.             End If
  44.             ' Okay, everything failed....
  45.             Return IntPtr.Zero
  46.         End Function
复制代码
Naylon写了个VB6版本的,经我测试,有效。

857

主题

2632

回帖

2

精华

管理员

此生无悔入华夏,  长居日耳曼尼亚。  

积分
36130
 楼主| 发表于 2010-12-8 14:43:01 | 显示全部楼层

275

主题

3017

回帖

1

精华

管理员

嗷嗷叫的老马

积分
17064

论坛牛人贡献奖关注奖最佳版主进步奖人气王疯狂作品奖精英奖赞助论坛勋章乐于助人勋章

QQ
发表于 2010-12-8 17:02:28 | 显示全部楼层
......内核的玩意玩不懂啊- -!
我就是嗷嗷叫的老马了......

头像被屏蔽

27

主题

136

回帖

2

精华

铂金会员

积分
2257
发表于 2010-12-11 10:56:42 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽

23

主题

117

回帖

1

精华

银牌会员

积分
400
发表于 2010-12-11 20:09:07 | 显示全部楼层
隐藏进程。。。N种方法;对应的,获取进程信息,也N种方法。。不多说

0

主题

16

回帖

0

精华

初来乍到

积分
9
发表于 2011-12-4 22:15:11 | 显示全部楼层
先看再说:)

28

主题

116

回帖

0

精华

铜牌会员

积分
273
发表于 2011-12-4 23:55:27 | 显示全部楼层

学习一下!
您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

快速回复 返回顶部 返回列表