LightbulbHow to return pointer value obtained in IDA

Posts 1–6 of 6 · Page 1 of 1
How to return pointer value obtained in IDA
Hello everyone, I'm having a problem developing my program.

I have an IDA pointer, this pointer is a struct that returns me values ​​such as size, hp, energy, ...

but trying to pull this value is not returning the correct value.

IDA Pointer:

Code:
.data:00B1C4E5 ; CPlayer *player
.data:00B1C4E5 player      dd ?
.data:00B1C4E5
Header Code:

Code:
class PlayerHK : public Player {
public:
	PlayerHK();

	ULONG player_hp();
	ULONG player_power();
	ULONG player_hp2();
	ULONG player_power2();

private:

	struct CPlayer
	{
		BYTE padding[0x20];
		ULONG hp;
		ULONG power;
	};
	
	CPlayer *player;
};
Code:

Code:
PlayerHK::PlayerHK() {

	player = reinterpret_cast<CPlayer*>(*reinterpret_cast<DWORD*>(0x00B1C4E5));

}

ULONG PlayerHK::player_hp() {
	return player->hp; //does not return the value
}

ULONG PlayerHK::player_power() {
	return player->power; //does not return the value
}

ULONG PlayerHK::player_hp2() {
	return *(ULONG*)(*(DWORD*)(0x00B1C4E5) + 0x20); //returns the value
}

ULONG PlayerHK::player_power2() {
	return *(ULONG*)(*(DWORD*)(0x00B1C4E5) + 0x24); //returns the value
}
when I am using player_hp or player_power the value is not returned, I believe it is something in my player pointer, because when I use player_hp2 or player_power2 the value is returning correctly. But I want to use structures instead of maintaining the second form, does anyone know what's wrong?
i think seems will be wrong then:
Code:
player = reinterpret_cast<CPlayer*>(*reinterpret_cast<DWORD*>(0x00B1C4E5));
did u tried with out cast?
Code:
player = reinterpret_cast<CPlayer*>(reinterpret_cast<DWORD*>(0x00B1C4E5));
Quote Originally Posted by MikeRohsoft View Post
i think seems will be wrong then:
Code:
player = reinterpret_cast<CPlayer*>(*reinterpret_cast<DWORD*>(0x00B1C4E5));
did u tried with out cast?
Code:
player = reinterpret_cast<CPlayer*>(reinterpret_cast<DWORD*>(0x00B1C4E5));
yes I tried to use it that way too, but it returns the wrong value.
lol ofc, because it will replace the memory region xD
you have to make your methods private and the struct public
Quote Originally Posted by MikeRohsoft View Post
lol ofc, because it will replace the memory region xD
you have to make your methods private and the struct public
Do you say to do this?

Code:
class PlayerHK : public Player {
public:
	PlayerHK();

	struct CPlayer
	{
		BYTE padding[0x20];
		ULONG hp;
		ULONG power;
	};
	
	CPlayer *player;
};

private:

	ULONG player_hp();
	ULONG player_power();
	ULONG player_hp2();
	ULONG player_power2();

};
Even changing does not return the value
Ohh, thanks guys) u r amazing
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?