warbler / SharpMonoInjector

A tool for injecting assemblies into Mono embedded applications, commonly Unity Engine based games
MIT License
310 stars 108 forks source link

Injection failed: mono_class_from_name() returned NULL + GAME CRASH #12

Open ZeeDEU opened 5 years ago

ZeeDEU commented 5 years ago

`` using System; using UnityEngine;

namespace InjectUnityBased { public class ForceLoader { public static GameObject loadobject;

    public static void Init()
    {
        loadobject = new GameObject();
        loadobject.AddComponent<ForceCheats>();
        UnityEngine.Object.DontDestroyOnLoad(loadobject);
    }

    public static void Unload()
    {
        UnityEngine.Object.Destroy(loadobject);
    }
}

} ``

pls i need to fix that :/

huyngkh commented 4 years ago

I've got the same issue. Because the method GetClassFromName() of the class Injector return a pointer of zero. @class = GetClassFromName(image, @namespace, className);

Since I dug deeper in the library code and I've found the issue comes from the method Execute() of the same class. It is successful at creating a remote thread but failed at reading a long value from a previous allocated memory by the following code line: IntPtr ret = Is64Bit ? (IntPtr)_memory.ReadLong(retValPtr) : (IntPtr)_memory.ReadInt(retValPtr);

The return value ret gets zero. It looks like causing by the method 'ReadProcessMemory' from ReadLong() because it returns an array of zero bytes, although the target address to read seems valid (non-zero).

I have no idea how to overcome it. If you don't have time to fix it, could you give me any suggestion to do myself? @warbler

More details for my apps: Target process: 64 bits Injected dll: 64 bits SharpMonoInjector console: 64 bits

Error: Failed to inject assembly: SharpMonoInjector.InjectorException: mono_class_from_name() returned NULL

rie-kumar commented 4 years ago

I'm also running into this issue too.

frap129 commented 4 years ago

I had this issue, fix (For me at least) was to compile my dll with the same version of .NET framework as the game I was injecting it into.

rie-kumar commented 4 years ago

I had this issue, fix (For me at least) was to compile my dll with the same version of .NET framework as the game I was injecting it into.

I can confirm that fixed it for me too.