Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3c892e242f8dc24aeb34 to your computer and use it in GitHub Desktop.
Save anonymous/3c892e242f8dc24aeb34 to your computer and use it in GitHub Desktop.
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <mmsystem.h>
#include "dllmain.h"
#include "detours.h"
#include <iostream>
#pragma comment (lib, "detours.lib")
typedef int (__thiscall* worldToScreen)(void *ptr,int a4, int a5, int a6);
worldToScreen world;
DWORD mainaddr = (DWORD)GetModuleHandle(TEXT("mb_warband.exe"));
DWORD address = mainaddr + 0x34CA0;
int __stdcall h_worldToScreen(void *ptr,int a4,int a5,int a6)
{
return world(ptr,a4,a5,a6);
}
DWORD WINAPI blah(LPVOID lpParam)
{
while (true)
{
Sleep(2500);
static bool once = true;
if (once)
{
once = false;
world = (worldToScreen)(address);
void *ptr = (void*)0x8E3120;
int a = world(ptr,0xA633F0,0xC6AFB58,0);
std::cout << "Function2: This ." << a << std::endl;
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)world, h_worldToScreen);
DetourTransactionCommit();
}
if (GetAsyncKeyState(VK_INSERT) & 1)
{
MessageBox(0, "DLLINJECTED", "2", MB_OK);
}
Sleep(5);
}
return 0;
}
BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
AllocConsole();
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
printf("> Started.\n");
DisableThreadLibraryCalls(GetModuleHandle(NULL));
CreateThread(NULL, 0, blah, NULL, 0, 0);
printf("> Threads Active.\n");
}
else if (dwReason == DLL_PROCESS_DETACH)
{
Sleep(500);
}
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment