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.