// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "pch.h"
#include <stdio.h>
#include <tchar.h>
#include <exception>
#include <wchar.h>
#include <windows.h>
void process_attach(HMODULE hModule) {
MessageBox(0, TEXT("注入成功!"), TEXT("Warning"), MB_ICONWARNING);
try {
//通过GetModuleHandleA(0)找到进程的加载地址
HANDLE ExeBaseAddress = GetModuleHandleA(0);
uintptr_t* p = (uintptr_t*)((uintptr_t)ExeBaseAddress + 0xD1C99);
// uintptr_t ModuleBaseAdrs = (DWORD&)*p;
// uintptr_t* p = (uintptr_t*)((uintptr_t)fmd);
// uintptr_t* p = (uintptr_t*)((uintptr_t)hModule + 0xD1C99);
char* name = (char*)0x0057EE9C;
name = (char*)"方东信";
char dada[100];
sprintf_s(dada, "0xD1C99 val:%x", *p);
MessageBoxA(0, dada, "Warning", MB_ICONWARNING);
sprintf_s(dada, "0x0057EE9C val: %s", ((char *)0x0057EE9C) );
MessageBoxA(0, dada, "Warning", MB_ICONWARNING);
}
catch (std::exception &e) {
MessageBox(0, TEXT("出现了异常"), TEXT("Warning"), MB_ICONWARNING);
}
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
process_attach( hModule);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
标签:uintptr,dada,dll,char,偏移,TEXT,include,DLL,加载
From: https://www.cnblogs.com/cfas/p/17153108.html