[Asm] 纯文本查看 复制代码 // 5566.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<stdio.h>
#include<windows.h>
#include <psapi.h>//居然修改成功了 加了一堆的宏定义
#include <cassert>
#include <cstdio>
#include <iostream>
#include <TlHelp32.h>
#include <vector>
using namespace std;
HANDLE FindProcessByName(const char* name)
{
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(PROCESSENTRY32);
HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcessSnap == INVALID_HANDLE_VALUE)
{
return NULL;
}
if (Process32First(hProcessSnap, &pe32))
{
do
{
if (strcmp(pe32.szExeFile, name) == 0)
{
CloseHandle(hProcessSnap);
return OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);
}
} while (Process32Next(hProcessSnap, &pe32));
}
CloseHandle(hProcessSnap);
return NULL;
}
/**
* [url=home.php?mod=space&uid=190858]@brief[/url] 枚举指定进程所有内存块
* [url=home.php?mod=space&uid=952169]@Param[/url] hProcess [in] 要枚举的进程,至少需拥有PROCESS_QUERY_INFORMATION权限
* @param memories [out] 返回枚举到的内存块数组
* [url=home.php?mod=space&uid=155549]@Return[/url] 成功返回true,失败返回false.
*/
int main(int argc, char* argv[])
{
HANDLE hProcess = FindProcessByName("trashcleaner.exe");
if (hProcess == NULL)
{
printf("FindProcessByName failed\n");
return -1;
}
// 获取每一个模块加载基址
DWORD pro_base = NULL;
DWORD prodll_base = NULL;
HMODULE hModule[100] = { 0 };
DWORD dwRet = 0;
int num = 0;
int bRet = EnumProcessModulesEx(hProcess, (HMODULE *)(hModule), sizeof(hModule), &dwRet, NULL);
if (bRet == 0){
printf("EnumProcessModules");
}
// 总模块个数
num = dwRet / sizeof(HMODULE);int ii;
printf("总模块个数: %d\n", num);
// 打印每一个模块加载基址
char lpBaseName[100];
for (int i = 0; i < num; i++){
GetModuleBaseNameA(hProcess, hModule[i], lpBaseName, sizeof(lpBaseName));
printf("%-2d %-25s基址: 0x%p\n", i, lpBaseName, hModule[i]);
char str2[100] = "edobjectmodule.dll";
if (strcmp(lpBaseName, str2) == 0)//留着后面解决吧 输入了 == 号 就运行正常了
{
printf("//////////////////////%-2d %-25s基址: 0x%p\n///////////////////", i, lpBaseName, hModule[i]);
ii = i;
}
}
pro_base = (DWORD)hModule[0]; prodll_base = (DWORD)hModule[49];
printf("程序基址: 0x%p\n", pro_base); printf("基址: 0x%p\n", prodll_base);
printf("Hello World!\n");
return 0;
}
C:\Program Files (x86)\Microsoft Visual Studio\VC98\Include 放入附件新的Psapi.h
C:\Program Files (x86)\Microsoft Visual Studio\VC98\Lib 放入附件新的Kernel32.lib |