VadRoot枚举进程模块在Windows7下的完整实现
原理小伟的小伟在http://bbs.pediy.com/showthread.php?t=66886说的挺清楚了,Windows7下有一些变化,使用NtQueryVirtualMemory来枚举模块是一个效率很低的事情,自己枚举VadRoot速度是很快的,有N个子节点时,为log(N),还有我在这里补上的基地址获取和镜像大小获取,废话不多说,完整代码如下,仅给有需要的人参考,大侠飘过……
typedef struct _MMADDRESS_NODE // 0x14
{
union u1; // +0x0(0x4)
struct _MMADDRESS_NODE* LeftChild; // +0x4(0x4)
struct _MMADDRESS_NODE* RightChild; // +0x8(0x4)
ULONG StartingVpn; // +0xc(0x4)
ULONG EndingVpn; // +0x10(0x4)
}MMADDRESS_NODE,*PMMADDRESS_NODE;
#pragma pack(push,1)
typedef struct _EX_FAST_REF
{
union
{
PVOID Object;
ULONG_PTR RefCnt:3;
ULONG_PTR Value;
};
} EX_FAST_REF, *PEX_FAST_REF;
#pragma pack(pop)
struct _SEGMENT // 0x38
{
struct _CONTROL_AREA* ControlArea; // +0x0(0x4)
ULONG TotalNumberOfPtes; // +0x4(0x4)
ULONG SegmentFlags; // +0x8(0x4)
ULONG NumberOfCommittedPages; // +0xc(0x4)
ULONGLONG SizeOfSegment; // +0x10(0x8)
union
{
struct _MMEXTEND_INFO* ExtendInfo; // +0x18(0x4)
void* BasedAddress; // +0x18(0x4)
};
EX_PUSH_LOCK SegmentLock; // +0x1c(0x4)
ULONG u1; // +0x20(0x4)
ULONG u2; // +0x24(0x4)
struct _MMPTE* PrototypePte; // +0x28(0x4)
//ULONGLONG ThePtes[0x1]; // +0x30(0x8)
};
struct _CONTROL_AREA // 0x50
{
struct _SEGMENT* Segment; // +0x0(0x4)
struct _LIST_ENTRY DereferenceList; // +0x4(0x8)
ULONG NumberOfSectionReferences; // +0xc(0x4)
ULONG NumberOfPfnReferences; // +0x10(0x4)
ULONG NumberOfMappedViews; // +0x14(0x4)
ULONG NumberOfUserReferences; // +0x18(0x4)
ULONG u; // +0x1c(0x4)
ULONG FlushInProgressCount; // +0x20(0x4)
struct _EX_FAST_REF FilePointer; // +0x24(0x4)
};
struct _SUBSECTION // 0x20
{
struct _CONTROL_AREA* ControlArea; // +0x0(0x4)
struct _MMPTE* SubsectionBase; // +0x4(0x4)
struct _SUBSECTION* NextSubsection; // +0x8(0x4)
ULONG PtesInSubsection; // +0xc(0x4)
ULONG UnusedPtes; // +0x10(0x4)
struct _MM_AVL_TABLE* GlobalPerSessionHead; // +0x10(0x4)
union u; // +0x14(0x4)
ULONG StartingSector; // +0x18(0x4)
ULONG NumberOfFullSectors; // +0x1c(0x4)
};
typedef struct _MMVAD // 0x3c
{
ULONG u1; // +0x0(0x4)
struct _MMVAD* LeftChild; // +0x4(0x4)
struct _MMVAD* RightChild; // +0x8(0x4)
ULONG StartingVpn; // +0xc(0x4)
ULONG EndingVpn; // +0x10(0x4)
ULONG u; // +0x14(0x4)
EX_PUSH_LOCK PushLock; // +0x18(0x4)
ULONG u5; // +0x1c(0x4)
ULONG u2; // +0x20(0x4)
struct _SUBSECTION* Subsection; // +0x24(0x4)
struct _MSUBSECTION* MappedSubsection; // +0x24(0x4)
struct _MMPTE* FirstPrototypePte; // +0x28(0x4)
struct _MMPTE* LastContiguousPte; // +0x2c(0x4)
struct _LIST_ENTRY ViewLinks; // +0x30(0x8)
struct _EPROCESS* VadsProcess; // +0x38(0x4)
}MMVAD; typedef struct tag_MM_AVL_TABLE // 0x20
{
struct _MMADDRESS_NODE BalancedRoot; // +0x0(0x14)
ULONG DepthOfTree; // +0x14(0x4)
ULONG Unused; // +0x14(0x4)
ULONG NumberGenericTableElements; // +0x14(0x4)
void* NodeHint; // +0x18(0x4)
void* NodeFreeHint; // +0x1c(0x4)
}MM_AVL_TABLE,*PMMAVL_TABLE; #define GetVadRoot(eprocess) ((PVOID)((char*)eprocess+0x278))
VOID PrintTree(MMVAD* Root)
{
POBJECT_NAME_INFORMATION Str=(POBJECT_NAME_INFORMATION )ExAllocatePool(PagedPool,800);
ULONG RetLen=0;
if(!Str||!Root)
return ;
RtlZeroMemory(Str,800);//递归要节省堆栈资源,不要大量使用局部变量
__try
{
if(MmIsAddressValid(Root->Subsection)&&MmIsAddressValid(Root->Subsection->ControlArea))
{
if(MmIsAddressValid((PVOID)Root->Subsection->ControlArea->FilePointer.Value))
{
PFILE_OBJECT pFileObj=(PFILE_OBJECT)((Root->Subsection->ControlArea->FilePointer.Value>>3)<<3);
if(MmIsAddressValid(pFileObj))
{
NTSTATUS Status=ObQueryNameString(pFileObj,Str,800,&RetLen);
if(NT_SUCCESS(Status))
{
KdPrint(("Base:%08X Size:%dKb ",Root->Subsection->ControlArea->Segment->BasedAddress,\
(Root->Subsection->ControlArea->Segment->SizeOfSegment)/0x1000));
KdPrint(("Name:%ws\n",Str->Name.Buffer));
}
else
{
KdPrint(("不能获取到对象!%08X\n",Status));
} }
} }
}
__except(1)
{
KdPrint(("Invalid Address!\n"));
}
ExFreePool(Str);
__try
{
if(MmIsAddressValid(Root->LeftChild))
PrintTree(Root->LeftChild);
if(MmIsAddressValid(Root->RightChild))
PrintTree(Root->RightChild);
}
__except(1)
{
KdPrint(("异常!!"));
return;
} }
VOID ShowProcessModule(ULONG Pid)
{
#ifdef DBG
_asm int 3
#endif
PMMAVL_TABLE Table;
PEPROCESS Epr=0;
if(NT_SUCCESS(PsLookupProcessByProcessId((HANDLE)Pid,&Epr)))
{
KeAttachProcess(Epr);
Table=(PMMAVL_TABLE)GetVadRoot(Epr);
if(Table->BalancedRoot.LeftChild)
PrintTree((MMVAD*)Table->BalancedRoot.LeftChild);
if(Table->BalancedRoot.RightChild)
PrintTree((MMVAD*)Table->BalancedRoot.RightChild);
KeDetachProcess();
}
} VOID DriverUnLoad(PDRIVER_OBJECT Driver)
{
KdPrint(("Driver UnLoaded!\n"));
} extern "C"
NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject,PUNICODE_STRING Reg)
{
KdPrint(("Enter Driver Entry!\n"));
pDriverObject->DriverUnload=DriverUnLoad;
ShowProcessModule(2000);
KdPrint(("Leave Driver Entry!\n"));
return STATUS_SUCCESS;
对记事本的测试结果如下:
Base:75740000 Size:25Kb Name:\Device\HarddiskVolume2\Windows\System32\sechost.dll
Base:00060000 Size:48Kb Name:\Device\HarddiskVolume2\Windows\System32\notepad.exe
Base:00000000 Size:102Kb Name:\Device\HarddiskVolume2\Windows\System32\locale.nls
Base:74140000 Size:414Kb Name:\Device\HarddiskVolume2\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16385_none_421189da2b7fabfc\comctl32.dll
Base:00000000 Size:718Kb Name:\Device\HarddiskVolume2\Windows\Globalization\Sorting\SortDefault.nls
Base:00000000 Size:2368Kb Name:\Device\HarddiskVolume2\Windows\Fonts\StaticCache.dat
Base:70FD0000 Size:81Kb Name:\Device\HarddiskVolume2\Windows\System32\winspool.drv
Base:73FC0000 Size:64Kb Name:\Device\HarddiskVolume2\Windows\System32\uxtheme.dll
Base:75420000 Size:172Kb Name:\Device\HarddiskVolume2\Windows\System32\msvcrt.dll
Base:75210000 Size:74Kb Name:\Device\HarddiskVolume2\Windows\System32\KernelBase.dll
Base:745A0000 Size:9Kb Name:\Device\HarddiskVolume2\Windows\System32\version.dll
Base:74FF0000 Size:12Kb Name:\Device\HarddiskVolume2\Windows\System32\cryptbase.dll
Base:753A0000 Size:123Kb Name:\Device\HarddiskVolume2\Windows\System32\comdlg32.dll
Base:75680000 Size:31Kb Name:\Device\HarddiskVolume2\Windows\System32\imm32.dll
Base:75520000 Size:201Kb Name:\Device\HarddiskVolume2\Windows\System32\user32.dll
Base:756A0000 Size:157Kb Name:\Device\HarddiskVolume2\Windows\System32\usp10.dll
Base:76F50000 Size:316Kb Name:\Device\HarddiskVolume2\Windows\System32\ntdll.dll
Base:75BA0000 Size:160Kb Name:\Device\HarddiskVolume2\Windows\System32\advapi32.dll
Base:75A60000 Size:143Kb Name:\Device\HarddiskVolume2\Windows\System32\oleaut32.dll
Base:75900000 Size:348Kb Name:\Device\HarddiskVolume2\Windows\System32\ole32.dll
Base:757D0000 Size:204Kb Name:\Device\HarddiskVolume2\Windows\System32\msctf.dll
Base:75AF0000 Size:161Kb Name:\Device\HarddiskVolume2\Windows\System32\rpcrt4.dll
Base:76D30000 Size:212Kb Name:\Device\HarddiskVolume2\Windows\System32\kernel32.dll
Base:75C40000 Size:3145Kb Name:\Device\HarddiskVolume2\Windows\System32\shell32.dll
Base:77180000 Size:80Kb Name:\Device\HarddiskVolume2\Windows\System32\apisetschema.dll
Base:770B0000 Size:78Kb Name:\Device\HarddiskVolume2\Windows\System32\gdi32.dll
Base:770A0000 Size:10Kb Name:\Device\HarddiskVolume2\Windows\System32\lpk.dll
Base:77120000 Size:87Kb Name:\Device\HarddiskVolume2\Windows\System32\shlwapi.dll
jpg改rar
VadRoot枚举进程模块在Windows7下的完整实现的更多相关文章
- ZwQueryVirtualMemory枚举进程模块
ZwQueryVirtualMemory算是枚举进程方法中的黑科技吧,主要是该方法可以检测出隐藏的模块(类似IceSword). 代码VS2015测试通过 再次奉上源码链接:https://githu ...
- Windows7下IIS+php配置教程 http://www.jb51.net/article/113812.htm
这篇文章主要为大家详细介绍了Windows7下IIS+php配置教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 WINDOWS 7 IIS+php配置教程,具体内容如下 打开 开始 -> ...
- windows7下安装apache+PHP5.3
Apache+PHP 安装与配置 最近在学习PHP,所以就在windows7下安装了PHP的开发环境.之所以没有选择集成的软件,如WAMP.AppServ等套件,是为了单独安装这些软件,有助于更加深入 ...
- Windows7下移植Qt4.8.4项目到QT5.2上时遇到的一些问题
最近在Windows7下将Qt4.8.4+MSVC2008的项目移植到QT5.2下时,遇到了一些小问题: 问题一:错误:C1083: 无法打开包括文件:"QApplication&q ...
- windows7下php5.4成功安装imageMagick,及解决php imagick常见错误问题。(phpinfo中显示不出来是因为:1.imagick软件本身、php本身、php扩展三方版本要一致,2.需要把CORE_RL_*.dll多个文件放到/php/目录下面)
windows7下 php5.4成功安装imageMagick . (phpinfo中显示不出来是因为:1.软件本身.php本身.php扩展三方版本要一致,2.需要把CORE_RL_*.dll多个 ...
- windows7 下伪静态配置方法
今天终于算是彻底知道windows7下伪静态的IIS配置了.尼玛真坑爹,竟然64位的和32位的配置竟然不一样... 网上找的比较详细的文章地址: http://jingyan.baidu.com/ar ...
- windows7下安装php的imagick和imagemagick扩展教程
这篇文章主要介绍了windows7下安装php的imagick和imagemagick扩展教程,同样也适应XP操作系统,Win8下就没测试过了,需要的朋友可以参考下 最近的PHP项目中,需要用到切图和 ...
- Windows7下Blend for Visual Studio 2012使用问题
目前开发的系统里很多控件样式和动画比较复杂,应该是之前同事用Blend做的,这种神器不用太浪费了,自己也准备试试. 系统环境Windows7+Visual Studio 2012 1.Windows7 ...
- Windows7下QT5开发环境搭建 分类: QT开发 2015-03-09 23:44 65人阅读 评论(0) 收藏
Windows7下QT开法环境常见搭配方法有两种. 第一种是:QT Creator+QT SDK: 第二种是:VS+qt-vs-addin+QT SDK: 以上两种均可,所需文件见QT社区,QT下载地 ...
随机推荐
- CSS样式收集
1.改变浏览器滚动条样式(适合webkit内核,摘自www.webhek.com/scrollbar) ::-webkit-scrollbar{width:2px;} ::-webkit-scroll ...
- 提升mysql性能的建议
使用show status命令查看mysql状态相关的值及其含义:使用show status命令含义如下:aborted_clients 客户端非法中断连接次数aborted_connects 连接m ...
- eclispe+axis2+webservice入门
配置eclipse相关插件并启动axis2: http://blog.csdn.net/pilihaotian/article/details/52513697 这里你可能会遇到使用eclipse 启 ...
- 【jQuery】初始化的三种方法
JQ初始化方法实际上有两种,由于美元符号可以定义 jQuery,那么就有三种方法可以进行初始化操作,根据个人习惯来选择吧! 第一种 $(document).ready(function(){ // j ...
- JAVA过滤器
对于get请求和post请求全局过滤: 自己创建一个类,实现HttpServletRequestWrapper接口 package com.dh.deno; import java.io.Buffer ...
- jquery easyui datagrid翻页后再查询始终从第一页开始
在查询之前将datagrid的属性pageNumber重新设置为1 var opts = grid.datagrid('options'); opts.pageNumber = 1; easyui d ...
- ionic的常用命令总结以及正式发布的准备
常用命令: npm install -g ionic cordova(需要安装node) ionic start cutePuppyPics --v2(建app cutePuppyPics app名字 ...
- Vue.js:轻量高效的前端组件化方案
转发一篇尤老师对vue.js的介绍,了解vue.js的来龙去脉.不过现在已经是2.0了,也有添加一些新的东西,当然有些东西也改了. Vue.js:轻量高效的前端组件化方案 Vue.js 是我在2014 ...
- Microsoft QAS架接项目
1,p位置玩文件后.运行程序命令是: QCSQueryLabelWithLES.exe -c %CD%\FinalQASModelDir --variant AMyMovie --outputFull ...
- Docker - Dockerizing applications: A “Hello world”
1. 在Docker容器(container)运行Hello world $ docker run ubuntu /bin/echo 'Hello world' docker run - 运行一个容器 ...