Skip to content

Instantly share code, notes, and snippets.

Created December 11, 2015 16:05
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/81b11f1b3bdc06e1d56c to your computer and use it in GitHub Desktop.
Save anonymous/81b11f1b3bdc06e1d56c 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 double(__cdecl* worldToScreen)(double a1);
worldToScreen world;
DWORD mainaddr = (DWORD)GetModuleHandle(TEXT("eZ hack.exe"));
DWORD address = mainaddr + 0x1000;
double __cdecl h_worldToScreen(double a1)
{
a1 = 15.5;
std::cout << "Function2: This is function2." << std::endl;
return a1;
}
void HookFunctions()
{
static bool once = true;
if (once) {
once = false;
world = (worldToScreen) (address);
float a = world(5);
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)world, h_worldToScreen);
DetourTransactionCommit();
}
}
DWORD WINAPI blah(LPVOID lpParam)
{
while (true) {
Sleep(2500);
/*worldToScreen2(15,14,20);*/
/*printf("> Started.\n");*/
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();
/* MessageBox(0, (LPCWSTR)"1", (LPCWSTR)"2", MB_OK);*/
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
printf("> Started.\n");
DisableThreadLibraryCalls(GetModuleHandle(NULL));
//detour our functions
HookFunctions();
CreateThread(NULL, 0, blah, NULL, 0, 0);
/*a = GetCurrentProcess();*/
printf("> Threads Active.\n");
/*printf((char*)a);*/
}
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