Hi all,
here is my code to find the LoadlibraryA address from an exe, I want to write the return value to text file , but I cant figure out how to do that.Any help would be greatly appreciated.
#include <windows.h>
#include <tlhelp32.h>
#include <iostream>
#include <conio.h>
using namespace std;
char exe[MAX_PATH];
DWORD GetProcessIDFromName(LPSTR szProcName)
{
PROCESSENTRY32 procEntry;
HANDLE hSnapshot;
BOOL bFound;
if(!(hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0))) return 0;
procEntry.dwSize = sizeof(PROCESSENTRY32);
bFound = Process32First(hSnapshot, &procEntry);
while(bFound) {
if(!lstrcmp(procEntry.szExeFile, szProcName)) {
CloseHandle(hSnapshot);
return procEntry.th32ProcessID;
}
bFound = Process32Next(hSnapshot, &procEntry);
}
CloseHandle(hSnapshot);
return 0;
}
int main()
{
HANDLE hProc;
cout<<"EXE NAME := ";
cin>>exe;
DWORD dwPid = GetProcessIDFromName(exe);
hProc = OpenProcess(PROCESS_ALL_ACCESS, false, dwPid);
HANDLE address=GetProcAddress(GetModuleHandle("KERNEL32.DLL"), "LoadLibraryA");
CloseHandle(address);
cout<<address<<endl;
getch();
return 0;
}