首页
社区
课程
招聘
未解决 [求助]ZwQueryVirtualMemory的使用
发表于: 2019-1-20 20:53 2814

未解决 [求助]ZwQueryVirtualMemory的使用

2019-1-20 20:53
2814
请问用ZwQueryVirtualMemory可以枚举模块基址跟路径 那么要怎么获取这个模块的大小呢?

[课程]FART 脱壳王!加量不加价!FART作者讲授!

收藏
免费 0
支持
分享
最新回复 (3)
雪    币: 6400
活跃值: (4160)
能力值: ( LV10,RANK:163 )
在线值:
发帖
回帖
粉丝
2
PE头里有大小.
2019-1-21 09:58
1
雪    币: 6400
活跃值: (4160)
能力值: ( LV10,RANK:163 )
在线值:
发帖
回帖
粉丝
3

下面再送一个 ZwQueryVirtualMemory 套餐(有坑):

ULONG WINAPI My_NtQueryVirtualMemory(HANDLE ProcessHandle, PVOID BaseAddress, MEMORY_INFORMATION_CLASS MemoryInformationClass, PVOID MemoryInformation, SIZE_T MemoryInformationLength, PSIZE_T ReturnLength)
{
	ULONG uRet = KrlEngine::m_NtQueryVirtualMemory(ProcessHandle, BaseAddress, MemoryInformationClass, MemoryInformation, MemoryInformationLength, ReturnLength);

	if ((::GetCurrentProcess() == ProcessHandle) && (0 == uRet))
	{
		if (MemoryBasicInformation == MemoryInformationClass)
		{
			if ((NULL != BaseAddress) && (NULL != MemoryInformation) && (NULL != g_hModule))
			{
				while (true)
				{
					DWORD dwBase = (DWORD)BaseAddress;
					bool bCall = false;

					if (((int)dwBase >= (int)g_hModule) && ((int)dwBase <= ((int)g_hModule + g_ModuleSize)))
					{
						bCall = true;
					}

					if (bCall)
					{
						PMEMORY_BASIC_INFORMATION pMemInfo = (PMEMORY_BASIC_INFORMATION)MemoryInformation;
						DWORD dwNextAddr = (DWORD)pMemInfo->BaseAddress + pMemInfo->RegionSize;

						uRet = KrlEngine::m_NtQueryVirtualMemory(ProcessHandle, (PVOID)dwNextAddr, MemoryInformationClass, MemoryInformation, MemoryInformationLength, ReturnLength);

						if (0 != uRet)
						{
							break;
						}
					}
					else
					{
						break;
					}
				}
			}
		}
		else if (MemoryRegionInformation == MemoryInformationClass)
		{
			if ((NULL != BaseAddress) && (NULL != MemoryInformation) && (NULL != g_hModule))
			{
				DWORD dwBase = (DWORD)BaseAddress;
				bool bCall = false;

				if (((int)dwBase >= (int)g_hModule) && ((int)dwBase <= ((int)g_hModule + g_ModuleSize))) {

					bCall = true;
				}

				if (bCall)
				{
					::ZeroMemory(MemoryInformation, MemoryInformationLength);
					uRet = 0xC0000141;
				}
			}
		}
	}

	return uRet;
}

最后于 2019-1-21 10:02 被yimingqpa编辑 ,原因:
2019-1-21 10:01
1
雪    币: 472
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
yimingqpa 下面再送一个 ZwQueryVirtualMemory 套餐(有坑):ULONG&nbsp;WINAPI&nbsp;My_NtQueryVirtualMemory(HAND ...
谢谢
2019-1-21 12:13
0
游客
登录 | 注册 方可回帖
返回
//