Results 1 to 7 of 7
  1. #1
    Ethede's Avatar
    Join Date
    Feb 2017
    Gender
    male
    Posts
    91
    Reputation
    10
    Thanks
    37
    My Mood
    Cheerful

    My trainer doesn't work

    Hello, I've created an AOB trainer recently, dllmain code:
    Code:
    #include "stdafx.h"
    #include <Windows.h>
    #include <iostream>  
    #include "Memory.h"
    using namespace std;
    
    void ChangeMemory(DWORD baseadress, int value, DWORD offset1, DWORD offset2, bool msg)
    {
    	DWORD d, ds;
    	DWORD* adress = (DWORD*)((*(DWORD*)(baseadress + offset1)) + offset2);	
    
    	if (msg)
    	{
    		char szTest[10] ;
    		sprintf_s(szTest, "The final adress is : %X", adress);
    		MessageBoxA(NULL,szTest , NULL, NULL);
    	}
    
    	*(int*)adress = value;
    }
    void PatchAOB(char* pattern, char* mask, char* processname, bool msg, char* valuetowrite, int size, int position)
    {
    	
    	DWORD pVariable = FindPattern(processname, pattern, mask);
    	pVariable += position;	
    	if (pVariable != 0)
    	{
    		WriteToMemory(pVariable, valuetowrite, size);
    	}
    	else
    	{
    		MessageBoxA(NULL,"Something has gone wrong. :/" , NULL, NULL);
    	}
    	
    
    }
    
    DWORD Patch()
    {
    	PatchAOB("\xEB\x03\x8B\x45\x08\xC9\xC3\x00\x00\x00\x00\x00\x55\x8B\xEC", "xxxxxxxxxxxxxxx", "Game.exe", true, "\x90\x90", 2, 0);
    	return NULL;
    }
    
    BOOL APIENTRY DllMain( HMODULE hModule,
                           DWORD  ul_reason_for_call,
                           LPVOID lpReserved
    					 )
    {
    	switch (ul_reason_for_call)
    	{
    	case DLL_PROCESS_ATTACH:
    		CreateThread(0,0,(LPTHREAD_START_ROUTINE)Patch,0,0,0);
                break;
    	case DLL_THREAD_ATTACH:
    	case DLL_THREAD_DETACH:
    	case DLL_PROCESS_DETACH:
    		break;
    	}
    	return TRUE;
    }
    Memory.h
    Code:
    #include <iostream>
    #include <Windows.h>
    #include <tlhelp32.h>
    #include <Psapi.h>
    
    void WriteToMemory(uintptr_t addressToWrite, char* valueToWrite, int byteNum)
    {
    	unsigned long OldProtection;
    	VirtualProtect((LPVOID)(addressToWrite), byteNum, PAGE_EXECUTE_READWRITE, &OldProtection);
    	memcpy( (LPVOID)addressToWrite, valueToWrite, byteNum);
    	VirtualProtect((LPVOID)(addressToWrite), byteNum, OldProtection, NULL);
    }
    
    MODULEINFO GetModuleInfo( char *szModule )
    {
    	MODULEINFO modinfo = {0};
    	HMODULE hModule = GetModuleHandle(szModule);
    	if(hModule == 0) 
    		return modinfo;
    	GetModuleInformation(GetCurrentProcess(), hModule, &modinfo, sizeof(MODULEINFO));
    	return modinfo;
    }
    
    DWORD FindPattern(char *module, char *pattern, char *mask)
    {
    	MODULEINFO mInfo = GetModuleInfo(module);
    	DWORD base = (DWORD)mInfo.lpBaseOfDll;
    	DWORD size =  (DWORD)mInfo.SizeOfImage;
    
    	DWORD patternLength = (DWORD)strlen(mask);
    
    	for(DWORD i = 0; i < size - patternLength; i++)
    	{
    		bool found = true;
    		for(DWORD j = 0; j < patternLength; j++)
    		{
    			found &= mask[j] == '?' || pattern[j] == *(char*)(base + i + j);
    		}
    
    		if(found) 
    		{
    			return base + i;
    		}
    	}
    
    	return NULL;
    }
    I'm only using the AOB patching function, ignore the others in dllmain.
    It doesn't detect the signature and shows that message box, but I'm sure it does exist. Checked multiple times with OllyDbg.
    Note: The game is a Unity3D one.
    Any help is appreciated, thanks!
    Last edited by Ethede; 04-12-2017 at 03:48 AM.

  2. #2
    Biesi's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    4,993
    Reputation
    374
    Thanks
    8,808
    My Mood
    Twisted
    Are you sure your mask is supposed to be 'xxxxxxxxxxxxxxx'? Are there no unknown bytes in the pattern?

  3. #3
    Ethede's Avatar
    Join Date
    Feb 2017
    Gender
    male
    Posts
    91
    Reputation
    10
    Thanks
    37
    My Mood
    Cheerful
    Quote Originally Posted by Biesi View Post
    Are you sure your mask is supposed to be 'xxxxxxxxxxxxxxx'? Are there no unknown bytes in the pattern?
    Yes, the pattern doesn't change each time I restart the game.

    Update: Tried "\xEB\x03\x8B\x45\x08\xC9\xC3" with xxxxxxx and didn't work either.
    Does it have something to do with Unity?
    Last edited by Ethede; 04-12-2017 at 04:05 AM.

  4. #4
    Annet's Avatar
    Join Date
    Oct 2016
    Gender
    female
    Location
    Moscow city
    Posts
    3
    Reputation
    10
    Thanks
    0
    1) Are you sure that game already unpacked when you trying to inject dll?
    2) I just noticed a little bug in PatchAOB:
    If you set position argument > 0, even if nothing found, pVariable became that offset, so program will crash because of writing invalid memory
    So you can fix it:
    Code:
    void PatchAOB(char* pattern, char* mask, char* processname, bool msg, char* valuetowrite, size_t size, size_t position)
    {
    	if (auto addr = pVariable = FindPattern(processname, pattern, mask))
    	{
    		addr += position;
    		WriteToMemory(addr, valuetowrite, size);
    	}
    	else MessageBoxA(NULL,"Something has gone wrong. :/" , NULL, NULL);
    }

  5. #5
    Ethede's Avatar
    Join Date
    Feb 2017
    Gender
    male
    Posts
    91
    Reputation
    10
    Thanks
    37
    My Mood
    Cheerful
    Quote Originally Posted by Annet View Post
    1) Are you sure that game already unpacked when you trying to inject dll?
    2) I just noticed a little bug in PatchAOB:
    If you set position argument > 0, even if nothing found, pVariable became that offset, so program will crash because of writing invalid memory
    So you can fix it:
    Code:
    void PatchAOB(char* pattern, char* mask, char* processname, bool msg, char* valuetowrite, size_t size, size_t position)
    {
    	if (auto addr = pVariable = FindPattern(processname, pattern, mask))
    	{
    		addr += position;
    		WriteToMemory(addr, valuetowrite, size);
    	}
    	else MessageBoxA(NULL,"Something has gone wrong. :/" , NULL, NULL);
    }
    Hi, thanks for willing to help.
    1) Yes, tried with cheat engine and it detects the pattern.
    2) Still showing me the message box. :/

  6. #6
    Zaczero's Avatar
    Join Date
    Oct 2013
    Gender
    male
    Location
    localhost
    Posts
    3,288
    Reputation
    1517
    Thanks
    14,263
    My Mood
    Angelic
    You can use WinApi's mouse_event.
    It works perfectly for me !
    https://msdn.microsof*****m/pl-pl/lib...(v=vs.85).aspx
    . . . malsignature.com . . .



    [ global rules ] [ scam report ] [ image title ] [ name change ] [ anime force ]
    [ league of legends marketplace rules ] [ battlefield marketplace rules ]

    "because everytime you post a picture of anime in here
    your virginity's time increases by 1 month"
    ~Smoke 2/18/2018


    Former Staff 09-29-2018
    Battlefield Minion 07-21-2018
    Premium Seller 03-04-2018
    Publicist 12-10-2017
    League of Legends Minion 05-31-2017
    Premium 02-05-2017
    Member 10-13-2013

  7. #7
    samlarenskoog's Avatar
    Join Date
    Apr 2016
    Gender
    male
    Posts
    104
    Reputation
    25
    Thanks
    57
    My Mood
    Cheerful
    If the pattern is correctly found, the message box should not be shown. Are you sure that your dll is detecting the pattern?

Similar Threads

  1. Bypass 2.5 Doesn't Work with My Vista! HELP!!!
    By saefine in forum Combat Arms Hacks & Cheats
    Replies: 10
    Last Post: 02-13-2009, 07:58 AM
  2. HALP! MY CA DOESN"T WORK! Plz help
    By apeguy in forum Combat Arms Hacks & Cheats
    Replies: 7
    Last Post: 08-13-2008, 07:37 PM
  3. MHS SPIRO doesn't work nomore
    By azngamerboi9 in forum Combat Arms Hacks & Cheats
    Replies: 9
    Last Post: 07-31-2008, 07:00 PM
  4. SWIM CODE and GUN CODE, DOESN'T WORK ??
    By h4x0r m3mb3r in forum WarRock - International Hacks
    Replies: 4
    Last Post: 07-26-2007, 01:57 AM
  5. Hacks doesn't work anymore?
    By jorisy00 in forum WarRock - International Hacks
    Replies: 9
    Last Post: 02-23-2007, 09:55 AM