Home > Net >  O WM_COPYDATA EasyHook hook example
O WM_COPYDATA EasyHook hook example

Time:09-18

O WM_COPYDATA EasyHook hook example
It is a process of I use the SetWindowsHookEx install hooks, check a lot of information, said can't install global hooks, install hooks all unsuccessful (0), in my post [https://bbs.csdn.net/topics/396175597] it is suggested that using easyhook, all in this post, please win copydate example,
Public class CopyDataHook {

Private const int WM_COPYDATA=https://bbs.csdn.net/topics/0x004A;
Private IntPtr nextHookPtr;
Private HookProc HookProc;
Private const int HookType. CallWndProc=4;

[DllImport (" User32. DLL)]
Public static extern void UnhookWindowsHookEx (IntPtr handle);
[DllImport (" User32. DLL)]
Public static extern IntPtr SetWindowsHookEx (int idHook, [MarshalAs (UnmanagedType. FunctionPtr)] HookProc LPFN, IntPtr hinstance, int threadID); .
[DllImport (" User32. DLL)]
Public static extern IntPtr CallNextHookEx (IntPtr handle, int code, IntPtr wparam, IntPtr lparam);

Public CopyDataHook ()
{
NextHookPtr=IntPtr. Zero;
}
Public void SetCopyDataHook ()
{
If (nextHookPtr!=IntPtr. Zero)
return;
HookProc=new hookProc (CopyDatahookProc);
NextHookPtr=SetWindowsHookEx ((int) HookType CallWndProc,
HookProc,
Marshal. GetHINSTANCE (
The Assembly. GetExecutingAssembly (.) GetModules () [0]),
0);
Console. Write (string Format (" HookPtr: {0} ", nextHookPtr. ToString ()));
}
}

CodePudding user response:

Can install global hooks (hook function in the DLL (dynamic link libraries of c/c + +)),
Dynamic libraries of c # and c/c + +, so can only use local hooks
MSDN, very comprehensive, or you will write a friend help you write good, direct call you, is not the same

CodePudding user response:

reference 1st floor mingcsharp response:
can install global hooks (hook function in the DLL (dynamic link libraries of c/c + +)),
Dynamic libraries of c # and c/c + +, so can only use local hooks
MSDN, very comprehensive, or you will write a friend help you write good, direct call you, is not the same


Is looking for someone to write it, I can find will write friends I would not be in this waste of time,,,
Or have written will help to leave a contact way, will ChongXie

CodePudding user response:

Didn't see, do you want to hook the inside of the c # code WM_COPYDATA, or native code inside?

Managed and unmanaged hook is different

CodePudding user response:


Dog child needs in unmanaged assembly

Even if you have an unmanaged DLL, then managed call unmanaged is still a problem that can call this

Remember is not call
  •  Tags:  
  • C#
  • Related