What game are you modding? Got any crash logs you can share? :>
public int Coins
{
[Token(Token = "0x6000FE3")]
[Address(RVA = "0x20DF77A", Offset = "0x20DF77A", VA = "0x20DF77A")]
get
{
return 0;
}
}
UnityResolve::Hook(OBFUSCATE("Player"), OBFUSCATE("get_Coins"), {}, (void *)new_Coins, (void **)&old_Coins);
int (*old_Coins)(void *instance);
int new_Coins(void *instance) {
if (instance != NULL) {
if (Vars::PlayerData.CoinsVar)
return 1000;
}
return old_Coins(instance);
}
// invoke the method and pass the value to the parameter if there any
UnityResolve::Get("somedll.dll")->Get("Player")->Get<UnityResolve::Method>("set_Coins")->Invoke<void>(instance, 9999);
auto pValue = UnityResolve::Get("somedll.dll")->Get("Player")->GetValue<int>(instance, "get_Coins"); // read field value
UnityResolve::Get("somedll.dll")->Get("Player")->SetValue<void>(instance, "setCoins", 9999); // set field value
UnityResolve::Get("somedll.dll")->Get("Player")->SetValue<void>(instance, "setCoins", 9999); // set field value
no matching member function for call to 'SetValue'
That code’s basically showing how to hook a function by name, since it’ll auto find the right address for youThank you for your help and quick reply
In my example code above there is only a get and not a set
Is there no way to hook the get by name as LGL can hook by address so I could return a different value when the get is called?
If not then I could probably find an alternative class, method or field but would be good to know if hooking a get by name is possible or not?
// this is example how to hook by address
DobbyHook((void*) getAbsoluteAddress("libil2cpp.so",0xF00000), (void*)new_Coins, (void**)&old_Coins);
ah yeah i forgot, because the field is not the void, you need to change the type dataI'm getting an error when trying to compile on the set field example you posted above
C++:UnityResolve::Get("somedll.dll")->Get("Player")->SetValue<void>(instance, "setCoins", 9999); // set field value
// SetValue<int>, change it the typedata, void is not supported for the field
UnityResolve::Get("somedll.dll")->Get("Player")->SetValue<int>(_this, "coins", 9999);
Thank you, I should have spotted thatah yeah i forgot, because the field is not the void, you need to change the type data
C++:// SetValue<int>, change it the typedata, void is not supported for the field UnityResolve::Get("somedll.dll")->Get("Player")->SetValue<int>(_this, "coins", 9999);
UnityResolve::Get("UnityEngine.CoreModule.dll")->Get("Player")->SetValue<int>(instance, "Coins", 9999); // set field value
That code’s basically showing how to hook a function by name, since it’ll auto find the right address for you
public int Coins
{
[Token(Token = "0x6000FE3")]
[Address(RVA = "0x20DF77A", Offset = "0x20DF77A", VA = "0x20DF77A")]
get
{
return 0;
}
}
We use cookies to personalize content and ads, to provide social media features and to analyse our traffic. We also share necessary information with our advertising and analytics partners to optimize your experience on our site.
Learn more about cookies
We use cookies to personalize content and ads, to provide social media features and to analyse our traffic. We also share necessary information with our advertising and analytics partners to optimize your experience on our site.
Learn more about cookies