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.

153 lines
5.8 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/toolhelp/module_sequence.hpp
  3. *
  4. * Purpose: TOOLHELP module 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/module_sequence.hpp
  44. *
  45. * \brief [C++ only] Definition of the
  46. * \link winstl::module_sequence module_sequence\endlink class
  47. * (\ref group__library__windows_toolhelp "Windows ToolHelp" Library).
  48. */
  49. #ifndef WINSTL_INCL_WINSTL_TOOLHELP_HPP_MODULE_SEQUENCE
  50. #define WINSTL_INCL_WINSTL_TOOLHELP_HPP_MODULE_SEQUENCE
  51. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  52. # define WINSTL_VER_WINSTL_TOOLHELP_HPP_MODULE_SEQUENCE_MAJOR 1
  53. # define WINSTL_VER_WINSTL_TOOLHELP_HPP_MODULE_SEQUENCE_MINOR 1
  54. # define WINSTL_VER_WINSTL_TOOLHELP_HPP_MODULE_SEQUENCE_REVISION 2
  55. # define WINSTL_VER_WINSTL_TOOLHELP_HPP_MODULE_SEQUENCE_EDIT 9
  56. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  57. /* /////////////////////////////////////////////////////////////////////////
  58. * Includes
  59. */
  60. #ifndef WINSTL_INCL_WINSTL_H_WINSTL
  61. # include <winstl/winstl.h>
  62. #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */
  63. #ifdef STLSOFT_CF_PRAGMA_ONCE_SUPPORT
  64. # pragma once
  65. #endif /* STLSOFT_CF_PRAGMA_ONCE_SUPPORT */
  66. #ifndef WINSTL_INCL_WINSTL_TOOLHELP_HPP_SEQUENCE_BASE
  67. # include <winstl/toolhelp/sequence_base.hpp>
  68. #endif /* !WINSTL_INCL_WINSTL_TOOLHELP_HPP_SEQUENCE_BASE */
  69. /* /////////////////////////////////////////////////////////////////////////
  70. * Namespace
  71. */
  72. #ifndef _WINSTL_NO_NAMESPACE
  73. # if defined(_STLSOFT_NO_NAMESPACE) || \
  74. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  75. /* There is no stlsoft namespace, so must define ::winstl */
  76. namespace winstl
  77. {
  78. # else
  79. /* Define stlsoft::winstl_project */
  80. namespace stlsoft
  81. {
  82. namespace winstl_project
  83. {
  84. # endif /* _STLSOFT_NO_NAMESPACE */
  85. #endif /* !_WINSTL_NO_NAMESPACE */
  86. /* /////////////////////////////////////////////////////////////////////////
  87. * Classes
  88. */
  89. // th_sequence_value_traits specialization for module_sequence
  90. ////////////////////////////////////////////////////////////////////////////
  91. #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_VALUE MODULEENTRY32
  92. #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_FIRST Module32First
  93. #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_NEXT Module32Next
  94. #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_FLAG TH32CS_SNAPMODULE
  95. #define WINSTL_TH_API_SEQUENCE_VALUE_TRAITS_CREATE_SNAPSHOT_FAIL_MESSAGE TEXT("Could not create module list snapshot")
  96. #include <winstl/toolhelp/sequence_value_traits.hpp>
  97. /** \brief An STL collection for accessing module information for a given process.
  98. *
  99. * \ingroup group__library__windows_toolhelp
  100. */
  101. typedef th_sequence_base<MODULEENTRY32> module_sequence;
  102. /** \brief [IMPLEMENTATION] Specialisation of
  103. * \link winstl::sequence_doesnt_use_pid sequence_doesnt_use_pid\endlink to proscribe
  104. * use of the non-default constructor of the MODULEENTRY32 specialisation of
  105. * \link winstl::th_sequence_base th_sequence_base\endlink.
  106. */
  107. STLSOFT_TEMPLATE_SPECIALISATION
  108. struct sequence_doesnt_use_pid<MODULEENTRY32>
  109. {};
  110. /** \brief Attribute shim for retrieving the process id associated with the MODULEENTRY32 instance
  111. *
  112. * \ingroup group__library__windows_toolhelp
  113. *
  114. * \param me The MODULEENTRY32 instance
  115. */
  116. inline DWORD get_pid(MODULEENTRY32 const& me)
  117. {
  118. return me.th32ProcessID;
  119. }
  120. /* ////////////////////////////////////////////////////////////////////// */
  121. #ifndef _WINSTL_NO_NAMESPACE
  122. # if defined(_STLSOFT_NO_NAMESPACE) || \
  123. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  124. } // namespace winstl
  125. # else
  126. } // namespace winstl_project
  127. } // namespace stlsoft
  128. # endif /* _STLSOFT_NO_NAMESPACE */
  129. #endif /* !_WINSTL_NO_NAMESPACE */
  130. /* ////////////////////////////////////////////////////////////////////// */
  131. #endif // WINSTL_INCL_WINSTL_TOOLHELP_HPP_MODULE_SEQUENCE
  132. /* ///////////////////////////// end of file //////////////////////////// */