The principle and realization of the technique of mouse screen word-taking

Source: Internet
Author: User

"Mouse screen word" technology is widely used in the electronic dictionary, such as the four-way and Kingsoft and other software, this technology seems simple, in fact, the implementation of the Windows system is very complex, in general there are two ways to achieve:

The first: The use of interception of some GDI API calls to implement, such as Textout,textouta.

Second: Copy each Device context (DC) and track all actions that modify the context (DC).

The second method is more powerful, but not compatible, and the first method uses the Intercept WINDOWSAPI call, the technology is far more powerful than you can imagine, it is no exaggeration to say that, using WINDOWSAPI interception technology, you could transform the entire operating system, In fact, many of the plug-in Windows Chinese platform is so implemented! This technique is also the subject of this article.

The WINDOWSAPI call, in particular, can be divided into two ways:

The first method can be intercepted by directly overwriting the WINAPI image in memory, embedding the assembly code, and then jumping to the specified address when it is invoked. The second method overwrites the IAT (Import Address table entry form). REDIRECT WINAPI function calls to implement the interception of WINAPI.

The implementation of the first method is cumbersome and more difficult under Win95 and 98, because while Microsoft says the Win16 API is reserved for compatibility only, programmers should call 32-bit APIs as much as possible, which is actually not the case at all! Most of the 32-bit APIs inside the win 9x have been transformed to call the 16-bit API with the same name, which means we need to embed 16-bit assembler code in the blocked function!

We are going to introduce the second interception method, which runs under Win95, 98 and NT, and is more stable and has better compatibility. Because of the need for management of Windows virtual memory, breaking the process boundary wall, injecting code into the application's process space, PE (portable executable) file format, and IAT (Input Address table) and other low-level knowledge, So let's start with a brief introduction of the knowledge involved, and finally give the key code for the Intercept section.

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.