1 /*
2 * Copyright 2015 Klemens Morgenstern
3 * Copyright 2016 Jorge Lodos
4 * Copyright 2016 Andrey Semashev
5 *
6 * Distributed under the Boost Software License, Version 1.0.
7 * See http://www.boost.org/LICENSE_1_0.txt
8 */
9
10 #ifndef BOOST_WINAPI_DBGHELP_HPP_INCLUDED_
11 #define BOOST_WINAPI_DBGHELP_HPP_INCLUDED_
12
13 #include <boost/winapi/basic_types.hpp>
14
15 #if defined( BOOST_USE_WINDOWS_H )
16 #if !defined( BOOST_WINAPI_IS_MINGW )
17 #include <dbghelp.h>
18 #else
19 // In MinGW there is no dbghelp.h but an older imagehlp.h header defines some of the symbols from it.
20 // Note that the user has to link with libimagehlp.a instead of libdbghelp.a for it to work.
21 #include <imagehlp.h>
22 #endif
23 #endif
24
25 #ifdef BOOST_HAS_PRAGMA_ONCE
26 #pragma once
27 #endif
28
29 #if BOOST_WINAPI_PARTITION_DESKTOP
30
31 #include <boost/winapi/detail/header.hpp>
32
33 // Some symbols declared below are not present in all versions of Windows SDK, MinGW and MinGW-w64.
34 // dbghelp.h/imagehlp.h define the API_VERSION_NUMBER macro which we use to detect its version.
35 // When the macro is not available we can only guess based on the compiler version or SDK type.
36 #if defined(API_VERSION_NUMBER)
37 #if API_VERSION_NUMBER >= 11
38 // UnDecorateSymbolNameW available since Windows SDK 6.0A and MinGW-w64 (as of 2016-02-14)
39 #define BOOST_WINAPI_DETAIL_HAS_UNDECORATESYMBOLNAMEW
40 #endif
41 #elif defined(_MSC_VER) && _MSC_VER >= 1500
42 // Until MSVC 9.0 Windows SDK was bundled in Visual Studio and didn't have UnDecorateSymbolNameW.
43 // Supposedly, Windows SDK 6.0A was the first standalone one and it is used with MSVC 9.0.
44 #define BOOST_WINAPI_DETAIL_HAS_UNDECORATESYMBOLNAMEW
45 #elif !defined(BOOST_WINAPI_IS_MINGW)
46 // MinGW does not provide UnDecorateSymbolNameW (as of 2016-02-14)
47 #define BOOST_WINAPI_DETAIL_HAS_UNDECORATESYMBOLNAMEW
48 #endif
49
50 #if !defined( BOOST_USE_WINDOWS_H )
51 extern "C" {
52
53 struct API_VERSION;
54
55 BOOST_WINAPI_IMPORT boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC
56 UnDecorateSymbolName(
57 boost::winapi::LPCSTR_ DecoratedName,
58 boost::winapi::LPSTR_ UnDecoratedName,
59 boost::winapi::DWORD_ UndecoratedLength,
60 boost::winapi::DWORD_ Flags);
61
62 #if defined( BOOST_WINAPI_DETAIL_HAS_UNDECORATESYMBOLNAMEW )
63 BOOST_WINAPI_IMPORT boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC
64 UnDecorateSymbolNameW(
65 boost::winapi::LPCWSTR_ DecoratedName,
66 boost::winapi::LPWSTR_ UnDecoratedName,
67 boost::winapi::DWORD_ UndecoratedLength,
68 boost::winapi::DWORD_ Flags);
69 #endif
70
71 BOOST_WINAPI_IMPORT API_VERSION* BOOST_WINAPI_WINAPI_CC
72 ImagehlpApiVersion(BOOST_WINAPI_DETAIL_VOID);
73
74 } // extern "C"
75 #endif
76
77 namespace boost {
78 namespace winapi {
79
80 #if defined( BOOST_USE_WINDOWS_H )
81
82 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_COMPLETE_ = UNDNAME_COMPLETE;
83 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_LEADING_UNDERSCORES_ = UNDNAME_NO_LEADING_UNDERSCORES;
84 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_MS_KEYWORDS_ = UNDNAME_NO_MS_KEYWORDS;
85 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_FUNCTION_RETURNS_ = UNDNAME_NO_FUNCTION_RETURNS;
86 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ALLOCATION_MODEL_ = UNDNAME_NO_ALLOCATION_MODEL;
87 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ALLOCATION_LANGUAGE_ = UNDNAME_NO_ALLOCATION_LANGUAGE;
88 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_MS_THISTYPE_ = UNDNAME_NO_MS_THISTYPE;
89 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_CV_THISTYPE_ = UNDNAME_NO_CV_THISTYPE;
90 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_THISTYPE_ = UNDNAME_NO_THISTYPE;
91 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ACCESS_SPECIFIERS_ = UNDNAME_NO_ACCESS_SPECIFIERS;
92 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_THROW_SIGNATURES_ = UNDNAME_NO_THROW_SIGNATURES;
93 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_MEMBER_TYPE_ = UNDNAME_NO_MEMBER_TYPE;
94 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_RETURN_UDT_MODEL_ = UNDNAME_NO_RETURN_UDT_MODEL;
95 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_32_BIT_DECODE_ = UNDNAME_32_BIT_DECODE;
96 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NAME_ONLY_ = UNDNAME_NAME_ONLY;
97 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ARGUMENTS_ = UNDNAME_NO_ARGUMENTS;
98 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_SPECIAL_SYMS_ = UNDNAME_NO_SPECIAL_SYMS;
99
100 #else // defined( BOOST_USE_WINDOWS_H )
101
102 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_COMPLETE_ = 0x00000000;
103 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_LEADING_UNDERSCORES_ = 0x00000001;
104 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_MS_KEYWORDS_ = 0x00000002;
105 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_FUNCTION_RETURNS_ = 0x00000004;
106 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ALLOCATION_MODEL_ = 0x00000008;
107 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ALLOCATION_LANGUAGE_ = 0x00000010;
108 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_MS_THISTYPE_ = 0x00000020;
109 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_CV_THISTYPE_ = 0x00000040;
110 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_THISTYPE_ = 0x00000060;
111 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ACCESS_SPECIFIERS_ = 0x00000080;
112 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_THROW_SIGNATURES_ = 0x00000100;
113 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_MEMBER_TYPE_ = 0x00000200;
114 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_RETURN_UDT_MODEL_ = 0x00000400;
115 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_32_BIT_DECODE_ = 0x00000800;
116 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NAME_ONLY_ = 0x00001000;
117 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ARGUMENTS_ = 0x00002000;
118 BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_SPECIAL_SYMS_ = 0x00004000;
119
120 #endif // defined( BOOST_USE_WINDOWS_H )
121
122 using ::UnDecorateSymbolName;
123 #if defined( BOOST_WINAPI_DETAIL_HAS_UNDECORATESYMBOLNAMEW )
124 using ::UnDecorateSymbolNameW;
125 #endif
126
127 typedef struct BOOST_MAY_ALIAS API_VERSION {
128 USHORT_ MajorVersion;
129 USHORT_ MinorVersion;
130 USHORT_ Revision;
131 USHORT_ Reserved;
132 } API_VERSION_, *LPAPI_VERSION_;
133
ImagehlpApiVersion()134 BOOST_FORCEINLINE LPAPI_VERSION_ ImagehlpApiVersion()
135 {
136 return reinterpret_cast<LPAPI_VERSION_>(::ImagehlpApiVersion());
137 }
138
undecorate_symbol_name(LPCSTR_ DecoratedName,LPSTR_ UnDecoratedName,DWORD_ UndecoratedLength,DWORD_ Flags)139 BOOST_FORCEINLINE DWORD_ undecorate_symbol_name(
140 LPCSTR_ DecoratedName,
141 LPSTR_ UnDecoratedName,
142 DWORD_ UndecoratedLength,
143 DWORD_ Flags)
144 {
145 return ::UnDecorateSymbolName(
146 DecoratedName,
147 UnDecoratedName,
148 UndecoratedLength,
149 Flags);
150 }
151
152 #if defined( BOOST_WINAPI_DETAIL_HAS_UNDECORATESYMBOLNAMEW )
153
undecorate_symbol_name(LPCWSTR_ DecoratedName,LPWSTR_ UnDecoratedName,DWORD_ UndecoratedLength,DWORD_ Flags)154 BOOST_FORCEINLINE DWORD_ undecorate_symbol_name(
155 LPCWSTR_ DecoratedName,
156 LPWSTR_ UnDecoratedName,
157 DWORD_ UndecoratedLength,
158 DWORD_ Flags)
159 {
160 return ::UnDecorateSymbolNameW(
161 DecoratedName,
162 UnDecoratedName,
163 UndecoratedLength,
164 Flags);
165 }
166
167 #endif
168
169 }
170 }
171
172 #include <boost/winapi/detail/footer.hpp>
173
174 #endif // BOOST_WINAPI_PARTITION_DESKTOP
175 #endif // BOOST_WINAPI_DBGHELP_HPP_INCLUDED_
176