dbghelp.hpp 6.4 KB

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