【发布时间】:2016-02-25 10:22:19
【问题描述】:
我想在kernel32.dll 中调用一个函数(不管是哪个函数)。它工作得很好。
现在我有以下问题:
另一个程序注入了在 kernel32.dll 中挂钩函数并更改其返回值的代码。我怎样才能调用 origin 函数呢?
在我可以先打开 我的 程序之前,它运行良好。但在 Windows 10 中,它调用了注入函数。
希望我能解释清楚。
这是一个例子:
我使用了ReadProcessMemory()这个函数,效果很好。有一个程序可以更改此功能。如果启动这个程序,我只会收到来自ReadProcessMemory() 的 0xFF。
例如,在 Windows 7 中,我只需要在另一个程序更改功能之前启动我的程序。
但在 Windows 10 中,它不再工作了。当另一个程序启动时,我只收到 0xFF。
所以我导入函数:
[DllImport(@"C:\WINDOWS\system32\kernel32.dll", EntryPoint = "ReadProcessMemory")]
private static extern bool ReadProcessMemory(IntPtr hProcess, UIntPtr lpBaseAddress, [Out] byte[] lpBuffer, UIntPtr nSize, IntPtr lpNumberOfBytesRead);
我的阅读功能:
public static bool ReadMemory(Int64 Address, ref byte[] buffer)
{
return ReadProcessMemory(ProcessHandle, (UIntPtr)Address, buffer, (UIntPtr)buffer.Length, IntPtr.Zero);
}
【问题讨论】:
-
不,一点都不清楚
-
这应该是一个问题吗...你需要给我更多的细节。什么程序在注入函数,返回值是什么,变成了什么?你是如何从 kernel32.dll 调用函数的?您正在使用的代码示例怎么样?
-
还不是很清楚。其他程序如何修改
ReadProcessMemory在您的程序中的行为方式?是否有一些骇人听闻的注入?我们怎么知道您不只是错误地调用ReadProcessMemory并且误诊了您的问题。除非您准备提供具体细节,否则没有人可以帮助您。请出示minimal reproducible example。