【进程处理】3,MFC枚举当前进程所有模块

1,代码

        PBYTE pb = NULL;
	MEMORY_BASIC_INFORMATION mbi;
	while (VirtualQuery(pb,&mbi,sizeof(mbi)) == sizeof(mbi))
	{
		TCHAR szModeName[MAX_PATH] = {0};
		if (mbi.State == MEM_FREE)
		{
			mbi.AllocationBase = mbi.BaseAddress;
		}
		if (mbi.AllocationBase == AfxGetModuleState()->m_hCurrentInstanceHandle || 
			mbi.AllocationBase != mbi.BaseAddress ||
			mbi.AllocationBase == NULL)
		{
			
		}
		else
		{
			GetModuleFileName((HINSTANCE)mbi.AllocationBase,szModeName,_countof(szModeName));
			if (_tcslen(szModeName)>0)
			{
				EASY_LOG(szModeName);
			}
		}
		pb += mbi.RegionSize;
	}

 

注:其中EASY_LOG() 是一个输出日志的宏,可自行修改;

效果:

图片[1]-【进程处理】3,MFC枚举当前进程所有模块-第五维

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享