最好的重载方法匹配有一些无效的参数WriteProcessMemory

时间:2014-07-18 23:44:38

标签: c#

此部分代码无效:

public void WriteNOP(int Address)
    {
        byte[] buffer = new byte[] { 0x90, 0x90 };
        IntPtr zero = IntPtr.Zero;
        WriteProcessMemory(this.pHandel, (IntPtr) Address, buffer, (uint) buffer.Length, out zero);

错误:

The best overloaded method match for 'Send_to_Console_CSharp.Form1.WriteProcessMemory(SYstem.IntPtr,SystemIntPtr, byte[], uint, int)' has some invalid arguments

有关错误原因的任何猜测?

编辑:我删除了最后一个参数,但现在出现了一个新错误:

No overload for the 'Writeprocessmemory' method, it takes '4' arguments

1 个答案:

答案 0 :(得分:0)

仔细查看您的方法签名,如下所示,最后一个参数只是int类型,而不是out int,而您将其作为out参数传递给IntPtr } type cause zero声明为IntPtr zero = IntPtr.Zero;

WriteProcessMemory(SYstem.IntPtr,SystemIntPtr, byte[], uint, int)

您的方法电话

WriteProcessMemory(this.pHandel, (IntPtr) Address, buffer, (uint) buffer.Length, out zero); 
                                                                                   <-- Here