C # Inline-hook/api-hook

Source: Internet
Author: User

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
  1. [DllImport ("user32", EntryPoint = "MessageBoxW", CharSet = CharSet.Unicode)]
  2. Public static extern int MessageBox (IntPtr hWnd, string lptext, string lpcaption, uint utype);
  3. [STAThread]
  4. static void Main (string[] args)
  5. {
  6. Inlinehook ich = new Inlinehook ();
  7. Ich. Install (Ich. GetProcAddress ("user32", "MessageBoxW"), Ich.  GetProcAddress (new MessageBoxW (Cb_messagebox)));
  8. //MessageBox.Show ("Hello World", "Advapi32");
  9. MessageBox (IntPtr.Zero, " Hello World", "Advapi32", 0);
  10. Console.readkey (false);
  11. }

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.