-
Notifications
You must be signed in to change notification settings - Fork 82
Description
Hello there, new to unity here.
Well after checking some of the .h file funtions and stuffs i go into a issue that i maybe doing something wrong.
For example on 7 days to day we have functions like:
// Token: 0x170003B3 RID: 947 // (get) Token: 0x060022B2 RID: 8882 RVA: 0x000DAAA8 File Offset: 0x000D8CA8 public string PlayerDisplayName { get { if (this.cachedPlayerName != null) { return this.cachedPlayerName.DisplayName; } PersistentPlayerData playerDataFromEntityID = GameManager.Instance.persistentPlayers.GetPlayerDataFromEntityID(this.entityId); if (playerDataFromEntityID == null) { return null; } this.cachedPlayerName = playerDataFromEntityID.PlayerName; return this.cachedPlayerName.DisplayName; } }
This one are get/set ones, i trying to call this as others:
1.- first method: m_PlayerDisplayName = pClass->Get<IM>("get_PlayerDisplayName")->Cast<std::string, Player*>(); 2.- second method : m_PlayerDisplayName = pClass->Get<IM>("PlayerDisplayName")->Cast<std::string, Player*>();
On both im crashing atm, the first try is crashing at call.
To provide some of context im hookin Awake on EntityPlayer class, named on my side "Player":
class Player : EntityAlive at the end on inherance this ending beeing a : MonoBehaviour
On the hook im doing:
if (_this) { if (_this->InitPlayer()) { players.push_back(_this); bool isAdmin = _this->isAdmin(); LOG(INFO) << "Is admin: " << (bool)isAdmin; LOG(INFO) << "Player: " << _this->GetName() << " add to the memory.."; //Using second method we crash here } }
Im doing: UnityResolve::MethodPointer<std::string, Player*> m_PlayerDisplayName{};
So isAdmin is working good, same for others, im just having issues doing on that way.
In the case of first method im crashing on the direct search
m_PlayerDisplayName = pClass->Get<IM>("get_PlayerDisplayName")->Cast<std::string, Player*>();
Anyone have i idea if im doing something wrong.
To more context my getName:
if (!m_PlayerDisplayName) { return "NONE"; } return m_PlayerDisplayName(this);
My isAdmin:
`
bool Player::isAdmin() {
// Resolve the field (ideally do this once and cache it)
auto gameObject = this->GetGameObject();
if (!gameObject) {
return false;
}
if (const auto pClass = I::Get("Assembly-CSharp.dll")->Get("EntityPlayer")) {
LOG(INFO) << "[isAdmin] returning using class value..";
return pClass->GetValue<bool>(gameObject, "isAdmin");
}
return false;
}
`