代码:

// 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;
}

运行结果:

C++获取(32位)Kernel32 LoadLibrary等地址,并写入txt文件_ios