BepInEx / Il2CppInterop

A tool interoperate between CoreCLR and Il2Cpp at runtime
GNU Lesser General Public License v3.0
217 stars 67 forks source link

System.AccessViolationException when injecting class #188

Open jumbogram456 opened 1 month ago

jumbogram456 commented 1 month ago

After calling AddComponent, the type is successfully registered.

[Warning:Il2CppInterop] Class::Init signatures have been exhausted, using a substitute!
[Info   :Il2CppInterop] Registered mono type PokerServer.MyBehaviour in il2cpp domain

Shortly after, the game crashes and the error log contains:

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Il2CppInterop.Runtime.Injection.Hooks.Class_GetFieldDefaultValue_Hook.Hook(Il2CppInterop.Runtime.Runtime.Il2CppFieldInfo*, Il2CppInterop.Runtime.Runtime.Il2CppTypeStruct* ByRef)

The game is Vegas Infinite by PokerStars, I'm aware the game contains anti-cheat (only EAC) but I'm running the game without it (just by launching PokerStarsVR.exe) since my goal is to create a private server for the game. The game runs on Unity 2022.3.29f1.

I'm running this through the latest build of BepInEx which runs Il2CppInterop 1.4.5.

jumbogram456 commented 1 month ago

I've been temporarily able to resolve this by patching other methods in the game to get the callbacks I need (OnUpdate, etc), but it'd be much easier if class injection worked on this game.