How to hook an application?

后端 未结 5 1175
情书的邮戳
情书的邮戳 2020-12-18 16:20

I\'m trying to hook the creation of a windows in my C# app.

static IntPtr hhook = IntPtr.Zero;
static NativeMethods.HookProc hhookProc;

static void Main(str         


        
5条回答
  •  佛祖请我去吃肉
    2020-12-18 17:00

    This won't work in C#

    Scope: Thread

    If the application installs a hook procedure for a thread of a different application, the procedure must be in a DLL.

    (Documentation of SetWindowsHookEx)

    Scope: Global

    To install a global hook, a hook must have a native DLL export to inject itself in another process that requires a valid, consistent function to call into. This behavior requires a DLL export. The .NET Framework does not support DLL exports.

    (Source)

提交回复
热议问题