1 // dbghelp.hpp --------------------------------------------------------------//
3 // Copyright 2015 Klemens Morgenstern
4 // Copyright 2016 Jorge Lodos
5 // Copyright 2016 Andrey Semashev
7 // Distributed under the Boost Software License, Version 1.0.
8 // See http://www.boost.org/LICENSE_1_0.txt
11 #ifndef BOOST_DETAIL_WINAPI_DBGHELP_HPP
12 #define BOOST_DETAIL_WINAPI_DBGHELP_HPP
14 #include <boost/detail/winapi/basic_types.hpp>
16 #if defined( BOOST_USE_WINDOWS_H )
17 #if !defined( BOOST_WINAPI_IS_MINGW )
20 // In MinGW there is no dbghelp.h but an older imagehlp.h header defines some of the symbols from it.
21 // Note that the user has to link with libimagehlp.a instead of libdbghelp.a for it to work.
26 #ifdef BOOST_HAS_PRAGMA_ONCE
30 // Some symbols declared below are not present in all versions of Windows SDK, MinGW and MinGW-w64.
31 // dbghelp.h/imagehlp.h define the API_VERSION_NUMBER macro which we use to detect its version.
32 // When the macro is not available we can only guess based on the compiler version or SDK type.
33 #if defined(API_VERSION_NUMBER)
34 #if API_VERSION_NUMBER >= 11
35 // UnDecorateSymbolNameW available since Windows SDK 6.0A and MinGW-w64 (as of 2016-02-14)
36 #define BOOST_DETAIL_WINAPI_HAS_UNDECORATESYMBOLNAMEW
38 #elif defined(_MSC_VER) && _MSC_VER >= 1500
39 // Until MSVC 9.0 Windows SDK was bundled in Visual Studio and didn't have UnDecorateSymbolNameW.
40 // Supposedly, Windows SDK 6.0A was the first standalone one and it is used with MSVC 9.0.
41 #define BOOST_DETAIL_WINAPI_HAS_UNDECORATESYMBOLNAMEW
42 #elif !defined(BOOST_WINAPI_IS_MINGW)
43 // MinGW does not provide UnDecorateSymbolNameW (as of 2016-02-14)
44 #define BOOST_DETAIL_WINAPI_HAS_UNDECORATESYMBOLNAMEW
47 #if !defined( BOOST_USE_WINDOWS_H )
52 BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI
54 boost::detail::winapi::LPCSTR_ DecoratedName,
55 boost::detail::winapi::LPSTR_ UnDecoratedName,
56 boost::detail::winapi::DWORD_ UndecoratedLength,
57 boost::detail::winapi::DWORD_ Flags);
59 #if defined( BOOST_DETAIL_WINAPI_HAS_UNDECORATESYMBOLNAMEW )
60 BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI
61 UnDecorateSymbolNameW(
62 boost::detail::winapi::LPCWSTR_ DecoratedName,
63 boost::detail::winapi::LPWSTR_ UnDecoratedName,
64 boost::detail::winapi::DWORD_ UndecoratedLength,
65 boost::detail::winapi::DWORD_ Flags);
68 BOOST_SYMBOL_IMPORT API_VERSION* WINAPI
69 ImagehlpApiVersion(BOOST_DETAIL_WINAPI_VOID);
78 #if defined( BOOST_USE_WINDOWS_H )
80 const DWORD_ UNDNAME_COMPLETE_ = UNDNAME_COMPLETE;
81 const DWORD_ UNDNAME_NO_LEADING_UNDERSCORES_ = UNDNAME_NO_LEADING_UNDERSCORES;
82 const DWORD_ UNDNAME_NO_MS_KEYWORDS_ = UNDNAME_NO_MS_KEYWORDS;
83 const DWORD_ UNDNAME_NO_FUNCTION_RETURNS_ = UNDNAME_NO_FUNCTION_RETURNS;
84 const DWORD_ UNDNAME_NO_ALLOCATION_MODEL_ = UNDNAME_NO_ALLOCATION_MODEL;
85 const DWORD_ UNDNAME_NO_ALLOCATION_LANGUAGE_ = UNDNAME_NO_ALLOCATION_LANGUAGE;
86 const DWORD_ UNDNAME_NO_MS_THISTYPE_ = UNDNAME_NO_MS_THISTYPE;
87 const DWORD_ UNDNAME_NO_CV_THISTYPE_ = UNDNAME_NO_CV_THISTYPE;
88 const DWORD_ UNDNAME_NO_THISTYPE_ = UNDNAME_NO_THISTYPE;
89 const DWORD_ UNDNAME_NO_ACCESS_SPECIFIERS_ = UNDNAME_NO_ACCESS_SPECIFIERS;
90 const DWORD_ UNDNAME_NO_THROW_SIGNATURES_ = UNDNAME_NO_THROW_SIGNATURES;
91 const DWORD_ UNDNAME_NO_MEMBER_TYPE_ = UNDNAME_NO_MEMBER_TYPE;
92 const DWORD_ UNDNAME_NO_RETURN_UDT_MODEL_ = UNDNAME_NO_RETURN_UDT_MODEL;
93 const DWORD_ UNDNAME_32_BIT_DECODE_ = UNDNAME_32_BIT_DECODE;
94 const DWORD_ UNDNAME_NAME_ONLY_ = UNDNAME_NAME_ONLY;
95 const DWORD_ UNDNAME_NO_ARGUMENTS_ = UNDNAME_NO_ARGUMENTS;
96 const DWORD_ UNDNAME_NO_SPECIAL_SYMS_ = UNDNAME_NO_SPECIAL_SYMS;
98 #else // defined( BOOST_USE_WINDOWS_H )
100 const DWORD_ UNDNAME_COMPLETE_ = 0x00000000;
101 const DWORD_ UNDNAME_NO_LEADING_UNDERSCORES_ = 0x00000001;
102 const DWORD_ UNDNAME_NO_MS_KEYWORDS_ = 0x00000002;
103 const DWORD_ UNDNAME_NO_FUNCTION_RETURNS_ = 0x00000004;
104 const DWORD_ UNDNAME_NO_ALLOCATION_MODEL_ = 0x00000008;
105 const DWORD_ UNDNAME_NO_ALLOCATION_LANGUAGE_ = 0x00000010;
106 const DWORD_ UNDNAME_NO_MS_THISTYPE_ = 0x00000020;
107 const DWORD_ UNDNAME_NO_CV_THISTYPE_ = 0x00000040;
108 const DWORD_ UNDNAME_NO_THISTYPE_ = 0x00000060;
109 const DWORD_ UNDNAME_NO_ACCESS_SPECIFIERS_ = 0x00000080;
110 const DWORD_ UNDNAME_NO_THROW_SIGNATURES_ = 0x00000100;
111 const DWORD_ UNDNAME_NO_MEMBER_TYPE_ = 0x00000200;
112 const DWORD_ UNDNAME_NO_RETURN_UDT_MODEL_ = 0x00000400;
113 const DWORD_ UNDNAME_32_BIT_DECODE_ = 0x00000800;
114 const DWORD_ UNDNAME_NAME_ONLY_ = 0x00001000;
115 const DWORD_ UNDNAME_NO_ARGUMENTS_ = 0x00002000;
116 const DWORD_ UNDNAME_NO_SPECIAL_SYMS_ = 0x00004000;
118 #endif // defined( BOOST_USE_WINDOWS_H )
120 using ::UnDecorateSymbolName;
121 #if defined( BOOST_DETAIL_WINAPI_HAS_UNDECORATESYMBOLNAMEW )
122 using ::UnDecorateSymbolNameW;
125 typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS API_VERSION {
126 USHORT_ MajorVersion;
127 USHORT_ MinorVersion;
130 } API_VERSION_, *LPAPI_VERSION_;
132 BOOST_FORCEINLINE LPAPI_VERSION_ ImagehlpApiVersion()
134 return reinterpret_cast<LPAPI_VERSION_>(::ImagehlpApiVersion());
137 BOOST_FORCEINLINE DWORD_ undecorate_symbol_name(
138 LPCSTR_ DecoratedName,
139 LPSTR_ UnDecoratedName,
140 DWORD_ UndecoratedLength,
143 return ::UnDecorateSymbolName(
150 #if defined( BOOST_DETAIL_WINAPI_HAS_UNDECORATESYMBOLNAMEW )
152 BOOST_FORCEINLINE DWORD_ undecorate_symbol_name(
153 LPCWSTR_ DecoratedName,
154 LPWSTR_ UnDecoratedName,
155 DWORD_ UndecoratedLength,
158 return ::UnDecorateSymbolNameW(
171 #endif // BOOST_DETAIL_WINAPI_DBGHELP_HPP