Calling the static class method "virtualAddress = 0" resulted in the error: "access violation accessing 0x86"
On the LDDnplayer9 64-bit emulator, I found a static class. Then I tried to call one of its methods. There was a possibility of encountering a memory access error. After debugging, I found that the class could be located and its methods could also be traversed, but when calling, the memory access failed directly. Then I discovered that the problem was with the virtualAddress being 0.
Also, when hooking a certain method, this kind of situation may occur. However, if I call it by using an instantiated object from another class, these problems will not arise.
The issues mentioned above are all of a probabilistic nature.
Thanks for reporting. What happens if you invoke Il2Cpp.Class::initialize before any other method?
Also, would you console.log(klass)?
Thanks for reporting. What happens if you invoke
Il2Cpp.Class::initializebefore any other method?Also, would you
console.log(klass)?
I'm currently trying to figure out how to reproduce this issue. When running on multiple devices, there are always a few that don't work properly occasionally. Now I've encountered another strange problem.
private getInstance(assemblyName: string, className: string): Il2Cpp.Object | null {
try {
const assembly = Il2Cpp.domain.assembly(assemblyName);
const targetClass = assembly.image.class(className);
let instance: Il2Cpp.Object | null = null;
Il2Cpp.gc.choose(targetClass).forEach(function (obj) {
instance = obj;
});
return instance;
}
catch (e) {
logger.info(`Failed to get ${className}: ${String(e)}`);
return null;
}
}
getInstance() After obtaining the object, when it came to the actual invocation, there was a problem with the x86 memory access. Then I attempted to...
console.log(obj.handle) add code After adding this, there was an error in direct memory access in the gc section.
private getInstance(assemblyName: string, className: string): Il2Cpp.Object | null {
try {
const assembly = Il2Cpp.domain.assembly(assemblyName);
const targetClass = assembly.image.class(className);
let instance: Il2Cpp.Object | null = null;
Il2Cpp.gc.choose(targetClass).forEach(function (obj) {
instance = obj;
console.log(obj.handle)
});
return instance;
}
catch (e) {
logger.info(`Failed to get ${className}: ${String(e)}`);
return null;
}
}
But after one failure, the second time it was called, it worked properly again.