Reversing a class

Posts 114 of 14 · Page 1 of 1
Reversing a class
I will teach you how to reverse a class, be patient as I am a novice @ reversing classes and ~Fallen~ and Giniyat202 helped me.
What you need:
A calculator (Google and Bing can do the calculator functions we need right in their search engine )
Something to write in
STEP 1) Get the offsets/strings that you need.

so...
OHK:0x7F8
weight:0xACC

STEP 2) Arrange in increasing (IE: 1,2,3,4,5 not 5,4,3,2,1) order. It is a good idea to convert to decimal.

so...
Code:
		OHK:0x7F8 -> 2040
		weight:0xACC -> 2764
STEP 3) Find the useless bytes that you want to skip in your class/struct.

so...
let's start with one hit kill because it is the smallest:
OHK->0x7F8: everything before 0x7F8 is useless, why?
0x7F8 is useful, it is where we want to be. The last byte that is useless is 0x7F7, so 0x7F8-1 byte=0x7F7. Range 0~0x7F7 is useless.
Basically, you start at 0 and you want to jump to 0x7F8 because the rest is useless!
Do you think that is the end of OHK? Well, it is not. If you remember, the value of OHK is float, which is 4 bytes. We must reserve 4 bytes for this purpose
0x7F8+4 bytes = 0x7FC. 0x7FC is the last byte for our "OHK" range, everything after that is of no use for this feature!
Let's start building our struct: We are using a struct because we want the members to be public and a struct defaults to that (my personal preference)
Code:
struct _weaponclass (the name of our struct)
{
};
We need to skip all those bytes we talked about which would be 0 through 0x7F7 (you may convert to decimal if you like)
Code:
struct _weaponclass
{
char skipbytes01[0x7F8-0]; //we skipped our bytes to land on the one hit kill range (0x7F8~0x7FC)
float OHK;//0x7F8
};
We have successfully added one hit kill to our class. It is good practice to add the offset in a comment for your or other people's reference, but classes eliminate the use of offsets!

0let's move on to the next one that is bigger, which is Weapon weight
weight->0xACC: everything between One hit kill and weapon weight are useless, why?
0xACC is where we want to be. We just landed on one hit kill range which ends at 0x7FC because it is a 4 byte range. Now, we want to skip bytes and land on the weaight range. This is essentially 0x7FC~0xACC.
Again, this is not a 1 byte range rather, it is a 4 byte range. So, like we did with OHK, add 4 bytes to make it four byte range for Weapon Weight.
After our byte jump, we land on 0xACC, so 0xACC+4 bytes = 0xAD0. The four byte range is 0xACC~0xAD0. The latter is not needed because we are not continuing the tutorial onto other offsets. By now, you should have a basic understand on how to reverse the rest of a class!
Let's continue our struct, and infact, finish it for now!
Right now, it should look like this:
Code:
struct _weaponclass
{
char skipbytes01[0x7F8-0]; //we skipped our bytes to land on the one hit kill range (0x7F8~0x7FC)
float OHK;//0x7F8
};
We will add our next byte skip and a new member to the class:
Bytes 0x7FC~0xACC are usless, so we will make that the range of bytes to skip and then we will add our weight as our next member:
Code:
struct _weaponclass
{
char skipbytes01[0x7F8-0]; //we skipped our bytes to land on the one hit kill range (0x7F8~0x7FC)
float OHK; //0x7F8
char skipbytes02[0xACC-0x7FC];//we skipped our bytes to land on the weight range (0xACC~0xAD0)
float WeaponWeight; //0xACC
};
STEP 4) PAT YOURSELF ON THE BACK!
This must have taken you a while to read and comprehend, but hopefully by now you can move out of using measily offsets and can start using classes in your hacks.
Classes:
save time;
are easy to use;
make your code more readable;
make your code more efficient

Using a class is as simple as giving it a pointer and doing this:
class->member=value;
It's that easy

If you need more help, you can visit Brimir's tutorial on how to use classes in your hack base!
http://www.mpgh.net/forum/242-crossf...e-classes.html

I'd like to thank a few people;

@~FALLEN~
@giniyat202

Thanks for reading.
Quote Originally Posted by dakr54 View Post
I will teach you how to reverse a class, be patient as I am a novice @ reversing classes and ~Fallen~ and Giniyat202 helped me.
What you need:
A calculator (Google and Bing can do the calculator functions we need right in their search engine )
Something to write in
STEP 1) Get the offsets/strings that you need.

so...
OHK:0x7F8
weight:0xACC

STEP 2) Arrange in increasing (IE: 1,2,3,4,5 not 5,4,3,2,1) order. It is a good idea to convert to decimal.

so...
Code:
		OHK:0x7F8 -> 2040
		weight:0xACC -> 2764
STEP 3) Find the useless bytes that you want to skip in your class/struct.

so...
let's start with one hit kill because it is the smallest:
OHK->0x7F8: everything before 0x7F8 is useless, why?
0x7F8 is useful, it is where we want to be. The last byte that is useless is 0x7F7, so 0x7F8-1 byte=0x7F7. Range 0~0x7F7 is useless.
Basically, you start at 0 and you want to jump to 0x7F8 because the rest is useless!
Do you think that is the end of OHK? Well, it is not. If you remember, the value of OHK is float, which is 4 bytes. We must reserve 4 bytes for this purpose
0x7F8+4 bytes = 0x7FC. 0x7FC is the last byte for our "OHK" range, everything after that is of no use for this feature!
Let's start building our struct: We are using a struct because we want the members to be public and a struct defaults to that (my personal preference)
Code:
struct _weaponclass (the name of our struct)
{
};
We need to skip all those bytes we talked about which would be 0 through 0x7F7 (you may convert to decimal if you like)
Code:
struct _weaponclass
{
char skipbytes01[0x7F8-0]; //we skipped our bytes to land on the one hit kill range (0x7F8~0x7FC)
float OHK;//0x7F8
};
We have successfully added one hit kill to our class. It is good practice to add the offset in a comment for your or other people's reference, but classes eliminate the use of offsets!

0let's move on to the next one that is bigger, which is Weapon weight
weight->0xACC: everything between One hit kill and weapon weight are useless, why?
0xACC is where we want to be. We just landed on one hit kill range which ends at 0x7FC because it is a 4 byte range. Now, we want to skip bytes and land on the weaight range. This is essentially 0x7FC~0xACC.
Again, this is not a 1 byte range rather, it is a 4 byte range. So, like we did with OHK, add 4 bytes to make it four byte range for Weapon Weight.
After our byte jump, we land on 0xACC, so 0xACC+4 bytes = 0xAD0. The four byte range is 0xACC~0xAD0. The latter is not needed because we are not continuing the tutorial onto other offsets. By now, you should have a basic understand on how to reverse the rest of a class!
Let's continue our struct, and infact, finish it for now!
Right now, it should look like this:
Code:
struct _weaponclass
{
char skipbytes01[0x7F8-0]; //we skipped our bytes to land on the one hit kill range (0x7F8~0x7FC)
float OHK;//0x7F8
};
We will add our next byte skip and a new member to the class:
Bytes 0x7FC~0xACC are usless, so we will make that the range of bytes to skip and then we will add our weight as our next member:
Code:
struct _weaponclass
{
char skipbytes01[0x7F8-0]; //we skipped our bytes to land on the one hit kill range (0x7F8~0x7FC)
float OHK; //0x7F8
char skipbytes02[0xACC-0x7FC];//we skipped our bytes to land on the weight range (0xACC~0xAD0)
float WeaponWeight; //0xACC
};
STEP 4) PAT YOURSELF ON THE BACK!
This must have taken you a while to read and comprehend, but hopefully by now you can move out of using measily offsets and can start using classes in your hacks.
Classes:
save time;
are easy to use;
make your code more readable;
make your code more efficient

Using a class is as simple as giving it a pointer and doing this:
class->member=value;
It's that easy

If you need more help, you can visit Brimir's tutorial on how to use classes in your hack base!
http://www.mpgh.net/forum/242-crossf...e-classes.html

I'd like to thank a few people;

@~FALLEN~
@giniyat202

Thanks for reading.
good job... I would recommend using class instead of struct just because of ease of use later on with inline functions and such.. anyways here's my weapon class... should all be correct

Code:
class cWeaponList{
	public:
		char spacer00[2];
		unsigned short WeaponClass;
		int WeaponIndex;
		char WeaponName[12];
		char spacer02[1288];
		float SpreadMin[9];
		char spacer03[324];
		float SpreadMax[9];
		char spacer04[324];
		float WeaponRange;
		unsigned short MaxAmmo;
		unsigned short AmmoPerMagazine;
		unsigned short NanoMaxAmmo;
		unsigned short NanoAmmoPerMagazine;
		float AmmoDamage;
		float UnlimitedAmmo;
		int TargetSlot;
		int SubType;
		float DamageFactorByDistance;
		float DamageVariationFactor;
		float ShotsPerMinute;
		char spacer05[24];
		unsigned char ShotsPerAmmo;
		char spacer06;
		unsigned short WeaponPrice;
		unsigned short AmmoPrice;
		bool ReloadSingleAmmo;
		char spacer07[3];
		float BoomDuration;
		char spacer08[480];
		float KnifeNormalRange[4];
		float KnifeYawPitch[2];
		float KnifeNormalAnimationRate[3];
		float KnifeBigshotRange[4];
		float KnifeBigshotYawPitch[2];
		float KnifeBigshotAnimationRate[3];
		char spacer9[72];
		unsigned char FireMode;
		char spacer10[3];
		unsigned char ZoomMode;
		char spacer11[3];
		unsigned char ZoomAttributes;
		char spacer12[3];
		unsigned char ReloadAttributes;
		char spacer13[3];
		unsigned char KnifeAttributes;
		char spacer14[3];
		bool IsDroppedWhenDie;
		char spacer15[8];
		float StunTime;
		int SubWeaponIndex;
		float DamageRatioPerNode;
		char spacer16[236];
		float KnifeNormalAmmoDamage[3];
		float KnifeBigShotAmmoDamage[3];
		char spacer17[28];
		float SmokeAlpha;
		char spacer18[3416];
		D3DXVECTOR3 BulletPosOffset;
		char spacer19[2848];
		float SpeedPenalty[3];
		char spacer20[4];
		float FireAnimationMultiplier[3];
		char spacer21[164];
		int DelayOneShootTime[3];
		char spacer22[276];
		float ThrowVelAngleGravityAirResTime[3];
		char spacer23[4];
		unsigned char BoomType;
		unsigned char BoomDurationDamage;
		char spacer24[2];
		float BoomDamageCheckInterval;
		float SideEffectDamage;
		float SideEffectTimeGap;
		float DamagePenaltyTimeAndMoveRate[2];
		float NanoDamagePenaltyTimeAndMoveRate[2];
		float WallShotDamageRatio;
		float ReloadAnimRatio;
		float ChangeWeaponAnimRatio;
		char spacer25[188];
		bool HaveKnife;
		char spacer26[39];
		float KnockBack;
	};

#define WeaponList 0x00A974A0

cWeaponList *GetWeaponByIndex( int Index ){

		unsigned long *pWeaponList = new unsigned long;
		
		*pWeaponList = 0;

		*pWeaponList = *reinterpret_cast< unsigned long *>( reinterpret_cast< unsigned long >( GetModuleHandle( "CShell.dll" ) ) + WeaponList );

		if( *pWeaponList == NULL )
			goto Failed;

		*pWeaponList = *reinterpret_cast< unsigned long *>( *pWeaponList + ( Index * 4 ) );

		if( *pWeaponList == NULL )
			goto Failed;

		cWeaponList* Ret = reinterpret_cast< cWeaponList * >( *pWeaponList );

		delete pWeaponList;
		return Ret;
Failed:
		delete pWeaponList;
		return NULL;
	}
tbh the last check isnt needed... idk why its in there :/
Quote Originally Posted by ~FALLEN~ View Post
good job... I would recommend using class instead of struct just because of ease of use later on with inline functions and such.. anyways here's my weapon class... should all be correct

Code:
class cWeaponList{
	public:
		char spacer00[2];
		unsigned short WeaponClass;
		int WeaponIndex;
		char WeaponName[12];
		char spacer02[1288];
		float SpreadMin[9];
		char spacer03[324];
		float SpreadMax[9];
		char spacer04[324];
		float WeaponRange;
		unsigned short MaxAmmo;
		unsigned short AmmoPerMagazine;
		unsigned short NanoMaxAmmo;
		unsigned short NanoAmmoPerMagazine;
		float AmmoDamage;
		float UnlimitedAmmo;
		int TargetSlot;
		int SubType;
		float DamageFactorByDistance;
		float DamageVariationFactor;
		float ShotsPerMinute;
		char spacer05[24];
		unsigned char ShotsPerAmmo;
		char spacer06;
		unsigned short WeaponPrice;
		unsigned short AmmoPrice;
		bool ReloadSingleAmmo;
		char spacer07[3];
		float BoomDuration;
		char spacer08[480];
		float KnifeNormalRange[4];
		float KnifeYawPitch[2];
		float KnifeNormalAnimationRate[3];
		float KnifeBigshotRange[4];
		float KnifeBigshotYawPitch[2];
		float KnifeBigshotAnimationRate[3];
		char spacer9[72];
		unsigned char FireMode;
		char spacer10[3];
		unsigned char ZoomMode;
		char spacer11[3];
		unsigned char ZoomAttributes;
		char spacer12[3];
		unsigned char ReloadAttributes;
		char spacer13[3];
		unsigned char KnifeAttributes;
		char spacer14[3];
		bool IsDroppedWhenDie;
		char spacer15[8];
		float StunTime;
		int SubWeaponIndex;
		float DamageRatioPerNode;
		char spacer16[236];
		float KnifeNormalAmmoDamage[3];
		float KnifeBigShotAmmoDamage[3];
		char spacer17[28];
		float SmokeAlpha;
		char spacer18[3416];
		D3DXVECTOR3 BulletPosOffset;
		char spacer19[2848];
		float SpeedPenalty[3];
		char spacer20[4];
		float FireAnimationMultiplier[3];
		char spacer21[164];
		int DelayOneShootTime[3];
		char spacer22[276];
		float ThrowVelAngleGravityAirResTime[3];
		char spacer23[4];
		unsigned char BoomType;
		unsigned char BoomDurationDamage;
		char spacer24[2];
		float BoomDamageCheckInterval;
		float SideEffectDamage;
		float SideEffectTimeGap;
		float DamagePenaltyTimeAndMoveRate[2];
		float NanoDamagePenaltyTimeAndMoveRate[2];
		float WallShotDamageRatio;
		float ReloadAnimRatio;
		float ChangeWeaponAnimRatio;
		char spacer25[188];
		bool HaveKnife;
		char spacer26[39];
		float KnockBack;
	};

#define WeaponList 0x00A974A0

cWeaponList *GetWeaponByIndex( int Index ){

		unsigned long *pWeaponList = new unsigned long;
		
		*pWeaponList = 0;

		*pWeaponList = *reinterpret_cast< unsigned long *>( reinterpret_cast< unsigned long >( GetModuleHandle( "CShell.dll" ) ) + WeaponList );

		if( *pWeaponList == NULL )
			goto Failed;

		*pWeaponList = *reinterpret_cast< unsigned long *>( *pWeaponList + ( Index * 4 ) );

		if( *pWeaponList == NULL )
			goto Failed;

		cWeaponList* Ret = reinterpret_cast< cWeaponList * >( *pWeaponList );

		if( Ret ){

			delete pWeaponList;
			return Ret;
		}else goto Failed;

Failed:
		delete pWeaponList;
		return NULL;
	}
Thanks Cody, I only used a struct because I am a noob and have no need for inline functions as of yet, and it defaults to public members so less code for me! XD
Thanks for sharing bro.
thx for the tut dude
@Hero @Royku this is worth a sticky
Very Usefull
~Stickyed
@DaRk did you succede using the fallesn's class ??? bcs i dont know how to i mean i can make it for BasicPlayerInfo but here is different can you help
Quote Originally Posted by kmanev073 View Post
@DaRk did you succede using the fallesn's class ??? bcs i dont know how to i mean i can make it for BasicPlayerInfo but here is different can you help
yea i used his class and it worked perfectly
i am gonna make my own now
Quote Originally Posted by DaRk View Post
yea i used his class and it worked perfectly
i am gonna make my own now
can you tell me how to point it i mean like BasicPlayerInfo... But here i need loop HOW ???
Quote Originally Posted by kmanev073 View Post
can you tell me how to point it i mean like BasicPlayerInfo... But here i need loop HOW ???
i am having trouble with that too
idk how to add a loop
No problem, I made this because not many people know how to reverse a class .
thanks!

very good
Very helpful thanks! : )
Posts 114 of 14 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?