0

我正在使用 EasyHook 将 DLL 注入进程(Duh!)但是,当调用 Inject 函数时,我收到以下错误消息:

“给定的用户库没有在 'EasyHook.IEntryPoint' 接口中导出正确的 Run(EasyHook.InjectionLoader+REMOTE_ENTRY_INFO) 方法。”

我相信它确实如此。

这是DLL代码:

using System;
using EasyHook;
using System.Windows.Forms;

namespace EasyHookDLL
{
    public class Main : IEntryPoint
    {
        public Main(RemoteHooking.IContext IContext, String InChannelName)
        {
            MessageBox.Show("Constructor called");
        }

        public void Run(RemoteHooking.IContext IContext, String InChannelName)
        {
            MessageBox.Show("Run method called");
        }
    }
}

这是我的注射器:

using System;
using EasyHook;
using System.Diagnostics;
using System.Threading;

namespace EasyHookInjector
{
    class Program
    {
        static void Main(string[] args)
        {
            System.EnterpriseServices.Internal.Publish publish = new System.EnterpriseServices.Internal.Publish();
            publish.GacInstall("EasyHook.dll");
            publish.GacInstall("EasyHook32.dll");
            publish.GacInstall("EasyHook64.dll");
            publish.GacInstall("EasyLoad32.dll");
            publish.GacInstall("EasyLoad64.dll");

            Console.WriteLine("Waiting for process to start...");
            Process[] processes;
            while ((processes = Process.GetProcessesByName("Process name")).Length == 0)
            {
                Thread.Sleep(500);
            }

            Console.WriteLine("Injecting...");

            RemoteHooking.Inject(processes[0].Id, 
                @"dll path.dll", 
                @"dll path.dll", 
                null);
        }
    }
}

我也尝试将所有 EasyHook 文件添加到调试文件夹中,但这没有帮助。

4

0 回答 0