c# - EasyHook - CRT 调试断言失败 - "Buffer too small"

标签 c# hook msvcrt easyhook

我有一个调用以下(删节)代码的注入(inject)器:

var processes = Process.GetProcessesByName("target");
/* ... */
var process = processes[0];
/* ... */
process.Kill();
RemoteHooking.CreateAndInject(process.MainModule.FileName, string.Empty, 0,
    InjectionOptions.NoService | InjectionOptions.DoNotRequireStrongName,
    typeof(EntryPoint).Assembly.Location, typeof(EntryPoint).Assembly.Location,
    out injectedProcessId, null);

应该注入(inject)的DLL只有下面的代码:

public class EntryPoint : IEntryPoint {
    public EntryPoint(RemoteHooking.IContext InContext) {}

    public void Run(RemoteHooking.IContext InContext) {
        RemoteHooking.WakeUpProcess();
        Thread.Sleep(5000);
    }
}

不幸的是,注入(inject)器崩溃了,典型的 Windows 错误报告工具出现了,根本没有视觉异常消息,甚至没有进入 DLL。事件 View 的错误是这样的:

Faulting application name: TestInjector.vshost.exe, version: 14.0.23107.0, time stamp: 0x559b788a
Faulting module name: EasyHook64.dll, version: 2.7.0.0, time stamp: 0x589704aa
Exception code: 0xc0000409
Fault offset: 0x0000000000091a9b

在 Debug模式下运行时,我无法逐步通过 EasyHook 代码找到关键位置,但我至少遇到一个异常:

enter image description here

对于如何进一步调试此问题并找出导致它的原因,您有什么建议吗?我什至尝试关闭各种应用程序以减少干扰,但无济于事。

最佳答案

我可以解决这个错误——我调用的应用程序也获得了一个命令行参数(不幸的是它不在我的示例代码中),这对于库来说太长了。因此我增加了缓冲区大小 right here以及对它的引用调用right here现在可以正常使用了。

关于c# - EasyHook - CRT 调试断言失败 - "Buffer too small",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42053685/

相关文章:

c++ - 为什么这个系统范围的 CBT Hook 不能正常工作?

c - 我如何覆盖加载了 dlopen 的库中的全局符号?

visual-c++ - 列出可用的平台工具集

c++ - 找不到 MSVCP80.dll(并排问题?)

wordpress - 删除插件类中定义的操作

c++ - 如何在执行 LoadLibrary ("*.exe"时初始化 CRT)

c# - 如果发送特定消息,如何运行代码(Telegram Bot)

c# - 如何使用 Moq 模拟 ILogger/ILoggerService

c# - 为什么编译器不喜欢隐式转换为 uint?

c# - WCF 和 Entities Framework 延迟加载