Solved I inject DLL but nothing happens

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

FloppyWhale

Jr.Coder
Full Member
Nobleman
Jan 12, 2015
65
308
0
Hello! After reading many tutorials here I decided to make a quick little ammo hack for Assault Cube. When I inject the DLL, nothing happens...

Here's my code :
C++:
#include <Windows.h>
#include <iostream>

HANDLE curProc = GetCurrentProcess();

DWORD ammoAddress = 004637E9;
int newAmmo = 999999;

DWORD WINAPI doMyHacks()
{
	MessageBoxA(NULL, "You're Attached!", "Hi There!", MB_OK);
	WriteProcessMemory(curProc, (LPVOID)ammoAddress, &newAmmo, sizeof(newAmmo), NULL);
	return true;
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
	if (dwReason == DLL_PROCESS_ATTACH)
	{
		CreateThread(0, 0, (LPTHREAD_START_ROUTINE)doMyHacks, 0, 0, 0);
	}
	return TRUE;
}
 

Broihon

edgy 12 y/o
Escobar Tier VIP
Fleep Tier Donator
Dec 22, 2013
1,745
40,528
316
Hello! After reading many tutorials here I decided to make a quick little ammo hack for Assault Cube. When I inject the DLL, nothing happens...

Here's my code :
C++:
#include <Windows.h>
#include <iostream>

HANDLE curProc = GetCurrentProcess();

DWORD ammoAddress = 004637E9;
int newAmmo = 999999;

DWORD WINAPI doMyHacks()
{
	MessageBoxA(NULL, "You're Attached!", "Hi There!", MB_OK);
	WriteProcessMemory(curProc, (LPVOID)ammoAddress, &newAmmo, sizeof(newAmmo), NULL);
	return true;
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
	if (dwReason == DLL_PROCESS_ATTACH)
	{
		CreateThread(0, 0, (LPTHREAD_START_ROUTINE)doMyHacks, 0, 0, 0);
	}
	return TRUE;
}
The DllMain looks correct. The MessageBox should appear. What injector are you using?
Also the hacking part itself look weird to me. How did you get that address? Ammo should be 4-byte aligned (0/4/8/C as last digit of the address). Also the ammo isn't static but dynamic.
Since a DLL is internal there's no need for nasty Read-/WriteProcessMemory.
Internal you can read write data like this:
C++:
//Read:
DataType Foo = *(DataType*)Address;

//Write
*(DataType*)Address = Value;
Btw. better use CPP tags instead of CODE tags.
 

FloppyWhale

Jr.Coder
Full Member
Nobleman
Jan 12, 2015
65
308
0
Вroihon;40150 said:
The DllMain looks correct. The MessageBox should appear. What injector are you using?
Also the hacking part itself look weird to me. How did you get that address? Ammo should be 4-byte aligned (0/4/8/C as last digit of the address). Also the ammo isn't static but dynamic.
Since a DLL is internal there's no need for nasty Read-/WriteProcessMemory.
Internal you can read write data like this:
C++:
//Read:
DataType Foo = *(DataType*)Address;

//Write
*(DataType*)Address = Value;
Btw. better use CPP tags instead of CODE tags.
Sorry it's my first post and thanks!
 

FloppyWhale

Jr.Coder
Full Member
Nobleman
Jan 12, 2015
65
308
0
I'm still having problems. This time it's crashing once the DLL is injected. I'm using Extreme Injector aswell.

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

DWORD WINAPI doMyHacks()
{
	MessageBoxA(NULL, "You're Attached!", "Hi There!", MB_OK);

	//Read Memory
	DWORD ammoAddress = *(DWORD*)0x4637E9;
	//Write Memory
	*(DWORD*)ammoAddress = 999999;

	return true;
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
	if (dwReason == DLL_PROCESS_ATTACH)
	{
		CreateThread(0, 0, (LPTHREAD_START_ROUTINE)doMyHacks, 0, 0, 0);
	}
	return TRUE;
}
The address I got was the pointer for ammo. I don't know how to check if it's correct either :(
 
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