How to determine which DLLs contain specific W32 functions?

My application is a WPF application, and it already has code for an older type of DPI system recognition that works well in every version of windows except 8.1. It turns out that Microsoft has added a number of features in Windows 8.1 as part of their implementation for each DPI monitor. I need to implement code in my program in order to maintain this type of DPI awareness.

I have documentation that lists the DPI recognition features for each monitor and what their settings are. I need to import them into C # and call them from my window class. But I do not know which DLLs contain these functions! The documentation for the GetProcessDpiAwareness function, for example, does not indicate which DLL it is in.

How to find out what is export to DLL?

+7
c # dll winapi
source share
3 answers

Right from the head, stupid method: binary search in C:\Windows\System32 for GetProcessDpiAwareness , then exploring each event using Dependency Walker for export.

This gives the result: GetProcessDpiAwareness exported SHCore.dll .

You can also search for the titles and libraries of the Windows SDK, but in my case I did not find GetProcessDpiAwareness , to my surprise.

Another idea: run the following at a command prompt:

 for %f in (%windir%\system32\*.dll) do dumpbin.exe /exports %f >>%temp%\__exports 

Then search for %temp%\__exports for the API.

+3
source share

Usually, functions that work with the same resources are in the same DLL. Look at another dpi function, such as GetDpiForMonitor, and you will see that it is located in Shcore.dll

Edit: after you find the DLL in this way, you can double-check using the dependency host to see which functions are exported from this DLL.

0
source share

I know this was asked some time ago. (Each time I go to Google, this question arises. So let me share my method.)

If someone wants to look for functions in a DLL, there is this tool that will do this for you. In the case of GetProcessDpiAwareness on my Windows 10 (64-bit shcore.dll ) it is exported from shcore.dll as someone mentioned above. Here is a screenshot:

enter image description here


Although I need to anticipate it by saying that it would be wise to refer to the function documentation on MSDN instead. Currently you can find it at the bottom of each page:

enter image description here

If you experiment with the search, which I showed above, you will notice that many system functions are exported from several DLLs (some of which are undocumented). Therefore, if you simply blindly go with what you find in a search application, you may cause your program to crash in the future if Microsoft changes one of these undocumented features. So use it only for your own research or curiosity.

0
source share

All Articles