Solved C++ Sig Scanning DLL Injection Help

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

TheGreatUnknown

Jr.Coder
Full Member
Nobleman
Dec 20, 2012
58
417
1
I've been learning C++ for about 2-3 months now so I'm some what getting there, I decided to give dll injection and sig scanning a go. I followed fleeps tutorial but whenever I try to inject my dll I get this from RemoteDLL (I've tried running it as admin as well). "LoadLibrary on remove process failed [ 159416 - ac_client.exe] failed. Try running RemoteDll as Administrator... also Fleeps dll works fine so I have no idea why mine isn't.

Here is my code, functions.h:
C++:
#include <iostream>
#include <windows.h>
#include <TlHelp32.h>
#include <Psapi.h>
using namespace std;

//Print our pattern scan results if necessary
void MsgBoxAddy(DWORD addy)
{
	char szBuffer[1024];
	sprintf(szBuffer, "Addy: %02x", addy);
	MessageBox(NULL, szBuffer, "Title", MB_OK);
}

//Get all module related info, this will include the base DLL. 
//and the size of the module
MODULEINFO GetModuleInfo(char * szModule)
{
	MODULEINFO modinfo = {0};
	HMODULE hModule = GetModuleHandle (szModule);
	if(hModule == 0)
		
		GetModuleInformation(GetCurrentProcess(), hModule, &modinfo, sizeof(MODULEINFO));
		return modinfo;
	
}

void WriteToMemory(uintptr_t addressToWrite, char* valueToWrite, int bytenum)
{
	//used to change our file access type, stores the old
	//access type and restores it after memory is written
	unsigned long oldProtection;
	//give that address read and write permissions and store the old permissions at oldProtection
	VirtualProtect((LPVOID)(addressToWrite), bytenum, PAGE_EXECUTE_READWRITE, &oldProtection);

	//write the memory into the program and overwrite previous value
	memcpy((LPVOID)(addressToWrite), valueToWrite, bytenum);

	//reset the permissions of the address back to oldProtection after witting memory
	VirtualProtect((LPVOID)(addressToWrite), bytenum, oldProtection, NULL);
}

DWORD FindPattern(char *module, char* pattern, char* mask)
{
	//Get all module related information
	MODULEINFO mInfo = GetModuleInfo(module);

	//Assign our base and module size
	//Having the values right is ESSENTIAL, this makes sure
	//that we don't scan unwanted memory and leading our game to crash
	DWORD base = (DWORD)mInfo.lpBaseOfDll;
	DWORD size = (DWORD)mInfo.SizeOfImage;

	//Get length for our mask, this will allow us to loop through our array
	DWORD patternLengh = (DWORD)strlen(mask);

	for(DWORD i = 0; i < size - patternLengh; i++) // increments byte scanning in case pattern doesn't match pattern
	{
		bool found = true;
		for(DWORD j = 0; j < patternLengh; j++)
		{
			//if we have a ? in our mask then we have true by default, 
			//or if the bytes match then we keep searching until finding it or not
			found &= mask[j] == '?' || pattern[j] == *(char*)(base+i+j);
		}

		//found = true, our entire pattern was found
		//return the memory addy so we can write to it
		if(found)
		{
			return base+i;
	}

	}

	return NULL;
}
And source:

C++:
#include "Functions.h"
#include <iostream>
#include <Windows.h>

char AmmoOpCode[] = "\x90\x90"; // 2bytes to nop ammo

void InitiateHooks()
{
	DWORD ammoAddy = FindPattern("ac_client.exe",
	"\x89\x0A\x8B\x76\x14\xFF\x0E\x57\x8B\x7C\x24\x14\x8D\x74\x24\x28\xE8\x00\x00\x00\x00",
	"xxxxxxxxxxxxxxxxx????");

	ammoAddy+=5;

	MsgBoxAddy(ammoAddy);
	WriteToMemory(ammoAddy,AmmoOpCode, 2); // 2bytes of memory to nop


}

BOOL WINAPI DllMain(
	HINSTANCE hinstDLL,  // handle to DLL module
	DWORD fdwReason,     // reason for calling function
	LPVOID lpReserved)     // reserved
{
	// Perform actions based on the reason for calling.
	switch(fdwReason)
	{
	case DLL_PROCESS_ATTACH:
		// Initialize once for each new process.
		// Return FALSE to fail DLL load.
		//MessageBoxA(NULL, "Attached successfully", "", 0);
		InitiateHooks();
		break;
	}
	// Successful DLL_PROCESS_ATTACH.
	return TRUE;
}
 
Last edited:

dmo

Coder
Full Member
Nobleman
Nov 8, 2014
145
678
5
What is you "UAC" level in Windows?

I think you need to change token privileges using OpenProcessToken();
 
Last edited:
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods