Solved Question regarding the pattern scan code / general DLL injection & memorywriting

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

prycx

Newbie
Full Member
Nov 10, 2014
9
82
0
Solved :) thanks to everybody involved & special thanks to Cryslacks


First of all, I'm not a native speaker and I did this to the best of my ability.
Hey guys. I just viewed the tutorial on patternscanning, I did build a dll for the game Binding of Isaac Rebirth,
i found the right adress manually, and it works if I NOP the things I want NOP'd manually in CE or Ollydbg, but if I use Fleeps code, the values do not change. Neither if I use the patternscan or the 'direct' method. I am falling apart here. my
C++:
#include <iostream>
#include <Windows.h>
#include <tlhelp32.h>
#include <Psapi.h>



void MsgBoxAddy(DWORD addy)
{
	char szBuffer[100];
	sprintf_s(szBuffer,sizeof(szBuffer), "Addy: %02x", addy);
	MessageBox(NULL, szBuffer, "Title", MB_OK);

}



MODULEINFO GetModuleInfo(char *szModule)
{
	MODULEINFO modinfo = { 0 };
	HMODULE hModule = GetModuleHandle(szModule);
	if (hModule == 0)
		return modinfo;
	GetModuleInformation(GetCurrentProcess(), hModule, &modinfo, sizeof(MODULEINFO));
	return modinfo;
}


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


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

And now the main.cpp I seared in this forum for quite some time but I didn't seem to find the right answer.
The inject is successful (regarding to Extreme Injector v3.3) but the memory is not getting changed (checked with olly) PLEASE help me :(
Used multiple Injectors
C++:
#include <iostream>
#include <Windows.h>
#include "functions.h"

char HpDecOpCode[] = "\x90\x90";

void invulnerability()
{
	/*DWORD HpDecAddy = FindPattern("isaac-ng.exe",
		"\x29\x06\xEB\x78\x8B\x83\x00\x00\x00\x00",
		"xxxxxx????");

	HpDecAddy+=2;
	MsgBoxAddy(HpDecAddy);

	WriteToMemory(HpDecAddy, HpDecOpCode, 2);
*/
	WriteToMemory(0x0119F637, "\x90\x90", 2); 
}





BOOL WINAPI dllMain(
	HINSTANCE hinstDLL, 
	DWORD fdwReason,     
	LPVOID lpReserved)     
{
	
	switch (fdwReason)
	{
	case DLL_PROCESS_ATTACH:
		invulnerability();
		break;
	}
	return TRUE;
}
 
Last edited by a moderator:

Cryslacks

<>>>
Dank Tier Donator
Nobleman
Dec 10, 2013
132
1,198
8
Nope. It was my second try. to give out the thing manually. look if you can't help. don't comment. do you think I'm stupid or what?
If that isnt help then you are not searching for help, your searching for source code.
Thats what i think.

On-Topic:
Have you tried many different injectors?
Because that injector your using may not work.

Is it a x64 or x86 game?

Try just doing another dll with something like this:
C++:
void Startup();

BOOL WINAPI DllMain( _In_  HINSTANCE hinstDLL,  _In_  DWORD fdwReason,  _In_  LPVOID lpvReserved)
{
  Startup();

  Return true;
}

void Startup()
{
  if(GetAsyncKeyState(VK_F3))
  {
    MessageBox(NULL, "Test", "Title", 0);
  }
}
Learn how to make DLL hacks correctly:
https://guidedhacking.com/threads/how-to-hack-any-game-first-internal-hack-dll-tutorial.12142/
 
Last edited by a moderator:

Liduen

Hacker
Dank Tier VIP
May 19, 2013
702
8,478
33
Did the call of
C++:
void MsgBoxAddy(DWORD addy)
printed the correct address?

If yes, then something is wrong with your memory writing part.
If no, then something is wrong with your find pattern method or memory writing part.

Because of the fact that you said that even
C++:
WriteToMemory(0x0119F637, "\x90\x90", 2);
didn't work, I guess that something is wrong with your memory writing method.
 
Last edited:

prycx

Newbie
Full Member
Nov 10, 2014
9
82
0
C++:
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);
}
it printed nothing. it didn't even show up. I got the code from the fleep tutorial ;s
can someone help me? i did as fleep did
 

Liduen

Hacker
Dank Tier VIP
May 19, 2013
702
8,478
33
C++:
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);
}
it printed nothing. it didn't even show up. I got the code from the fleep tutorial ;s
can someone help me? i did as fleep did
So did you get a valid address (0x0119F637) in the message box or not?
 

prycx

Newbie
Full Member
Nov 10, 2014
9
82
0
as I said it printed nothing, the msgbox didn't even show up and I can't seem to find a flaw in the code. Atleast i am too dumb to spot one.
 

prycx

Newbie
Full Member
Nov 10, 2014
9
82
0
Im looking at the code and I think you forgot to uncomment the MsgBox
Nope. It was my second try. to give out the thing manually. look if you can't help. don't comment. do you think I'm stupid or what?
 

Liduen

Hacker
Dank Tier VIP
May 19, 2013
702
8,478
33
This is a problem which can be solved perfectly by only using trial and error.

I think there is no need for us to help you, because if you understood the code you posted, then you should be able to find the problem yourself ;)
 

prycx

Newbie
Full Member
Nov 10, 2014
9
82
0
Are you sure the DLL gets loaded properly?
Put AllocConsole() at the beginning of the DllMain.
If no console shows up the injector failed because the code looks correct.
Did you start the injector as admin?
Yea it doesn't show up. But the injector calls a success and that would mean that the dllMain returned true. Or am I mistaking? I tried 2 or 3 injectors and none of them showed me a problem
 

prycx

Newbie
Full Member
Nov 10, 2014
9
82
0
If that isnt help then you are not searching for help, your searching for source code.
Thats what i think.

On-Topic:
Have you tried many different injectors?
Because that injector your using may not work.

Is it a x64 or x86 game?

Try just doing another dll with something like this:
C++:
void Startup();

BOOL WINAPI DllMain( _In_  HINSTANCE hinstDLL,  _In_  DWORD fdwReason,  _In_  LPVOID lpvReserved)
{
  Startup();

  Return true;
}

void Startup()
{
  if(GetAsyncKeyState(VK_F3))
  {
    MessageBox(NULL, "Test", "Title", 0);
  }
}
Written on my phone, may not be precise.
Yea sorry, I was stressed at work and I kinda overshot my tone.
it is a x86 game.

edit: something seems to be wrong here, I do inject it, yet the test msgbox doesn't come up. is that a sign that the program prevents something? or is it a problem with the code?
and if the game does prevent something, is there a way to find that out and bypass that?

edit: I commented out the
C++:
 if(GetAsyncKeyState(VK_F3))
so only the then the msgbox showed up. Could you explain that get function? It seems weird to me.

edit: played around with your code. your dll main seems to be a lot smoother than mine (fleeps)
it runs like a charm and with the code
C++:
BOOL WINAPI DllMain(_In_  HINSTANCE hinstDLL, _In_  DWORD fdwReason, _In_  LPVOID lpvReserved)
{
	//Startup();
	invulnerability();
	return true;
}
it gives me the right addy in the right addy.
I can work with that :)
thank you a lot.
If you have a minute or two could you explain me the differences between your dll main and mine (fleeps)
and the reason for the usage of _In_ ?
would be nice.
Thanks a lot for helping me out here :)
 
Last edited:

Cryslacks

<>>>
Dank Tier Donator
Nobleman
Dec 10, 2013
132
1,198
8
Yea sorry, I was stressed at work and I kinda overshot my tone.
it is a x86 game.

edit: something seems to be wrong here, I do inject it, yet the test msgbox doesn't come up. is that a sign that the program prevents something? or is it a problem with the code?
and if the game does prevent something, is there a way to find that out and bypass that?
Try pressing F3 when injected.

If that doesnt work then try deleting the .dll when you have injected it.
If it deletes then the injection failed.
 

prycx

Newbie
Full Member
Nov 10, 2014
9
82
0
Well as long as it works now I'm happy. Glad you showed me that :) have a nice day :)
 
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