
Originally Posted by
Nik08154
Hey community!
I saw this in a cf hack and I dont understand why there as example:
if ((*(DWORD*)((*(DWORD*)(CShell+WeaponMgr))+(4*i))) != 0)
are 2 *(DWORD*)
*(DWORD*) is de-referencing that pointer to an actual DWORD value.
and (DWORD*) is a cast to convert a value to a pointer to a DWORD.
But i dont understand why there are 2 from them
Hope you can help me
break that line into steps, starting at the inner-most ( )'s
Code:
*(DWORD*)((*(DWORD*)(CShell+WeaponMgr))+(4*i))
1. add CShell+weaponMgr --> we'll store the answer in (a temporary variable) 'aa'
aa = CShell+WeaponMgr;
2. *(DWORD*)(aa)
--read a DWORD (4 bytes) starting at the addr aa --> these 4 bytes will be a memory address. we'll store in (a temporary variable) 'bb'
bb = *(DWORD*)(aa);
3. + (4*i)
bb += 4*i;
4. *(DWORD*)(bb)
--same as step 2. Read 4 bytes starting at 'bb'. we'll store this in (a temporary variable) 'cc'
cc = *(DWORD*)(bb); // cc could be a memory addr -- or regular Int32 value, representing..something.
5. cc != 0 //last item in the expression.
------------------------
Code:
*(DWORD*)(CShell+WeaponMgr)
If we only did one *(DWORD*)() that would read 4 bytes from CShell+WeaponMgr
it would return an address like 0x11223344.
If we then read a DWORD from (0x11223344 + (4*i)), we get some useful number from the game like gun ammo - or possibly* a pointer to some object in the game.
-----------------------------

Originally Posted by
XarutoUsoCrack
DWORD CShell = ( DWORD )GetModuleHandleA( "CShell.dll");
DWORD WeaponMgr = *( DWORD *)( CShell + 0x0 );
if( WeaponMgr )
{
for( int i = INT_MAX; i = 0; i++ )
{
DWORD Wep = *( DWORD *)( Wep + ( i * 4 ) );
if( Wep )
{
//hacks
}
}
More clean code than yours, if you want really understand just learn the ASM logic and C++ logic.
Troll?
DWORD WeaponMgr = *( DWORD *)( CShell + 0x0 );
// +0 means nothing. ?
if( WeaponMgr )
{
for( int i = INT_MAX; i = 0; i++ )
//This loop will never execute its body... Why is i being set =0, not checked against ==0? If the value of a condition is 0, it's == false, the body won't execute.
{
DWORD Wep = *( DWORD *)( Wep + ( i * 4 ) );
'Wep' used in it's own definition. Wild goose chase, or compiler error?
//Wep + ( i * 4 ); has 'undefined' value.
test:
Code:
#include <climits>
#include <Windows.h>
int main()
{
for (int i = INT_MAX; i = 0; i++) // error in condition; same as above.
{
MessageBoxA(0,"Annoying yet?","Nope. This code never runs.",0);// never executed
bool _breakPoint = false; // never executed
}
MessageBoxA(0,"How many times did that loop run?","Zero???",0); // executed
bool _done = true; // executed