简体   繁体   中英

EasyHook - CRT Debug Assertion Failed - “Buffer too small”

I have an injector which calls the following (abridged) code:

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);

The DLL that should be injected has just the following code:

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

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

Unfortunately the injector just crashes with the typical Windows Error Reporting tool showing up and no visual exception message at all and not even going into the DLL. The error from the Event View is this one:

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

When running in debug mode, I am not able to step through the EasyHook code step by step to find the critical location, but I am getting at least one exception:

在此处输入图片说明

Do you have any suggestions on how to further debug this issue and find out what's causing it? I even tried to close various applications to reduce interferences but nothing helped.

I could resolve the error - the application that I was invoking was getting a command line argument as well (which is not in my sample code unfortunately) which is too long for the library. Therefore I increased the buffer size right here as well as the referring call to it right here and it works now without any issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM