Solved Pattern scan/Mid function hook errors

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

HelpMe

Newbie
Full Member
Jan 17, 2016
23
98
1
I get 2 errors, LNK2019 unresolved external symbol GetModuleInformation and error lnk1120. Full code:

main.cpp

#include <Windows.h>
#include <iostream>
#include "Hooks.h"


void InitiateHooks()
{
DWORD ammoAddy = FindPattern("ac_client.exe", "\x89\x0A\x8B\x76\x14\xFF\x0E", "xxxxxxx");
ammoAddy+=5;
ammoJmpBack = ammoAddy + 0x7;

PlaceJMP((BYTE*)ammoAddy, (DWORD)InfiniteAmmo, 7);


}




BOOL WINAPI DllMain(
HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpReserved)
{
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
InitiateHooks();

break;

}
return TRUE;

}

Functions.h

#include <Windows.h>
#include <iostream>
#include <TlHelp32.h>
#include <Psapi.h>


void PlaceJMP(BYTE *Address, DWORD jumpTo, DWORD length)
{
DWORD dwOldProtect, dwBkup, dwRelAddr;

VirtualProtect(Address, length, PAGE_EXECUTE_READWRITE, &dwOldProtect);

dwRelAddr = (DWORD) (jumpTo - (DWORD) Address) - 5;

*Address = 0xE9;

*((DWORD *)(Address + 0x1)) = dwRelAddr;

for(DWORD x = 0x5; x < length; x++)
*(Address + x) = 0x90;

VirtualProtect(Address, length, dwOldProtect, &dwBkup);

}

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;
}

Hooks.h

#include "Functions.h"


DWORD ammoJmpBack = 0;

__declspec(naked) void InfiniteAmmo()
{
__asm INC [ESI]
__asm push edi
__asm mov edi, [esp+0x14]

__asm jmp [ammoJmpBack]

}
 
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