How Can I Debug Windows API Functions?

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

If you want to debug a Windows API function that has NT symbols loaded, you must do the following.

To set a breakpoint on a Windows API function with NT symbols loaded

  • In the function breakpoint, enter the function name together with the name of the DLL where the function resides (see the context operator). In 32-bit code, use the decorated form of the function name. To set a breakpoint on MessageBeep, for example, you must enter the following.

    {,,USER32.DLL}_MessageBeep@4
    

    To obtain the decorated name, see Viewing Decorated Names.

    You can test the decorated name and view it in disassembly code. While paused at the function in the Visual Studio debugger, right-click the function in the code editor or call stack window and choose Go to Disassembly.

  • In 64-bit code, you can use the undecorated name.

    {,,USER32.DLL}MessageBeep
    

See also