i really want to know this is correct way to do unlink with String get_name ? I try to hook this method but it doesnt work
I use this MonoString
This is how i hook it
I use this MonoString
C++:
typedef struct _monoString
{
void* klass;
void* monitor;
int length;
char chars[1];
int getLength()
{
return length;
}
char* getChars()
{
return chars;
}
}monoString;
monoString *CreateString(const char *str) {
monoString *(*CreateString)(void *_this, const char *str, int start, int length) = (monoString *(*)(void *, const char *, int, int))IL2CPP_H::Il2CppGetMethodOffset(OBFUSCATE("mscorlib.dll"), OBFUSCATE("System"), OBFUSCATE("String"), OBFUSCATE("CreateString"), 3);
int length = (int)strlen(str);
return CreateString(NULL, str, 0, length);
}
This is how i hook it
C++:
monoString *(*get_name)(void *inst);
void (*org_EntityListUpdate)(void *object);
void new_EntityListUpdate(void *object) {
if(player != NULL){
auto name = get_name(object);
if(name == CreateString("purple_coin_8")){
if (!objectFind(object))
{
objectList.push_back(object);
}
}
}
org_EntityListUpdate(object);
}
//hack thread
get_name = (monoString *(*)(void *))IL2CPP_H::Il2CppGetMethodOffset(OBFUSCATE("Scripts.dll"), OBFUSCATE("Oak"), OBFUSCATE("FieldObject"), OBFUSCATE("get_Name"), 0);
DobbyHook((void *)IL2CPP_H::Il2CppGetMethodOffset(OBFUSCATE("Scripts.dll"), OBFUSCATE("Oak"), OBFUSCATE("FieldObject") , OBFUSCATE("get_FieldObjectStatsBehaviour"), 0), (void *) new_EntityListUpdate , (void **) &org_EntityListUpdate);
Last edited: