Thoughts on getprocaddress Functions

Source: Internet
Author: User

Author: Zhu Jincan

Source:Http://www.cnblogs.com/clever101

 

GetprocaddressIt is a strange Win32 API function. Generally, Win32 API functions that involve string parameters have two internal versions: An ANSI version and a unicode version, however, the versions used for users often use the string type of lpctstr to be compatible with the Multi-Byte Character Set and Unicode Character Set.

But let's take a look at the second parameter of getprocaddress, The lpcstr lpprocname, which clearly tells you that this is a multi-byte string. In the header file where getprocaddress is located, we also see that it has only one version.

Why? I used to be confused about this.

 

Previously, I explained to my colleagues what static libraries and import/export libraries are. I suddenly started to understand the design of getprocaddress. We know that a DLL file is essentially a PE file. What character sets are used inside PE files? According to my previous research, it uses multi-byte character sets. Therefore, getprocaddress is used to find its address in the DLL through the function name. It is natural to use multi-byte character input parameters. Windows core programming tells us that string operations are involved in all core win API functions. If you input a multi-byte string, the system needs it to be converted to a unicode string and then transmitted to the operating system. getprocaddress is afraid that it is a rare API function that does not need to be converted to a unicode string to be transferred to a multi-byte string. Let's take a deeper look. If we are familiar with the PE file structure, we can implement getprocaddress on our own.

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.