I looked up the relevant C # information, but did not find that there was a provision on the Api-hook
Including the application library I wrote a set of Inline-hook libraries to support x64, x86 based on
The CLR's common language, such as C #, C+/CLR, and vb.net, can all use this class library to change the underlying API
result, such as we need to make a grab kit, or intercept a function called inside an ActiveX object
Very useful some people use the SPI when making "cut-off" tools, but they can also be implemented by this technology
Calling MessageBox.Show ("Hello World", "Advapi32") jumps to the Cb_messagebox function
MessageBox.Show () This method calls the MessageBoxW function in the lower layer, and we can try
[CSharp]View Plaincopy
- [DllImport ("user32", EntryPoint = "MessageBoxW", CharSet = CharSet.Unicode)]
- Public static extern int MessageBox (IntPtr hWnd, string lptext, string lpcaption, uint utype);
- [STAThread]
- static void Main (string[] args)
- {
- Inlinehook ich = new Inlinehook ();
- Ich. Install (Ich. GetProcAddress ("user32", "MessageBoxW"), Ich. GetProcAddress (new MessageBoxW (Cb_messagebox)));
- //MessageBox.Show ("Hello World", "Advapi32");
- MessageBox (IntPtr.Zero, " Hello World", "Advapi32", 0);
- Console.readkey (false);
- }
The above code is executed with the same result as the topmost one. This library provides two of the separate requirements. NET 2/4
Different class libraries, basically meet the needs of development but this one has always been C + +, but I believe in the future
would be C # to do this piece, but rather than wait until the time to provide the class library as early as the class library, we do not need
To study how to achieve in my class library, although the class library I slightly confused but you have to study and do not
is very difficult, but I am too lazy to discuss how to implement the lower layer DLL is not into the copyright information, very
Simple you do not see any information in the properties, except for an internal name without any information, so you do not
Must worry the following is an explanation of the function interfaces and definitions exported in Inlinehook.
Inlinehook.getprocaddress (String strlibraryname, String strmethodname)//Fetch function address (library file, function name)
Inlinehook.getprocaddress (System.Delegate D)//Fetch function address (valid delegate)
Inlinehook.install (System.IntPtr oldmethodaddress, System.IntPtr newmethodaddress)//Installation hooks (source function address, new function address)
Inlinehook.resume ()//Recovery hooks
Inlinehook.suspend ()//Hang Hooks
Inlinehook.uninstall ()//unload hooks
Sample:
CAT (Inline-hook) http://pan.baidu.com/s/1kTKjFPt//sample address with class library
Each version of the folder contains x86/x64 two copies of different libraries, if you use this type of library have doubts about the place can leave a message below me.
C # Inline-hook/api-hook