Solved Dll injection, fail to read memory

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

j3b

Jr.Coder
Full Member
Nobleman
Dec 18, 2012
67
408
1
Hello. Donno if this is the right section to post....BUT!

Been doing external cheats for CSGO. And now i wanted to try something new, dll injection.
I want to read the games memory, and since im "inside" the games memory, i just read as :.


C++:
clientDll = (DWORD)GetModuleHandle("client.dll");
	Local = clientDll + Player_base;  //Player_base = 0x.... 
	LocalPlayer = *(DWORD*)Local;

	myHealth = (DWORD*)(LocalPlayer + dwHealth);
cout<<*myHealth;
This works very well, it prints out my health and soo on.

Problem is that when im not on a server, the game crashes..
And i dont really know why? myHealth must get some value that isnt a int?
Is there a way to "bypass" this, so it does not crash?

Been also reading the same way, but for the other players on the server. It works, prints out every enemys health 1 time, but then it crashes.
 

Nether

The Angel Of Verdun
Meme Tier VIP
Dank Tier Donator
Dec 11, 2013
293
3,738
16
perhaps your health is loaded into a different module if your on a different server than localhost, or if your reffering to it not working when not in game then its not likley not initizalied and your reading a NULL Pointer.

to solve null pointer.

C++:
if(myHealth)
   cout << *myHealth << endl;
i would also recomend writing your local like this:

C++:
CLocalPlayer *Player = *(CLocalPlayer**)((DWORD)GetModuleHandleA("client.dll") + 0x7A4DF0);
replace my random offset with your correct one (CLocalPlayer Is My Class, I would also REcommend using Re-Class If you havent yet)

then you can just use this example if your using re-class or any sort of class that holds your offsets.

C++:
if (Player)
   cout << Player->myHealth << endl;
 
Last edited:

j3b

Jr.Coder
Full Member
Nobleman
Dec 18, 2012
67
408
1
perhaps your health is loaded into a different module if your on a different server than localhost, or if your reffering to it not working when not in game then its not likley not initizalied and your reading a NULL Pointer.

to solve null pointer.

C++:
if(myHealth)
   cout << *myHealth << endl;
i would also recomend writing your local liek this:

C++:
CLocalPlayer *Player = *(CLocalPlayer**)((DWORD)GetModuleHandleA("client.dll") + 0x7A4DF0);
replace my random offset with your correct one (CLocalPlayer Is My Class, I would also REcommend using Re-Class If you havent yet)

then you can just use this example if your using re-class or any sort of class that holds your offsets.

C++:
if (Player-myHealth)
   cout << *Player->myHealth << endl;
I will try this one. Yes, ive heard of Reclass, but i just want to try this way.
I will be back if this still crashes the game :<

Edit : Its crashing when im just in the lobby in CSGO.
 
Last edited:

Nether

The Angel Of Verdun
Meme Tier VIP
Dank Tier Donator
Dec 11, 2013
293
3,738
16
I will try this one. Yes, ive heard of Reclass, but i just want to try this way.
I will be back if this still crashes the game :<

Edit : Its crashing when im just in the lobby in CSGO.
sorry i failed with editing on that last post the forum wasnt working correctly when i tried to edit it, ive updated my previous post, please let met know if you have errors still.
 

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
As Nether already said, it could be that another entity pointer or just pointer to your playerbase which is being used in multiplayer..

Just put out the value that the pointer holds, if it's 0 just add a

if (pointer != 0)
{
....
}

Or find the correct multiplayer pointer..
 

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
People say that IsBadReadPtr wouldn't be so good so rather go for a not outdated function :)
 

rN'

Jr.Hacker
Meme Tier VIP
Jan 19, 2014
340
5,268
41
C++:
int CBaseEntity::m_iHealth( void )
{
	return *reinterpret_case<int>*( dwEntity + 0x90 );
}
works for meeeh
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,140
78,998
2,394
C++:
if(!IsBadReadPtr ( (DWORD*) LocalPlayer, sizeof ( (DWORD*) LocalPlayer )))
{
    //your code
}
Straight from MSDN:

MSDN said:
IsBadReadPtr function

Verifies that the calling process has read access to the specified range of memory.

Important This function is obsolete and should not be used. Despite its name, it does not guarantee that the pointer is valid or that the memory pointed to is safe to use. For more information, see Remarks on this page.

Remarks

This function is typically used when working with pointers returned from third-party libraries, where you cannot determine the memory management behavior in the third-party DLL.
Threads in a process are expected to cooperate in such a way that one will not free memory that the other needs. Use of this function does not negate the need to do this. If this is not done, the application may fail in an unpredictable manner.
Dereferencing potentially invalid pointers can disable stack expansion in other threads. A thread exhausting its stack, when stack expansion has been disabled, results in the immediate termination of the parent process, with no pop-up error window or diagnostic information.
If the calling process has read access to some, but not all, of the bytes in the specified memory range, the return value is nonzero.
In a preemptive multitasking environment, it is possible for some other thread to change the process's access to the memory being tested. Even when the function indicates that the process has read access to the specified memory, you should use structured exception handling when attempting to access the memory. Use of structured exception handling enables the system to notify the process if an access violation exception occurs, giving the process an opportunity to handle the exception.
Or as most people say, they should really call it " CrashProgramRandomly " :)
 
Last edited by a moderator:
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