使用GetProcAddress获取ZwUnmapViewOfSection函数指针

要想使用ZwUnmapViewOfSection函数,又没有安装驱动开发的工具包,可以从ntdll.dll里获取ZwUnmapViewOfSection的函数指针,代码如下:

#include 
#include 

int main()
{
	// 获取 ZwUnmapViewOfSection
	HMODULE hModuleNt = LoadLibrary("ntdll.dll");
	if (NULL == hModuleNt)
	{
		printf("获取ntdll句柄失败\n");
		getchar();
		return -1;
	}
	typedef DWORD(WINAPI *_TZwUnmapViewOfSection)(HANDLE, PVOID);
	_TZwUnmapViewOfSection pZwUnmapViewOfSection = (_TZwUnmapViewOfSection)GetProcAddress(hModuleNt, "ZwUnmapViewOfSection");
	if (NULL == pZwUnmapViewOfSection)
	{
		printf("获取ZwUnmapViewOfSection函数指针失败\n");
		getchar();
		return -1;
	}
	printf("成功获取函数指针\n");
	getchar();
    return 0;
}

你可能感兴趣的:(Windows)