Skip to content

Instantly share code, notes, and snippets.

@binh12A3
Created July 31, 2021 09:12
Show Gist options
  • Save binh12A3/2e23777052d6d0d86beed12df14d3f75 to your computer and use it in GitHub Desktop.
Save binh12A3/2e23777052d6d0d86beed12df14d3f75 to your computer and use it in GitHub Desktop.
// dllmain.cpp : Defines the entry point for the DLL application.
#include <Windows.h>
typedef void(__cdecl* _Function1)();
_Function1 Func1;
typedef void(__cdecl* _Function2)(const char* str);
_Function2 Func2;
DWORD WINAPI MainThread(LPVOID param)
{
//Ep kieu (uintptr_t). Vi cai dll nay duoc goi trong chuong trinh luon --> NULL
//No se tra ve address cua model dang goi cai dll này
uintptr_t modelBase = (uintptr_t)GetModuleHandle(NULL);
Func1 = (_Function1)(modelBase + 0x12370);
Func2 = (_Function2)(modelBase + 0x123F0);
//loop until we press "END" key
while (!GetAsyncKeyState(VK_END))
{
if (GetAsyncKeyState(VK_NUMPAD2) & 1)
{
Func1();
}
if (GetAsyncKeyState(VK_NUMPAD3) & 1)
{
Func2("I'm a mother fucker hacker");
}
}
//Free memory
FreeLibraryAndExitThread((HMODULE)param, 0);
return 0;
}
BOOL WINAPI DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved )
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
CreateThread(0, 0, MainThread, hModule, 0, 0);
break;
}
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment