Represents a collection of section headers in a PE image.
| 12 | /// Represents a collection of section headers in a PE image. |
| 13 | /// </summary> |
| 14 | class section_headers |
| 15 | { |
| 16 | friend class image; |
| 17 | |
| 18 | PIMAGE_NT_HEADERS _nt_headers = nullptr; |
| 19 | |
| 20 | /// <summary> |
| 21 | /// Creates a new instance of the section headers class. |
| 22 | /// </summary> |
| 23 | /// <param name="nt_headers">The NT headers to use.</param> |
| 24 | explicit section_headers( PIMAGE_NT_HEADERS nt_headers ) noexcept; |
| 25 | |
| 26 | /// <summary> |
| 27 | /// Fixes the alignment of the section headers. |
| 28 | /// </summary> |
| 29 | void realign( ) const noexcept; |
| 30 | |
| 31 | public: |
| 32 | /// <summary> |
| 33 | /// Returns the number of sections in the image. |
| 34 | /// </summary> |
| 35 | /// <returns>The number of sections.</returns> |
| 36 | constexpr std::uint16_t count( ) const noexcept |
| 37 | { |
| 38 | return _nt_headers->FileHeader.NumberOfSections; |
| 39 | } |
| 40 | |
| 41 | /// <summary> |
| 42 | /// Returns the section header at the specified index. |
| 43 | /// </summary> |
| 44 | /// <param name="index">The index of the section header.</param> |
| 45 | /// <returns>The section header.</returns> |
| 46 | constexpr PIMAGE_SECTION_HEADER at( std::uint16_t index ) const noexcept |
| 47 | { |
| 48 | return IMAGE_FIRST_SECTION( _nt_headers ) + index; |
| 49 | } |
| 50 | |
| 51 | /// <summary> |
| 52 | /// Returns the section header at the specified index. |
| 53 | /// </summary> |
| 54 | /// <param name="index">The index of the section header.</param> |
| 55 | /// <returns>The section header.</returns> |
| 56 | constexpr PIMAGE_SECTION_HEADER operator[]( std::uint16_t index ) const noexcept |
| 57 | { |
| 58 | return at( index ); |
| 59 | } |
| 60 | |
| 61 | /// <summary> |
| 62 | /// Returns the last section header in the image. |
| 63 | /// </summary> |
| 64 | constexpr PIMAGE_SECTION_HEADER last( ) const noexcept |
| 65 | { |
| 66 | return at( count( ) - 1 ); |
| 67 | } |
| 68 | |
| 69 | /// <summary> |
| 70 | /// Returns the first section header in the image. |
| 71 | /// </summary> |
no outgoing calls
no test coverage detected