You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
5.7 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/toolhelp/heap_sequence.hpp
  3. *
  4. * Purpose: TOOLHELP heap sequence class.
  5. *
  6. * Created: 21st May 2005
  7. * Updated: 10th August 2009
  8. *
  9. * Thanks: To Pablo for contributing this great library.
  10. *
  11. * Home: http://stlsoft.org/
  12. *
  13. * Copyright (c) 2005-2009, Pablo Aguilar
  14. * Copyright (c) 2006-2007, Matthew Wilson
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without
  18. * modification, are permitted provided that the following conditions are met:
  19. *
  20. * - Redistributions of source code must retain the above copyright notice, this
  21. * list of conditions and the following disclaimer.
  22. * - Redistributions in binary form must reproduce the above copyright notice,
  23. * this list of conditions and the following disclaimer in the documentation
  24. * and/or other materials provided with the distribution.
  25. * - Neither the name(s) of Matthew Wilson and Synesis Software, nor Pablo
  26. * Aguilar, nor the names of any contributors may be used to endorse or
  27. * promote products derived from this software without specific prior written
  28. * permission.
  29. *
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  31. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  32. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  33. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  34. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  35. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  36. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  37. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  38. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  39. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGE.
  41. *
  42. * ////////////////////////////////////////////////////////////////////// */
  43. /** \file winstl/toolhelp/heap_sequence.hpp
  44. *
  45. * \brief [C++ only] Definition of the \link winstl::heap_sequence heap_sequence\endlink class
  46. * (\ref group__library__windows_toolhelp "Windows ToolHelp" Library).
  47. */
  48. #ifndef WINSTL_INCL_WINSTL_TOOLHELP_HPP_HEAP_SEQUENCE
  49. #define WINSTL_INCL_WINSTL_TOOLHELP_HPP_HEAP_SEQUENCE
  50. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  51. # define WINSTL_VER_WINSTL_TOOLHELP_HPP_HEAP_SEQUENCE_MAJOR 1
  52. # define WINSTL_VER_WINSTL_TOOLHELP_HPP_HEAP_SEQUENCE_MINOR 1
  53. # define WINSTL_VER_WINSTL_TOOLHELP_HPP_HEAP_SEQUENCE_REVISION 2
  54. # define WINSTL_VER_WINSTL_TOOLHELP_HPP_HEAP_SEQUENCE_EDIT 9
  55. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  56. /* /////////////////////////////////////////////////////////////////////////
  57. * Includes
  58. */
  59. #ifndef WINSTL_INCL_WINSTL_H_WINSTL
  60. # include <winstl/winstl.h>
  61. #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */
  62. #ifdef STLSOFT_CF_PRAGMA_ONCE_SUPPORT
  63. # pragma once
  64. #endif /* STLSOFT_CF_PRAGMA_ONCE_SUPPORT */
  65. #ifndef WINSTL_INCL_WINSTL_TOOLHELP_HPP_SEQUENCE_BASE
  66. # include <winstl/toolhelp/sequence_base.hpp>
  67. #endif /* !WINSTL_INCL_WINSTL_TOOLHELP_HPP_SEQUENCE_BASE */
  68. /* /////////////////////////////////////////////////////////////////////////
  69. * Namespace
  70. */
  71. #ifndef _WINSTL_NO_NAMESPACE
  72. # if defined(_STLSOFT_NO_NAMESPACE) || \
  73. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  74. /* There is no stlsoft namespace, so must define ::winstl */
  75. namespace winstl
  76. {
  77. # else
  78. /* Define stlsoft::winstl_project */
  79. namespace stlsoft
  80. {
  81. namespace winstl_project
  82. {
  83. # endif /* _STLSOFT_NO_NAMESPACE */
  84. #endif /* !_WINSTL_NO_NAMESPACE */
  85. /* /////////////////////////////////////////////////////////////////////////
  86. * Classes
  87. */
  88. // th_sequence_value_traits specialization for heap_sequence
  89. ////////////////////////////////////////////////////////////////////////////
  90. #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_VALUE HEAPLIST32
  91. #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_FIRST Heap32ListFirst
  92. #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_NEXT Heap32ListNext
  93. #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_FLAG TH32CS_SNAPHEAPLIST
  94. #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_CREATE_SNAPSHOT_FAIL_MESSAGE TEXT("Could not create heap list snapshot")
  95. #include <winstl/toolhelp/sequence_value_traits.hpp>
  96. /** \brief An STL collection for accessing heap information.
  97. *
  98. * \ingroup group__library__windows_toolhelp
  99. */
  100. typedef th_sequence_base<HEAPLIST32> heap_sequence;
  101. /** \brief [IMPLEMENTATION] Specialisation of
  102. * \link winstl::sequence_doesnt_use_pid sequence_doesnt_use_pid\endlink to proscribe
  103. * use of the non-default constructor of the HEAPLIST32 specialisation of
  104. * \link winstl::th_sequence_base th_sequence_base\endlink.
  105. */
  106. STLSOFT_TEMPLATE_SPECIALISATION
  107. struct sequence_doesnt_use_pid<HEAPLIST32>
  108. {};
  109. /** \brief Attribute shim for retrieving the process id associated with the HEAPLIST32 instance
  110. *
  111. * \ingroup group__library__windows_toolhelp
  112. *
  113. * \param hl The HEAPLIST32 instance
  114. */
  115. inline DWORD get_pid(HEAPLIST32 const& hl)
  116. {
  117. return hl.th32ProcessID;
  118. }
  119. /* ////////////////////////////////////////////////////////////////////// */
  120. #ifndef _WINSTL_NO_NAMESPACE
  121. # if defined(_STLSOFT_NO_NAMESPACE) || \
  122. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  123. } // namespace winstl
  124. # else
  125. } // namespace winstl_project
  126. } // namespace stlsoft
  127. # endif /* _STLSOFT_NO_NAMESPACE */
  128. #endif /* !_WINSTL_NO_NAMESPACE */
  129. /* ////////////////////////////////////////////////////////////////////// */
  130. #endif /* WINSTL_INCL_WINSTL_TOOLHELP_HPP_HEAP_SEQUENCE */
  131. /* ///////////////////////////// end of file //////////////////////////// */