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;
}
}
Feel free to ask in the future and happy modding
thanks for any help you can giveHow can I create an instance of a class using UnityResolve so I can call a method without using a hook?
aww man sorry for late reply, i've bussy days and the paid sucks, you can check this issue for the question you ask
Thanks but I did find this and I tried already and failedaww man sorry for late reply, i've bussy days and the paid sucks, you can check this issue for the question you ask
How to instantiate a class?
const auto assembly = UnityResolve::Get("Assembly-CSharp.dll"); // get dll
const auto pClass = assembly->Get("Player"); // get classname
const auto pGame = pClass->New<Player*>(); // create instance?
UnityResolve::Get("Assembly-CSharp.dll")->Get("Player")->Get<UnityResolve::Method>("AddCoins")->Invoke<void>(pGame,9999);
error: use of undeclared identifier 'Player'
you need to create the struct named Player if that case, then you can use that struct as instance, try this oneThanks but I did find this and I tried already and failed
This is what I tried
C++:const auto assembly = UnityResolve::Get("Assembly-CSharp.dll"); // get dll const auto pClass = assembly->Get("Player"); // get classname const auto pGame = pClass->New<Player*>(); // create instance? UnityResolve::Get("Assembly-CSharp.dll")->Get("Player")->Get<UnityResolve::Method>("AddCoins")->Invoke<void>(pGame,9999);
but I get this error when I try to compile
I'm confused what to use instead of <Game*> because the classname is already used in the previous line?
typedef struct CPlayerLocal CPlayerLocal;
struct CPlayerLocal {
auto set_DecreaseAmmo(int pWeaponId, int pAmount = 1) -> void {
static UnityResolve::Method *method;
if (!method) method = UnityResolve::Get(OBFUSCATE("Scripts.dll"))->Get(OBFUSCATE("CPlayerLocal"))->Get<UnityResolve::Method>(OBFUSCATE("DecreaseAmmo"));
if (method) method->Invoke<void>(this, pWeaponId, pAmount);
}
};
// on somewhere
auto m_PlayerLocal = UnityResolve::Get("Scripts.dll")->Get("CPlayerLocal")->New<CPlayerLocal>(); // create new instance
// and use it like this
m_PlayerLocal->set_DecreaseAmmo(0,0); // the param is dummy
Hello, sorry to tag, but please Help whenever you have the time.... So I am trying to hook and force set the value of "value" in parameters of method set_DefaultPlayerWeaponAmmoSize to 100,Feel free to ask in the future and happy modding
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