C ++ acquiring (32) Kernel32 LoadLibrary like address, and write txt file

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/Giser_D/article/details/91045760

Code:

// GetKernel32Info.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	ofstream txtfile;
	txtfile.open(".\\kernel32info.txt",std::ios::out | std::ios::app);//创建kernelinfo.txt文本
	
	fstream(".\\kernel32info.txt",ios::out); //清空文本信息

	//重新写入信息
	HMODULE hMoudule = GetModuleHandle(L"kernel32.dll"); //获取kernel32.dll的句柄
	txtfile << "LoadLibraryA Address:";
	txtfile << (DWORD)GetProcAddress(hMoudule,"LoadLibraryA");
	txtfile << "\n";

	txtfile << "GetProcAddress Address:";
	txtfile << (DWORD)GetProcAddress(hMoudule,"GetProcAddress");
	txtfile << "\n";
	
	txtfile << "ExitThread Address:";
	txtfile << (DWORD)GetProcAddress(hMoudule,"ExitThread");
	txtfile << "\n";

	txtfile << "FreeLibraryAndExitThread Address:";
	txtfile << (DWORD)GetProcAddress(hMoudule,"FreeLibraryAndExitThread");
	txtfile << "\n";

	txtfile.close();

	return 0;
}

operation result:

Source Address: https://download.csdn.net/download/giser_d/11229336

Guess you like

Origin blog.csdn.net/Giser_D/article/details/91045760