给定的用户库不会导出正确的Run方法

时间:2015-08-31 17:36:01

标签: c# easyhook

我正在使用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文件添加到调试文件夹中,但这没有帮助。

0 个答案:

没有答案