// RVA: 0x135F8F4 Offset: 0x135F8F4 VA: 0x135F8F4
public static bool JoinRoom(string RoomName) { }
bool JoinRoom;
bool (*old_JoinRoom)(monoString * Name);
bool OnJoinRoom(monoString * Name ) {
if (JoinRoom) {
old_JoinRoom(String_CreateString(get_StringInstance,RoomName));
JoinRoom = false;
return 1;
}
return old_JoinRoom(Name);
}
MSHookFunction((void *) getAbsoluteAddress("libil2cpp.so", 0x135F8F4), (void *) &OnJoinRoom, (void **) &old_JoinRoom);
cpp
#include <string> // Include necessary headers
bool JoinRoomSuccess; // Declare a flag to track successful room joining
bool (*old_JoinRoom)(std::string RoomName); // Define the function pointer
bool OnJoinRoom(std::string RoomName) {
if (JoinRoomSuccess) {
// Call the original JoinRoom function with the provided RoomName
old_JoinRoom(RoomName);
JoinRoomSuccess = false;
return true; // Indicate successful room joining
}
// Call the original JoinRoom function with the provided RoomName
return old_JoinRoom(RoomName);
}
// Hooking function
MSHookFunction((void *)getAbsoluteAddress("libil2cpp.so", 0x135F8F4), (void *)&OnJoinRoom, (void **)&old_JoinRoom);
Don't forget, you can hook any static methods inside Update. Just make sure you don't call any instance in a static method.Solved. Thank u bro by the way. I used any update() to help hooking and then it works :)
Could you give me a few examples?Don't forget, you can hook any static methods inside Update. Just make sure you don't call any instance in a static method.
Could you give me a few examples?
You cannot use std::string, but only able to convert the std::string into using Il2cpp's string method. Unity uses it's own implementation for strings with .NET Framework. std::string differents from C++. You can either use std::string to and convert it for C-Style or just use monoString to make it easier.Hello, I think the signature of your OnJoinRoom function does not match the signature of the JoinRoom function you are trying to hook. The JoinRoom function takes a string parameter, not a monoString* parameter.
Here is a revised version of your code:
In this revised version, the OnJoinRoom function takes a std::string parameter RoomName to match the signature of JoinRoom. This function then calls the original function old_JoinRoom with the provided RoomName. Remember to adjust any other parts of your code accordingly to ensure consistency and compatibility with the rest of your implementation.Code:cpp #include <string> // Include necessary headers bool JoinRoomSuccess; // Declare a flag to track successful room joining bool (*old_JoinRoom)(std::string RoomName); // Define the function pointer bool OnJoinRoom(std::string RoomName) { if (JoinRoomSuccess) { // Call the original JoinRoom function with the provided RoomName old_JoinRoom(RoomName); JoinRoomSuccess = false; return true; // Indicate successful room joining } // Call the original JoinRoom function with the provided RoomName return old_JoinRoom(RoomName); } // Hooking function MSHookFunction((void *)getAbsoluteAddress("libil2cpp.so", 0x135F8F4), (void *)&OnJoinRoom, (void **)&old_JoinRoom);
i have function:View attachment 668598
You have static methods like these. Static methods is already in a class, meaning you don't have to create an additional parameter by creating an "instance". You can call any static methods without those objects/instance. Static is shared across all INSTANCES. You can call it ANYWHERE from ANY CLASS by creating the function pointer for it. set_timeScale is from the class Time. You can call that in any classes like Player, Weapons, ETC because it's "static".
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