From 699ae7ed96d7c8c915791605aafaa27e9f6660c2 Mon Sep 17 00:00:00 2001 From: Romain Thomas Date: Fri, 1 Nov 2024 06:45:19 +0100 Subject: [PATCH] Change Doxygen comment style --- include/LIEF/ART/Parser.hpp | 2 +- include/LIEF/ART/java_structures.hpp | 14 +- include/LIEF/ART/utils.hpp | 10 +- include/LIEF/Abstract/Binary.hpp | 116 ++-- include/LIEF/Abstract/Parser.hpp | 26 +- include/LIEF/Abstract/Relocation.hpp | 18 +- include/LIEF/Abstract/Section.hpp | 26 +- include/LIEF/Abstract/Symbol.hpp | 10 +- include/LIEF/BinaryStream/BinaryStream.hpp | 2 +- include/LIEF/BinaryStream/FileStream.hpp | 2 +- include/LIEF/DEX/Class.hpp | 32 +- include/LIEF/DEX/Field.hpp | 20 +- include/LIEF/DEX/File.hpp | 36 +- include/LIEF/DEX/Header.hpp | 26 +- include/LIEF/DEX/MapItem.hpp | 12 +- include/LIEF/DEX/MapList.hpp | 22 +- include/LIEF/DEX/Method.hpp | 26 +- include/LIEF/DEX/Parser.hpp | 4 +- include/LIEF/DEX/Prototype.hpp | 6 +- include/LIEF/DEX/Type.hpp | 24 +- include/LIEF/DEX/hash.hpp | 4 +- include/LIEF/DEX/instructions.hpp | 4 +- include/LIEF/DEX/utils.hpp | 8 +- include/LIEF/ELF/Binary.hpp | 612 +++++++++--------- include/LIEF/ELF/Builder.hpp | 20 +- include/LIEF/ELF/DynamicEntry.hpp | 16 +- include/LIEF/ELF/DynamicEntryArray.hpp | 26 +- include/LIEF/ELF/DynamicEntryFlags.hpp | 8 +- include/LIEF/ELF/DynamicEntryLibrary.hpp | 8 +- include/LIEF/ELF/DynamicEntryRpath.hpp | 16 +- include/LIEF/ELF/DynamicEntryRunPath.hpp | 18 +- include/LIEF/ELF/DynamicSharedObject.hpp | 10 +- include/LIEF/ELF/GnuHash.hpp | 46 +- include/LIEF/ELF/Note.hpp | 2 +- include/LIEF/ELF/NoteDetails/AndroidIdent.hpp | 12 +- .../LIEF/ELF/NoteDetails/core/CoreAuxv.hpp | 2 +- .../LIEF/ELF/NoteDetails/core/CoreFile.hpp | 6 +- .../ELF/NoteDetails/core/CorePrStatus.hpp | 2 +- .../LIEF/ELF/NoteDetails/core/CoreSigInfo.hpp | 2 +- include/LIEF/ELF/Parser.hpp | 146 ++--- include/LIEF/ELF/ParserConfig.hpp | 6 +- include/LIEF/ELF/Section.hpp | 50 +- include/LIEF/ELF/Segment.hpp | 44 +- include/LIEF/ELF/SymbolVersion.hpp | 38 +- include/LIEF/ELF/SymbolVersionAux.hpp | 4 +- .../LIEF/ELF/SymbolVersionAuxRequirement.hpp | 12 +- include/LIEF/ELF/SymbolVersionDefinition.hpp | 22 +- include/LIEF/ELF/SymbolVersionRequirement.hpp | 18 +- include/LIEF/ELF/SysvHash.hpp | 20 +- include/LIEF/ELF/enums.hpp | 2 +- include/LIEF/ELF/hash.hpp | 4 +- include/LIEF/ELF/utils.hpp | 6 +- include/LIEF/MachO/Binary.hpp | 464 ++++++------- include/LIEF/MachO/BinaryParser.hpp | 14 +- include/LIEF/MachO/BindingInfo.hpp | 40 +- include/LIEF/MachO/BuildToolVersion.hpp | 10 +- include/LIEF/MachO/BuildVersion.hpp | 2 +- include/LIEF/MachO/Builder.hpp | 4 +- include/LIEF/MachO/ChainedBindingInfo.hpp | 20 +- include/LIEF/MachO/CodeSignature.hpp | 4 +- include/LIEF/MachO/CodeSignatureDir.hpp | 4 +- include/LIEF/MachO/DataCodeEntry.hpp | 6 +- include/LIEF/MachO/DataInCode.hpp | 18 +- include/LIEF/MachO/DyldBindingInfo.hpp | 20 +- include/LIEF/MachO/DyldChainedFixups.hpp | 70 +- include/LIEF/MachO/DyldEnvironment.hpp | 6 +- include/LIEF/MachO/DyldExportsTrie.hpp | 26 +- include/LIEF/MachO/DyldInfo.hpp | 220 +++---- include/LIEF/MachO/DylibCommand.hpp | 26 +- include/LIEF/MachO/DylinkerCommand.hpp | 6 +- include/LIEF/MachO/DynamicSymbolCommand.hpp | 104 +-- include/LIEF/MachO/EncryptionInfo.hpp | 14 +- include/LIEF/MachO/ExportInfo.hpp | 34 +- include/LIEF/MachO/FatBinary.hpp | 40 +- include/LIEF/MachO/FilesetCommand.hpp | 12 +- include/LIEF/MachO/FunctionStarts.hpp | 22 +- include/LIEF/MachO/Header.hpp | 32 +- include/LIEF/MachO/LinkerOptHint.hpp | 6 +- include/LIEF/MachO/LoadCommand.hpp | 10 +- include/LIEF/MachO/MainCommand.hpp | 10 +- include/LIEF/MachO/Parser.hpp | 52 +- include/LIEF/MachO/ParserConfig.hpp | 18 +- include/LIEF/MachO/RPathCommand.hpp | 10 +- include/LIEF/MachO/Relocation.hpp | 64 +- include/LIEF/MachO/RelocationDyld.hpp | 22 +- include/LIEF/MachO/RelocationFixup.hpp | 42 +- include/LIEF/MachO/RelocationObject.hpp | 36 +- include/LIEF/MachO/Section.hpp | 86 +-- include/LIEF/MachO/SegmentCommand.hpp | 64 +- include/LIEF/MachO/SegmentSplitInfo.hpp | 2 +- include/LIEF/MachO/SourceVersion.hpp | 10 +- include/LIEF/MachO/SubClient.hpp | 2 +- include/LIEF/MachO/SubFramework.hpp | 26 +- include/LIEF/MachO/Symbol.hpp | 56 +- include/LIEF/MachO/SymbolCommand.hpp | 10 +- include/LIEF/MachO/ThreadCommand.hpp | 42 +- include/LIEF/MachO/TwoLevelHints.hpp | 10 +- include/LIEF/MachO/UUIDCommand.hpp | 4 +- include/LIEF/MachO/UnknownCommand.hpp | 2 +- include/LIEF/MachO/VersionMin.hpp | 8 +- include/LIEF/MachO/hash.hpp | 4 +- include/LIEF/MachO/utils.hpp | 18 +- include/LIEF/OAT/Binary.hpp | 20 +- include/LIEF/OAT/Header.hpp | 8 +- include/LIEF/OAT/Method.hpp | 16 +- include/LIEF/OAT/Parser.hpp | 4 +- include/LIEF/OAT/enums.hpp | 6 +- include/LIEF/OAT/utils.hpp | 14 +- include/LIEF/PE/Binary.hpp | 436 ++++++------- include/LIEF/PE/Builder.hpp | 44 +- include/LIEF/PE/CodeIntegrity.hpp | 6 +- include/LIEF/PE/DataDirectory.hpp | 16 +- include/LIEF/PE/DelayImport.hpp | 42 +- include/LIEF/PE/DelayImportEntry.hpp | 32 +- include/LIEF/PE/DosHeader.hpp | 12 +- include/LIEF/PE/Export.hpp | 18 +- include/LIEF/PE/ExportEntry.hpp | 6 +- include/LIEF/PE/Header.hpp | 46 +- include/LIEF/PE/Import.hpp | 64 +- include/LIEF/PE/ImportEntry.hpp | 30 +- .../LoadConfigurations/LoadConfiguration.hpp | 86 +-- .../LoadConfigurationV0.hpp | 8 +- .../LoadConfigurationV1.hpp | 24 +- .../LoadConfigurationV2.hpp | 4 +- .../LoadConfigurationV3.hpp | 10 +- .../LoadConfigurationV4.hpp | 8 +- .../LoadConfigurationV5.hpp | 12 +- .../LoadConfigurationV6.hpp | 6 +- include/LIEF/PE/OptionalHeader.hpp | 136 ++-- include/LIEF/PE/Parser.hpp | 34 +- include/LIEF/PE/ParserConfig.hpp | 2 +- include/LIEF/PE/Relocation.hpp | 12 +- include/LIEF/PE/RelocationEntry.hpp | 20 +- include/LIEF/PE/ResourceData.hpp | 16 +- include/LIEF/PE/ResourceDirectory.hpp | 24 +- include/LIEF/PE/ResourceNode.hpp | 50 +- include/LIEF/PE/ResourcesManager.hpp | 46 +- include/LIEF/PE/RichEntry.hpp | 8 +- include/LIEF/PE/RichHeader.hpp | 44 +- include/LIEF/PE/Section.hpp | 52 +- include/LIEF/PE/Symbol.hpp | 4 +- include/LIEF/PE/TLS.hpp | 62 +- include/LIEF/PE/debug/CodeView.hpp | 8 +- include/LIEF/PE/debug/CodeViewPDB.hpp | 2 +- include/LIEF/PE/debug/Debug.hpp | 24 +- include/LIEF/PE/debug/Pogo.hpp | 6 +- include/LIEF/PE/debug/Repro.hpp | 12 +- include/LIEF/PE/enums.hpp | 16 +- include/LIEF/PE/hash.hpp | 4 +- include/LIEF/PE/resources/LangCodeItem.hpp | 32 +- .../LIEF/PE/resources/ResourceAccelerator.hpp | 8 +- include/LIEF/PE/resources/ResourceDialog.hpp | 76 +-- .../LIEF/PE/resources/ResourceDialogItem.hpp | 32 +- .../PE/resources/ResourceFixedFileInfo.hpp | 60 +- include/LIEF/PE/resources/ResourceIcon.hpp | 28 +- .../PE/resources/ResourceStringFileInfo.hpp | 30 +- .../LIEF/PE/resources/ResourceStringTable.hpp | 4 +- .../LIEF/PE/resources/ResourceVarFileInfo.hpp | 26 +- include/LIEF/PE/resources/ResourceVersion.hpp | 38 +- include/LIEF/PE/signature/Attribute.hpp | 6 +- include/LIEF/PE/signature/ContentInfo.hpp | 4 +- include/LIEF/PE/signature/OIDToString.hpp | 2 +- include/LIEF/PE/signature/PKCS9TSTInfo.hpp | 62 +- include/LIEF/PE/signature/RsaInfo.hpp | 18 +- include/LIEF/PE/signature/Signature.hpp | 90 +-- include/LIEF/PE/signature/SignatureParser.hpp | 6 +- include/LIEF/PE/signature/SignerInfo.hpp | 74 +-- include/LIEF/PE/signature/SpcIndirectData.hpp | 12 +- .../PE/signature/attributes/ContentType.hpp | 20 +- .../PE/signature/attributes/GenericType.hpp | 8 +- .../attributes/MsManifestBinaryID.hpp | 22 +- .../attributes/MsSpcNestedSignature.hpp | 22 +- .../attributes/MsSpcStatementType.hpp | 26 +- .../attributes/PKCS9AtSequenceNumber.hpp | 34 +- .../attributes/PKCS9CounterSignature.hpp | 26 +- .../attributes/PKCS9MessageDigest.hpp | 34 +- .../signature/attributes/PKCS9SigningTime.hpp | 36 +- .../attributes/SigningCertificateV2.hpp | 40 +- .../PE/signature/attributes/SpcSpOpusInfo.hpp | 28 +- include/LIEF/PE/signature/x509.hpp | 62 +- include/LIEF/PE/utils.hpp | 58 +- include/LIEF/VDEX/File.hpp | 6 +- include/LIEF/VDEX/Header.hpp | 12 +- include/LIEF/VDEX/Parser.hpp | 2 +- include/LIEF/VDEX/utils.hpp | 10 +- include/LIEF/Visitor.hpp | 276 ++++---- include/LIEF/errors.hpp | 68 +- include/LIEF/iterators.hpp | 8 +- include/LIEF/logging.hpp | 22 +- include/LIEF/utils.hpp | 12 +- src/ART/Structures.hpp | 2 +- src/Abstract/json_internal.hpp | 4 +- src/DEX/Structures.hpp | 2 +- src/DEX/json_internal.hpp | 4 +- src/ELF/ExeLayout.hpp | 4 +- src/ELF/ObjectFileLayout.hpp | 8 +- src/ELF/json_internal.hpp | 4 +- src/ELF/utils.cpp | 6 +- src/MachO/LinkEdit.cpp | 4 +- src/MachO/Structures.hpp | 2 +- src/MachO/json_internal.hpp | 4 +- src/OAT/Structures.hpp | 2 +- src/PE/Parser.cpp | 2 +- src/PE/ResourcesParser.hpp | 30 +- src/PE/Structures.hpp | 8 +- src/PE/json_internal.hpp | 4 +- src/PE/structures.inc | 24 +- src/VDEX/Structures.hpp | 2 +- 208 files changed, 3288 insertions(+), 3288 deletions(-) diff --git a/include/LIEF/ART/Parser.hpp b/include/LIEF/ART/Parser.hpp index 4a393b9523..a5c9666d56 100644 --- a/include/LIEF/ART/Parser.hpp +++ b/include/LIEF/ART/Parser.hpp @@ -28,7 +28,7 @@ namespace ART { class File; -//! @brief Class which parses an ART file and transform into a ART::File object +/// Class which parses an ART file and transform into a ART::File object class LIEF_API Parser { public: static std::unique_ptr parse(const std::string& file); diff --git a/include/LIEF/ART/java_structures.hpp b/include/LIEF/ART/java_structures.hpp index 108f0d2479..ca88d31301 100644 --- a/include/LIEF/ART/java_structures.hpp +++ b/include/LIEF/ART/java_structures.hpp @@ -24,7 +24,7 @@ #include "LIEF/ART/types.hpp" namespace LIEF { -//! @brief Namespace related to the LIEF's ART module +/// Namespace related to the LIEF's ART module namespace ART { namespace details { @@ -36,7 +36,7 @@ struct no_brooks_read_barrier_t {}; // ====================== namespace ART_17 { -//! @brief Namespace related to the Java part of ART 17 +/// Namespace related to the Java part of ART 17 namespace Java { using heap_reference_t = uint32_t; @@ -130,7 +130,7 @@ struct ALIGNED_(4) jdex_cache_t { // ====================== namespace ART_29 { -//! @brief Namespace related to the Java part of ART 29 +/// Namespace related to the Java part of ART 29 namespace Java { using heap_reference_t = ART_17::Java::heap_reference_t; using brooks_read_barrier_t = ART_17::Java::brooks_read_barrier_t; @@ -215,7 +215,7 @@ struct ALIGNED_(4) jdex_cache_t { // ====================== namespace ART_30 { -//! @brief Namespace related to the Java part of ART 30 +/// Namespace related to the Java part of ART 30 namespace Java { using heap_reference_t = ART_29::Java::heap_reference_t; @@ -246,7 +246,7 @@ using jdex_cache_t = ART_29::Java::jdex_cache_t; // ====================== namespace ART_44 { -//! @brief Namespace related to the Java part of ART 44 +/// Namespace related to the Java part of ART 44 namespace Java { @@ -335,7 +335,7 @@ struct ALIGNED_(4) jdex_cache_t { // ====================== namespace ART_46 { -//! @brief Namespace related to the Java part of ART 46 +/// Namespace related to the Java part of ART 46 namespace Java { using heap_reference_t = ART_44::Java::heap_reference_t; @@ -364,7 +364,7 @@ using jdex_cache_t = ART_44::Java::jdex_cache_t; // ====================== namespace ART_56 { -//! @brief Namespace related to the Java part of ART 46 +/// Namespace related to the Java part of ART 46 namespace Java { using heap_reference_t = ART_46::Java::heap_reference_t; diff --git a/include/LIEF/ART/utils.hpp b/include/LIEF/ART/utils.hpp index b90ea57dd0..9ff9a5298d 100644 --- a/include/LIEF/ART/utils.hpp +++ b/include/LIEF/ART/utils.hpp @@ -29,19 +29,19 @@ namespace LIEF { namespace ART { -//! @brief Check if the given file is an ART one. +/// Check if the given file is an ART one. LIEF_API bool is_art(const std::string& file); -//! @brief Check if the given raw data is an ART one. +/// Check if the given raw data is an ART one. LIEF_API bool is_art(const std::vector& raw); -//! @brief Return the ART version of the given file +/// Return the ART version of the given file LIEF_API art_version_t version(const std::string& file); -//! @brief Return the ART version of the raw data +/// Return the ART version of the raw data LIEF_API art_version_t version(const std::vector& raw); -//! @brief Return the ANDROID_VERSIONS associated with the given ART version +/// Return the ANDROID_VERSIONS associated with the given ART version LIEF_API LIEF::Android::ANDROID_VERSIONS android_version(art_version_t version); } diff --git a/include/LIEF/Abstract/Binary.hpp b/include/LIEF/Abstract/Binary.hpp index 1a93f82f91..7da6c0de7b 100644 --- a/include/LIEF/Abstract/Binary.hpp +++ b/include/LIEF/Abstract/Binary.hpp @@ -28,7 +28,7 @@ #include "LIEF/Abstract/Header.hpp" #include "LIEF/Abstract/Function.hpp" -//! LIEF namespace +/// LIEF namespace namespace LIEF { class Section; class Relocation; @@ -36,12 +36,12 @@ class Symbol; class DebugInfo; -//! Abstract binary that exposes an uniform API for the -//! different executable file formats +/// Abstract binary that exposes an uniform API for the +/// different executable file formats class LIEF_API Binary : public Object { public: - //! Type of a virtual address + /// Type of a virtual address enum class VA_TYPES { AUTO = 0, ///< Try to guess if it's relative or not RVA = 1, ///< Relative @@ -58,31 +58,31 @@ class LIEF_API Binary : public Object { using functions_t = std::vector; - //! Internal container + /// Internal container using sections_t = std::vector; - //! Iterator that outputs LIEF::Section& + /// Iterator that outputs LIEF::Section& using it_sections = ref_iterator; - //! Iterator that outputs const LIEF::Section& + /// Iterator that outputs const LIEF::Section& using it_const_sections = const_ref_iterator; - //! Internal container + /// Internal container using symbols_t = std::vector; - //! Iterator that outputs LIEF::Symbol& + /// Iterator that outputs LIEF::Symbol& using it_symbols = ref_iterator; - //! Iterator that outputs const LIEF::Symbol& + /// Iterator that outputs const LIEF::Symbol& using it_const_symbols = const_ref_iterator; - //! Internal container + /// Internal container using relocations_t = std::vector; - //! Iterator that outputs LIEF::Relocation& + /// Iterator that outputs LIEF::Relocation& using it_relocations = ref_iterator; - //! Iterator that outputs const LIEF::Relocation& + /// Iterator that outputs const LIEF::Relocation& using it_const_relocations = const_ref_iterator; public: @@ -94,40 +94,40 @@ class LIEF_API Binary : public Object { Binary& operator=(const Binary&) = delete; Binary(const Binary&) = delete; - //! Executable format (ELF, PE, Mach-O) of the underlying binary + /// Executable format (ELF, PE, Mach-O) of the underlying binary FORMATS format() const { return format_; } - //! Return the abstract header of the binary + /// Return the abstract header of the binary Header header() const { return get_abstract_header(); } - //! Return an iterator over the abstracted symbols in which the elements **can** be modified + /// Return an iterator over the abstracted symbols in which the elements **can** be modified it_symbols symbols() { return get_abstract_symbols(); } - //! Return an iterator over the abstracted symbols in which the elements **can't** be modified + /// Return an iterator over the abstracted symbols in which the elements **can't** be modified it_const_symbols symbols() const { return const_cast(this)->get_abstract_symbols(); } - //! Check if a Symbol with the given name exists + /// Check if a Symbol with the given name exists bool has_symbol(const std::string& name) const { return get_symbol(name) != nullptr; } - //! Return the Symbol with the given name - //! If the symbol does not exist, return a nullptr + /// Return the Symbol with the given name + /// If the symbol does not exist, return a nullptr const Symbol* get_symbol(const std::string& name) const; Symbol* get_symbol(const std::string& name) { return const_cast(static_cast(this)->get_symbol(name)); } - //! Return an iterator over the binary's sections (LIEF::Section) + /// Return an iterator over the binary's sections (LIEF::Section) it_sections sections() { return get_abstract_sections(); } @@ -136,10 +136,10 @@ class LIEF_API Binary : public Object { return const_cast(this)->get_abstract_sections(); } - //! Remove **all** the sections in the underlying binary + /// Remove **all** the sections in the underlying binary virtual void remove_section(const std::string& name, bool clear = false) = 0; - //! Return an iterator over the binary relocation (LIEF::Relocation) + /// Return an iterator over the binary relocation (LIEF::Relocation) it_relocations relocations() { return get_abstract_relocations(); } @@ -148,61 +148,61 @@ class LIEF_API Binary : public Object { return const_cast(this)->get_abstract_relocations(); } - //! Binary's entrypoint (if any) + /// Binary's entrypoint (if any) virtual uint64_t entrypoint() const = 0; - //! Binary's original size + /// Binary's original size uint64_t original_size() const { return original_size_; } - //! Return the functions exported by the binary + /// Return the functions exported by the binary functions_t exported_functions() const { return get_abstract_exported_functions(); } - //! Return libraries which are imported by the binary + /// Return libraries which are imported by the binary std::vector imported_libraries() const { return get_abstract_imported_libraries(); } - //! Return functions imported by the binary + /// Return functions imported by the binary functions_t imported_functions() const { return get_abstract_imported_functions(); } - //! Return the address of the given function name + /// Return the address of the given function name virtual result get_function_address(const std::string& func_name) const; - //! Method so that a ``visitor`` can visit us + /// Method so that a ``visitor`` can visit us void accept(Visitor& visitor) const override; std::vector xref(uint64_t address) const; - //! Patch the content at virtual address @p address with @p patch_value - //! - //! @param[in] address Address to patch - //! @param[in] patch_value Patch to apply - //! @param[in] addr_type Specify if the address should be used as an - //! absolute virtual address or a RVA + /// Patch the content at virtual address @p address with @p patch_value + /// + /// @param[in] address Address to patch + /// @param[in] patch_value Patch to apply + /// @param[in] addr_type Specify if the address should be used as an + /// absolute virtual address or a RVA virtual void patch_address(uint64_t address, const std::vector& patch_value, VA_TYPES addr_type = VA_TYPES::AUTO) = 0; - //! Patch the address with the given value - //! - //! @param[in] address Address to patch - //! @param[in] patch_value Patch to apply - //! @param[in] size Size of the value in **bytes** (1, 2, ... 8) - //! @param[in] addr_type Specify if the address should be used as an absolute virtual address or an RVA + /// Patch the address with the given value + /// + /// @param[in] address Address to patch + /// @param[in] patch_value Patch to apply + /// @param[in] size Size of the value in **bytes** (1, 2, ... 8) + /// @param[in] addr_type Specify if the address should be used as an absolute virtual address or an RVA virtual void patch_address(uint64_t address, uint64_t patch_value, size_t size = sizeof(uint64_t), VA_TYPES addr_type = VA_TYPES::AUTO) = 0; - //! Return the content located at the given virtual address + /// Return the content located at the given virtual address virtual span get_content_from_virtual_address(uint64_t virtual_address, uint64_t size, VA_TYPES addr_type = VA_TYPES::AUTO) const = 0; - //! Get the integer value at the given virtual address + /// Get the integer value at the given virtual address template LIEF::result get_int_from_virtual_address( uint64_t va, VA_TYPES addr_type = VA_TYPES::AUTO) const @@ -219,38 +219,38 @@ class LIEF_API Binary : public Object { return value; } - //! @brief Change binary's original size. - //! - //! @warning - //! This function should be used carefully as some optimizations - //! can be performed with this value + /// Change binary's original size. + /// + /// @warning + /// This function should be used carefully as some optimizations + /// can be performed with this value void original_size(uint64_t size) { original_size_ = size; } - //! Check if the binary is position independent + /// Check if the binary is position independent virtual bool is_pie() const = 0; - //! Check if the binary uses ``NX`` protection + /// Check if the binary uses ``NX`` protection virtual bool has_nx() const = 0; - //! Default image base address if the ASLR is not enabled. + /// Default image base address if the ASLR is not enabled. virtual uint64_t imagebase() const = 0; - //! Constructor functions that are called prior any other functions + /// Constructor functions that are called prior any other functions virtual functions_t ctor_functions() const = 0; - //! Convert the given offset into a virtual address. - //! - //! @param[in] offset The offset to convert. - //! @param[in] slide If not 0, it will replace the default base address (if any) + /// Convert the given offset into a virtual address. + /// + /// @param[in] offset The offset to convert. + /// @param[in] slide If not 0, it will replace the default base address (if any) virtual result offset_to_virtual_address(uint64_t offset, uint64_t slide = 0) const = 0; virtual std::ostream& print(std::ostream& os) const { return os; } - //! Build & transform the Binary object representation into a *real* executable + /// Build & transform the Binary object representation into a *real* executable virtual void write(const std::string& name) = 0; virtual void write(std::ostream& os) = 0; diff --git a/include/LIEF/Abstract/Parser.hpp b/include/LIEF/Abstract/Parser.hpp index 8bb985a628..a427691bf7 100644 --- a/include/LIEF/Abstract/Parser.hpp +++ b/include/LIEF/Abstract/Parser.hpp @@ -26,26 +26,26 @@ namespace LIEF { class BinaryStream; class Binary; -//! Main interface to parse an executable regardless of its format +/// Main interface to parse an executable regardless of its format class LIEF_API Parser { public: - //! Construct an LIEF::Binary from the given filename - //! - //! @warning If the target file is a FAT Mach-O, it will return the **last** one - //! @see LIEF::MachO::Parser::parse + /// Construct an LIEF::Binary from the given filename + /// + /// @warning If the target file is a FAT Mach-O, it will return the **last** one + /// @see LIEF::MachO::Parser::parse static std::unique_ptr parse(const std::string& filename); - //! @brief Construct an LIEF::Binary from the given raw data - //! - //! @warning If the target file is a FAT Mach-O, it will return the **last** one - //! @see LIEF::MachO::Parser::parse + /// Construct an LIEF::Binary from the given raw data + /// + /// @warning If the target file is a FAT Mach-O, it will return the **last** one + /// @see LIEF::MachO::Parser::parse static std::unique_ptr parse(const std::vector& raw); - //! @brief Construct an LIEF::Binary from the given stream - //! - //! @warning If the target file is a FAT Mach-O, it will return the **last** one - //! @see LIEF::MachO::Parser::parse + /// Construct an LIEF::Binary from the given stream + /// + /// @warning If the target file is a FAT Mach-O, it will return the **last** one + /// @see LIEF::MachO::Parser::parse static std::unique_ptr parse(std::unique_ptr stream); protected: diff --git a/include/LIEF/Abstract/Relocation.hpp b/include/LIEF/Abstract/Relocation.hpp index 5facb45cb0..629e67053b 100644 --- a/include/LIEF/Abstract/Relocation.hpp +++ b/include/LIEF/Abstract/Relocation.hpp @@ -23,13 +23,13 @@ #include "LIEF/visibility.h" namespace LIEF { -//! Class which represents an abstracted Relocation +/// Class which represents an abstracted Relocation class LIEF_API Relocation : public Object { public: Relocation() = default; - //! Constructor from a relocation's address and size + /// Constructor from a relocation's address and size Relocation(uint64_t address, uint8_t size) : address_(address), size_(size) @@ -44,12 +44,12 @@ class LIEF_API Relocation : public Object { std::swap(size_, other.size_); } - //! Relocation's address + /// Relocation's address virtual uint64_t address() const { return address_; } - //! Relocation size in **bits** + /// Relocation size in **bits** virtual size_t size() const { return size_; } @@ -62,26 +62,26 @@ class LIEF_API Relocation : public Object { size_ = (uint8_t)size; } - //! Method so that the ``visitor`` can visit us + /// Method so that the ``visitor`` can visit us void accept(Visitor& visitor) const override; - //! Comparaison based on the Relocation's **address** + /// Comparaison based on the Relocation's **address** virtual bool operator<(const Relocation& rhs) const { return address() < rhs.address(); } - //! Comparaison based on the Relocation's **address** + /// Comparaison based on the Relocation's **address** virtual bool operator<=(const Relocation& rhs) const { return !(address() > rhs.address()); } - //! Comparaison based on the Relocation's **address** + /// Comparaison based on the Relocation's **address** virtual bool operator>(const Relocation& rhs) const { return address() > rhs.address(); } - //! Comparaison based on the Relocation's **address** + /// Comparaison based on the Relocation's **address** virtual bool operator>=(const Relocation& rhs) const { return !(address() < rhs.address()); } diff --git a/include/LIEF/Abstract/Section.hpp b/include/LIEF/Abstract/Section.hpp index a7a2c8cab4..cb66e4b902 100644 --- a/include/LIEF/Abstract/Section.hpp +++ b/include/LIEF/Abstract/Section.hpp @@ -25,7 +25,7 @@ #include "LIEF/visibility.h" namespace LIEF { -//! Class which represents an abstracted section +/// Class which represents an abstracted section class LIEF_API Section : public Object { public: static constexpr size_t npos = -1; @@ -40,38 +40,38 @@ class LIEF_API Section : public Object { Section& operator=(const Section&) = default; Section(const Section&) = default; - //! section's name + /// section's name virtual std::string name() const { return name_.c_str(); } - //! Return the **complete** section's name which might - //! trailing (``0``) bytes + /// Return the **complete** section's name which might + /// trailing (``0``) bytes virtual const std::string& fullname() const { return name_; } - //! section's content + /// section's content virtual span content() const { return {}; } - //! Change the section size + /// Change the section size virtual void size(uint64_t size) { size_ = size; } - //! section's size (size in the binary, not the virtual size) + /// section's size (size in the binary, not the virtual size) virtual uint64_t size() const { return size_; } - //! Offset in the binary + /// Offset in the binary virtual uint64_t offset() const { return offset_; } - //! Address where the section should be mapped + /// Address where the section should be mapped virtual uint64_t virtual_address() const { return virtual_address_; } @@ -80,19 +80,19 @@ class LIEF_API Section : public Object { virtual_address_ = virtual_address; } - //! Change the section's name + /// Change the section's name virtual void name(std::string name) { name_ = std::move(name); } - //! Change section content + /// Change section content virtual void content(const std::vector&) {} virtual void offset(uint64_t offset) { offset_ = offset; } - //! Section's entropy + /// Section's entropy double entropy() const; // Search functions @@ -110,7 +110,7 @@ class LIEF_API Section : public Object { std::vector search_all(const std::string& v) const; - //! @brief Method so that the ``visitor`` can visit us + /// Method so that the ``visitor`` can visit us void accept(Visitor& visitor) const override; diff --git a/include/LIEF/Abstract/Symbol.hpp b/include/LIEF/Abstract/Symbol.hpp index 5e45ccb5a5..7ef411ff4d 100644 --- a/include/LIEF/Abstract/Symbol.hpp +++ b/include/LIEF/Abstract/Symbol.hpp @@ -24,7 +24,7 @@ namespace LIEF { -//! This class represents a symbol in an executable format. +/// This class represents a symbol in an executable format. class LIEF_API Symbol : public Object { public: Symbol() = default; @@ -47,7 +47,7 @@ class LIEF_API Symbol : public Object { void swap(Symbol& other) noexcept; - //! Return the symbol's name + /// Return the symbol's name virtual const std::string& name() const { return name_; } @@ -55,7 +55,7 @@ class LIEF_API Symbol : public Object { return name_; } - //! Set symbol name + /// Set symbol name virtual void name(std::string name) { name_ = std::move(name); } @@ -68,7 +68,7 @@ class LIEF_API Symbol : public Object { value_ = value; } - //! This size of the symbol (when applicable) + /// This size of the symbol (when applicable) virtual uint64_t size() const { return size_; } @@ -77,7 +77,7 @@ class LIEF_API Symbol : public Object { size_ = value; } - //! Method so that the ``visitor`` can visit us + /// Method so that the ``visitor`` can visit us void accept(Visitor& visitor) const override; LIEF_API friend std::ostream& operator<<(std::ostream& os, const Symbol& entry); diff --git a/include/LIEF/BinaryStream/BinaryStream.hpp b/include/LIEF/BinaryStream/BinaryStream.hpp index db3acac7da..caea9e4db2 100644 --- a/include/LIEF/BinaryStream/BinaryStream.hpp +++ b/include/LIEF/BinaryStream/BinaryStream.hpp @@ -29,7 +29,7 @@ namespace LIEF { class ASN1Reader; -//! Class that is used to a read stream of data from different sources +/// Class that is used to a read stream of data from different sources class LIEF_API BinaryStream { public: friend class ASN1Reader; diff --git a/include/LIEF/BinaryStream/FileStream.hpp b/include/LIEF/BinaryStream/FileStream.hpp index b476153611..846c8fe65b 100644 --- a/include/LIEF/BinaryStream/FileStream.hpp +++ b/include/LIEF/BinaryStream/FileStream.hpp @@ -26,7 +26,7 @@ namespace LIEF { -//! Stream interface over a `std::ifstream` +/// Stream interface over a `std::ifstream` class LIEF_API FileStream : public BinaryStream { public: static result from_file(const std::string& file); diff --git a/include/LIEF/DEX/Class.hpp b/include/LIEF/DEX/Class.hpp index b31cce95ad..bb967166d9 100644 --- a/include/LIEF/DEX/Class.hpp +++ b/include/LIEF/DEX/Class.hpp @@ -32,7 +32,7 @@ class Parser; class Field; class Method; -//! Class which represents a DEX Class (i.e. a Java/Kotlin class) +/// Class which represents a DEX Class (i.e. a Java/Kotlin class) class LIEF_API Class : public Object { friend class Parser; @@ -65,54 +65,54 @@ class LIEF_API Class : public Object { Class(std::string fullname, uint32_t access_flags = ACCESS_FLAGS::ACC_UNKNOWN, Class* parent = nullptr, std::string source_filename = ""); - //! Mangled class name (e.g. ``Lcom/example/android/MyActivity;``) + /// Mangled class name (e.g. ``Lcom/example/android/MyActivity;``) const std::string& fullname() const; - //! Package Name + /// Package Name std::string package_name() const; - //! Class name + /// Class name std::string name() const; - //! Demangled class name + /// Demangled class name std::string pretty_name() const; - //! Check if the class has the given access flag + /// Check if the class has the given access flag bool has(ACCESS_FLAGS f) const; - //! Access flags used by this class + /// Access flags used by this class access_flags_list_t access_flags() const; - //! Filename associated with this class (if any) + /// Filename associated with this class (if any) const std::string& source_filename() const; - //! True if the current class extends another one + /// True if the current class extends another one bool has_parent() const; - //! Parent class + /// Parent class const Class* parent() const; Class* parent(); - //! Methods implemented in this class + /// Methods implemented in this class it_const_methods methods() const; it_methods methods(); - //! Return Methods having the given name + /// Return Methods having the given name it_named_methods methods(const std::string& name); it_const_named_methods methods(const std::string& name) const; - //! Fields implemented in this class + /// Fields implemented in this class it_const_fields fields() const; it_fields fields(); - //! Return Fields having the given name + /// Return Fields having the given name it_named_fields fields(const std::string& name); it_const_named_fields fields(const std::string& name) const; - //! De-optimize information + /// De-optimize information dex2dex_class_info_t dex2dex_info() const; - //! Original index in the DEX class pool + /// Original index in the DEX class pool size_t index() const; void accept(Visitor& visitor) const override; diff --git a/include/LIEF/DEX/Field.hpp b/include/LIEF/DEX/Field.hpp index 26a00db4f9..f2a512274a 100644 --- a/include/LIEF/DEX/Field.hpp +++ b/include/LIEF/DEX/Field.hpp @@ -30,7 +30,7 @@ namespace DEX { class Parser; class Class; -//! Class which represent a DEX Field +/// Class which represent a DEX Field class LIEF_API Field : public Object { friend class Parser; public: @@ -43,33 +43,33 @@ class LIEF_API Field : public Object { Field(const Field&); Field& operator=(const Field&); - //! Name of the Field + /// Name of the Field const std::string& name() const; - //! True if a class is associated with this field - //! (which should be the case) + /// True if a class is associated with this field + /// (which should be the case) bool has_class() const; - //! Class associated with this Field + /// Class associated with this Field const Class* cls() const; Class* cls(); - //! Index in the DEX Fields pool + /// Index in the DEX Fields pool size_t index() const; - //! True if this field is a static one. + /// True if this field is a static one. bool is_static() const; - //! Field's prototype + /// Field's prototype const Type* type() const; Type* type(); void accept(Visitor& visitor) const override; - //! Check if the field has the given ACCESS_FLAGS + /// Check if the field has the given ACCESS_FLAGS bool has(ACCESS_FLAGS f) const; - //! ACCESS_FLAGS as a list + /// ACCESS_FLAGS as a list access_flags_list_t access_flags() const; diff --git a/include/LIEF/DEX/File.hpp b/include/LIEF/DEX/File.hpp index 39605fa9d1..212a2f23b0 100644 --- a/include/LIEF/DEX/File.hpp +++ b/include/LIEF/DEX/File.hpp @@ -35,7 +35,7 @@ class Type; class Prototype; class Field; -//! Class that represents a DEX file +/// Class that represents a DEX file class LIEF_API File : public Object { friend class Parser; @@ -69,70 +69,70 @@ class LIEF_API File : public Object { File& operator=(const File& copy) = delete; File(const File& copy) = delete; - //! Version of the current DEX file + /// Version of the current DEX file dex_version_t version() const; - //! Name of this file + /// Name of this file const std::string& name() const; void name(const std::string& name); - //! Location of this file + /// Location of this file const std::string& location() const; void location(const std::string& location); - //! DEX header + /// DEX header const Header& header() const; Header& header(); - //! **All** classes used in the DEX file + /// **All** classes used in the DEX file it_const_classes classes() const; it_classes classes(); - //! Check if the given class name exists + /// Check if the given class name exists bool has_class(const std::string& class_name) const; - //! Return the DEX::Class object associated with the given name + /// Return the DEX::Class object associated with the given name const Class* get_class(const std::string& class_name) const; Class* get_class(const std::string& class_name); - //! Return the DEX::Class object associated with the given index + /// Return the DEX::Class object associated with the given index const Class* get_class(size_t index) const; Class* get_class(size_t index); - //! De-optimize information + /// De-optimize information dex2dex_info_t dex2dex_info() const; - //! De-optimize information as JSON + /// De-optimize information as JSON std::string dex2dex_json_info() const; - //! Return an iterator over **all** the DEX::Method used in this DEX file + /// Return an iterator over **all** the DEX::Method used in this DEX file it_const_methods methods() const; it_methods methods(); - //! Return an iterator over **all** the DEX::Field used in this DEX file + /// Return an iterator over **all** the DEX::Field used in this DEX file it_const_fields fields() const; it_fields fields(); - //! String pool + /// String pool it_const_strings strings() const; it_strings strings(); - //! Type pool + /// Type pool it_const_types types() const; it_types types(); - //! Prototype pool + /// Prototype pool it_prototypes prototypes(); it_const_prototypes prototypes() const; - //! DEX Map + /// DEX Map const MapList& map() const; MapList& map(); - //! Extract the current dex file and deoptimize it + /// Extract the current dex file and deoptimize it std::string save(const std::string& path = "", bool deoptimize = true) const; std::vector raw(bool deoptimize = true) const; diff --git a/include/LIEF/DEX/Header.hpp b/include/LIEF/DEX/Header.hpp index 9f708c9508..c933bfba5d 100644 --- a/include/LIEF/DEX/Header.hpp +++ b/include/LIEF/DEX/Header.hpp @@ -31,11 +31,11 @@ class Visitor; namespace DEX { class Parser; -//! Class which represents the DEX header. -//! This is the first structure that begins the DEX format. -//! -//! The official documentation is provided here: -//! https://source.android.com/devices/tech/dalvik/dex-format#header-item +/// Class which represents the DEX header. +/// This is the first structure that begins the DEX format. +/// +/// The official documentation is provided here: +/// https://source.android.com/devices/tech/dalvik/dex-format#header-item class LIEF_API Header : public Object { friend class Parser; @@ -52,28 +52,28 @@ class LIEF_API Header : public Object { template LIEF_LOCAL Header(const T& header); - //! The DEX magic bytes (``DEX\n`` followed by the DEX version) + /// The DEX magic bytes (``DEX\n`` followed by the DEX version) magic_t magic() const; - //! The file checksum + /// The file checksum uint32_t checksum() const; - //! SHA-1 DEX signature (which is not really used as a signature) + /// SHA-1 DEX signature (which is not really used as a signature) signature_t signature() const; - //! Size of the entire file (including the current the header) + /// Size of the entire file (including the current the header) uint32_t file_size() const; - //! Size of this header. It should be 0x70 + /// Size of this header. It should be 0x70 uint32_t header_size() const; - //! File endianess of the file + /// File endianess of the file uint32_t endian_tag() const; - //! Offset from the start of the file to the map list (see: DEX::MapList) + /// Offset from the start of the file to the map list (see: DEX::MapList) uint32_t map() const; - //! Offset and size of the string pool + /// Offset and size of the string pool location_t strings() const; location_t link() const; location_t types() const; diff --git a/include/LIEF/DEX/MapItem.hpp b/include/LIEF/DEX/MapItem.hpp index 1fef1f54be..bf754bac60 100644 --- a/include/LIEF/DEX/MapItem.hpp +++ b/include/LIEF/DEX/MapItem.hpp @@ -27,7 +27,7 @@ namespace DEX { class Parser; class Class; -//! Class which represents an element of the MapList object +/// Class which represents an element of the MapList object class LIEF_API MapItem : public Object { friend class Parser; @@ -63,17 +63,17 @@ class LIEF_API MapItem : public Object { MapItem(const MapItem&); MapItem& operator=(const MapItem&); - //! The type of the item + /// The type of the item TYPES type() const; - //! Reserved value (likely for alignment prupose) + /// Reserved value (likely for alignment prupose) uint16_t reserved() const; - //! The number of elements (the real meaning depends on the type) + /// The number of elements (the real meaning depends on the type) uint32_t size() const; - //! Offset from the start of the DEX file to the items associated with - //! the underlying TYPES + /// Offset from the start of the DEX file to the items associated with + /// the underlying TYPES uint32_t offset() const; void accept(Visitor& visitor) const override; diff --git a/include/LIEF/DEX/MapList.hpp b/include/LIEF/DEX/MapList.hpp index 7a532ebc24..472b6e8d49 100644 --- a/include/LIEF/DEX/MapList.hpp +++ b/include/LIEF/DEX/MapList.hpp @@ -29,11 +29,11 @@ namespace DEX { class Parser; class Class; -//! Class which represents the ``map_list`` structure that -//! follows the main DEX header. -//! -//! This MapList aims at referencing the location of other DEX structures as -//! described in https://source.android.com/devices/tech/dalvik/dex-format#map-item +/// Class which represents the ``map_list`` structure that +/// follows the main DEX header. +/// +/// This MapList aims at referencing the location of other DEX structures as +/// described in https://source.android.com/devices/tech/dalvik/dex-format#map-item class LIEF_API MapList : public Object { friend class Parser; @@ -48,23 +48,23 @@ class LIEF_API MapList : public Object { MapList(const MapList&); MapList& operator=(const MapList&); - //! Iterator over LIEF::DEX::MapItem + /// Iterator over LIEF::DEX::MapItem it_items_t items(); it_const_items_t items() const; - //! Check if the given type exists + /// Check if the given type exists bool has(MapItem::TYPES type) const; - //! Return the LIEF::DEX::MapItem associated with the given type + /// Return the LIEF::DEX::MapItem associated with the given type const MapItem& get(MapItem::TYPES type) const; - //! Return the LIEF::DEX::MapItem associated with the given type + /// Return the LIEF::DEX::MapItem associated with the given type MapItem& get(MapItem::TYPES type); - //! Return the LIEF::DEX::MapItem associated with the given type + /// Return the LIEF::DEX::MapItem associated with the given type const MapItem& operator[](MapItem::TYPES type) const; - //! Return the LIEF::DEX::MapItem associated with the given type + /// Return the LIEF::DEX::MapItem associated with the given type MapItem& operator[](MapItem::TYPES type); void accept(Visitor& visitor) const override; diff --git a/include/LIEF/DEX/Method.hpp b/include/LIEF/DEX/Method.hpp index 289eb9511a..1d737f0c4b 100644 --- a/include/LIEF/DEX/Method.hpp +++ b/include/LIEF/DEX/Method.hpp @@ -32,7 +32,7 @@ class Parser; class Class; class Prototype; -//! Class which represents a DEX::Method +/// Class which represents a DEX::Method class LIEF_API Method : public Object { friend class Parser; public: @@ -46,31 +46,31 @@ class LIEF_API Method : public Object { Method(const Method&); Method& operator=(const Method&); - //! Name of the Method + /// Name of the Method const std::string& name() const; - //! True if a class is associated with this method + /// True if a class is associated with this method bool has_class() const; - //! DEX::Class associated with this Method or a nullptr - //! if not resolved + /// DEX::Class associated with this Method or a nullptr + /// if not resolved const Class* cls() const; Class* cls(); - //! Offset to the Dalvik Bytecode + /// Offset to the Dalvik Bytecode uint64_t code_offset() const; - //! Dalvik Bytecode as bytes + /// Dalvik Bytecode as bytes const bytecode_t& bytecode() const; - //! Index in the DEX Methods pool + /// Index in the DEX Methods pool size_t index() const; - //! True if this method is a virtual one. - //! i.e. not **static**, **private**, **finale** or constructor + /// True if this method is a virtual one. + /// i.e. not **static**, **private**, **finale** or constructor bool is_virtual() const; - //! Method's prototype or a nullptr if it is not resolved + /// Method's prototype or a nullptr if it is not resolved const Prototype* prototype() const; Prototype* prototype(); @@ -80,10 +80,10 @@ class LIEF_API Method : public Object { const dex2dex_method_info_t& dex2dex_info() const; - //! Check if the current method has the given ACCESS_FLAGS + /// Check if the current method has the given ACCESS_FLAGS bool has(ACCESS_FLAGS f) const; - //! ACCESS_FLAGS as an std::set + /// ACCESS_FLAGS as an std::set access_flags_list_t access_flags() const; diff --git a/include/LIEF/DEX/Parser.hpp b/include/LIEF/DEX/Parser.hpp index e7e79055d8..f1a0486523 100644 --- a/include/LIEF/DEX/Parser.hpp +++ b/include/LIEF/DEX/Parser.hpp @@ -34,11 +34,11 @@ class Field; class File; class Type; -//! Class which parses a DEX file to produce a DEX::File object +/// Class which parses a DEX file to produce a DEX::File object class LIEF_API Parser { public: - //! Parse the DEX file from the file path given in parameter + /// Parse the DEX file from the file path given in parameter static std::unique_ptr parse(const std::string& file); static std::unique_ptr parse(std::vector data, const std::string& name = ""); diff --git a/include/LIEF/DEX/Prototype.hpp b/include/LIEF/DEX/Prototype.hpp index 7fcaad759f..6982d03572 100644 --- a/include/LIEF/DEX/Prototype.hpp +++ b/include/LIEF/DEX/Prototype.hpp @@ -25,7 +25,7 @@ namespace DEX { class Parser; class Type; -//! Class which represents a DEX method prototype +/// Class which represents a DEX method prototype class LIEF_API Prototype : public Object { friend class Parser; @@ -38,11 +38,11 @@ class LIEF_API Prototype : public Object { Prototype(); Prototype(const Prototype& other); - //! Type returned or a nullptr if not resolved + /// Type returned or a nullptr if not resolved const Type* return_type() const; Type* return_type(); - //! Types of the parameters + /// Types of the parameters it_const_params parameters_type() const; it_params parameters_type(); diff --git a/include/LIEF/DEX/Type.hpp b/include/LIEF/DEX/Type.hpp index 13abec30fc..5c62125600 100644 --- a/include/LIEF/DEX/Type.hpp +++ b/include/LIEF/DEX/Type.hpp @@ -28,8 +28,8 @@ namespace DEX { class Parser; class Class; -//! Class which represents a DEX type as described in the -//! format specifications: https://source.android.com/devices/tech/dalvik/dex-format#typedescriptor +/// Class which represents a DEX type as described in the +/// format specifications: https://source.android.com/devices/tech/dalvik/dex-format#typedescriptor class LIEF_API Type : public Object { friend class Parser; @@ -63,30 +63,30 @@ class LIEF_API Type : public Object { Type(const std::string& mangled); Type(const Type& other); - //! Whether it is a primitive type, a class, ... + /// Whether it is a primitive type, a class, ... TYPES type() const; const Class& cls() const; const array_t& array() const; const PRIMITIVES& primitive() const; - //! **IF** the current type is a TYPES::CLASS, return the - //! associated DEX::CLASS. Otherwise the returned value is **undefined**. + /// **IF** the current type is a TYPES::CLASS, return the + /// associated DEX::CLASS. Otherwise the returned value is **undefined**. Class& cls(); - //! **IF** the current type is a TYPES::ARRAY, return the - //! associated array. Otherwise the returned value is **undefined**. + /// **IF** the current type is a TYPES::ARRAY, return the + /// associated array. Otherwise the returned value is **undefined**. array_t& array(); - //! **IF** the current type is a TYPES::PRIMITIVE, return the - //! associated PRIMITIVES. Otherwise the returned value is **undefined**. + /// **IF** the current type is a TYPES::PRIMITIVE, return the + /// associated PRIMITIVES. Otherwise the returned value is **undefined**. PRIMITIVES& primitive(); - //! Return the array dimension if the current type is - //! an array. Otherwise it returns 0 + /// Return the array dimension if the current type is + /// an array. Otherwise it returns 0 size_t dim() const; - //! In the case of a TYPES::ARRAY, return the array's type + /// In the case of a TYPES::ARRAY, return the array's type const Type& underlying_array_type() const; Type& underlying_array_type(); diff --git a/include/LIEF/DEX/hash.hpp b/include/LIEF/DEX/hash.hpp index 132a628f08..c3ebcf1584 100644 --- a/include/LIEF/DEX/hash.hpp +++ b/include/LIEF/DEX/hash.hpp @@ -35,8 +35,8 @@ class Prototype; class CodeInfo; class Type; -//! Class which implements a visitor to compute -//! a **deterministic** hash for LIEF DEX objects +/// Class which implements a visitor to compute +/// a **deterministic** hash for LIEF DEX objects class LIEF_API Hash : public LIEF::Hash { public: static LIEF::Hash::value_type hash(const Object& obj); diff --git a/include/LIEF/DEX/instructions.hpp b/include/LIEF/DEX/instructions.hpp index adce82da7a..597da53c8e 100644 --- a/include/LIEF/DEX/instructions.hpp +++ b/include/LIEF/DEX/instructions.hpp @@ -28,7 +28,7 @@ enum SWITCH_ARRAY_IDENT : uint16_t { IDENT_FILL_ARRAY = 0x0300, }; -//! The Dalvik Opcodes +/// The Dalvik Opcodes enum OPCODES : uint8_t { OP_NOP = 0x00, OP_MOVE = 0x01, @@ -339,7 +339,7 @@ struct fill_array_data { }; -//! Return the INST_FORMATS format associated with the given opcode +/// Return the INST_FORMATS format associated with the given opcode LIEF_API INST_FORMATS inst_format_from_opcode(OPCODES op); LIEF_API size_t inst_size_from_format(INST_FORMATS fmt); diff --git a/include/LIEF/DEX/utils.hpp b/include/LIEF/DEX/utils.hpp index 8d7cc4968c..d058015c02 100644 --- a/include/LIEF/DEX/utils.hpp +++ b/include/LIEF/DEX/utils.hpp @@ -28,16 +28,16 @@ namespace LIEF { class BinaryStream; namespace DEX { -//! Check if the given file is a DEX. +/// Check if the given file is a DEX. LIEF_API bool is_dex(const std::string& file); -//! Check if the given raw data is a DEX. +/// Check if the given raw data is a DEX. LIEF_API bool is_dex(const std::vector& raw); -//! Return the DEX version of the given file +/// Return the DEX version of the given file LIEF_API dex_version_t version(const std::string& file); -//! Return the DEX version of the raw data +/// Return the DEX version of the raw data LIEF_API dex_version_t version(const std::vector& raw); dex_version_t version(BinaryStream& stream); diff --git a/include/LIEF/ELF/Binary.hpp b/include/LIEF/ELF/Binary.hpp index 388cbce803..c9bfd8c563 100644 --- a/include/LIEF/ELF/Binary.hpp +++ b/include/LIEF/ELF/Binary.hpp @@ -33,7 +33,7 @@ #include "LIEF/ELF/Builder.hpp" namespace LIEF { -//! Namespace related to the LIEF's ELF module +/// Namespace related to the LIEF's ELF module namespace ELF { namespace DataHandler { class Handler; @@ -55,7 +55,7 @@ class DynamicEntryLibrary; class SysvHash; struct sizing_info_t; -//! Class which represents an ELF binary +/// Class which represents an ELF binary class LIEF_API Binary : public LIEF::Binary { friend class Parser; friend class Builder; @@ -66,127 +66,127 @@ class LIEF_API Binary : public LIEF::Binary { public: using string_list_t = std::vector; - //! Internal container for storing notes + /// Internal container for storing notes using notes_t = std::vector>; - //! Iterator which outputs Note& object + /// Iterator which outputs Note& object using it_notes = ref_iterator; - //! Iterator which outputs const Note& object + /// Iterator which outputs const Note& object using it_const_notes = const_ref_iterator; - //! Internal container for storing SymbolVersionRequirement + /// Internal container for storing SymbolVersionRequirement using symbols_version_requirement_t = std::vector>; - //! Iterator which outputs SymbolVersionRequirement& object + /// Iterator which outputs SymbolVersionRequirement& object using it_symbols_version_requirement = ref_iterator; - //! Iterator which outputs const SymbolVersionRequirement& object + /// Iterator which outputs const SymbolVersionRequirement& object using it_const_symbols_version_requirement = const_ref_iterator; - //! Internal container for storing SymbolVersionDefinition + /// Internal container for storing SymbolVersionDefinition using symbols_version_definition_t = std::vector>; - //! Iterator which outputs SymbolVersionDefinition& object + /// Iterator which outputs SymbolVersionDefinition& object using it_symbols_version_definition = ref_iterator; - //! Iterator which outputs const SymbolVersionDefinition& object + /// Iterator which outputs const SymbolVersionDefinition& object using it_const_symbols_version_definition = const_ref_iterator; - //! Internal container for storing ELF's Segment + /// Internal container for storing ELF's Segment using segments_t = std::vector>; - //! Iterator which outputs Segment& object + /// Iterator which outputs Segment& object using it_segments = ref_iterator; - //! Iterator which outputs const Segment& object + /// Iterator which outputs const Segment& object using it_const_segments = const_ref_iterator; - //! Internal container for storing ELF's DynamicEntry + /// Internal container for storing ELF's DynamicEntry using dynamic_entries_t = std::vector>; - //! Iterator which outputs DynamicEntry& object + /// Iterator which outputs DynamicEntry& object using it_dynamic_entries = ref_iterator; - //! Iterator which outputs const DynamicEntry& object + /// Iterator which outputs const DynamicEntry& object using it_const_dynamic_entries = const_ref_iterator; - //! Internal container for storing ELF's SymbolVersion + /// Internal container for storing ELF's SymbolVersion using symbols_version_t = std::vector>; - //! Iterator which outputs SymbolVersion& object + /// Iterator which outputs SymbolVersion& object using it_symbols_version = ref_iterator; - //! Iterator which outputs const SymbolVersion& object + /// Iterator which outputs const SymbolVersion& object using it_const_symbols_version = const_ref_iterator; - //! Internal container for storing ELF's Relocation + /// Internal container for storing ELF's Relocation using relocations_t = std::vector>; - //! Iterator which outputs plt/got Relocation& object + /// Iterator which outputs plt/got Relocation& object using it_pltgot_relocations = filter_iterator; - //! Iterator which outputs plt/got const Relocation& object + /// Iterator which outputs plt/got const Relocation& object using it_const_pltgot_relocations = const_filter_iterator; - //! Iterator which outputs dynamic Relocation& object (not related to the PLT/GOT mechanism) + /// Iterator which outputs dynamic Relocation& object (not related to the PLT/GOT mechanism) using it_dynamic_relocations = filter_iterator; - //! Iterator which outputs dynamic const Relocation& object (not related to the PLT/GOT mechanism) + /// Iterator which outputs dynamic const Relocation& object (not related to the PLT/GOT mechanism) using it_const_dynamic_relocations = const_filter_iterator; - //! Iterator which outputs Relocation& object found in object files (.o) + /// Iterator which outputs Relocation& object found in object files (.o) using it_object_relocations = filter_iterator; - //! Iterator which outputs const Relocation& object found in object files (.o) + /// Iterator which outputs const Relocation& object found in object files (.o) using it_const_object_relocations = const_filter_iterator; - //! Iterator which outputs Relocation& object + /// Iterator which outputs Relocation& object using it_relocations = ref_iterator; - //! Iterator which outputs const Relocation& object + /// Iterator which outputs const Relocation& object using it_const_relocations = const_ref_iterator; - //! Internal container for storing ELF's Symbol + /// Internal container for storing ELF's Symbol using symbols_t = std::vector>; - //! Iterator which outputs the Dynamic Symbol& object + /// Iterator which outputs the Dynamic Symbol& object using it_dynamic_symbols = ref_iterator; - //! Iterator which outputs the Dynamic const Symbol& object + /// Iterator which outputs the Dynamic const Symbol& object using it_const_dynamic_symbols = const_ref_iterator; - //! Iterator which outputs the static/debug Symbol& object + /// Iterator which outputs the static/debug Symbol& object using it_symtab_symbols = ref_iterator; - //! Iterator which outputs the static/debug const Symbol& object + /// Iterator which outputs the static/debug const Symbol& object using it_const_symtab_symbols = const_ref_iterator; - //! Iterator which outputs static and dynamic Symbol& object + /// Iterator which outputs static and dynamic Symbol& object using it_symbols = ref_iterator>; - //! Iterator which outputs static and dynamic const Symbol& object + /// Iterator which outputs static and dynamic const Symbol& object using it_const_symbols = const_ref_iterator>; - //! Iterator which outputs exported Symbol& object + /// Iterator which outputs exported Symbol& object using it_exported_symbols = filter_iterator>; - //! Iterator which outputs exported const Symbol& object + /// Iterator which outputs exported const Symbol& object using it_const_exported_symbols = const_filter_iterator>; - //! Iterator which outputs imported Symbol& object + /// Iterator which outputs imported Symbol& object using it_imported_symbols = filter_iterator>; - //! Iterator which outputs imported const Symbol& object + /// Iterator which outputs imported const Symbol& object using it_const_imported_symbols = const_filter_iterator>; - //! Internal container for storing ELF's Section + /// Internal container for storing ELF's Section using sections_t = std::vector>; - //! Iterator which outputs Section& object + /// Iterator which outputs Section& object using it_sections = ref_iterator; - //! Iterator which outputs const Section& object + /// Iterator which outputs const Section& object using it_const_sections = const_ref_iterator; public: @@ -227,12 +227,12 @@ class LIEF_API Binary : public LIEF::Binary { Binary& operator=(const Binary& ) = delete; Binary(const Binary& copy) = delete; - //! Return binary's class (ELF32 or ELF64) + /// Return binary's class (ELF32 or ELF64) Header::CLASS type() const { return type_; } - //! Return @link ELF::Header Elf header @endlink + /// Return @link ELF::Header Elf header @endlink Header& header() { return header_; } @@ -241,18 +241,18 @@ class LIEF_API Binary : public LIEF::Binary { return header_; } - //! Return the last offset used in binary - //! according to sections table + /// Return the last offset used in binary + /// according to sections table uint64_t last_offset_section() const; - //! Return the last offset used in binary - //! according to segments table + /// Return the last offset used in binary + /// according to segments table uint64_t last_offset_segment() const; - //! Return the next virtual address available + /// Return the next virtual address available uint64_t next_virtual_address() const; - //! Return an iterator over the binary's sections + /// Return an iterator over the binary's sections it_sections sections() { return sections_; } @@ -261,12 +261,12 @@ class LIEF_API Binary : public LIEF::Binary { return sections_; } - //! Return the binary's entrypoint + /// Return the binary's entrypoint uint64_t entrypoint() const override { return header_.entrypoint(); } - //! Return binary's segments + /// Return binary's segments it_segments segments() { return segments_; } @@ -275,7 +275,7 @@ class LIEF_API Binary : public LIEF::Binary { return segments_; } - //! Return binary's dynamic entries + /// Return binary's dynamic entries it_dynamic_entries dynamic_entries() { return dynamic_entries_; } @@ -284,36 +284,36 @@ class LIEF_API Binary : public LIEF::Binary { return dynamic_entries_; } - //! Add the given dynamic entry and return the new entry + /// Add the given dynamic entry and return the new entry DynamicEntry& add(const DynamicEntry& entry); - //! Add the given note and return the created entry + /// Add the given note and return the created entry Note& add(const Note& note); - //! Remove the given dynamic entry + /// Remove the given dynamic entry void remove(const DynamicEntry& entry); - //! Remove **all** dynamic entries with the given tag + /// Remove **all** dynamic entries with the given tag void remove(DynamicEntry::TAG tag); - //! Remove the given section. The ``clear`` parameter - //! can be used to zeroize the original content beforehand - //! - //! @param[in] section The section to remove - //! @param[in] clear Whether zeroize the original content + /// Remove the given section. The ``clear`` parameter + /// can be used to zeroize the original content beforehand + /// + /// @param[in] section The section to remove + /// @param[in] clear Whether zeroize the original content void remove(const Section& section, bool clear = false); - //! Remove the given note + /// Remove the given note void remove(const Note& note); - //! Remove **all** notes with the given type + /// Remove **all** notes with the given type void remove(Note::TYPE type); - //! Remove the given segment + /// Remove the given segment void remove(const Segment& seg); - //! Return an iterator over the binary's dynamic symbols - //! The dynamic symbols are those located in the ``.dynsym`` section + /// Return an iterator over the binary's dynamic symbols + /// The dynamic symbols are those located in the ``.dynsym`` section it_dynamic_symbols dynamic_symbols() { return dynamic_symbols_; } @@ -322,15 +322,15 @@ class LIEF_API Binary : public LIEF::Binary { return dynamic_symbols_; } - //! Return symbols which are exported by the binary + /// Return symbols which are exported by the binary it_exported_symbols exported_symbols(); it_const_exported_symbols exported_symbols() const; - //! Return symbols which are imported by the binary + /// Return symbols which are imported by the binary it_imported_symbols imported_symbols(); it_const_imported_symbols imported_symbols() const; - //! Return the debug symbols from the `.symtab` section. + /// Return the debug symbols from the `.symtab` section. it_symtab_symbols symtab_symbols() { return symtab_symbols_; } @@ -339,7 +339,7 @@ class LIEF_API Binary : public LIEF::Binary { return symtab_symbols_; } - //! Return the symbol versions + /// Return the symbol versions it_symbols_version symbols_version() { return symbol_version_table_; } @@ -347,7 +347,7 @@ class LIEF_API Binary : public LIEF::Binary { return symbol_version_table_; } - //! Return symbols version definition + /// Return symbols version definition it_symbols_version_definition symbols_version_definition() { return symbol_version_definition_; } @@ -356,7 +356,7 @@ class LIEF_API Binary : public LIEF::Binary { return symbol_version_definition_; } - //! Return Symbol version requirement + /// Return Symbol version requirement it_symbols_version_requirement symbols_version_requirement() { return symbol_version_requirements_; } @@ -365,41 +365,41 @@ class LIEF_API Binary : public LIEF::Binary { return symbol_version_requirements_; } - //! Return dynamic relocations + /// Return dynamic relocations it_dynamic_relocations dynamic_relocations(); it_const_dynamic_relocations dynamic_relocations() const; - //! Add a new *dynamic* relocation. - //! - //! We consider a dynamic relocation as a relocation which is not plt-related - //! - //! See: add_pltgot_relocation + /// Add a new *dynamic* relocation. + /// + /// We consider a dynamic relocation as a relocation which is not plt-related + /// + /// See: add_pltgot_relocation Relocation& add_dynamic_relocation(const Relocation& relocation); - //! Add a .plt.got relocation. This kind of relocation is usually - //! associated with a PLT stub that aims at resolving the underlying symbol - //! - //! See also: add_dynamic_relocation + /// Add a .plt.got relocation. This kind of relocation is usually + /// associated with a PLT stub that aims at resolving the underlying symbol + /// + /// See also: add_dynamic_relocation Relocation& add_pltgot_relocation(const Relocation& relocation); - //! Add relocation for object file (.o) - //! - //! The first parameter is the section to add while the second parameter - //! is the LIEF::ELF::Section associated with the relocation. - //! - //! If there is an error, this function returns a ``nullptr``. Otherwise, it returns - //! the relocation added. + /// Add relocation for object file (.o) + /// + /// The first parameter is the section to add while the second parameter + /// is the LIEF::ELF::Section associated with the relocation. + /// + /// If there is an error, this function returns a ``nullptr``. Otherwise, it returns + /// the relocation added. Relocation* add_object_relocation(const Relocation& relocation, const Section& section); - //! Return `plt.got` relocations + /// Return `plt.got` relocations it_pltgot_relocations pltgot_relocations(); it_const_pltgot_relocations pltgot_relocations() const; - //! Return relocations used in an object file (``*.o``) + /// Return relocations used in an object file (``*.o``) it_object_relocations object_relocations(); it_const_object_relocations object_relocations() const; - //! Return **all** relocations present in the binary + /// Return **all** relocations present in the binary it_relocations relocations() { return relocations_; } @@ -408,116 +408,116 @@ class LIEF_API Binary : public LIEF::Binary { return relocations_; } - //! Return relocation associated with the given address. - //! It returns a ``nullptr`` if it is not found + /// Return relocation associated with the given address. + /// It returns a ``nullptr`` if it is not found const Relocation* get_relocation(uint64_t address) const; Relocation* get_relocation(uint64_t address) { return const_cast(static_cast(this)->get_relocation(address)); } - //! Return relocation associated with the given Symbol - //! It returns a ``nullptr`` if it is not found + /// Return relocation associated with the given Symbol + /// It returns a ``nullptr`` if it is not found const Relocation* get_relocation(const Symbol& symbol) const; Relocation* get_relocation(const Symbol& symbol) { return const_cast(static_cast(this)->get_relocation(symbol)); } - //! Return relocation associated with the given Symbol name - //! It returns a ``nullptr`` if it is not found + /// Return relocation associated with the given Symbol name + /// It returns a ``nullptr`` if it is not found const Relocation* get_relocation(const std::string& symbol_name) const; Relocation* get_relocation(const std::string& symbol_name) { return const_cast(static_cast(this)->get_relocation(symbol_name)); } - //! ``true`` if GNU hash is used - //! - //! @see gnu_hash and use_sysv_hash + /// ``true`` if GNU hash is used + /// + /// @see gnu_hash and use_sysv_hash bool use_gnu_hash() const { return gnu_hash_ != nullptr && has(DynamicEntry::TAG::GNU_HASH); } - //! Return the GnuHash object in **readonly** - //! If the ELF binary does not use the GNU hash table, return a nullptr + /// Return the GnuHash object in **readonly** + /// If the ELF binary does not use the GNU hash table, return a nullptr const GnuHash* gnu_hash() const { return use_gnu_hash() ? gnu_hash_.get() : nullptr; } - //! ``true`` if SYSV hash is used - //! - //! @see sysv_hash and use_gnu_hash + /// ``true`` if SYSV hash is used + /// + /// @see sysv_hash and use_gnu_hash bool use_sysv_hash() const { return sysv_hash_ != nullptr && has(DynamicEntry::TAG::HASH); } - //! Return the SysvHash object as a **read-only** object - //! If the ELF binary does not use the legacy sysv hash table, return a nullptr + /// Return the SysvHash object as a **read-only** object + /// If the ELF binary does not use the legacy sysv hash table, return a nullptr const SysvHash* sysv_hash() const { return use_sysv_hash() ? sysv_hash_.get() : nullptr; } - //! Check if a section with the given name exists in the binary + /// Check if a section with the given name exists in the binary bool has_section(const std::string& name) const { return get_section(name) != nullptr; } - //! Check if a section that handles the given offset exists + /// Check if a section that handles the given offset exists bool has_section_with_offset(uint64_t offset) const; - //! Check if a section that handles the given virtual address exists + /// Check if a section that handles the given virtual address exists bool has_section_with_va(uint64_t va) const; - //! Return Section with the given `name`. If the section can't be - //! found, it returns a nullptr + /// Return Section with the given `name`. If the section can't be + /// found, it returns a nullptr Section* get_section(const std::string& name) { return const_cast(static_cast(this)->get_section(name)); } const Section* get_section(const std::string& name) const; - //! Return the `.text` section. If the section - //! can't be found, it returns a nullptr + /// Return the `.text` section. If the section + /// can't be found, it returns a nullptr Section* text_section() { return get_section(".text"); } - //! Return the `.dynamic` section. If the section - //! can't be found, it returns a nullptr + /// Return the `.dynamic` section. If the section + /// can't be found, it returns a nullptr Section* dynamic_section(); - //! Return the hash section. If the section - //! can't be found, it returns a nullptr + /// Return the hash section. If the section + /// can't be found, it returns a nullptr Section* hash_section(); - //! Return section which holds the symtab symbols. If the section - //! can't be found, it returns a nullptr + /// Return section which holds the symtab symbols. If the section + /// can't be found, it returns a nullptr Section* symtab_symbols_section(); - //! Return program image base. For instance ``0x40000`` - //! - //! To compute the image base, we look for the PT_PHDR segment header (phdr), - //! and we return ``phdr->p_vaddr - phdr->p_offset`` + /// Return program image base. For instance ``0x40000`` + /// + /// To compute the image base, we look for the PT_PHDR segment header (phdr), + /// and we return ``phdr->p_vaddr - phdr->p_offset`` uint64_t imagebase() const override; - //! Return the size of the mapped binary + /// Return the size of the mapped binary uint64_t virtual_size() const; - //! Check if the binary uses a loader (also named linker or interpreter) - //! @see interpreter + /// Check if the binary uses a loader (also named linker or interpreter) + /// @see interpreter bool has_interpreter() const; - //! Return the ELF interpreter if any. (e.g. `/lib64/ld-linux-x86-64.so.2`) - //! If the binary does not have an interpreter, it returns an empty string - //! - //! @see has_interpreter + /// Return the ELF interpreter if any. (e.g. `/lib64/ld-linux-x86-64.so.2`) + /// If the binary does not have an interpreter, it returns an empty string + /// + /// @see has_interpreter const std::string& interpreter() const { return interpreter_; } - //! Change the interpreter + /// Change the interpreter void interpreter(const std::string& interpreter) { interpreter_ = interpreter; } - //! Return an iterator on both static and dynamic symbols + /// Return an iterator on both static and dynamic symbols it_symbols symbols() { return symtab_dyn_symbols(); } @@ -526,259 +526,259 @@ class LIEF_API Binary : public LIEF::Binary { return symtab_dyn_symbols(); } - //! Export the given symbol and create it if it doesn't exist + /// Export the given symbol and create it if it doesn't exist Symbol& export_symbol(const Symbol& symbol); - //! Export the symbol with the given name and create it if it doesn't exist + /// Export the symbol with the given name and create it if it doesn't exist Symbol& export_symbol(const std::string& symbol_name, uint64_t value = 0); - //! Check if the symbol with the given ``name`` exists in the dynamic symbols table + /// Check if the symbol with the given ``name`` exists in the dynamic symbols table bool has_dynamic_symbol(const std::string& name) const { return get_dynamic_symbol(name) != nullptr; } - //! Get the dynamic symbol from the given name. - //! Return a nullptr if it can't be found + /// Get the dynamic symbol from the given name. + /// Return a nullptr if it can't be found const Symbol* get_dynamic_symbol(const std::string& name) const; Symbol* get_dynamic_symbol(const std::string& name) { return const_cast(static_cast(this)->get_dynamic_symbol(name)); } - //! Check if the symbol with the given ``name`` exists in the symtab symbol table + /// Check if the symbol with the given ``name`` exists in the symtab symbol table bool has_symtab_symbol(const std::string& name) const { return get_symtab_symbol(name) != nullptr; } - //! Get the symtab symbol from the given name - //! Return a nullptr if it can't be found + /// Get the symtab symbol from the given name + /// Return a nullptr if it can't be found const Symbol* get_symtab_symbol(const std::string& name) const; Symbol* get_symtab_symbol(const std::string& name) { return const_cast(static_cast(this)->get_symtab_symbol(name)); } - //! Return list of the strings used by the ELF binary. - //! - //! Basically, this function looks for string in the ``.roadata`` section + /// Return list of the strings used by the ELF binary. + /// + /// Basically, this function looks for string in the ``.roadata`` section string_list_t strings(size_t min_size = 5) const; - //! Remove symbols with the given name in both: - //! * dynamic symbols - //! * symtab symbols - //! - //! @see remove_symtab_symbol, remove_dynamic_symbol + /// Remove symbols with the given name in both: + /// * dynamic symbols + /// * symtab symbols + /// + /// @see remove_symtab_symbol, remove_dynamic_symbol void remove_symbol(const std::string& name); - //! Remove symtabl symbols with the given name + /// Remove symtabl symbols with the given name void remove_symtab_symbol(const std::string& name); void remove_symtab_symbol(Symbol* symbol); - //! Remove dynamic symbols with the given name + /// Remove dynamic symbols with the given name void remove_dynamic_symbol(const std::string& name); - //! Remove the given symbol from the dynamic symbols table. - //! - //! As a side effect, it will remove any ELF::Relocation - //! that refers to this symbol and the SymbolVersion (if any) - //! associated with this symbol + /// Remove the given symbol from the dynamic symbols table. + /// + /// As a side effect, it will remove any ELF::Relocation + /// that refers to this symbol and the SymbolVersion (if any) + /// associated with this symbol void remove_dynamic_symbol(Symbol* symbol); - //! Return the address of the given function name + /// Return the address of the given function name result get_function_address(const std::string& func_name) const override; - //! Return the address of the given function name + /// Return the address of the given function name // - //! @param[in] func_name The function's name target - //! @param[in] demangled Use the demangled name + /// @param[in] func_name The function's name target + /// @param[in] demangled Use the demangled name result get_function_address(const std::string& func_name, bool demangled) const; - //! Add a new section in the binary - //! - //! @param[in] section The section object to insert - //! @param[in] loaded Boolean value to indicate that section's data must be loaded - //! by a PT_LOAD segment - //! - //! @return The section added. The `size` and the `virtual address` might change. - //! - //! This function requires a well-formed ELF binary + /// Add a new section in the binary + /// + /// @param[in] section The section object to insert + /// @param[in] loaded Boolean value to indicate that section's data must be loaded + /// by a PT_LOAD segment + /// + /// @return The section added. The `size` and the `virtual address` might change. + /// + /// This function requires a well-formed ELF binary Section* add(const Section& section, bool loaded = true); Section* extend(const Section& section, uint64_t size); - //! Add a symtab symbol + /// Add a symtab symbol Symbol& add_symtab_symbol(const Symbol& symbol); - //! Add a dynamic symbol with the associated SymbolVersion + /// Add a dynamic symbol with the associated SymbolVersion Symbol& add_dynamic_symbol(const Symbol& symbol, const SymbolVersion* version = nullptr); - //! Create a symbol for the function at the given address and export it + /// Create a symbol for the function at the given address and export it Symbol& add_exported_function(uint64_t address, const std::string& name = ""); - //! Add a library as dependency + /// Add a library as dependency DynamicEntryLibrary& add_library(const std::string& library_name); - //! Remove the given library from the dependencies + /// Remove the given library from the dependencies void remove_library(const std::string& library_name); - //! Get the library object (DynamicEntryLibrary) from the given name - //! If the library can't be found, it returns a nullptr. + /// Get the library object (DynamicEntryLibrary) from the given name + /// If the library can't be found, it returns a nullptr. DynamicEntryLibrary* get_library(const std::string& library_name) { return const_cast(static_cast(this)->get_library(library_name)); } - //! Get the library object (DynamicEntryLibrary) from the given name - //! If the library can't be found, it returns a nullptr. + /// Get the library object (DynamicEntryLibrary) from the given name + /// If the library can't be found, it returns a nullptr. const DynamicEntryLibrary* get_library(const std::string& library_name) const; - //! Check if the given library name exists in the current binary + /// Check if the given library name exists in the current binary bool has_library(const std::string& name) const { return get_library(name) != nullptr; } - //! Add a new segment in the binary - //! - //! The segment is inserted at the end - //! - //! @return The segment added. `Virtual address` and `File Offset` might change. - //! - //! This function requires a well-formed ELF binary + /// Add a new segment in the binary + /// + /// The segment is inserted at the end + /// + /// @return The segment added. `Virtual address` and `File Offset` might change. + /// + /// This function requires a well-formed ELF binary Segment* add(const Segment& segment, uint64_t base = 0); - //! Replace the segment given in 2nd parameter with the segment given in the first one and return the updated segment. - //! - //! @warning The ``original_segment`` is no longer valid after this function + /// Replace the segment given in 2nd parameter with the segment given in the first one and return the updated segment. + /// + /// @warning The ``original_segment`` is no longer valid after this function Segment* replace(const Segment& new_segment, const Segment& original_segment, uint64_t base = 0); Segment* extend(const Segment& segment, uint64_t size); - //! Patch the content at virtual address @p address with @p patch_value - //! - //! @param[in] address Address to patch - //! @param[in] patch_value Patch to apply - //! @param[in] addr_type Specify if the address should be used as an absolute virtual address or an RVA + /// Patch the content at virtual address @p address with @p patch_value + /// + /// @param[in] address Address to patch + /// @param[in] patch_value Patch to apply + /// @param[in] addr_type Specify if the address should be used as an absolute virtual address or an RVA void patch_address(uint64_t address, const std::vector& patch_value, LIEF::Binary::VA_TYPES addr_type = LIEF::Binary::VA_TYPES::AUTO) override; - //! Patch the address with the given value - //! - //! @param[in] address Address to patch - //! @param[in] patch_value Patch to apply - //! @param[in] size Size of the value in **bytes** (1, 2, ... 8) - //! @param[in] addr_type Specify if the address should be used as an absolute virtual address or an RVA + /// Patch the address with the given value + /// + /// @param[in] address Address to patch + /// @param[in] patch_value Patch to apply + /// @param[in] size Size of the value in **bytes** (1, 2, ... 8) + /// @param[in] addr_type Specify if the address should be used as an absolute virtual address or an RVA void patch_address(uint64_t address, uint64_t patch_value, size_t size = sizeof(uint64_t), LIEF::Binary::VA_TYPES addr_type = LIEF::Binary::VA_TYPES::AUTO) override; - //! Patch the imported symbol with the ``address`` - //! - //! @param[in] symbol Imported symbol to patch - //! @param[in] address New address + /// Patch the imported symbol with the ``address`` + /// + /// @param[in] symbol Imported symbol to patch + /// @param[in] address New address void patch_pltgot(const Symbol& symbol, uint64_t address); - //! Patch the imported symbol's name with the ``address`` - //! - //! @param[in] symbol_name Imported symbol's name to patch - //! @param[in] address New address + /// Patch the imported symbol's name with the ``address`` + /// + /// @param[in] symbol_name Imported symbol's name to patch + /// @param[in] address New address void patch_pltgot(const std::string& symbol_name, uint64_t address); - //! Strip the binary by removing symtab symbols + /// Strip the binary by removing symtab symbols void strip(); - //! Remove a binary's section. - //! - //! @param[in] name The name of the section to remove - //! @param[in] clear Whether zeroize the original content + /// Remove a binary's section. + /// + /// @param[in] name The name of the section to remove + /// @param[in] clear Whether zeroize the original content void remove_section(const std::string& name, bool clear = false) override; - //! Reconstruct the binary object and write it in `filename` - //! - //! This function assumes that the layout of the current ELF binary is correct - //! (i.e. the binary can run). - //! - //! @param filename Path for the written ELF binary + /// Reconstruct the binary object and write it in `filename` + /// + /// This function assumes that the layout of the current ELF binary is correct + /// (i.e. the binary can run). + /// + /// @param filename Path for the written ELF binary void write(const std::string& filename) override; - //! Reconstruct the binary object with the given config and write it in `filename` - //! - //! This function assumes that the layout of the current ELF binary is correct - //! (i.e. the binary can run). - //! - //! @param filename Path for the written ELF binary - //! @param config Builder configuration + /// Reconstruct the binary object with the given config and write it in `filename` + /// + /// This function assumes that the layout of the current ELF binary is correct + /// (i.e. the binary can run). + /// + /// @param filename Path for the written ELF binary + /// @param config Builder configuration void write(const std::string& filename, Builder::config_t config); - //! Reconstruct the binary object and write it in `os` stream - //! - //! This function assumes that the layout of the current ELF binary is correct - //! (i.e. the binary can run). - //! - //! @param os Output stream for the written ELF binary + /// Reconstruct the binary object and write it in `os` stream + /// + /// This function assumes that the layout of the current ELF binary is correct + /// (i.e. the binary can run). + /// + /// @param os Output stream for the written ELF binary void write(std::ostream& os) override; - //! Reconstruct the binary object with the given config and write it in `os` stream - //! - //! @param os Output stream for the written ELF binary - //! @param config Builder configuration + /// Reconstruct the binary object with the given config and write it in `os` stream + /// + /// @param os Output stream for the written ELF binary + /// @param config Builder configuration void write(std::ostream& os, Builder::config_t config); - //! Reconstruct the binary object and return its content as a byte vector + /// Reconstruct the binary object and return its content as a byte vector std::vector raw(); - //! Convert a virtual address to a file offset + /// Convert a virtual address to a file offset result virtual_address_to_offset(uint64_t virtual_address) const; - //! Convert the given offset into a virtual address. - //! - //! @param[in] offset The offset to convert. - //! @param[in] slide If not 0, it will replace the default base address (if any) + /// Convert the given offset into a virtual address. + /// + /// @param[in] offset The offset to convert. + /// @param[in] slide If not 0, it will replace the default base address (if any) result offset_to_virtual_address(uint64_t offset, uint64_t slide = 0) const override; - //! Check if the binary has been compiled with `-fpie -pie` flags - //! - //! To do so we check if there is a `PT_INTERP` segment and if - //! the binary type is `ET_DYN` (Shared object) + /// Check if the binary has been compiled with `-fpie -pie` flags + /// + /// To do so we check if there is a `PT_INTERP` segment and if + /// the binary type is `ET_DYN` (Shared object) bool is_pie() const override; - //! Check if the binary uses the ``NX`` protection (Non executable stack) + /// Check if the binary uses the ``NX`` protection (Non executable stack) bool has_nx() const override; - //! Symbol index in the dynamic symbol table or -1 if the symbol - //! does not exist. + /// Symbol index in the dynamic symbol table or -1 if the symbol + /// does not exist. int64_t dynsym_idx(const std::string& name) const; int64_t dynsym_idx(const Symbol& sym) const; - //! Symbol index from the `.symtab` section or -1 if the symbol is not present + /// Symbol index from the `.symtab` section or -1 if the symbol is not present int64_t symtab_idx(const std::string& name) const; int64_t symtab_idx(const Symbol& sym) const; - //! Return the ELF::Section from the given @p offset. Return a nullptr - //! if a section can't be found - //! - //! If @p skip_nobits is set (which is the case by default), this function won't - //! consider section for which the type is ``SHT_NOBITS`` (like ``.bss, .tbss, ...``) + /// Return the ELF::Section from the given @p offset. Return a nullptr + /// if a section can't be found + /// + /// If @p skip_nobits is set (which is the case by default), this function won't + /// consider section for which the type is ``SHT_NOBITS`` (like ``.bss, .tbss, ...``) const Section* section_from_offset(uint64_t offset, bool skip_nobits = true) const; Section* section_from_offset(uint64_t offset, bool skip_nobits = true) { return const_cast(static_cast(this)->section_from_offset(offset, skip_nobits)); } - //! Return the ELF::Section from the given @p address. Return a nullptr - //! if a section can't be found. - //! - //! If @p skip_nobits is set (which is the case by default), this function won't - //! consider section for which type is ``SHT_NOBITS`` (like ``.bss, .tbss, ...``) + /// Return the ELF::Section from the given @p address. Return a nullptr + /// if a section can't be found. + /// + /// If @p skip_nobits is set (which is the case by default), this function won't + /// consider section for which type is ``SHT_NOBITS`` (like ``.bss, .tbss, ...``) const Section* section_from_virtual_address(uint64_t address, bool skip_nobits = true) const; Section* section_from_virtual_address(uint64_t address, bool skip_nobits = true) { return const_cast(static_cast(this)->section_from_virtual_address(address, skip_nobits)); } - //! Return the ELF::Segment from the given @p address. Return a nullptr - //! if a segment can't be found. + /// Return the ELF::Segment from the given @p address. Return a nullptr + /// if a segment can't be found. const Segment* segment_from_virtual_address(uint64_t address) const; Segment* segment_from_virtual_address(uint64_t address) { return const_cast(static_cast(this)->segment_from_virtual_address(address)); @@ -790,86 +790,86 @@ class LIEF_API Binary : public LIEF::Binary { return const_cast(static_cast(this)->segment_from_virtual_address(type, address)); } - //! Return the ELF::Segment from the @p offset. Return a nullptr - //! if a segment can't be found. + /// Return the ELF::Segment from the @p offset. Return a nullptr + /// if a segment can't be found. const Segment* segment_from_offset(uint64_t offset) const; Segment* segment_from_offset(uint64_t offset) { return const_cast(static_cast(this)->segment_from_offset(offset)); } - //! Return the **first** ELF::DynamicEntry associated with the given tag - //! If the tag can't be found, it returns a nullptr + /// Return the **first** ELF::DynamicEntry associated with the given tag + /// If the tag can't be found, it returns a nullptr const DynamicEntry* get(DynamicEntry::TAG tag) const; DynamicEntry* get(DynamicEntry::TAG tag) { return const_cast(static_cast(this)->get(tag)); } - //! Return the **first** ELF::Segment associated with the given type. - //! If a segment can't be found, it returns a nullptr. + /// Return the **first** ELF::Segment associated with the given type. + /// If a segment can't be found, it returns a nullptr. const Segment* get(Segment::TYPE type) const; Segment* get(Segment::TYPE type) { return const_cast(static_cast(this)->get(type)); } - //! Return the **first** ELF::Note associated with the given type - //! If a note can't be found, it returns a nullptr. + /// Return the **first** ELF::Note associated with the given type + /// If a note can't be found, it returns a nullptr. const Note* get(Note::TYPE type) const; Note* get(Note::TYPE type) { return const_cast(static_cast(this)->get(type)); } - //! Return the **first** ELF::Section associated with the given type - //! If a section can't be found, it returns a nullptr. + /// Return the **first** ELF::Section associated with the given type + /// If a section can't be found, it returns a nullptr. const Section* get(Section::TYPE type) const; Section* get(Section::TYPE type) { return const_cast(static_cast(this)->get(type)); } - //! Check if an ELF::DynamicEntry associated with the given tag exists. + /// Check if an ELF::DynamicEntry associated with the given tag exists. bool has(DynamicEntry::TAG tag) const { return get(tag) != nullptr; } - //! Check if ELF::Segment associated with the given type exists. + /// Check if ELF::Segment associated with the given type exists. bool has(Segment::TYPE type) const { return get(type) != nullptr; } - //! Check if a ELF::Note associated with the given type exists. + /// Check if a ELF::Note associated with the given type exists. bool has(Note::TYPE type) const { return get(type) != nullptr; } - //! Check if a ELF::Section associated with the given type exists. + /// Check if a ELF::Section associated with the given type exists. bool has(Section::TYPE type) const { return get(type) != nullptr; } - //! Return the content located at virtual address + /// Return the content located at virtual address span get_content_from_virtual_address(uint64_t virtual_address, uint64_t size, Binary::VA_TYPES addr_type = Binary::VA_TYPES::AUTO) const override; - //! Method associated with the visitor pattern. + /// Method associated with the visitor pattern. void accept(LIEF::Visitor& visitor) const override; - //! Apply the given permutation on the dynamic symbols table + /// Apply the given permutation on the dynamic symbols table void permute_dynamic_symbols(const std::vector& permutation); - //! List of binary constructors (typically, the functions located in the ``.init_array``) + /// List of binary constructors (typically, the functions located in the ``.init_array``) LIEF::Binary::functions_t ctor_functions() const override; - //! List of the binary destructors (typically, the functions located in the ``.fini_array``) + /// List of the binary destructors (typically, the functions located in the ``.fini_array``) LIEF::Binary::functions_t dtor_functions() const; - //! List of the functions found the in the binary. + /// List of the functions found the in the binary. LIEF::Binary::functions_t functions() const; - //! ``true`` if the binary embeds notes + /// ``true`` if the binary embeds notes bool has_notes() const; - //! Return an iterator over the ELF's LIEF::ELF::Note - //! - //! @see has_note + /// Return an iterator over the ELF's LIEF::ELF::Note + /// + /// @see has_note it_const_notes notes() const { return notes_; } @@ -878,40 +878,40 @@ class LIEF_API Binary : public LIEF::Binary { return notes_; } - //! Return the last offset used by the ELF binary according to both: the sections table - //! and the segments table + /// Return the last offset used by the ELF binary according to both: the sections table + /// and the segments table uint64_t eof_offset() const; - //! True if data are present at the end of the binary + /// True if data are present at the end of the binary bool has_overlay() const { return !overlay_.empty(); } - //! Overlay data (if any) + /// Overlay data (if any) span overlay() const { return overlay_; } - //! Function to set the overlay + /// Function to set the overlay void overlay(std::vector overlay) { overlay_ = std::move(overlay); } - //! Force relocating the segments table in a specific way. - //! - //! This function can be used to enforce a specific relocation of the - //! segments table. - //! - //! @param[in] type The relocation type to apply - //! @return The offset of the new segments table or 0 if it fails with - //! the given method. + /// Force relocating the segments table in a specific way. + /// + /// This function can be used to enforce a specific relocation of the + /// segments table. + /// + /// @param[in] type The relocation type to apply + /// @return The offset of the new segments table or 0 if it fails with + /// the given method. uint64_t relocate_phdr_table(PHDR_RELOC type); - //! Return the array defined by the given tag (e.g. - //! DynamicEntry::TAG::INIT_ARRAY) with relocations applied (if any) + /// Return the array defined by the given tag (e.g. + /// DynamicEntry::TAG::INIT_ARRAY) with relocations applied (if any) std::vector get_relocated_dynamic_array(DynamicEntry::TAG tag) const; - //! True if the current ELF is targeting Android + /// True if the current ELF is targeting Android bool is_targeting_android() const; static bool classof(const LIEF::Binary* bin) { @@ -1007,7 +1007,7 @@ class LIEF_API Binary : public LIEF::Binary { }; Binary(); - //! Return an abstraction of binary's section: LIEF::Section + /// Return an abstraction of binary's section: LIEF::Section LIEF::Binary::sections_t get_abstract_sections() override; LIEF::Header get_abstract_header() const override { diff --git a/include/LIEF/ELF/Builder.hpp b/include/LIEF/ELF/Builder.hpp index 882b005bba..b0d1644463 100644 --- a/include/LIEF/ELF/Builder.hpp +++ b/include/LIEF/ELF/Builder.hpp @@ -41,17 +41,17 @@ class ObjectFileLayout; class Layout; class Relocation; -//! Class which takes an ELF::Binary object and reconstructs a valid binary -//! -//! This interface assumes that the layout of input ELF binary is correct (i.e. -//! the binary can run). +/// Class which takes an ELF::Binary object and reconstructs a valid binary +/// +/// This interface assumes that the layout of input ELF binary is correct (i.e. +/// the binary can run). class LIEF_API Builder { friend class ObjectFileLayout; friend class Layout; friend class ExeLayout; public: - //! Configuration options to tweak the building process + /// Configuration options to tweak the building process struct config_t { bool dt_hash = true; /// Rebuild DT_HASH bool dyn_str = true; /// Rebuild DT_STRTAB @@ -80,10 +80,10 @@ class LIEF_API Builder { Builder() = delete; ~Builder(); - //! Perform the build of the provided ELF binary + /// Perform the build of the provided ELF binary void build(); - //! Tweak the ELF builder with the provided config parameter + /// Tweak the ELF builder with the provided config parameter Builder& set_config(config_t conf) { config_ = conf; return *this; @@ -93,13 +93,13 @@ class LIEF_API Builder { return config_; } - //! Return the built ELF binary as a byte vector + /// Return the built ELF binary as a byte vector const std::vector& get_build(); - //! Write the built ELF binary in the ``filename`` given in parameter + /// Write the built ELF binary in the ``filename`` given in parameter void write(const std::string& filename) const; - //! Write the built ELF binary in the stream ``os`` given in parameter + /// Write the built ELF binary in the stream ``os`` given in parameter void write(std::ostream& os) const; protected: diff --git a/include/LIEF/ELF/DynamicEntry.hpp b/include/LIEF/ELF/DynamicEntry.hpp index 0d090e4b16..42a807168c 100644 --- a/include/LIEF/ELF/DynamicEntry.hpp +++ b/include/LIEF/ELF/DynamicEntry.hpp @@ -31,8 +31,8 @@ struct Elf64_Dyn; struct Elf32_Dyn; } -//! Class which represents an entry in the dynamic table -//! These entries are located in the ``.dynamic`` section or the ``PT_DYNAMIC`` segment +/// Class which represents an entry in the dynamic table +/// These entries are located in the ``.dynamic`` section or the ``PT_DYNAMIC`` segment class LIEF_API DynamicEntry : public Object { public: static constexpr uint64_t MIPS_DISC = 0x100000000; @@ -200,16 +200,16 @@ class LIEF_API DynamicEntry : public Object { return std::unique_ptr(new DynamicEntry(*this)); } - //! Tag of the current entry. The most common tags are: - //! DT_NEEDED, DT_INIT, ... + /// Tag of the current entry. The most common tags are: + /// DT_NEEDED, DT_INIT, ... TAG tag() const { return tag_; } - //! Return the entry's value - //! - //! The meaning of the value strongly depends on the tag. - //! It can be an offset, an index, a flag, ... + /// Return the entry's value + /// + /// The meaning of the value strongly depends on the tag. + /// It can be an offset, an index, a flag, ... uint64_t value() const { return value_; } diff --git a/include/LIEF/ELF/DynamicEntryArray.hpp b/include/LIEF/ELF/DynamicEntryArray.hpp index 87ec658aa8..447d439174 100644 --- a/include/LIEF/ELF/DynamicEntryArray.hpp +++ b/include/LIEF/ELF/DynamicEntryArray.hpp @@ -24,14 +24,14 @@ namespace LIEF { namespace ELF { -//! Class that represent an Array in the dynamic table. -//! This entry is associated with constructors: -//! - ``DT_PREINIT_ARRAY`` -//! - ``DT_INIT_ARRAY`` -//! - ``DT_FINI_ARRAY`` -//! -//! The underlying values are 64-bits integers to cover both: -//! ELF32 and ELF64 binaries. +/// Class that represent an Array in the dynamic table. +/// This entry is associated with constructors: +/// - ``DT_PREINIT_ARRAY`` +/// - ``DT_INIT_ARRAY`` +/// - ``DT_FINI_ARRAY`` +/// +/// The underlying values are 64-bits integers to cover both: +/// ELF32 and ELF64 binaries. class LIEF_API DynamicEntryArray : public DynamicEntry { public: using array_t = std::vector; @@ -50,7 +50,7 @@ class LIEF_API DynamicEntryArray : public DynamicEntry { return std::unique_ptr(new DynamicEntryArray(*this)); } - //! Return the array values (list of pointers) + /// Return the array values (list of pointers) array_t& array() { return array_; } @@ -62,19 +62,19 @@ class LIEF_API DynamicEntryArray : public DynamicEntry { array_ = array; } - //! Insert the given function at ``pos`` + /// Insert the given function at ``pos`` DynamicEntryArray& insert(size_t pos, uint64_t function); - //! Append the given function + /// Append the given function DynamicEntryArray& append(uint64_t function) { array_.push_back(function); return *this; } - //! Remove the given function + /// Remove the given function DynamicEntryArray& remove(uint64_t function); - //! Number of function registred in this array + /// Number of function registred in this array size_t size() const { return array_.size(); } diff --git a/include/LIEF/ELF/DynamicEntryFlags.hpp b/include/LIEF/ELF/DynamicEntryFlags.hpp index 83625d26d0..6477b66c60 100644 --- a/include/LIEF/ELF/DynamicEntryFlags.hpp +++ b/include/LIEF/ELF/DynamicEntryFlags.hpp @@ -90,10 +90,10 @@ class LIEF_API DynamicEntryFlags : public DynamicEntry { return std::unique_ptr(new DynamicEntryFlags(*this)); } - //! If the current entry has the given FLAG + /// If the current entry has the given FLAG bool has(FLAG f) const; - //! Return flags as a list of integers + /// Return flags as a list of integers flags_list_t flags() const; uint64_t raw_flags() const { @@ -105,10 +105,10 @@ class LIEF_API DynamicEntryFlags : public DynamicEntry { ); } - //! Add the given FLAG + /// Add the given FLAG void add(FLAG f); - //! Remove the given FLAG + /// Remove the given FLAG void remove(FLAG f); DynamicEntryFlags& operator+=(FLAG f) { diff --git a/include/LIEF/ELF/DynamicEntryLibrary.hpp b/include/LIEF/ELF/DynamicEntryLibrary.hpp index 04688c8522..36217cb976 100644 --- a/include/LIEF/ELF/DynamicEntryLibrary.hpp +++ b/include/LIEF/ELF/DynamicEntryLibrary.hpp @@ -23,9 +23,9 @@ namespace LIEF { namespace ELF { -//! Class which represents a ``DT_NEEDED`` entry in the dynamic table. -//! -//! This kind of entry is usually used to create library dependency. +/// Class which represents a ``DT_NEEDED`` entry in the dynamic table. +/// +/// This kind of entry is usually used to create library dependency. class LIEF_API DynamicEntryLibrary : public DynamicEntry { public: @@ -47,7 +47,7 @@ class LIEF_API DynamicEntryLibrary : public DynamicEntry { return std::unique_ptr(new DynamicEntryLibrary{*this}); } - //! Return the library associated with this entry (e.g. ``libc.so.6``) + /// Return the library associated with this entry (e.g. ``libc.so.6``) const std::string& name() const { return libname_; } diff --git a/include/LIEF/ELF/DynamicEntryRpath.hpp b/include/LIEF/ELF/DynamicEntryRpath.hpp index d573c6e780..0469d5a542 100644 --- a/include/LIEF/ELF/DynamicEntryRpath.hpp +++ b/include/LIEF/ELF/DynamicEntryRpath.hpp @@ -25,8 +25,8 @@ namespace LIEF { namespace ELF { -//! Class which represents a ``DT_RPATH`` entry. This attribute is -//! deprecated (cf. ``man ld``) in favour of ``DT_RUNPATH`` (See DynamicRunPath) +/// Class which represents a ``DT_RPATH`` entry. This attribute is +/// deprecated (cf. ``man ld``) in favour of ``DT_RUNPATH`` (See DynamicRunPath) class LIEF_API DynamicEntryRpath : public DynamicEntry { public: static constexpr char delimiter = ':'; @@ -40,7 +40,7 @@ class LIEF_API DynamicEntryRpath : public DynamicEntry { rpath_(std::move(rpath)) {} - //! Constructor from a list of paths + /// Constructor from a list of paths DynamicEntryRpath(const std::vector& paths) : DynamicEntry::DynamicEntry(DynamicEntry::TAG::RPATH, 0) { @@ -54,7 +54,7 @@ class LIEF_API DynamicEntryRpath : public DynamicEntry { return std::unique_ptr(new DynamicEntryRpath(*this)); } - //! The actual rpath as a string + /// The actual rpath as a string const std::string& rpath() const { return rpath_; } @@ -63,17 +63,17 @@ class LIEF_API DynamicEntryRpath : public DynamicEntry { rpath_ = std::move(name); } - //! Paths as a list + /// Paths as a list std::vector paths() const; void paths(const std::vector& paths); - //! Insert a ``path`` at the given ``position`` + /// Insert a ``path`` at the given ``position`` DynamicEntryRpath& insert(size_t pos, const std::string& path); - //! Append the given ``path`` + /// Append the given ``path`` DynamicEntryRpath& append(std::string path); - //! Remove the given ``path`` + /// Remove the given ``path`` DynamicEntryRpath& remove(const std::string& path); DynamicEntryRpath& operator+=(std::string path) { diff --git a/include/LIEF/ELF/DynamicEntryRunPath.hpp b/include/LIEF/ELF/DynamicEntryRunPath.hpp index d3fa8b962d..e796ce8383 100644 --- a/include/LIEF/ELF/DynamicEntryRunPath.hpp +++ b/include/LIEF/ELF/DynamicEntryRunPath.hpp @@ -25,8 +25,8 @@ namespace LIEF { namespace ELF { -//! Class that represents a ``DT_RUNPATH`` wich is used by the loader -//! to resolve libraries (DynamicEntryLibrary). +/// Class that represents a ``DT_RUNPATH`` wich is used by the loader +/// to resolve libraries (DynamicEntryLibrary). class LIEF_API DynamicEntryRunPath : public DynamicEntry { public: @@ -37,13 +37,13 @@ class LIEF_API DynamicEntryRunPath : public DynamicEntry { DynamicEntry::DynamicEntry(DynamicEntry::TAG::RUNPATH, 0) {} - //! Constructor from (run)path + /// Constructor from (run)path DynamicEntryRunPath(std::string runpath) : DynamicEntry::DynamicEntry(DynamicEntry::TAG::RUNPATH, 0), runpath_(std::move(runpath)) {} - //! Constructor from a list of paths + /// Constructor from a list of paths DynamicEntryRunPath(const std::vector& paths) : DynamicEntry::DynamicEntry(DynamicEntry::TAG::RUNPATH, 0) { @@ -57,7 +57,7 @@ class LIEF_API DynamicEntryRunPath : public DynamicEntry { return std::unique_ptr(new DynamicEntryRunPath(*this)); } - //! Runpath raw value + /// Runpath raw value const std::string& runpath() const { return runpath_; } @@ -66,17 +66,17 @@ class LIEF_API DynamicEntryRunPath : public DynamicEntry { runpath_ = std::move(runpath); } - //! Paths as a list + /// Paths as a list std::vector paths() const; void paths(const std::vector& paths); - //! Insert a ``path`` at the given ``position`` + /// Insert a ``path`` at the given ``position`` DynamicEntryRunPath& insert(size_t pos, const std::string& path); - //! Append the given ``path`` + /// Append the given ``path`` DynamicEntryRunPath& append(const std::string& path); - //! Remove the given ``path`` + /// Remove the given ``path`` DynamicEntryRunPath& remove(const std::string& path); DynamicEntryRunPath& operator+=(std::string path) { diff --git a/include/LIEF/ELF/DynamicSharedObject.hpp b/include/LIEF/ELF/DynamicSharedObject.hpp index 3c58313f18..b8ed6d2ff0 100644 --- a/include/LIEF/ELF/DynamicSharedObject.hpp +++ b/include/LIEF/ELF/DynamicSharedObject.hpp @@ -24,10 +24,10 @@ namespace LIEF { namespace ELF { -//! Class which represents a ``DT_SONAME`` entry in the dynamic table -//! This kind of entry is usually used to name the original library. -//! -//! This entry is not present for executable. +/// Class which represents a ``DT_SONAME`` entry in the dynamic table +/// This kind of entry is usually used to name the original library. +/// +/// This entry is not present for executable. class LIEF_API DynamicSharedObject : public DynamicEntry { public: @@ -48,7 +48,7 @@ class LIEF_API DynamicSharedObject : public DynamicEntry { return std::unique_ptr(new DynamicSharedObject(*this)); } - //! The actual name (e.g. ``libMyLib.so``) + /// The actual name (e.g. ``libMyLib.so``) const std::string& name() const { return name_; } diff --git a/include/LIEF/ELF/GnuHash.hpp b/include/LIEF/ELF/GnuHash.hpp index 7941e9b5a6..b660010e9c 100644 --- a/include/LIEF/ELF/GnuHash.hpp +++ b/include/LIEF/ELF/GnuHash.hpp @@ -30,9 +30,9 @@ class Parser; class Builder; class Binary; -//! Class which provides a view over the GNU Hash implementation. -//! Most of the fields are read-only since the values -//! are re-computed by the LIEF::ELF::Builder. +/// Class which provides a view over the GNU Hash implementation. +/// Most of the fields are read-only since the values +/// are re-computed by the LIEF::ELF::Builder. class LIEF_API GnuHash : public Object { friend class Parser; @@ -54,62 +54,62 @@ class LIEF_API GnuHash : public Object { ~GnuHash() override = default; - //! Return the number of buckets - //! @see GnuHash::buckets + /// Return the number of buckets + /// @see GnuHash::buckets uint32_t nb_buckets() const { return buckets_.size(); } - //! Index of the first symbol in the dynamic - //! symbols table which accessible with the hash table + /// Index of the first symbol in the dynamic + /// symbols table which accessible with the hash table uint32_t symbol_index() const { return symbol_index_; } - //! Shift count used in the bloom filter + /// Shift count used in the bloom filter uint32_t shift2() const { return shift2_; } - //! Number of bloom filters used. - //! It must be a power of 2 + /// Number of bloom filters used. + /// It must be a power of 2 uint32_t maskwords() const { return bloom_filters_.size(); } - //! Bloom filters + /// Bloom filters const std::vector& bloom_filters() const { return bloom_filters_; } - //! Hash buckets + /// Hash buckets const std::vector& buckets() const { return buckets_; } - //! Hash values + /// Hash values const std::vector& hash_values() const { return hash_values_; } - //! Check if the given hash passes the bloom filter + /// Check if the given hash passes the bloom filter bool check_bloom_filter(uint32_t hash) const; - //! Check if the given hash passes the bucket filter + /// Check if the given hash passes the bucket filter bool check_bucket(uint32_t hash) const { return buckets_[hash % nb_buckets()] > 0; } - //! Check if the symbol *probably* exists. If - //! the returned value is ``false`` you can assume at ``100%`` that - //! the symbol with the given name doesn't exist. If ``true``, you can't - //! do any assumption + /// Check if the symbol *probably* exists. If + /// the returned value is ``false`` you can assume at ``100%`` that + /// the symbol with the given name doesn't exist. If ``true``, you can't + /// do any assumption bool check(const std::string& symbol_name) const; - //! Check if the symbol associated with the given hash *probably* exists. If - //! the returned value is ``false`` you can assume at ``100%`` that - //! the symbol doesn't exists. If ``true`` you can't - //! do any assumption + /// Check if the symbol associated with the given hash *probably* exists. If + /// the returned value is ``false`` you can assume at ``100%`` that + /// the symbol doesn't exists. If ``true`` you can't + /// do any assumption bool check(uint32_t hash) const; diff --git a/include/LIEF/ELF/Note.hpp b/include/LIEF/ELF/Note.hpp index 77dcd96e51..3f605c5325 100644 --- a/include/LIEF/ELF/Note.hpp +++ b/include/LIEF/ELF/Note.hpp @@ -42,7 +42,7 @@ class LIEF_API Note : public Object { friend class Binary; public: - //! Container used to handle the description data + /// Container used to handle the description data using description_t = std::vector; /// LIEF representation of the ELF `NT_` values. diff --git a/include/LIEF/ELF/NoteDetails/AndroidIdent.hpp b/include/LIEF/ELF/NoteDetails/AndroidIdent.hpp index 3d4f9caea5..10e3b6236f 100644 --- a/include/LIEF/ELF/NoteDetails/AndroidIdent.hpp +++ b/include/LIEF/ELF/NoteDetails/AndroidIdent.hpp @@ -25,9 +25,9 @@ namespace LIEF { namespace ELF { -//! Class representing the ".note.android.ident" section -//! -//! @see: https://android.googlesource.com/platform/ndk/+/ndk-release-r16/sources/crt/crtbrand.S#39 +/// Class representing the ".note.android.ident" section +/// +/// @see: https://android.googlesource.com/platform/ndk/+/ndk-release-r16/sources/crt/crtbrand.S#39 class LIEF_API AndroidIdent : public Note { public: static constexpr size_t sdk_version_size = sizeof(uint32_t); @@ -39,13 +39,13 @@ class LIEF_API AndroidIdent : public Note { return std::unique_ptr(new AndroidIdent(*this)); } - //! Target SDK version (or 0 if it can't be resolved) + /// Target SDK version (or 0 if it can't be resolved) uint32_t sdk_version() const; - //! NDK version used (or an empty string if it can't be parsed) + /// NDK version used (or an empty string if it can't be parsed) std::string ndk_version() const; - //! NDK build number (or an empty string if it can't be parsed) + /// NDK build number (or an empty string if it can't be parsed) std::string ndk_build_number() const; void sdk_version(uint32_t version); diff --git a/include/LIEF/ELF/NoteDetails/core/CoreAuxv.hpp b/include/LIEF/ELF/NoteDetails/core/CoreAuxv.hpp index b99860eca1..c4a22b0d66 100644 --- a/include/LIEF/ELF/NoteDetails/core/CoreAuxv.hpp +++ b/include/LIEF/ELF/NoteDetails/core/CoreAuxv.hpp @@ -28,7 +28,7 @@ namespace LIEF { namespace ELF { -//! Class representing core auxv object +/// Class representing core auxv object class LIEF_API CoreAuxv : public Note { public: enum class TYPE { diff --git a/include/LIEF/ELF/NoteDetails/core/CoreFile.hpp b/include/LIEF/ELF/NoteDetails/core/CoreFile.hpp index aa00a77ae0..d9e8defcb3 100644 --- a/include/LIEF/ELF/NoteDetails/core/CoreFile.hpp +++ b/include/LIEF/ELF/NoteDetails/core/CoreFile.hpp @@ -30,7 +30,7 @@ namespace ELF { /// of the process class LIEF_API CoreFile : public Note { public: - //! Core file entry + /// Core file entry struct entry_t { uint64_t start = 0; /// Start address of mapped file uint64_t end = 0; ///< End address of mapped file @@ -53,12 +53,12 @@ class LIEF_API CoreFile : public Note { return std::unique_ptr(new CoreFile(*this)); } - //! Number of coredump file entries + /// Number of coredump file entries uint64_t count() const { return files_.size(); } - //! Coredump file entries + /// Coredump file entries const files_t& files() const { return files_; } diff --git a/include/LIEF/ELF/NoteDetails/core/CorePrStatus.hpp b/include/LIEF/ELF/NoteDetails/core/CorePrStatus.hpp index ccf5c7e259..927b49b17d 100644 --- a/include/LIEF/ELF/NoteDetails/core/CorePrStatus.hpp +++ b/include/LIEF/ELF/NoteDetails/core/CorePrStatus.hpp @@ -31,7 +31,7 @@ class Parser; class Builder; class Binary; -//! Class representing core PrPsInfo object +/// Class representing core PrPsInfo object class LIEF_API CorePrStatus : public Note { public: struct siginfo_t { diff --git a/include/LIEF/ELF/NoteDetails/core/CoreSigInfo.hpp b/include/LIEF/ELF/NoteDetails/core/CoreSigInfo.hpp index 0ec9f57843..ea94ffd1a9 100644 --- a/include/LIEF/ELF/NoteDetails/core/CoreSigInfo.hpp +++ b/include/LIEF/ELF/NoteDetails/core/CoreSigInfo.hpp @@ -27,7 +27,7 @@ namespace LIEF { namespace ELF { -//! Class representing a core siginfo object +/// Class representing a core siginfo object class LIEF_API CoreSigInfo : public Note { public: std::unique_ptr clone() const override { diff --git a/include/LIEF/ELF/Parser.hpp b/include/LIEF/ELF/Parser.hpp index 5031506674..700ff88a07 100644 --- a/include/LIEF/ELF/Parser.hpp +++ b/include/LIEF/ELF/Parser.hpp @@ -41,7 +41,7 @@ class Symbol; class Note; class Relocation; -//! Class which parses and transforms an ELF file into a ELF::Binary object +/// Class which parses and transforms an ELF file into a ELF::Binary object class LIEF_API Parser : public LIEF::Parser { friend class OAT::Parser; public: @@ -60,36 +60,36 @@ class LIEF_API Parser : public LIEF::Parser { ELF32, ELF64 }; - //! Parse an ELF file and return a LIEF::ELF::Binary object - //! - //! For weird binaries (e.g. sectionless) you can choose which method to use for counting dynamic symbols - //! - //! @param[in] file Path to the ELF binary - //! @param[in] conf Optional configuration for the parser - //! - //! @return LIEF::ELF::Binary as a `unique_ptr` + /// Parse an ELF file and return a LIEF::ELF::Binary object + /// + /// For weird binaries (e.g. sectionless) you can choose which method to use for counting dynamic symbols + /// + /// @param[in] file Path to the ELF binary + /// @param[in] conf Optional configuration for the parser + /// + /// @return LIEF::ELF::Binary as a `unique_ptr` static std::unique_ptr parse(const std::string& file, const ParserConfig& conf = ParserConfig::all()); - //! Parse the given raw data as an ELF binary and return a LIEF::ELF::Binary object - //! - //! For weird binaries (e.g. sectionless) you can choose which method use to count dynamic symbols - //! - //! @param[in] data Raw ELF as a std::vector of uint8_t - //! @param[in] conf Optional configuration for the parser - //! - //! @return LIEF::ELF::Binary + /// Parse the given raw data as an ELF binary and return a LIEF::ELF::Binary object + /// + /// For weird binaries (e.g. sectionless) you can choose which method use to count dynamic symbols + /// + /// @param[in] data Raw ELF as a std::vector of uint8_t + /// @param[in] conf Optional configuration for the parser + /// + /// @return LIEF::ELF::Binary static std::unique_ptr parse(const std::vector& data, const ParserConfig& conf = ParserConfig::all()); - //! Parse the ELF binary from the given stream and return a LIEF::ELF::Binary object - //! - //! For weird binaries (e.g. sectionless) you can choose which method use to count dynamic symbols - //! - //! @param[in] stream The stream which wraps the ELF binary - //! @param[in] conf Optional configuration for the parser - //! - //! @return LIEF::ELF::Binary + /// Parse the ELF binary from the given stream and return a LIEF::ELF::Binary object + /// + /// For weird binaries (e.g. sectionless) you can choose which method use to count dynamic symbols + /// + /// @param[in] stream The stream which wraps the ELF binary + /// @param[in] conf Optional configuration for the parser + /// + /// @return LIEF::ELF::Binary static std::unique_ptr parse(std::unique_ptr stream, const ParserConfig& conf = ParserConfig::all()); @@ -132,27 +132,27 @@ class LIEF_API Parser : public LIEF::Parser { uint64_t get_dynamic_string_table_from_sections() const; - //! Return the number of dynamic symbols using the given method + /// Return the number of dynamic symbols using the given method template result get_numberof_dynamic_symbols(ParserConfig::DYNSYM_COUNT mtd) const; - //! Count based on hash table (reliable) + /// Count based on hash table (reliable) template result nb_dynsym_hash() const; - //! Count based on SYSV hash table + /// Count based on SYSV hash table template result nb_dynsym_sysv_hash() const; - //! Count based on GNU hash table + /// Count based on GNU hash table template result nb_dynsym_gnu_hash() const; - //! Count based on sections (not very reliable) + /// Count based on sections (not very reliable) template result nb_dynsym_section() const; - //! Count based on PLT/GOT relocations (very reliable but not accurate) + /// Count based on PLT/GOT relocations (very reliable but not accurate) template result nb_dynsym_relocations() const; @@ -162,87 +162,87 @@ class LIEF_API Parser : public LIEF::Parser { template ok_error_t parse_dynamic_symbols(uint64_t offset); - //! Parse symtab Symbol - //! - //! Parser find Symbols offset by using the file offset attribute of the - //! ELF_SECTION_TYPES::SHT_SYMTAB Section. - //! - //! The number of symbols is taken from the `information` attribute in the section header. - //! - //! The section containing symbols name is found with the `link` attribute. + /// Parse symtab Symbol + /// + /// Parser find Symbols offset by using the file offset attribute of the + /// ELF_SECTION_TYPES::SHT_SYMTAB Section. + /// + /// The number of symbols is taken from the `information` attribute in the section header. + /// + /// The section containing symbols name is found with the `link` attribute. template ok_error_t parse_symtab_symbols(uint64_t offset, uint32_t nb_symbols, const Section& string_section); - //! Parse Dynamic relocations - //! - //! It uses DT_REL/DT_RELA dynamic entries to parse it + /// Parse Dynamic relocations + /// + /// It uses DT_REL/DT_RELA dynamic entries to parse it template ok_error_t parse_dynamic_relocations(uint64_t relocations_offset, uint64_t size); - //! Parse `.plt.got`/`got` relocations - //! - //! For: - //! * ELF32 it uses **DT_JMPREL** and **DT_PLTRELSZ** - //! * ELF64 it uses **DT_PLTREL** and **DT_PLTRELSZ** + /// Parse `.plt.got`/`got` relocations + /// + /// For: + /// * ELF32 it uses **DT_JMPREL** and **DT_PLTRELSZ** + /// * ELF64 it uses **DT_PLTREL** and **DT_PLTRELSZ** template ok_error_t parse_pltgot_relocations(uint64_t offset, uint64_t size); - //! Parse *relative* relocations + /// Parse *relative* relocations template ok_error_t parse_relative_relocations(uint64_t offset, uint64_t size); - //! Parse Android packed relocations + /// Parse Android packed relocations template ok_error_t parse_packed_relocations(uint64_t offset, uint64_t size); template ok_error_t process_dynamic_table(); - //! Parse relocations using LIEF::ELF::Section. - //! Section relocations are usually found in object files + /// Parse relocations using LIEF::ELF::Section. + /// Section relocations are usually found in object files template ok_error_t parse_section_relocations(const Section& section); - //! Parse SymbolVersionRequirement - //! - //! We use the virtual address stored in the - //! DynamicEntry::TAG::VERNEED entry to get the offset. - //! and DynamicEntry::TAG::VERNEEDNUM to get the number of entries + /// Parse SymbolVersionRequirement + /// + /// We use the virtual address stored in the + /// DynamicEntry::TAG::VERNEED entry to get the offset. + /// and DynamicEntry::TAG::VERNEEDNUM to get the number of entries template ok_error_t parse_symbol_version_requirement(uint64_t offset, uint32_t nb_entries); - //! Parse SymbolVersionDefinition. - //! - //! We use the virtual address stored in - //! the DynamicEntry::TAG::VERDEF DT_VERDEF entry to get the offset. - //! DynamicEntry::TAG::VERDEFNUM gives the number of entries + /// Parse SymbolVersionDefinition. + /// + /// We use the virtual address stored in + /// the DynamicEntry::TAG::VERDEF DT_VERDEF entry to get the offset. + /// DynamicEntry::TAG::VERDEFNUM gives the number of entries template ok_error_t parse_symbol_version_definition(uint64_t offset, uint32_t nb_entries); - //! Parse @link SymbolVersion Symbol version @endlink. - //! - //! We use the virtual address stored in the - //! DynamicEntry::TAG::VERSYM entry to parse it. - //! - //! @see http://dev.gentoo.org/~solar/elf/symbol-versioning + /// Parse @link SymbolVersion Symbol version @endlink. + /// + /// We use the virtual address stored in the + /// DynamicEntry::TAG::VERSYM entry to parse it. + /// + /// @see http://dev.gentoo.org/~solar/elf/symbol-versioning ok_error_t parse_symbol_version(uint64_t symbol_version_offset); - //! Parse Symbols's GNU hash - //! - //! @see https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections + /// Parse Symbols's GNU hash + /// + /// @see https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections template ok_error_t parse_symbol_gnu_hash(uint64_t offset); - //! Parse Note (.gnu.note) + /// Parse Note (.gnu.note) ok_error_t parse_notes(uint64_t offset, uint64_t size); std::unique_ptr get_note(uint32_t type, std::string name, std::vector desc_bytes); - //! Parse Symbols's SYSV hash + /// Parse Symbols's SYSV hash ok_error_t parse_symbol_sysv_hash(uint64_t offset); ok_error_t parse_overlay(); @@ -250,7 +250,7 @@ class LIEF_API Parser : public LIEF::Parser { template uint32_t max_relocation_index(uint64_t relocations_offset, uint64_t size) const; - //! Check if the given Section is wrapped by the given segment + /// Check if the given Section is wrapped by the given segment static bool check_section_in_segment(const Section& section, const Segment& segment); bool bind_symbol(Relocation& R); diff --git a/include/LIEF/ELF/ParserConfig.hpp b/include/LIEF/ELF/ParserConfig.hpp index bbeaa5843e..a880cba8c8 100644 --- a/include/LIEF/ELF/ParserConfig.hpp +++ b/include/LIEF/ELF/ParserConfig.hpp @@ -21,7 +21,7 @@ namespace LIEF { namespace ELF { -//! This structure is used to tweak the ELF Parser (ELF::Parser) +/// This structure is used to tweak the ELF Parser (ELF::Parser) struct LIEF_API ParserConfig { /** Methods that can be used by the LIEF::ELF::Parser to count the number of dynamic symbols */ @@ -32,8 +32,8 @@ struct LIEF_API ParserConfig { RELOCATIONS = 3, /**< Count based on PLT/GOT relocations (very reliable but not accurate) */ }; - //! This returns a ParserConfig object configured to process all the ELF - //! elements. + /// This returns a ParserConfig object configured to process all the ELF + /// elements. static ParserConfig all() { static const ParserConfig DEFAULT; return DEFAULT; diff --git a/include/LIEF/ELF/Section.hpp b/include/LIEF/ELF/Section.hpp index c56ee3ae28..b0768daee0 100644 --- a/include/LIEF/ELF/Section.hpp +++ b/include/LIEF/ELF/Section.hpp @@ -44,7 +44,7 @@ class ExeLayout; class ObjectFileLayout; -//! Class wich represents an ELF Section +/// Class wich represents an ELF Section class LIEF_API Section : public LIEF::Section { friend class Parser; friend class Binary; @@ -177,26 +177,26 @@ class LIEF_API Section : public LIEF::Section { return type_; } - //! Section's content + /// Section's content span content() const override; - //! Set section content + /// Set section content void content(const std::vector& data) override; void content(std::vector&& data); - //! Section flags + /// Section flags uint64_t flags() const { return flags_; } - //! ``True`` if the section has the given flag + /// ``True`` if the section has the given flag bool has(FLAGS flag) const; - //! ``True`` if the section is wrapped by the given Segment + /// ``True`` if the section is wrapped by the given Segment bool has(const Segment& segment) const; - //! Return section flags as a ``std::set`` + /// Return section flags as a ``std::set`` std::vector flags_list() const; uint64_t size() const override { @@ -211,52 +211,52 @@ class LIEF_API Section : public LIEF::Section { return offset_; } - //! @see offset + /// @see offset uint64_t file_offset() const { return this->offset(); } - //! Original size of the section's data. - //! - //! This value is used by the ELF::Builder to determines if it needs - //! to be relocated to avoid an override of the data + /// Original size of the section's data. + /// + /// This value is used by the ELF::Builder to determines if it needs + /// to be relocated to avoid an override of the data uint64_t original_size() const { return original_size_; } - //! Section file alignment + /// Section file alignment uint64_t alignment() const { return address_align_; } - //! Section information. - //! The meaning of this value depends on the section's type + /// Section information. + /// The meaning of this value depends on the section's type uint64_t information() const { return info_; } - //! This function returns the size of an element in the case of a section that contains - //! an array. - //! - //! For instance, the `.dynamic` section contains an array of DynamicEntry. As the - //! size of the raw C structure of this entry is 0x10 (`sizeoe(Elf64_Dyn)`) - //! in a ELF64, the `entry_size` is set to this value. + /// This function returns the size of an element in the case of a section that contains + /// an array. + /// + /// For instance, the `.dynamic` section contains an array of DynamicEntry. As the + /// size of the raw C structure of this entry is 0x10 (`sizeoe(Elf64_Dyn)`) + /// in a ELF64, the `entry_size` is set to this value. uint64_t entry_size() const { return entry_size_; } - //! Index to another section + /// Index to another section uint32_t link() const { return link_; } - //! Clear the content of the section with the given ``value`` + /// Clear the content of the section with the given ``value`` Section& clear(uint8_t value = 0); - //! Add the given ELF_SECTION_FLAGS + /// Add the given ELF_SECTION_FLAGS void add(FLAGS flag); - //! Remove the given ELF_SECTION_FLAGS + /// Remove the given ELF_SECTION_FLAGS void remove(FLAGS flag); void type(TYPE type) { diff --git a/include/LIEF/ELF/Segment.hpp b/include/LIEF/ELF/Segment.hpp index b1322fd49a..e596ded7cf 100644 --- a/include/LIEF/ELF/Segment.hpp +++ b/include/LIEF/ELF/Segment.hpp @@ -42,7 +42,7 @@ class Binary; class Section; class Builder; -//! Class which represents the ELF segments +/// Class which represents the ELF segments class LIEF_API Segment : public Object { friend class Parser; @@ -134,70 +134,70 @@ class LIEF_API Segment : public Object { return type() == TYPE::PHDR; } - //! The segment's type (LOAD, DYNAMIC, ...) + /// The segment's type (LOAD, DYNAMIC, ...) TYPE type() const { return type_; } - //! The flag permissions associated with this segment + /// The flag permissions associated with this segment FLAGS flags() const { return FLAGS(flags_); } - //! The file offset of the data associated with this segment + /// The file offset of the data associated with this segment uint64_t file_offset() const { return file_offset_; } - //! The virtual address of the segment. + /// The virtual address of the segment. uint64_t virtual_address() const { return virtual_address_; } - //! The physical address of the segment. - //! This value is not really relevant on systems like Linux or Android. - //! On the other hand, Qualcomm trustlets might use this value. - //! - //! Usually this value matches virtual_address + /// The physical address of the segment. + /// This value is not really relevant on systems like Linux or Android. + /// On the other hand, Qualcomm trustlets might use this value. + /// + /// Usually this value matches virtual_address uint64_t physical_address() const { return physical_address_; } - //! The **file** size of the data associated with this segment + /// The **file** size of the data associated with this segment uint64_t physical_size() const { return size_; } - //! The in-memory size of this segment. - //! Usually, if the `.bss` segment is wrapped by this segment - //! then, virtual_size is larger than physical_size + /// The in-memory size of this segment. + /// Usually, if the `.bss` segment is wrapped by this segment + /// then, virtual_size is larger than physical_size uint64_t virtual_size() const { return virtual_size_; } - //! The offset alignment of the segment + /// The offset alignment of the segment uint64_t alignment() const { return alignment_; } - //! The raw data associated with this segment. + /// The raw data associated with this segment. span content() const; - //! Check if the current segment has the given flag + /// Check if the current segment has the given flag bool has(FLAGS flag) const { return (flags_ & static_cast(flag)) != 0; } - //! Check if the current segment wraps the given ELF::Section + /// Check if the current segment wraps the given ELF::Section bool has(const Section& section) const; - //! Check if the current segment wraps the given section's name + /// Check if the current segment wraps the given section's name bool has(const std::string& section_name) const; - //! Append the given ELF_SEGMENT_FLAGS + /// Append the given ELF_SEGMENT_FLAGS void add(FLAGS flag); - //! Remove the given ELF_SEGMENT_FLAGS + /// Remove the given ELF_SEGMENT_FLAGS void remove(FLAGS flag); void type(TYPE type) { @@ -242,7 +242,7 @@ class LIEF_API Segment : public Object { template void set_content_value(size_t offset, T value); size_t get_content_size() const; - //! Iterator over the sections wrapped by this segment + /// Iterator over the sections wrapped by this segment it_sections sections() { return sections_; } diff --git a/include/LIEF/ELF/SymbolVersion.hpp b/include/LIEF/ELF/SymbolVersion.hpp index 17fb39669e..d2cf0c577c 100644 --- a/include/LIEF/ELF/SymbolVersion.hpp +++ b/include/LIEF/ELF/SymbolVersion.hpp @@ -27,8 +27,8 @@ class Parser; class SymbolVersionAux; class SymbolVersionAuxRequirement; -//! Class which represents an entry defined in the `DT_VERSYM` -//! dynamic entry +/// Class which represents an entry defined in the `DT_VERSYM` +/// dynamic entry class LIEF_API SymbolVersion : public Object { friend class Parser; @@ -38,12 +38,12 @@ class LIEF_API SymbolVersion : public Object { {} SymbolVersion() = default; - //! Generate a *local* SymbolVersion + /// Generate a *local* SymbolVersion static SymbolVersion local() { return SymbolVersion(0); } - //! Generate a *global* SymbolVersion + /// Generate a *global* SymbolVersion static SymbolVersion global() { return SymbolVersion(1); } @@ -53,23 +53,23 @@ class LIEF_API SymbolVersion : public Object { SymbolVersion& operator=(const SymbolVersion&) = default; SymbolVersion(const SymbolVersion&) = default; - //! Value associated with the symbol - //! - //! If the given SymbolVersion hasn't Auxiliary version: - //! - //! * ``0`` means **Local** - //! * ``1`` means **Global** + /// Value associated with the symbol + /// + /// If the given SymbolVersion hasn't Auxiliary version: + /// + /// * ``0`` means **Local** + /// * ``1`` means **Global** uint16_t value() const { return value_; } - //! Whether the current SymbolVersion has an auxiliary one + /// Whether the current SymbolVersion has an auxiliary one bool has_auxiliary_version() const { return symbol_version_auxiliary() != nullptr; } - //! SymbolVersionAux associated with the current Version if any, - //! or a nullptr + /// SymbolVersionAux associated with the current Version if any, + /// or a nullptr SymbolVersionAux* symbol_version_auxiliary() { return symbol_aux_; } @@ -78,12 +78,12 @@ class LIEF_API SymbolVersion : public Object { return symbol_aux_; } - //! Set the version's auxiliary requirement - //! The given SymbolVersionAuxRequirement must be an existing - //! reference in the ELF::Binary. - //! - //! On can add a new SymbolVersionAuxRequirement by using - //! SymbolVersionRequirement::add_aux_requirement + /// Set the version's auxiliary requirement + /// The given SymbolVersionAuxRequirement must be an existing + /// reference in the ELF::Binary. + /// + /// On can add a new SymbolVersionAuxRequirement by using + /// SymbolVersionRequirement::add_aux_requirement void symbol_version_auxiliary(SymbolVersionAuxRequirement& svauxr); void value(uint16_t v) { diff --git a/include/LIEF/ELF/SymbolVersionAux.hpp b/include/LIEF/ELF/SymbolVersionAux.hpp index bd37f1e4cf..8861b781a1 100644 --- a/include/LIEF/ELF/SymbolVersionAux.hpp +++ b/include/LIEF/ELF/SymbolVersionAux.hpp @@ -26,7 +26,7 @@ namespace LIEF { namespace ELF { class Parser; -//! @brief Class which represents an Auxiliary Symbol version +/// Class which represents an Auxiliary Symbol version class LIEF_API SymbolVersionAux : public Object { friend class Parser; public: @@ -39,7 +39,7 @@ class LIEF_API SymbolVersionAux : public Object { SymbolVersionAux& operator=(const SymbolVersionAux&) = default; SymbolVersionAux(const SymbolVersionAux&) = default; - //! Symbol's aux name (e.g. ``GLIBC_2.2.5``) + /// Symbol's aux name (e.g. ``GLIBC_2.2.5``) const std::string& name() const { return name_; } diff --git a/include/LIEF/ELF/SymbolVersionAuxRequirement.hpp b/include/LIEF/ELF/SymbolVersionAuxRequirement.hpp index 3b0d847e4f..c85be51a76 100644 --- a/include/LIEF/ELF/SymbolVersionAuxRequirement.hpp +++ b/include/LIEF/ELF/SymbolVersionAuxRequirement.hpp @@ -45,20 +45,20 @@ class LIEF_API SymbolVersionAuxRequirement : public SymbolVersionAux { ~SymbolVersionAuxRequirement() override = default; - //! Hash value of the dependency name (use ELF hashing function) + /// Hash value of the dependency name (use ELF hashing function) uint32_t hash() const { return hash_; } - //! Bitmask of flags + /// Bitmask of flags uint16_t flags() const { return flags_; } - //! It returns the unique version index for the file which is used in the - //! version symbol table. If the highest bit (bit 15) is set this - //! is a hidden symbol which cannot be referenced from outside the - //! object. + /// It returns the unique version index for the file which is used in the + /// version symbol table. If the highest bit (bit 15) is set this + /// is a hidden symbol which cannot be referenced from outside the + /// object. uint16_t other() const { return other_; } diff --git a/include/LIEF/ELF/SymbolVersionDefinition.hpp b/include/LIEF/ELF/SymbolVersionDefinition.hpp index 5ba6e2f6c6..fc6036070d 100644 --- a/include/LIEF/ELF/SymbolVersionDefinition.hpp +++ b/include/LIEF/ELF/SymbolVersionDefinition.hpp @@ -33,7 +33,7 @@ struct Elf64_Verdef; struct Elf32_Verdef; } -//! Class which represents an entry defined in `DT_VERDEF` or `.gnu.version_d` +/// Class which represents an entry defined in `DT_VERDEF` or `.gnu.version_d` class LIEF_API SymbolVersionDefinition : public Object { friend class Parser; public: @@ -50,32 +50,32 @@ class LIEF_API SymbolVersionDefinition : public Object { SymbolVersionDefinition(const SymbolVersionDefinition& other); void swap(SymbolVersionDefinition& other); - //! Version revision - //! - //! This field should always have the value ``1``. It will be changed - //! if the versioning implementation has to be changed in an incompatible way. + /// Version revision + /// + /// This field should always have the value ``1``. It will be changed + /// if the versioning implementation has to be changed in an incompatible way. uint16_t version() const { return version_; } - //! Version information + /// Version information uint16_t flags() const { return flags_; } - //! Version index - //! - //! Numeric value used as an index in the LIEF::ELF::SymbolVersion table + /// Version index + /// + /// Numeric value used as an index in the LIEF::ELF::SymbolVersion table uint16_t ndx() const { return ndx_; } - //! Hash value of the symbol's name (using ELF hash function) + /// Hash value of the symbol's name (using ELF hash function) uint32_t hash() const { return hash_; } - //! SymbolVersionAux entries + /// SymbolVersionAux entries it_version_aux symbols_aux() { return symbol_version_aux_; } diff --git a/include/LIEF/ELF/SymbolVersionRequirement.hpp b/include/LIEF/ELF/SymbolVersionRequirement.hpp index 01a8d6ca9d..9bf26bae52 100644 --- a/include/LIEF/ELF/SymbolVersionRequirement.hpp +++ b/include/LIEF/ELF/SymbolVersionRequirement.hpp @@ -35,7 +35,7 @@ struct Elf64_Verneed; struct Elf32_Verneed; } -//! Class which represents an entry in the `DT_VERNEED` or `.gnu.version_r` table +/// Class which represents an entry in the `DT_VERNEED` or `.gnu.version_r` table class LIEF_API SymbolVersionRequirement : public Object { friend class Parser; @@ -53,20 +53,20 @@ class LIEF_API SymbolVersionRequirement : public Object { SymbolVersionRequirement(const SymbolVersionRequirement& other); void swap(SymbolVersionRequirement& other); - //! Version revision - //! - //! This field should always have the value ``1``. It will be changed - //! if the versioning implementation has to be changed in an incompatible way. + /// Version revision + /// + /// This field should always have the value ``1``. It will be changed + /// if the versioning implementation has to be changed in an incompatible way. uint16_t version() const { return version_; } - //! Number of auxiliary entries + /// Number of auxiliary entries size_t cnt() const { return aux_requirements_.size(); } - //! Auxiliary entries as an iterator over SymbolVersionAuxRequirement + /// Auxiliary entries as an iterator over SymbolVersionAuxRequirement it_aux_requirement auxiliary_symbols() { return aux_requirements_; } @@ -75,7 +75,7 @@ class LIEF_API SymbolVersionRequirement : public Object { return aux_requirements_; } - //! Return the library name associated with this requirement (e.g. ``libc.so.6``) + /// Return the library name associated with this requirement (e.g. ``libc.so.6``) const std::string& name() const { return name_; } @@ -88,7 +88,7 @@ class LIEF_API SymbolVersionRequirement : public Object { name_ = name; } - //! Add a version auxiliary requirement to the existing list + /// Add a version auxiliary requirement to the existing list SymbolVersionAuxRequirement& add_aux_requirement(const SymbolVersionAuxRequirement& aux_requirement); void accept(Visitor& visitor) const override; diff --git a/include/LIEF/ELF/SysvHash.hpp b/include/LIEF/ELF/SysvHash.hpp index bbd0f67720..1ea0c14a0a 100644 --- a/include/LIEF/ELF/SysvHash.hpp +++ b/include/LIEF/ELF/SysvHash.hpp @@ -30,12 +30,12 @@ class Parser; class Builder; class Binary; -//! Class which represents the SYSV hash for the symbols -//! resolution. -//! -//! References: -//! - http://www.linker-aliens.org/blogs/ali/entry/gnu_hash_elf_sections/ -//! - https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-48031.html +/// Class which represents the SYSV hash for the symbols +/// resolution. +/// +/// References: +/// - http://www.linker-aliens.org/blogs/ali/entry/gnu_hash_elf_sections/ +/// - https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-48031.html class LIEF_API SysvHash : public Object { friend class Parser; @@ -51,22 +51,22 @@ class LIEF_API SysvHash : public Object { SysvHash(SysvHash&&) = default; ~SysvHash() override = default; - //! @brief Return the number of buckets used + /// Return the number of buckets used uint32_t nbucket() const { return buckets_.size(); } - //! @brief Return the number of chain used + /// Return the number of chain used uint32_t nchain() const { return chains_.size(); } - //! @brief Buckets values + /// Buckets values const std::vector& buckets() const { return buckets_; } - //! @brief Chains values + /// Chains values const std::vector& chains() const { return chains_; } diff --git a/include/LIEF/ELF/enums.hpp b/include/LIEF/ELF/enums.hpp index 3545a645aa..c304f7426f 100644 --- a/include/LIEF/ELF/enums.hpp +++ b/include/LIEF/ELF/enums.hpp @@ -23,7 +23,7 @@ namespace LIEF { namespace ELF { /** - * @brief Machine architectures + * Machine architectures * See current registered ELF machine architectures at: * http://www.sco.com/developers/gabi/latest/ch4.eheader.html */ diff --git a/include/LIEF/ELF/hash.hpp b/include/LIEF/ELF/hash.hpp index 20e1e5a307..4c9bd5eaa9 100644 --- a/include/LIEF/ELF/hash.hpp +++ b/include/LIEF/ELF/hash.hpp @@ -53,8 +53,8 @@ class CoreFile; class GnuHash; class SysvHash; -//! Class which implements a visitor to compute -//! a **deterministic** hash for LIEF ELF objects +/// Class which implements a visitor to compute +/// a **deterministic** hash for LIEF ELF objects class LIEF_API Hash : public LIEF::Hash { public: static LIEF::Hash::value_type hash(const Object& obj); diff --git a/include/LIEF/ELF/utils.hpp b/include/LIEF/ELF/utils.hpp index f14a789c83..955de3eed8 100644 --- a/include/LIEF/ELF/utils.hpp +++ b/include/LIEF/ELF/utils.hpp @@ -27,13 +27,13 @@ class BinaryStream; namespace ELF { -//! @brief Check if given stream wraps an ELF file +/// Check if given stream wraps an ELF file LIEF_API bool is_elf(BinaryStream& stream); -//! @brief Check if the given file is an ELF one. +/// Check if the given file is an ELF one. LIEF_API bool is_elf(const std::string& file); -//! @brief check if the raw data is a ELF file +/// check if the raw data is a ELF file LIEF_API bool is_elf(const std::vector& raw); LIEF_API unsigned long hash32(const char* name); diff --git a/include/LIEF/MachO/Binary.hpp b/include/LIEF/MachO/Binary.hpp index 5fd167aa0d..16544ea146 100644 --- a/include/LIEF/MachO/Binary.hpp +++ b/include/LIEF/MachO/Binary.hpp @@ -42,7 +42,7 @@ namespace objc { class Metadata; } -//! Namespace related to the LIEF's Mach-O module +/// Namespace related to the LIEF's Mach-O module namespace MachO { class BinaryParser; @@ -81,7 +81,7 @@ class TwoLevelHints; class UUIDCommand; class VersionMin; -//! Class which represents a MachO binary +/// Class which represents a MachO binary class LIEF_API Binary : public LIEF::Binary { friend class Parser; @@ -104,109 +104,109 @@ class LIEF_API Binary : public LIEF::Binary { } }; - //! Internal container for storing Mach-O LoadCommand + /// Internal container for storing Mach-O LoadCommand using commands_t = std::vector>; - //! Iterator that outputs LoadCommand& + /// Iterator that outputs LoadCommand& using it_commands = ref_iterator; - //! Iterator that outputs const LoadCommand& + /// Iterator that outputs const LoadCommand& using it_const_commands = const_ref_iterator; - //! Internal container for storing Mach-O Symbol + /// Internal container for storing Mach-O Symbol using symbols_t = std::vector>; - //! Iterator that outputs Symbol& + /// Iterator that outputs Symbol& using it_symbols = ref_iterator; - //! Iterator that outputs const Symbol& + /// Iterator that outputs const Symbol& using it_const_symbols = const_ref_iterator; - //! Iterator that outputs exported Symbol& + /// Iterator that outputs exported Symbol& using it_exported_symbols = filter_iterator; - //! Iterator that outputs exported const Symbol& + /// Iterator that outputs exported const Symbol& using it_const_exported_symbols = const_filter_iterator; - //! Iterator that outputs imported Symbol& + /// Iterator that outputs imported Symbol& using it_imported_symbols = filter_iterator; - //! Iterator that outputs imported const Symbol& + /// Iterator that outputs imported const Symbol& using it_const_imported_symbols = const_filter_iterator; - //! Internal container for caching Mach-O Section + /// Internal container for caching Mach-O Section using sections_cache_t = std::vector; - //! Iterator that outputs Section& + /// Iterator that outputs Section& using it_sections = ref_iterator; - //! Iterator that outputs const Section& + /// Iterator that outputs const Section& using it_const_sections = const_ref_iterator; - //! Internal container for storing Mach-O SegmentCommand + /// Internal container for storing Mach-O SegmentCommand using segments_cache_t = std::vector; - //! Iterator that outputs SegmentCommand& + /// Iterator that outputs SegmentCommand& using it_segments = ref_iterator; - //! Iterator that outputs const SegmentCommand& + /// Iterator that outputs const SegmentCommand& using it_const_segments = const_ref_iterator; - //! Internal container for storing Mach-O DylibCommand + /// Internal container for storing Mach-O DylibCommand using libraries_cache_t = std::vector; - //! Iterator that outputs DylibCommand& + /// Iterator that outputs DylibCommand& using it_libraries = ref_iterator; - //! Iterator that outputs const DylibCommand& + /// Iterator that outputs const DylibCommand& using it_const_libraries = const_ref_iterator; - //! Internal container for storing Mach-O Fileset Binary + /// Internal container for storing Mach-O Fileset Binary using fileset_binaries_t = std::vector>; - //! Iterator that outputs Binary& + /// Iterator that outputs Binary& using it_fileset_binaries = ref_iterator; - //! Iterator that outputs const Binary& + /// Iterator that outputs const Binary& using it_const_fileset_binaries = const_ref_iterator; struct KeyCmp { bool operator() (const Relocation* lhs, const Relocation* rhs) const; }; - //! Internal container that store all the relocations - //! found in a Mach-O. The relocations are actually owned - //! by Section & SegmentCommand and these references are used for convenience + /// Internal container that store all the relocations + /// found in a Mach-O. The relocations are actually owned + /// by Section & SegmentCommand and these references are used for convenience using relocations_t = std::set; - //! Iterator which outputs Relocation& + /// Iterator which outputs Relocation& using it_relocations = ref_iterator; - //! Iterator which outputs const Relocation& + /// Iterator which outputs const Relocation& using it_const_relocations = const_ref_iterator; - //! Iterator which outputs RPathCommand& + /// Iterator which outputs RPathCommand& using it_rpaths = filter_iterator; - //! Iterator which outputs const RPathCommand& + /// Iterator which outputs const RPathCommand& using it_const_rpaths = const_filter_iterator; - //! Iterator which outputs SubClient& + /// Iterator which outputs SubClient& using it_sub_clients = filter_iterator; - //! Iterator which outputs const SubClient& + /// Iterator which outputs const SubClient& using it_const_sub_clients = const_filter_iterator; using it_bindings = iterator_range; - //! Iterator type for Symbol's stub + /// Iterator type for Symbol's stub using stub_iterator = iterator_range; public: Binary(const Binary&) = delete; Binary& operator=(const Binary&) = delete; - //! Return a reference to the MachO::Header + /// Return a reference to the MachO::Header Header& header() { return header_; } @@ -215,8 +215,8 @@ class LIEF_API Binary : public LIEF::Binary { return header_; } - //! Return an iterator over the MachO LoadCommand present - //! in the binary + /// Return an iterator over the MachO LoadCommand present + /// in the binary it_commands commands() { return commands_; } @@ -225,8 +225,8 @@ class LIEF_API Binary : public LIEF::Binary { return commands_; } - //! Return an iterator over the MachO::Binary associated - //! with the LoadCommand::TYPE::FILESET_ENTRY commands + /// Return an iterator over the MachO::Binary associated + /// with the LoadCommand::TYPE::FILESET_ENTRY commands it_fileset_binaries filesets() { return filesets_; } @@ -235,7 +235,7 @@ class LIEF_API Binary : public LIEF::Binary { return filesets_; } - //! Return binary's @link MachO::Symbol symbols @endlink + /// Return binary's @link MachO::Symbol symbols @endlink it_symbols symbols() { return symbols_; } @@ -243,22 +243,22 @@ class LIEF_API Binary : public LIEF::Binary { return symbols_; } - //! Check if a symbol with the given name exists + /// Check if a symbol with the given name exists bool has_symbol(const std::string& name) const { return get_symbol(name) != nullptr; } - //! Return Symbol from the given name. If the symbol does not - //! exists, it returns a null pointer + /// Return Symbol from the given name. If the symbol does not + /// exists, it returns a null pointer const Symbol* get_symbol(const std::string& name) const; Symbol* get_symbol(const std::string& name) { return const_cast(static_cast(this)->get_symbol(name)); } - //! Check if the given symbol is exported + /// Check if the given symbol is exported static bool is_exported(const Symbol& symbol); - //! Return binary's exported symbols (iterator over LIEF::MachO::Symbol) + /// Return binary's exported symbols (iterator over LIEF::MachO::Symbol) it_exported_symbols exported_symbols() { return {symbols_, [] (const std::unique_ptr& symbol) { return is_exported(*symbol); } @@ -270,10 +270,10 @@ class LIEF_API Binary : public LIEF::Binary { }}; } - //! Check if the given symbol is an imported one + /// Check if the given symbol is an imported one static bool is_imported(const Symbol& symbol); - //! Return binary's imported symbols (iterator over LIEF::MachO::Symbol) + /// Return binary's imported symbols (iterator over LIEF::MachO::Symbol) it_imported_symbols imported_symbols() { return {symbols_, [] (const std::unique_ptr& symbol) { return is_imported(*symbol); @@ -286,7 +286,7 @@ class LIEF_API Binary : public LIEF::Binary { }}; } - //! Return binary imported libraries (MachO::DylibCommand) + /// Return binary imported libraries (MachO::DylibCommand) it_libraries libraries() { return libraries_; } @@ -295,7 +295,7 @@ class LIEF_API Binary : public LIEF::Binary { return libraries_; } - //! Return an iterator over the SegmentCommand + /// Return an iterator over the SegmentCommand it_segments segments() { return segments_; } @@ -303,7 +303,7 @@ class LIEF_API Binary : public LIEF::Binary { return segments_; } - //! Return an iterator over the MachO::Section + /// Return an iterator over the MachO::Section it_sections sections() { return sections_; } @@ -311,28 +311,28 @@ class LIEF_API Binary : public LIEF::Binary { return sections_; } - //! Return an iterator over the MachO::Relocation + /// Return an iterator over the MachO::Relocation it_relocations relocations(); it_const_relocations relocations() const; - //! Reconstruct the binary object and write the result in the given `filename` - //! - //! @param filename Path to write the reconstructed binary + /// Reconstruct the binary object and write the result in the given `filename` + /// + /// @param filename Path to write the reconstructed binary void write(const std::string& filename) override; - //! Reconstruct the binary object and write the result in the given `os` stream - //! - //! @param os Output stream to write the reconstructed binary + /// Reconstruct the binary object and write the result in the given `os` stream + /// + /// @param os Output stream to write the reconstructed binary void write(std::ostream& os) override; - //! Reconstruct the binary object and return its content as bytes + /// Reconstruct the binary object and return its content as bytes std::vector raw(); - //! Check if the current binary has the given MachO::LoadCommand::TYPE + /// Check if the current binary has the given MachO::LoadCommand::TYPE bool has(LoadCommand::TYPE type) const; - //! Return the LoadCommand associated with the given LoadCommand::TYPE - //! or a nullptr if the command can't be found. + /// Return the LoadCommand associated with the given LoadCommand::TYPE + /// or a nullptr if the command can't be found. const LoadCommand* get(LoadCommand::TYPE type) const; LoadCommand* get(LoadCommand::TYPE type) { return const_cast(static_cast(this)->get(type)); @@ -340,233 +340,233 @@ class LIEF_API Binary : public LIEF::Binary { LoadCommand* add(std::unique_ptr command); - //! Insert a new LoadCommand + /// Insert a new LoadCommand LoadCommand* add(const LoadCommand& command) { return add(command.clone()); } - //! Insert a new LoadCommand at the specified ``index`` + /// Insert a new LoadCommand at the specified ``index`` LoadCommand* add(const LoadCommand& command, size_t index); - //! Insert the given DylibCommand + /// Insert the given DylibCommand LoadCommand* add(const DylibCommand& library); - //! Add a new LC_SEGMENT command from the given SegmentCommand + /// Add a new LC_SEGMENT command from the given SegmentCommand LoadCommand* add(const SegmentCommand& segment); - //! Insert a new shared library through a ``LC_LOAD_DYLIB`` command + /// Insert a new shared library through a ``LC_LOAD_DYLIB`` command LoadCommand* add_library(const std::string& name); - //! Add a new MachO::Section in the __TEXT segment + /// Add a new MachO::Section in the __TEXT segment Section* add_section(const Section& section); - //! Add a section in the given MachO::SegmentCommand. - //! - //! @warning This method may corrupt the file if the segment is not the first one - //! nor the last one + /// Add a section in the given MachO::SegmentCommand. + /// + /// @warning This method may corrupt the file if the segment is not the first one + /// nor the last one Section* add_section(const SegmentCommand& segment, const Section& section); - //! Remove the section with the name provided in the first parameter. - //! - //! @param name Name of the MachO::Section to remove - //! @param clear If ``true`` clear the content of the section before removing + /// Remove the section with the name provided in the first parameter. + /// + /// @param name Name of the MachO::Section to remove + /// @param clear If ``true`` clear the content of the section before removing void remove_section(const std::string& name, bool clear = false) override; - //! Remove the section from the segment with the name - //! given in the first parameter and with the section's name provided in the - //! second parameter - //! - //! @param segname Name of the MachO::Segment - //! @param secname Name of the MachO::Section to remove - //! @param clear If ``true`` clear the content of the section before removing + /// Remove the section from the segment with the name + /// given in the first parameter and with the section's name provided in the + /// second parameter + /// + /// @param segname Name of the MachO::Segment + /// @param secname Name of the MachO::Section to remove + /// @param clear If ``true`` clear the content of the section before removing void remove_section(const std::string& segname, const std::string& secname, bool clear = false); - //! Remove the given LoadCommand + /// Remove the given LoadCommand bool remove(const LoadCommand& command); - //! Remove **all** LoadCommand with the given type (MachO::LoadCommand::TYPE) + /// Remove **all** LoadCommand with the given type (MachO::LoadCommand::TYPE) bool remove(LoadCommand::TYPE type); - //! Remove the Load Command at the provided ``index`` + /// Remove the Load Command at the provided ``index`` bool remove_command(size_t index); - //! Remove the LC_SIGNATURE command + /// Remove the LC_SIGNATURE command bool remove_signature(); - //! Extend the **size** of the given LoadCommand + /// Extend the **size** of the given LoadCommand bool extend(const LoadCommand& command, uint64_t size); - //! Extend the **content** of the given SegmentCommand + /// Extend the **content** of the given SegmentCommand bool extend_segment(const SegmentCommand& segment, size_t size); - //! Remove the ``PIE`` flag + /// Remove the ``PIE`` flag bool disable_pie(); - //! Return the binary's imagebase. ``0`` if not relevant + /// Return the binary's imagebase. ``0`` if not relevant uint64_t imagebase() const override; - //! Size of the binary in memory when mapped by the loader (``dyld``) + /// Size of the binary in memory when mapped by the loader (``dyld``) uint64_t virtual_size() const { return align(va_ranges().size(), (uint64_t)page_size()); } - //! Return the binary's loader (e.g. ``/usr/lib/dyld``) or an - //! empty string if the binary does not use a loader/linker + /// Return the binary's loader (e.g. ``/usr/lib/dyld``) or an + /// empty string if the binary does not use a loader/linker std::string loader() const; - //! Check if a section with the given name exists + /// Check if a section with the given name exists bool has_section(const std::string& name) const { return get_section(name) != nullptr; } - //! Return the section from the given name of a nullptr - //! if the section can't be found. + /// Return the section from the given name of a nullptr + /// if the section can't be found. Section* get_section(const std::string& name) { return const_cast(static_cast(this)->get_section(name)); } - //! Return the section from the given name or a nullptr - //! if the section can't be found + /// Return the section from the given name or a nullptr + /// if the section can't be found const Section* get_section(const std::string& name) const; - //! Return the section from the segment with the name - //! given in the first parameter and with the section's name provided in the - //! second parameter. If the section cannot be found, it returns a nullptr + /// Return the section from the segment with the name + /// given in the first parameter and with the section's name provided in the + /// second parameter. If the section cannot be found, it returns a nullptr Section* get_section(const std::string& segname, const std::string& secname) { return const_cast(static_cast(this)->get_section(segname, secname)); } const Section* get_section(const std::string& segname, const std::string& secname) const; - //! Check if a segment with the given name exists + /// Check if a segment with the given name exists bool has_segment(const std::string& name) const { return get_segment(name) != nullptr; } - //! Return the segment from the given name + /// Return the segment from the given name const SegmentCommand* get_segment(const std::string& name) const; - //! Return the segment from the given name + /// Return the segment from the given name SegmentCommand* get_segment(const std::string& name) { return const_cast(static_cast(this)->get_segment(name)); } - //! Remove the symbol with the given name + /// Remove the symbol with the given name bool remove_symbol(const std::string& name); - //! Remove the given symbol + /// Remove the given symbol bool remove(const Symbol& sym); - //! Check if the given symbol can be safely removed. + /// Check if the given symbol can be safely removed. bool can_remove(const Symbol& sym) const; - //! Check if the MachO::Symbol with the given name can be safely removed. + /// Check if the MachO::Symbol with the given name can be safely removed. bool can_remove_symbol(const std::string& name) const; - //! Remove the given MachO::Symbol with the given name from the export table + /// Remove the given MachO::Symbol with the given name from the export table bool unexport(const std::string& name); - //! Remove the given symbol from the export table + /// Remove the given symbol from the export table bool unexport(const Symbol& sym); - //! Return the MachO::Section that encompasses the provided offset. - //! If a section can't be found, it returns a null pointer (``nullptr``) + /// Return the MachO::Section that encompasses the provided offset. + /// If a section can't be found, it returns a null pointer (``nullptr``) Section* section_from_offset(uint64_t offset) { return const_cast(static_cast(this)->section_from_offset(offset)); } const Section* section_from_offset(uint64_t offset) const; - //! Return the MachO::Section that encompasses the provided virtual address. - //! If a section can't be found, it returns a null pointer (``nullptr``) + /// Return the MachO::Section that encompasses the provided virtual address. + /// If a section can't be found, it returns a null pointer (``nullptr``) Section* section_from_virtual_address(uint64_t virtual_address) { return const_cast(static_cast(this)->section_from_virtual_address(virtual_address)); } const Section* section_from_virtual_address(uint64_t virtual_address) const; - //! Convert a virtual address to an offset in the file + /// Convert a virtual address to an offset in the file result virtual_address_to_offset(uint64_t virtual_address) const; - //! Convert the given offset into a virtual address. - //! - //! @param[in] offset The offset to convert. - //! @param[in] slide If not 0, it will replace the default base address (if any) + /// Convert the given offset into a virtual address. + /// + /// @param[in] offset The offset to convert. + /// @param[in] slide If not 0, it will replace the default base address (if any) result offset_to_virtual_address(uint64_t offset, uint64_t slide = 0) const override; - //! Return the binary's SegmentCommand that encompasses the provided offset - //! - //! If a SegmentCommand can't be found it returns a null pointer (``nullptr``). + /// Return the binary's SegmentCommand that encompasses the provided offset + /// + /// If a SegmentCommand can't be found it returns a null pointer (``nullptr``). SegmentCommand* segment_from_offset(uint64_t offset) { return const_cast(static_cast(this)->segment_from_offset(offset)); } const SegmentCommand* segment_from_offset(uint64_t offset) const; - //! Return the index of the given SegmentCommand + /// Return the index of the given SegmentCommand size_t segment_index(const SegmentCommand& segment) const; - //! Return binary's *fat offset*. ``0`` if not relevant. + /// Return binary's *fat offset*. ``0`` if not relevant. uint64_t fat_offset() const { return fat_offset_; } - //! Return the binary's SegmentCommand which encompasses the given virtual address - //! or a nullptr if not found. + /// Return the binary's SegmentCommand which encompasses the given virtual address + /// or a nullptr if not found. SegmentCommand* segment_from_virtual_address(uint64_t virtual_address) { return const_cast(static_cast(this)->segment_from_virtual_address(virtual_address)); } const SegmentCommand* segment_from_virtual_address(uint64_t virtual_address) const; - //! Return the range of virtual addresses + /// Return the range of virtual addresses range_t va_ranges() const; - //! Return the range of offsets + /// Return the range of offsets range_t off_ranges() const; - //! Check if the given address is encompassed in the - //! binary's virtual addresses range + /// Check if the given address is encompassed in the + /// binary's virtual addresses range bool is_valid_addr(uint64_t address) const { const range_t& r = va_ranges(); return r.start <= address && address < r.end; } - //! Method so that the ``visitor`` can visit us + /// Method so that the ``visitor`` can visit us void accept(LIEF::Visitor& visitor) const override; std::ostream& print(std::ostream& os) const override; - //! Patch the content at virtual address @p address with @p patch_value - //! - //! @param[in] address Address to patch - //! @param[in] patch_value Patch to apply - //! @param[in] addr_type Specify if the address should be used as - //! an absolute virtual address or an RVA + /// Patch the content at virtual address @p address with @p patch_value + /// + /// @param[in] address Address to patch + /// @param[in] patch_value Patch to apply + /// @param[in] addr_type Specify if the address should be used as + /// an absolute virtual address or an RVA void patch_address(uint64_t address, const std::vector& patch_value, LIEF::Binary::VA_TYPES addr_type = LIEF::Binary::VA_TYPES::AUTO) override; - //! Patch the address with the given value - //! - //! @param[in] address Address to patch - //! @param[in] patch_value Patch to apply - //! @param[in] size Size of the value in **bytes** (1, 2, ... 8) - //! @param[in] addr_type Specify if the address should be used as - //! an absolute virtual address or an RVA + /// Patch the address with the given value + /// + /// @param[in] address Address to patch + /// @param[in] patch_value Patch to apply + /// @param[in] size Size of the value in **bytes** (1, 2, ... 8) + /// @param[in] addr_type Specify if the address should be used as + /// an absolute virtual address or an RVA void patch_address(uint64_t address, uint64_t patch_value, size_t size = sizeof(uint64_t), LIEF::Binary::VA_TYPES addr_type = LIEF::Binary::VA_TYPES::AUTO) override; - //! Return the content located at virtual address + /// Return the content located at virtual address span get_content_from_virtual_address( uint64_t virtual_address, uint64_t size, Binary::VA_TYPES addr_type = Binary::VA_TYPES::AUTO) const override; - //! The binary entrypoint + /// The binary entrypoint uint64_t entrypoint() const override; - //! Check if the binary is position independent + /// Check if the binary is position independent bool is_pie() const override { return header().has(Header::FLAGS::PIE); } - //! Check if the binary uses ``NX`` protection + /// Check if the binary uses ``NX`` protection bool has_nx() const override { return !has_nx_stack(); } @@ -581,208 +581,208 @@ class LIEF_API Binary : public LIEF::Binary { return !header().has(Header::FLAGS::NO_HEAP_EXECUTION); } - //! ``true`` if the binary has an entrypoint. - //! - //! Basically for libraries it will return ``false`` + /// ``true`` if the binary has an entrypoint. + /// + /// Basically for libraries it will return ``false`` bool has_entrypoint() const { return has_main_command() || has_thread_command(); } - //! ``true`` if the binary has a MachO::UUIDCommand command. + /// ``true`` if the binary has a MachO::UUIDCommand command. bool has_uuid() const { return uuid() != nullptr; } - //! Return the MachO::UUIDCommand if present, a nullptr otherwise. + /// Return the MachO::UUIDCommand if present, a nullptr otherwise. UUIDCommand* uuid(); const UUIDCommand* uuid() const; - //! ``true`` if the binary has a MachO::MainCommand command. + /// ``true`` if the binary has a MachO::MainCommand command. bool has_main_command() const { return main_command() != nullptr; } - //! Return the MachO::MainCommand if present, a nullptr otherwise. + /// Return the MachO::MainCommand if present, a nullptr otherwise. MainCommand* main_command(); const MainCommand* main_command() const; - //! ``true`` if the binary has a MachO::DylinkerCommand. + /// ``true`` if the binary has a MachO::DylinkerCommand. bool has_dylinker() const { return dylinker() != nullptr; } - //! Return the MachO::DylinkerCommand if present, a nullptr otherwise. + /// Return the MachO::DylinkerCommand if present, a nullptr otherwise. DylinkerCommand* dylinker(); const DylinkerCommand* dylinker() const; - //! ``true`` if the binary has a MachO::DyldInfo command. + /// ``true`` if the binary has a MachO::DyldInfo command. bool has_dyld_info() const { return dyld_info() != nullptr; } - //! Return the MachO::Dyld command if present, a nullptr otherwise. + /// Return the MachO::Dyld command if present, a nullptr otherwise. DyldInfo* dyld_info(); const DyldInfo* dyld_info() const; - //! ``true`` if the binary has a MachO::FunctionStarts command. + /// ``true`` if the binary has a MachO::FunctionStarts command. bool has_function_starts() const { return function_starts() != nullptr; } - //! Return the MachO::FunctionStarts command if present, a nullptr otherwise. + /// Return the MachO::FunctionStarts command if present, a nullptr otherwise. FunctionStarts* function_starts(); const FunctionStarts* function_starts() const; - //! ``true`` if the binary has a MachO::SourceVersion command. + /// ``true`` if the binary has a MachO::SourceVersion command. bool has_source_version() const { return source_version() != nullptr; } - //! Return the MachO::SourceVersion command if present, a nullptr otherwise. + /// Return the MachO::SourceVersion command if present, a nullptr otherwise. SourceVersion* source_version(); const SourceVersion* source_version() const; - //! ``true`` if the binary has a MachO::VersionMin command. + /// ``true`` if the binary has a MachO::VersionMin command. bool has_version_min() const { return version_min() != nullptr; } - //! Return the MachO::VersionMin command if present, a nullptr otherwise. + /// Return the MachO::VersionMin command if present, a nullptr otherwise. VersionMin* version_min(); const VersionMin* version_min() const; - //! ``true`` if the binary has a MachO::ThreadCommand command. + /// ``true`` if the binary has a MachO::ThreadCommand command. bool has_thread_command() const { return thread_command() != nullptr; } - //! Return the MachO::ThreadCommand command if present, a nullptr otherwise. + /// Return the MachO::ThreadCommand command if present, a nullptr otherwise. ThreadCommand* thread_command(); const ThreadCommand* thread_command() const; - //! ``true`` if the binary has a MachO::Routine command. + /// ``true`` if the binary has a MachO::Routine command. bool has_routine_command() const { return routine_command() != nullptr; } - //! Return the MachO::Routine command if present, a nullptr otherwise. + /// Return the MachO::Routine command if present, a nullptr otherwise. Routine* routine_command(); const Routine* routine_command() const; - //! ``true`` if the binary has a MachO::RPathCommand command. + /// ``true`` if the binary has a MachO::RPathCommand command. bool has_rpath() const { return rpath() != nullptr; } - //! Return the MachO::RPathCommand command if present, a nullptr otherwise. + /// Return the MachO::RPathCommand command if present, a nullptr otherwise. RPathCommand* rpath(); const RPathCommand* rpath() const; - //! Iterator over **all** the MachO::RPathCommand commands. + /// Iterator over **all** the MachO::RPathCommand commands. it_rpaths rpaths(); it_const_rpaths rpaths() const; - //! ``true`` if the binary has a MachO::SymbolCommand command. + /// ``true`` if the binary has a MachO::SymbolCommand command. bool has_symbol_command() const { return symbol_command() != nullptr; } - //! Return the MachO::SymbolCommand if present, a nullptr otherwise. + /// Return the MachO::SymbolCommand if present, a nullptr otherwise. SymbolCommand* symbol_command(); const SymbolCommand* symbol_command() const; - //! ``true`` if the binary has a MachO::DynamicSymbolCommand command. + /// ``true`` if the binary has a MachO::DynamicSymbolCommand command. bool has_dynamic_symbol_command() const { return dynamic_symbol_command() != nullptr; } - //! Return the MachO::SymbolCommand if present, a nullptr otherwise. + /// Return the MachO::SymbolCommand if present, a nullptr otherwise. DynamicSymbolCommand* dynamic_symbol_command(); const DynamicSymbolCommand* dynamic_symbol_command() const; - //! ``true`` if the binary is signed with `LC_CODE_SIGNATURE` command + /// ``true`` if the binary is signed with `LC_CODE_SIGNATURE` command bool has_code_signature() const { return code_signature() != nullptr; } - //! Return the MachO::CodeSignature if present, a nullptr otherwise. + /// Return the MachO::CodeSignature if present, a nullptr otherwise. CodeSignature* code_signature() { return const_cast(static_cast(this)->code_signature()); } const CodeSignature* code_signature() const; - //! ``true`` if the binary is signed with the command `DYLIB_CODE_SIGN_DRS` + /// ``true`` if the binary is signed with the command `DYLIB_CODE_SIGN_DRS` bool has_code_signature_dir() const { return code_signature_dir() != nullptr; } - //! Return the MachO::CodeSignatureDir if present, a nullptr otherwise. + /// Return the MachO::CodeSignatureDir if present, a nullptr otherwise. CodeSignatureDir* code_signature_dir() { return const_cast(static_cast(this)->code_signature_dir()); } const CodeSignatureDir* code_signature_dir() const; - //! ``true`` if the binary has a MachO::DataInCode command. + /// ``true`` if the binary has a MachO::DataInCode command. bool has_data_in_code() const { return data_in_code() != nullptr; } - //! Return the MachO::DataInCode if present, a nullptr otherwise. + /// Return the MachO::DataInCode if present, a nullptr otherwise. DataInCode* data_in_code(); const DataInCode* data_in_code() const; - //! ``true`` if the binary has segment split info. + /// ``true`` if the binary has segment split info. bool has_segment_split_info() const { return segment_split_info() != nullptr; } - //! Return the MachO::SegmentSplitInfo if present, a nullptr otherwise. + /// Return the MachO::SegmentSplitInfo if present, a nullptr otherwise. SegmentSplitInfo* segment_split_info(); const SegmentSplitInfo* segment_split_info() const; - //! ``true`` if the binary has a sub framework command. + /// ``true`` if the binary has a sub framework command. bool has_sub_framework() const { return sub_framework() != nullptr; } - //! ``true`` if the binary has Encryption Info. + /// ``true`` if the binary has Encryption Info. bool has_encryption_info() const { return encryption_info() != nullptr; } - //! Return the MachO::DyldEnvironment if present, a nullptr otherwise. + /// Return the MachO::DyldEnvironment if present, a nullptr otherwise. EncryptionInfo* encryption_info(); const EncryptionInfo* encryption_info() const; - //! Return the MachO::SubFramework if present, a nullptr otherwise. + /// Return the MachO::SubFramework if present, a nullptr otherwise. SubFramework* sub_framework(); const SubFramework* sub_framework() const; - //! Iterator over **all** the MachO::SubClient commands. + /// Iterator over **all** the MachO::SubClient commands. it_sub_clients subclients(); it_const_sub_clients subclients() const; bool has_subclients() const; - //! ``true`` if the binary has Dyld envrionment variables. + /// ``true`` if the binary has Dyld envrionment variables. bool has_dyld_environment() const { return dyld_environment() != nullptr; } - //! Return the MachO::DyldEnvironment if present, a nullptr otherwise + /// Return the MachO::DyldEnvironment if present, a nullptr otherwise DyldEnvironment* dyld_environment(); const DyldEnvironment* dyld_environment() const; - //! ``true`` if the binary has the BuildVersion command. + /// ``true`` if the binary has the BuildVersion command. bool has_build_version() const { return build_version() != nullptr; } - //! Return the MachO::BuildVersion if present, a nullptr otherwise. + /// Return the MachO::BuildVersion if present, a nullptr otherwise. BuildVersion* build_version(); const BuildVersion* build_version() const; - //! Return the platform for which this Mach-O has been compiled for + /// Return the platform for which this Mach-O has been compiled for BuildVersion::PLATFORMS platform() const { if (const BuildVersion* version = build_version()) { return version->platform(); @@ -790,74 +790,74 @@ class LIEF_API Binary : public LIEF::Binary { return BuildVersion::PLATFORMS::UNKNOWN; } - //! True if this binary targets iOS + /// True if this binary targets iOS bool is_ios() const { return platform() == BuildVersion::PLATFORMS::IOS || has(LoadCommand::TYPE::VERSION_MIN_IPHONEOS); } - //! True if this binary targets macOS + /// True if this binary targets macOS bool is_macos() const { return platform() == BuildVersion::PLATFORMS::MACOS || has(LoadCommand::TYPE::VERSION_MIN_MACOSX); } - //! ``true`` if the binary has the command LC_DYLD_CHAINED_FIXUPS. + /// ``true`` if the binary has the command LC_DYLD_CHAINED_FIXUPS. bool has_dyld_chained_fixups() const { return dyld_chained_fixups() != nullptr; } - //! Return the MachO::DyldChainedFixups if present, a nullptr otherwise. + /// Return the MachO::DyldChainedFixups if present, a nullptr otherwise. DyldChainedFixups* dyld_chained_fixups(); const DyldChainedFixups* dyld_chained_fixups() const; - //! ``true`` if the binary has the command LC_DYLD_CHAINED_FIXUPS. + /// ``true`` if the binary has the command LC_DYLD_CHAINED_FIXUPS. bool has_dyld_exports_trie() const { return dyld_exports_trie() != nullptr; } - //! Return the MachO::DyldChainedFixups if present, a nullptr otherwise. + /// Return the MachO::DyldChainedFixups if present, a nullptr otherwise. DyldExportsTrie* dyld_exports_trie(); const DyldExportsTrie* dyld_exports_trie() const; - //! ``true`` if the binary has the command LC_TWO_LEVEL_HINTS. + /// ``true`` if the binary has the command LC_TWO_LEVEL_HINTS. bool has_two_level_hints() const { return two_level_hints() != nullptr; } - //! Return the MachO::DyldChainedFixups if present, a nullptr otherwise. + /// Return the MachO::DyldChainedFixups if present, a nullptr otherwise. TwoLevelHints* two_level_hints() { return const_cast(static_cast(this)->two_level_hints()); } const TwoLevelHints* two_level_hints() const; - //! ``true`` if the binary has the command LC_LINKER_OPTIMIZATION_HINT. + /// ``true`` if the binary has the command LC_LINKER_OPTIMIZATION_HINT. bool has_linker_opt_hint() const { return linker_opt_hint() != nullptr; } - //! Return the MachO::LinkerOptHint if present, a nullptr otherwise. + /// Return the MachO::LinkerOptHint if present, a nullptr otherwise. LinkerOptHint* linker_opt_hint() { return const_cast(static_cast(this)->linker_opt_hint()); } const LinkerOptHint* linker_opt_hint() const; - //! Add a symbol in the export trie of the current binary + /// Add a symbol in the export trie of the current binary ExportInfo* add_exported_function(uint64_t address, const std::string& name); - //! Add a symbol in LC_SYMTAB command of the current binary + /// Add a symbol in LC_SYMTAB command of the current binary Symbol* add_local_symbol(uint64_t address, const std::string& name); - //! Return Objective-C metadata if present + /// Return Objective-C metadata if present std::unique_ptr objc_metadata() const; - //! Return an iterator over the symbol stubs. - //! - //! These stubs are involved when calling an **imported** function and are - //! similar to the ELF's plt/got mechanism. - //! - //! There are located in sections like: `__stubs,__auth_stubs,__symbol_stub,__picsymbolstub4` + /// Return an iterator over the symbol stubs. + /// + /// These stubs are involved when calling an **imported** function and are + /// similar to the ELF's plt/got mechanism. + /// + /// There are located in sections like: `__stubs,__auth_stubs,__symbol_stub,__picsymbolstub4` stub_iterator symbol_stubs() const; template @@ -882,53 +882,53 @@ class LIEF_API Binary : public LIEF::Binary { return get(type); } - //! Return the list of the MachO's constructors + /// Return the list of the MachO's constructors LIEF::Binary::functions_t ctor_functions() const override; - //! Return all the functions found in this MachO + /// Return all the functions found in this MachO LIEF::Binary::functions_t functions() const; - //! Return the functions found in the ``__unwind_info`` section + /// Return the functions found in the ``__unwind_info`` section LIEF::Binary::functions_t unwind_functions() const; - //! ``true`` if the binary has a LoadCommand::TYPE::FILESET_ENTRY command + /// ``true`` if the binary has a LoadCommand::TYPE::FILESET_ENTRY command bool has_filesets() const { return filesets_.empty(); } - //! Name associated with the LC_FILESET_ENTRY binary + /// Name associated with the LC_FILESET_ENTRY binary const std::string& fileset_name() const { return fileset_name_; } - //! Add a symbol to this binary + /// Add a symbol to this binary Symbol& add(const Symbol& symbol); ~Binary() override; - //! Shift the content located right after the Load commands table. - //! This operation can be used to add a new command + /// Shift the content located right after the Load commands table. + /// This operation can be used to add a new command ok_error_t shift(size_t value); - //! Shift the position on the __LINKEDIT data by `width` + /// Shift the position on the __LINKEDIT data by `width` ok_error_t shift_linkedit(size_t width); - //! If this Mach-O binary has been parsed from memory, - //! it returns the in-memory base address of this binary. - //! - //! Otherwise, it returns 0 + /// If this Mach-O binary has been parsed from memory, + /// it returns the in-memory base address of this binary. + /// + /// Otherwise, it returns 0 uint64_t memory_base_address() const { return in_memory_base_addr_; } - //! Check if the binary is supporting ARM64 pointer authentication (arm64e) + /// Check if the binary is supporting ARM64 pointer authentication (arm64e) bool support_arm64_ptr_auth() const { return header().cpu_type() == Header::CPU_TYPE::ARM64 && (header().cpu_subtype() & ~Header::CPU_SUBTYPE_MASK) == Header::CPU_SUBTYPE_ARM64_ARM64E; } - //! Return an iterator over the binding info which can come from either - //! DyldInfo or DyldChainedFixups commands. + /// Return an iterator over the binding info which can come from either + /// DyldInfo or DyldChainedFixups commands. it_bindings bindings() const; uint32_t page_size() const; @@ -945,13 +945,13 @@ class LIEF_API Binary : public LIEF::Binary { void refresh_seg_offset(); private: - //! Default constructor + /// Default constructor Binary(); void shift_command(size_t width, uint64_t from_offset); - //! Insert a Segment command in the cache field (segments_) - //! and keep a consistent state of the indexes. + /// Insert a Segment command in the cache field (segments_) + /// and keep a consistent state of the indexes. size_t add_cached_segment(SegmentCommand& segment); template diff --git a/include/LIEF/MachO/BinaryParser.hpp b/include/LIEF/MachO/BinaryParser.hpp index 6f2c1b3b72..59870f54f7 100644 --- a/include/LIEF/MachO/BinaryParser.hpp +++ b/include/LIEF/MachO/BinaryParser.hpp @@ -66,19 +66,19 @@ union dyld_chained_ptr_generic64; union dyld_chained_ptr_generic32; } -//! Class used to parse a **single** binary (i.e. non-FAT) -//! -//! @warning This class should not be directly used. -//! -//! @see MachO::Parser +/// Class used to parse a **single** binary (i.e. non-FAT) +/// +/// @warning This class should not be directly used. +/// +/// @see MachO::Parser class LIEF_API BinaryParser : public LIEF::Parser { friend class MachO::Parser; - //! Maximum number of relocations + /// Maximum number of relocations constexpr static size_t MAX_RELOCATIONS = (std::numeric_limits::max)(); - //! Maximum number of MachO LoadCommand + /// Maximum number of MachO LoadCommand constexpr static size_t MAX_COMMANDS = (std::numeric_limits::max)(); public: diff --git a/include/LIEF/MachO/BindingInfo.hpp b/include/LIEF/MachO/BindingInfo.hpp index 0643019942..1834aead00 100644 --- a/include/LIEF/MachO/BindingInfo.hpp +++ b/include/LIEF/MachO/BindingInfo.hpp @@ -29,13 +29,13 @@ class Symbol; class BinaryParser; class DyldChainedFixupsCreator; -//! Class that provides an interface over a *binding* operation. -//! -//! This class does not represent a structure that exists in the Mach-O format -//! specifications but it provides a *view* of a binding operation that is performed -//! by the Dyld binding bytecode (`LC_DYLD_INFO`) or the Dyld chained fixups (`DYLD_CHAINED_FIXUPS`) -//! -//! See: LIEF::MachO::ChainedBindingInfo, LIEF::MachO::DyldBindingInfo +/// Class that provides an interface over a *binding* operation. +/// +/// This class does not represent a structure that exists in the Mach-O format +/// specifications but it provides a *view* of a binding operation that is performed +/// by the Dyld binding bytecode (`LC_DYLD_INFO`) or the Dyld chained fixups (`DYLD_CHAINED_FIXUPS`) +/// +/// See: LIEF::MachO::ChainedBindingInfo, LIEF::MachO::DyldBindingInfo class LIEF_API BindingInfo : public Object { friend class BinaryParser; @@ -54,13 +54,13 @@ class LIEF_API BindingInfo : public Object { BindingInfo(const BindingInfo& other); void swap(BindingInfo& other) noexcept; - //! Check if a MachO::SegmentCommand is associated with this binding + /// Check if a MachO::SegmentCommand is associated with this binding bool has_segment() const { return segment_ != nullptr; } - //! The MachO::SegmentCommand associated with the BindingInfo or - //! a nullptr of it is not bind to a SegmentCommand + /// The MachO::SegmentCommand associated with the BindingInfo or + /// a nullptr of it is not bind to a SegmentCommand const SegmentCommand* segment() const { return segment_; } @@ -68,13 +68,13 @@ class LIEF_API BindingInfo : public Object { return segment_; } - //! Check if a MachO::DylibCommand is tied with the BindingInfo + /// Check if a MachO::DylibCommand is tied with the BindingInfo bool has_library() const { return library_ != nullptr; } - //! MachO::DylibCommand associated with the BindingInfo or a nullptr - //! if not present + /// MachO::DylibCommand associated with the BindingInfo or a nullptr + /// if not present const DylibCommand* library() const { return library_; } @@ -82,13 +82,13 @@ class LIEF_API BindingInfo : public Object { return library_; } - //! Check if a MachO::Symbol is associated with the BindingInfo + /// Check if a MachO::Symbol is associated with the BindingInfo bool has_symbol() const { return symbol_ != nullptr; } - //! MachO::Symbol associated with the BindingInfo or - //! a nullptr if not present + /// MachO::Symbol associated with the BindingInfo or + /// a nullptr if not present const Symbol* symbol() const { return symbol_; } @@ -96,7 +96,7 @@ class LIEF_API BindingInfo : public Object { return symbol_; } - //! Address of the binding + /// Address of the binding virtual uint64_t address() const { return address_; } @@ -113,7 +113,7 @@ class LIEF_API BindingInfo : public Object { library_ordinal_ = ordinal; } - //! Value added to the segment's virtual address when bound + /// Value added to the segment's virtual address when bound int64_t addend() const { return addend_; } @@ -130,8 +130,8 @@ class LIEF_API BindingInfo : public Object { is_weak_import_ = val; } - //! The type of the binding. This type provides the origin - //! of the binding (LC_DYLD_INFO or LC_DYLD_CHAINED_FIXUPS) + /// The type of the binding. This type provides the origin + /// of the binding (LC_DYLD_INFO or LC_DYLD_CHAINED_FIXUPS) virtual TYPES type() const = 0; ~BindingInfo() override = default; diff --git a/include/LIEF/MachO/BuildToolVersion.hpp b/include/LIEF/MachO/BuildToolVersion.hpp index 8467748030..7824c2f901 100644 --- a/include/LIEF/MachO/BuildToolVersion.hpp +++ b/include/LIEF/MachO/BuildToolVersion.hpp @@ -29,11 +29,11 @@ namespace details { struct build_tool_version; } -//! Class that represents a tool's version that was -//! involved in the build of the binary +/// Class that represents a tool's version that was +/// involved in the build of the binary class LIEF_API BuildToolVersion : public Object { public: - //! A version is an array of **3** integers + /// A version is an array of **3** integers using version_t = std::array; public: @@ -49,12 +49,12 @@ class LIEF_API BuildToolVersion : public Object { BuildToolVersion() = default; BuildToolVersion(const details::build_tool_version& tool); - //! The tools used + /// The tools used TOOLS tool() const { return tool_; } - //! Version associated with the tool + /// Version associated with the tool version_t version() const { return version_; } diff --git a/include/LIEF/MachO/BuildVersion.hpp b/include/LIEF/MachO/BuildVersion.hpp index cc57833ac7..80890187bf 100644 --- a/include/LIEF/MachO/BuildVersion.hpp +++ b/include/LIEF/MachO/BuildVersion.hpp @@ -35,7 +35,7 @@ class LIEF_API BuildVersion : public LoadCommand { friend class BinaryParser; public: - //! Version is an array of **3** integers + /// Version is an array of **3** integers using version_t = std::array; using tools_list_t = std::vector; diff --git a/include/LIEF/MachO/Builder.hpp b/include/LIEF/MachO/Builder.hpp index 49a19e3b23..124ecc2c83 100644 --- a/include/LIEF/MachO/Builder.hpp +++ b/include/LIEF/MachO/Builder.hpp @@ -53,10 +53,10 @@ class TwoLevelHints; class VersionMin; class RPathCommand; -//! Class used to rebuild a Mach-O file +/// Class used to rebuild a Mach-O file class LIEF_API Builder { public: - //! Options to tweak the building process + /// Options to tweak the building process struct config_t { bool linkedit = true; }; diff --git a/include/LIEF/MachO/ChainedBindingInfo.hpp b/include/LIEF/MachO/ChainedBindingInfo.hpp index 8aea25e4b2..a795ef659a 100644 --- a/include/LIEF/MachO/ChainedBindingInfo.hpp +++ b/include/LIEF/MachO/ChainedBindingInfo.hpp @@ -38,13 +38,13 @@ struct dyld_chained_ptr_64_bind; struct dyld_chained_ptr_32_bind; } -//! This class represents a symbol binding operation associated with -//! the LC_DYLD_CHAINED_FIXUPS command. -//! -//! This class does not represent a structure that exists in the Mach-O format -//! specifications but it provides a *view* on an entry. -//! -//! @see: BindingInfo +/// This class represents a symbol binding operation associated with +/// the LC_DYLD_CHAINED_FIXUPS command. +/// +/// This class does not represent a structure that exists in the Mach-O format +/// specifications but it provides a *view* on an entry. +/// +/// @see: BindingInfo class LIEF_API ChainedBindingInfo : public BindingInfo { friend class BinaryParser; @@ -62,17 +62,17 @@ class LIEF_API ChainedBindingInfo : public BindingInfo { void swap(ChainedBindingInfo& other) noexcept; - //! Format of the imports + /// Format of the imports DYLD_CHAINED_FORMAT format() const { return format_; } - //! Format of the pointer + /// Format of the pointer DYLD_CHAINED_PTR_FORMAT ptr_format() const { return ptr_format_; } - //! Original offset in the chain of this binding + /// Original offset in the chain of this binding uint32_t offset() const { return offset_; } diff --git a/include/LIEF/MachO/CodeSignature.hpp b/include/LIEF/MachO/CodeSignature.hpp index d9bb294e91..ae931afcd5 100644 --- a/include/LIEF/MachO/CodeSignature.hpp +++ b/include/LIEF/MachO/CodeSignature.hpp @@ -50,12 +50,12 @@ class LIEF_API CodeSignature : public LoadCommand { return std::unique_ptr(new CodeSignature(*this)); } - //! Offset in the binary where the signature starts + /// Offset in the binary where the signature starts uint32_t data_offset() const { return data_offset_; } - //! Size of the raw signature + /// Size of the raw signature uint32_t data_size() const { return data_size_; } diff --git a/include/LIEF/MachO/CodeSignatureDir.hpp b/include/LIEF/MachO/CodeSignatureDir.hpp index c2b1ac71fb..a94a12c099 100644 --- a/include/LIEF/MachO/CodeSignatureDir.hpp +++ b/include/LIEF/MachO/CodeSignatureDir.hpp @@ -49,12 +49,12 @@ class LIEF_API CodeSignatureDir : public LoadCommand { return std::unique_ptr(new CodeSignatureDir(*this)); } - //! Offset in the binary where the signature starts + /// Offset in the binary where the signature starts uint32_t data_offset() const { return data_offset_; } - //! Size of the raw signature + /// Size of the raw signature uint32_t data_size() const { return data_size_; } diff --git a/include/LIEF/MachO/DataCodeEntry.hpp b/include/LIEF/MachO/DataCodeEntry.hpp index fbf2621be9..15f4d208ca 100644 --- a/include/LIEF/MachO/DataCodeEntry.hpp +++ b/include/LIEF/MachO/DataCodeEntry.hpp @@ -29,7 +29,7 @@ namespace details { struct data_in_code_entry; } -//! Interface over an entry in the DataInCode command +/// Interface over an entry in the DataInCode command class LIEF_API DataCodeEntry : public LIEF::Object { public: enum class TYPES { @@ -53,12 +53,12 @@ class LIEF_API DataCodeEntry : public LIEF::Object { DataCodeEntry& operator=(const DataCodeEntry&) = default; DataCodeEntry(const DataCodeEntry&) = default; - //! Offset of the data + /// Offset of the data uint32_t offset() const { return offset_; } - //! Length of the data + /// Length of the data uint16_t length() const { return length_; } diff --git a/include/LIEF/MachO/DataInCode.hpp b/include/LIEF/MachO/DataInCode.hpp index ed25377bfd..23b978529c 100644 --- a/include/LIEF/MachO/DataInCode.hpp +++ b/include/LIEF/MachO/DataInCode.hpp @@ -34,11 +34,11 @@ namespace details { struct linkedit_data_command; } -//! Interface of the LC_DATA_IN_CODE command -//! This command is used to list slices of code sections that contain data. The *slices* -//! information are stored as an array of DataCodeEntry -//! -//! @see DataCodeEntry +/// Interface of the LC_DATA_IN_CODE command +/// This command is used to list slices of code sections that contain data. The *slices* +/// information are stored as an array of DataCodeEntry +/// +/// @see DataCodeEntry class LIEF_API DataInCode : public LoadCommand { friend class BinaryParser; friend class LinkEdit; @@ -58,12 +58,12 @@ class LIEF_API DataInCode : public LoadCommand { return std::unique_ptr(new DataInCode(*this)); } - //! Start of the array of the DataCodeEntry entries + /// Start of the array of the DataCodeEntry entries uint32_t data_offset() const { return data_offset_; } - //! Size of the raw array (``size = sizeof(DataCodeEntry) * nb_elements``) + /// Size of the raw array (``size = sizeof(DataCodeEntry) * nb_elements``) uint32_t data_size() const { return data_size_; } @@ -75,13 +75,13 @@ class LIEF_API DataInCode : public LoadCommand { data_size_ = size; } - //! Add a new entry + /// Add a new entry DataInCode& add(DataCodeEntry entry) { entries_.push_back(std::move(entry)); return *this; } - //! Iterator over the DataCodeEntry + /// Iterator over the DataCodeEntry it_const_entries entries() const { return entries_; } diff --git a/include/LIEF/MachO/DyldBindingInfo.hpp b/include/LIEF/MachO/DyldBindingInfo.hpp index 978f074f3f..cb7308065f 100644 --- a/include/LIEF/MachO/DyldBindingInfo.hpp +++ b/include/LIEF/MachO/DyldBindingInfo.hpp @@ -24,13 +24,13 @@ namespace LIEF { namespace MachO { -//! This class represents a symbol binding operation associated with -//! the LC_DYLD_INFO bytecode. -//! -//! It does not represent a structure that exists in the Mach-O format -//! specifications but it provides a *view* on an entry of the Dyld binding opcodes. -//! -//! @see: BindingInfo +/// This class represents a symbol binding operation associated with +/// the LC_DYLD_INFO bytecode. +/// +/// It does not represent a structure that exists in the Mach-O format +/// specifications but it provides a *view* on an entry of the Dyld binding opcodes. +/// +/// @see: BindingInfo class LIEF_API DyldBindingInfo : public BindingInfo { friend class BinaryParser; @@ -62,7 +62,7 @@ class LIEF_API DyldBindingInfo : public BindingInfo { void swap(DyldBindingInfo& other) noexcept; - //! Class of the binding (weak, lazy, ...) + /// Class of the binding (weak, lazy, ...) CLASS binding_class() const { return class_; } @@ -70,7 +70,7 @@ class LIEF_API DyldBindingInfo : public BindingInfo { class_ = bind_class; } - //! Type of the binding. Most of the times it's TYPE::POINTER + /// Type of the binding. Most of the times it's TYPE::POINTER TYPE binding_type() const { return binding_type_; } @@ -87,7 +87,7 @@ class LIEF_API DyldBindingInfo : public BindingInfo { this->is_non_weak_definition_ = val; } - //! Original relative offset of the binding opcodes + /// Original relative offset of the binding opcodes uint64_t original_offset() const { return offset_; } diff --git a/include/LIEF/MachO/DyldChainedFixups.hpp b/include/LIEF/MachO/DyldChainedFixups.hpp index cad1e6bd2d..f07ba5d1bc 100644 --- a/include/LIEF/MachO/DyldChainedFixups.hpp +++ b/include/LIEF/MachO/DyldChainedFixups.hpp @@ -41,11 +41,11 @@ struct dyld_chained_fixups_header; struct dyld_chained_starts_in_segment; } -//! Class that represents the LC_DYLD_CHAINED_FIXUPS command -//! -//! This command aims at providing rebase and binding information like -//! the DyldInfo's bytecode. Compared to the DyldInfo bytecode, these chained -//! fixups are taking less space. +/// Class that represents the LC_DYLD_CHAINED_FIXUPS command +/// +/// This command aims at providing rebase and binding information like +/// the DyldInfo's bytecode. Compared to the DyldInfo bytecode, these chained +/// fixups are taking less space. class LIEF_API DyldChainedFixups : public LoadCommand { friend class BinaryParser; friend class Builder; @@ -55,10 +55,10 @@ class LIEF_API DyldChainedFixups : public LoadCommand { friend class DyldChainedFixupsCreator; public: - //! Structure that mirrors the raw dyld_chained_starts_in_segment - //! which aims at providing information about the chained rebase/bind fixups - //! - //! The relocations provided by this structure can be accessed through SegmentCommand::relocations + /// Structure that mirrors the raw dyld_chained_starts_in_segment + /// which aims at providing information about the chained rebase/bind fixups + /// + /// The relocations provided by this structure can be accessed through SegmentCommand::relocations struct chained_starts_in_segment { uint32_t offset = 0; ///< Original offset of the structure, relative to DyldChainedFixups::starts_offset uint32_t size = 0; ///< sizeof(size) + sizeof(page_size) + ... + sizeof(pointer_format) @@ -67,7 +67,7 @@ class LIEF_API DyldChainedFixups : public LoadCommand { uint32_t max_valid_pointer = 0; ///< for 32-bit OS, any value beyond this is not a pointer DYLD_CHAINED_PTR_FORMAT pointer_format = DYLD_CHAINED_PTR_FORMAT::NONE; ///< How pointers are encoded - //! How many pages are in the page_start array + /// How many pages are in the page_start array size_t page_count() const { return page_start.size(); } @@ -90,22 +90,22 @@ class LIEF_API DyldChainedFixups : public LoadCommand { SegmentCommand& segment); }; - //! Internal container for storing chained_starts_in_segment + /// Internal container for storing chained_starts_in_segment using chained_starts_in_segments_t = std::vector; - //! Iterator that outputs chained_starts_in_segment& + /// Iterator that outputs chained_starts_in_segment& using it_chained_starts_in_segments_t = ref_iterator; - //! Iterator that outputs const chained_starts_in_segment& + /// Iterator that outputs const chained_starts_in_segment& using it_const_chained_starts_in_segments_t = const_ref_iterator; - //! Internal container for storing DyldBindingInfo + /// Internal container for storing DyldBindingInfo using binding_info_t = std::vector>; - //! Iterator which outputs DyldBindingInfo& + /// Iterator which outputs DyldBindingInfo& using it_binding_info = ref_iterator; - //! Iterator which outputs const DyldBindingInfo& + /// Iterator which outputs const DyldBindingInfo& using it_const_binding_info = const_ref_iterator; @@ -117,13 +117,13 @@ class LIEF_API DyldChainedFixups : public LoadCommand { ~DyldChainedFixups() override; - //! Offset of the LC_DYLD_CHAINED_FIXUPS chained payload. - //! This offset should point in the __LINKEDIT segment + /// Offset of the LC_DYLD_CHAINED_FIXUPS chained payload. + /// This offset should point in the __LINKEDIT segment uint32_t data_offset() const { return data_offset_; } - //! Size of the LC_DYLD_CHAINED_FIXUPS payload. + /// Size of the LC_DYLD_CHAINED_FIXUPS payload. uint32_t data_size() const { return data_size_; } @@ -135,22 +135,22 @@ class LIEF_API DyldChainedFixups : public LoadCommand { data_size_ = size; } - //! Return the raw content of the command + /// Return the raw content of the command span payload() const { return content_; } - //! Iterator over the bindings (ChainedBindingInfo) associated with this command + /// Iterator over the bindings (ChainedBindingInfo) associated with this command it_binding_info bindings() { return all_bindings_; } - //! Iterator over the bindings (ChainedBindingInfo) associated with this command + /// Iterator over the bindings (ChainedBindingInfo) associated with this command it_const_binding_info bindings() const { return all_bindings_; } - //! Iterator over the chained fixup metadata + /// Iterator over the chained fixup metadata it_chained_starts_in_segments_t chained_starts_in_segments() { return chained_starts_in_segment_; } @@ -159,36 +159,36 @@ class LIEF_API DyldChainedFixups : public LoadCommand { return chained_starts_in_segment_; } - //! Chained fixups version. The loader (dyld v852.2) checks - //! that this value is set to 0 + /// Chained fixups version. The loader (dyld v852.2) checks + /// that this value is set to 0 uint32_t fixups_version() const { return fixups_version_; } void fixups_version(uint32_t version) { fixups_version_ = version; } - //! offset of dyld_chained_starts_in_image in chain_data + /// offset of dyld_chained_starts_in_image in chain_data uint32_t starts_offset() const { return starts_offset_; } void starts_offset(uint32_t offset) { starts_offset_ = offset; } - //! Offset of imports table in chain data + /// Offset of imports table in chain data uint32_t imports_offset() const { return imports_offset_; } void imports_offset(uint32_t offset) { imports_offset_ = offset; } - //! Offset of symbol strings in chain data + /// Offset of symbol strings in chain data uint32_t symbols_offset() const { return symbols_offset_; } void symbols_offset(uint32_t offset) { symbols_offset_ = offset; } - //! Number of imported symbol names + /// Number of imported symbol names uint32_t imports_count() const { return imports_count_; } void imports_count(uint32_t cnt) { imports_count_ = cnt; } - //! The compression algorithm (if any) used to store the symbols - //! 0 means uncompressed while 1 means zlib compressed. - //! - //! As far of the version v852.2 of dyld loader, it only supports - //! **uncompressed** format + /// The compression algorithm (if any) used to store the symbols + /// 0 means uncompressed while 1 means zlib compressed. + /// + /// As far of the version v852.2 of dyld loader, it only supports + /// **uncompressed** format uint32_t symbols_format() const { return symbols_format_; } void symbols_format(uint32_t fmt) { symbols_format_ = fmt; } - //! The format of the imports (ChainedBindingInfo) + /// The format of the imports (ChainedBindingInfo) DYLD_CHAINED_FORMAT imports_format() const { return imports_format_; } void imports_format(DYLD_CHAINED_FORMAT fmt) { imports_format_ = fmt; } diff --git a/include/LIEF/MachO/DyldEnvironment.hpp b/include/LIEF/MachO/DyldEnvironment.hpp index 05a2c9693a..3d9d76da7d 100644 --- a/include/LIEF/MachO/DyldEnvironment.hpp +++ b/include/LIEF/MachO/DyldEnvironment.hpp @@ -29,8 +29,8 @@ namespace details { struct dylinker_command; } -//! Class that represents a `LC_DYLD_ENVIRONMENT` command which is -//! used by the Mach-O linker/loader to initialize an environment variable +/// Class that represents a `LC_DYLD_ENVIRONMENT` command which is +/// used by the Mach-O linker/loader to initialize an environment variable class LIEF_API DyldEnvironment : public LoadCommand { public: DyldEnvironment() = default; @@ -47,7 +47,7 @@ class LIEF_API DyldEnvironment : public LoadCommand { std::ostream& print(std::ostream& os) const override; - //! The actual environment variable + /// The actual environment variable const std::string& value() const { return value_; } diff --git a/include/LIEF/MachO/DyldExportsTrie.hpp b/include/LIEF/MachO/DyldExportsTrie.hpp index 8ca2fcca35..2573e04cec 100644 --- a/include/LIEF/MachO/DyldExportsTrie.hpp +++ b/include/LIEF/MachO/DyldExportsTrie.hpp @@ -34,9 +34,9 @@ namespace details { struct linkedit_data_command; } -//! Class that represents the LC_DYLD_EXPORTS_TRIE command -//! -//! In recent Mach-O binaries, this command replace the DyldInfo export trie buffer +/// Class that represents the LC_DYLD_EXPORTS_TRIE command +/// +/// In recent Mach-O binaries, this command replace the DyldInfo export trie buffer class LIEF_API DyldExportsTrie : public LoadCommand { friend class BinaryParser; friend class Builder; @@ -44,13 +44,13 @@ class LIEF_API DyldExportsTrie : public LoadCommand { friend class Binary; public: - //! Internal container for storing ExportInfo + /// Internal container for storing ExportInfo using export_info_t = std::vector>; - //! Iterator which outputs const ExportInfo& + /// Iterator which outputs const ExportInfo& using it_export_info = ref_iterator; - //! Iterator which outputs const ExportInfo& + /// Iterator which outputs const ExportInfo& using it_const_export_info = const_ref_iterator; DyldExportsTrie(); @@ -63,13 +63,13 @@ class LIEF_API DyldExportsTrie : public LoadCommand { ~DyldExportsTrie() override; - //! Offset of the LC_DYLD_EXPORTS_TRIE. - //! This offset should point in the __LINKEDIT segment + /// Offset of the LC_DYLD_EXPORTS_TRIE. + /// This offset should point in the __LINKEDIT segment uint32_t data_offset() const { return data_offset_; } - //! Size of the LC_DYLD_EXPORTS_TRIE payload. + /// Size of the LC_DYLD_EXPORTS_TRIE payload. uint32_t data_size() const { return data_size_; } @@ -85,7 +85,7 @@ class LIEF_API DyldExportsTrie : public LoadCommand { return content_; } - //! Iterator over the ExportInfo entries + /// Iterator over the ExportInfo entries it_export_info exports() { return export_info_; } @@ -94,11 +94,11 @@ class LIEF_API DyldExportsTrie : public LoadCommand { return export_info_; } - //! Print the exports trie in a humman-readable way + /// Print the exports trie in a humman-readable way std::string show_export_trie() const; - //! Add an entrie in the current trie. - //! See also: LIEF::MachO::Binary::add_exported_function + /// Add an entrie in the current trie. + /// See also: LIEF::MachO::Binary::add_exported_function void add(std::unique_ptr info); void accept(Visitor& visitor) const override; diff --git a/include/LIEF/MachO/DyldInfo.hpp b/include/LIEF/MachO/DyldInfo.hpp index 79c1c47903..3fd22fdd2e 100644 --- a/include/LIEF/MachO/DyldInfo.hpp +++ b/include/LIEF/MachO/DyldInfo.hpp @@ -46,7 +46,7 @@ namespace details { struct dyld_info_command; } -//! Class that represents the LC_DYLD_INFO and LC_DYLD_INFO_ONLY commands +/// Class that represents the LC_DYLD_INFO and LC_DYLD_INFO_ONLY commands class LIEF_API DyldInfo : public LoadCommand { friend class BinaryParser; @@ -56,25 +56,25 @@ class LIEF_API DyldInfo : public LoadCommand { friend class BindingInfoIterator; public: - //! Tuple of ``offset`` and ``size`` + /// Tuple of ``offset`` and ``size`` using info_t = std::pair; - //! Internal container for storing DyldBindingInfo + /// Internal container for storing DyldBindingInfo using binding_info_t = std::vector>; - //! Iterator which outputs DyldBindingInfo& + /// Iterator which outputs DyldBindingInfo& using it_binding_info = ref_iterator; - //! Iterator which outputs const DyldBindingInfo& + /// Iterator which outputs const DyldBindingInfo& using it_const_binding_info = const_ref_iterator; - //! Internal container for storing ExportInfo + /// Internal container for storing ExportInfo using export_info_t = std::vector>; - //! Iterator which outputs const ExportInfo& + /// Iterator which outputs const ExportInfo& using it_export_info = ref_iterator; - //! Iterator which outputs const ExportInfo& + /// Iterator which outputs const ExportInfo& using it_const_export_info = const_ref_iterator; enum class BINDING_ENCODING_VERSION { @@ -102,7 +102,7 @@ class LIEF_API DyldInfo : public LoadCommand { DO_REBASE_ULEB_TIMES_SKIPPING_ULEB = 0x80u ///< Rebase and skip several bytes }; - //! @brief Opcodes used by Dyld info to bind symbols + /// Opcodes used by Dyld info to bind symbols enum class BIND_OPCODES: uint8_t { DONE = 0x00u, ///< It's finished SET_DYLIB_ORDINAL_IMM = 0x10u, ///< Set ordinal to immediate (lower 4-bits). Used for ordinal numbers from 0-15 @@ -150,24 +150,24 @@ class LIEF_API DyldInfo : public LoadCommand { ~DyldInfo() override; - //! *Rebase* information - //! - //! Dyld rebases an image whenever dyld loads it at an address different - //! from its preferred address. The rebase information is a stream - //! of byte sized opcodes for which symbolic names start with REBASE_OPCODE_. - //! Conceptually the rebase information is a table of tuples: - //! - //! The opcodes are a compressed way to encode the table by only - //! encoding when a column changes. In addition simple patterns - //! like "every n'th offset for m times" can be encoded in a few - //! bytes. - //! - //! @see ``/usr/include/mach-o/loader.h`` + /// *Rebase* information + /// + /// Dyld rebases an image whenever dyld loads it at an address different + /// from its preferred address. The rebase information is a stream + /// of byte sized opcodes for which symbolic names start with REBASE_OPCODE_. + /// Conceptually the rebase information is a table of tuples: + /// + /// The opcodes are a compressed way to encode the table by only + /// encoding when a column changes. In addition simple patterns + /// like "every n'th offset for m times" can be encoded in a few + /// bytes. + /// + /// @see ``/usr/include/mach-o/loader.h`` const info_t& rebase() const { return rebase_; } - //! Return Rebase's opcodes as raw data + /// Return Rebase's opcodes as raw data span rebase_opcodes() const { return rebase_opcodes_; } @@ -175,31 +175,31 @@ class LIEF_API DyldInfo : public LoadCommand { return rebase_opcodes_; } - //! Set new opcodes + /// Set new opcodes void rebase_opcodes(buffer_t raw); - //! Return the rebase opcodes in a humman-readable way + /// Return the rebase opcodes in a humman-readable way std::string show_rebases_opcodes() const; - //! *Bind* information - //! - //! Dyld binds an image during the loading process, if the image - //! requires any pointers to be initialized to symbols in other images. - //! The rebase information is a stream of byte sized - //! opcodes for which symbolic names start with BIND_OPCODE_. - //! Conceptually the bind information is a table of tuples: - //! - //! The opcodes are a compressed way to encode the table by only - //! encoding when a column changes. In addition simple patterns - //! like for runs of pointers initialzed to the same value can be - //! encoded in a few bytes. - //! - //! @see ``/usr/include/mach-o/loader.h`` + /// *Bind* information + /// + /// Dyld binds an image during the loading process, if the image + /// requires any pointers to be initialized to symbols in other images. + /// The rebase information is a stream of byte sized + /// opcodes for which symbolic names start with BIND_OPCODE_. + /// Conceptually the bind information is a table of tuples: + /// + /// The opcodes are a compressed way to encode the table by only + /// encoding when a column changes. In addition simple patterns + /// like for runs of pointers initialzed to the same value can be + /// encoded in a few bytes. + /// + /// @see ``/usr/include/mach-o/loader.h`` const info_t& bind() const { return bind_; } - //! Return Binding's opcodes as raw data + /// Return Binding's opcodes as raw data span bind_opcodes() const { return bind_opcodes_; } @@ -207,34 +207,34 @@ class LIEF_API DyldInfo : public LoadCommand { return bind_opcodes_; } - //! Set new opcodes + /// Set new opcodes void bind_opcodes(buffer_t raw); - //! Return the bind opcodes in a humman-readable way + /// Return the bind opcodes in a humman-readable way std::string show_bind_opcodes() const; - //! *Weak Bind* information - //! - //! Some C++ programs require dyld to unique symbols so that all - //! images in the process use the same copy of some code/data. - //! This step is done after binding. The content of the weak_bind - //! info is an opcode stream like the bind_info. But it is sorted - //! alphabetically by symbol name. This enables dyld to walk - //! all images with weak binding information in order and look - //! for collisions. If there are no collisions, dyld does - //! no updating. That means that some fixups are also encoded - //! in the bind_info. For instance, all calls to "operator new" - //! are first bound to libstdc++.dylib using the information - //! in bind_info. Then if some image overrides operator new - //! that is detected when the weak_bind information is processed - //! and the call to operator new is then rebound. - //! - //! @see ``/usr/include/mach-o/loader.h`` + /// *Weak Bind* information + /// + /// Some C++ programs require dyld to unique symbols so that all + /// images in the process use the same copy of some code/data. + /// This step is done after binding. The content of the weak_bind + /// info is an opcode stream like the bind_info. But it is sorted + /// alphabetically by symbol name. This enables dyld to walk + /// all images with weak binding information in order and look + /// for collisions. If there are no collisions, dyld does + /// no updating. That means that some fixups are also encoded + /// in the bind_info. For instance, all calls to "operator new" + /// are first bound to libstdc++.dylib using the information + /// in bind_info. Then if some image overrides operator new + /// that is detected when the weak_bind information is processed + /// and the call to operator new is then rebound. + /// + /// @see ``/usr/include/mach-o/loader.h`` const info_t& weak_bind() const { return weak_bind_; } - //! Return **Weak** Binding's opcodes as raw data + /// Return **Weak** Binding's opcodes as raw data span weak_bind_opcodes() const { return weak_bind_opcodes_; } @@ -242,31 +242,31 @@ class LIEF_API DyldInfo : public LoadCommand { return weak_bind_opcodes_; } - //! Set new opcodes + /// Set new opcodes void weak_bind_opcodes(buffer_t raw); - //! Return the bind opcodes in a humman-readable way + /// Return the bind opcodes in a humman-readable way std::string show_weak_bind_opcodes() const; - //! *Lazy Bind* information - //! - //! Some uses of external symbols do not need to be bound immediately. - //! Instead they can be lazily bound on first use. The lazy_bind - //! are contains a stream of BIND opcodes to bind all lazy symbols. - //! Normal use is that dyld ignores the lazy_bind section when - //! loading an image. Instead the static linker arranged for the - //! lazy pointer to initially point to a helper function which - //! pushes the offset into the lazy_bind area for the symbol - //! needing to be bound, then jumps to dyld which simply adds - //! the offset to lazy_bind_off to get the information on what - //! to bind. - //! - //! @see ``/usr/include/mach-o/loader.h`` + /// *Lazy Bind* information + /// + /// Some uses of external symbols do not need to be bound immediately. + /// Instead they can be lazily bound on first use. The lazy_bind + /// are contains a stream of BIND opcodes to bind all lazy symbols. + /// Normal use is that dyld ignores the lazy_bind section when + /// loading an image. Instead the static linker arranged for the + /// lazy pointer to initially point to a helper function which + /// pushes the offset into the lazy_bind area for the symbol + /// needing to be bound, then jumps to dyld which simply adds + /// the offset to lazy_bind_off to get the information on what + /// to bind. + /// + /// @see ``/usr/include/mach-o/loader.h`` const info_t& lazy_bind() const { return lazy_bind_; } - //! Return **Lazy** Binding's opcodes as raw data + /// Return **Lazy** Binding's opcodes as raw data span lazy_bind_opcodes() const { return lazy_bind_opcodes_; } @@ -274,13 +274,13 @@ class LIEF_API DyldInfo : public LoadCommand { return lazy_bind_opcodes_; } - //! Set new opcodes + /// Set new opcodes void lazy_bind_opcodes(buffer_t raw); - //! Return the lazy opcodes in a humman-readable way + /// Return the lazy opcodes in a humman-readable way std::string show_lazy_bind_opcodes() const; - //! Iterator over BindingInfo entries + /// Iterator over BindingInfo entries it_binding_info bindings() { return binding_info_; } @@ -289,37 +289,37 @@ class LIEF_API DyldInfo : public LoadCommand { return binding_info_; } - //! *Export* information - //! - //! The symbols exported by a dylib are encoded in a trie. This - //! is a compact representation that factors out common prefixes. - //! It also reduces LINKEDIT pages in RAM because it encodes all - //! information (name, address, flags) in one small, contiguous range. - //! The export area is a stream of nodes. The first node sequentially - //! is the start node for the trie. - //! - //! Nodes for a symbol start with a byte that is the length of - //! the exported symbol information for the string so far. - //! If there is no exported symbol, the byte is zero. If there - //! is exported info, it follows the length byte. The exported - //! info normally consists of a flags and offset both encoded - //! in uleb128. The offset is location of the content named - //! by the symbol. It is the offset from the mach_header for - //! the image. - //! - //! After the initial byte and optional exported symbol information - //! is a byte of how many edges (0-255) that this node has leaving - //! it, followed by each edge. - //! Each edge is a zero terminated cstring of the addition chars - //! in the symbol, followed by a uleb128 offset for the node that - //! edge points to. - //! - //! @see ``/usr/include/mach-o/loader.h`` + /// *Export* information + /// + /// The symbols exported by a dylib are encoded in a trie. This + /// is a compact representation that factors out common prefixes. + /// It also reduces LINKEDIT pages in RAM because it encodes all + /// information (name, address, flags) in one small, contiguous range. + /// The export area is a stream of nodes. The first node sequentially + /// is the start node for the trie. + /// + /// Nodes for a symbol start with a byte that is the length of + /// the exported symbol information for the string so far. + /// If there is no exported symbol, the byte is zero. If there + /// is exported info, it follows the length byte. The exported + /// info normally consists of a flags and offset both encoded + /// in uleb128. The offset is location of the content named + /// by the symbol. It is the offset from the mach_header for + /// the image. + /// + /// After the initial byte and optional exported symbol information + /// is a byte of how many edges (0-255) that this node has leaving + /// it, followed by each edge. + /// Each edge is a zero terminated cstring of the addition chars + /// in the symbol, followed by a uleb128 offset for the node that + /// edge points to. + /// + /// @see ``/usr/include/mach-o/loader.h`` const info_t& export_info() const { return export_; } - //! Iterator over ExportInfo entries + /// Iterator over ExportInfo entries it_export_info exports() { return export_info_; } @@ -327,7 +327,7 @@ class LIEF_API DyldInfo : public LoadCommand { return export_info_; } - //! Return Export's trie as raw data + /// Return Export's trie as raw data span export_trie() const { return export_trie_; } @@ -335,10 +335,10 @@ class LIEF_API DyldInfo : public LoadCommand { return export_trie_; } - //! Set new trie + /// Set new trie void export_trie(buffer_t raw); - //! Return the export trie in a humman-readable way + /// Return the export trie in a humman-readable way std::string show_export_trie() const; void rebase(const info_t& info) { diff --git a/include/LIEF/MachO/DylibCommand.hpp b/include/LIEF/MachO/DylibCommand.hpp index 4543e1061e..71a704c942 100644 --- a/include/LIEF/MachO/DylibCommand.hpp +++ b/include/LIEF/MachO/DylibCommand.hpp @@ -30,13 +30,13 @@ namespace details { struct dylib_command; } -//! Class which represents a library dependency +/// Class which represents a library dependency class LIEF_API DylibCommand : public LoadCommand { public: using version_t = std::array; public: - //! Helper to convert an integer into a version array + /// Helper to convert an integer into a version array static version_t int2version(uint32_t version) { return {{ static_cast(version >> 16), @@ -45,42 +45,42 @@ class LIEF_API DylibCommand : public LoadCommand { }}; } - //! Helper to convert a version array into an integer + /// Helper to convert a version array into an integer static uint32_t version2int(version_t version) { return (version[2]) | (version[1] << 8) | (version[0] << 16); } - //! Factory function to generate a LC_LOAD_WEAK_DYLIB library + /// Factory function to generate a LC_LOAD_WEAK_DYLIB library static DylibCommand weak_dylib(const std::string& name, uint32_t timestamp = 0, uint32_t current_version = 0, uint32_t compat_version = 0); - //! Factory function to generate a LC_ID_DYLIB library + /// Factory function to generate a LC_ID_DYLIB library static DylibCommand id_dylib(const std::string& name, uint32_t timestamp = 0, uint32_t current_version = 0, uint32_t compat_version = 0); - //! Factory function to generate a LC_LOAD_DYLIB library + /// Factory function to generate a LC_LOAD_DYLIB library static DylibCommand load_dylib(const std::string& name, uint32_t timestamp = 2, uint32_t current_version = 0, uint32_t compat_version = 0); - //! Factory function to generate a LC_REEXPORT_DYLIB library + /// Factory function to generate a LC_REEXPORT_DYLIB library static DylibCommand reexport_dylib(const std::string& name, uint32_t timestamp = 0, uint32_t current_version = 0, uint32_t compat_version = 0); - //! Factory function to generate a LC_LOAD_UPWARD_DYLIB library + /// Factory function to generate a LC_LOAD_UPWARD_DYLIB library static DylibCommand load_upward_dylib(const std::string& name, uint32_t timestamp = 0, uint32_t current_version = 0, uint32_t compat_version = 0); - //! Factory function to generate a LC_LAZY_LOAD_DYLIB library + /// Factory function to generate a LC_LAZY_LOAD_DYLIB library static DylibCommand lazy_load_dylib(const std::string& name, uint32_t timestamp = 0, uint32_t current_version = 0, @@ -99,22 +99,22 @@ class LIEF_API DylibCommand : public LoadCommand { return std::unique_ptr(new DylibCommand(*this)); } - //! Library name + /// Library name const std::string& name() const { return name_; } - //! Date and Time when the shared library was built + /// Date and Time when the shared library was built uint32_t timestamp() const { return timestamp_; } - //! Current version of the shared library + /// Current version of the shared library version_t current_version() const { return int2version(current_version_); } - //! Compatibility version of the shared library + /// Compatibility version of the shared library version_t compatibility_version() const { return int2version(compatibility_version_); } diff --git a/include/LIEF/MachO/DylinkerCommand.hpp b/include/LIEF/MachO/DylinkerCommand.hpp index 0bdd6987bf..2a9ca7a65e 100644 --- a/include/LIEF/MachO/DylinkerCommand.hpp +++ b/include/LIEF/MachO/DylinkerCommand.hpp @@ -29,8 +29,8 @@ namespace details { struct dylinker_command; } -//! Class that represents the Mach-O linker, also named loader. -//! Most of the time, DylinkerCommand::name() should return ``/usr/lib/dyld`` +/// Class that represents the Mach-O linker, also named loader. +/// Most of the time, DylinkerCommand::name() should return ``/usr/lib/dyld`` class LIEF_API DylinkerCommand : public LoadCommand { public: DylinkerCommand() = default; @@ -48,7 +48,7 @@ class LIEF_API DylinkerCommand : public LoadCommand { std::ostream& print(std::ostream& os) const override; - //! Path to the linker (or loader) + /// Path to the linker (or loader) const std::string& name() const { return name_; } diff --git a/include/LIEF/MachO/DynamicSymbolCommand.hpp b/include/LIEF/MachO/DynamicSymbolCommand.hpp index 90ca6cf6be..04999d1726 100644 --- a/include/LIEF/MachO/DynamicSymbolCommand.hpp +++ b/include/LIEF/MachO/DynamicSymbolCommand.hpp @@ -33,10 +33,10 @@ namespace details { struct dysymtab_command; } -//! Class that represents the LC_DYSYMTAB command. -//! -//! This command completes the LC_SYMTAB (SymbolCommand) to provide -//! a better granularity over the symbols layout. +/// Class that represents the LC_DYSYMTAB command. +/// +/// This command completes the LC_SYMTAB (SymbolCommand) to provide +/// a better granularity over the symbols layout. class LIEF_API DynamicSymbolCommand : public LoadCommand { friend class BinaryParser; friend class Builder; @@ -67,123 +67,123 @@ class LIEF_API DynamicSymbolCommand : public LoadCommand { std::ostream& print(std::ostream& os) const override; - //! Index of the first symbol in the group of local symbols. + /// Index of the first symbol in the group of local symbols. uint32_t idx_local_symbol() const { return idx_local_symbol_; } - //! Number of symbols in the group of local symbols. + /// Number of symbols in the group of local symbols. uint32_t nb_local_symbols() const { return nb_local_symbols_; } - //! Index of the first symbol in the group of defined external symbols. + /// Index of the first symbol in the group of defined external symbols. uint32_t idx_external_define_symbol() const { return idx_external_define_symbol_; } - //! Number of symbols in the group of defined external symbols. + /// Number of symbols in the group of defined external symbols. uint32_t nb_external_define_symbols() const { return nb_external_define_symbols_; } - //! Index of the first symbol in the group of undefined external symbols. + /// Index of the first symbol in the group of undefined external symbols. uint32_t idx_undefined_symbol() const { return idx_undefined_symbol_; } - //! Number of symbols in the group of undefined external symbols. + /// Number of symbols in the group of undefined external symbols. uint32_t nb_undefined_symbols() const { return nb_undefined_symbols_; } - //! Byte offset from the start of the file to the table of contents data - //! - //! Table of content is used by legacy Mach-O loader and this field should be - //! set to 0 + /// Byte offset from the start of the file to the table of contents data + /// + /// Table of content is used by legacy Mach-O loader and this field should be + /// set to 0 uint32_t toc_offset() const { return toc_offset_; } - //! Number of entries in the table of contents. - //! - //! Should be set to 0 on recent Mach-O + /// Number of entries in the table of contents. + /// + /// Should be set to 0 on recent Mach-O uint32_t nb_toc() const { return nb_toc_; } - //! Byte offset from the start of the file to the module table data. - //! - //! This field seems unused by recent Mach-O loader and should be set to 0 + /// Byte offset from the start of the file to the module table data. + /// + /// This field seems unused by recent Mach-O loader and should be set to 0 uint32_t module_table_offset() const { return module_table_offset_; } - //! Number of entries in the module table. - //! - //! This field seems unused by recent Mach-O loader and should be set to 0 + /// Number of entries in the module table. + /// + /// This field seems unused by recent Mach-O loader and should be set to 0 uint32_t nb_module_table() const { return nb_module_table_; } - //! Byte offset from the start of the file to the external reference table data. - //! - //! This field seems unused by recent Mach-O loader and should be set to 0 + /// Byte offset from the start of the file to the external reference table data. + /// + /// This field seems unused by recent Mach-O loader and should be set to 0 uint32_t external_reference_symbol_offset() const { return external_reference_symbol_offset_; } - //! Number of entries in the external reference table - //! - //! This field seems unused by recent Mach-O loader and should be set to 0 + /// Number of entries in the external reference table + /// + /// This field seems unused by recent Mach-O loader and should be set to 0 uint32_t nb_external_reference_symbols() const { return nb_external_reference_symbols_; } - //! Byte offset from the start of the file to the indirect symbol table data. - //! - //! Indirect symbol table is used by the loader to speed-up symbol resolution during - //! the *lazy binding* process - //! - //! References: - //! * dyld-519.2.1/src/ImageLoaderMachOCompressed.cpp - //! * dyld-519.2.1/src/ImageLoaderMachOClassic.cpp + /// Byte offset from the start of the file to the indirect symbol table data. + /// + /// Indirect symbol table is used by the loader to speed-up symbol resolution during + /// the *lazy binding* process + /// + /// References: + /// * dyld-519.2.1/src/ImageLoaderMachOCompressed.cpp + /// * dyld-519.2.1/src/ImageLoaderMachOClassic.cpp uint32_t indirect_symbol_offset() const { return indirect_sym_offset_; } - //! Number of entries in the indirect symbol table. - //! - //! @see indirect_symbol_offset + /// Number of entries in the indirect symbol table. + /// + /// @see indirect_symbol_offset uint32_t nb_indirect_symbols() const { return nb_indirect_symbols_; } - //! Byte offset from the start of the file to the external relocation table data. - //! - //! This field seems unused by recent Mach-O loader and should be set to 0 + /// Byte offset from the start of the file to the external relocation table data. + /// + /// This field seems unused by recent Mach-O loader and should be set to 0 uint32_t external_relocation_offset() const { return external_relocation_offset_; } - //! Number of entries in the external relocation table. - //! - //! This field seems unused by recent Mach-O loader and should be set to 0 + /// Number of entries in the external relocation table. + /// + /// This field seems unused by recent Mach-O loader and should be set to 0 uint32_t nb_external_relocations() const { return nb_external_relocations_; } - //! Byte offset from the start of the file to the local relocation table data. - //! - //! This field seems unused by recent Mach-O loader and should be set to 0 + /// Byte offset from the start of the file to the local relocation table data. + /// + /// This field seems unused by recent Mach-O loader and should be set to 0 uint32_t local_relocation_offset() const { return local_relocation_offset_; } - //! Number of entries in the local relocation table. - //! - //! This field seems unused by recent Mach-O loader and should be set to 0 + /// Number of entries in the local relocation table. + /// + /// This field seems unused by recent Mach-O loader and should be set to 0 uint32_t nb_local_relocations() const { return nb_local_relocations_; } diff --git a/include/LIEF/MachO/EncryptionInfo.hpp b/include/LIEF/MachO/EncryptionInfo.hpp index 37b92ca45f..97136e1f5e 100644 --- a/include/LIEF/MachO/EncryptionInfo.hpp +++ b/include/LIEF/MachO/EncryptionInfo.hpp @@ -28,10 +28,10 @@ namespace details { struct encryption_info_command; } -//! Class that represents the LC_ENCRYPTION_INFO / LC_ENCRYPTION_INFO_64 commands -//! -//! The encryption info is usually present in Mach-O executables that -//! target iOS to encrypt some sections of the binary +/// Class that represents the LC_ENCRYPTION_INFO / LC_ENCRYPTION_INFO_64 commands +/// +/// The encryption info is usually present in Mach-O executables that +/// target iOS to encrypt some sections of the binary class LIEF_API EncryptionInfo : public LoadCommand { public: EncryptionInfo() = default; @@ -46,17 +46,17 @@ class LIEF_API EncryptionInfo : public LoadCommand { return std::unique_ptr(new EncryptionInfo(*this)); } - //! The beginning of the encrypted area + /// The beginning of the encrypted area uint32_t crypt_offset() const { return coff_; } - //! The size of the encrypted area + /// The size of the encrypted area uint32_t crypt_size() const { return csize_; } - //! The encryption system. 0 means no encrypted + /// The encryption system. 0 means no encrypted uint32_t crypt_id() const { return cid_; } diff --git a/include/LIEF/MachO/ExportInfo.hpp b/include/LIEF/MachO/ExportInfo.hpp index c61316b7da..585e39d02b 100644 --- a/include/LIEF/MachO/ExportInfo.hpp +++ b/include/LIEF/MachO/ExportInfo.hpp @@ -31,10 +31,10 @@ class Symbol; class DylibCommand; class Binary; -//! Class that provides an interface over the Dyld export info -//! -//! This class does not represent a structure that exists in the Mach-O format -//! specification but provides a *view* on an entry of the Dyld export trie. +/// Class that provides an interface over the Dyld export info +/// +/// This class does not represent a structure that exists in the Mach-O format +/// specification but provides a *view* on an entry of the Dyld export trie. class LIEF_API ExportInfo : public Object { friend class BinaryParser; @@ -66,13 +66,13 @@ class LIEF_API ExportInfo : public Object { ExportInfo(const ExportInfo& copy); void swap(ExportInfo& other) noexcept; - //! Original offset in the export Trie + /// Original offset in the export Trie uint64_t node_offset() const { return node_offset_; } - //! Some information (ExportInfo::FLAGS) about the export. - //! (like weak export, reexport, ...) + /// Some information (ExportInfo::FLAGS) about the export. + /// (like weak export, reexport, ...) uint64_t flags() const { return flags_; } @@ -81,13 +81,13 @@ class LIEF_API ExportInfo : public Object { flags_ = flags; } - //! The export flags() as a list + /// The export flags() as a list flag_list_t flags_list() const; - //! Check if the current entry contains the provided ExportInfo::FLAGS + /// Check if the current entry contains the provided ExportInfo::FLAGS bool has(FLAGS flag) const; - //! The export's kind (regular, thread local, absolute, ...) + /// The export's kind (regular, thread local, absolute, ...) KIND kind() const { static constexpr auto MASK = uint64_t(3); return KIND(flags_ & MASK); @@ -97,7 +97,7 @@ class LIEF_API ExportInfo : public Object { return other_; } - //! The address of the export + /// The address of the export uint64_t address() const { return address_; } @@ -105,12 +105,12 @@ class LIEF_API ExportInfo : public Object { address_ = addr; } - //! Check if a symbol is associated with this export + /// Check if a symbol is associated with this export bool has_symbol() const { return symbol() != nullptr; } - //! MachO::Symbol associated with this export or a nullptr if no symbol + /// MachO::Symbol associated with this export or a nullptr if no symbol const Symbol* symbol() const { return symbol_; } @@ -118,8 +118,8 @@ class LIEF_API ExportInfo : public Object { return symbol_; } - //! If the export is a ExportInfo::FLAGS::REEXPORT, - //! this returns the (optional) MachO::Symbol + /// If the export is a ExportInfo::FLAGS::REEXPORT, + /// this returns the (optional) MachO::Symbol Symbol* alias() { return alias_; } @@ -127,8 +127,8 @@ class LIEF_API ExportInfo : public Object { return alias_; } - //! If the export is a ExportInfo::FLAGS::REEXPORT, - //! this returns the (optional) library (MachO::DylibCommand) + /// If the export is a ExportInfo::FLAGS::REEXPORT, + /// this returns the (optional) library (MachO::DylibCommand) DylibCommand* alias_library() { return alias_location_; } diff --git a/include/LIEF/MachO/FatBinary.hpp b/include/LIEF/MachO/FatBinary.hpp index 15b07b650c..e4542d1b07 100644 --- a/include/LIEF/MachO/FatBinary.hpp +++ b/include/LIEF/MachO/FatBinary.hpp @@ -31,8 +31,8 @@ class Parser; class Builder; class Binary; -//! Class which represent a Mach-O (fat) binary -//! This object is also used for representing Mach-O binaries that are **NOT FAT** +/// Class which represent a Mach-O (fat) binary +/// This object is also used for representing Mach-O binaries that are **NOT FAT** class LIEF_API FatBinary { friend class LIEF::Parser; @@ -41,13 +41,13 @@ class LIEF_API FatBinary { public: - //! Internal containter used to store Binary objects within a Fat Mach-O + /// Internal containter used to store Binary objects within a Fat Mach-O using binaries_t = std::vector>; - //! Iterator that outputs Binary& + /// Iterator that outputs Binary& using it_binaries = ref_iterator; - //! Iterator that outputs const Binary& + /// Iterator that outputs const Binary& using it_const_binaries = const_ref_iterator; FatBinary(const FatBinary&) = delete; @@ -55,12 +55,12 @@ class LIEF_API FatBinary { virtual ~FatBinary(); - //! Number of MachO::Binary wrapped by this object + /// Number of MachO::Binary wrapped by this object size_t size() const { return binaries_.size(); } - //! Checks whether this object contains MachO::Binary + /// Checks whether this object contains MachO::Binary bool empty() const { return binaries_.empty(); } @@ -82,12 +82,12 @@ class LIEF_API FatBinary { void release_all_binaries(); - //! Get a pointer to the last MachO::Binary object presents in this Fat Binary. - //! It returns a nullptr if no binary are present. + /// Get a pointer to the last MachO::Binary object presents in this Fat Binary. + /// It returns a nullptr if no binary are present. std::unique_ptr pop_back(); - //! Get a pointer to the MachO::Binary specified by the ``index``. - //! It returns a nullptr if the binary does not exist at the given index. + /// Get a pointer to the MachO::Binary specified by the ``index``. + /// It returns a nullptr if the binary does not exist at the given index. Binary* at(size_t index); const Binary* at(size_t index) const; @@ -104,21 +104,21 @@ class LIEF_API FatBinary { return at(index); } - //! Extract a MachO::Binary object. Gives ownership to the caller, and - //! remove it from this FatBinary object. - //! - //! @warning: this invalidates any previously hold iterator! + /// Extract a MachO::Binary object. Gives ownership to the caller, and + /// remove it from this FatBinary object. + /// + /// @warning: this invalidates any previously hold iterator! std::unique_ptr take(size_t index); - //! Take the underlying MachO::Binary that matches the given architecture - //! If no binary with the architecture can be found, return a nullptr + /// Take the underlying MachO::Binary that matches the given architecture + /// If no binary with the architecture can be found, return a nullptr std::unique_ptr take(Header::CPU_TYPE cpu); - //! Reconstruct the Fat binary object and write it in `filename` - //! @param filename Path to write the reconstructed binary + /// Reconstruct the Fat binary object and write it in `filename` + /// @param filename Path to write the reconstructed binary void write(const std::string& filename); - //! Reconstruct the Fat binary object and return his content as bytes + /// Reconstruct the Fat binary object and return his content as bytes std::vector raw(); LIEF_API friend std::ostream& operator<<(std::ostream& os, const FatBinary& fatbinary); diff --git a/include/LIEF/MachO/FilesetCommand.hpp b/include/LIEF/MachO/FilesetCommand.hpp index 8eda072191..df9d57b107 100644 --- a/include/LIEF/MachO/FilesetCommand.hpp +++ b/include/LIEF/MachO/FilesetCommand.hpp @@ -31,7 +31,7 @@ namespace details { struct fileset_entry_command; } -//! Class associated with the LC_FILESET_ENTRY commands +/// Class associated with the LC_FILESET_ENTRY commands class LIEF_API FilesetCommand : public LoadCommand { public: friend class BinaryParser; @@ -54,23 +54,23 @@ class LIEF_API FilesetCommand : public LoadCommand { ~FilesetCommand() override = default; - //! Name of the underlying MachO binary (e.g. ``com.apple.security.quarantine``) + /// Name of the underlying MachO binary (e.g. ``com.apple.security.quarantine``) const std::string& name() const { return name_; } - //! Memory address where the MachO file should be mapped + /// Memory address where the MachO file should be mapped uint64_t virtual_address() const { return virtual_address_; } - //! Original offset in the kernel cache + /// Original offset in the kernel cache uint64_t file_offset() const { return file_offset_; } - //! Return a pointer on the LIEF::MachO::Binary associated - //! with this entry + /// Return a pointer on the LIEF::MachO::Binary associated + /// with this entry const Binary* binary() const { return binary_; } diff --git a/include/LIEF/MachO/FunctionStarts.hpp b/include/LIEF/MachO/FunctionStarts.hpp index ae6409655f..d5eda35adf 100644 --- a/include/LIEF/MachO/FunctionStarts.hpp +++ b/include/LIEF/MachO/FunctionStarts.hpp @@ -33,9 +33,9 @@ struct linkedit_data_command; } -//! Class which represents the LC_FUNCTION_STARTS command -//! -//! This command is an array of ULEB128 encoded values +/// Class which represents the LC_FUNCTION_STARTS command +/// +/// This command is an array of ULEB128 encoded values class LIEF_API FunctionStarts : public LoadCommand { friend class BinaryParser; friend class LinkEdit; @@ -51,21 +51,21 @@ class LIEF_API FunctionStarts : public LoadCommand { return std::unique_ptr(new FunctionStarts(*this)); } - //! Offset in the ``__LINKEDIT`` SegmentCommand where *start functions* are located + /// Offset in the ``__LINKEDIT`` SegmentCommand where *start functions* are located uint32_t data_offset() const { return data_offset_; } - //! Size of the functions list in the binary + /// Size of the functions list in the binary uint32_t data_size() const { return data_size_; } - //! Addresses of every function entry point in the executable. - //! - //! This allows functions to exist for which there are no entries in the symbol table. - //! - //! @warning The address is relative to the ``__TEXT`` segment + /// Addresses of every function entry point in the executable. + /// + /// This allows functions to exist for which there are no entries in the symbol table. + /// + /// @warning The address is relative to the ``__TEXT`` segment const std::vector& functions() const { return functions_; } @@ -74,7 +74,7 @@ class LIEF_API FunctionStarts : public LoadCommand { return functions_; } - //! Add a new function + /// Add a new function void add_function(uint64_t address) { functions_.emplace_back(address); } diff --git a/include/LIEF/MachO/Header.hpp b/include/LIEF/MachO/Header.hpp index 6d54090a10..4526befb83 100644 --- a/include/LIEF/MachO/Header.hpp +++ b/include/LIEF/MachO/Header.hpp @@ -34,7 +34,7 @@ struct mach_header_64; struct mach_header; } -//! Class that represents the Mach-O header +/// Class that represents the Mach-O header class LIEF_API Header : public Object { friend class BinaryParser; public: @@ -109,53 +109,53 @@ class LIEF_API Header : public Object { static constexpr auto CPU_SUBTYPE_ARM64_ARM64E = 2; - //! The Mach-O magic bytes. These bytes determine whether it is - //! a 32 bits Mach-O, a 64 bits Mach-O files etc. + /// The Mach-O magic bytes. These bytes determine whether it is + /// a 32 bits Mach-O, a 64 bits Mach-O files etc. MACHO_TYPES magic() const { return magic_; } - //! The CPU architecture targeted by this binary + /// The CPU architecture targeted by this binary CPU_TYPE cpu_type() const { return cputype_; } - //! Return the CPU subtype supported by the Mach-O binary. - //! For ARM architectures, this value could represent the minimum version - //! for which the Mach-O binary has been compiled for. + /// Return the CPU subtype supported by the Mach-O binary. + /// For ARM architectures, this value could represent the minimum version + /// for which the Mach-O binary has been compiled for. uint32_t cpu_subtype() const { return cpusubtype_; } - //! Return the type of the Mach-O file (executable, object, shared library, ...) + /// Return the type of the Mach-O file (executable, object, shared library, ...) FILE_TYPE file_type() const { return filetype_; } - //! Return the FLAGS as a list + /// Return the FLAGS as a list std::vector flags_list() const; - //! Check if the given HEADER_FLAGS is present in the header's flags + /// Check if the given HEADER_FLAGS is present in the header's flags bool has(FLAGS flag) const; - //! Number of LoadCommand present in the Mach-O binary + /// Number of LoadCommand present in the Mach-O binary uint32_t nb_cmds() const { return ncmds_; } - //! The size of **all** the LoadCommand + /// The size of **all** the LoadCommand uint32_t sizeof_cmds() const { return sizeofcmds_; } - //! Header flags (cf. HEADER_FLAGS) - //! - //! @see flags_list + /// Header flags (cf. HEADER_FLAGS) + /// + /// @see flags_list uint32_t flags() const { return flags_; } - //! According to the official documentation, a reserved value + /// According to the official documentation, a reserved value uint32_t reserved() const { return reserved_; } diff --git a/include/LIEF/MachO/LinkerOptHint.hpp b/include/LIEF/MachO/LinkerOptHint.hpp index 1a6c67beb1..16b59649e2 100644 --- a/include/LIEF/MachO/LinkerOptHint.hpp +++ b/include/LIEF/MachO/LinkerOptHint.hpp @@ -33,7 +33,7 @@ namespace details { struct linkedit_data_command; } -//! Class which represents the `LC_LINKER_OPTIMIZATION_HINT` command +/// Class which represents the `LC_LINKER_OPTIMIZATION_HINT` command class LIEF_API LinkerOptHint : public LoadCommand { friend class BinaryParser; friend class Builder; @@ -50,12 +50,12 @@ class LIEF_API LinkerOptHint : public LoadCommand { return std::unique_ptr(new LinkerOptHint(*this)); } - //! Offset in the binary where the *hint* starts + /// Offset in the binary where the *hint* starts uint32_t data_offset() const { return data_offset_; } - //! Size of the payload + /// Size of the payload uint32_t data_size() const { return data_size_; } diff --git a/include/LIEF/MachO/LoadCommand.hpp b/include/LIEF/MachO/LoadCommand.hpp index 7ef62e9d2a..c919817b99 100644 --- a/include/LIEF/MachO/LoadCommand.hpp +++ b/include/LIEF/MachO/LoadCommand.hpp @@ -33,7 +33,7 @@ namespace details { struct load_command; } -//! Based class for the Mach-O load commands +/// Based class for the Mach-O load commands class LIEF_API LoadCommand : public Object { friend class Builder; friend class BinaryParser; @@ -120,22 +120,22 @@ class LIEF_API LoadCommand : public Object { ~LoadCommand() override = default; - //! Command type + /// Command type LoadCommand::TYPE command() const { return command_; } - //! Size of the command (should be greather than ``sizeof(load_command)``) + /// Size of the command (should be greather than ``sizeof(load_command)``) uint32_t size() const { return size_; } - //! Raw command + /// Raw command span data() const { return original_data_; } - //! Offset of the command within the *Load Command Table* + /// Offset of the command within the *Load Command Table* uint64_t command_offset() const { return command_offset_; } diff --git a/include/LIEF/MachO/MainCommand.hpp b/include/LIEF/MachO/MainCommand.hpp index d70f9d753f..cf6ace8822 100644 --- a/include/LIEF/MachO/MainCommand.hpp +++ b/include/LIEF/MachO/MainCommand.hpp @@ -28,8 +28,8 @@ namespace details { struct entry_point_command; } -//! Class that represent the LC_MAIN command. This kind -//! of command can be used to determine the entrypoint of an executable +/// Class that represent the LC_MAIN command. This kind +/// of command can be used to determine the entrypoint of an executable class LIEF_API MainCommand : public LoadCommand { public: MainCommand() = default; @@ -45,13 +45,13 @@ class LIEF_API MainCommand : public LoadCommand { ~MainCommand() override = default; - //! Offset of the *main* function relative to the ``__TEXT`` - //! segment + /// Offset of the *main* function relative to the ``__TEXT`` + /// segment uint64_t entrypoint() const { return entrypoint_; } - //! The initial stack size + /// The initial stack size uint64_t stack_size() const { return stack_size_; } diff --git a/include/LIEF/MachO/Parser.hpp b/include/LIEF/MachO/Parser.hpp index 3204c291d9..b8b7a4980b 100644 --- a/include/LIEF/MachO/Parser.hpp +++ b/include/LIEF/MachO/Parser.hpp @@ -33,12 +33,12 @@ namespace MachO { class Binary; class FatBinary; -//! The main interface to parse a Mach-O binary. -//! -//! This class is used to parse both Fat & non-Fat binary. -//! Non-fat binaries are considerated as a **fat** with -//! only one architecture. This is why MachO::Parser::parse outputs -//! a FatBinary object. +/// The main interface to parse a Mach-O binary. +/// +/// This class is used to parse both Fat & non-Fat binary. +/// Non-fat binaries are considerated as a **fat** with +/// only one architecture. This is why MachO::Parser::parse outputs +/// a FatBinary object. class LIEF_API Parser : public LIEF::Parser { public: Parser& operator=(const Parser& copy) = delete; @@ -46,39 +46,39 @@ class LIEF_API Parser : public LIEF::Parser { ~Parser() override; - //! Parse a Mach-O file from the path provided by the ``filename`` - //! parameter - //! - //! The @p conf parameter can be used to tweak the configuration - //! of the parser - //! - //! @param[in] filename Path to the Mach-O file - //! @param[in] conf Parser configuration (Defaut: ParserConfig::deep) + /// Parse a Mach-O file from the path provided by the ``filename`` + /// parameter + /// + /// The @p conf parameter can be used to tweak the configuration + /// of the parser + /// + /// @param[in] filename Path to the Mach-O file + /// @param[in] conf Parser configuration (Defaut: ParserConfig::deep) static std::unique_ptr parse(const std::string& filename, const ParserConfig& conf = ParserConfig::deep()); - //! Parse a Mach-O file from the raw content provided by the ``data`` - //! parameter - //! - //! The @p conf parameter can be used to tweak the configuration - //! of the parser - //! - //! @param[in] data Mach-O file as a vector of bytes - //! @param[in] conf Parser configuration (Defaut: ParserConfig::deep) + /// Parse a Mach-O file from the raw content provided by the ``data`` + /// parameter + /// + /// The @p conf parameter can be used to tweak the configuration + /// of the parser + /// + /// @param[in] data Mach-O file as a vector of bytes + /// @param[in] conf Parser configuration (Defaut: ParserConfig::deep) static std::unique_ptr parse(const std::vector& data, const ParserConfig& conf = ParserConfig::deep()); - //! Parser a Mach-O binary from the provided BinaryStream. + /// Parser a Mach-O binary from the provided BinaryStream. static std::unique_ptr parse(std::unique_ptr stream, const ParserConfig& conf = ParserConfig::deep()); - //! Parse the Mach-O binary from the address given in the first parameter + /// Parse the Mach-O binary from the address given in the first parameter static std::unique_ptr parse_from_memory(uintptr_t address, const ParserConfig& conf = ParserConfig::deep()); - //! Parse the Mach-O binary from the address given in the first parameter - //! and the size given in the second parameter + /// Parse the Mach-O binary from the address given in the first parameter + /// and the size given in the second parameter static std::unique_ptr parse_from_memory(uintptr_t address, size_t size, const ParserConfig& conf = ParserConfig::deep()); diff --git a/include/LIEF/MachO/ParserConfig.hpp b/include/LIEF/MachO/ParserConfig.hpp index 71b3b536f8..7f983687c2 100644 --- a/include/LIEF/MachO/ParserConfig.hpp +++ b/include/LIEF/MachO/ParserConfig.hpp @@ -20,20 +20,20 @@ namespace LIEF { namespace MachO { -//! This structure is used to tweak the MachO Parser (MachO::Parser) +/// This structure is used to tweak the MachO Parser (MachO::Parser) struct LIEF_API ParserConfig { - //! Return a parser configuration such as all the objects supported by - //! LIEF are parsed + /// Return a parser configuration such as all the objects supported by + /// LIEF are parsed static ParserConfig deep(); - //! Return a configuration to parse the most important MachO - //! structures + /// Return a configuration to parse the most important MachO + /// structures static ParserConfig quick(); - //! If ``flag`` is set to ``true``, Exports, Bindings and Rebases opcodes are - //! parsed. - //! - //! @warning Enabling this flag can slow down the parsing + /// If ``flag`` is set to ``true``, Exports, Bindings and Rebases opcodes are + /// parsed. + /// + /// @warning Enabling this flag can slow down the parsing ParserConfig& full_dyldinfo(bool flag); bool parse_dyld_exports = true; ///< Parse the Dyld export trie diff --git a/include/LIEF/MachO/RPathCommand.hpp b/include/LIEF/MachO/RPathCommand.hpp index 082e6c646d..92958c11d0 100644 --- a/include/LIEF/MachO/RPathCommand.hpp +++ b/include/LIEF/MachO/RPathCommand.hpp @@ -29,10 +29,10 @@ namespace details { struct rpath_command; } -//! Class that represents the LC_RPATH command. -//! -//! This command is used to add path for searching libraries -//! associated with the ``@rpath`` prefix. +/// Class that represents the LC_RPATH command. +/// +/// This command is used to add path for searching libraries +/// associated with the ``@rpath`` prefix. class LIEF_API RPathCommand : public LoadCommand { public: RPathCommand() = default; @@ -47,7 +47,7 @@ class LIEF_API RPathCommand : public LoadCommand { ~RPathCommand() override = default; - //! The rpath value as a string + /// The rpath value as a string const std::string& path() const { return path_; } diff --git a/include/LIEF/MachO/Relocation.hpp b/include/LIEF/MachO/Relocation.hpp index 286a30ca43..ac62990161 100644 --- a/include/LIEF/MachO/Relocation.hpp +++ b/include/LIEF/MachO/Relocation.hpp @@ -31,12 +31,12 @@ class Section; class SegmentCommand; class Symbol; -//! Class that represents a Mach-O relocation -//! -//! @see: -//! * MachO::RelocationObject -//! * MachO::RelocationDyld -//! * MachO::RelocationFixup +/// Class that represents a Mach-O relocation +/// +/// @see: +/// * MachO::RelocationObject +/// * MachO::RelocationDyld +/// * MachO::RelocationFixup class LIEF_API Relocation : public LIEF::Relocation { friend class BinaryParser; @@ -66,42 +66,42 @@ class LIEF_API Relocation : public LIEF::Relocation { virtual std::unique_ptr clone() const = 0; - //! Indicates whether the item containing the address to be - //! relocated is part of a CPU instruction that uses PC-relative addressing. - //! - //! For addresses contained in PC-relative instructions, the CPU adds the address of - //! the instruction to the address contained in the instruction. + /// Indicates whether the item containing the address to be + /// relocated is part of a CPU instruction that uses PC-relative addressing. + /// + /// For addresses contained in PC-relative instructions, the CPU adds the address of + /// the instruction to the address contained in the instruction. virtual bool is_pc_relative() const = 0; - //! Type of the relocation according to the - //! Relocation::architecture and/or the Relocation::origin - //! - //! See: - //! * MachO::X86_RELOCATION - //! * MachO::X86_64_RELOCATION - //! * MachO::PPC_RELOCATION - //! * MachO::ARM_RELOCATION - //! * MachO::ARM64_RELOCATION - //! * MachO::REBASE_TYPES + /// Type of the relocation according to the + /// Relocation::architecture and/or the Relocation::origin + /// + /// See: + /// * MachO::X86_RELOCATION + /// * MachO::X86_64_RELOCATION + /// * MachO::PPC_RELOCATION + /// * MachO::ARM_RELOCATION + /// * MachO::ARM64_RELOCATION + /// * MachO::REBASE_TYPES virtual uint8_t type() const { return type_; } - //! Achitecture targeted by this relocation + /// Achitecture targeted by this relocation Header::CPU_TYPE architecture() const { return architecture_; } - //! Origin of the relocation + /// Origin of the relocation virtual ORIGIN origin() const = 0; - //! ``true`` if the relocation has a symbol associated with + /// ``true`` if the relocation has a symbol associated with bool has_symbol() const { return symbol() != nullptr; } - //! Symbol associated with the relocation, if any, - //! otherwise a nullptr. + /// Symbol associated with the relocation, if any, + /// otherwise a nullptr. Symbol* symbol() { return symbol_; } @@ -109,13 +109,13 @@ class LIEF_API Relocation : public LIEF::Relocation { return symbol_; } - //! ``true`` if the relocation has a section associated with + /// ``true`` if the relocation has a section associated with bool has_section() const { return section() != nullptr; } - //! Section associated with the relocation, if any, - //! otherwise a nullptr. + /// Section associated with the relocation, if any, + /// otherwise a nullptr. Section* section() { return section_; } @@ -123,13 +123,13 @@ class LIEF_API Relocation : public LIEF::Relocation { return section_; } - //! ``true`` if the relocation has a SegmentCommand associated with + /// ``true`` if the relocation has a SegmentCommand associated with bool has_segment() const { return segment() != nullptr; } - //! SegmentCommand associated with the relocation, if any, - //! otherwise a nullptr. + /// SegmentCommand associated with the relocation, if any, + /// otherwise a nullptr. SegmentCommand* segment() { return segment_; } diff --git a/include/LIEF/MachO/RelocationDyld.hpp b/include/LIEF/MachO/RelocationDyld.hpp index 3498c5d502..bfc1a104d1 100644 --- a/include/LIEF/MachO/RelocationDyld.hpp +++ b/include/LIEF/MachO/RelocationDyld.hpp @@ -26,10 +26,10 @@ namespace MachO { class BinaryParser; -//! Class that represents a relocation found in the DyldInfo structure. -//! -//! While this class does not have an associated structure in the Mach-O format specification, -//! it provides a convenient interface for the Dyld::rebase +/// Class that represents a relocation found in the DyldInfo structure. +/// +/// While this class does not have an associated structure in the Mach-O format specification, +/// it provides a convenient interface for the Dyld::rebase class LIEF_API RelocationDyld : public Relocation { friend class BinaryParser; @@ -51,15 +51,15 @@ class LIEF_API RelocationDyld : public Relocation { return std::unique_ptr(new RelocationDyld(*this)); } - //! Indicates whether the item containing the address to be - //! relocated is part of a CPU instruction that uses PC-relative addressing. - //! - //! For addresses contained in PC-relative instructions, the CPU adds the address of - //! the instruction to the address contained in the instruction. + /// Indicates whether the item containing the address to be + /// relocated is part of a CPU instruction that uses PC-relative addressing. + /// + /// For addresses contained in PC-relative instructions, the CPU adds the address of + /// the instruction to the address contained in the instruction. bool is_pc_relative() const override; - //! Origin of the relocation. For this concrete object, it - //! should be Relocation::ORIGIN::DYLDINFO + /// Origin of the relocation. For this concrete object, it + /// should be Relocation::ORIGIN::DYLDINFO ORIGIN origin() const override { return ORIGIN::DYLDINFO; } diff --git a/include/LIEF/MachO/RelocationFixup.hpp b/include/LIEF/MachO/RelocationFixup.hpp index 170f95ca35..be7f499975 100644 --- a/include/LIEF/MachO/RelocationFixup.hpp +++ b/include/LIEF/MachO/RelocationFixup.hpp @@ -37,16 +37,16 @@ class BinaryParser; class Builder; class DyldChainedFixupsCreator; -//! Class that represents a rebase relocation found in the `LC_DYLD_CHAINED_FIXUPS` command. -//! -//! This class extends LIEF::Relocation in which LIEF::Relocation::address is set to -//! the absolute virtual address where the relocation must take place (e.g. `0x10000d270`). -//! -//! On the other hand, RelocationFixup::target contains the value that should be -//! set at LIEF::Relocation::address if the imagebase is LIEF::Binary::imagebase (e.g. `0x1000073a8`). -//! -//! If the Mach-O loader chooses another base address (like 0x7ff100000), it must set -//! `0x10000d270` to `0x7ff1073a8`. +/// Class that represents a rebase relocation found in the `LC_DYLD_CHAINED_FIXUPS` command. +/// +/// This class extends LIEF::Relocation in which LIEF::Relocation::address is set to +/// the absolute virtual address where the relocation must take place (e.g. `0x10000d270`). +/// +/// On the other hand, RelocationFixup::target contains the value that should be +/// set at LIEF::Relocation::address if the imagebase is LIEF::Binary::imagebase (e.g. `0x1000073a8`). +/// +/// If the Mach-O loader chooses another base address (like 0x7ff100000), it must set +/// `0x10000d270` to `0x7ff1073a8`. class LIEF_API RelocationFixup : public Relocation { friend class BinaryParser; @@ -69,13 +69,13 @@ class LIEF_API RelocationFixup : public Relocation { return std::unique_ptr(new RelocationFixup(*this)); } - //! Not relevant for this kind of relocation + /// Not relevant for this kind of relocation bool is_pc_relative() const override { return false; } - //! Origin of the relocation. For this concrete object, it - //! should be Relocation::ORIGIN::CHAINED_FIXUPS + /// Origin of the relocation. For this concrete object, it + /// should be Relocation::ORIGIN::CHAINED_FIXUPS ORIGIN origin() const override { return ORIGIN::CHAINED_FIXUPS; } @@ -84,13 +84,13 @@ class LIEF_API RelocationFixup : public Relocation { return ptr_fmt_; } - //! The value that should be set at the address pointed by LIEF::Relocation::address - //! if the imagebase chosen by the loader is LIEF::Binary::imagebase. - //! Otherwise: target() - LIEF::Binary::imagebase() + new_imagebase. + /// The value that should be set at the address pointed by LIEF::Relocation::address + /// if the imagebase chosen by the loader is LIEF::Binary::imagebase. + /// Otherwise: target() - LIEF::Binary::imagebase() + new_imagebase. uint64_t target() const; void target(uint64_t target); - //! Not relevant for this kind of relocation + /// Not relevant for this kind of relocation void pc_relative(bool) override {} uint32_t offset() const { @@ -101,20 +101,20 @@ class LIEF_API RelocationFixup : public Relocation { offset_ = offset; } - //! The address of this relocation is bound to its offset. + /// The address of this relocation is bound to its offset. uint64_t address() const override { return address_; } - //! Changing the address means changing the offset + /// Changing the address means changing the offset void address(uint64_t address) override { address_ = address; } - //! Return the (unscaled) next offset in the chain + /// Return the (unscaled) next offset in the chain uint32_t next() const; - //! Change next offset of the current element + /// Change next offset of the current element void next(uint32_t value); void accept(Visitor& visitor) const override; diff --git a/include/LIEF/MachO/RelocationObject.hpp b/include/LIEF/MachO/RelocationObject.hpp index 93546c3495..a67827ca0d 100644 --- a/include/LIEF/MachO/RelocationObject.hpp +++ b/include/LIEF/MachO/RelocationObject.hpp @@ -31,10 +31,10 @@ struct relocation_info; struct scattered_relocation_info; } -//! Class that represents a relocation presents in the MachO object -//! file (``.o``). Usually, this kind of relocation is found in the MachO::Section -//! -//! @see RelocationDyld +/// Class that represents a relocation presents in the MachO object +/// file (``.o``). Usually, this kind of relocation is found in the MachO::Section +/// +/// @see RelocationDyld class LIEF_API RelocationObject : public Relocation { friend class BinaryParser; @@ -56,34 +56,34 @@ class LIEF_API RelocationObject : public Relocation { return std::unique_ptr(new RelocationObject(*this)); } - //! Whether the relocation is PC relative + /// Whether the relocation is PC relative bool is_pc_relative() const override { return is_pcrel_; } - //! Size of the relocation + /// Size of the relocation size_t size() const override; - //! Address where the relocation is applied - //! This address is relative to the start of the section where the relocation takes place + /// Address where the relocation is applied + /// This address is relative to the start of the section where the relocation takes place uint64_t address() const override; - //! ``true`` if the relocation is a scattered one + /// ``true`` if the relocation is a scattered one bool is_scattered() const { return is_scattered_; } - //! For **scattered** relocations: - //! The address of the relocatable expression for the item in the file that needs - //! to be updated if the address is changed. - //! - //! For relocatable expressions with the difference of two section addresses, - //! the address from which to subtract (in mathematical terms, the minuend) - //! is contained in the first relocation entry and the address to subtract (the subtrahend) - //! is contained in the second relocation entry. + /// For **scattered** relocations: + /// The address of the relocatable expression for the item in the file that needs + /// to be updated if the address is changed. + /// + /// For relocatable expressions with the difference of two section addresses, + /// the address from which to subtract (in mathematical terms, the minuend) + /// is contained in the first relocation entry and the address to subtract (the subtrahend) + /// is contained in the second relocation entry. int32_t value() const; - //! Origin of the relocation. For this object it should be Relocation::ORIGIN::RELOC_TABLE) + /// Origin of the relocation. For this object it should be Relocation::ORIGIN::RELOC_TABLE) ORIGIN origin() const override { return ORIGIN::RELOC_TABLE; } diff --git a/include/LIEF/MachO/Section.hpp b/include/LIEF/MachO/Section.hpp index 817cf8e70b..c2e65ca7c2 100644 --- a/include/LIEF/MachO/Section.hpp +++ b/include/LIEF/MachO/Section.hpp @@ -42,7 +42,7 @@ struct section_32; struct section_64; } -//! Class that represents a Mach-O section +/// Class that represents a Mach-O section class LIEF_API Section : public LIEF::Section { friend class BinaryParser; @@ -52,13 +52,13 @@ class LIEF_API Section : public LIEF::Section { public: using content_t = std::vector; - //! Internal container for storing Mach-O Relocation + /// Internal container for storing Mach-O Relocation using relocations_t = std::vector>; - //! Iterator which outputs Relocation& + /// Iterator which outputs Relocation& using it_relocations = ref_iterator; - //! Iterator which outputs const Relocation& + /// Iterator which outputs const Relocation& using it_const_relocations = const_ref_iterator; static constexpr auto FLAGS_MASK = uint32_t(0xffffff00u); @@ -121,85 +121,85 @@ class LIEF_API Section : public LIEF::Section { span content() const override; - //! Update the content of the section + /// Update the content of the section void content(const content_t& data) override; - //! Return the name of the segment linked to this section + /// Return the name of the segment linked to this section const std::string& segment_name() const; - //! Virtual base address of the section + /// Virtual base address of the section uint64_t address() const { return virtual_address(); } - //! Section alignment as a power of 2 + /// Section alignment as a power of 2 uint32_t alignment() const { return align_; } - //! Offset of the relocation table. This value should be 0 - //! for executable and libraries as the relocations are managed by the DyldInfo::rebase - //! - //! On the other hand, for object files (``.o``) this value should not be 0 - //! - //! @see numberof_relocations - //! @see relocations + /// Offset of the relocation table. This value should be 0 + /// for executable and libraries as the relocations are managed by the DyldInfo::rebase + /// + /// On the other hand, for object files (``.o``) this value should not be 0 + /// + /// @see numberof_relocations + /// @see relocations uint32_t relocation_offset() const { return relocations_offset_; } - //! Number of relocations associated with this section + /// Number of relocations associated with this section uint32_t numberof_relocations() const { return nbof_relocations_; } - //! Section's flags masked with SECTION_FLAGS_MASK (see: Section::FLAGS) - //! - //! @see flags + /// Section's flags masked with SECTION_FLAGS_MASK (see: Section::FLAGS) + /// + /// @see flags FLAGS flags() const { return FLAGS(flags_ & FLAGS_MASK); } - //! Type of the section. This value can help to determine - //! the purpose of the section (e.g. MACHO_SECTION_TYPES::MACHO_SECTION_TYPES) + /// Type of the section. This value can help to determine + /// the purpose of the section (e.g. MACHO_SECTION_TYPES::MACHO_SECTION_TYPES) TYPE type() const { return TYPE(flags_ & TYPE_MASK); } - //! According to the official ``loader.h`` file, this value is reserved - //! for *offset* or *index* + /// According to the official ``loader.h`` file, this value is reserved + /// for *offset* or *index* uint32_t reserved1() const { return reserved1_; } - //! According to the official ``loader.h`` file, this value is reserved - //! for *count* or *sizeof* + /// According to the official ``loader.h`` file, this value is reserved + /// for *count* or *sizeof* uint32_t reserved2() const { return reserved2_; } - //! This value is only present for 64 bits Mach-O files. In that case, - //! the value is *reserved*. + /// This value is only present for 64 bits Mach-O files. In that case, + /// the value is *reserved*. uint32_t reserved3() const { return reserved3_; } - //! Return the Section::flags as a list of Section::FLAGS - //! @see flags + /// Return the Section::flags as a list of Section::FLAGS + /// @see flags std::vector flags_list() const; - //! Section flags without applying the SECTION_FLAGS_MASK mask + /// Section flags without applying the SECTION_FLAGS_MASK mask uint32_t raw_flags() const { return flags_; } - //! Check if this section is correctly linked with a MachO::SegmentCommand + /// Check if this section is correctly linked with a MachO::SegmentCommand bool has_segment() const { return segment() != nullptr; } - //! The segment associated with this section or a nullptr - //! if not present + /// The segment associated with this section or a nullptr + /// if not present SegmentCommand* segment() { return segment_; } @@ -207,17 +207,17 @@ class LIEF_API Section : public LIEF::Section { return segment_; } - //! Return a stream over the content of this section + /// Return a stream over the content of this section std::unique_ptr stream() const; - //! Clear the content of this section by filling its values - //! with the byte provided in parameter + /// Clear the content of this section by filling its values + /// with the byte provided in parameter void clear(uint8_t v); - //! Return an iterator over the MachO::Relocation associated with this section - //! - //! This iterator is likely to be empty of executable and libraries while it should not - //! for object files (``.o``) + /// Return an iterator over the MachO::Relocation associated with this section + /// + /// This iterator is likely to be empty of executable and libraries while it should not + /// for object files (``.o``) it_relocations relocations() { return relocations_; } @@ -255,13 +255,13 @@ class LIEF_API Section : public LIEF::Section { reserved3_ = reserved3; } - //! Check if the section has the given Section::FLAGS flag + /// Check if the section has the given Section::FLAGS flag bool has(FLAGS flag) const; - //! Append a Section::FLAGS to the current section + /// Append a Section::FLAGS to the current section void add(FLAGS flag); - //! Remove a Section::FLAGS to the current section + /// Remove a Section::FLAGS to the current section void remove(FLAGS flag); Section& operator+=(FLAGS flag) { diff --git a/include/LIEF/MachO/SegmentCommand.hpp b/include/LIEF/MachO/SegmentCommand.hpp index ad289f9ac9..b1417ad3a1 100644 --- a/include/LIEF/MachO/SegmentCommand.hpp +++ b/include/LIEF/MachO/SegmentCommand.hpp @@ -46,7 +46,7 @@ struct segment_command_32; struct segment_command_64; } -//! Class which represents a LoadCommand::TYPE::SEGMENT / LoadCommand::TYPE::SEGMENT_64 command +/// Class which represents a LoadCommand::TYPE::SEGMENT / LoadCommand::TYPE::SEGMENT_64 command class LIEF_API SegmentCommand : public LoadCommand { friend class DyldChainedFixupsCreator; @@ -58,22 +58,22 @@ class LIEF_API SegmentCommand : public LoadCommand { public: using content_t = std::vector; - //! Internal container for storing Mach-O Section + /// Internal container for storing Mach-O Section using sections_t = std::vector>; - //! Iterator which outputs Section& + /// Iterator which outputs Section& using it_sections = ref_iterator; - //! Iterator which outputs const Section& + /// Iterator which outputs const Section& using it_const_sections = const_ref_iterator; - //! Internal container for storing Mach-O Relocation + /// Internal container for storing Mach-O Relocation using relocations_t = std::vector>; - //! Iterator which outputs Relocation& + /// Iterator which outputs Relocation& using it_relocations = ref_iterator; - //! Iterator which outputs const Relocation& + /// Iterator which outputs const Relocation& using it_const_relocations = const_ref_iterator; enum class FLAGS: uint64_t { @@ -84,8 +84,8 @@ class LIEF_API SegmentCommand : public LoadCommand { READ_ONLY = 0x10u, }; - //! Values for segment_command.initprot. - //! From + /// Values for segment_command.initprot. + /// From enum class VM_PROTECTIONS { READ = 0x1, ///< Reading data within the segment is allowed WRITE = 0x2, ///< Writing data within the segment is allowed @@ -112,52 +112,52 @@ class LIEF_API SegmentCommand : public LoadCommand { ~SegmentCommand() override; - //! Name of the segment (e.g. ``__TEXT``) + /// Name of the segment (e.g. ``__TEXT``) const std::string& name() const { return name_; } - //! Absolute virtual base address of the segment + /// Absolute virtual base address of the segment uint64_t virtual_address() const { return virtual_address_; } - //! Virtual size of the segment + /// Virtual size of the segment uint64_t virtual_size() const { return virtual_size_; } - //! Size of this segment in the binary file + /// Size of this segment in the binary file uint64_t file_size() const { return file_size_; } - //! Offset of the data of this segment in the file + /// Offset of the data of this segment in the file uint64_t file_offset() const { return file_offset_; } - //! The maximum of protections for this segment (cf. VM_PROTECTIONS) + /// The maximum of protections for this segment (cf. VM_PROTECTIONS) uint32_t max_protection() const { return max_protection_; } - //! The initial protections of this segment (cf. VM_PROTECTIONS) + /// The initial protections of this segment (cf. VM_PROTECTIONS) uint32_t init_protection() const { return init_protection_; } - //! The number of sections associated with this segment + /// The number of sections associated with this segment uint32_t numberof_sections() const { return nb_sections_; } - //! Flags associated with this segment (cf. SegmentCommand::FLAGS) + /// Flags associated with this segment (cf. SegmentCommand::FLAGS) uint32_t flags() const { return flags_; } - //! Return an iterator over the MachO::Section linked to this segment + /// Return an iterator over the MachO::Section linked to this segment it_sections sections() { return sections_; } @@ -166,11 +166,11 @@ class LIEF_API SegmentCommand : public LoadCommand { return sections_; } - //! Return an iterator over the MachO::Relocation linked to this segment - //! - //! For Mach-O executable or library this iterator should be empty as - //! the relocations are managed by the Dyld::rebase_opcodes. - //! On the other hand, for object files (``.o``) this iterator should not be empty + /// Return an iterator over the MachO::Relocation linked to this segment + /// + /// For Mach-O executable or library this iterator should be empty as + /// the relocations are managed by the Dyld::rebase_opcodes. + /// On the other hand, for object files (``.o``) this iterator should not be empty it_relocations relocations() { return relocations_; } @@ -178,19 +178,19 @@ class LIEF_API SegmentCommand : public LoadCommand { return relocations_; } - //! Get the section with the given name + /// Get the section with the given name const Section* get_section(const std::string& name) const; Section* get_section(const std::string& name); - //! The raw content of this segment + /// The raw content of this segment span content() const { return data_; } - //! Return a stream over the content of this segment + /// Return a stream over the content of this segment std::unique_ptr stream() const; - //! The original index of this segment or -1 if not defined + /// The original index of this segment or -1 if not defined int8_t index() const { return this->index_; } @@ -226,16 +226,16 @@ class LIEF_API SegmentCommand : public LoadCommand { void content(content_t data); - //! Add a new section in this segment + /// Add a new section in this segment Section& add_section(const Section& section); - //! Remove all the sections linked to this segment + /// Remove all the sections linked to this segment void remove_all_sections(); - //! Check if the current segment embeds the given section + /// Check if the current segment embeds the given section bool has(const Section& section) const; - //! Check if the current segment embeds the given section name + /// Check if the current segment embeds the given section name bool has_section(const std::string& section_name) const; bool is(VM_PROTECTIONS prot) const { diff --git a/include/LIEF/MachO/SegmentSplitInfo.hpp b/include/LIEF/MachO/SegmentSplitInfo.hpp index 15c031824c..595acc6a3e 100644 --- a/include/LIEF/MachO/SegmentSplitInfo.hpp +++ b/include/LIEF/MachO/SegmentSplitInfo.hpp @@ -31,7 +31,7 @@ namespace details { struct linkedit_data_command; } -//! Class that represents the LoadCommand::TYPE::SEGMENT_SPLIT_INFO command +/// Class that represents the LoadCommand::TYPE::SEGMENT_SPLIT_INFO command class LIEF_API SegmentSplitInfo : public LoadCommand { friend class BinaryParser; friend class LinkEdit; diff --git a/include/LIEF/MachO/SourceVersion.hpp b/include/LIEF/MachO/SourceVersion.hpp index 1941396ba8..990e8da860 100644 --- a/include/LIEF/MachO/SourceVersion.hpp +++ b/include/LIEF/MachO/SourceVersion.hpp @@ -29,13 +29,13 @@ namespace details { struct source_version_command; } -//! Class that represents the MachO LoadCommand::TYPE::SOURCE_VERSION -//! This command is used to provide the *version* of the sources used to -//! build the binary +/// Class that represents the MachO LoadCommand::TYPE::SOURCE_VERSION +/// This command is used to provide the *version* of the sources used to +/// build the binary class LIEF_API SourceVersion : public LoadCommand { public: - //! Version is an array of **5** integers + /// Version is an array of **5** integers using version_t = std::array; SourceVersion() = default; @@ -50,7 +50,7 @@ class LIEF_API SourceVersion : public LoadCommand { ~SourceVersion() override = default; - //! Return the version as an array + /// Return the version as an array const version_t& version() const { return version_; } diff --git a/include/LIEF/MachO/SubClient.hpp b/include/LIEF/MachO/SubClient.hpp index 9b5fa9f582..7aaced2c9c 100644 --- a/include/LIEF/MachO/SubClient.hpp +++ b/include/LIEF/MachO/SubClient.hpp @@ -53,7 +53,7 @@ class LIEF_API SubClient : public LoadCommand { return std::unique_ptr(new SubClient(*this)); } - //! Name of the client + /// Name of the client const std::string& client() const { return client_; } diff --git a/include/LIEF/MachO/SubFramework.hpp b/include/LIEF/MachO/SubFramework.hpp index 20669b3810..d318e0cc31 100644 --- a/include/LIEF/MachO/SubFramework.hpp +++ b/include/LIEF/MachO/SubFramework.hpp @@ -31,18 +31,18 @@ namespace details { struct sub_framework_command; } -//! Class that represents the SubFramework command. -//! Accodring to the Mach-O ``loader.h`` documentation: -//! -//! -//! > A dynamically linked shared library may be a subframework of an umbrella -//! > framework. If so it will be linked with "-umbrella umbrella_name" where -//! > Where "umbrella_name" is the name of the umbrella framework. A subframework -//! > can only be linked against by its umbrella framework or other subframeworks -//! > that are part of the same umbrella framework. Otherwise the static link -//! > editor produces an error and states to link against the umbrella framework. -//! > The name of the umbrella framework for subframeworks is recorded in the -//! > following structure. +/// Class that represents the SubFramework command. +/// Accodring to the Mach-O ``loader.h`` documentation: +/// +/// +/// > A dynamically linked shared library may be a subframework of an umbrella +/// > framework. If so it will be linked with "-umbrella umbrella_name" where +/// > Where "umbrella_name" is the name of the umbrella framework. A subframework +/// > can only be linked against by its umbrella framework or other subframeworks +/// > that are part of the same umbrella framework. Otherwise the static link +/// > editor produces an error and states to link against the umbrella framework. +/// > The name of the umbrella framework for subframeworks is recorded in the +/// > following structure. class LIEF_API SubFramework : public LoadCommand { friend class BinaryParser; public: @@ -56,7 +56,7 @@ class LIEF_API SubFramework : public LoadCommand { return std::unique_ptr(new SubFramework(*this)); } - //! Name of the umbrella framework + /// Name of the umbrella framework const std::string& umbrella() const { return umbrella_; } diff --git a/include/LIEF/MachO/Symbol.hpp b/include/LIEF/MachO/Symbol.hpp index 2f4b90aa89..de00c35e82 100644 --- a/include/LIEF/MachO/Symbol.hpp +++ b/include/LIEF/MachO/Symbol.hpp @@ -38,12 +38,12 @@ struct nlist_32; struct nlist_64; } -//! Class that represents a Symbol in a Mach-O file. -//! -//! A Mach-O symbol can come from: -//! 1. The symbols command (LC_SYMTAB / SymbolCommand) -//! 2. The Dyld Export trie -//! 3. The Dyld Symbol bindings +/// Class that represents a Symbol in a Mach-O file. +/// +/// A Mach-O symbol can come from: +/// 1. The symbols command (LC_SYMTAB / SymbolCommand) +/// 2. The Dyld Export trie +/// 3. The Dyld Symbol bindings class LIEF_API Symbol : public LIEF::Symbol { friend class BinaryParser; @@ -54,8 +54,8 @@ class LIEF_API Symbol : public LIEF::Symbol { static constexpr int MAIN_EXECUTABLE_ORD = 0xff; // Mirror DYNAMIC_LOOKUP_ORDINAL static constexpr int DYNAMIC_LOOKUP_ORD = 0xfe; // EXECUTABLE_ORDINAL - //! Category of the symbol when the symbol comes from the `LC_SYMTAB` command. - //! The category is defined according to the `LC_DYSYMTAB` (DynamicSymbolCommand) command. + /// Category of the symbol when the symbol comes from the `LC_SYMTAB` command. + /// The category is defined according to the `LC_DYSYMTAB` (DynamicSymbolCommand) command. enum class CATEGORY : uint32_t { NONE = 0, LOCAL, @@ -83,7 +83,7 @@ class LIEF_API Symbol : public LIEF::Symbol { }; - //! Same as N_TYPE + /// Same as N_TYPE static constexpr uint32_t TYPE_MASK = 0x0e; Symbol() = default; @@ -115,35 +115,35 @@ class LIEF_API Symbol : public LIEF::Symbol { return (description() >> 8) & 0xff; } - //! Raw value of `nlist_xx.n_type` + /// Raw value of `nlist_xx.n_type` uint8_t raw_type() const { return type_; } - //! Type as defined by `nlist_xx.n_type & N_TYPE` + /// Type as defined by `nlist_xx.n_type & N_TYPE` TYPE type() const { return TYPE(type_ & TYPE_MASK); } - //! It returns the number of sections in which this symbol can be found. - //! If the symbol can't be found in any section, it returns 0 (NO_SECT) + /// It returns the number of sections in which this symbol can be found. + /// If the symbol can't be found in any section, it returns 0 (NO_SECT) uint8_t numberof_sections() const { return numberof_sections_; } - //! Return information about the symbol (SYMBOL_DESCRIPTIONS) + /// Return information about the symbol (SYMBOL_DESCRIPTIONS) uint16_t description() const { return description_; } - //! True if the symbol is associated with an ExportInfo - //! This value is set when the symbol comes from the Dyld Export trie + /// True if the symbol is associated with an ExportInfo + /// This value is set when the symbol comes from the Dyld Export trie bool has_export_info() const { return export_info() != nullptr; } - //! Return the ExportInfo associated with this symbol (or nullptr if not present) - //! @see has_export_info + /// Return the ExportInfo associated with this symbol (or nullptr if not present) + /// @see has_export_info const ExportInfo* export_info() const { return export_info_; } @@ -151,14 +151,14 @@ class LIEF_API Symbol : public LIEF::Symbol { return export_info_; } - //! True if the symbol is associated with a BindingInfo - //! This value is set when the symbol comes from the Dyld symbol bindings + /// True if the symbol is associated with a BindingInfo + /// This value is set when the symbol comes from the Dyld symbol bindings bool has_binding_info() const { return binding_info() != nullptr; } - //! Return the BindingInfo associated with this symbol (or nullptr if not present) - //! @see has_binding_info + /// Return the BindingInfo associated with this symbol (or nullptr if not present) + /// @see has_binding_info const BindingInfo* binding_info() const { return binding_info_; } @@ -167,16 +167,16 @@ class LIEF_API Symbol : public LIEF::Symbol { return binding_info_; } - //! Try to demangle the symbol or return an empty string if it is not possible + /// Try to demangle the symbol or return an empty string if it is not possible std::string demangled_name() const; - //! True if the symbol is defined as an external symbol. + /// True if the symbol is defined as an external symbol. bool is_external() const { return type() == TYPE::UNDEFINED; } - //! Return the library in which the symbol is defined. - //! It returns a null pointer if the library can't be resolved + /// Return the library in which the symbol is defined. + /// It returns a null pointer if the library can't be resolved const DylibCommand* library() const { return library_; } @@ -185,12 +185,12 @@ class LIEF_API Symbol : public LIEF::Symbol { return library_; } - //! Return the origin of the symbol: from LC_SYMTAB command or from the Dyld information + /// Return the origin of the symbol: from LC_SYMTAB command or from the Dyld information ORIGIN origin() const { return origin_; } - //! Category of the symbol according to the `LC_DYSYMTAB` command + /// Category of the symbol according to the `LC_DYSYMTAB` command CATEGORY category() const { return category_; } diff --git a/include/LIEF/MachO/SymbolCommand.hpp b/include/LIEF/MachO/SymbolCommand.hpp index e42c87d071..3b20204859 100644 --- a/include/LIEF/MachO/SymbolCommand.hpp +++ b/include/LIEF/MachO/SymbolCommand.hpp @@ -31,7 +31,7 @@ namespace details { struct symtab_command; } -//! Class that represents the LC_SYMTAB command +/// Class that represents the LC_SYMTAB command class LIEF_API SymbolCommand : public LoadCommand { friend class BinaryParser; friend class LinkEdit; @@ -49,22 +49,22 @@ class LIEF_API SymbolCommand : public LoadCommand { ~SymbolCommand() override = default; - //! Offset from the start of the file to the n_list associated with the command + /// Offset from the start of the file to the n_list associated with the command uint32_t symbol_offset() const { return symbols_offset_; } - //! Number of symbols registered + /// Number of symbols registered uint32_t numberof_symbols() const { return nb_symbols_; } - //! Offset from the start of the file to the string table + /// Offset from the start of the file to the string table uint32_t strings_offset() const { return strings_offset_; } - //! Size of the size string table + /// Size of the size string table uint32_t strings_size() const { return strings_size_; } diff --git a/include/LIEF/MachO/ThreadCommand.hpp b/include/LIEF/MachO/ThreadCommand.hpp index b2974cbd03..e5f38ff615 100644 --- a/include/LIEF/MachO/ThreadCommand.hpp +++ b/include/LIEF/MachO/ThreadCommand.hpp @@ -33,11 +33,11 @@ namespace details { struct thread_command; } -//! Class that represents the LC_THREAD / LC_UNIXTHREAD commands and that -//! can be used to get the binary entrypoint when the LC_MAIN (MainCommand) is not present -//! -//! Generally speaking, this command aims at defining the original state -//! of the main thread which includes the registers' values +/// Class that represents the LC_THREAD / LC_UNIXTHREAD commands and that +/// can be used to get the binary entrypoint when the LC_MAIN (MainCommand) is not present +/// +/// Generally speaking, this command aims at defining the original state +/// of the main thread which includes the registers' values class LIEF_API ThreadCommand : public LoadCommand { friend class BinaryParser; public: @@ -56,30 +56,30 @@ class LIEF_API ThreadCommand : public LoadCommand { ~ThreadCommand() override = default; - //! Integer that defines a special *flavor* for the thread. - //! - //! The meaning of this value depends on the architecture(). The list of - //! the values can be found in the XNU kernel files: - //! - xnu/osfmk/mach/arm/thread_status.h for the ARM/AArch64 architectures - //! - xnu/osfmk/mach/i386/thread_status.h for the x86/x86-64 architectures + /// Integer that defines a special *flavor* for the thread. + /// + /// The meaning of this value depends on the architecture(). The list of + /// the values can be found in the XNU kernel files: + /// - xnu/osfmk/mach/arm/thread_status.h for the ARM/AArch64 architectures + /// - xnu/osfmk/mach/i386/thread_status.h for the x86/x86-64 architectures uint32_t flavor() const { return flavor_; } - //! Size of the thread state data with 32-bits alignment. - //! - //! This value should match state().size() + /// Size of the thread state data with 32-bits alignment. + /// + /// This value should match state().size() uint32_t count() const { return count_; } - //! The CPU architecture that is targeted by this ThreadCommand + /// The CPU architecture that is targeted by this ThreadCommand Header::CPU_TYPE architecture() const { return architecture_; } - //! The actual thread state as a vector of bytes. Depending on the architecture(), - //! these data can be casted into x86_thread_state_t, x86_thread_state64_t, ... + /// The actual thread state as a vector of bytes. Depending on the architecture(), + /// these data can be casted into x86_thread_state_t, x86_thread_state64_t, ... span state() const { return state_; } @@ -88,10 +88,10 @@ class LIEF_API ThreadCommand : public LoadCommand { return state_; } - //! Return the initial Program Counter regardless of the underlying architecture. - //! This value, when non null, can be used to determine the binary's entrypoint. - //! - //! Underneath, it works by looking for the PC register value in the state() data + /// Return the initial Program Counter regardless of the underlying architecture. + /// This value, when non null, can be used to determine the binary's entrypoint. + /// + /// Underneath, it works by looking for the PC register value in the state() data uint64_t pc() const; void state(std::vector state) { diff --git a/include/LIEF/MachO/TwoLevelHints.hpp b/include/LIEF/MachO/TwoLevelHints.hpp index b8ed86bef5..fe9fdc15a3 100644 --- a/include/LIEF/MachO/TwoLevelHints.hpp +++ b/include/LIEF/MachO/TwoLevelHints.hpp @@ -35,7 +35,7 @@ namespace details { struct twolevel_hints_command; } -//! Class which represents the `LC_TWOLEVEL_HINTS` command +/// Class which represents the `LC_TWOLEVEL_HINTS` command class LIEF_API TwoLevelHints : public LoadCommand { friend class BinaryParser; friend class LinkEdit; @@ -56,16 +56,16 @@ class LIEF_API TwoLevelHints : public LoadCommand { return std::unique_ptr(new TwoLevelHints(*this)); } - //! Original payload of the command + /// Original payload of the command span content() const { return content_; } span content() { return content_; } - //! Iterator over the hints (`uint32_t` integers) + /// Iterator over the hints (`uint32_t` integers) it_hints_t hints() { return hints_; } it_const_hints_t hints() const { return hints_; } - //! Original offset of the command. It should point in the - //! `__LINKEDIT` segment + /// Original offset of the command. It should point in the + /// `__LINKEDIT` segment uint32_t offset() const { return offset_; } void offset(uint32_t offset) { offset_ = offset; } diff --git a/include/LIEF/MachO/UUIDCommand.hpp b/include/LIEF/MachO/UUIDCommand.hpp index 12bb625910..506ad1b028 100644 --- a/include/LIEF/MachO/UUIDCommand.hpp +++ b/include/LIEF/MachO/UUIDCommand.hpp @@ -31,7 +31,7 @@ struct uuid_command; using uuid_t = std::array; -//! Class that represents the UUID command +/// Class that represents the UUID command class LIEF_API UUIDCommand : public LoadCommand { public: UUIDCommand() = default; @@ -46,7 +46,7 @@ class LIEF_API UUIDCommand : public LoadCommand { ~UUIDCommand() override = default; - //! The UUID as a 16-bytes array + /// The UUID as a 16-bytes array const uuid_t& uuid() const { return uuid_; } diff --git a/include/LIEF/MachO/UnknownCommand.hpp b/include/LIEF/MachO/UnknownCommand.hpp index 8476601ec1..9643283a58 100644 --- a/include/LIEF/MachO/UnknownCommand.hpp +++ b/include/LIEF/MachO/UnknownCommand.hpp @@ -28,7 +28,7 @@ struct load_command; } -//! Generic class when the command is not recognized by LIEF +/// Generic class when the command is not recognized by LIEF class LIEF_API UnknownCommand : public LoadCommand { public: diff --git a/include/LIEF/MachO/VersionMin.hpp b/include/LIEF/MachO/VersionMin.hpp index 2480d88fa4..e62ff2ada4 100644 --- a/include/LIEF/MachO/VersionMin.hpp +++ b/include/LIEF/MachO/VersionMin.hpp @@ -29,11 +29,11 @@ namespace details { struct version_min_command; } -//! Class that wraps the LC_VERSION_MIN_MACOSX, LC_VERSION_MIN_IPHONEOS, ... commands. +/// Class that wraps the LC_VERSION_MIN_MACOSX, LC_VERSION_MIN_IPHONEOS, ... commands. class LIEF_API VersionMin : public LoadCommand { public: - //! Version is an array of **3** integers + /// Version is an array of **3** integers using version_t = std::array; VersionMin() = default; @@ -48,7 +48,7 @@ class LIEF_API VersionMin : public LoadCommand { ~VersionMin() override = default; - //! Return the version as an array + /// Return the version as an array const version_t& version() const { return version_; } @@ -56,7 +56,7 @@ class LIEF_API VersionMin : public LoadCommand { version_ = version; } - //! Return the sdk version as an array + /// Return the sdk version as an array const version_t& sdk() const { return sdk_; } diff --git a/include/LIEF/MachO/hash.hpp b/include/LIEF/MachO/hash.hpp index 2bdb77c4bf..dea0ef0e52 100644 --- a/include/LIEF/MachO/hash.hpp +++ b/include/LIEF/MachO/hash.hpp @@ -64,8 +64,8 @@ class UUIDCommand; class VersionMin; class UnknownCommand; -//! Class which implements a visitor to compute -//! a **deterministic** hash for LIEF MachO objects +/// Class which implements a visitor to compute +/// a **deterministic** hash for LIEF MachO objects class LIEF_API Hash : public LIEF::Hash { public: static LIEF::Hash::value_type hash(const Object& obj); diff --git a/include/LIEF/MachO/utils.hpp b/include/LIEF/MachO/utils.hpp index 7ccf208507..0c92fc9428 100644 --- a/include/LIEF/MachO/utils.hpp +++ b/include/LIEF/MachO/utils.hpp @@ -29,29 +29,29 @@ namespace MachO { class Binary; class FatBinary; -//! Check if the given stream wraps a Mach-O binary +/// Check if the given stream wraps a Mach-O binary LIEF_API bool is_macho(BinaryStream& stream); -//! Check if the given file is a Mach-O binary +/// Check if the given file is a Mach-O binary LIEF_API bool is_macho(const std::string& file); -//! Check if the given raw data is a Mach-O binary +/// Check if the given raw data is a Mach-O binary LIEF_API bool is_macho(const std::vector& raw); -//! Check if the given file is a FAT Mach-O +/// Check if the given file is a FAT Mach-O LIEF_API bool is_fat(const std::string& file); -//! Check if the given Mach-O is 64-bits +/// Check if the given Mach-O is 64-bits LIEF_API bool is_64(const std::string& file); LIEF_API bool is_64(BinaryStream& stream); -//! Check the layout of the given Mach-O binary. It checks if it can be signed -//! according to cctools-921/libstuff/checkout.c +/// Check the layout of the given Mach-O binary. It checks if it can be signed +/// according to cctools-921/libstuff/checkout.c LIEF_API bool check_layout(const Binary& binary, std::string* error = nullptr); -//! Check the layout of the given FAT Mach-O by checking individually the layout -//! of the binaries embedded in the FAT +/// Check the layout of the given FAT Mach-O by checking individually the layout +/// of the binaries embedded in the FAT LIEF_API bool check_layout(const FatBinary& binary, std::string* error = nullptr); diff --git a/include/LIEF/OAT/Binary.hpp b/include/LIEF/OAT/Binary.hpp index 69ef9f9354..7e04a48f06 100644 --- a/include/LIEF/OAT/Binary.hpp +++ b/include/LIEF/OAT/Binary.hpp @@ -65,39 +65,39 @@ class LIEF_API Binary : public ELF::Binary { Binary& operator=(const Binary& copy) = delete; Binary(const Binary& copy) = delete; - //! OAT Header + /// OAT Header const Header& header() const; Header& header(); - //! Iterator over LIEF::DEX::File + /// Iterator over LIEF::DEX::File it_dex_files dex_files(); it_const_dex_files dex_files() const; - //! Iterator over LIEF::OAT::DexFile + /// Iterator over LIEF::OAT::DexFile it_oat_dex_files oat_dex_files(); it_const_oat_dex_files oat_dex_files() const; - //! Iterator over LIEF::OAT::Class + /// Iterator over LIEF::OAT::Class it_const_classes classes() const; it_classes classes(); - //! Check if the current OAT has the given class + /// Check if the current OAT has the given class bool has_class(const std::string& class_name) const; - //! Return the LIEF::OAT::Class with the given name or - //! a nullptr if the class can't be found + /// Return the LIEF::OAT::Class with the given name or + /// a nullptr if the class can't be found const Class* get_class(const std::string& class_name) const; Class* get_class(const std::string& class_name); - //! Return the LIEF::OAT::Class at the given index or a nullptr - //! if it does not exist + /// Return the LIEF::OAT::Class at the given index or a nullptr + /// if it does not exist const Class* get_class(size_t index) const; Class* get_class(size_t index); - //! Iterator over LIEF::OAT::Method + /// Iterator over LIEF::OAT::Method it_const_methods methods() const; it_methods methods(); diff --git a/include/LIEF/OAT/Header.hpp b/include/LIEF/OAT/Header.hpp index d52e0fe386..9d31b3731e 100644 --- a/include/LIEF/OAT/Header.hpp +++ b/include/LIEF/OAT/Header.hpp @@ -49,12 +49,12 @@ class LIEF_API Header : public Object { using it_key_values_t = ref_iterator>; using it_const_key_values_t = const_ref_iterator>; - //! @brief Iterator type over + /// Iterator type over using keys_t = std::vector; using values_t = std::vector; public: - //! Return the string value associated with the given key + /// Return the string value associated with the given key static std::string key_to_string(HEADER_KEYS key); public: @@ -65,10 +65,10 @@ class LIEF_API Header : public Object { template LIEF_LOCAL Header(const T* header); - //! Magic value: ``oat`` + /// Magic value: ``oat`` Header::magic_t magic() const; - //! OAT version + /// OAT version oat_version_t version() const; uint32_t checksum() const; diff --git a/include/LIEF/OAT/Method.hpp b/include/LIEF/OAT/Method.hpp index 93d7ba0779..a995857d34 100644 --- a/include/LIEF/OAT/Method.hpp +++ b/include/LIEF/OAT/Method.hpp @@ -35,7 +35,7 @@ class LIEF_API Method : public Object { friend class Parser; public: - //! Container for the Quick Code + /// Container for the Quick Code using quick_code_t = std::vector; public: @@ -45,22 +45,22 @@ class LIEF_API Method : public Object { Method& operator=(const Method&); - //! Method's name + /// Method's name std::string name() const; - //! OAT Class associated with this Method + /// OAT Class associated with this Method const Class* oat_class() const; Class* oat_class(); - //! Check if a LIEF::DEX::Method is associated with - //! this Method + /// Check if a LIEF::DEX::Method is associated with + /// this Method bool has_dex_method() const; - //! LIEF::DEX::Method associated (if any) + /// LIEF::DEX::Method associated (if any) const DEX::Method* dex_method() const; DEX::Method* dex_method(); - //! True if the optimization is DEX + /// True if the optimization is DEX bool is_dex2dex_optimized() const; // True if the optimization is native @@ -68,7 +68,7 @@ class LIEF_API Method : public Object { const DEX::dex2dex_method_info_t& dex2dex_info() const; - //! Quick code associated with the method + /// Quick code associated with the method const quick_code_t& quick_code() const; void quick_code(const quick_code_t& code); diff --git a/include/LIEF/OAT/Parser.hpp b/include/LIEF/OAT/Parser.hpp index 6cf64dd9ac..4b90c6f7b4 100644 --- a/include/LIEF/OAT/Parser.hpp +++ b/include/LIEF/OAT/Parser.hpp @@ -34,10 +34,10 @@ namespace OAT { class Binary; class Class; -//! Class to parse an OAT file to produce an OAT::Binary +/// Class to parse an OAT file to produce an OAT::Binary class LIEF_API Parser : public ELF::Parser { public: - //! Parse an OAT file + /// Parse an OAT file static std::unique_ptr parse(const std::string& oat_file); static std::unique_ptr parse(const std::string& oat_file, const std::string& vdex_file); diff --git a/include/LIEF/OAT/enums.hpp b/include/LIEF/OAT/enums.hpp index 0724bee870..8d3b9100b4 100644 --- a/include/LIEF/OAT/enums.hpp +++ b/include/LIEF/OAT/enums.hpp @@ -20,9 +20,9 @@ namespace LIEF { namespace OAT { enum OAT_CLASS_TYPES { - OAT_CLASS_ALL_COMPILED = 0, //! OatClass is followed by an OatMethodOffsets for each method. - OAT_CLASS_SOME_COMPILED = 1, //! A bitmap of which OatMethodOffsets are present follows the OatClass. - OAT_CLASS_NONE_COMPILED = 2, //! All methods are interpreted so no OatMethodOffsets are necessary. + OAT_CLASS_ALL_COMPILED = 0, /// OatClass is followed by an OatMethodOffsets for each method. + OAT_CLASS_SOME_COMPILED = 1, /// A bitmap of which OatMethodOffsets are present follows the OatClass. + OAT_CLASS_NONE_COMPILED = 2, /// All methods are interpreted so no OatMethodOffsets are necessary. }; // From art/runtime/mirror/class.h diff --git a/include/LIEF/OAT/utils.hpp b/include/LIEF/OAT/utils.hpp index 5b0e02a11f..6df42ef415 100644 --- a/include/LIEF/OAT/utils.hpp +++ b/include/LIEF/OAT/utils.hpp @@ -31,25 +31,25 @@ class Binary; } namespace OAT { -//! @brief Check if the given LIEF::ELF::Binary is an OAT one. +/// Check if the given LIEF::ELF::Binary is an OAT one. LIEF_API bool is_oat(const LIEF::ELF::Binary& elf_binary); -//! @brief Check if the given file is an OAT one. +/// Check if the given file is an OAT one. LIEF_API bool is_oat(const std::string& file); -//! @brief Check if the given raw data is an OAT one. +/// Check if the given raw data is an OAT one. LIEF_API bool is_oat(const std::vector& raw); -//! @brief Return the OAT version of the given file +/// Return the OAT version of the given file LIEF_API oat_version_t version(const std::string& file); -//! @brief Return the OAT version of the raw data +/// Return the OAT version of the raw data LIEF_API oat_version_t version(const std::vector& raw); -//! @brief Return the OAT version of the given LIEF::ELF::Binary +/// Return the OAT version of the given LIEF::ELF::Binary LIEF_API oat_version_t version(const LIEF::ELF::Binary& elf_binary); -//! @brief Return the ANDROID_VERSIONS associated with the given OAT version +/// Return the ANDROID_VERSIONS associated with the given OAT version LIEF_API LIEF::Android::ANDROID_VERSIONS android_version(oat_version_t version); diff --git a/include/LIEF/PE/Binary.hpp b/include/LIEF/PE/Binary.hpp index b1f24b8b0d..ec93f76896 100644 --- a/include/LIEF/PE/Binary.hpp +++ b/include/LIEF/PE/Binary.hpp @@ -32,7 +32,7 @@ namespace LIEF { -//! Namespace related to the LIEF's PE module +/// Namespace related to the LIEF's PE module namespace PE { class Builder; class CodeViewPDB; @@ -47,143 +47,143 @@ class ResourceNode; class RichHeader; class TLS; -//! Class which represents a PE binary -//! This is the main interface to manage and modify a PE executable +/// Class which represents a PE binary +/// This is the main interface to manage and modify a PE executable class LIEF_API Binary : public LIEF::Binary { friend class Parser; friend class Builder; public: - //! Internal container for storing PE's Section + /// Internal container for storing PE's Section using sections_t = std::vector>; - //! Iterator that outputs Section& object + /// Iterator that outputs Section& object using it_sections = ref_iterator; - //! Iterator that outputs const Section& object + /// Iterator that outputs const Section& object using it_const_sections = const_ref_iterator; - //! Internal container for storing PE's DataDirectory + /// Internal container for storing PE's DataDirectory using data_directories_t = std::vector>; - //! Iterator that outputs DataDirectory& + /// Iterator that outputs DataDirectory& using it_data_directories = ref_iterator; - //! Iterator that outputs const DataDirectory& + /// Iterator that outputs const DataDirectory& using it_const_data_directories = const_ref_iterator; - //! Internal container for storing PE's Relocation + /// Internal container for storing PE's Relocation using relocations_t = std::vector>; - //! Iterator that outputs Relocation& + /// Iterator that outputs Relocation& using it_relocations = ref_iterator; - //! Iterator that outputs const Relocation& + /// Iterator that outputs const Relocation& using it_const_relocations = const_ref_iterator; - //! Internal container for storing PE's Import + /// Internal container for storing PE's Import using imports_t = std::vector; - //! Iterator that output Import& + /// Iterator that output Import& using it_imports = ref_iterator; - //! Iterator that outputs const Import& + /// Iterator that outputs const Import& using it_const_imports = const_ref_iterator; - //! Internal container for storing PE's DelayImport + /// Internal container for storing PE's DelayImport using delay_imports_t = std::vector; - //! Iterator that output DelayImport& + /// Iterator that output DelayImport& using it_delay_imports = ref_iterator; - //! Iterator that outputs const DelayImport& + /// Iterator that outputs const DelayImport& using it_const_delay_imports = const_ref_iterator; - //! Internal container for storing Debug information + /// Internal container for storing Debug information using debug_entries_t = std::vector>; - //! Iterator that outputs Debug& + /// Iterator that outputs Debug& using it_debug_entries = ref_iterator; - //! Iterator that outputs const Debug& + /// Iterator that outputs const Debug& using it_const_debug_entries = const_ref_iterator; - //! Internal container for storing COFF Symbols + /// Internal container for storing COFF Symbols using symbols_t = std::vector; - //! Iterator that outputs Symbol& + /// Iterator that outputs Symbol& using it_symbols = ref_iterator; - //! Iterator that outputs const Symbol& + /// Iterator that outputs const Symbol& using it_const_symbols = const_ref_iterator; - //! Internal container for storing strings + /// Internal container for storing strings using strings_table_t = std::vector; - //! Iterator that outputs std::string& + /// Iterator that outputs std::string& using it_strings_table = ref_iterator; - //! Iterator that outputs const std::string& + /// Iterator that outputs const std::string& using it_const_strings_table = const_ref_iterator; - //! Internal container for storing PE's authenticode Signature + /// Internal container for storing PE's authenticode Signature using signatures_t = std::vector; - //! Iterator that outputs Signature& + /// Iterator that outputs Signature& using it_signatures = ref_iterator; - //! Iterator that outputs const Signature& + /// Iterator that outputs const Signature& using it_const_signatures = const_ref_iterator; Binary(PE_TYPE type); ~Binary() override; - //! Return `PE32` or `PE32+` + /// Return `PE32` or `PE32+` PE_TYPE type() const { return type_; } - //! Convert a Relative Virtual Address into an offset - //! - //! The conversion is performed by looking for the section that - //! encompasses the provided RVA. + /// Convert a Relative Virtual Address into an offset + /// + /// The conversion is performed by looking for the section that + /// encompasses the provided RVA. uint64_t rva_to_offset(uint64_t RVA) const; - //! Convert the **absolute** virtual address into an offset. - //! @see rva_to_offset + /// Convert the **absolute** virtual address into an offset. + /// @see rva_to_offset uint64_t va_to_offset(uint64_t VA) const; - //! Convert the given offset into a virtual address. - //! - //! @param[in] offset The offset to convert. - //! @param[in] slide If not 0, it will replace the default base address (if any) + /// Convert the given offset into a virtual address. + /// + /// @param[in] offset The offset to convert. + /// @param[in] slide If not 0, it will replace the default base address (if any) result offset_to_virtual_address(uint64_t offset, uint64_t slide = 0) const override; - //! Return binary's imagebase. ``0`` if not relevant - //! - //! The value is the same as those returned by OptionalHeader::imagebase + /// Return binary's imagebase. ``0`` if not relevant + /// + /// The value is the same as those returned by OptionalHeader::imagebase uint64_t imagebase() const override { return optional_header().imagebase(); } - //! Find the section associated that encompasses the given offset. - //! - //! If no section can be found, return a nullptr + /// Find the section associated that encompasses the given offset. + /// + /// If no section can be found, return a nullptr Section* section_from_offset(uint64_t offset) { return const_cast(static_cast(this)->section_from_offset(offset)); } const Section* section_from_offset(uint64_t offset) const; - //! Find the section associated that encompasses the given RVA. - //! - //! If no section can be found, return a nullptr + /// Find the section associated that encompasses the given RVA. + /// + /// If no section can be found, return a nullptr Section* section_from_rva(uint64_t virtual_address) { return const_cast(static_cast(this)->section_from_rva(virtual_address)); } const Section* section_from_rva(uint64_t virtual_address) const; - //! Return an iterator over the PE's Section + /// Return an iterator over the PE's Section it_sections sections() { return sections_; } @@ -192,7 +192,7 @@ class LIEF_API Binary : public LIEF::Binary { return sections_; } - //! Return a reference to the PE::DosHeader object + /// Return a reference to the PE::DosHeader object DosHeader& dos_header() { return dos_header_; } @@ -201,7 +201,7 @@ class LIEF_API Binary : public LIEF::Binary { return dos_header_; } - //! Return a reference to the PE::Header object + /// Return a reference to the PE::Header object Header& header() { return header_; } @@ -210,8 +210,8 @@ class LIEF_API Binary : public LIEF::Binary { return header_; } - //! Header that follows the header(). It is named optional from the COFF - //! specfication but it is mandatory in a PE file. + /// Header that follows the header(). It is named optional from the COFF + /// specfication but it is mandatory in a PE file. OptionalHeader& optional_header() { return optional_header_; } @@ -220,21 +220,21 @@ class LIEF_API Binary : public LIEF::Binary { return optional_header_; } - //! Re-compute the value of OptionalHeader::checksum. - //! If both values do not match, it could mean that the binary has been modified - //! after the compilation. - //! - //! This value is computed by LIEF for the current binary object. + /// Re-compute the value of OptionalHeader::checksum. + /// If both values do not match, it could mean that the binary has been modified + /// after the compilation. + /// + /// This value is computed by LIEF for the current binary object. uint32_t compute_checksum() const; - //! Compute the binary's virtual size. - //! It should match OptionalHeader::sizeof_image + /// Compute the binary's virtual size. + /// It should match OptionalHeader::sizeof_image uint64_t virtual_size() const; - //! Compute the size of all the headers + /// Compute the size of all the headers uint32_t sizeof_headers() const; - //! Return a reference to the TLS object + /// Return a reference to the TLS object TLS* tls() { return tls_.get(); } @@ -243,68 +243,68 @@ class LIEF_API Binary : public LIEF::Binary { return tls_.get(); } - //! Set a TLS object in the current Binary + /// Set a TLS object in the current Binary void tls(const TLS& tls); - //! Check if the current binary has a TLS object + /// Check if the current binary has a TLS object bool has_tls() const { return tls_ != nullptr; } - //! Check if the current binary contains imports - //! - //! @see Import + /// Check if the current binary contains imports + /// + /// @see Import bool has_imports() const { return !imports_.empty(); } - //! Check if the current binary contains signatures - //! - //! @see signatures + /// Check if the current binary contains signatures + /// + /// @see signatures bool has_signatures() const { return !signatures_.empty(); } - //! Check if the current binary has exports. - //! - //! @see Export + /// Check if the current binary has exports. + /// + /// @see Export bool has_exports() const { return export_ != nullptr; } - //! Check if the current binary has resources + /// Check if the current binary has resources bool has_resources() const { return resources_ != nullptr; } - //! Check if the current binary has exceptions + /// Check if the current binary has exceptions bool has_exceptions() const { return has(DataDirectory::TYPES::EXCEPTION_TABLE); } - //! Check if the current binary has relocations - //! - //! @see Relocation + /// Check if the current binary has relocations + /// + /// @see Relocation bool has_relocations() const { return !relocations_.empty(); } - //! Check if the current binary contains debug information + /// Check if the current binary contains debug information bool has_debug() const { return !debug_.empty(); } - //! Check if the current binary has a load configuration + /// Check if the current binary has a load configuration bool has_configuration() const { return load_configuration_ != nullptr; } - //! Check if the current binary is *reproducible build*, replacing timestamps by a compile hash. - //! - //! @see Repro + /// Check if the current binary is *reproducible build*, replacing timestamps by a compile hash. + /// + /// @see Repro bool is_reproducible_build() const; - //! Return an iterator over the Signature object(s) if the binary is signed + /// Return an iterator over the Signature object(s) if the binary is signed it_const_signatures signatures() const { return signatures_; } @@ -313,47 +313,47 @@ class LIEF_API Binary : public LIEF::Binary { return signatures_; } - //! Verify the binary against the embedded signature(s) (if any) - //! First, it checks that the embedded signatures are correct (c.f. Signature::check) - //! and then, it checks that the authentihash matches ContentInfo::digest - //! - //! One can tweak the verification process with the Signature::VERIFICATION_CHECKS flags - //! - //! @see LIEF::PE::Signature::check + /// Verify the binary against the embedded signature(s) (if any) + /// First, it checks that the embedded signatures are correct (c.f. Signature::check) + /// and then, it checks that the authentihash matches ContentInfo::digest + /// + /// One can tweak the verification process with the Signature::VERIFICATION_CHECKS flags + /// + /// @see LIEF::PE::Signature::check Signature::VERIFICATION_FLAGS verify_signature( Signature::VERIFICATION_CHECKS checks = Signature::VERIFICATION_CHECKS::DEFAULT) const; - //! Verify the binary with the Signature object provided in the first parameter. - //! It can be used to verify a detached signature: - //! - //! \code{.cpp} - //! result detached = LIEF::PE::SignatureParser::parse("sig.pkcs7") - //! if (detached) { - //! binary->verify_signature(detached.value()); - //! } - //! \endcode + /// Verify the binary with the Signature object provided in the first parameter. + /// It can be used to verify a detached signature: + /// + /// \code{.cpp} + /// result detached = LIEF::PE::SignatureParser::parse("sig.pkcs7") + /// if (detached) { + /// binary->verify_signature(detached.value()); + /// } + /// \endcode Signature::VERIFICATION_FLAGS verify_signature(const Signature& sig, Signature::VERIFICATION_CHECKS checks = Signature::VERIFICATION_CHECKS::DEFAULT) const; - //! Compute the authentihash according to the algorithm provided in the first - //! parameter + /// Compute the authentihash according to the algorithm provided in the first + /// parameter std::vector authentihash(ALGORITHMS algo) const; - //! Try to predict the RVA of the function `function` in the import library `library` - //! - //! @warning - //! The value could be chang if imports change - //! - //! @note - //! It should be used with: - //! LIEF::PE::Builder::build_imports set to ``true`` - //! - //! @param[in] library Library name in which the function is located - //! @param[in] function Function name - //! @return The address of the function (``IAT``) in the new import table + /// Try to predict the RVA of the function `function` in the import library `library` + /// + /// @warning + /// The value could be chang if imports change + /// + /// @note + /// It should be used with: + /// LIEF::PE::Builder::build_imports set to ``true`` + /// + /// @param[in] library Library name in which the function is located + /// @param[in] function Function name + /// @return The address of the function (``IAT``) in the new import table uint32_t predict_function_rva(const std::string& library, const std::string& function); - //! Return the Export object + /// Return the Export object Export* get_export() { return export_.get(); } @@ -362,7 +362,7 @@ class LIEF_API Binary : public LIEF::Binary { return export_.get(); } - //! Return binary Symbols + /// Return binary Symbols std::vector& symbols() { return symbols_; } @@ -371,7 +371,7 @@ class LIEF_API Binary : public LIEF::Binary { return symbols_; } - //! Return resources as a tree or a nullptr if there is no resources + /// Return resources as a tree or a nullptr if there is no resources ResourceNode* resources() { return resources_.get(); } @@ -380,48 +380,48 @@ class LIEF_API Binary : public LIEF::Binary { return resources_.get(); } - //! Set a new resource tree + /// Set a new resource tree void set_resources(const ResourceDirectory& resource); - //! Set a new resource tree + /// Set a new resource tree void set_resources(const ResourceData& resource); - //! Return the ResourcesManager (class to manage resources more easily than the tree one) + /// Return the ResourcesManager (class to manage resources more easily than the tree one) result resources_manager() const; - //! Return binary's section from its name. - //! If the secion can't be found, return a nullptr - //! - //! @param[in] name Name of the Section + /// Return binary's section from its name. + /// If the secion can't be found, return a nullptr + /// + /// @param[in] name Name of the Section Section* get_section(const std::string& name) { return const_cast(static_cast(this)->get_section(name)); } const Section* get_section(const std::string& name) const; - //! Return the section associated with import table or a - //! nullptr if the binary does not have an import table + /// Return the section associated with import table or a + /// nullptr if the binary does not have an import table const Section* import_section() const; Section* import_section() { return const_cast(static_cast(this)->import_section()); } - //! Delete the section with the given name - //! - //! @param[in] name Name of section to delete - //! @param[in] clear if ``true`` clear the section's content with 0 - //! before removing (default: ``false``) + /// Delete the section with the given name + /// + /// @param[in] name Name of section to delete + /// @param[in] clear if ``true`` clear the section's content with 0 + /// before removing (default: ``false``) void remove_section(const std::string& name, bool clear = false) override; - //! Remove the given section - //! - //! @see remove_section + /// Remove the given section + /// + /// @see remove_section void remove(const Section& section, bool clear = false); - //! Add a section to the binary and return the section added. + /// Add a section to the binary and return the section added. Section* add_section(const Section& section, PE_SECTION_TYPES type = PE_SECTION_TYPES::UNKNOWN); - //! Return an iterator over the PE's Relocation + /// Return an iterator over the PE's Relocation it_relocations relocations() { return relocations_; } @@ -430,13 +430,13 @@ class LIEF_API Binary : public LIEF::Binary { return relocations_; } - //! Add a PE::Relocation + /// Add a PE::Relocation Relocation& add_relocation(const Relocation& relocation); - //! Remove all the relocations + /// Remove all the relocations void remove_all_relocations(); - //! Return an iterator over the DataDirectory present in the Binary + /// Return an iterator over the DataDirectory present in the Binary it_data_directories data_directories() { return data_directories_; } @@ -445,18 +445,18 @@ class LIEF_API Binary : public LIEF::Binary { return data_directories_; } - //! Return the DataDirectory with the given type (or index) + /// Return the DataDirectory with the given type (or index) DataDirectory* data_directory(DataDirectory::TYPES type) { return const_cast(static_cast(this)->data_directory(type)); } const DataDirectory* data_directory(DataDirectory::TYPES type) const; - //! Check if the current binary has the given DataDirectory::TYPES + /// Check if the current binary has the given DataDirectory::TYPES bool has(DataDirectory::TYPES type) const { return data_directory(type) != nullptr; } - //! Return an iterator over the Debug entries + /// Return an iterator over the Debug entries it_debug_entries debug() { return debug_; } @@ -465,11 +465,11 @@ class LIEF_API Binary : public LIEF::Binary { return debug_; } - //! Return the CodeViewPDB object if present + /// Return the CodeViewPDB object if present const CodeViewPDB* codeview_pdb() const; - //! Retrun the LoadConfiguration object or a nullptr - //! if the binary does not use the LoadConfiguration + /// Retrun the LoadConfiguration object or a nullptr + /// if the binary does not use the LoadConfiguration const LoadConfiguration* load_configuration() const { return load_configuration_.get(); } @@ -478,7 +478,7 @@ class LIEF_API Binary : public LIEF::Binary { return load_configuration_.get(); } - //! Return the overlay content + /// Return the overlay content span overlay() const { return overlay_; } @@ -487,12 +487,12 @@ class LIEF_API Binary : public LIEF::Binary { return overlay_; } - //! Return the original overlay offset + /// Return the original overlay offset uint64_t overlay_offset() const { return overlay_offset_; } - //! Return the DOS stub content + /// Return the DOS stub content span dos_stub() const { return dos_stub_; } @@ -501,7 +501,7 @@ class LIEF_API Binary : public LIEF::Binary { return dos_stub_; } - //! Update the DOS stub content + /// Update the DOS stub content void dos_stub(std::vector content) { dos_stub_ = std::move(content); } @@ -509,7 +509,7 @@ class LIEF_API Binary : public LIEF::Binary { // Rich Header // ----------- - //! Return a reference to the RichHeader object + /// Return a reference to the RichHeader object RichHeader* rich_header() { return rich_header_.get(); } @@ -518,15 +518,15 @@ class LIEF_API Binary : public LIEF::Binary { return rich_header_.get(); } - //! Set a RichHeader object in the current Binary + /// Set a RichHeader object in the current Binary void rich_header(const RichHeader& rich_header); - //! Check if the current binary has a RichHeader object + /// Check if the current binary has a RichHeader object bool has_rich_header() const { return rich_header_ != nullptr; } - //! Return an iterator over the binary imports + /// Return an iterator over the binary imports it_imports imports() { return imports_; } @@ -535,31 +535,31 @@ class LIEF_API Binary : public LIEF::Binary { return imports_; } - //! Returns the PE::Import from the given name. If it can't be - //! found, return a nullptr - //! - //! @param[in] import_name Name of the import + /// Returns the PE::Import from the given name. If it can't be + /// found, return a nullptr + /// + /// @param[in] import_name Name of the import Import* get_import(const std::string& import_name) { return const_cast(static_cast(this)->get_import(import_name)); } const Import* get_import(const std::string& import_name) const; - //! ``True`` if the binary imports the given library name - //! - //! @param[in] import_name Name of the import + /// ``True`` if the binary imports the given library name + /// + /// @param[in] import_name Name of the import bool has_import(const std::string& import_name) const { return get_import(import_name) != nullptr; } - //! Check if the current binary contains delay imports - //! - //! @see DelayImport - //! @see has_import + /// Check if the current binary contains delay imports + /// + /// @see DelayImport + /// @see has_import bool has_delay_imports() const { return !delay_imports_.empty(); } - //! Return an iterator over the binary's delay imports + /// Return an iterator over the binary's delay imports it_delay_imports delay_imports() { return delay_imports_; } @@ -568,110 +568,110 @@ class LIEF_API Binary : public LIEF::Binary { return delay_imports_; } - //! Returns the PE::DelayImport from the given name. If it can't be - //! found, return a nullptr - //! - //! @param[in] import_name Name of the delay import + /// Returns the PE::DelayImport from the given name. If it can't be + /// found, return a nullptr + /// + /// @param[in] import_name Name of the delay import DelayImport* get_delay_import(const std::string& import_name) { return const_cast(static_cast(this)->get_delay_import(import_name)); } const DelayImport* get_delay_import(const std::string& import_name) const; - //! ``True`` if the binary delay-imports the given library name - //! - //! @param[in] import_name Name of the delay import + /// ``True`` if the binary delay-imports the given library name + /// + /// @param[in] import_name Name of the delay import bool has_delay_import(const std::string& import_name) const { return get_delay_import(import_name) != nullptr; } - //! Add the function @p function of the library @p library. - //! If the function fails, it returns a nullptr - //! - //! @param[in] library Library name of the function - //! @param[in] function Function's name from the library to import + /// Add the function @p function of the library @p library. + /// If the function fails, it returns a nullptr + /// + /// @param[in] library Library name of the function + /// @param[in] function Function's name from the library to import ImportEntry* add_import_function(const std::string& library, const std::string& function); - //! Add an imported library (i.e. `DLL`) to the binary + /// Add an imported library (i.e. `DLL`) to the binary Import& add_library(const std::string& name) { imports_.emplace_back(name); return imports_.back(); } - //! Remove the library with the given `name` + /// Remove the library with the given `name` void remove_library(const std::string& name); - //! Remove all libraries in the binary + /// Remove all libraries in the binary void remove_all_libraries() { imports_.clear(); } - //! Reconstruct the binary object and write the raw PE in `filename` - //! - //! Rebuild a PE binary from the current Binary object. - //! When rebuilding, import table and relocations are not rebuilt. + /// Reconstruct the binary object and write the raw PE in `filename` + /// + /// Rebuild a PE binary from the current Binary object. + /// When rebuilding, import table and relocations are not rebuilt. void write(const std::string& filename) override; - //! Reconstruct the binary object and write the raw PE in `os` stream - //! - //! Rebuild a PE binary from the current Binary object. - //! When rebuilding, import table and relocations are not rebuilt. + /// Reconstruct the binary object and write the raw PE in `os` stream + /// + /// Rebuild a PE binary from the current Binary object. + /// When rebuilding, import table and relocations are not rebuilt. void write(std::ostream& os) override; void accept(Visitor& visitor) const override; - //! Patch the content at virtual address @p address with @p patch_value - //! - //! @param[in] address Address to patch - //! @param[in] patch_value Patch to apply - //! @param[in] addr_type Type of the Virtual address: VA or RVA. Default: Auto + /// Patch the content at virtual address @p address with @p patch_value + /// + /// @param[in] address Address to patch + /// @param[in] patch_value Patch to apply + /// @param[in] addr_type Type of the Virtual address: VA or RVA. Default: Auto void patch_address(uint64_t address, const std::vector& patch_value, LIEF::Binary::VA_TYPES addr_type = LIEF::Binary::VA_TYPES::AUTO) override; - //! Patch the address with the given value - //! - //! @param[in] address Address to patch - //! @param[in] patch_value Patch to apply - //! @param[in] size Size of the value in **bytes** (1, 2, ... 8) - //! @param[in] addr_type Type of the Virtual address: VA or RVA. Default: Auto + /// Patch the address with the given value + /// + /// @param[in] address Address to patch + /// @param[in] patch_value Patch to apply + /// @param[in] size Size of the value in **bytes** (1, 2, ... 8) + /// @param[in] addr_type Type of the Virtual address: VA or RVA. Default: Auto void patch_address(uint64_t address, uint64_t patch_value, size_t size = sizeof(uint64_t), LIEF::Binary::VA_TYPES addr_type = LIEF::Binary::VA_TYPES::AUTO) override; - //! Return the content located at the provided virtual address - //! - //! @param[in] virtual_address Virtual address of the data to retrieve - //! @param[in] size Size in bytes of the data to retrieve - //! @param[in] addr_type Type of the Virtual address: VA or RVA. Default: Auto + /// Return the content located at the provided virtual address + /// + /// @param[in] virtual_address Virtual address of the data to retrieve + /// @param[in] size Size in bytes of the data to retrieve + /// @param[in] addr_type Type of the Virtual address: VA or RVA. Default: Auto span get_content_from_virtual_address( uint64_t virtual_address, uint64_t size, Binary::VA_TYPES addr_type = Binary::VA_TYPES::AUTO) const override; - //! Return the binary's entrypoint (It is the same value as OptionalHeader::addressof_entrypoint + /// Return the binary's entrypoint (It is the same value as OptionalHeader::addressof_entrypoint uint64_t entrypoint() const override { return optional_header_.imagebase() + optional_header_.addressof_entrypoint(); } - //! Check if the binary is position independent + /// Check if the binary is position independent bool is_pie() const override { return optional_header_.has(OptionalHeader::DLL_CHARACTERISTICS::DYNAMIC_BASE); } - //! Check if the binary uses ``NX`` protection + /// Check if the binary uses ``NX`` protection bool has_nx() const override { return optional_header_.has(OptionalHeader::DLL_CHARACTERISTICS::NX_COMPAT); } - //! Return the list of the binary constructors. - //! - //! In a PE file, we consider a constructors as a callback in the TLS object + /// Return the list of the binary constructors. + /// + /// In a PE file, we consider a constructors as a callback in the TLS object LIEF::Binary::functions_t ctor_functions() const override; - //! **All** functions found in the binary + /// **All** functions found in the binary LIEF::Binary::functions_t functions() const; - //! Functions found in the Exception table directory + /// Functions found in the Exception table directory LIEF::Binary::functions_t exception_functions() const; static bool classof(const LIEF::Binary* bin) { @@ -683,18 +683,18 @@ class LIEF_API Binary : public LIEF::Binary { private: Binary(); - //! Make space between the last section header and the beginning of the - //! content of first section + /// Make space between the last section header and the beginning of the + /// content of first section void make_space_for_new_section(); - //! Return binary's symbols as LIEF::Symbol + /// Return binary's symbols as LIEF::Symbol LIEF::Binary::symbols_t get_abstract_symbols() override; LIEF::Header get_abstract_header() const override { return LIEF::Header::from(*this); } - //! Return binary's section as LIEF::Section + /// Return binary's section as LIEF::Section LIEF::Binary::sections_t get_abstract_sections() override; LIEF::Binary::relocations_t get_abstract_relocations() override; diff --git a/include/LIEF/PE/Builder.hpp b/include/LIEF/PE/Builder.hpp index 0963e63c56..236feb8596 100644 --- a/include/LIEF/PE/Builder.hpp +++ b/include/LIEF/PE/Builder.hpp @@ -41,7 +41,7 @@ class OptionalHeader; class DataDirectory; class Section; -//! Class that is used to rebuild a raw PE binary from a PE::Binary object +/// Class that is used to rebuild a raw PE binary from a PE::Binary object class LIEF_API Builder { public: @@ -49,53 +49,53 @@ class LIEF_API Builder { Builder(Binary& binary); ~Builder(); - //! Perform the build process + /// Perform the build process ok_error_t build(); - //! @brief Construct a ``jmp [address] @ from``. - //! - //! It is used when patching import table + /// Construct a ``jmp [address] @ from``. + /// + /// It is used when patching import table template static std::vector build_jmp(uint64_t from, uint64_t address); - //! @brief Construct a ``jmp far address @ from``. - //! - //! It is used for hooking + /// Construct a ``jmp far address @ from``. + /// + /// It is used for hooking template static std::vector build_jmp_hook(uint64_t from, uint64_t address); - //! @brief Rebuild the import table in new section + /// Rebuild the import table in new section Builder& build_imports(bool flag = true); - //! @brief Patch the original import table in order to - //! redirect functions to the new import table. - //! - //! This setting should be used with LIEF::PE::Builder::build_imports set to ``true`` + /// Patch the original import table in order to + /// redirect functions to the new import table. + /// + /// This setting should be used with LIEF::PE::Builder::build_imports set to ``true`` Builder& patch_imports(bool flag = true); - //! @brief Rebuild the relocation table in another section + /// Rebuild the relocation table in another section Builder& build_relocations(bool flag = true); - //! @brief Rebuild TLS object in another section + /// Rebuild TLS object in another section Builder& build_tls(bool flag = true); - //! @brief Rebuid the resources in another section + /// Rebuid the resources in another section Builder& build_resources(bool flag); - //! @brief Rebuild the binary's overlay + /// Rebuild the binary's overlay Builder& build_overlay(bool flag); - //! @brief Rebuild the DOS stub content + /// Rebuild the DOS stub content Builder& build_dos_stub(bool flag); - //! @brief Return the build result + /// Return the build result const std::vector& get_build(); - //! @brief Write the build result into the ``output`` file + /// Write the build result into the ``output`` file void write(const std::string& filename) const; - //! @brief Write the build result into the ``os`` stream + /// Write the build result into the ``os`` stream void write(std::ostream& os) const; LIEF_API friend std::ostream& operator<<(std::ostream& os, const Builder& b); @@ -110,7 +110,7 @@ class LIEF_API Builder { template ok_error_t build_optional_header(const OptionalHeader& optional_header); - //! @brief Rebuild Import Table + /// Rebuild Import Table // TODO: Bug with x86 template void build_import_table(); diff --git a/include/LIEF/PE/CodeIntegrity.hpp b/include/LIEF/PE/CodeIntegrity.hpp index a1ec5dfd3d..d3eb04806a 100644 --- a/include/LIEF/PE/CodeIntegrity.hpp +++ b/include/LIEF/PE/CodeIntegrity.hpp @@ -36,12 +36,12 @@ class LIEF_API CodeIntegrity : public Object { CodeIntegrity& operator=(const CodeIntegrity&) = default; CodeIntegrity(const CodeIntegrity&) = default; - //! Flags to indicate if CI information is available, etc. + /// Flags to indicate if CI information is available, etc. uint16_t flags() const { return flags_; } - //! 0xFFFF means not available + /// 0xFFFF means not available uint16_t catalog() const { return catalog_; } @@ -49,7 +49,7 @@ class LIEF_API CodeIntegrity : public Object { return catalog_offset_; } - //! Additional bitmask to be defined later + /// Additional bitmask to be defined later uint32_t reserved() const { return reserved_; } diff --git a/include/LIEF/PE/DataDirectory.hpp b/include/LIEF/PE/DataDirectory.hpp index 9b6ccd25be..410a4db92f 100644 --- a/include/LIEF/PE/DataDirectory.hpp +++ b/include/LIEF/PE/DataDirectory.hpp @@ -34,7 +34,7 @@ namespace details { struct pe_data_directory; } -//! Class that represents a PE data directory entry +/// Class that represents a PE data directory entry class LIEF_API DataDirectory : public Object { friend class Builder; @@ -79,24 +79,24 @@ class LIEF_API DataDirectory : public Object { ~DataDirectory() override = default; - //! The relative virtual address of the content of this data - //! directory + /// The relative virtual address of the content of this data + /// directory uint32_t RVA() const { return rva_; } - //! The size of the content + /// The size of the content uint32_t size() const { return size_; } - //! Check if the content of this data directory is associated - //! with a PE Cection + /// Check if the content of this data directory is associated + /// with a PE Cection bool has_section() const { return section_ != nullptr; } - //! Section associated with the DataDirectory + /// Section associated with the DataDirectory Section* section() { return section_; } @@ -104,7 +104,7 @@ class LIEF_API DataDirectory : public Object { return section_; } - //! Type of the data directory + /// Type of the data directory TYPES type() const { return type_; } diff --git a/include/LIEF/PE/DelayImport.hpp b/include/LIEF/PE/DelayImport.hpp index 54270e4462..7399b0d8cd 100644 --- a/include/LIEF/PE/DelayImport.hpp +++ b/include/LIEF/PE/DelayImport.hpp @@ -32,7 +32,7 @@ namespace details { struct delay_imports; } -//! Class that represents a PE delayed import. +/// Class that represents a PE delayed import. class LIEF_API DelayImport : public Object { friend class Parser; @@ -59,8 +59,8 @@ class LIEF_API DelayImport : public Object { void swap(DelayImport& other); - //! According to the official PE specifications, - //! this value is reserved and should be set to 0. + /// According to the official PE specifications, + /// this value is reserved and should be set to 0. uint32_t attribute() const { return attribute_; } @@ -68,7 +68,7 @@ class LIEF_API DelayImport : public Object { attribute_ = hdl; } - //! Return the library's name (e.g. `kernel32.dll`) + /// Return the library's name (e.g. `kernel32.dll`) const std::string& name() const { return name_; } @@ -76,9 +76,9 @@ class LIEF_API DelayImport : public Object { name_ = std::move(name); } - //! The RVA of the module handle (in the ``.data`` section) - //! It is used for storage by the routine that is supplied to - //! manage delay-loading. + /// The RVA of the module handle (in the ``.data`` section) + /// It is used for storage by the routine that is supplied to + /// manage delay-loading. uint32_t handle() const { return handle_; } @@ -86,7 +86,7 @@ class LIEF_API DelayImport : public Object { handle_ = hdl; } - //! RVA of the delay-load import address table. + /// RVA of the delay-load import address table. uint32_t iat() const { return iat_; } @@ -94,8 +94,8 @@ class LIEF_API DelayImport : public Object { iat_ = iat; } - //! RVA of the delay-load import names table. - //! The content of this table has the layout as the Import lookup table + /// RVA of the delay-load import names table. + /// The content of this table has the layout as the Import lookup table uint32_t names_table() const { return names_table_; } @@ -103,8 +103,8 @@ class LIEF_API DelayImport : public Object { names_table_ = value; } - //! RVA of the **bound** delay-load import address table or 0 - //! if the table does not exist. + /// RVA of the **bound** delay-load import address table or 0 + /// if the table does not exist. uint32_t biat() const { return bound_iat_; } @@ -112,12 +112,12 @@ class LIEF_API DelayImport : public Object { bound_iat_ = value; } - //! RVA of the **unload** delay-load import address table or 0 - //! if the table does not exist. - //! - //! According to the PE specifications, this table is an - //! exact copy of the delay import address table that can be - //! used to to restore the original IAT the case of unloading. + /// RVA of the **unload** delay-load import address table or 0 + /// if the table does not exist. + /// + /// According to the PE specifications, this table is an + /// exact copy of the delay import address table that can be + /// used to to restore the original IAT the case of unloading. uint32_t uiat() const { return unload_iat_; } @@ -125,7 +125,7 @@ class LIEF_API DelayImport : public Object { unload_iat_ = value; } - //! The timestamp of the DLL to which this image has been bound. + /// The timestamp of the DLL to which this image has been bound. uint32_t timestamp() const { return timestamp_; } @@ -133,12 +133,12 @@ class LIEF_API DelayImport : public Object { timestamp_ = value; } - //! Iterator over the DelayImport's entries (DelayImportEntry) + /// Iterator over the DelayImport's entries (DelayImportEntry) it_entries entries() { return entries_; } - //! Iterator over the DelayImport's entries (DelayImportEntry) + /// Iterator over the DelayImport's entries (DelayImportEntry) it_const_entries entries() const { return entries_; } diff --git a/include/LIEF/PE/DelayImportEntry.hpp b/include/LIEF/PE/DelayImportEntry.hpp index a9e228c762..3085310a93 100644 --- a/include/LIEF/PE/DelayImportEntry.hpp +++ b/include/LIEF/PE/DelayImportEntry.hpp @@ -28,13 +28,13 @@ namespace PE { class Parser; class Builder; -//! Class that represents an entry (i.e. an import) in the delay import table (DelayImport). -//! -//! It extends the LIEF::Symbol generic class that exposes the LIEF::Symbol::name and -//! LIEF::Symbol::value API. -//! -//! The meaning of LIEF::Symbol::value for this PE object is the address (as an RVA) in the IAT -//! where the resolution should take place. +/// Class that represents an entry (i.e. an import) in the delay import table (DelayImport). +/// +/// It extends the LIEF::Symbol generic class that exposes the LIEF::Symbol::name and +/// LIEF::Symbol::value API. +/// +/// The meaning of LIEF::Symbol::value for this PE object is the address (as an RVA) in the IAT +/// where the resolution should take place. class LIEF_API DelayImportEntry : public LIEF::Symbol { friend class Parser; friend class Builder; @@ -54,36 +54,36 @@ class LIEF_API DelayImportEntry : public LIEF::Symbol { ~DelayImportEntry() override = default; - //! Demangled representation of the symbol or an empty string if it can't - //! be demangled + /// Demangled representation of the symbol or an empty string if it can't + /// be demangled std::string demangled_name() const; - //! `True` if it is an import by ordinal + /// `True` if it is an import by ordinal bool is_ordinal() const; - //! The ordinal value + /// The ordinal value uint16_t ordinal() const { static constexpr auto MASK = 0xFFFF; return data_ & MASK; } - //! @see DelayImportEntry::data + /// @see DelayImportEntry::data uint64_t hint_name_rva() const { return data(); } - //! Index into the Export::entries that is used to speed-up - //! the symbol resolution. + /// Index into the Export::entries that is used to speed-up + /// the symbol resolution. uint16_t hint() const { return hint_; } - //! Value of the current entry in the Import Address Table. + /// Value of the current entry in the Import Address Table. uint64_t iat_value() const { return iat_value_; } - //! Raw value + /// Raw value uint64_t data() const { return data_; } diff --git a/include/LIEF/PE/DosHeader.hpp b/include/LIEF/PE/DosHeader.hpp index 77504909b3..5698627cd8 100644 --- a/include/LIEF/PE/DosHeader.hpp +++ b/include/LIEF/PE/DosHeader.hpp @@ -31,10 +31,10 @@ namespace details { struct pe_dos_header; } -//! Class which represents the DosHeader, the **first** -//! structure presents at the beginning of a PE file. -//! -//! Most of the attributes of this structures are no longer relevant. +/// Class which represents the DosHeader, the **first** +/// structure presents at the beginning of a PE file. +/// +/// Most of the attributes of this structures are no longer relevant. class LIEF_API DosHeader : public Object { public: using reserved_t = std::array; @@ -51,7 +51,7 @@ class LIEF_API DosHeader : public Object { ~DosHeader() override = default; - //! Magic bytes identifying a DOS/PE binary + /// Magic bytes identifying a DOS/PE binary uint16_t magic() const { return magic_; } @@ -124,7 +124,7 @@ class LIEF_API DosHeader : public Object { return reserved2_; } - //! Return the offset to the PE::Header structure. + /// Return the offset to the PE::Header structure. uint32_t addressof_new_exeheader() const { return addr_new_exe_header_; } diff --git a/include/LIEF/PE/Export.hpp b/include/LIEF/PE/Export.hpp index 8f8af0ddad..0b0454b977 100644 --- a/include/LIEF/PE/Export.hpp +++ b/include/LIEF/PE/Export.hpp @@ -34,7 +34,7 @@ namespace details { struct pe_export_directory_table; } -//! Class which represents a PE Export +/// Class which represents a PE Export class LIEF_API Export : public Object { friend class Builder; friend class Parser; @@ -50,38 +50,38 @@ class LIEF_API Export : public Object { Export& operator=(const Export&) = default; ~Export() override = default; - //! According to the PE specifications this value is reserved - //! and should be set to 0 + /// According to the PE specifications this value is reserved + /// and should be set to 0 uint32_t export_flags() const { return export_flags_; } - //! The time and date that the export data was created + /// The time and date that the export data was created uint32_t timestamp() const { return timestamp_; } - //! The major version number (can be user-defined) + /// The major version number (can be user-defined) uint16_t major_version() const { return major_version_; } - //! The minor version number (can be user-defined) + /// The minor version number (can be user-defined) uint16_t minor_version() const { return minor_version_; } - //! The starting number for the exports. Usually this value is set to 1 + /// The starting number for the exports. Usually this value is set to 1 uint32_t ordinal_base() const { return ordinal_base_; } - //! The name of the library exported (e.g. `KERNEL32.dll`) + /// The name of the library exported (e.g. `KERNEL32.dll`) const std::string& name() const { return name_; } - //! Iterator over the ExportEntry + /// Iterator over the ExportEntry it_entries entries() { return entries_; } diff --git a/include/LIEF/PE/ExportEntry.hpp b/include/LIEF/PE/ExportEntry.hpp index a101861a7b..055ee28430 100644 --- a/include/LIEF/PE/ExportEntry.hpp +++ b/include/LIEF/PE/ExportEntry.hpp @@ -29,7 +29,7 @@ namespace PE { class Builder; class Parser; -//! Class which represents a PE Export entry (cf. PE::Export) +/// Class which represents a PE Export entry (cf. PE::Export) class LIEF_API ExportEntry : public LIEF::Symbol { friend class Builder; @@ -64,8 +64,8 @@ class LIEF_API ExportEntry : public LIEF::Symbol { ExportEntry& operator=(const ExportEntry&) = default; ~ExportEntry() override = default; - //! Demangled representation of the symbol or an empty string if it can't - //! be demangled + /// Demangled representation of the symbol or an empty string if it can't + /// be demangled std::string demangled_name() const; uint16_t ordinal() const { diff --git a/include/LIEF/PE/Header.hpp b/include/LIEF/PE/Header.hpp index 806cc07a23..5a951be6e3 100644 --- a/include/LIEF/PE/Header.hpp +++ b/include/LIEF/PE/Header.hpp @@ -32,7 +32,7 @@ namespace details { struct pe_header; } -//! Class that represents the PE header (which follows the DosHeader) +/// Class that represents the PE header (which follows the DosHeader) class LIEF_API Header : public Object { public: using signature_t = std::array; @@ -92,64 +92,64 @@ class LIEF_API Header : public Object { Header& operator=(const Header&) = default; Header(const Header&) = default; - //! Signature (or magic byte) of the header. It must be: ``PE\0\0`` + /// Signature (or magic byte) of the header. It must be: ``PE\0\0`` const signature_t& signature() const { return signature_; } - //! The targeted machine architecture like ARM, x86, AMD64, ... + /// The targeted machine architecture like ARM, x86, AMD64, ... MACHINE_TYPES machine() const { return machine_; } - //! The number of sections in the binary. + /// The number of sections in the binary. uint16_t numberof_sections() const { return nb_sections_; } - //! The low 32 bits of the number of seconds since - //! January 1, 1970. It **indicates** when the file was created. + /// The low 32 bits of the number of seconds since + /// January 1, 1970. It **indicates** when the file was created. uint32_t time_date_stamp() const { return timedatestamp_; } - //! The offset of the **COFF** symbol table. - //! - //! This value should be zero for an image because COFF debugging information is deprecated. + /// The offset of the **COFF** symbol table. + /// + /// This value should be zero for an image because COFF debugging information is deprecated. uint32_t pointerto_symbol_table() const { return pointerto_symtab_; } - //! The number of entries in the symbol table. This data can be used to locate the string table - //! which immediately follows the symbol table. - //! - //! This value should be zero for an image because COFF debugging information is deprecated. + /// The number of entries in the symbol table. This data can be used to locate the string table + /// which immediately follows the symbol table. + /// + /// This value should be zero for an image because COFF debugging information is deprecated. uint32_t numberof_symbols() const { return nb_symbols_; } - //! Size of the OptionalHeader **AND** the data directories which follows this header. - //! - //! This value is equivalent to: ``sizeof(pe_optional_header) + NB_DATA_DIR * sizeof(data_directory)`` - //! - //! This size **should** be either: - //! * 0xE0 (224) for a PE32 (32 bits) - //! * 0xF0 (240) for a PE32+ (64 bits) + /// Size of the OptionalHeader **AND** the data directories which follows this header. + /// + /// This value is equivalent to: ``sizeof(pe_optional_header) + NB_DATA_DIR * sizeof(data_directory)`` + /// + /// This size **should** be either: + /// * 0xE0 (224) for a PE32 (32 bits) + /// * 0xF0 (240) for a PE32+ (64 bits) uint16_t sizeof_optional_header() const { return sizeof_opt_header_; } - //! Characteristics of the binary like whether it is a DLL or an executable + /// Characteristics of the binary like whether it is a DLL or an executable uint32_t characteristics() const { return characteristics_; } - //! Check if the given CHARACTERISTICS is present + /// Check if the given CHARACTERISTICS is present bool has_characteristic(CHARACTERISTICS c) const { return (characteristics() & static_cast(c)) > 0; } - //! The list of the CHARACTERISTICS + /// The list of the CHARACTERISTICS std::vector characteristics_list() const; void machine(MACHINE_TYPES type) { diff --git a/include/LIEF/PE/Import.hpp b/include/LIEF/PE/Import.hpp index ca4159abe9..f18ddf3bc7 100644 --- a/include/LIEF/PE/Import.hpp +++ b/include/LIEF/PE/Import.hpp @@ -35,7 +35,7 @@ namespace details { struct pe_import; } -//! Class that represents a PE import. +/// Class that represents a PE import. class LIEF_API Import : public Object { friend class Parser; @@ -58,18 +58,18 @@ class LIEF_API Import : public Object { Import& operator=(Import&& other) noexcept = default; Import& operator=(const Import& other) = default; - //! The index of the first forwarder reference + /// The index of the first forwarder reference uint32_t forwarder_chain() const { return forwarder_chain_; } - //! The stamp that is set to zero until the image is bound. - //! After the image is bound, this field is set to the time/data stamp of the DLL + /// The stamp that is set to zero until the image is bound. + /// After the image is bound, this field is set to the time/data stamp of the DLL uint32_t timedatestamp() const { return timedatestamp_; } - //! Iterator over the PE::ImportEntry + /// Iterator over the PE::ImportEntry it_const_entries entries() const { return entries_; } @@ -78,50 +78,50 @@ class LIEF_API Import : public Object { return entries_; } - //! The RVA of the import address table (``IAT``). The content of this table is - //! **identical** to the content of the Import Lookup Table (``ILT``) until the - //! image is bound. - //! - //! @warning - //! This address could change when re-building the binary + /// The RVA of the import address table (``IAT``). The content of this table is + /// **identical** to the content of the Import Lookup Table (``ILT``) until the + /// image is bound. + /// + /// @warning + /// This address could change when re-building the binary uint32_t import_address_table_rva() const { return import_address_table_RVA_; } - //! Return the relative virtual address of the import lookup table. - //! - //! @warning - //! This address could change when re-building the binary + /// Return the relative virtual address of the import lookup table. + /// + /// @warning + /// This address could change when re-building the binary uint32_t import_lookup_table_rva() const { return import_lookup_table_RVA_; } - //! Return the Function's RVA from the import address table (`IAT`) - //! - //! @warning - //! This address could change when re-building the binary + /// Return the Function's RVA from the import address table (`IAT`) + /// + /// @warning + /// This address could change when re-building the binary result get_function_rva_from_iat(const std::string& function) const; - //! Return the imported function with the given name + /// Return the imported function with the given name ImportEntry* get_entry(const std::string& name) { return const_cast(static_cast(this)->get_entry(name)); } const ImportEntry* get_entry(const std::string& name) const; - //! Return the library's name (e.g. `kernel32.dll`) + /// Return the library's name (e.g. `kernel32.dll`) const std::string& name() const { return name_; } - //! Change the current import name + /// Change the current import name void name(std::string name) { name_ = std::move(name); } - //! Return the PE::DataDirectory associated with this import. - //! It should be the one at index PE::DataDirectory::TYPES::IMPORT_TABLE - //! - //! If the data directory can't be found, return a nullptr + /// Return the PE::DataDirectory associated with this import. + /// It should be the one at index PE::DataDirectory::TYPES::IMPORT_TABLE + /// + /// If the data directory can't be found, return a nullptr DataDirectory* directory() { return directory_; } @@ -129,10 +129,10 @@ class LIEF_API Import : public Object { return directory_; } - //! Return the PE::DataDirectory associated associated with the IAT. - //! It should be the one at index PE::DataDirectory::TYPES::IAT - //! - //! If the data directory can't be found, return a nullptr + /// Return the PE::DataDirectory associated associated with the IAT. + /// It should be the one at index PE::DataDirectory::TYPES::IAT + /// + /// If the data directory can't be found, return a nullptr DataDirectory* iat_directory() { return iat_directory_; } @@ -140,13 +140,13 @@ class LIEF_API Import : public Object { return iat_directory_; } - //! Add a new import entry (i.e. an imported function) + /// Add a new import entry (i.e. an imported function) ImportEntry& add_entry(ImportEntry entry) { entries_.push_back(std::move(entry)); return entries_.back(); } - //! Add a new import entry with the given name (i.e. an imported function) + /// Add a new import entry with the given name (i.e. an imported function) ImportEntry& add_entry(const std::string& name) { entries_.emplace_back(name); return entries_.back(); diff --git a/include/LIEF/PE/ImportEntry.hpp b/include/LIEF/PE/ImportEntry.hpp index 23f84bf8fa..9df542445f 100644 --- a/include/LIEF/PE/ImportEntry.hpp +++ b/include/LIEF/PE/ImportEntry.hpp @@ -29,10 +29,10 @@ namespace PE { class Parser; class Builder; -//! Class that represents an entry (i.e. an import) in the import table (Import). -//! -//! It extends the LIEF::Symbol generic class that exposes the LIEF::Symbol::name and -//! LIEF::Symbol::value API +/// Class that represents an entry (i.e. an import) in the import table (Import). +/// +/// It extends the LIEF::Symbol generic class that exposes the LIEF::Symbol::name and +/// LIEF::Symbol::value API class LIEF_API ImportEntry : public LIEF::Symbol { friend class Parser; friend class Builder; @@ -47,42 +47,42 @@ class LIEF_API ImportEntry : public LIEF::Symbol { ImportEntry& operator=(const ImportEntry&) = default; ~ImportEntry() override = default; - //! Demangled representation of the symbol or an empty string if it can't - //! be demangled + /// Demangled representation of the symbol or an empty string if it can't + /// be demangled std::string demangled_name() const; - //! `True` if it is an import by ordinal + /// `True` if it is an import by ordinal bool is_ordinal() const; - //! The ordinal value + /// The ordinal value uint16_t ordinal() const { static constexpr auto MASK = 0xFFFF; return is_ordinal() ? (data_ & MASK) : 0; } - //! @see ImportEntry::data + /// @see ImportEntry::data uint64_t hint_name_rva() const { return data(); } - //! Index into the Export::entries that is used to speed-up - //! the symbol resolution. + /// Index into the Export::entries that is used to speed-up + /// the symbol resolution. uint16_t hint() const { return hint_; } - //! Value of the current entry in the Import Address Table. - //! It should match the lookup table value + /// Value of the current entry in the Import Address Table. + /// It should match the lookup table value uint64_t iat_value() const { return iat_value_; } - //! Raw value + /// Raw value uint64_t data() const { return data_; } - //! **Original** address of the entry in the Import Address Table + /// **Original** address of the entry in the Import Address Table uint64_t iat_address() const { return rva_; } diff --git a/include/LIEF/PE/LoadConfigurations/LoadConfiguration.hpp b/include/LIEF/PE/LoadConfigurations/LoadConfiguration.hpp index bc979d144e..dfe5665220 100644 --- a/include/LIEF/PE/LoadConfigurations/LoadConfiguration.hpp +++ b/include/LIEF/PE/LoadConfigurations/LoadConfiguration.hpp @@ -29,9 +29,9 @@ template struct load_configuration; } -//! Class that represents the default PE's ``LoadConfiguration`` -//! -//! It's the base class for any future versions of the structure +/// Class that represents the default PE's ``LoadConfiguration`` +/// +/// It's the base class for any future versions of the structure class LIEF_API LoadConfiguration : public Object { public: enum class VERSION { @@ -60,126 +60,126 @@ class LIEF_API LoadConfiguration : public Object { LoadConfiguration& operator=(const LoadConfiguration&) = default; LoadConfiguration(const LoadConfiguration&) = default; - //! (SDK) Version of the structure + /// (SDK) Version of the structure virtual VERSION version() const { return WIN_VERSION; } - //! Characteristics of the structure - //! It usually holds its size - //! - //! @see @link version LoadConfiguration::version@endlink + /// Characteristics of the structure + /// It usually holds its size + /// + /// @see @link version LoadConfiguration::version@endlink uint32_t characteristics() const { return characteristics_; } - //! Size of the current structure which is an alias for characteristics + /// Size of the current structure which is an alias for characteristics uint32_t size() const { return characteristics_; } - //! Date and time stamp value + /// Date and time stamp value uint32_t timedatestamp() const { return timedatestamp_; } - //! Major Version + /// Major Version uint16_t major_version() const { return major_version_; } - //! Minor version + /// Minor version uint16_t minor_version() const { return minor_version_; } - //! The global loader flags to clear for - //! this process as the loader start the process. + /// The global loader flags to clear for + /// this process as the loader start the process. uint32_t global_flags_clear() const { return global_flags_clear_; } - //! The global loader flags to set for - //! this process as the loader starts the process. + /// The global loader flags to set for + /// this process as the loader starts the process. uint32_t global_flags_set() const { return global_flags_set_; } - //! The default timeout value to use for - //! this process’s critical sections that are abandoned. + /// The default timeout value to use for + /// this process’s critical sections that are abandoned. uint32_t critical_section_default_timeout() const { return critical_section_default_timeout_; } - //! Memory that must be freed before - //! it is returned to the system, in bytes. + /// Memory that must be freed before + /// it is returned to the system, in bytes. uint64_t decommit_free_block_threshold() const { return decommit_free_block_threshold_; } - //! Total amount of free memory, in - //! bytes. + /// Total amount of free memory, in + /// bytes. uint64_t decommit_total_free_threshold() const { return decommit_total_free_threshold_; } - //! The VA of a list of - //! addresses where the LOCK prefix - //! is used so that they can be replaced with NOP on single - //! processor machines. - //! - //! @warning For ``x86`` only + /// The VA of a list of + /// addresses where the LOCK prefix + /// is used so that they can be replaced with NOP on single + /// processor machines. + /// + /// @warning For ``x86`` only uint64_t lock_prefix_table() const { return lock_prefix_table_; } - //! Maximum allocation size, in bytes. + /// Maximum allocation size, in bytes. uint64_t maximum_allocation_size() const { return maximum_allocation_size_; } - //! Maximum virtual memory size, in bytes. + /// Maximum virtual memory size, in bytes. uint64_t virtual_memory_threshold() const { return virtual_memory_threshold_; } - //! Setting this field to a non-zero value is equivalent to calling - //! ``SetProcessAffinityMask`` with this value during process startup (.exe only) + /// Setting this field to a non-zero value is equivalent to calling + /// ``SetProcessAffinityMask`` with this value during process startup (.exe only) uint64_t process_affinity_mask() const { return process_affinity_mask_; } - //! Process heap flags that correspond to the first argument of the - //! ``HeapCreate`` function. These flags apply to the process heap that is - //! created during process startup. + /// Process heap flags that correspond to the first argument of the + /// ``HeapCreate`` function. These flags apply to the process heap that is + /// created during process startup. uint32_t process_heap_flags() const { return process_heap_flags_; } - //! The service pack version identifier. + /// The service pack version identifier. uint16_t csd_version() const { return csd_version_; } - //! Must be zero. + /// Must be zero. uint16_t reserved1() const { return reserved1_; } - //! Alias for reserved1. - //! - //! On recent the version of the structure, Microsoft renamed reserved1 to DependentLoadFlags + /// Alias for reserved1. + /// + /// On recent the version of the structure, Microsoft renamed reserved1 to DependentLoadFlags uint16_t dependent_load_flags() const { return reserved1_; } - //! Reserved for use by the system. + /// Reserved for use by the system. uint32_t editlist() const { return editlist_; } - //! A pointer to a cookie that is used by Visual C++ or GS - //! implementation. + /// A pointer to a cookie that is used by Visual C++ or GS + /// implementation. uint64_t security_cookie() const { return security_cookie_; } diff --git a/include/LIEF/PE/LoadConfigurations/LoadConfigurationV0.hpp b/include/LIEF/PE/LoadConfigurations/LoadConfigurationV0.hpp index b90b704625..29ded86a84 100644 --- a/include/LIEF/PE/LoadConfigurations/LoadConfigurationV0.hpp +++ b/include/LIEF/PE/LoadConfigurations/LoadConfigurationV0.hpp @@ -28,7 +28,7 @@ template struct load_configuration_v0; } -//! LoadConfiguration enhanced with SEH +/// LoadConfiguration enhanced with SEH class LIEF_API LoadConfigurationV0 : public LoadConfiguration { public: static constexpr VERSION WIN_VERSION = VERSION::SEH; @@ -45,13 +45,13 @@ class LIEF_API LoadConfigurationV0 : public LoadConfiguration { return WIN_VERSION; } - //! The VA of the sorted table of RVAs of each valid, unique - //! SE handler in the image. + /// The VA of the sorted table of RVAs of each valid, unique + /// SE handler in the image. uint64_t se_handler_table() const { return se_handler_table_; } - //! The count of unique handlers in the table. + /// The count of unique handlers in the table. uint64_t se_handler_count() const { return se_handler_count_; } diff --git a/include/LIEF/PE/LoadConfigurations/LoadConfigurationV1.hpp b/include/LIEF/PE/LoadConfigurations/LoadConfigurationV1.hpp index 13b8aa2d63..d8bd8052ce 100644 --- a/include/LIEF/PE/LoadConfigurations/LoadConfigurationV1.hpp +++ b/include/LIEF/PE/LoadConfigurations/LoadConfigurationV1.hpp @@ -30,9 +30,9 @@ namespace details { template struct load_configuration_v1; } -//! LoadConfiguration enhanced with Control Flow Guard -//! -//! This structure is available from Windows 8.1 +/// LoadConfiguration enhanced with Control Flow Guard +/// +/// This structure is available from Windows 8.1 class LIEF_API LoadConfigurationV1 : public LoadConfigurationV0 { public: static constexpr VERSION WIN_VERSION = VERSION::WIN_8_1; @@ -67,37 +67,37 @@ class LIEF_API LoadConfigurationV1 : public LoadConfigurationV0 { return WIN_VERSION; } - //! @brief The VA where Control Flow Guard check-function pointer is stored. + /// The VA where Control Flow Guard check-function pointer is stored. uint64_t guard_cf_check_function_pointer() const { return guard_cf_check_function_pointer_; } - //! @brief The VA where Control Flow Guard dispatch-function pointer is stored. + /// The VA where Control Flow Guard dispatch-function pointer is stored. uint64_t guard_cf_dispatch_function_pointer() const { return guard_cf_dispatch_function_pointer_; } - //! @brief The VA of the sorted table of RVAs of each Control Flow Guard - //! function in the image. + /// The VA of the sorted table of RVAs of each Control Flow Guard + /// function in the image. uint64_t guard_cf_function_table() const { return guard_cf_function_table_; } - //! @brief The count of unique RVAs in the - //! LoadConfigurationV1::guard_cf_function_table. + /// The count of unique RVAs in the + /// LoadConfigurationV1::guard_cf_function_table. uint64_t guard_cf_function_count() const { return guard_cf_function_count_; } - //! @brief Control Flow Guard related flags. + /// Control Flow Guard related flags. IMAGE_GUARD guard_flags() const { return flags_; } - //! @brief Check if the given flag is present in LoadConfigurationV1::guard_flags + /// Check if the given flag is present in LoadConfigurationV1::guard_flags bool has(IMAGE_GUARD flag) const; - //! @brief LoadConfigurationV1::guard_flags as a list of LIEF::PE::GUARD_CF_FLAGS + /// LoadConfigurationV1::guard_flags as a list of LIEF::PE::GUARD_CF_FLAGS std::vector guard_cf_flags_list() const; void guard_cf_check_function_pointer(uint64_t check_pointer) { diff --git a/include/LIEF/PE/LoadConfigurations/LoadConfigurationV2.hpp b/include/LIEF/PE/LoadConfigurations/LoadConfigurationV2.hpp index 358d4b8af0..4e08d0c076 100644 --- a/include/LIEF/PE/LoadConfigurations/LoadConfigurationV2.hpp +++ b/include/LIEF/PE/LoadConfigurations/LoadConfigurationV2.hpp @@ -30,7 +30,7 @@ template struct load_configuration_v2; } -//! @brief LoadConfiguration enhanced with code integrity +/// LoadConfiguration enhanced with code integrity class LIEF_API LoadConfigurationV2 : public LoadConfigurationV1 { public: static constexpr VERSION WIN_VERSION = VERSION::WIN_10_0_9879; @@ -47,7 +47,7 @@ class LIEF_API LoadConfigurationV2 : public LoadConfigurationV1 { return WIN_VERSION; } - //! @brief CodeIntegrity associated with + /// CodeIntegrity associated with const CodeIntegrity& code_integrity() const { return code_integrity_; } diff --git a/include/LIEF/PE/LoadConfigurations/LoadConfigurationV3.hpp b/include/LIEF/PE/LoadConfigurations/LoadConfigurationV3.hpp index 0766d6ccee..157c90c3df 100644 --- a/include/LIEF/PE/LoadConfigurations/LoadConfigurationV3.hpp +++ b/include/LIEF/PE/LoadConfigurations/LoadConfigurationV3.hpp @@ -28,7 +28,7 @@ template struct load_configuration_v3; } -//! @brief LoadConfiguration with Control Flow Guard improved +/// LoadConfiguration with Control Flow Guard improved class LIEF_API LoadConfigurationV3 : public LoadConfigurationV2 { public: @@ -46,22 +46,22 @@ class LIEF_API LoadConfigurationV3 : public LoadConfigurationV2 { return WIN_VERSION; } - //! @brief VA of a table associated with CFG's *IAT* checks + /// VA of a table associated with CFG's *IAT* checks uint64_t guard_address_taken_iat_entry_table() const { return guard_address_taken_iat_entry_table_; } - //! @brief Number of entries in the LoadConfigurationV3::guard_address_taken_iat_entry_table + /// Number of entries in the LoadConfigurationV3::guard_address_taken_iat_entry_table uint64_t guard_address_taken_iat_entry_count() const { return guard_address_taken_iat_entry_count_; } - //! @brief VA of a table associated with CFG's *long jump* + /// VA of a table associated with CFG's *long jump* uint64_t guard_long_jump_target_table() const { return guard_long_jump_target_table_; } - //! @brief Number of entries in the LoadConfigurationV3::guard_long_jump_target_table + /// Number of entries in the LoadConfigurationV3::guard_long_jump_target_table uint64_t guard_long_jump_target_count() const { return guard_long_jump_target_count_; } diff --git a/include/LIEF/PE/LoadConfigurations/LoadConfigurationV4.hpp b/include/LIEF/PE/LoadConfigurations/LoadConfigurationV4.hpp index 662ef3bef6..71bdb96c11 100644 --- a/include/LIEF/PE/LoadConfigurations/LoadConfigurationV4.hpp +++ b/include/LIEF/PE/LoadConfigurations/LoadConfigurationV4.hpp @@ -29,9 +29,9 @@ template struct load_configuration_v4; } -//! @brief Load Configuration enhanced with -//! * Kind of dynamic relocations -//! * *Hybrid Metadata Pointer* +/// Load Configuration enhanced with +/// * Kind of dynamic relocations +/// * *Hybrid Metadata Pointer* class LIEF_API LoadConfigurationV4 : public LoadConfigurationV3 { public: static constexpr VERSION WIN_VERSION = VERSION::WIN_10_0_14383; @@ -48,7 +48,7 @@ class LIEF_API LoadConfigurationV4 : public LoadConfigurationV3 { return WIN_VERSION; } - //! @brief VA of pointing to a ``IMAGE_DYNAMIC_RELOCATION_TABLE`` + /// VA of pointing to a ``IMAGE_DYNAMIC_RELOCATION_TABLE`` uint64_t dynamic_value_reloc_table() const { return dynamic_value_reloc_table_; } diff --git a/include/LIEF/PE/LoadConfigurations/LoadConfigurationV5.hpp b/include/LIEF/PE/LoadConfigurations/LoadConfigurationV5.hpp index c3d9e27b6d..46deab9da4 100644 --- a/include/LIEF/PE/LoadConfigurations/LoadConfigurationV5.hpp +++ b/include/LIEF/PE/LoadConfigurations/LoadConfigurationV5.hpp @@ -28,7 +28,7 @@ template struct load_configuration_v5; } -//! @brief Load Configuration enhanced with Return Flow Guard +/// Load Configuration enhanced with Return Flow Guard class LIEF_API LoadConfigurationV5 : public LoadConfigurationV4 { public: static constexpr VERSION WIN_VERSION = VERSION::WIN_10_0_14901; @@ -44,27 +44,27 @@ class LIEF_API LoadConfigurationV5 : public LoadConfigurationV4 { return WIN_VERSION; } - //! @brief VA of the failure routine + /// VA of the failure routine uint64_t guard_rf_failure_routine() const { return guard_rf_failure_routine_; } - //! @brief VA of the failure routine ``fptr``. + /// VA of the failure routine ``fptr``. uint64_t guard_rf_failure_routine_function_pointer() const { return guard_rf_failure_routine_function_pointer_; } - //! @brief Offset of dynamic relocation table relative to the relocation table + /// Offset of dynamic relocation table relative to the relocation table uint32_t dynamic_value_reloctable_offset() const { return dynamic_value_reloctable_offset_; } - //! The section index of the dynamic value relocation table + /// The section index of the dynamic value relocation table uint16_t dynamic_value_reloctable_section() const { return dynamic_value_reloctable_section_; } - //! @brief Must be zero + /// Must be zero uint16_t reserved2() const { return reserved2_; } diff --git a/include/LIEF/PE/LoadConfigurations/LoadConfigurationV6.hpp b/include/LIEF/PE/LoadConfigurations/LoadConfigurationV6.hpp index 375a6d9f08..5b26cfd9c0 100644 --- a/include/LIEF/PE/LoadConfigurations/LoadConfigurationV6.hpp +++ b/include/LIEF/PE/LoadConfigurations/LoadConfigurationV6.hpp @@ -29,7 +29,7 @@ template struct load_configuration_v6; } -//! @brief Load Configuration enhanced with Hotpatch and improved RFG +/// Load Configuration enhanced with Hotpatch and improved RFG class LIEF_API LoadConfigurationV6 : public LoadConfigurationV5 { public: static constexpr VERSION WIN_VERSION = VERSION::WIN_10_0_15002; @@ -46,12 +46,12 @@ class LIEF_API LoadConfigurationV6 : public LoadConfigurationV5 { return WIN_VERSION; } - //! @brief VA of the Function verifying the stack pointer + /// VA of the Function verifying the stack pointer uint64_t guard_rf_verify_stackpointer_function_pointer() const { return guardrf_verify_stackpointer_function_pointer_; } - //! @brief Offset to the *hotpatch* table + /// Offset to the *hotpatch* table uint32_t hotpatch_table_offset() const { return hotpatch_table_offset_; } diff --git a/include/LIEF/PE/OptionalHeader.hpp b/include/LIEF/PE/OptionalHeader.hpp index 5c6016107e..ae77bdf7f6 100644 --- a/include/LIEF/PE/OptionalHeader.hpp +++ b/include/LIEF/PE/OptionalHeader.hpp @@ -35,10 +35,10 @@ struct pe32_optional_header; struct pe64_optional_header; } -//! Class which represents the PE OptionalHeader structure -//! -//! Note that the term *optional* comes from the COFF specifications but this -//! header is **mandatory** for a PE binary. +/// Class which represents the PE OptionalHeader structure +/// +/// Note that the term *optional* comes from the COFF specifications but this +/// header is **mandatory** for a PE binary. class LIEF_API OptionalHeader : public Object { friend class Parser; friend class Binary; @@ -84,200 +84,200 @@ class LIEF_API OptionalHeader : public Object { static OptionalHeader create(PE_TYPE type); - //! Magic bytes: either ``PE32`` or ``PE32+`` for 64-bits PE files + /// Magic bytes: either ``PE32`` or ``PE32+`` for 64-bits PE files PE_TYPE magic() const { return magic_; } - //! The linker major version + /// The linker major version uint8_t major_linker_version() const { return major_linker_version_; } - //! The linker minor version + /// The linker minor version uint8_t minor_linker_version() const { return minor_linker_version_; } - //! The size of the code ``.text`` section or the sum of - //! all the sections that contain code (i.e. PE::Section with the flag Section::CHARACTERISTICS::CNT_CODE) + /// The size of the code ``.text`` section or the sum of + /// all the sections that contain code (i.e. PE::Section with the flag Section::CHARACTERISTICS::CNT_CODE) uint32_t sizeof_code() const { return sizeof_code_; } - //! The size of the initialized data which are usually located in the ``.data`` section. - //! If the initialized data are split across multiple sections, it is the sum of the sections. - //! - //! The sections associated with the initialized data are usually identified with the - //! flag Section::CHARACTERISTICS::CNT_INITIALIZED_DATA + /// The size of the initialized data which are usually located in the ``.data`` section. + /// If the initialized data are split across multiple sections, it is the sum of the sections. + /// + /// The sections associated with the initialized data are usually identified with the + /// flag Section::CHARACTERISTICS::CNT_INITIALIZED_DATA uint32_t sizeof_initialized_data() const { return sizeof_initialized_data_; } - //! The size of the uninitialized data which are usually located in the ``.bss`` section. - //! If the uninitialized data are split across multiple sections, it is the sum of the sections. - //! - //! The sections associated with the uninitialized data are usually identified with the - //! flag Section::CHARACTERISTICS::CNT_UNINITIALIZED_DATA + /// The size of the uninitialized data which are usually located in the ``.bss`` section. + /// If the uninitialized data are split across multiple sections, it is the sum of the sections. + /// + /// The sections associated with the uninitialized data are usually identified with the + /// flag Section::CHARACTERISTICS::CNT_UNINITIALIZED_DATA uint32_t sizeof_uninitialized_data() const { return sizeof_uninitialized_data_; } - //! The address of the entry point relative to the image base when the executable file is - //! loaded into memory. For program images, this is the starting address. For device - //! drivers, this is the address of the initialization function. - //! - //! An entry point is optional for DLLs. When no entry point is present, this field must be zero. + /// The address of the entry point relative to the image base when the executable file is + /// loaded into memory. For program images, this is the starting address. For device + /// drivers, this is the address of the initialization function. + /// + /// An entry point is optional for DLLs. When no entry point is present, this field must be zero. uint32_t addressof_entrypoint() const { return entrypoint_; } - //! Address relative to the imagebase where the binary's code starts. + /// Address relative to the imagebase where the binary's code starts. uint32_t baseof_code() const { return baseof_code_; } - //! Address relative to the imagebase where the binary's data starts. - //! - //! @warning This value is not present for PE64 files + /// Address relative to the imagebase where the binary's data starts. + /// + /// @warning This value is not present for PE64 files uint32_t baseof_data() const { return baseof_data_; } - //! The preferred base address when mapping the binary in memory + /// The preferred base address when mapping the binary in memory uint64_t imagebase() const { return imagebase_; } - //! The alignment (in bytes) of sections when they are loaded into memory. - //! - //! It must be greater than or equal to file_alignment and - //! the default is the page size for the architecture. + /// The alignment (in bytes) of sections when they are loaded into memory. + /// + /// It must be greater than or equal to file_alignment and + /// the default is the page size for the architecture. uint32_t section_alignment() const { return section_align_; } - //! The section's file alignment. This value must be a power of 2 between 512 and 64K. - //! The default value is usually 512 + /// The section's file alignment. This value must be a power of 2 between 512 and 64K. + /// The default value is usually 512 uint32_t file_alignment() const { return file_align_; } - //! The **major** version number of the required operating system + /// The **major** version number of the required operating system uint16_t major_operating_system_version() const { return major_os_version_; } - //! The **minor** version number of the required operating system + /// The **minor** version number of the required operating system uint16_t minor_operating_system_version() const { return minor_os_version_; } - //! The major version number of the image + /// The major version number of the image uint16_t major_image_version() const { return major_image_version_; } - //! The minor version number of the image + /// The minor version number of the image uint16_t minor_image_version() const { return minor_image_version_; } - //! The major version number of the subsystem + /// The major version number of the subsystem uint16_t major_subsystem_version() const { return major_subsys_version_; } - //! The minor version number of the subsystem + /// The minor version number of the subsystem uint16_t minor_subsystem_version() const { return minor_subsys_version_; } - //! According to the official PE specifications, this value - //! is reserved and **should** be 0. + /// According to the official PE specifications, this value + /// is reserved and **should** be 0. uint32_t win32_version_value() const { return win32_version_value_; } - //! The size (in bytes) of the image, including all headers, as the image is loaded in memory. - //! - //! It must be a multiple of section_alignment and should match Binary::virtual_size + /// The size (in bytes) of the image, including all headers, as the image is loaded in memory. + /// + /// It must be a multiple of section_alignment and should match Binary::virtual_size uint32_t sizeof_image() const { return sizeof_image_; } - //! Size of the DosHeader + PE Header + Section headers rounded up to a multiple of the file_alignment + /// Size of the DosHeader + PE Header + Section headers rounded up to a multiple of the file_alignment uint32_t sizeof_headers() const { return sizeof_headers_; } - //! The image file checksum. The algorithm for computing the checksum is incorporated into ``IMAGHELP.DLL``. - //! - //! The following are checked for validation at load time all **drivers**, any **DLL loaded at boot** - //! time, and any **DLL** that is loaded into a **critical** Windows process. + /// The image file checksum. The algorithm for computing the checksum is incorporated into ``IMAGHELP.DLL``. + /// + /// The following are checked for validation at load time all **drivers**, any **DLL loaded at boot** + /// time, and any **DLL** that is loaded into a **critical** Windows process. uint32_t checksum() const { return checksum_; } - //! Target subsystem like Driver, XBox, Windows GUI, ... + /// Target subsystem like Driver, XBox, Windows GUI, ... SUBSYSTEM subsystem() const { return subsystem_; } - //! Some characteristics of the underlying binary like the support of the PIE. - //! The prefix ``dll`` comes from the official PE specifications but these characteristics - //! are also used for **executables** + /// Some characteristics of the underlying binary like the support of the PIE. + /// The prefix ``dll`` comes from the official PE specifications but these characteristics + /// are also used for **executables** uint32_t dll_characteristics() const { return dll_characteristics_; } - //! Size of the stack to reserve when loading the PE binary - //! - //! Only OptionalHeader::sizeof_stack_commit is committed, the rest is made - //! available one page at a time until the reserve size is reached. + /// Size of the stack to reserve when loading the PE binary + /// + /// Only OptionalHeader::sizeof_stack_commit is committed, the rest is made + /// available one page at a time until the reserve size is reached. uint64_t sizeof_stack_reserve() const { return sizeof_stack_reserve_; } - //! Size of the stack to commit + /// Size of the stack to commit uint64_t sizeof_stack_commit() const { return sizeof_stack_commit_; } - //! Size of the heap to reserve when loading the PE binary + /// Size of the heap to reserve when loading the PE binary uint64_t sizeof_heap_reserve() const { return sizeof_heap_reserve_; } - //! Size of the heap to commit + /// Size of the heap to commit uint64_t sizeof_heap_commit() const { return sizeof_heap_commit_; } - //! According to the PE specifications, this value is *reserved* and **should** be 0. + /// According to the PE specifications, this value is *reserved* and **should** be 0. uint32_t loader_flags() const { return loader_flags_; } - //! The number of DataDirectory that follow this header. + /// The number of DataDirectory that follow this header. uint32_t numberof_rva_and_size() const { return nb_rva_size_; } - //! Check if the given DLL_CHARACTERISTICS is included in the dll_characteristics + /// Check if the given DLL_CHARACTERISTICS is included in the dll_characteristics bool has(DLL_CHARACTERISTICS c) const { return (dll_characteristics() & static_cast(c)) != 0; } - //! Return the list of the dll_characteristics as an std::set of DLL_CHARACTERISTICS + /// Return the list of the dll_characteristics as an std::set of DLL_CHARACTERISTICS std::vector dll_characteristics_list() const; - //! Add a DLL_CHARACTERISTICS to the current characteristics + /// Add a DLL_CHARACTERISTICS to the current characteristics void add(DLL_CHARACTERISTICS c) { dll_characteristics(dll_characteristics() | static_cast(c)); } - //! Remove a DLL_CHARACTERISTICS from the current characteristics + /// Remove a DLL_CHARACTERISTICS from the current characteristics void remove(DLL_CHARACTERISTICS c) { dll_characteristics(dll_characteristics() & (~ static_cast(c))); } diff --git a/include/LIEF/PE/Parser.hpp b/include/LIEF/PE/Parser.hpp index 49b8f96632..569261794a 100644 --- a/include/LIEF/PE/Parser.hpp +++ b/include/LIEF/PE/Parser.hpp @@ -42,12 +42,12 @@ struct pe_resource_directory_table; struct pe_debug; } -//! Main interface to parse PE binaries. In particular the **static** functions: -//! Parser::parse should be used to get a LIEF::PE::Binary +/// Main interface to parse PE binaries. In particular the **static** functions: +/// Parser::parse should be used to get a LIEF::PE::Binary class LIEF_API Parser : public LIEF::Parser { public: - //! Maximum size of the data read + /// Maximum size of the data read static constexpr size_t MAX_DATA_SIZE = 3_GB; static constexpr size_t MAX_TLS_CALLBACKS = 3000; @@ -55,34 +55,34 @@ class LIEF_API Parser : public LIEF::Parser { // According to https://stackoverflow.com/a/265782/87207 static constexpr size_t MAX_DLL_NAME_SIZE = 255; - //! Max size of the padding section + /// Max size of the padding section static constexpr size_t MAX_PADDING_SIZE = 1_GB; public: - //! Check if the given name is a valid import. - //! - //! This check verified that: - //! 1. The name is not too large or empty (cf. https://stackoverflow.com/a/23340781) - //! 2. All the characters are printable + /// Check if the given name is a valid import. + /// + /// This check verified that: + /// 1. The name is not too large or empty (cf. https://stackoverflow.com/a/23340781) + /// 2. All the characters are printable static bool is_valid_import_name(const std::string& name); - //! Check if the given name is a valid DLL name. - //! - //! This check verifies that: - //! 1. The name of the DLL is at 4 - //! 2. All the characters are printable + /// Check if the given name is a valid DLL name. + /// + /// This check verifies that: + /// 1. The name of the DLL is at 4 + /// 2. All the characters are printable static bool is_valid_dll_name(const std::string& name); public: - //! Parse a PE binary from the given filename + /// Parse a PE binary from the given filename static std::unique_ptr parse(const std::string& filename, const ParserConfig& conf = ParserConfig::all()); - //! Parse a PE binary from a data buffer + /// Parse a PE binary from a data buffer static std::unique_ptr parse(std::vector data, const ParserConfig& conf = ParserConfig::all()); - //! Parse a PE binary from the given BinaryStream + /// Parse a PE binary from the given BinaryStream static std::unique_ptr parse(std::unique_ptr stream, const ParserConfig& conf = ParserConfig::all()); diff --git a/include/LIEF/PE/ParserConfig.hpp b/include/LIEF/PE/ParserConfig.hpp index bdffd780a1..7eea383959 100644 --- a/include/LIEF/PE/ParserConfig.hpp +++ b/include/LIEF/PE/ParserConfig.hpp @@ -20,7 +20,7 @@ namespace LIEF { namespace PE { -//! This structure is used to tweak the PE Parser (PE::Parser) +/// This structure is used to tweak the PE Parser (PE::Parser) struct LIEF_API ParserConfig { static ParserConfig all() { static const ParserConfig DEFAULT; diff --git a/include/LIEF/PE/Relocation.hpp b/include/LIEF/PE/Relocation.hpp index b54aa3ac2b..e2beae3f82 100644 --- a/include/LIEF/PE/Relocation.hpp +++ b/include/LIEF/PE/Relocation.hpp @@ -32,8 +32,8 @@ namespace details { struct pe_base_relocation_block; } -//! Class which represents the *Base Relocation Block* -//! We usually find this structure in the ``.reloc`` section +/// Class which represents the *Base Relocation Block* +/// We usually find this structure in the ``.reloc`` section class LIEF_API Relocation : public Object { friend class Parser; friend class Builder; @@ -51,18 +51,18 @@ class LIEF_API Relocation : public Object { void swap(Relocation& other); - //! The RVA for which the offset of the relocation entries (RelocationEntry) is added + /// The RVA for which the offset of the relocation entries (RelocationEntry) is added uint32_t virtual_address() const { return virtual_address_; } - //! The total number of bytes in the base relocation block. - //! ``block_size = sizeof(BaseRelocationBlock) + nb_of_relocs * sizeof(uint16_t = RelocationEntry)`` + /// The total number of bytes in the base relocation block. + /// ``block_size = sizeof(BaseRelocationBlock) + nb_of_relocs * sizeof(uint16_t = RelocationEntry)`` uint32_t block_size() const { return block_size_; } - //! Iterator over the RelocationEntry + /// Iterator over the RelocationEntry it_const_entries entries() const { return entries_; } diff --git a/include/LIEF/PE/RelocationEntry.hpp b/include/LIEF/PE/RelocationEntry.hpp index 38dd921aba..bdd2b08510 100644 --- a/include/LIEF/PE/RelocationEntry.hpp +++ b/include/LIEF/PE/RelocationEntry.hpp @@ -30,9 +30,9 @@ namespace PE { class Relocation; -//! Class which represents an entry of the PE relocation table -//! -//! It extends the LIEF::Relocation object to provide an uniform API across the file formats +/// Class which represents an entry of the PE relocation table +/// +/// It extends the LIEF::Relocation object to provide an uniform API across the file formats class LIEF_API RelocationEntry : public LIEF::Relocation { friend class Parser; @@ -82,27 +82,27 @@ class LIEF_API RelocationEntry : public LIEF::Relocation { void swap(RelocationEntry& other); - //! The address of the relocation + /// The address of the relocation uint64_t address() const override; void address(uint64_t address) override; - //! The size of the relocatable pointer + /// The size of the relocatable pointer size_t size() const override; void size(size_t size) override; - //! Raw data of the relocation: - //! - The **high** 4 bits store the relocation type - //! - The **low** 12 bits store the relocation offset + /// Raw data of the relocation: + /// - The **high** 4 bits store the relocation type + /// - The **low** 12 bits store the relocation offset uint16_t data() const; - //! Offset relative to Relocation::virtual_address where the relocation occurs. + /// Offset relative to Relocation::virtual_address where the relocation occurs. uint16_t position() const { return position_; } - //! Type of the relocation + /// Type of the relocation BASE_TYPES type() const { return type_; } diff --git a/include/LIEF/PE/ResourceData.hpp b/include/LIEF/PE/ResourceData.hpp index 34c470f52b..4dd279a835 100644 --- a/include/LIEF/PE/ResourceData.hpp +++ b/include/LIEF/PE/ResourceData.hpp @@ -28,7 +28,7 @@ namespace PE { class Parser; class Builder; -//! Class which represents a Data Node in the PE resources tree +/// Class which represents a Data Node in the PE resources tree class LIEF_API ResourceData : public ResourceNode { friend class Parser; @@ -54,13 +54,13 @@ class LIEF_API ResourceData : public ResourceNode { return std::unique_ptr{new ResourceData{*this}}; } - //! Return the code page that is used to decode code point - //! values within the resource data. Typically, the code page is the unicode code page. + /// Return the code page that is used to decode code point + /// values within the resource data. Typically, the code page is the unicode code page. uint32_t code_page() const { return code_page_; } - //! Resource content + /// Resource content span content() const { return content_; } @@ -68,14 +68,14 @@ class LIEF_API ResourceData : public ResourceNode { return content_; } - //! Reserved value. Should be ``0`` + /// Reserved value. Should be ``0`` uint32_t reserved() const { return reserved_; } - //! Offset of the content within the resource - //! - //! @warning This value may change when rebuilding resource table + /// Offset of the content within the resource + /// + /// @warning This value may change when rebuilding resource table uint32_t offset() const { return offset_; } diff --git a/include/LIEF/PE/ResourceDirectory.hpp b/include/LIEF/PE/ResourceDirectory.hpp index 58bc4a69b1..cea4b65f08 100644 --- a/include/LIEF/PE/ResourceDirectory.hpp +++ b/include/LIEF/PE/ResourceDirectory.hpp @@ -52,38 +52,38 @@ class LIEF_API ResourceDirectory : public ResourceNode { return std::unique_ptr(new ResourceDirectory{*this}); } - //! Resource characteristics. This field is reserved for future use. - //! It is currently set to zero. + /// Resource characteristics. This field is reserved for future use. + /// It is currently set to zero. uint32_t characteristics() const { return characteristics_; } - //! The time that the resource data was created by the - //! resource compiler. + /// The time that the resource data was created by the + /// resource compiler. uint32_t time_date_stamp() const { return timedatestamp_; } - //! The major version number, set by the user. + /// The major version number, set by the user. uint16_t major_version() const { return majorversion_; } - //! The minor version number, set by the user. + /// The minor version number, set by the user. uint16_t minor_version() const { return minorversion_; } - //! The number of directory entries immediately - //! following the table that use strings to identify Type, - //! Name, or Language entries (depending on the level of the table). + /// The number of directory entries immediately + /// following the table that use strings to identify Type, + /// Name, or Language entries (depending on the level of the table). uint16_t numberof_name_entries() const { return numberof_name_entries_; } - //! The number of directory entries immediately - //! following the Name entries that use numeric IDs for - //! Type, Name, or Language entries. + /// The number of directory entries immediately + /// following the Name entries that use numeric IDs for + /// Type, Name, or Language entries. uint16_t numberof_id_entries() const { return numberof_id_entries_; } diff --git a/include/LIEF/PE/ResourceNode.hpp b/include/LIEF/PE/ResourceNode.hpp index 0484766738..5f13b91478 100644 --- a/include/LIEF/PE/ResourceNode.hpp +++ b/include/LIEF/PE/ResourceNode.hpp @@ -32,7 +32,7 @@ class ResourceData; class Parser; class Builder; -//! Class which represents a Node in the resource tree. +/// Class which represents a Node in the resource tree. class LIEF_API ResourceNode : public Object { friend class Parser; @@ -62,18 +62,18 @@ class LIEF_API ResourceNode : public Object { virtual std::unique_ptr clone() const = 0; - //! Integer that identifies the Type, Name, or Language ID of the entry - //! depending on its depth in the tree + /// Integer that identifies the Type, Name, or Language ID of the entry + /// depending on its depth in the tree uint32_t id() const { return id_; } - //! Name of the entry + /// Name of the entry const std::u16string& name() const { return name_; } - //! Iterator on node's children + /// Iterator on node's children it_childs childs() { return childs_; } @@ -81,34 +81,34 @@ class LIEF_API ResourceNode : public Object { return childs_; } - //! ``True`` if the entry uses a name as ID + /// ``True`` if the entry uses a name as ID bool has_name() const { return static_cast(id() & 0x80000000); } - //! Current depth of the Node in the resource tree + /// Current depth of the Node in the resource tree uint32_t depth() const { return depth_; } - //! ``True`` if the current entry is a ResourceDirectory. - //! - //! It can be safely casted with: - //! - //! ```cpp - //! const auto& dir_node = static_cast(node); - //! ``` + /// ``True`` if the current entry is a ResourceDirectory. + /// + /// It can be safely casted with: + /// + /// ```cpp + /// const auto& dir_node = static_cast(node); + /// ``` bool is_directory() const { return type_ == TYPE::DIRECTORY; } - //! ``True`` if the current entry is a ResourceData. - //! - //! It can be safely casted with: - //! - //! ```cpp - //! const auto& data_node = static_cast(node); - //! ``` + /// ``True`` if the current entry is a ResourceData. + /// + /// It can be safely casted with: + /// + /// ```cpp + /// const auto& data_node = static_cast(node); + /// ``` bool is_data() const { return type_ == TYPE::DATA; } @@ -122,16 +122,16 @@ class LIEF_API ResourceNode : public Object { name_ = std::move(name); } - //! Add a ResourceDirectory to the current node + /// Add a ResourceDirectory to the current node ResourceNode& add_child(const ResourceDirectory& child); - //! Add a ResourceData to the current node + /// Add a ResourceData to the current node ResourceNode& add_child(const ResourceData& child); - //! Delete the node with the given ``id`` + /// Delete the node with the given ``id`` void delete_child(uint32_t id); - //! Delete the given node from the node's children + /// Delete the given node from the node's children void delete_child(const ResourceNode& node); void accept(Visitor& visitor) const override; diff --git a/include/LIEF/PE/ResourcesManager.hpp b/include/LIEF/PE/ResourcesManager.hpp index dc4103c735..82c607c7d0 100644 --- a/include/LIEF/PE/ResourcesManager.hpp +++ b/include/LIEF/PE/ResourcesManager.hpp @@ -34,7 +34,7 @@ class VectorStream; namespace PE { class ResourceNode; -//! The Resource Manager provides an enhanced API to manipulate the resource tree. +/// The Resource Manager provides an enhanced API to manipulate the resource tree. class LIEF_API ResourcesManager : public Object { public: @@ -98,86 +98,86 @@ class LIEF_API ResourcesManager : public Object { ~ResourcesManager() override = default; - //! Return the ResourceNode associated with the given KIND - //! or a nullptr if not found; + /// Return the ResourceNode associated with the given KIND + /// or a nullptr if not found; ResourceNode* get_node_type(TYPE type); const ResourceNode* get_node_type(TYPE type) const; - //! List of TYPE present in the resources + /// List of TYPE present in the resources std::vector get_types() const; - //! ``true`` if the resource has the given LIEF::PE::KIND + /// ``true`` if the resource has the given LIEF::PE::KIND bool has_type(TYPE type) const { return get_node_type(type) != nullptr; } - //! ``true`` if resources contain the Manifest element + /// ``true`` if resources contain the Manifest element bool has_manifest() const { return get_node_type(TYPE::MANIFEST) != nullptr; } - //! Return the manifest as a std::string or an empty string if not found - //! or corrupted + /// Return the manifest as a std::string or an empty string if not found + /// or corrupted std::string manifest() const; - //! Update the manifest with the given string + /// Update the manifest with the given string void manifest(const std::string& manifest); - //! ``true`` if resources contain a LIEF::PE::ResourceVersion + /// ``true`` if resources contain a LIEF::PE::ResourceVersion bool has_version() const { return get_node_type(TYPE::VERSION) != nullptr; } - //! Return the ResourceVersion if any + /// Return the ResourceVersion if any result version() const; - //! ``true`` if resources contain a LIEF::PE::ResourceIcon + /// ``true`` if resources contain a LIEF::PE::ResourceIcon bool has_icons() const { return get_node_type(TYPE::ICON) != nullptr && get_node_type(TYPE::GROUP_ICON) != nullptr; } - //! Return the list of the icons present in the resources + /// Return the list of the icons present in the resources it_const_icons icons() const; - //! Add an icon to the resources + /// Add an icon to the resources void add_icon(const ResourceIcon& icon); void change_icon(const ResourceIcon& original, const ResourceIcon& newone); - //! ``true`` if resources contain @link LIEF::PE::ResourceDialog dialogs @endlink + /// ``true`` if resources contain @link LIEF::PE::ResourceDialog dialogs @endlink bool has_dialogs() const { return get_node_type(TYPE::DIALOG) != nullptr; } - //! Return the list of the dialogs present in the resource + /// Return the list of the dialogs present in the resource it_const_dialogs dialogs() const; - //! ``true`` if the resources contain a @link LIEF::PE::ResourceStringTable @endlink + /// ``true`` if the resources contain a @link LIEF::PE::ResourceStringTable @endlink bool has_string_table() const { return get_node_type(TYPE::STRING) != nullptr; } - //! Return the list of the string table in the resource + /// Return the list of the string table in the resource it_const_strings_table string_table() const; - //! ``true`` if the resources contain html + /// ``true`` if the resources contain html bool has_html() const { return get_node_type(TYPE::HTML) != nullptr; } - //! Return the list of the html resources + /// Return the list of the html resources std::vector html() const; - //! ``true`` if the resources contain @link LIEF::PE::ResourceAccelerator @endlink + /// ``true`` if the resources contain @link LIEF::PE::ResourceAccelerator @endlink bool has_accelerator() const { return get_node_type(TYPE::ACCELERATOR) != nullptr; } - //! Return the list of the accelerator in the resource + /// Return the list of the accelerator in the resource it_const_accelerators accelerator() const; - //!Print the resource tree to the given depth + ///Print the resource tree to the given depth std::string print(uint32_t depth = 0) const; void accept(Visitor& visitor) const override; diff --git a/include/LIEF/PE/RichEntry.hpp b/include/LIEF/PE/RichEntry.hpp index 7eba482947..7a2cf5866e 100644 --- a/include/LIEF/PE/RichEntry.hpp +++ b/include/LIEF/PE/RichEntry.hpp @@ -24,7 +24,7 @@ namespace LIEF { namespace PE { -//! Class which represents an entry associated to the RichHeader +/// Class which represents an entry associated to the RichHeader class LIEF_API RichEntry : public Object { public: @@ -39,17 +39,17 @@ class LIEF_API RichEntry : public Object { RichEntry& operator=(const RichEntry&) = default; ~RichEntry() override = default; - //! Entry type + /// Entry type uint16_t id() const { return id_; } - //! Build number of the tool (if any) + /// Build number of the tool (if any) uint16_t build_id() const { return build_id_; } - //! *Occurrence* count. + /// *Occurrence* count. uint32_t count() const { return count_; } diff --git a/include/LIEF/PE/RichHeader.hpp b/include/LIEF/PE/RichHeader.hpp index b78f13b736..bc0a8ba176 100644 --- a/include/LIEF/PE/RichHeader.hpp +++ b/include/LIEF/PE/RichHeader.hpp @@ -28,12 +28,12 @@ namespace LIEF { namespace PE { -//! Class which represents the not-so-documented rich header -//! -//! This structure is usually located at the end of the Binary::dos_stub -//! and contains information about the build environment. -//! It is generated by the Microsoft linker `link.exe` and there are no options to disable -//! or remove this information. +/// Class which represents the not-so-documented rich header +/// +/// This structure is usually located at the end of the Binary::dos_stub +/// and contains information about the build environment. +/// It is generated by the Microsoft linker `link.exe` and there are no options to disable +/// or remove this information. class LIEF_API RichHeader : public Object { public: @@ -46,12 +46,12 @@ class LIEF_API RichHeader : public Object { RichHeader& operator=(const RichHeader&) = default; ~RichHeader() override = default; - //! Key used to encode the header (xor operation) + /// Key used to encode the header (xor operation) uint32_t key() const { return key_; } - //! Return an iterator over the PE::RichEntry within the header + /// Return an iterator over the PE::RichEntry within the header it_entries entries() { return entries_; } @@ -64,38 +64,38 @@ class LIEF_API RichHeader : public Object { key_ = key; } - //! Add a new PE::RichEntry + /// Add a new PE::RichEntry void add_entry(RichEntry entry) { entries_.push_back(std::move(entry)); } - //! Add a new entry given the id, build_id and count + /// Add a new entry given the id, build_id and count void add_entry(uint16_t id, uint16_t build_id, uint32_t count) { entries_.emplace_back(id, build_id, count); } - //! The raw structure of the Rich header without xor-encoding. - //! - //! This function is equivalent as calling RichHeader::raw(uint32_t) with a `xor_key` set to 0 + /// The raw structure of the Rich header without xor-encoding. + /// + /// This function is equivalent as calling RichHeader::raw(uint32_t) with a `xor_key` set to 0 std::vector raw() const { return raw(/*xor_key=*/0); } - //! Given this rich header, this function re-computes - //! the raw bytes of the structure with the provided xor-key. - //! - //! You can access the decoded data's structure with the @p xor_key set to 0 - //! - //! @param[in] xor_key The key to use for the xor-encoding (can be 0) + /// Given this rich header, this function re-computes + /// the raw bytes of the structure with the provided xor-key. + /// + /// You can access the decoded data's structure with the @p xor_key set to 0 + /// + /// @param[in] xor_key The key to use for the xor-encoding (can be 0) std::vector raw(uint32_t xor_key) const; - //! Compute the hash of the decoded rich header structure with - //! the given hash algorithm + /// Compute the hash of the decoded rich header structure with + /// the given hash algorithm std::vector hash(ALGORITHMS algo) const { return hash(algo, /*xor_key=*/0); } - //! Compute the hash of the rich header structure encoded with the provided key. + /// Compute the hash of the rich header structure encoded with the provided key. std::vector hash(ALGORITHMS algo, uint32_t xor_key) const; void accept(Visitor& visitor) const override; diff --git a/include/LIEF/PE/Section.hpp b/include/LIEF/PE/Section.hpp index c373b828dc..790ca52e77 100644 --- a/include/LIEF/PE/Section.hpp +++ b/include/LIEF/PE/Section.hpp @@ -39,7 +39,7 @@ namespace details { struct pe_section; } -//! Class which represents a PE section +/// Class which represents a PE section class LIEF_API Section : public LIEF::Section { friend class Parser; @@ -98,77 +98,77 @@ class LIEF_API Section : public LIEF::Section { Section(const Section&) = default; ~Section() override = default; - //! Return the size of the data in the section. + /// Return the size of the data in the section. uint32_t sizeof_raw_data() const; - //! Return the size of the data when mapped in memory - //! - //! If this value is greater than sizeof_raw_data, the section is zero-padded. + /// Return the size of the data when mapped in memory + /// + /// If this value is greater than sizeof_raw_data, the section is zero-padded. uint32_t virtual_size() const { return virtual_size_; } - //! The actual content of the section + /// The actual content of the section span content() const override { return content_; } - //! Content of the section's padding area + /// Content of the section's padding area span padding() const { return padding_; } - //! The offset of the section data in the PE file + /// The offset of the section data in the PE file uint32_t pointerto_raw_data() const; - //! The file pointer to the beginning of the COFF relocation entries for the section. This is set to zero for - //! executable images or if there are no relocations. - //! - //! For modern PE binaries, this value is usually set to 0 as the relocations are managed by - //! PE::Relocation. + /// The file pointer to the beginning of the COFF relocation entries for the section. This is set to zero for + /// executable images or if there are no relocations. + /// + /// For modern PE binaries, this value is usually set to 0 as the relocations are managed by + /// PE::Relocation. uint32_t pointerto_relocation() const { return pointer_to_relocations_; } - //! The file pointer to the beginning of line-number entries for the section. - //! This is set to zero if there are no COFF line numbers. This value should be zero for an image because COFF - //! debugging information is deprecated and modern debug information relies on the PDB files. + /// The file pointer to the beginning of line-number entries for the section. + /// This is set to zero if there are no COFF line numbers. This value should be zero for an image because COFF + /// debugging information is deprecated and modern debug information relies on the PDB files. uint32_t pointerto_line_numbers() const { return pointer_to_linenumbers_; } - //! No longer used in recent PE binaries produced by Visual Studio + /// No longer used in recent PE binaries produced by Visual Studio uint16_t numberof_relocations() const { return number_of_relocations_; } - //! No longer used in recent PE binaries produced by Visual Studio + /// No longer used in recent PE binaries produced by Visual Studio uint16_t numberof_line_numbers() const { return number_of_linenumbers_; } - //! Characteristics of the section: it provides information about - //! the permissions of the section when mapped. It can also provide - //! information about the *purpose* of the section (contain code, BSS-like, ...) + /// Characteristics of the section: it provides information about + /// the permissions of the section when mapped. It can also provide + /// information about the *purpose* of the section (contain code, BSS-like, ...) uint32_t characteristics() const { return characteristics_; } - //! Deprecated do not use. It will likely change in a future release of LIEF + /// Deprecated do not use. It will likely change in a future release of LIEF bool is_type(PE_SECTION_TYPES type) const; - //! Deprecated do not use. It will likely change in a future release of LIEF + /// Deprecated do not use. It will likely change in a future release of LIEF const std::set& types() const; - //! Check if the section has the given CHARACTERISTICS + /// Check if the section has the given CHARACTERISTICS bool has_characteristic(CHARACTERISTICS c) const { return (characteristics() & static_cast(c)) > 0; } - //! List of the section characteristics as a std::set + /// List of the section characteristics as a std::set std::vector characteristics_list() const; - //! Fill the content of the section with the given ``char`` + /// Fill the content of the section with the given ``char`` void clear(uint8_t c); void content(const std::vector& data) override; diff --git a/include/LIEF/PE/Symbol.hpp b/include/LIEF/PE/Symbol.hpp index 05848a37f4..9d85fb8121 100644 --- a/include/LIEF/PE/Symbol.hpp +++ b/include/LIEF/PE/Symbol.hpp @@ -36,7 +36,7 @@ namespace details { struct pe_symbol; } -//! Class that represents a PE symbol. +/// Class that represents a PE symbol. class LIEF_API Symbol : public LIEF::Symbol { friend class Parser; @@ -62,7 +62,7 @@ class LIEF_API Symbol : public LIEF::Symbol { Section* section(); const Section* section() const; - //! @brief ``True`` if symbols are located in a section + /// ``True`` if symbols are located in a section bool has_section() const; void accept(Visitor& visitor) const override; diff --git a/include/LIEF/PE/TLS.hpp b/include/LIEF/PE/TLS.hpp index 976f7e4a1d..c7d7d20f54 100644 --- a/include/LIEF/PE/TLS.hpp +++ b/include/LIEF/PE/TLS.hpp @@ -36,9 +36,9 @@ struct pe32_tls; struct pe64_tls; } -//! Class which represents the PE Thread Local Storage -//! -//! This PE structure is also used to implement binary/library constructors. +/// Class which represents the PE Thread Local Storage +/// +/// This PE structure is also used to implement binary/library constructors. class LIEF_API TLS : public Object { friend class Parser; friend class Builder; @@ -55,65 +55,65 @@ class LIEF_API TLS : public Object { TLS(TLS&& other) noexcept = default; TLS& operator=(TLS&& other) noexcept = default; - //! List of the callback associated with the current TLS. - //! - //! These functions are called before any other functions . + /// List of the callback associated with the current TLS. + /// + /// These functions are called before any other functions . const std::vector& callbacks() const { return callbacks_; } - //! Pair ``(start address, end address)`` of the TLS template. - //! The template is a block of data that is used to initialize TLS data. - //! The system copies all of this data each time a thread is created, so it must not be - //! corrupted. + /// Pair ``(start address, end address)`` of the TLS template. + /// The template is a block of data that is used to initialize TLS data. + /// The system copies all of this data each time a thread is created, so it must not be + /// corrupted. - //! @note - //! These addresses are not RVA. It is addresses for which there should be a rebase - //! relocation in the ``.reloc`` section. + /// @note + /// These addresses are not RVA. It is addresses for which there should be a rebase + /// relocation in the ``.reloc`` section. const std::pair& addressof_raw_data() const { return va_rawdata_; } - //! The location to receive the TLS index assigned by the loader. - //! This location should be located in a writable section like `.data` + /// The location to receive the TLS index assigned by the loader. + /// This location should be located in a writable section like `.data` uint64_t addressof_index() const { return addressof_index_; } - //! Pointer to an array of TLS callback functions. - //! - //! The array is null-terminated, so if there is no callback function - //! this field points to 4 bytes set to zero. + /// Pointer to an array of TLS callback functions. + /// + /// The array is null-terminated, so if there is no callback function + /// this field points to 4 bytes set to zero. uint64_t addressof_callbacks() const { return addressof_callbacks_; } - //! Size in bytes of the zero to be *padded* after the data specified by - //! data_template. + /// Size in bytes of the zero to be *padded* after the data specified by + /// data_template. uint32_t sizeof_zero_fill() const { return sizeof_zero_fill_; } - //! The four bits [23:20] describe alignment info. - //! Possible values are those defined as `IMAGE_SCN_ALIGN_*`, which are also - //! used to describe alignment of section in object files. - //! The other 28 bits are reserved for future use. + /// The four bits [23:20] describe alignment info. + /// Possible values are those defined as `IMAGE_SCN_ALIGN_*`, which are also + /// used to describe alignment of section in object files. + /// The other 28 bits are reserved for future use. uint32_t characteristics() const { return characteristics_; } - //! The initial content used to initialize TLS data. + /// The initial content used to initialize TLS data. span data_template() const { return data_template_; } - //! True if there is a data directory associated with this entry + /// True if there is a data directory associated with this entry bool has_data_directory() const { return directory_ != nullptr; } - //! Return the DataDirectory associated with this object or a nullptr - //! If it exists, its type should be DataDirectory::TYPES::TLS_TABLE + /// Return the DataDirectory associated with this object or a nullptr + /// If it exists, its type should be DataDirectory::TYPES::TLS_TABLE DataDirectory* directory() { return directory_; } @@ -122,12 +122,12 @@ class LIEF_API TLS : public Object { return directory_; } - //! Check if there is a section associated with this entry + /// Check if there is a section associated with this entry bool has_section() const { return section_ != nullptr; } - //! The section associated with the entry (or a nullptr) + /// The section associated with the entry (or a nullptr) Section* section() { return section_; } diff --git a/include/LIEF/PE/debug/CodeView.hpp b/include/LIEF/PE/debug/CodeView.hpp index 89fb57296a..99445aa328 100644 --- a/include/LIEF/PE/debug/CodeView.hpp +++ b/include/LIEF/PE/debug/CodeView.hpp @@ -22,14 +22,14 @@ namespace PE { class Parser; class Builder; -//! Interface for the (generic) Debug CodeView (``IMAGE_DEBUG_TYPE_CODEVIEW``) +/// Interface for the (generic) Debug CodeView (``IMAGE_DEBUG_TYPE_CODEVIEW``) class LIEF_API CodeView : public Debug { friend class Parser; friend class Builder; public: - //! Code view signatures - //! @see: http://llvm.org/doxygen/CVDebugRecord_8h_source.html + /// Code view signatures + /// @see: http://llvm.org/doxygen/CVDebugRecord_8h_source.html enum class SIGNATURES { UNKNOWN = 0, @@ -54,7 +54,7 @@ class LIEF_API CodeView : public Debug { ~CodeView() override = default; - //! The signature that defines the underlying type of the payload + /// The signature that defines the underlying type of the payload SIGNATURES signature() const { return sig_; } diff --git a/include/LIEF/PE/debug/CodeViewPDB.hpp b/include/LIEF/PE/debug/CodeViewPDB.hpp index f13d1046d1..069bec0227 100644 --- a/include/LIEF/PE/debug/CodeViewPDB.hpp +++ b/include/LIEF/PE/debug/CodeViewPDB.hpp @@ -30,7 +30,7 @@ namespace details { struct pe_pdb_70; } -//! CodeView PDB specialization +/// CodeView PDB specialization class LIEF_API CodeViewPDB : public CodeView { friend class Parser; friend class Builder; diff --git a/include/LIEF/PE/debug/Debug.hpp b/include/LIEF/PE/debug/Debug.hpp index 00fbfd15ed..73b16ccd50 100644 --- a/include/LIEF/PE/debug/Debug.hpp +++ b/include/LIEF/PE/debug/Debug.hpp @@ -32,15 +32,15 @@ namespace details { struct pe_debug; } -//! This class represents a generic entry in the debug data directory. -//! For known types, this class is extended to provide a dedicated API -//! (see: ! CodeCodeView) +/// This class represents a generic entry in the debug data directory. +/// For known types, this class is extended to provide a dedicated API +/// (see: ! CodeCodeView) class LIEF_API Debug : public Object { friend class Parser; friend class Builder; public: - //! The entry types + /// The entry types enum class TYPES { UNKNOWN = 0, COFF = 1, ///< COFF debug information @@ -76,42 +76,42 @@ class LIEF_API Debug : public Object { return std::unique_ptr(new Debug(*this)); } - //! Reserved should be 0 + /// Reserved should be 0 uint32_t characteristics() const { return characteristics_; } - //! The time and date when the debug data was created. + /// The time and date when the debug data was created. uint32_t timestamp() const { return timestamp_; } - //! The major version number of the debug data format. + /// The major version number of the debug data format. uint16_t major_version() const { return major_version_; } - //! The minor version number of the debug data format. + /// The minor version number of the debug data format. uint16_t minor_version() const { return minor_version_; } - //! The format DEBUG_TYPES of the debugging information + /// The format DEBUG_TYPES of the debugging information TYPES type() const { return type_; } - //! Size of the debug data + /// Size of the debug data uint32_t sizeof_data() const { return sizeof_data_; } - //! Address of the debug data relative to the image base + /// Address of the debug data relative to the image base uint32_t addressof_rawdata() const { return addressof_rawdata_; } - //! File offset of the debug data + /// File offset of the debug data uint32_t pointerto_rawdata() const { return pointerto_rawdata_; } diff --git a/include/LIEF/PE/debug/Pogo.hpp b/include/LIEF/PE/debug/Pogo.hpp index 52568c7df4..9a6eae20e9 100644 --- a/include/LIEF/PE/debug/Pogo.hpp +++ b/include/LIEF/PE/debug/Pogo.hpp @@ -28,8 +28,8 @@ namespace PE { class Builder; class Parser; -//! This class represents a *Profile Guided Optimization* entry from the -//! debug directory (``IMAGE_DEBUG_TYPE_POGO``). +/// This class represents a *Profile Guided Optimization* entry from the +/// debug directory (``IMAGE_DEBUG_TYPE_POGO``). class LIEF_API Pogo : public Debug { friend class Builder; @@ -65,7 +65,7 @@ class LIEF_API Pogo : public Debug { return sig_; } - //! An iterator over the different POGO elements + /// An iterator over the different POGO elements it_entries entries() { return entries_; } diff --git a/include/LIEF/PE/debug/Repro.hpp b/include/LIEF/PE/debug/Repro.hpp index 698e2de5d8..b4b7c5d944 100644 --- a/include/LIEF/PE/debug/Repro.hpp +++ b/include/LIEF/PE/debug/Repro.hpp @@ -28,11 +28,11 @@ namespace PE { class Builder; class Parser; -//! This class represents a reproducible build entry from the debug directory. -//! (``IMAGE_DEBUG_TYPE_REPRO``). -//! This entry is usually generated with the undocumented `/Brepro` linker flag. -//! -//! See: https://nikhilism.com/post/2020/windows-deterministic-builds/ +/// This class represents a reproducible build entry from the debug directory. +/// (``IMAGE_DEBUG_TYPE_REPRO``). +/// This entry is usually generated with the undocumented `/Brepro` linker flag. +/// +/// See: https://nikhilism.com/post/2020/windows-deterministic-builds/ class LIEF_API Repro : public Debug { friend class Builder; @@ -56,7 +56,7 @@ class LIEF_API Repro : public Debug { Repro(const Repro& other) = default; Repro& operator=(const Repro& other) = default; - //! The hash associated with the reproducible build + /// The hash associated with the reproducible build span hash() const { return hash_; } diff --git a/include/LIEF/PE/enums.hpp b/include/LIEF/PE/enums.hpp index f667f828d6..d4c1177174 100644 --- a/include/LIEF/PE/enums.hpp +++ b/include/LIEF/PE/enums.hpp @@ -200,7 +200,7 @@ enum class CodeViewIdentifiers: size_t { }; -//! From https://docs.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles +/// From https://docs.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles enum class EXTENDED_WINDOW_STYLES: size_t { WS_EX_DLGMODALFRAME = 0x00000001L, WS_EX_NOPARENTNOTIFY = 0x00000004L, @@ -225,7 +225,7 @@ enum class EXTENDED_WINDOW_STYLES: size_t { WS_EX_APPWINDOW = 0x00040000L, }; -//! From: https://docs.microsoft.com/en-us/windows/win32/winmsg/window-styles +/// From: https://docs.microsoft.com/en-us/windows/win32/winmsg/window-styles enum class WINDOW_STYLES: size_t { WS_OVERLAPPED = 0x00000000L, WS_POPUP = 0x80000000L, @@ -251,7 +251,7 @@ enum class WINDOW_STYLES: size_t { }; -//! From https://docs.microsoft.com/en-us/windows/win32/dlgbox/dialog-box-styles +/// From https://docs.microsoft.com/en-us/windows/win32/dlgbox/dialog-box-styles enum class DIALOG_BOX_STYLES: size_t { DS_ABSALIGN = 0x0001L, DS_SYSMODAL = 0x0002L, @@ -329,7 +329,7 @@ enum class FIXED_VERSION_FILE_SUB_TYPES: size_t { VFT2_UNKNOWN = 0x00000000L, }; -//! Code page from https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers +/// Code page from https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers enum class CODE_PAGES: size_t { CP_IBM037 = 37, /**< IBM EBCDIC US-Canada */ CP_IBM437 = 437, /**< OEM United States */ @@ -473,7 +473,7 @@ enum class CODE_PAGES: size_t { CP_UTF_8 = 65001, /**< Unicode (UTF-8) */ }; -//! From https://docs.microsoft.com/en-us/windows/win32/menurc/acceltableentry +/// From https://docs.microsoft.com/en-us/windows/win32/menurc/acceltableentry enum class ACCELERATOR_FLAGS: size_t { FVIRTKEY = 0x01, FNOINVERT = 0x02, @@ -483,7 +483,7 @@ enum class ACCELERATOR_FLAGS: size_t { END = 0x80, }; -//! From https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes +/// From https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes enum class ACCELERATOR_VK_CODES: size_t { VK_LBUTTON = 0x01, VK_RBUTTON = 0x02, @@ -662,7 +662,7 @@ enum class ACCELERATOR_VK_CODES: size_t { }; -//! Common section type +/// Common section type enum class PE_SECTION_TYPES : uint8_t { TEXT = 0, TLS = 1, @@ -682,7 +682,7 @@ enum class PE_TYPE : uint16_t { PE32_PLUS = 0x20b ///< 64 bits }; -//! Cryptography algorithms +/// Cryptography algorithms enum class ALGORITHMS : uint32_t { UNKNOWN = 0, SHA_512, diff --git a/include/LIEF/PE/hash.hpp b/include/LIEF/PE/hash.hpp index c5f777564a..eb1d5f96b1 100644 --- a/include/LIEF/PE/hash.hpp +++ b/include/LIEF/PE/hash.hpp @@ -93,8 +93,8 @@ class Pogo; class PogoEntry; class Repro; -//! Class which implements a visitor to compute -//! a **deterministic** hash for LIEF PE objects +/// Class which implements a visitor to compute +/// a **deterministic** hash for LIEF PE objects class LIEF_API Hash : public LIEF::Hash { public: static LIEF::Hash::value_type hash(const Object& obj); diff --git a/include/LIEF/PE/resources/LangCodeItem.hpp b/include/LIEF/PE/resources/LangCodeItem.hpp index 7a52aef6a1..e82895135e 100644 --- a/include/LIEF/PE/resources/LangCodeItem.hpp +++ b/include/LIEF/PE/resources/LangCodeItem.hpp @@ -30,10 +30,10 @@ namespace PE { class ResourcesManager; struct ResourcesParser; -//! Class which represents the childs of the ResourceStringFileInfo -//! -//! @see: LIEF::PE::ResourceStringFileInfo -//! @see: https://docs.microsoft.com/en-us/windows/win32/menurc/stringtable +/// Class which represents the childs of the ResourceStringFileInfo +/// +/// @see: LIEF::PE::ResourceStringFileInfo +/// @see: https://docs.microsoft.com/en-us/windows/win32/menurc/stringtable class LIEF_API LangCodeItem : public Object { friend class ResourcesManager; @@ -51,30 +51,30 @@ class LIEF_API LangCodeItem : public Object { LangCodeItem& operator=(const LangCodeItem&) = default; ~LangCodeItem() override = default; - //! The type of data in the version resource - //! * ``1`` if it contains text data - //! * ``0`` if it contains binary data + /// The type of data in the version resource + /// * ``1`` if it contains text data + /// * ``0`` if it contains binary data uint16_t type() const { return type_; } - //! A 8-digit hexadecimal number stored as an Unicode string. - //! * The four most significant digits represent the language identifier. - //! * The four least significant digits represent the code page for which the data is formatted. - //! - //! @see LangCodeItem::code_page, LangCodeItem::lang, LangCodeItem::sublang + /// A 8-digit hexadecimal number stored as an Unicode string. + /// * The four most significant digits represent the language identifier. + /// * The four least significant digits represent the code page for which the data is formatted. + /// + /// @see LangCodeItem::code_page, LangCodeItem::lang, LangCodeItem::sublang const std::u16string& key() const { return key_; } - //! [Code page](https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers) - //! for which LangCodeItem::items are defined + /// [Code page](https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers) + /// for which LangCodeItem::items are defined CODE_PAGES code_page() const; - //! Lang for which LangCodeItem::items are defined + /// Lang for which LangCodeItem::items are defined uint32_t lang() const; - //! Sublang for which LangCodeItem::items are defined + /// Sublang for which LangCodeItem::items are defined uint32_t sublang() const; const items_t& items() const { diff --git a/include/LIEF/PE/resources/ResourceAccelerator.hpp b/include/LIEF/PE/resources/ResourceAccelerator.hpp index 9b1d9566df..dc36927e29 100644 --- a/include/LIEF/PE/resources/ResourceAccelerator.hpp +++ b/include/LIEF/PE/resources/ResourceAccelerator.hpp @@ -51,22 +51,22 @@ class LIEF_API ResourceAccelerator : public Object { std::set flags_list() const; std::string ansi_str() const; - //! Describe the keyboard accelerator characteristics + /// Describe the keyboard accelerator characteristics int16_t flags() const { return flags_; } - //! An ANSI character value or a virtual-key code that identifies the accelerator key + /// An ANSI character value or a virtual-key code that identifies the accelerator key int16_t ansi() const { return ansi_; } - //! An identifier for the keyboard accelerator + /// An identifier for the keyboard accelerator uint16_t id() const { return id_; } - //! The number of bytes inserted to ensure that the structure is aligned on a DWORD boundary. + /// The number of bytes inserted to ensure that the structure is aligned on a DWORD boundary. int16_t padding() const { return padding_; } diff --git a/include/LIEF/PE/resources/ResourceDialog.hpp b/include/LIEF/PE/resources/ResourceDialog.hpp index fc37eac5d1..7947189316 100644 --- a/include/LIEF/PE/resources/ResourceDialog.hpp +++ b/include/LIEF/PE/resources/ResourceDialog.hpp @@ -37,13 +37,13 @@ struct pe_dialog_template_ext; struct pe_dialog_template; } -//! Representation of a dialog box -//! -//! Windows allows two kinds of dialog box: -//! * Simple one -//! * Extended one -//! -//! ResourceDialog::is_extended determine the type of the Dialog +/// Representation of a dialog box +/// +/// Windows allows two kinds of dialog box: +/// * Simple one +/// * Extended one +/// +/// ResourceDialog::is_extended determine the type of the Dialog class LIEF_API ResourceDialog : public Object { friend class ResourcesManager; @@ -63,51 +63,51 @@ class LIEF_API ResourceDialog : public Object { ~ResourceDialog() override; - //! ``true`` if the dialog is an extended one + /// ``true`` if the dialog is an extended one bool is_extended() const; - //! The extended windows styles + /// The extended windows styles uint32_t extended_style() const; - //! Return list of LIEF::PE::EXTENDED_WINDOW_STYLES associated with the - //! ResourceDialog::extended_style value + /// Return list of LIEF::PE::EXTENDED_WINDOW_STYLES associated with the + /// ResourceDialog::extended_style value std::set extended_style_list() const; bool has_extended_style(EXTENDED_WINDOW_STYLES style) const; - //! The style of the dialog box. This member can be a combination of LIEF::PE::WINDOW_STYLES values and - //! LIEF::PE::DIALOG_BOX_STYLES values. + /// The style of the dialog box. This member can be a combination of LIEF::PE::WINDOW_STYLES values and + /// LIEF::PE::DIALOG_BOX_STYLES values. uint32_t style() const; - //! Return list of LIEF::PE::WINDOW_STYLES associated with the - //! ResourceDialog::style value + /// Return list of LIEF::PE::WINDOW_STYLES associated with the + /// ResourceDialog::style value std::set style_list() const; bool has_style(WINDOW_STYLES style) const; - //! Return list of LIEF::PE::DIALOG_BOX_STYLES associated with the - //! ResourceDialog::style value + /// Return list of LIEF::PE::DIALOG_BOX_STYLES associated with the + /// ResourceDialog::style value std::set dialogbox_style_list() const; bool has_dialogbox_style(DIALOG_BOX_STYLES style) const; - //! The x-coordinate, in dialog box units, of the upper-left corner of the dialog box. + /// The x-coordinate, in dialog box units, of the upper-left corner of the dialog box. int16_t x() const; - //! The y-coordinate, in dialog box units, of the upper-left corner of the dialog box. + /// The y-coordinate, in dialog box units, of the upper-left corner of the dialog box. int16_t y() const; - //! The width, in dialog box units, of the dialog box. + /// The width, in dialog box units, of the dialog box. int16_t cx() const; - //! The height, in dialog box units, of the dialog box. + /// The height, in dialog box units, of the dialog box. int16_t cy() const; - //! Iterator on the controls (ResourceDialogItem) that defines the Dialog (Button, Label...) + /// Iterator on the controls (ResourceDialogItem) that defines the Dialog (Button, Label...) it_const_items items() const; - //! RESOURCE_LANGS associated with the Dialog + /// RESOURCE_LANGS associated with the Dialog uint32_t lang() const; - //! RESOURCE_SUBLANGS associated with the Dialog + /// RESOURCE_SUBLANGS associated with the Dialog uint32_t sub_lang() const; void lang(uint32_t lang); @@ -117,36 +117,36 @@ class LIEF_API ResourceDialog : public Object { // Extended API // ============ - //! The version number of the extended dialog box template. This member must be set to 1. + /// The version number of the extended dialog box template. This member must be set to 1. uint16_t version() const; - //! Indicates whether a template is an extended dialog box template: - //! - //! * ``0xFFFF``: Extended dialog box template - //! * Other value: Standard dialog box template - //! - //! @see ResourceDialog::is_extended + /// Indicates whether a template is an extended dialog box template: + /// + /// * ``0xFFFF``: Extended dialog box template + /// * Other value: Standard dialog box template + /// + /// @see ResourceDialog::is_extended uint16_t signature() const; - //! The help context identifier for the dialog box window + /// The help context identifier for the dialog box window uint32_t help_id() const; - //! The weight of the font + /// The weight of the font uint16_t weight() const; - //! The point size of the font to use for the text in the dialog box and its controls. + /// The point size of the font to use for the text in the dialog box and its controls. uint16_t point_size() const; - //! Indicates whether the font is italic. If this value is ``true``, the font is italic + /// Indicates whether the font is italic. If this value is ``true``, the font is italic bool is_italic() const; - //! The character to be used + /// The character to be used uint8_t charset() const; - //! The title of the dialog box + /// The title of the dialog box const std::u16string& title() const; - //! The name of the typeface for the font + /// The name of the typeface for the font const std::u16string& typeface() const; void accept(Visitor& visitor) const override; diff --git a/include/LIEF/PE/resources/ResourceDialogItem.hpp b/include/LIEF/PE/resources/ResourceDialogItem.hpp index 8e30dcf433..39cbcf5d8b 100644 --- a/include/LIEF/PE/resources/ResourceDialogItem.hpp +++ b/include/LIEF/PE/resources/ResourceDialogItem.hpp @@ -36,7 +36,7 @@ struct pe_dialog_item_template_ext; struct pe_dialog_item_template; } -//! This class represents an item in the ResourceDialog +/// This class represents an item in the ResourceDialog class LIEF_API ResourceDialogItem : public Object { friend class ResourcesManager; @@ -52,50 +52,50 @@ class LIEF_API ResourceDialogItem : public Object { ~ResourceDialogItem() override; - //! ``True`` if the control is an extended one + /// ``True`` if the control is an extended one bool is_extended() const; - //! The extended styles for a window + /// The extended styles for a window uint32_t extended_style() const; - //! List of PE::EXTENDED_WINDOW_STYLES associated with - //! the ResourceDialogItem::extended_style value + /// List of PE::EXTENDED_WINDOW_STYLES associated with + /// the ResourceDialogItem::extended_style value std::set extended_style_list() const; - //! Check if the DialogItem has the given PE::EXTENDED_WINDOW_STYLES + /// Check if the DialogItem has the given PE::EXTENDED_WINDOW_STYLES bool has_extended_style(EXTENDED_WINDOW_STYLES style) const; - //! The style of the control + /// The style of the control uint32_t style() const; std::set style_list() const; bool has_style(WINDOW_STYLES style) const; - //! The x-coordinate, in dialog box units, of the upper-left corner of the control. - //! This coordinate is always relative to the upper-left corner of the dialog box's client area. + /// The x-coordinate, in dialog box units, of the upper-left corner of the control. + /// This coordinate is always relative to the upper-left corner of the dialog box's client area. int16_t x() const; - //! The y-coordinate, in dialog box units, of the upper-left corner of the control. - //! This coordinate is always relative to the upper-left corner of the dialog box's client area. + /// The y-coordinate, in dialog box units, of the upper-left corner of the control. + /// This coordinate is always relative to the upper-left corner of the dialog box's client area. int16_t y() const; - //! The width, in dialog box units, of the control. + /// The width, in dialog box units, of the control. int16_t cx() const; - //! The height, in dialog box units, of the control. + /// The height, in dialog box units, of the control. int16_t cy() const; - //! The control identifier. + /// The control identifier. uint32_t id() const; // Extended API // ============ - //! The help context identifier for the control + /// The help context identifier for the control uint32_t help_id() const; - //! Initial text of the control + /// Initial text of the control const std::u16string& title() const; void accept(Visitor& visitor) const override; diff --git a/include/LIEF/PE/resources/ResourceFixedFileInfo.hpp b/include/LIEF/PE/resources/ResourceFixedFileInfo.hpp index d9cb345ffb..c8dab37186 100644 --- a/include/LIEF/PE/resources/ResourceFixedFileInfo.hpp +++ b/include/LIEF/PE/resources/ResourceFixedFileInfo.hpp @@ -31,8 +31,8 @@ namespace details { struct pe_resource_fixed_file_info; } -//! Representation of [VS_FIXEDFILEINFO](https://docs.microsoft.com/en-us/windows/win32/api/verrsrc/ns-verrsrc-vs_fixedfileinfo) -//! Structure +/// Representation of [VS_FIXEDFILEINFO](https://docs.microsoft.com/en-us/windows/win32/api/verrsrc/ns-verrsrc-vs_fixedfileinfo) +/// Structure class LIEF_API ResourceFixedFileInfo : public Object { public: @@ -43,58 +43,58 @@ class LIEF_API ResourceFixedFileInfo : public Object { ResourceFixedFileInfo& operator=(const ResourceFixedFileInfo&); ~ResourceFixedFileInfo() override; - //! Must be set to ``0xFEEF04BD`` + /// Must be set to ``0xFEEF04BD`` uint32_t signature() const; - //! The binary version number of this structure. - //! - //! The high-order word of this member contains the major version number, - //! and the low-order word contains the minor version number. + /// The binary version number of this structure. + /// + /// The high-order word of this member contains the major version number, + /// and the low-order word contains the minor version number. uint32_t struct_version() const; - //! The **most** significant 32 bits of the file's binary version number. - //! - //! This member is used with ResourceFixedFileInfo::file_version_LS to form a 64-bits - //! value used for numeric comparisons. + /// The **most** significant 32 bits of the file's binary version number. + /// + /// This member is used with ResourceFixedFileInfo::file_version_LS to form a 64-bits + /// value used for numeric comparisons. uint32_t file_version_MS() const; - //! The **least** significant 32 bits of the file's binary version number. - //! - //! This member is used with ResourceFixedFileInfo::file_version_MS to form a 64-bits value used for numeric comparisons. + /// The **least** significant 32 bits of the file's binary version number. + /// + /// This member is used with ResourceFixedFileInfo::file_version_MS to form a 64-bits value used for numeric comparisons. uint32_t file_version_LS() const; - //! The **most** significant 32 bits of the product with which this file was distributed - //! - //! This member is used with ResourceFixedFileInfo::product_version_LS to form a 64-bits value used for numeric comparisons. + /// The **most** significant 32 bits of the product with which this file was distributed + /// + /// This member is used with ResourceFixedFileInfo::product_version_LS to form a 64-bits value used for numeric comparisons. uint32_t product_version_MS() const; - //! The **least** significant 32 bits of the product with which this file was distributed - //! - //! This member is used with ResourceFixedFileInfo::product_version_MS to form a 64-bits value used for numeric comparisons. + /// The **least** significant 32 bits of the product with which this file was distributed + /// + /// This member is used with ResourceFixedFileInfo::product_version_MS to form a 64-bits value used for numeric comparisons. uint32_t product_version_LS() const; - //! Contains a bitmask that specifies the valid bits in ResourceFixedFileInfo::file_flags. - //! - //! A bit is valid only if it was defined when the file was created. + /// Contains a bitmask that specifies the valid bits in ResourceFixedFileInfo::file_flags. + /// + /// A bit is valid only if it was defined when the file was created. uint32_t file_flags_mask() const; - //! Contains a bitmask that specifies the Boolean attributes of the file - //! (PE::FIXED_VERSION_FILE_FLAGS) + /// Contains a bitmask that specifies the Boolean attributes of the file + /// (PE::FIXED_VERSION_FILE_FLAGS) uint32_t file_flags() const; - //! The operating system for which this file was designed (PE::FIXED_VERSION_OS). + /// The operating system for which this file was designed (PE::FIXED_VERSION_OS). FIXED_VERSION_OS file_os() const; - //! The general type of file (PE::FIXED_VERSION_FILE_TYPES) + /// The general type of file (PE::FIXED_VERSION_FILE_TYPES) FIXED_VERSION_FILE_TYPES file_type() const; - //! The function of the file (PE::FIXED_VERSION_FILE_SUB_TYPES) + /// The function of the file (PE::FIXED_VERSION_FILE_SUB_TYPES) FIXED_VERSION_FILE_SUB_TYPES file_subtype() const; - //! The **most** significant 32 bits of the file's 64-bit binary creation date and time stamp. + /// The **most** significant 32 bits of the file's 64-bit binary creation date and time stamp. uint32_t file_date_MS() const; - //! The **least** significant 32 bits of the file's 64-bit binary creation date and time stamp. + /// The **least** significant 32 bits of the file's 64-bit binary creation date and time stamp. uint32_t file_date_LS() const; void signature(uint32_t signature); diff --git a/include/LIEF/PE/resources/ResourceIcon.hpp b/include/LIEF/PE/resources/ResourceIcon.hpp index 44cbb8cafb..1fa5e8d2cc 100644 --- a/include/LIEF/PE/resources/ResourceIcon.hpp +++ b/include/LIEF/PE/resources/ResourceIcon.hpp @@ -50,37 +50,37 @@ class LIEF_API ResourceIcon : public Object { ~ResourceIcon() override; - //! Id associated with the icon + /// Id associated with the icon uint32_t id() const; - //! Language associated with the icon + /// Language associated with the icon uint32_t lang() const; - //! Sub language associated with the icon + /// Sub language associated with the icon uint32_t sublang() const; - //! Width in pixels of the image + /// Width in pixels of the image uint8_t width() const; - //! Height in pixels of the image + /// Height in pixels of the image uint8_t height() const; - //! Number of colors in image (0 if >=8bpp) + /// Number of colors in image (0 if >=8bpp) uint8_t color_count() const; - //! Reserved (must be 0) + /// Reserved (must be 0) uint8_t reserved() const; - //! Color Planes + /// Color Planes uint16_t planes() const; - //! Bits per pixel + /// Bits per pixel uint16_t bit_count() const; - //! Size in bytes of the image + /// Size in bytes of the image uint32_t size() const; - //! Pixels of the image (as bytes) + /// Pixels of the image (as bytes) span pixels() const; void id(uint32_t id); @@ -94,9 +94,9 @@ class LIEF_API ResourceIcon : public Object { void bit_count(uint16_t bit_count); void pixels(const std::vector& pixels); - //! Save the icon to the given filename - //! - //! @param[in] filename Path to file in which the icon will be saved + /// Save the icon to the given filename + /// + /// @param[in] filename Path to file in which the icon will be saved void save(const std::string& filename) const; void accept(Visitor& visitor) const override; diff --git a/include/LIEF/PE/resources/ResourceStringFileInfo.hpp b/include/LIEF/PE/resources/ResourceStringFileInfo.hpp index 5381f24c8b..97e47198b9 100644 --- a/include/LIEF/PE/resources/ResourceStringFileInfo.hpp +++ b/include/LIEF/PE/resources/ResourceStringFileInfo.hpp @@ -30,11 +30,11 @@ class ResourcesManager; class ResourceVersion; struct ResourcesParser; -//! Representation of the ``StringFileInfo`` structure -//! -//! It contains version information that can be displayed for a particular language and code page. -//! -//! See: https://docs.microsoft.com/en-us/windows/win32/menurc/stringfileinfo +/// Representation of the ``StringFileInfo`` structure +/// +/// It contains version information that can be displayed for a particular language and code page. +/// +/// See: https://docs.microsoft.com/en-us/windows/win32/menurc/stringfileinfo class LIEF_API ResourceStringFileInfo : public Object { friend class ResourcesManager; @@ -51,24 +51,24 @@ class LIEF_API ResourceStringFileInfo : public Object { ResourceStringFileInfo& operator=(const ResourceStringFileInfo&) = default; ~ResourceStringFileInfo() override = default; - //! The type of data in the version resource - //! * ``1`` if it contains text data - //! * ``0`` if it contains binary data + /// The type of data in the version resource + /// * ``1`` if it contains text data + /// * ``0`` if it contains binary data uint16_t type() const { return type_; } - //! Signature of the structure: - //! Must be the unicode string "StringFileInfo" + /// Signature of the structure: + /// Must be the unicode string "StringFileInfo" const std::u16string& key() const { return key_; } - //! List of the LangCodeItem items. - //! - //! Each LangCodeItem::key indicates the appropriate - //! language and code page for displaying the ``key: value`` of - //! LangCodeItem::items + /// List of the LangCodeItem items. + /// + /// Each LangCodeItem::key indicates the appropriate + /// language and code page for displaying the ``key: value`` of + /// LangCodeItem::items const std::vector& langcode_items() const { return childs_; } diff --git a/include/LIEF/PE/resources/ResourceStringTable.hpp b/include/LIEF/PE/resources/ResourceStringTable.hpp index e6f7820787..bc47e18c6d 100644 --- a/include/LIEF/PE/resources/ResourceStringTable.hpp +++ b/include/LIEF/PE/resources/ResourceStringTable.hpp @@ -43,12 +43,12 @@ class LIEF_API ResourceStringTable : public Object { void accept(Visitor& visitor) const override; - //! The size of the string, not including length field itself. + /// The size of the string, not including length field itself. int16_t length() const { return length_; } - //! The variable-length Unicode string data, word-aligned. + /// The variable-length Unicode string data, word-aligned. const std::u16string& name() const { return name_; } diff --git a/include/LIEF/PE/resources/ResourceVarFileInfo.hpp b/include/LIEF/PE/resources/ResourceVarFileInfo.hpp index 60fbe26ff6..51d8062dfd 100644 --- a/include/LIEF/PE/resources/ResourceVarFileInfo.hpp +++ b/include/LIEF/PE/resources/ResourceVarFileInfo.hpp @@ -30,9 +30,9 @@ class ResourcesManager; class ResourceVersion; struct ResourcesParser; -//! This object describes information about languages supported by the application -//! -//! @see LIEF::PE::ResourceVersion +/// This object describes information about languages supported by the application +/// +/// @see LIEF::PE::ResourceVersion class LIEF_API ResourceVarFileInfo : public Object { friend class ResourcesManager; @@ -46,24 +46,24 @@ class LIEF_API ResourceVarFileInfo : public Object { ResourceVarFileInfo& operator=(const ResourceVarFileInfo&) = default; ~ResourceVarFileInfo() override = default; - //! The type of data in the version resource - //! * ``1`` if it contains text data - //! * ``0`` if it contains binary data + /// The type of data in the version resource + /// * ``1`` if it contains text data + /// * ``0`` if it contains binary data uint16_t type() const { return type_; } - //! Signature of the structure: - //! Must be the unicode string "VarFileInfo" + /// Signature of the structure: + /// Must be the unicode string "VarFileInfo" const std::u16string& key() const { return key_; } - //! List of languages that the application supports - //! - //! The **least** significant 16-bits must contain a Microsoft language identifier, - //! and the **most** significant 16-bits must contain the PE::CODE_PAGES - //! Either **most** or **least** 16-bits can be zero, indicating that the file is language or code page independent. + /// List of languages that the application supports + /// + /// The **least** significant 16-bits must contain a Microsoft language identifier, + /// and the **most** significant 16-bits must contain the PE::CODE_PAGES + /// Either **most** or **least** 16-bits can be zero, indicating that the file is language or code page independent. const std::vector& translations() const { return translations_; } diff --git a/include/LIEF/PE/resources/ResourceVersion.hpp b/include/LIEF/PE/resources/ResourceVersion.hpp index e55f0cd6a4..4c9dddf0a5 100644 --- a/include/LIEF/PE/resources/ResourceVersion.hpp +++ b/include/LIEF/PE/resources/ResourceVersion.hpp @@ -32,9 +32,9 @@ class ResourceVarFileInfo; class ResourcesManager; struct ResourcesParser; -//! Representation of the data associated with the ``RT_VERSION`` entry -//! -//! See: ``VS_VERSIONINFO`` - https://docs.microsoft.com/en-us/windows/win32/menurc/vs-versioninfo +/// Representation of the data associated with the ``RT_VERSION`` entry +/// +/// See: ``VS_VERSIONINFO`` - https://docs.microsoft.com/en-us/windows/win32/menurc/vs-versioninfo class LIEF_API ResourceVersion : public Object { friend class ResourcesManager; friend struct ResourcesParser; @@ -44,38 +44,38 @@ class LIEF_API ResourceVersion : public Object { ResourceVersion& operator=(const ResourceVersion&); ~ResourceVersion() override; - //! The type of data in the version resource - //! * ``1`` if it contains text data - //! * ``0`` if it contains binary data + /// The type of data in the version resource + /// * ``1`` if it contains text data + /// * ``0`` if it contains binary data uint16_t type() const; - //! Signature of the structure: - //! Must be the unicode string "VS_VERSION_INFO" + /// Signature of the structure: + /// Must be the unicode string "VS_VERSION_INFO" const std::u16string& key() const; - //! ``true`` if the version contains a ResourceFixedFileInfo + /// ``true`` if the version contains a ResourceFixedFileInfo bool has_fixed_file_info() const; - //! ``true`` if the version contains a ResourceStringFileInfo + /// ``true`` if the version contains a ResourceStringFileInfo bool has_string_file_info() const; - //! ``true`` if the version contains a ResourceVarFileInfo + /// ``true`` if the version contains a ResourceVarFileInfo bool has_var_file_info() const; - //! Object that describes various information about the application's version. - //! This is an optional information and if it is not present, it returns a nullptr + /// Object that describes various information about the application's version. + /// This is an optional information and if it is not present, it returns a nullptr const ResourceFixedFileInfo* fixed_file_info() const; ResourceFixedFileInfo* fixed_file_info(); - //! Object that describes various information about the application's version. - //! The underlying structure is basically a dictionary (key/value) - //! - //! This structure is not always present and if not, it returns a nullptr + /// Object that describes various information about the application's version. + /// The underlying structure is basically a dictionary (key/value) + /// + /// This structure is not always present and if not, it returns a nullptr const ResourceStringFileInfo* string_file_info() const; ResourceStringFileInfo* string_file_info(); - //! Object that describes information about languages supported by the application - //! This structure is not always present and if not, it returns a nullptr + /// Object that describes information about languages supported by the application + /// This structure is not always present and if not, it returns a nullptr const ResourceVarFileInfo* var_file_info() const; ResourceVarFileInfo* var_file_info(); diff --git a/include/LIEF/PE/signature/Attribute.hpp b/include/LIEF/PE/signature/Attribute.hpp index 755cd3d7d6..94c54e541a 100644 --- a/include/LIEF/PE/signature/Attribute.hpp +++ b/include/LIEF/PE/signature/Attribute.hpp @@ -25,7 +25,7 @@ namespace LIEF { namespace PE { -//! Interface over PKCS #7 attribute +/// Interface over PKCS #7 attribute class LIEF_API Attribute : public Object { friend class Parser; @@ -58,12 +58,12 @@ class LIEF_API Attribute : public Object { virtual std::unique_ptr clone() const = 0; - //! Concrete type of the attribute + /// Concrete type of the attribute virtual TYPE type() const { return type_; } - //! Print information about the underlying attribute + /// Print information about the underlying attribute virtual std::string print() const = 0; void accept(Visitor& visitor) const override; diff --git a/include/LIEF/PE/signature/ContentInfo.hpp b/include/LIEF/PE/signature/ContentInfo.hpp index 4afe1bc1e4..66df479550 100644 --- a/include/LIEF/PE/signature/ContentInfo.hpp +++ b/include/LIEF/PE/signature/ContentInfo.hpp @@ -124,8 +124,8 @@ class LIEF_API ContentInfo : public Object { void swap(ContentInfo& other) noexcept; - //! Return the OID that describes the content wrapped by this object. - //! It should match SPC_INDIRECT_DATA_OBJID (1.3.6.1.4.1.311.2.1.4) + /// Return the OID that describes the content wrapped by this object. + /// It should match SPC_INDIRECT_DATA_OBJID (1.3.6.1.4.1.311.2.1.4) oid_t content_type() const { return value_->content_type(); } diff --git a/include/LIEF/PE/signature/OIDToString.hpp b/include/LIEF/PE/signature/OIDToString.hpp index acf7def679..f953d06239 100644 --- a/include/LIEF/PE/signature/OIDToString.hpp +++ b/include/LIEF/PE/signature/OIDToString.hpp @@ -21,7 +21,7 @@ namespace LIEF { namespace PE { -//! @brief Convert an OID to a human-readable string +/// Convert an OID to a human-readable string LIEF_API const char* oid_to_string(const oid_t& oid); } diff --git a/include/LIEF/PE/signature/PKCS9TSTInfo.hpp b/include/LIEF/PE/signature/PKCS9TSTInfo.hpp index d200c895e9..06e1a5e94a 100644 --- a/include/LIEF/PE/signature/PKCS9TSTInfo.hpp +++ b/include/LIEF/PE/signature/PKCS9TSTInfo.hpp @@ -25,37 +25,37 @@ namespace LIEF { namespace PE { -//! Interface over the structure described by the OID `1.2.840.113549.1.9.16.1.4` (PKCS #9) -//! -//! The internal structure is described in the -//! [RFC #3161](https://tools.ietf.org/html/rfc3161) -//! -//! ```text -//! TSTInfo ::= SEQUENCE { -//! version INTEGER { v1(1) }, -//! policy TSAPolicyId, -//! messageImprint MessageImprint, -//! serialNumber INTEGER, -//! genTime GeneralizedTime, -//! accuracy Accuracy OPTIONAL, -//! ordering BOOLEAN DEFAULT FALSE, -//! nonce INTEGER OPTIONAL, -//! tsa [0] GeneralName OPTIONAL, -//! extensions [1] IMPLICIT Extensions OPTIONAL -//! } -//! -//! TSAPolicyId ::= OBJECT IDENTIFIER -//! MessageImprint ::= SEQUENCE { -//! hashAlgorithm AlgorithmIdentifier, -//! hashedMessage OCTET STRING -//! } -//! -//! Accuracy ::= SEQUENCE { -//! seconds INTEGER OPTIONAL, -//! millis [0] INTEGER (1..999) OPTIONAL, -//! micros [1] INTEGER (1..999) OPTIONAL -//! } -//! ``` +/// Interface over the structure described by the OID `1.2.840.113549.1.9.16.1.4` (PKCS #9) +/// +/// The internal structure is described in the +/// [RFC #3161](https://tools.ietf.org/html/rfc3161) +/// +/// ```text +/// TSTInfo ::= SEQUENCE { +/// version INTEGER { v1(1) }, +/// policy TSAPolicyId, +/// messageImprint MessageImprint, +/// serialNumber INTEGER, +/// genTime GeneralizedTime, +/// accuracy Accuracy OPTIONAL, +/// ordering BOOLEAN DEFAULT FALSE, +/// nonce INTEGER OPTIONAL, +/// tsa [0] GeneralName OPTIONAL, +/// extensions [1] IMPLICIT Extensions OPTIONAL +/// } +/// +/// TSAPolicyId ::= OBJECT IDENTIFIER +/// MessageImprint ::= SEQUENCE { +/// hashAlgorithm AlgorithmIdentifier, +/// hashedMessage OCTET STRING +/// } +/// +/// Accuracy ::= SEQUENCE { +/// seconds INTEGER OPTIONAL, +/// millis [0] INTEGER (1..999) OPTIONAL, +/// micros [1] INTEGER (1..999) OPTIONAL +/// } +/// ``` class LIEF_API PKCS9TSTInfo : public ContentInfo::Content { friend class SignatureParser; diff --git a/include/LIEF/PE/signature/RsaInfo.hpp b/include/LIEF/PE/signature/RsaInfo.hpp index 8021145583..c5ee9c71a6 100644 --- a/include/LIEF/PE/signature/RsaInfo.hpp +++ b/include/LIEF/PE/signature/RsaInfo.hpp @@ -25,7 +25,7 @@ namespace LIEF { namespace PE { class x509; -//! Object that wraps a RSA key +/// Object that wraps a RSA key class LIEF_API RsaInfo { friend class x509; @@ -38,28 +38,28 @@ class LIEF_API RsaInfo { RsaInfo(RsaInfo&& other); RsaInfo& operator=(RsaInfo other); - //! True if it embeds a public key + /// True if it embeds a public key bool has_public_key() const; - //! True if it embeds a private key + /// True if it embeds a private key bool has_private_key() const; - //! RSA public modulus + /// RSA public modulus bignum_wrapper_t N() const; - //! RSA public exponent + /// RSA public exponent bignum_wrapper_t E() const; - //! RSA private exponent + /// RSA private exponent bignum_wrapper_t D() const; - //! First prime factor + /// First prime factor bignum_wrapper_t P() const; - //! Second prime factor + /// Second prime factor bignum_wrapper_t Q() const; - //! Size of the public modulus (in bits) + /// Size of the public modulus (in bits) size_t key_size() const; void swap(RsaInfo& other); diff --git a/include/LIEF/PE/signature/Signature.hpp b/include/LIEF/PE/signature/Signature.hpp index 51f24a31fc..aa5d9f7b83 100644 --- a/include/LIEF/PE/signature/Signature.hpp +++ b/include/LIEF/PE/signature/Signature.hpp @@ -35,7 +35,7 @@ namespace PE { class SignatureParser; class Binary; -//! Main interface for the PKCS #7 signature scheme +/// Main interface for the PKCS #7 signature scheme class LIEF_API Signature : public Object { friend class SignatureParser; @@ -43,7 +43,7 @@ class LIEF_API Signature : public Object { friend class Binary; public: - //! Hash the input given the algorithm + /// Hash the input given the algorithm static std::vector hash(const std::vector& input, ALGORITHMS algo) { return hash(input.data(), input.size(), algo); } @@ -52,19 +52,19 @@ class LIEF_API Signature : public Object { public: - //! Iterator which outputs const x509& certificates + /// Iterator which outputs const x509& certificates using it_const_crt = const_ref_iterator&>; - //! Iterator which outputs x509& certificates + /// Iterator which outputs x509& certificates using it_crt = ref_iterator&>; - //! Iterator which outputs const SignerInfo& + /// Iterator which outputs const SignerInfo& using it_const_signers_t = const_ref_iterator&>; - //! Iterator which outputs SignerInfo& + /// Iterator which outputs SignerInfo& using it_signers_t = ref_iterator&>; - //! Flags returned by the verification functions + /// Flags returned by the verification functions enum class VERIFICATION_FLAGS : uint32_t { OK = 0, INVALID_SIGNER = 1 << 0, @@ -81,13 +81,13 @@ class LIEF_API Signature : public Object { CERT_FUTURE = 1 << 11, }; - //! Convert a verification flag into a humman representation. - //! e.g VERIFICATION_FLAGS.BAD_DIGEST | VERIFICATION_FLAGS.BAD_SIGNATURE | VERIFICATION_FLAGS.CERT_EXPIRED + /// Convert a verification flag into a humman representation. + /// e.g VERIFICATION_FLAGS.BAD_DIGEST | VERIFICATION_FLAGS.BAD_SIGNATURE | VERIFICATION_FLAGS.CERT_EXPIRED static std::string flag_to_string(VERIFICATION_FLAGS flag); - //! Flags to tweak the verification process of the signature - //! - //! See Signature::check and LIEF::PE::Binary::verify_signature + /// Flags to tweak the verification process of the signature + /// + /// See Signature::check and LIEF::PE::Binary::verify_signature enum class VERIFICATION_CHECKS : uint32_t { DEFAULT = 1 << 0, /**< Default behavior that tries to follow the Microsoft verification process as close as possible */ HASH_ONLY = 1 << 1, /**< Only check that Binary::authentihash matches ContentInfo::digest regardless of the signature's validity */ @@ -102,24 +102,24 @@ class LIEF_API Signature : public Object { Signature(Signature&&); Signature& operator=(Signature&&); - //! Should be 1 + /// Should be 1 uint32_t version() const { return version_; } - //! Algorithm used to *digest* the file. - //! - //! It should match SignerInfo::digest_algorithm + /// Algorithm used to *digest* the file. + /// + /// It should match SignerInfo::digest_algorithm ALGORITHMS digest_algorithm() const { return digest_algorithm_; } - //! Return the ContentInfo + /// Return the ContentInfo const ContentInfo& content_info() const { return content_info_; } - //! Return an iterator over x509 certificates + /// Return an iterator over x509 certificates it_const_crt certificates() const { return certificates_; } @@ -128,7 +128,7 @@ class LIEF_API Signature : public Object { return certificates_; } - //! Return an iterator over the signers (SignerInfo) defined in the PKCS #7 signature + /// Return an iterator over the signers (SignerInfo) defined in the PKCS #7 signature it_const_signers_t signers() const { return signers_; } @@ -137,46 +137,46 @@ class LIEF_API Signature : public Object { return signers_; } - //! Return the raw original PKCS7 signature + /// Return the raw original PKCS7 signature span raw_der() const { return original_raw_signature_; } - //! Find x509 certificate according to its serial number + /// Find x509 certificate according to its serial number const x509* find_crt(const std::vector& serialno) const; - //! Find x509 certificate according to its subject + /// Find x509 certificate according to its subject const x509* find_crt_subject(const std::string& subject) const; - //! Find x509 certificate according to its subject **AND** serial number + /// Find x509 certificate according to its subject **AND** serial number const x509* find_crt_subject(const std::string& subject, const std::vector& serialno) const; - //! Find x509 certificate according to its issuer + /// Find x509 certificate according to its issuer const x509* find_crt_issuer(const std::string& issuer) const; - //! Find x509 certificate according to its issuer **AND** serial number + /// Find x509 certificate according to its issuer **AND** serial number const x509* find_crt_issuer(const std::string& issuer, const std::vector& serialno) const; - //! Check if this signature is valid according to the Authenticode/PKCS #7 verification scheme - //! - //! By default, it performs the following verifications: - //! - //! 1. It must contain only **one** signer info - //! 2. Signature::digest_algorithm must match: - //! * ContentInfo::digest_algorithm - //! * SignerInfo::digest_algorithm - //! 3. The x509 certificate specified by SignerInfo::serial_number **and** SignerInfo::issuer - //! must exist within Signature::certificates - //! 4. Given the x509 certificate, compare SignerInfo::encrypted_digest against either: - //! * hash of authenticated attributes if present - //! * hash of ContentInfo - //! 5. If authenticated attributes are present, check that a PKCS9_MESSAGE_DIGEST attribute exists - //! and that its value matches hash of ContentInfo - //! 6. Check the validity of the PKCS #9 counter signature if present - //! 7. If the signature doesn't embed a signing-time in the counter signature, check the certificate - //! validity. (See LIEF::PE::Signature::VERIFICATION_CHECKS::LIFETIME_SIGNING and LIEF::PE::Signature::VERIFICATION_CHECKS::SKIP_CERT_TIME) - //! - //! See: LIEF::PE::Signature::VERIFICATION_CHECKS to tweak the behavior + /// Check if this signature is valid according to the Authenticode/PKCS #7 verification scheme + /// + /// By default, it performs the following verifications: + /// + /// 1. It must contain only **one** signer info + /// 2. Signature::digest_algorithm must match: + /// * ContentInfo::digest_algorithm + /// * SignerInfo::digest_algorithm + /// 3. The x509 certificate specified by SignerInfo::serial_number **and** SignerInfo::issuer + /// must exist within Signature::certificates + /// 4. Given the x509 certificate, compare SignerInfo::encrypted_digest against either: + /// * hash of authenticated attributes if present + /// * hash of ContentInfo + /// 5. If authenticated attributes are present, check that a PKCS9_MESSAGE_DIGEST attribute exists + /// and that its value matches hash of ContentInfo + /// 6. Check the validity of the PKCS #9 counter signature if present + /// 7. If the signature doesn't embed a signing-time in the counter signature, check the certificate + /// validity. (See LIEF::PE::Signature::VERIFICATION_CHECKS::LIFETIME_SIGNING and LIEF::PE::Signature::VERIFICATION_CHECKS::SKIP_CERT_TIME) + /// + /// See: LIEF::PE::Signature::VERIFICATION_CHECKS to tweak the behavior VERIFICATION_FLAGS check(VERIFICATION_CHECKS checks = VERIFICATION_CHECKS::DEFAULT) const; void accept(Visitor& visitor) const override; diff --git a/include/LIEF/PE/signature/SignatureParser.hpp b/include/LIEF/PE/signature/SignatureParser.hpp index 284bb07156..1deb11c660 100644 --- a/include/LIEF/PE/signature/SignatureParser.hpp +++ b/include/LIEF/PE/signature/SignatureParser.hpp @@ -56,13 +56,13 @@ class LIEF_API SignatureParser { using x509_certificates_t = std::vector; using time_t = std::array; - //! Parse a PKCS #7 signature given a raw blob + /// Parse a PKCS #7 signature given a raw blob static result parse(std::vector data, bool skip_header = false); - //! Parse a PKCS #7 signature given a BinaryStream + /// Parse a PKCS #7 signature given a BinaryStream static result parse(BinaryStream& stream, bool skip_header = false); - //! Parse a PKCS #7 signature from a file path + /// Parse a PKCS #7 signature from a file path static result parse(const std::string& path); SignatureParser(const SignatureParser&) = delete; SignatureParser& operator=(const SignatureParser&) = delete; diff --git a/include/LIEF/PE/signature/SignerInfo.hpp b/include/LIEF/PE/signature/SignerInfo.hpp index b4f651dee8..03bce646bf 100644 --- a/include/LIEF/PE/signature/SignerInfo.hpp +++ b/include/LIEF/PE/signature/SignerInfo.hpp @@ -59,11 +59,11 @@ class LIEF_API SignerInfo : public Object { public: using encrypted_digest_t = std::vector; - //! Internal container used to store both - //! authenticated and unauthenticated attributes + /// Internal container used to store both + /// authenticated and unauthenticated attributes using attributes_t = std::vector>; - //! Iterator which outputs const Attribute& + /// Iterator which outputs const Attribute& using it_const_attributes_t = const_ref_iterator; SignerInfo(); @@ -76,86 +76,86 @@ class LIEF_API SignerInfo : public Object { void swap(SignerInfo& other); - //! Should be 1 + /// Should be 1 uint32_t version() const { return version_; } - //! Return the serial number associated with the x509 certificate - //! used by this signer. - //! - //! @see - //! LIEF::PE::x509::serial_number - //! SignerInfo::issuer + /// Return the serial number associated with the x509 certificate + /// used by this signer. + /// + /// @see + /// LIEF::PE::x509::serial_number + /// SignerInfo::issuer span serial_number() const { return serialno_; } - //! Return the x509::issuer used by this signer + /// Return the x509::issuer used by this signer const std::string& issuer() const { return issuer_; } - //! Algorithm (OID) used to hash the file. - //! - //! This value should match LIEF::PE::ContentInfo::digest_algorithm and - //! LIEF::PE::Signature::digest_algorithm + /// Algorithm (OID) used to hash the file. + /// + /// This value should match LIEF::PE::ContentInfo::digest_algorithm and + /// LIEF::PE::Signature::digest_algorithm ALGORITHMS digest_algorithm() const { return digest_algorithm_; } - //! Return the (public-key) algorithm used to encrypt - //! the signature + /// Return the (public-key) algorithm used to encrypt + /// the signature ALGORITHMS encryption_algorithm() const { return digest_enc_algorithm_; } - //! Return the signature created by the signing - //! certificate's private key + /// Return the signature created by the signing + /// certificate's private key const encrypted_digest_t& encrypted_digest() const { return encrypted_digest_; } - //! Iterator over LIEF::PE::Attribute for **authenticated** attributes + /// Iterator over LIEF::PE::Attribute for **authenticated** attributes it_const_attributes_t authenticated_attributes() const { return authenticated_attributes_; } - //! Iterator over LIEF::PE::Attribute for **unauthenticated** attributes + /// Iterator over LIEF::PE::Attribute for **unauthenticated** attributes it_const_attributes_t unauthenticated_attributes() const { return unauthenticated_attributes_; } - //! Return the authenticated or un-authenticated attribute matching the - //! given PE::SIG_ATTRIBUTE_TYPES. - //! - //! It returns **the first** entry that matches the given type. If it can't be - //! found, it returns a nullptr. + /// Return the authenticated or un-authenticated attribute matching the + /// given PE::SIG_ATTRIBUTE_TYPES. + /// + /// It returns **the first** entry that matches the given type. If it can't be + /// found, it returns a nullptr. const Attribute* get_attribute(Attribute::TYPE type) const; - //! Return the authenticated attribute matching the given PE::SIG_ATTRIBUTE_TYPES. - //! - //! It returns **the first** entry that matches the given type. If it can't be - //! found, it returns a nullptr. + /// Return the authenticated attribute matching the given PE::SIG_ATTRIBUTE_TYPES. + /// + /// It returns **the first** entry that matches the given type. If it can't be + /// found, it returns a nullptr. const Attribute* get_auth_attribute(Attribute::TYPE type) const; - //! Return the un-authenticated attribute matching the given PE::SIG_ATTRIBUTE_TYPES. - //! - //! It returns **the first** entry that matches the given type. If it can't be - //! found, it returns a nullptr. + /// Return the un-authenticated attribute matching the given PE::SIG_ATTRIBUTE_TYPES. + /// + /// It returns **the first** entry that matches the given type. If it can't be + /// found, it returns a nullptr. const Attribute* get_unauth_attribute(Attribute::TYPE type) const; - //! x509 certificate used by this signer. If it can't be found, it returns a nullptr + /// x509 certificate used by this signer. If it can't be found, it returns a nullptr const x509* cert() const { return cert_.get(); } - //! x509 certificate used by this signer. If it can't be found, it returns a nullptr + /// x509 certificate used by this signer. If it can't be found, it returns a nullptr x509* cert() { return cert_.get(); } - //! Raw blob that is signed by the signer certificate + /// Raw blob that is signed by the signer certificate span raw_auth_data() const { return raw_auth_data_; } diff --git a/include/LIEF/PE/signature/SpcIndirectData.hpp b/include/LIEF/PE/signature/SpcIndirectData.hpp index 36e6488803..c2275f8c66 100644 --- a/include/LIEF/PE/signature/SpcIndirectData.hpp +++ b/include/LIEF/PE/signature/SpcIndirectData.hpp @@ -43,16 +43,16 @@ class LIEF_API SpcIndirectData : public ContentInfo::Content { return std::unique_ptr(new SpcIndirectData{*this}); } - //! Digest used to hash the file - //! - //! It should match LIEF::PE::SignerInfo::digest_algorithm + /// Digest used to hash the file + /// + /// It should match LIEF::PE::SignerInfo::digest_algorithm ALGORITHMS digest_algorithm() const { return digest_algorithm_; } - //! PE's authentihash - //! - //! @see LIEF::PE::Binary::authentihash + /// PE's authentihash + /// + /// @see LIEF::PE::Binary::authentihash span digest() const { return digest_; } diff --git a/include/LIEF/PE/signature/attributes/ContentType.hpp b/include/LIEF/PE/signature/attributes/ContentType.hpp index aa9e268776..d84d1ff3ad 100644 --- a/include/LIEF/PE/signature/attributes/ContentType.hpp +++ b/include/LIEF/PE/signature/attributes/ContentType.hpp @@ -26,14 +26,14 @@ namespace LIEF { class VectorStream; namespace PE { -//! Interface over the structure described by the OID ``1.2.840.113549.1.9.3`` (PKCS #9) -//! -//! The internal structure is described in the -//! [RFC #2985: PKCS #9 - Selected Object Classes and Attribute Types Version 2.0](https://tools.ietf.org/html/rfc2985) -//! -//! ```text -//! ContentType ::= OBJECT IDENTIFIER -//! ``` +/// Interface over the structure described by the OID ``1.2.840.113549.1.9.3`` (PKCS #9) +/// +/// The internal structure is described in the +/// [RFC #2985: PKCS #9 - Selected Object Classes and Attribute Types Version 2.0](https://tools.ietf.org/html/rfc2985) +/// +/// ```text +/// ContentType ::= OBJECT IDENTIFIER +/// ``` class LIEF_API ContentType : public Attribute { friend class Parser; @@ -50,12 +50,12 @@ class LIEF_API ContentType : public Attribute { ContentType(const ContentType&) = default; ContentType& operator=(const ContentType&) = default; - //! OID as described in RFC #2985 + /// OID as described in RFC #2985 const oid_t& oid() const { return oid_; } - //! Print information about the attribute + /// Print information about the attribute std::string print() const override; std::unique_ptr clone() const override { diff --git a/include/LIEF/PE/signature/attributes/GenericType.hpp b/include/LIEF/PE/signature/attributes/GenericType.hpp index ca70b625d5..e10c208c68 100644 --- a/include/LIEF/PE/signature/attributes/GenericType.hpp +++ b/include/LIEF/PE/signature/attributes/GenericType.hpp @@ -27,7 +27,7 @@ namespace LIEF { class VectorStream; namespace PE { -//! Interface over an attribute for which the internal structure is not supported by LIEF +/// Interface over an attribute for which the internal structure is not supported by LIEF class LIEF_API GenericType : public Attribute { friend class Parser; friend class SignatureParser; @@ -48,17 +48,17 @@ class LIEF_API GenericType : public Attribute { return std::unique_ptr(new GenericType{*this}); } - //! OID of the original attribute + /// OID of the original attribute const oid_t& oid() const { return oid_; } - //! Original DER blob of the attribute + /// Original DER blob of the attribute span raw_content() const { return raw_; } - //! Print information about the attribute + /// Print information about the attribute std::string print() const override; void accept(Visitor& visitor) const override; diff --git a/include/LIEF/PE/signature/attributes/MsManifestBinaryID.hpp b/include/LIEF/PE/signature/attributes/MsManifestBinaryID.hpp index d3346b77e6..b04cca38b4 100644 --- a/include/LIEF/PE/signature/attributes/MsManifestBinaryID.hpp +++ b/include/LIEF/PE/signature/attributes/MsManifestBinaryID.hpp @@ -23,15 +23,15 @@ namespace LIEF { namespace PE { -//! Interface over the structure described by the OID `1.3.6.1.4.1.311.10.3.28` (szOID_PLATFORM_MANIFEST_BINARY_ID) -//! -//! The internal structure is not documented but we can infer the following structure: -//! -//! ```text -//! szOID_PLATFORM_MANIFEST_BINARY_ID ::= SET OF BinaryID -//! ``` -//! -//! `BinaryID` being an alias of UTF8STRING +/// Interface over the structure described by the OID `1.3.6.1.4.1.311.10.3.28` (szOID_PLATFORM_MANIFEST_BINARY_ID) +/// +/// The internal structure is not documented but we can infer the following structure: +/// +/// ```text +/// szOID_PLATFORM_MANIFEST_BINARY_ID ::= SET OF BinaryID +/// ``` +/// +/// `BinaryID` being an alias of UTF8STRING class LIEF_API MsManifestBinaryID : public Attribute { friend class Parser; @@ -47,12 +47,12 @@ class LIEF_API MsManifestBinaryID : public Attribute { MsManifestBinaryID(const MsManifestBinaryID&) = default; MsManifestBinaryID& operator=(const MsManifestBinaryID&) = default; - //! Print information about the attribute + /// Print information about the attribute std::string print() const override { return id_; } - //! The manifest id as a string + /// The manifest id as a string const std::string& manifest_id() const { return id_; } diff --git a/include/LIEF/PE/signature/attributes/MsSpcNestedSignature.hpp b/include/LIEF/PE/signature/attributes/MsSpcNestedSignature.hpp index a45e5550e2..c8bc766634 100644 --- a/include/LIEF/PE/signature/attributes/MsSpcNestedSignature.hpp +++ b/include/LIEF/PE/signature/attributes/MsSpcNestedSignature.hpp @@ -24,15 +24,15 @@ namespace LIEF { namespace PE { -//! Interface over the structure described by the OID ``1.3.6.1.4.1.311.2.4.1`` -//! -//! The internal structure is not documented but we can infer the following structure: -//! -//! ```text -//! MsSpcNestedSignature ::= SET OF SignedData -//! ``` -//! -//! ``SignedData`` is the structure described in PKCS #7 RFC (LIEF::PE::Signature) +/// Interface over the structure described by the OID ``1.3.6.1.4.1.311.2.4.1`` +/// +/// The internal structure is not documented but we can infer the following structure: +/// +/// ```text +/// MsSpcNestedSignature ::= SET OF SignedData +/// ``` +/// +/// ``SignedData`` is the structure described in PKCS #7 RFC (LIEF::PE::Signature) class LIEF_API MsSpcNestedSignature : public Attribute { friend class Parser; @@ -51,12 +51,12 @@ class LIEF_API MsSpcNestedSignature : public Attribute { return std::unique_ptr(new MsSpcNestedSignature{*this}); } - //! Underlying Signature object + /// Underlying Signature object const Signature& sig() const { return sig_; } - //! Print information about the attribute + /// Print information about the attribute std::string print() const override; void accept(Visitor& visitor) const override; diff --git a/include/LIEF/PE/signature/attributes/MsSpcStatementType.hpp b/include/LIEF/PE/signature/attributes/MsSpcStatementType.hpp index 3af399c25d..f9d2f902b4 100644 --- a/include/LIEF/PE/signature/attributes/MsSpcStatementType.hpp +++ b/include/LIEF/PE/signature/attributes/MsSpcStatementType.hpp @@ -23,14 +23,14 @@ namespace LIEF { namespace PE { -//! Interface over the structure described by the OID ``1.3.6.1.4.1.311.2.1.11`` -//! -//! The internal structure is described in the official document: -//! [Windows Authenticode Portable Executable Signature Format](http://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/Authenticode_PE.docx) -//! -//! ```text -//! SpcStatementType ::= SEQUENCE of OBJECT IDENTIFIER -//! ``` +/// Interface over the structure described by the OID ``1.3.6.1.4.1.311.2.1.11`` +/// +/// The internal structure is described in the official document: +/// [Windows Authenticode Portable Executable Signature Format](http://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/Authenticode_PE.docx) +/// +/// ```text +/// SpcStatementType ::= SEQUENCE of OBJECT IDENTIFIER +/// ``` class LIEF_API MsSpcStatementType : public Attribute { friend class Parser; @@ -50,15 +50,15 @@ class LIEF_API MsSpcStatementType : public Attribute { return std::unique_ptr(new MsSpcStatementType{*this}); } - //! According to the documentation: - //! > The SpcStatementType MUST contain one Object Identifier with either - //! > the value ``1.3.6.1.4.1.311.2.1.21 (SPC_INDIVIDUAL_SP_KEY_PURPOSE_OBJID)`` or - //! > ``1.3.6.1.4.1.311.2.1.22 (SPC_COMMERCIAL_SP_KEY_PURPOSE_OBJID)``. + /// According to the documentation: + /// > The SpcStatementType MUST contain one Object Identifier with either + /// > the value ``1.3.6.1.4.1.311.2.1.21 (SPC_INDIVIDUAL_SP_KEY_PURPOSE_OBJID)`` or + /// > ``1.3.6.1.4.1.311.2.1.22 (SPC_COMMERCIAL_SP_KEY_PURPOSE_OBJID)``. const oid_t& oid() const { return oid_; } - //! Print information about the attribute + /// Print information about the attribute std::string print() const override; static bool classof(const Attribute* attr) { diff --git a/include/LIEF/PE/signature/attributes/PKCS9AtSequenceNumber.hpp b/include/LIEF/PE/signature/attributes/PKCS9AtSequenceNumber.hpp index eee60ef89d..d3ad6d9b80 100644 --- a/include/LIEF/PE/signature/attributes/PKCS9AtSequenceNumber.hpp +++ b/include/LIEF/PE/signature/attributes/PKCS9AtSequenceNumber.hpp @@ -25,21 +25,21 @@ namespace PE { class Parser; class SignatureParser; -//! Interface over the structure described by the OID ``1.2.840.113549.1.9.25.4`` (PKCS #9) -//! -//! The internal structure is described in the -//! [RFC #2985: PKCS #9 - Selected Object Classes and Attribute Types Version 2.0](https://tools.ietf.org/html/rfc2985) -//! -//! ```text -//! sequenceNumber ATTRIBUTE ::= { -//! WITH SYNTAX SequenceNumber -//! EQUALITY MATCHING RULE integerMatch -//! SINGLE VALUE TRUE -//! ID pkcs-9-at-sequenceNumber -//! } -//! -//! SequenceNumber ::= INTEGER (1..MAX) -//! ``` +/// Interface over the structure described by the OID ``1.2.840.113549.1.9.25.4`` (PKCS #9) +/// +/// The internal structure is described in the +/// [RFC #2985: PKCS #9 - Selected Object Classes and Attribute Types Version 2.0](https://tools.ietf.org/html/rfc2985) +/// +/// ```text +/// sequenceNumber ATTRIBUTE ::= { +/// WITH SYNTAX SequenceNumber +/// EQUALITY MATCHING RULE integerMatch +/// SINGLE VALUE TRUE +/// ID pkcs-9-at-sequenceNumber +/// } +/// +/// SequenceNumber ::= INTEGER (1..MAX) +/// ``` class LIEF_API PKCS9AtSequenceNumber : public Attribute { friend class Parser; @@ -59,12 +59,12 @@ class LIEF_API PKCS9AtSequenceNumber : public Attribute { return std::unique_ptr(new PKCS9AtSequenceNumber{*this}); } - //! Number as described in the RFC + /// Number as described in the RFC uint32_t number() const { return number_; } - //! Print information about the attribute + /// Print information about the attribute std::string print() const override; static bool classof(const Attribute* attr) { diff --git a/include/LIEF/PE/signature/attributes/PKCS9CounterSignature.hpp b/include/LIEF/PE/signature/attributes/PKCS9CounterSignature.hpp index 9e6293b16c..d84b2adc76 100644 --- a/include/LIEF/PE/signature/attributes/PKCS9CounterSignature.hpp +++ b/include/LIEF/PE/signature/attributes/PKCS9CounterSignature.hpp @@ -24,17 +24,17 @@ namespace LIEF { class VectorStream; namespace PE { -//! Interface over the structure described by the OID ``1.2.840.113549.1.9.6`` (PKCS #9) -//! -//! The internal structure is described in the -//! [RFC #2985: PKCS #9 - Selected Object Classes and Attribute Types Version 2.0](https://tools.ietf.org/html/rfc2985) -//! -//! ```text -//! counterSignature ATTRIBUTE ::= { -//! WITH SYNTAX SignerInfo -//! ID pkcs-9-at-counterSignature -//! } -//! ``` +/// Interface over the structure described by the OID ``1.2.840.113549.1.9.6`` (PKCS #9) +/// +/// The internal structure is described in the +/// [RFC #2985: PKCS #9 - Selected Object Classes and Attribute Types Version 2.0](https://tools.ietf.org/html/rfc2985) +/// +/// ```text +/// counterSignature ATTRIBUTE ::= { +/// WITH SYNTAX SignerInfo +/// ID pkcs-9-at-counterSignature +/// } +/// ``` class LIEF_API PKCS9CounterSignature : public Attribute { friend class Parser; @@ -54,12 +54,12 @@ class LIEF_API PKCS9CounterSignature : public Attribute { return std::unique_ptr(new PKCS9CounterSignature{*this}); } - //! SignerInfo as described in the RFC #2985 + /// SignerInfo as described in the RFC #2985 const SignerInfo& signer() const { return this->signer_; } - //! Print information about the attribute + /// Print information about the attribute std::string print() const override; static bool classof(const Attribute* attr) { diff --git a/include/LIEF/PE/signature/attributes/PKCS9MessageDigest.hpp b/include/LIEF/PE/signature/attributes/PKCS9MessageDigest.hpp index 96373c477e..518d04246b 100644 --- a/include/LIEF/PE/signature/attributes/PKCS9MessageDigest.hpp +++ b/include/LIEF/PE/signature/attributes/PKCS9MessageDigest.hpp @@ -28,21 +28,21 @@ namespace PE { class Parser; class SignatureParser; -//! Interface over the structure described by the OID ``1.2.840.113549.1.9.4`` (PKCS #9) -//! -//! The internal structure is described in the -//! [RFC #2985: PKCS #9 - Selected Object Classes and Attribute Types Version 2.0](https://tools.ietf.org/html/rfc2985) -//! -//! ```text -//! messageDigest ATTRIBUTE ::= { -//! WITH SYNTAX MessageDigest -//! EQUALITY MATCHING RULE octetStringMatch -//! SINGLE VALUE TRUE -//! ID pkcs-9-at-messageDigest -//! } -//! -//! MessageDigest ::= OCTET STRING -//! ``` +/// Interface over the structure described by the OID ``1.2.840.113549.1.9.4`` (PKCS #9) +/// +/// The internal structure is described in the +/// [RFC #2985: PKCS #9 - Selected Object Classes and Attribute Types Version 2.0](https://tools.ietf.org/html/rfc2985) +/// +/// ```text +/// messageDigest ATTRIBUTE ::= { +/// WITH SYNTAX MessageDigest +/// EQUALITY MATCHING RULE octetStringMatch +/// SINGLE VALUE TRUE +/// ID pkcs-9-at-messageDigest +/// } +/// +/// MessageDigest ::= OCTET STRING +/// ``` class LIEF_API PKCS9MessageDigest : public Attribute { friend class Parser; @@ -62,12 +62,12 @@ class LIEF_API PKCS9MessageDigest : public Attribute { return std::unique_ptr(new PKCS9MessageDigest{*this}); } - //! Message digeset as a blob of bytes as described in the RFC + /// Message digeset as a blob of bytes as described in the RFC span digest() const { return digest_; } - //! Print information about the attribute + /// Print information about the attribute std::string print() const override; static bool classof(const Attribute* attr) { diff --git a/include/LIEF/PE/signature/attributes/PKCS9SigningTime.hpp b/include/LIEF/PE/signature/attributes/PKCS9SigningTime.hpp index 13faaf0639..2a8010f319 100644 --- a/include/LIEF/PE/signature/attributes/PKCS9SigningTime.hpp +++ b/include/LIEF/PE/signature/attributes/PKCS9SigningTime.hpp @@ -24,28 +24,28 @@ namespace LIEF { namespace PE { -//! Interface over the structure described by the OID ``1.2.840.113549.1.9.5`` (PKCS #9) -//! -//! The internal structure is described in the -//! [RFC #2985: PKCS #9 - Selected Object Classes and Attribute Types Version 2.0](https://tools.ietf.org/html/rfc2985) -//! -//! ```text -//! signingTime ATTRIBUTE ::= { -//! WITH SYNTAX SigningTime -//! EQUALITY MATCHING RULE signingTimeMatch -//! SINGLE VALUE TRUE -//! ID pkcs-9-at-signingTime -//! } -//! -//! SigningTime ::= Time -- imported from ISO/IEC 9594-8 -//! ``` +/// Interface over the structure described by the OID ``1.2.840.113549.1.9.5`` (PKCS #9) +/// +/// The internal structure is described in the +/// [RFC #2985: PKCS #9 - Selected Object Classes and Attribute Types Version 2.0](https://tools.ietf.org/html/rfc2985) +/// +/// ```text +/// signingTime ATTRIBUTE ::= { +/// WITH SYNTAX SigningTime +/// EQUALITY MATCHING RULE signingTimeMatch +/// SINGLE VALUE TRUE +/// ID pkcs-9-at-signingTime +/// } +/// +/// SigningTime ::= Time -- imported from ISO/IEC 9594-8 +/// ``` class LIEF_API PKCS9SigningTime : public Attribute { friend class Parser; friend class SignatureParser; public: - //! Time as an array [year, month, day, hour, min, sec] + /// Time as an array [year, month, day, hour, min, sec] using time_t = std::array; PKCS9SigningTime() = delete; @@ -57,12 +57,12 @@ class LIEF_API PKCS9SigningTime : public Attribute { PKCS9SigningTime(const PKCS9SigningTime&) = default; PKCS9SigningTime& operator=(const PKCS9SigningTime&) = default; - //! Time as an array [year, month, day, hour, min, sec] + /// Time as an array [year, month, day, hour, min, sec] const time_t& time() const { return time_; } - //! Print information about the attribute + /// Print information about the attribute std::string print() const override; std::unique_ptr clone() const override { diff --git a/include/LIEF/PE/signature/attributes/SigningCertificateV2.hpp b/include/LIEF/PE/signature/attributes/SigningCertificateV2.hpp index eb09f5f730..6d4a4a46e4 100644 --- a/include/LIEF/PE/signature/attributes/SigningCertificateV2.hpp +++ b/include/LIEF/PE/signature/attributes/SigningCertificateV2.hpp @@ -21,26 +21,26 @@ namespace LIEF { namespace PE { -//! SigningCertificateV2 ::= SEQUENCE { -//! certs SEQUENCE OF ESSCertIDv2, -//! policies SEQUENCE OF PolicyInformation OPTIONAL -//! } -//! -//! ESSCertIDv2 ::= SEQUENCE { -//! hashAlgorithm AlgorithmIdentifier DEFAULT {algorithm id-sha256}, -//! certHash OCTET STRING, -//! issuerSerial IssuerSerial OPTIONAL -//! } -//! -//! IssuerSerial ::= SEQUENCE { -//! issuer GeneralNames, -//! serialNumber CertificateSerialNumber -//! } -//! -//! PolicyInformation ::= SEQUENCE { -//! policyIdentifier OBJECT IDENTIFIER, -//! policyQualifiers SEQUENCE SIZE (1..MAX) OF PolicyQualifierInfo OPTIONAL -//! } +/// SigningCertificateV2 ::= SEQUENCE { +/// certs SEQUENCE OF ESSCertIDv2, +/// policies SEQUENCE OF PolicyInformation OPTIONAL +/// } +/// +/// ESSCertIDv2 ::= SEQUENCE { +/// hashAlgorithm AlgorithmIdentifier DEFAULT {algorithm id-sha256}, +/// certHash OCTET STRING, +/// issuerSerial IssuerSerial OPTIONAL +/// } +/// +/// IssuerSerial ::= SEQUENCE { +/// issuer GeneralNames, +/// serialNumber CertificateSerialNumber +/// } +/// +/// PolicyInformation ::= SEQUENCE { +/// policyIdentifier OBJECT IDENTIFIER, +/// policyQualifiers SEQUENCE SIZE (1..MAX) OF PolicyQualifierInfo OPTIONAL +/// } class LIEF_API SigningCertificateV2 : public Attribute { friend class Parser; friend class SignatureParser; diff --git a/include/LIEF/PE/signature/attributes/SpcSpOpusInfo.hpp b/include/LIEF/PE/signature/attributes/SpcSpOpusInfo.hpp index 8312f668db..6c6b160bb9 100644 --- a/include/LIEF/PE/signature/attributes/SpcSpOpusInfo.hpp +++ b/include/LIEF/PE/signature/attributes/SpcSpOpusInfo.hpp @@ -25,17 +25,17 @@ namespace LIEF { namespace PE { -//! Interface over the structure described by the OID ``1.3.6.1.4.1.311.2.1.12`` -//! -//! The internal structure is described in the official document: -//! [Windows Authenticode Portable Executable Signature Format](http://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/Authenticode_PE.docx) -//! -//! ```text -//! SpcSpOpusInfo ::= SEQUENCE { -//! programName [0] EXPLICIT SpcString OPTIONAL, -//! moreInfo [1] EXPLICIT SpcLink OPTIONAL -//! } -//! ``` +/// Interface over the structure described by the OID ``1.3.6.1.4.1.311.2.1.12`` +/// +/// The internal structure is described in the official document: +/// [Windows Authenticode Portable Executable Signature Format](http://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/Authenticode_PE.docx) +/// +/// ```text +/// SpcSpOpusInfo ::= SEQUENCE { +/// programName [0] EXPLICIT SpcString OPTIONAL, +/// moreInfo [1] EXPLICIT SpcLink OPTIONAL +/// } +/// ``` class LIEF_API SpcSpOpusInfo : public Attribute { friend class Parser; @@ -59,17 +59,17 @@ class LIEF_API SpcSpOpusInfo : public Attribute { return std::unique_ptr(new SpcSpOpusInfo{*this}); } - //! Program description provided by the publisher + /// Program description provided by the publisher const std::string& program_name() const { return program_name_; } - //! Other information such as an url + /// Other information such as an url const std::string& more_info() const { return more_info_; } - //! Print information about the attribute + /// Print information about the attribute std::string print() const override; static bool classof(const Attribute* attr) { diff --git a/include/LIEF/PE/signature/x509.hpp b/include/LIEF/PE/signature/x509.hpp index e17fa2fbbe..fc9379f079 100644 --- a/include/LIEF/PE/signature/x509.hpp +++ b/include/LIEF/PE/signature/x509.hpp @@ -39,7 +39,7 @@ class Signature; class RsaInfo; -//! Interface over a x509 certificate +/// Interface over a x509 certificate class LIEF_API x509 : public Object { friend class Parser; @@ -47,27 +47,27 @@ class LIEF_API x509 : public Object { friend class Signature; public: - //! Tuple (Year, Month, Day, Hour, Minute, Second) + /// Tuple (Year, Month, Day, Hour, Minute, Second) using date_t = std::array; using certificates_t = std::vector; - //! Parse x509 certificate(s) from file path + /// Parse x509 certificate(s) from file path static certificates_t parse(const std::string& path); - //! Parse x509 certificate(s) from raw blob + /// Parse x509 certificate(s) from raw blob static certificates_t parse(const std::vector& content); - //! Return True if ``before`` is *before* than ``after``. False otherwise + /// Return True if ``before`` is *before* than ``after``. False otherwise static bool check_time(const date_t& before, const date_t& after); - //! True if the given time is in the **past** according to the clock's system + /// True if the given time is in the **past** according to the clock's system static bool time_is_past(const date_t& to); - //! True if the given time is in the future according to the clock's system + /// True if the given time is in the future according to the clock's system static bool time_is_future(const date_t& from); - //! Public key scheme + /// Public key scheme enum class KEY_TYPES : uint32_t { NONE = 0, ///< Unknown scheme RSA, ///< RSA Scheme @@ -78,9 +78,9 @@ class LIEF_API x509 : public Object { RSASSA_PSS, ///< RSA Probabilistic signature scheme }; - //! Mirror of mbedtls's X509 Verify codes: MBEDTLS_X509_XX - //! - //! It must be sync with include/mbedtls/x509.h + /// Mirror of mbedtls's X509 Verify codes: MBEDTLS_X509_XX + /// + /// It must be sync with include/mbedtls/x509.h enum class VERIFICATION_FLAGS : uint32_t { OK = 0, /**< The verification succeed */ BADCERT_EXPIRED = 1 << 0, /**< The certificate validity has expired. */ @@ -105,7 +105,7 @@ class LIEF_API x509 : public Object { BADCRL_BAD_KEY = 1 << 19, /**< The CRL is signed with an unacceptable key (eg bad curve, RSA too short). */ }; - //! Key usage as defined in [RFC #5280 - section-4.2.1.3](https://tools.ietf.org/html/rfc5280#section-4.2.1.3) + /// Key usage as defined in [RFC #5280 - section-4.2.1.3](https://tools.ietf.org/html/rfc5280#section-4.2.1.3) enum class KEY_USAGE : uint32_t { DIGITAL_SIGNATURE = 0, /**< The key is used for digital signature */ NON_REPUDIATION, /**< The key is used for digital signature AND to protects against falsely denying some action */ @@ -123,60 +123,60 @@ class LIEF_API x509 : public Object { x509& operator=(x509 other); void swap(x509& other); - //! X.509 version. (1=v1, 2=v2, 3=v3) + /// X.509 version. (1=v1, 2=v2, 3=v3) uint32_t version() const; - //! Unique id for certificate issued by a specific CA. + /// Unique id for certificate issued by a specific CA. std::vector serial_number() const; - //! Signature algorithm (OID) + /// Signature algorithm (OID) oid_t signature_algorithm() const; - //! Start time of certificate validity + /// Start time of certificate validity date_t valid_from() const; - //! End time of certificate validity + /// End time of certificate validity date_t valid_to() const; - //! Issuer informations + /// Issuer informations std::string issuer() const; - //! Subject informations + /// Subject informations std::string subject() const; - //! Try to decrypt the given signature and check if it matches the given hash according to - //! the hash algorithm provided + /// Try to decrypt the given signature and check if it matches the given hash according to + /// the hash algorithm provided bool check_signature(const std::vector& hash, const std::vector& signature, ALGORITHMS digest) const; - //! The raw x509 bytes (DER encoded) + /// The raw x509 bytes (DER encoded) std::vector raw() const; - //! Return the underlying public-key scheme + /// Return the underlying public-key scheme KEY_TYPES key_type() const; - //! **If** the underlying public-key scheme is RSA, return the RSA information. - //! Otherwise, return a nullptr + /// **If** the underlying public-key scheme is RSA, return the RSA information. + /// Otherwise, return a nullptr std::unique_ptr rsa_info() const; - //! Verify that this certificate has been used **to trust** the given certificate + /// Verify that this certificate has been used **to trust** the given certificate VERIFICATION_FLAGS verify(const x509& ca) const; - //! Verify that this certificate **is trusted** by the given CA list + /// Verify that this certificate **is trusted** by the given CA list VERIFICATION_FLAGS is_trusted_by(const std::vector& ca) const; - //! Policy information terms as OID (see RFC #5280) + /// Policy information terms as OID (see RFC #5280) std::vector certificate_policies() const; - //! Purpose of the key contained in the certificate + /// Purpose of the key contained in the certificate std::vector key_usage() const; - //! Indicates one or more purposes for which the certified public key may be used (OID types) + /// Indicates one or more purposes for which the certified public key may be used (OID types) std::vector ext_key_usage() const; bool is_ca() const; - //! The signature of the certificate + /// The signature of the certificate std::vector signature() const; void accept(Visitor& visitor) const override; diff --git a/include/LIEF/PE/utils.hpp b/include/LIEF/PE/utils.hpp index 39603d7734..8a04a358c5 100644 --- a/include/LIEF/PE/utils.hpp +++ b/include/LIEF/PE/utils.hpp @@ -29,7 +29,7 @@ namespace PE { class Binary; class Import; -//! Enum to define the behavior of LIEF::PE::get_imphash +/// Enum to define the behavior of LIEF::PE::get_imphash enum class IMPHASH_MODE { DEFAULT = 0, /**< Default implementation */ LIEF = DEFAULT, /**< Same as IMPHASH_MODE::DEFAULT */ @@ -40,47 +40,47 @@ enum class IMPHASH_MODE { //Check if the given stream wraps a PE binary LIEF_API bool is_pe(BinaryStream& stream); -//! check if the `file` is a PE file +/// check if the `file` is a PE file LIEF_API bool is_pe(const std::string& file); -//! check if the raw data is a PE file +/// check if the raw data is a PE file LIEF_API bool is_pe(const std::vector& raw); -//! if the input `file` is a PE one, return `PE32` or `PE32+` +/// if the input `file` is a PE one, return `PE32` or `PE32+` LIEF_API result get_type(const std::string& file); -//! Return `PE32` or `PE32+` +/// Return `PE32` or `PE32+` LIEF_API result get_type(const std::vector& raw); // In this case we assume that stream contains a valid PE stream LIEF_LOCAL result get_type_from_stream(BinaryStream& stream); -//! Compute the hash of imported functions -//! -//! By default, it generates an hash with the following properties: -//! * Order agnostic -//! * Casse agnostic -//! * Ordinal (**in some extent**) agnostic -//! -//! If one needs the same output as Virus Total (i.e. pefile), you can pass IMPHASH_MODE::PEFILE -//! as second parameter. -//! -//! @warning The default algorithm used to compute the *imphash* value has some variations compared to Yara, pefile, VT implementation -//! -//! @see https://www.fireeye.com/blog/threat-research/2014/01/tracking-malware-import-hashing.html +/// Compute the hash of imported functions +/// +/// By default, it generates an hash with the following properties: +/// * Order agnostic +/// * Casse agnostic +/// * Ordinal (**in some extent**) agnostic +/// +/// If one needs the same output as Virus Total (i.e. pefile), you can pass IMPHASH_MODE::PEFILE +/// as second parameter. +/// +/// @warning The default algorithm used to compute the *imphash* value has some variations compared to Yara, pefile, VT implementation +/// +/// @see https://www.fireeye.com/blog/threat-research/2014/01/tracking-malware-import-hashing.html LIEF_API std::string get_imphash(const Binary& binary, IMPHASH_MODE mode = IMPHASH_MODE::DEFAULT); -//! Take a PE::Import as entry and try to resolve imports -//! by ordinal. -//! -//! The ``strict`` boolean parameter enables to throw an LIEF::not_found exception -//! if the ordinal can't be resolved. Otherwise it skips the entry. -//! -//! @param[in] import Import to resolve -//! @param[in] strict If set to ``true``, throw an exception if the import can't be resolved -//! @param[in] use_std If ``true``, it will use the [pefile](https://github.com/erocarrera/pefile/tree/09264be6f731bf8578aee8638cc4046154e03abf/ordlookup) look-up table for resolving imports -//! -//! @return The PE::import resolved with PE::ImportEntry::name set +/// Take a PE::Import as entry and try to resolve imports +/// by ordinal. +/// +/// The ``strict`` boolean parameter enables to throw an LIEF::not_found exception +/// if the ordinal can't be resolved. Otherwise it skips the entry. +/// +/// @param[in] import Import to resolve +/// @param[in] strict If set to ``true``, throw an exception if the import can't be resolved +/// @param[in] use_std If ``true``, it will use the [pefile](https://github.com/erocarrera/pefile/tree/09264be6f731bf8578aee8638cc4046154e03abf/ordlookup) look-up table for resolving imports +/// +/// @return The PE::import resolved with PE::ImportEntry::name set LIEF_API result resolve_ordinals(const Import& import, bool strict=false, bool use_std=false); LIEF_API ALGORITHMS algo_from_oid(const std::string& oid); diff --git a/include/LIEF/VDEX/File.hpp b/include/LIEF/VDEX/File.hpp index 54982d517a..2460717a8e 100644 --- a/include/LIEF/VDEX/File.hpp +++ b/include/LIEF/VDEX/File.hpp @@ -38,7 +38,7 @@ class Binary; namespace VDEX { class Parser; -//! Main class for the VDEX module which represents a VDEX file +/// Main class for the VDEX module which represents a VDEX file class LIEF_API File : public Object { friend class Parser; friend class OAT::Binary; @@ -51,11 +51,11 @@ class LIEF_API File : public Object { File& operator=(const File& copy) = delete; File(const File& copy) = delete; - //! VDEX Header + /// VDEX Header const Header& header() const; Header& header(); - //! Iterator over LIEF::DEX::Files registered + /// Iterator over LIEF::DEX::Files registered it_dex_files dex_files(); it_const_dex_files dex_files() const; diff --git a/include/LIEF/VDEX/Header.hpp b/include/LIEF/VDEX/Header.hpp index 1cbf8f4450..5734df9e10 100644 --- a/include/LIEF/VDEX/Header.hpp +++ b/include/LIEF/VDEX/Header.hpp @@ -40,22 +40,22 @@ class LIEF_API Header : public Object { Header(const Header&); Header& operator=(const Header&); - //! Magic value used to identify VDEX + /// Magic value used to identify VDEX magic_t magic() const; - //! VDEX version number + /// VDEX version number vdex_version_t version() const; - //! Number of LIEF::DEX::File files registered + /// Number of LIEF::DEX::File files registered uint32_t nb_dex_files() const; - //! Size of **all** LIEF::DEX::File + /// Size of **all** LIEF::DEX::File uint32_t dex_size() const; - //! Size of verifier deps section + /// Size of verifier deps section uint32_t verifier_deps_size() const; - //! Size of quickening info section + /// Size of quickening info section uint32_t quickening_info_size() const; void accept(Visitor& visitor) const override; diff --git a/include/LIEF/VDEX/Parser.hpp b/include/LIEF/VDEX/Parser.hpp index 9a301524d4..7e07ca20ee 100644 --- a/include/LIEF/VDEX/Parser.hpp +++ b/include/LIEF/VDEX/Parser.hpp @@ -28,7 +28,7 @@ class VectorStream; namespace VDEX { class File; -//! @brief Class which parse an VDEX file and transform into a VDEX::File object +/// Class which parse an VDEX file and transform into a VDEX::File object class LIEF_API Parser { public: static std::unique_ptr parse(const std::string& file); diff --git a/include/LIEF/VDEX/utils.hpp b/include/LIEF/VDEX/utils.hpp index b1a5dfb6e2..53b595f4e4 100644 --- a/include/LIEF/VDEX/utils.hpp +++ b/include/LIEF/VDEX/utils.hpp @@ -29,19 +29,19 @@ namespace LIEF { namespace VDEX { -//! @brief Check if the given file is an VDEX one. +/// Check if the given file is an VDEX one. LIEF_API bool is_vdex(const std::string& file); -//! @brief Check if the given raw data is an VDEX one. +/// Check if the given raw data is an VDEX one. LIEF_API bool is_vdex(const std::vector& raw); -//! @brief Return the VDEX version of the given file +/// Return the VDEX version of the given file LIEF_API vdex_version_t version(const std::string& file); -//! @brief Return the VDEX version of the raw data +/// Return the VDEX version of the raw data LIEF_API vdex_version_t version(const std::vector& raw); -//! @brief Return the ANDROID_VERSIONS associated with the given VDEX version +/// Return the ANDROID_VERSIONS associated with the given VDEX version LIEF_API Android::ANDROID_VERSIONS android_version(vdex_version_t version); } diff --git a/include/LIEF/Visitor.hpp b/include/LIEF/Visitor.hpp index e80997dac6..72b8549469 100644 --- a/include/LIEF/Visitor.hpp +++ b/include/LIEF/Visitor.hpp @@ -237,22 +237,22 @@ class LIEF_API Visitor { // Abstract Part // ============= - //! Method to visit a LIEF::Binary + /// Method to visit a LIEF::Binary LIEF_ABSTRACT_VISITABLE(Binary) - //! Method to visit a LIEF::Header + /// Method to visit a LIEF::Header LIEF_ABSTRACT_VISITABLE(Header) - //! Method to visit a LIEF::Section + /// Method to visit a LIEF::Section LIEF_ABSTRACT_VISITABLE(Section) - //! Method to visit a LIEF::Symbol + /// Method to visit a LIEF::Symbol LIEF_ABSTRACT_VISITABLE(Symbol) - //! Method to visit a LIEF::Relocation + /// Method to visit a LIEF::Relocation LIEF_ABSTRACT_VISITABLE(Relocation) - //! Method to visit a LIEF::Function + /// Method to visit a LIEF::Function LIEF_ABSTRACT_VISITABLE(Function) LIEF_ELF_VISITABLE(Binary) @@ -288,415 +288,415 @@ class LIEF_API Visitor { // PE Part // ======= - //! Method to visit a LIEF::PE::Binary + /// Method to visit a LIEF::PE::Binary LIEF_PE_VISITABLE(Binary) - //! Method to visit a LIEF::PE::DosHeader + /// Method to visit a LIEF::PE::DosHeader LIEF_PE_VISITABLE(DosHeader) - //! Method to visit a LIEF::PE:RichHeader + /// Method to visit a LIEF::PE:RichHeader LIEF_PE_VISITABLE(RichHeader) - //! Method to visit a LIEF::PE:RichEntry + /// Method to visit a LIEF::PE:RichEntry LIEF_PE_VISITABLE(RichEntry) - //! Method to visit a LIEF::PE::Header + /// Method to visit a LIEF::PE::Header LIEF_PE_VISITABLE(Header) - //! Method to visit a LIEF::PE::OptionalHeader + /// Method to visit a LIEF::PE::OptionalHeader LIEF_PE_VISITABLE(OptionalHeader) - //! Method to visit a LIEF::PE::DataDirectory + /// Method to visit a LIEF::PE::DataDirectory LIEF_PE_VISITABLE(DataDirectory) - //! Method to visit a LIEF::PE::TLS + /// Method to visit a LIEF::PE::TLS LIEF_PE_VISITABLE(TLS) - //! Method to visit a LIEF::PE::Symbol + /// Method to visit a LIEF::PE::Symbol LIEF_PE_VISITABLE(Symbol) - //! Method to visit a LIEF::PE::Section + /// Method to visit a LIEF::PE::Section LIEF_PE_VISITABLE(Section) - //! Method to visit a LIEF::PE::Relocation + /// Method to visit a LIEF::PE::Relocation LIEF_PE_VISITABLE(Relocation) - //! Method to visit a LIEF::PE::RelocationEntry + /// Method to visit a LIEF::PE::RelocationEntry LIEF_PE_VISITABLE(RelocationEntry) - //! Method to visit a LIEF::PE::Export + /// Method to visit a LIEF::PE::Export LIEF_PE_VISITABLE(Export) - //! Method to visit a LIEF::PE::ExportEntry + /// Method to visit a LIEF::PE::ExportEntry LIEF_PE_VISITABLE(ExportEntry) - //! Method to visit a LIEF::PE::Debug + /// Method to visit a LIEF::PE::Debug LIEF_PE_VISITABLE(Debug) - //! Method to visit a LIEF::PE::CodeView + /// Method to visit a LIEF::PE::CodeView LIEF_PE_VISITABLE(CodeView) - //! Method to visit a LIEF::PE::CodeViewPDB + /// Method to visit a LIEF::PE::CodeViewPDB LIEF_PE_VISITABLE(CodeViewPDB) - //! Method to visit a LIEF::PE::Import + /// Method to visit a LIEF::PE::Import LIEF_PE_VISITABLE(Import) - //! Method to visit a LIEF::PE::ImportEntry + /// Method to visit a LIEF::PE::ImportEntry LIEF_PE_VISITABLE(ImportEntry) - //! Method to visit a LIEF::PE::DelayImport + /// Method to visit a LIEF::PE::DelayImport LIEF_PE_VISITABLE(DelayImport) - //! Method to visit a LIEF::PE::DelayImportEntry + /// Method to visit a LIEF::PE::DelayImportEntry LIEF_PE_VISITABLE(DelayImportEntry) - //! Method to visit a LIEF::PE::ResourceNode + /// Method to visit a LIEF::PE::ResourceNode LIEF_PE_VISITABLE(ResourceNode) - //! Method to visit a LIEF::PE::ResourceData + /// Method to visit a LIEF::PE::ResourceData LIEF_PE_VISITABLE(ResourceData) - //! Method to visit a LIEF::PE::ResourceDirectory + /// Method to visit a LIEF::PE::ResourceDirectory LIEF_PE_VISITABLE(ResourceDirectory) - //! Method to visit a LIEF::PE::ResourceVersion + /// Method to visit a LIEF::PE::ResourceVersion LIEF_PE_VISITABLE(ResourcesManager) - //! Method to visit a LIEF::PE::ResourceVersion + /// Method to visit a LIEF::PE::ResourceVersion LIEF_PE_VISITABLE(ResourceVersion) - //! Method to visit a LIEF::PE::ResourceStringFileInfo + /// Method to visit a LIEF::PE::ResourceStringFileInfo LIEF_PE_VISITABLE(ResourceStringFileInfo) - //! Method to visit a LIEF::PE::ResourceFixedFileInfo + /// Method to visit a LIEF::PE::ResourceFixedFileInfo LIEF_PE_VISITABLE(ResourceFixedFileInfo) - //! Method to visit a LIEF::PE::ResourceVarFileInfo + /// Method to visit a LIEF::PE::ResourceVarFileInfo LIEF_PE_VISITABLE(ResourceVarFileInfo) - //! Method to visit a LIEF::PE::ResourceStringTable + /// Method to visit a LIEF::PE::ResourceStringTable LIEF_PE_VISITABLE(ResourceStringTable) - //! Method to visit a LIEF::PE::ResourceAccelerator + /// Method to visit a LIEF::PE::ResourceAccelerator LIEF_PE_VISITABLE(ResourceAccelerator) - //! Method to visit a LIEF::PE::LangCodeItem + /// Method to visit a LIEF::PE::LangCodeItem LIEF_PE_VISITABLE(LangCodeItem) - //! Method to visit a LIEF::PE::ResourceIcon + /// Method to visit a LIEF::PE::ResourceIcon LIEF_PE_VISITABLE(ResourceIcon) - //! Method to visit a LIEF::PE::ResourceDialog + /// Method to visit a LIEF::PE::ResourceDialog LIEF_PE_VISITABLE(ResourceDialog) - //! Method to visit a LIEF::PE::ResourceDialogItem + /// Method to visit a LIEF::PE::ResourceDialogItem LIEF_PE_VISITABLE(ResourceDialogItem) - //! Method to visit a LIEF::PE::Signature + /// Method to visit a LIEF::PE::Signature LIEF_PE_VISITABLE(Signature) - //! Method to visit a LIEF::PE::x509 + /// Method to visit a LIEF::PE::x509 LIEF_PE_VISITABLE(x509) - //! Method to visit a LIEF::PE::SignerInfo + /// Method to visit a LIEF::PE::SignerInfo LIEF_PE_VISITABLE(SignerInfo) - //! Method to visit a LIEF::PE::ContentInfo + /// Method to visit a LIEF::PE::ContentInfo LIEF_PE_VISITABLE(ContentInfo) - //! Method to visit a LIEF::PE::Attribute + /// Method to visit a LIEF::PE::Attribute LIEF_PE_VISITABLE(Attribute) - //! Method to visit a LIEF::PE::ContentType + /// Method to visit a LIEF::PE::ContentType LIEF_PE_VISITABLE(ContentType) - //! Method to visit a LIEF::PE::GenericContent + /// Method to visit a LIEF::PE::GenericContent LIEF_PE_VISITABLE(GenericContent) - //! Method to visit a LIEF::PE::SpcIndirectData + /// Method to visit a LIEF::PE::SpcIndirectData LIEF_PE_VISITABLE(SpcIndirectData) - //! Method to visit a LIEF::PE::GenericType + /// Method to visit a LIEF::PE::GenericType LIEF_PE_VISITABLE(GenericType) - //! Method to visit a LIEF::PE::MsCounterSign + /// Method to visit a LIEF::PE::MsCounterSign LIEF_PE_VISITABLE(MsCounterSign) - //! Method to visit a LIEF::PE::MsManifestBinaryID + /// Method to visit a LIEF::PE::MsManifestBinaryID LIEF_PE_VISITABLE(MsManifestBinaryID) - //! Method to visit a LIEF::PE::MsSpcNestedSignature + /// Method to visit a LIEF::PE::MsSpcNestedSignature LIEF_PE_VISITABLE(MsSpcNestedSignature) - //! Method to visit a LIEF::PE::MsSpcStatementType + /// Method to visit a LIEF::PE::MsSpcStatementType LIEF_PE_VISITABLE(MsSpcStatementType) - //! Method to visit a LIEF::PE::PKCS9AtSequenceNumber + /// Method to visit a LIEF::PE::PKCS9AtSequenceNumber LIEF_PE_VISITABLE(PKCS9AtSequenceNumber) - //! Method to visit a LIEF::PE::PKCS9CounterSignature + /// Method to visit a LIEF::PE::PKCS9CounterSignature LIEF_PE_VISITABLE(PKCS9CounterSignature) - //! Method to visit a LIEF::PE::PKCS9MessageDigest + /// Method to visit a LIEF::PE::PKCS9MessageDigest LIEF_PE_VISITABLE(PKCS9MessageDigest) - //! Method to visit a LIEF::PE::PKCS9SigningTime + /// Method to visit a LIEF::PE::PKCS9SigningTime LIEF_PE_VISITABLE(PKCS9SigningTime) - //! Method to visit a LIEF::PE::SpcSpOpusInfo + /// Method to visit a LIEF::PE::SpcSpOpusInfo LIEF_PE_VISITABLE(SpcSpOpusInfo) - //! Method to visit a LIEF::PE::SpcRelaxedPeMarkerCheck + /// Method to visit a LIEF::PE::SpcRelaxedPeMarkerCheck LIEF_PE_VISITABLE(SpcRelaxedPeMarkerCheck) - //! Method to visit a LIEF::PE::SigningCertificateV2 + /// Method to visit a LIEF::PE::SigningCertificateV2 LIEF_PE_VISITABLE(SigningCertificateV2) - //! Method to visit a LIEF::PE::LoadConfiguration + /// Method to visit a LIEF::PE::LoadConfiguration LIEF_PE_VISITABLE(LoadConfiguration) - //! Method to visit a LIEF::PE::LoadConfigurationV0 + /// Method to visit a LIEF::PE::LoadConfigurationV0 LIEF_PE_VISITABLE(LoadConfigurationV0) - //! Method to visit a LIEF::PE::LoadConfigurationV1 + /// Method to visit a LIEF::PE::LoadConfigurationV1 LIEF_PE_VISITABLE(LoadConfigurationV1) - //! Method to visit a LIEF::PE::LoadConfigurationV2 + /// Method to visit a LIEF::PE::LoadConfigurationV2 LIEF_PE_VISITABLE(LoadConfigurationV2) - //! Method to visit a LIEF::PE::LoadConfigurationV3 + /// Method to visit a LIEF::PE::LoadConfigurationV3 LIEF_PE_VISITABLE(LoadConfigurationV3) - //! Method to visit a LIEF::PE::LoadConfigurationV4 + /// Method to visit a LIEF::PE::LoadConfigurationV4 LIEF_PE_VISITABLE(LoadConfigurationV4) - //! Method to visit a LIEF::PE::LoadConfigurationV5 + /// Method to visit a LIEF::PE::LoadConfigurationV5 LIEF_PE_VISITABLE(LoadConfigurationV5) - //! Method to visit a LIEF::PE::LoadConfigurationV6 + /// Method to visit a LIEF::PE::LoadConfigurationV6 LIEF_PE_VISITABLE(LoadConfigurationV6) - //! Method to visit a LIEF::PE::LoadConfigurationV7 + /// Method to visit a LIEF::PE::LoadConfigurationV7 LIEF_PE_VISITABLE(LoadConfigurationV7) - //! Method to visit a LIEF::PE::LoadConfigurationV8 + /// Method to visit a LIEF::PE::LoadConfigurationV8 LIEF_PE_VISITABLE(LoadConfigurationV8) - //! Method to visit a LIEF::PE::LoadConfigurationV9 + /// Method to visit a LIEF::PE::LoadConfigurationV9 LIEF_PE_VISITABLE(LoadConfigurationV9) - //! Method to visit a LIEF::PE::LoadConfigurationV10 + /// Method to visit a LIEF::PE::LoadConfigurationV10 LIEF_PE_VISITABLE(LoadConfigurationV10) - //! Method to visit a LIEF::PE::LoadConfigurationV11 + /// Method to visit a LIEF::PE::LoadConfigurationV11 LIEF_PE_VISITABLE(LoadConfigurationV11) - //! Method to visit a LIEF::PE::CodeIntegrity + /// Method to visit a LIEF::PE::CodeIntegrity LIEF_PE_VISITABLE(CodeIntegrity) - //! Method to visit a LIEF::PE::Pogo + /// Method to visit a LIEF::PE::Pogo LIEF_PE_VISITABLE(Pogo) - //! Method to visit a LIEF::PE::PogoEntry + /// Method to visit a LIEF::PE::PogoEntry LIEF_PE_VISITABLE(PogoEntry) - //! Method to visit a LIEF::PE::Repro + /// Method to visit a LIEF::PE::Repro LIEF_PE_VISITABLE(Repro) // MachO part // ========== - //! Method to visit a LIEF::MachO::Binary + /// Method to visit a LIEF::MachO::Binary LIEF_MACHO_VISITABLE(Binary) - //! Method to visit a LIEF::MachO::Header + /// Method to visit a LIEF::MachO::Header LIEF_MACHO_VISITABLE(Header) - //! Method to visit a LIEF::MachO::LoadCommand + /// Method to visit a LIEF::MachO::LoadCommand LIEF_MACHO_VISITABLE(LoadCommand) - //! Method to visit a LIEF::MachO::UUIDCommand + /// Method to visit a LIEF::MachO::UUIDCommand LIEF_MACHO_VISITABLE(UUIDCommand) - //! Method to visit a LIEF::MachO::SymbolCommand + /// Method to visit a LIEF::MachO::SymbolCommand LIEF_MACHO_VISITABLE(SymbolCommand) - //! Method to visit a LIEF::MachO::SegmentCommand + /// Method to visit a LIEF::MachO::SegmentCommand LIEF_MACHO_VISITABLE(SegmentCommand) - //! Method to visit a LIEF::MachO::Section + /// Method to visit a LIEF::MachO::Section LIEF_MACHO_VISITABLE(Section) - //! Method to visit a LIEF::MachO::MainCommand + /// Method to visit a LIEF::MachO::MainCommand LIEF_MACHO_VISITABLE(MainCommand) - //! Method to visit a LIEF::MachO::DynamicSymbolCommand + /// Method to visit a LIEF::MachO::DynamicSymbolCommand LIEF_MACHO_VISITABLE(DynamicSymbolCommand) - //! Method to visit a LIEF::MachO::DylinkerCommand + /// Method to visit a LIEF::MachO::DylinkerCommand LIEF_MACHO_VISITABLE(DylinkerCommand) - //! Method to visit a LIEF::MachO::DylibCommand + /// Method to visit a LIEF::MachO::DylibCommand LIEF_MACHO_VISITABLE(DylibCommand) - //! Method to visit a LIEF::MachO::ThreadCommand + /// Method to visit a LIEF::MachO::ThreadCommand LIEF_MACHO_VISITABLE(ThreadCommand) - //! Method to visit a LIEF::MachO::RPathCommand + /// Method to visit a LIEF::MachO::RPathCommand LIEF_MACHO_VISITABLE(RPathCommand) - //! Method to visit a LIEF::MachO::Symbol + /// Method to visit a LIEF::MachO::Symbol LIEF_MACHO_VISITABLE(Symbol) - //! Method to visit a LIEF::MachO::Relocation + /// Method to visit a LIEF::MachO::Relocation LIEF_MACHO_VISITABLE(Relocation) - //! Method to visit a LIEF::MachO::RelocationObject + /// Method to visit a LIEF::MachO::RelocationObject LIEF_MACHO_VISITABLE(RelocationObject) - //! Method to visit a LIEF::MachO::RelocationDyld + /// Method to visit a LIEF::MachO::RelocationDyld LIEF_MACHO_VISITABLE(RelocationDyld) - //! Method to visit a LIEF::MachO::RelocationFixup + /// Method to visit a LIEF::MachO::RelocationFixup LIEF_MACHO_VISITABLE(RelocationFixup) - //! Method to visit a LIEF::MachO::BindingInfo + /// Method to visit a LIEF::MachO::BindingInfo LIEF_MACHO_VISITABLE(BindingInfo) - //! Method to visit a LIEF::MachO::DyldBindingInfo + /// Method to visit a LIEF::MachO::DyldBindingInfo LIEF_MACHO_VISITABLE(DyldBindingInfo) - //! Method to visit a LIEF::MachO::ChainedBindingInfo + /// Method to visit a LIEF::MachO::ChainedBindingInfo LIEF_MACHO_VISITABLE(ChainedBindingInfo) - //! Method to visit a LIEF::MachO::DyldExportsTrie + /// Method to visit a LIEF::MachO::DyldExportsTrie LIEF_MACHO_VISITABLE(DyldExportsTrie) - //! Method to visit a LIEF::MachO::ExportInfo + /// Method to visit a LIEF::MachO::ExportInfo LIEF_MACHO_VISITABLE(ExportInfo) - //! @brief Method to visit a LIEF::MachO::FunctionStarts + /// Method to visit a LIEF::MachO::FunctionStarts LIEF_MACHO_VISITABLE(FunctionStarts) - //! @brief Method to visit a LIEF::MachO::CodeSignature + /// Method to visit a LIEF::MachO::CodeSignature LIEF_MACHO_VISITABLE(CodeSignature) - //! @brief Method to visit a LIEF::MachO::DataInCode + /// Method to visit a LIEF::MachO::DataInCode LIEF_MACHO_VISITABLE(DataInCode) - //! @brief Method to visit a LIEF::MachO::DataCodeEntry + /// Method to visit a LIEF::MachO::DataCodeEntry LIEF_MACHO_VISITABLE(DataCodeEntry) - //! @brief Method to visit a LIEF::MachO::SourceVersion + /// Method to visit a LIEF::MachO::SourceVersion LIEF_MACHO_VISITABLE(SourceVersion) - //! @brief Method to visit a LIEF::MachO::VersionMin + /// Method to visit a LIEF::MachO::VersionMin LIEF_MACHO_VISITABLE(VersionMin) - //! @brief Method to visit a LIEF::MachO::SegmentSplitInfo + /// Method to visit a LIEF::MachO::SegmentSplitInfo LIEF_MACHO_VISITABLE(SegmentSplitInfo) - //! @brief Method to visit a LIEF::MachO::SubFramework + /// Method to visit a LIEF::MachO::SubFramework LIEF_MACHO_VISITABLE(SubFramework) - //! @brief Method to visit a LIEF::MachO::Routine + /// Method to visit a LIEF::MachO::Routine LIEF_MACHO_VISITABLE(Routine) - //! @brief Method to visit a LIEF::MachO::DyldEnvironment + /// Method to visit a LIEF::MachO::DyldEnvironment LIEF_MACHO_VISITABLE(DyldEnvironment) - //! @brief Method to visit a LIEF::MachO::DyldEnvironment + /// Method to visit a LIEF::MachO::DyldEnvironment LIEF_MACHO_VISITABLE(EncryptionInfo) - //! @brief Method to visit a LIEF::MachO:BuildVersion: + /// Method to visit a LIEF::MachO:BuildVersion: LIEF_MACHO_VISITABLE(BuildVersion) - //! @brief Method to visit a LIEF::MachO:BuildToolVersion: + /// Method to visit a LIEF::MachO:BuildToolVersion: LIEF_MACHO_VISITABLE(BuildToolVersion) - //! @brief Method to visit a LIEF::MachO:BuildToolVersion: + /// Method to visit a LIEF::MachO:BuildToolVersion: LIEF_MACHO_VISITABLE(FilesetCommand) - //! Method to visit a LIEF::MachO::CodeSignatureDir + /// Method to visit a LIEF::MachO::CodeSignatureDir LIEF_MACHO_VISITABLE(CodeSignatureDir) - //! Method to visit a LIEF::MachO::TwoLevelHints + /// Method to visit a LIEF::MachO::TwoLevelHints LIEF_MACHO_VISITABLE(TwoLevelHints) - //! Method to visit a LIEF::MachO::LinkerOptHint + /// Method to visit a LIEF::MachO::LinkerOptHint LIEF_MACHO_VISITABLE(LinkerOptHint) - //! @brief Method to visit a LIEF::MachO::UnknownCommand + /// Method to visit a LIEF::MachO::UnknownCommand LIEF_MACHO_VISITABLE(UnknownCommand) // OAT part // ======== - //! Method to visit a LIEF::OAT::Binary + /// Method to visit a LIEF::OAT::Binary LIEF_OAT_VISITABLE(Binary) - //! Method to visit a LIEF::OAT::Header + /// Method to visit a LIEF::OAT::Header LIEF_OAT_VISITABLE(Header) - //! Method to visit a LIEF::OAT::DexFile + /// Method to visit a LIEF::OAT::DexFile LIEF_OAT_VISITABLE(DexFile) - //! Method to visit a LIEF::OAT::Class + /// Method to visit a LIEF::OAT::Class LIEF_OAT_VISITABLE(Class) - //! Method to visit a LIEF::OAT::Method + /// Method to visit a LIEF::OAT::Method LIEF_OAT_VISITABLE(Method) // DEX part // ======== - //! Method to visit a LIEF::DEX::File + /// Method to visit a LIEF::DEX::File LIEF_DEX_VISITABLE(File) -//! Method to visit a LIEF::DEX::Field +/// Method to visit a LIEF::DEX::Field LIEF_DEX_VISITABLE(Field) - //! Method to visit a LIEF::DEX::Method + /// Method to visit a LIEF::DEX::Method LIEF_DEX_VISITABLE(Method) - //! Method to visit a LIEF::DEX::Header + /// Method to visit a LIEF::DEX::Header LIEF_DEX_VISITABLE(Header) - //! Method to visit a LIEF::DEX::Class + /// Method to visit a LIEF::DEX::Class LIEF_DEX_VISITABLE(Class) - //! Method to visit a LIEF::DEX::CodeInfo + /// Method to visit a LIEF::DEX::CodeInfo LIEF_DEX_VISITABLE(CodeInfo) - //! Method to visit a LIEF::DEX::Type + /// Method to visit a LIEF::DEX::Type LIEF_DEX_VISITABLE(Type) - //! Method to visit a LIEF::DEX:Prototype: + /// Method to visit a LIEF::DEX:Prototype: LIEF_DEX_VISITABLE(Prototype) - //! Method to visit a LIEF::DEX:MapList: + /// Method to visit a LIEF::DEX:MapList: LIEF_DEX_VISITABLE(MapList) - //! Method to visit a LIEF::DEX:MapItem: + /// Method to visit a LIEF::DEX:MapItem: LIEF_DEX_VISITABLE(MapItem) // VDEX part // ========= - //! Method to visit a LIEF::VDEX::File + /// Method to visit a LIEF::VDEX::File LIEF_VDEX_VISITABLE(File) - //! Method to visit a LIEF::VDEX::Header + /// Method to visit a LIEF::VDEX::Header LIEF_VDEX_VISITABLE(Header) // ART part // ========= - //! Method to visit a LIEF::ART::File + /// Method to visit a LIEF::ART::File LIEF_ART_VISITABLE(File) - //! Method to visit a LIEF::ART::Header + /// Method to visit a LIEF::ART::Header LIEF_ART_VISITABLE(Header) template diff --git a/include/LIEF/errors.hpp b/include/LIEF/errors.hpp index af419dcc9b..f731729f6c 100644 --- a/include/LIEF/errors.hpp +++ b/include/LIEF/errors.hpp @@ -19,7 +19,7 @@ #include #include -//! LIEF error codes definition +/// LIEF error codes definition enum class lief_errors : uint32_t { read_error = 1, not_found, @@ -48,64 +48,64 @@ enum class lief_errors : uint32_t { const char* to_string(lief_errors err); -//! Create an standard error code from lief_errors +/// Create an standard error code from lief_errors inline tl::unexpected make_error_code(lief_errors e) { return tl::make_unexpected(e); } namespace LIEF { -//! Wrapper that contains an Object (``T``) or an error -//! -//! The tl/expected implementation exposes the method ``value()`` to access the underlying object (if no error) -//! -//! Typical usage is: -//! -//! \code{.cpp} -//! result intval = my_function(); -//! if (intval) { -//! int val = intval.value(); -//! } else { // There is an error -//! std::cout << get_error(intval).message() << "\n"; -//! } -//! \endcode -//! -//! See https://tl.tartanllama.xyz/en/latest/api/expected.html for more details +/// Wrapper that contains an Object (``T``) or an error +/// +/// The tl/expected implementation exposes the method ``value()`` to access the underlying object (if no error) +/// +/// Typical usage is: +/// +/// \code{.cpp} +/// result intval = my_function(); +/// if (intval) { +/// int val = intval.value(); +/// } else { // There is an error +/// std::cout << get_error(intval).message() << "\n"; +/// } +/// \endcode +/// +/// See https://tl.tartanllama.xyz/en/latest/api/expected.html for more details template using result = tl::expected; -//! Get the error code associated with the result +/// Get the error code associated with the result template lief_errors get_error(result& err) { return err.error(); } -//! Return the lief_errors when the provided ``result`` is an error +/// Return the lief_errors when the provided ``result`` is an error template lief_errors as_lief_err(result& err) { return err.error(); } -//! Opaque structure used by ok_error_t +/// Opaque structure used by ok_error_t struct ok_t {}; -//! Return success for function with return type ok_error_t. +/// Return success for function with return type ok_error_t. inline ok_t ok() { return ok_t{}; } -//! Opaque structure that is used by LIEF to avoid -//! writing ``result f(...)``. Instead, it makes the output -//! explicit such as: -//! -//! \code{.cpp} -//! ok_error_t process() { -//! if (fail) { -//! return make_error_code(...); -//! } -//! return ok(); -//! } -//! \endcode +/// Opaque structure that is used by LIEF to avoid +/// writing ``result f(...)``. Instead, it makes the output +/// explicit such as: +/// +/// \code{.cpp} +/// ok_error_t process() { +/// if (fail) { +/// return make_error_code(...); +/// } +/// return ok(); +/// } +/// \endcode using ok_error_t = result; inline bool is_ok(const ok_error_t& val) { diff --git a/include/LIEF/iterators.hpp b/include/LIEF/iterators.hpp index d17a06ac43..2c7ff933c6 100644 --- a/include/LIEF/iterators.hpp +++ b/include/LIEF/iterators.hpp @@ -40,7 +40,7 @@ template< class T > using add_lvalue_reference_t = typename std::add_lvalue_reference::type; -//! Iterator which returns reference on container's values +/// Iterator which returns reference on container's values template::value_type, class ITERATOR_T = typename decay_t::iterator> class ref_iterator { @@ -252,12 +252,12 @@ class ref_iterator { }; -//! Iterator which return const ref on container's values +/// Iterator which return const ref on container's values template::value_type, class CT = typename std::add_const::type> using const_ref_iterator = ref_iterator::const_iterator>; -//! Iterator which return a ref on container's values given predicates +/// Iterator which return a ref on container's values given predicates template::value_type, class ITERATOR_T = typename decay_t::iterator> class filter_iterator { @@ -473,7 +473,7 @@ class filter_iterator { typename filter_iterator::difference_type distance_ = 0; }; -//! Iterator which return a const ref on container's values given predicates +/// Iterator which return a const ref on container's values given predicates template::value_type, class CT = typename std::add_const::type> using const_filter_iterator = filter_iterator::const_iterator>; diff --git a/include/LIEF/logging.hpp b/include/LIEF/logging.hpp index 6c820d6d2b..ed928c3ad7 100644 --- a/include/LIEF/logging.hpp +++ b/include/LIEF/logging.hpp @@ -30,11 +30,11 @@ class logger; namespace LIEF { namespace logging { -//! **Hierarchical** logging level -//! -//! From a given level set, all levels below this ! level are enabled -//! -//! For example, if LEVEL::INFO is enabled then LEVEL::WARN, LEVEL::ERR are also enabled +/// **Hierarchical** logging level +/// +/// From a given level set, all levels below this ! level are enabled +/// +/// For example, if LEVEL::INFO is enabled then LEVEL::WARN, LEVEL::ERR are also enabled enum class LEVEL : uint32_t { OFF = 0, @@ -46,24 +46,24 @@ enum class LEVEL : uint32_t { CRITICAL, }; -//! Current log level +/// Current log level LIEF_API LEVEL get_level(); LIEF_API const char* to_string(LEVEL e); -//! Globally disable the logging module +/// Globally disable the logging module LIEF_API void disable(); -//! Globally enable the logging module +/// Globally enable the logging module LIEF_API void enable(); -//! Change the logging level (**hierarchical**) +/// Change the logging level (**hierarchical**) LIEF_API void set_level(LEVEL level); -//! Change the logger as a file-base logging and set its path +/// Change the logger as a file-base logging and set its path LIEF_API void set_path(const std::string& path); -//! Log a message with the LIEF's logger +/// Log a message with the LIEF's logger LIEF_API void log(LEVEL level, const std::string& msg); LIEF_API void log(LEVEL level, const std::string& fmt, diff --git a/include/LIEF/utils.hpp b/include/LIEF/utils.hpp index 1cf799ac7e..7001aaf644 100644 --- a/include/LIEF/utils.hpp +++ b/include/LIEF/utils.hpp @@ -70,18 +70,18 @@ constexpr size_t operator ""_GB(unsigned long long gbs) return 1024LLU * 1024LLU * 1024LLU * gbs; } -//! Convert a UTF-16 string to a UTF-8 one +/// Convert a UTF-16 string to a UTF-8 one LIEF_API std::string u16tou8(const std::u16string& string, bool remove_null_char = false); -//! Convert a UTF-8 string to a UTF-16 one +/// Convert a UTF-8 string to a UTF-16 one LIEF_API result u8tou16(const std::string& string); -//! Whether this version of LIEF includes extended features +/// Whether this version of LIEF includes extended features LIEF_API bool is_extended(); -//! Demangle the given input. -//! -//! This function only works with the extended version of LIEF +/// Demangle the given input. +/// +/// This function only works with the extended version of LIEF LIEF_API result demangle(const std::string& mangled); } diff --git a/src/ART/Structures.hpp b/src/ART/Structures.hpp index cc44d1660a..4ea503233e 100644 --- a/src/ART/Structures.hpp +++ b/src/ART/Structures.hpp @@ -39,7 +39,7 @@ // ====================== namespace LIEF { -//! @brief Namespace related to the LIEF's ART module +/// Namespace related to the LIEF's ART module namespace ART { namespace details { diff --git a/src/Abstract/json_internal.hpp b/src/Abstract/json_internal.hpp index 4d85d8f5bf..848054d126 100644 --- a/src/Abstract/json_internal.hpp +++ b/src/Abstract/json_internal.hpp @@ -24,8 +24,8 @@ namespace LIEF { -//! Class that implements the Visitor pattern to serialize LIEF abstracted -//! object in JSON +/// Class that implements the Visitor pattern to serialize LIEF abstracted +/// object in JSON class AbstractJsonVisitor : public LIEF::JsonVisitor { public: using LIEF::JsonVisitor::JsonVisitor; diff --git a/src/DEX/Structures.hpp b/src/DEX/Structures.hpp index 38a3963d3c..cbf4bf217d 100644 --- a/src/DEX/Structures.hpp +++ b/src/DEX/Structures.hpp @@ -24,7 +24,7 @@ #include "LIEF/DEX/types.hpp" namespace LIEF { -//! @brief Namespace related to the LIEF's DEX module +/// Namespace related to the LIEF's DEX module namespace DEX { namespace details { diff --git a/src/DEX/json_internal.hpp b/src/DEX/json_internal.hpp index ccfd4a932f..fee164ea19 100644 --- a/src/DEX/json_internal.hpp +++ b/src/DEX/json_internal.hpp @@ -24,8 +24,8 @@ namespace DEX { json to_json_obj(const Object& v); -//! Class that implements the Visitor pattern to output -//! a JSON representation of an ELF object +/// Class that implements the Visitor pattern to output +/// a JSON representation of an ELF object class JsonVisitor : public LIEF::JsonVisitor { public: using LIEF::JsonVisitor::JsonVisitor; diff --git a/src/ELF/ExeLayout.hpp b/src/ELF/ExeLayout.hpp index 6de2c0636a..cd0751a10a 100644 --- a/src/ELF/ExeLayout.hpp +++ b/src/ELF/ExeLayout.hpp @@ -72,8 +72,8 @@ inline Relocation::TYPE relative_from_arch(ARCH arch) { return TYPE::UNKNOWN; } -//! Compute the size and the offset of the elements -//! needed to rebuild the ELF file. +/// Compute the size and the offset of the elements +/// needed to rebuild the ELF file. class LIEF_LOCAL ExeLayout : public Layout { public: struct sym_verdef_info_t { diff --git a/src/ELF/ObjectFileLayout.hpp b/src/ELF/ObjectFileLayout.hpp index 4502a1ad0f..cebc821bcb 100644 --- a/src/ELF/ObjectFileLayout.hpp +++ b/src/ELF/ObjectFileLayout.hpp @@ -29,8 +29,8 @@ namespace LIEF { namespace ELF { -//! Class used to compute the size and the offsets of the elements -//! needed to rebuild the ELF file. +/// Class used to compute the size and the offsets of the elements +/// needed to rebuild the ELF file. class LIEF_LOCAL ObjectFileLayout : public Layout { public: using relocations_map_t = std::unordered_map>; // Relocation associated with a section @@ -45,8 +45,8 @@ class LIEF_LOCAL ObjectFileLayout : public Layout { ObjectFileLayout(ObjectFileLayout&&) = default; ObjectFileLayout& operator=(ObjectFileLayout&&) = default; - //! The given section should be relocated if the "needed" size - //! is greater than 0 + /// The given section should be relocated if the "needed" size + /// is greater than 0 bool should_relocate(const Section& sec) const { const auto it = sec_reloc_info_.find(&sec); if (it == std::end(sec_reloc_info_)) { diff --git a/src/ELF/json_internal.hpp b/src/ELF/json_internal.hpp index 2fbd2bdc36..f3277406c5 100644 --- a/src/ELF/json_internal.hpp +++ b/src/ELF/json_internal.hpp @@ -54,8 +54,8 @@ class SymbolVersionDefinition; class SymbolVersionRequirement; class SysvHash; -//! Class that implements the Visitor pattern to output -//! a JSON representation of an ELF object +/// Class that implements the Visitor pattern to output +/// a JSON representation of an ELF object class JsonVisitor : public LIEF::JsonVisitor { public: using LIEF::JsonVisitor::JsonVisitor; diff --git a/src/ELF/utils.cpp b/src/ELF/utils.cpp index 5e559c06d3..9993bd95d1 100644 --- a/src/ELF/utils.cpp +++ b/src/ELF/utils.cpp @@ -51,7 +51,7 @@ bool is_elf(const std::vector& raw) { return false; } -//! SYSV hash function +/// SYSV hash function unsigned long hash32(const char* name) { unsigned long h = 0, g; while (*name != 0) { @@ -64,8 +64,8 @@ unsigned long hash32(const char* name) { return h; } -//! SYSV hash function -//! https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections +/// SYSV hash function +/// https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections unsigned long hash64(const char* name) { unsigned long h = 0, g; while (*name != 0) { diff --git a/src/MachO/LinkEdit.cpp b/src/MachO/LinkEdit.cpp index 3186d2f4bc..0c6a0656d7 100644 --- a/src/MachO/LinkEdit.cpp +++ b/src/MachO/LinkEdit.cpp @@ -68,8 +68,8 @@ inline ok_error_t update_span(span& sp, uintptr_t original_data_addr, return ok(); } -//! @param[in] offset Offset where the insertion took place -//! @param[in] size Size of the inserted data +/// @param[in] offset Offset where the insertion took place +/// @param[in] size Size of the inserted data inline ok_error_t update_span(span& sp, uintptr_t original_data_addr, uintptr_t original_data_end, size_t offset, size_t size, std::vector& new_data) { diff --git a/src/MachO/Structures.hpp b/src/MachO/Structures.hpp index 0a88207d12..431d503f1e 100644 --- a/src/MachO/Structures.hpp +++ b/src/MachO/Structures.hpp @@ -44,7 +44,7 @@ (((val) << 40) & 0x00FF000000000000) | (((val) << 56) & 0xFF00000000000000) ) namespace LIEF { -//! Namespace related to the LIEF's MachO module +/// Namespace related to the LIEF's MachO module namespace MachO { namespace details { diff --git a/src/MachO/json_internal.hpp b/src/MachO/json_internal.hpp index 34c43d660a..41c3573d86 100644 --- a/src/MachO/json_internal.hpp +++ b/src/MachO/json_internal.hpp @@ -65,8 +65,8 @@ class UUIDCommand; class VersionMin; class UnknownCommand; -//! Class that implements the Visitor pattern to output -//! a JSON representation of a MachO object +/// Class that implements the Visitor pattern to output +/// a JSON representation of a MachO object class JsonVisitor : public LIEF::JsonVisitor { public: using LIEF::JsonVisitor::JsonVisitor; diff --git a/src/OAT/Structures.hpp b/src/OAT/Structures.hpp index 01621bff83..f1ec1923a9 100644 --- a/src/OAT/Structures.hpp +++ b/src/OAT/Structures.hpp @@ -38,7 +38,7 @@ // ====================== namespace LIEF { -//! @brief Namespace related to the LIEF's OAT module +/// Namespace related to the LIEF's OAT module namespace OAT { namespace details { diff --git a/src/PE/Parser.cpp b/src/PE/Parser.cpp index 82a555594b..bad4f5f0b5 100644 --- a/src/PE/Parser.cpp +++ b/src/PE/Parser.cpp @@ -1139,7 +1139,7 @@ bool Parser::is_valid_import_name(const std::string& name) { bool Parser::is_valid_dll_name(const std::string& name) { - //! @brief Minimum size for a DLL's name + /// @brief Minimum size for a DLL's name static constexpr unsigned MIN_DLL_NAME_SIZE = 4; if (name.size() < MIN_DLL_NAME_SIZE || name.size() > Parser::MAX_DLL_NAME_SIZE) { diff --git a/src/PE/ResourcesParser.hpp b/src/PE/ResourcesParser.hpp index 83534dc9b3..b42e4b8ab2 100644 --- a/src/PE/ResourcesParser.hpp +++ b/src/PE/ResourcesParser.hpp @@ -27,21 +27,21 @@ class ResourceData; class ResourceDialog; struct ResourcesParser { - //! Parse the resource version structure described by: - //! - //! ``` - //! typedef struct { - //! WORD wLength; - //! WORD wValueLength; - //! WORD wType; - //! WCHAR szKey; - //! WORD Padding1; - //! VS_FIXEDFILEINFO Value; - //! WORD Padding2; - //! WORD Children; - //! } VS_VERSIONINFO; - //! ``` - //! See: https://docs.microsoft.com/en-us/windows/win32/menurc/vs-versioninfo + /// Parse the resource version structure described by: + /// + /// ``` + /// typedef struct { + /// WORD wLength; + /// WORD wValueLength; + /// WORD wType; + /// WCHAR szKey; + /// WORD Padding1; + /// VS_FIXEDFILEINFO Value; + /// WORD Padding2; + /// WORD Children; + /// } VS_VERSIONINFO; + /// ``` + /// See: https://docs.microsoft.com/en-us/windows/win32/menurc/vs-versioninfo static result parse_vs_versioninfo(BinaryStream& stream); static ok_error_t parse_version_info_child(ResourceVersion& version, BinaryStream& stream); diff --git a/src/PE/Structures.hpp b/src/PE/Structures.hpp index 74873c1c7a..d6eafc1ed3 100644 --- a/src/PE/Structures.hpp +++ b/src/PE/Structures.hpp @@ -23,14 +23,14 @@ namespace LIEF { -//! Namespace related to the LIEF's PE module -//! -//! Some parts come from llvm/Support/COFF.h +/// Namespace related to the LIEF's PE module +/// +/// Some parts come from llvm/Support/COFF.h namespace PE { namespace details { -//! Sizes in bytes of various things in the COFF format. +/// Sizes in bytes of various things in the COFF format. namespace sizes { static constexpr size_t HEADER_16 = 20; static constexpr size_t HEADER_32 = 56; diff --git a/src/PE/json_internal.hpp b/src/PE/json_internal.hpp index 3f95ab1bd8..6d5607be7f 100644 --- a/src/PE/json_internal.hpp +++ b/src/PE/json_internal.hpp @@ -98,8 +98,8 @@ class Pogo; class PogoEntry; class Repro; -//! Class that implements the Visitor pattern to output -//! a JSON representation of a PE object +/// Class that implements the Visitor pattern to output +/// a JSON representation of a PE object class JsonVisitor : public LIEF::JsonVisitor { public: using LIEF::JsonVisitor::JsonVisitor; diff --git a/src/PE/structures.inc b/src/PE/structures.inc index 415481c3fc..8c795a671a 100644 --- a/src/PE/structures.inc +++ b/src/PE/structures.inc @@ -1,7 +1,7 @@ -//! The maximum number of sections that a COFF object can have (inclusive). +/// The maximum number of sections that a COFF object can have (inclusive). static const int32_t MaxNumberOfSections16 = 65279; -//! The PE signature bytes that follows the DOS stub header. +/// The PE signature bytes that follows the DOS stub header. static const char PE_Magic[] = { 'P', 'E', '\0', '\0' }; static const char Rich_Magic[] = {'R', 'i', 'c', 'h'}; @@ -373,10 +373,10 @@ struct pe_resource_version_info { // uint16_t children }; -//! Resource icons directory structure -//! Based on https://docs.microsoft.com/en-us/windows/win32/menurc/resources-reference -//! -//! This is the begining of the RESOURCE_TYPES::GROUP_ICON content +/// Resource icons directory structure +/// Based on https://docs.microsoft.com/en-us/windows/win32/menurc/resources-reference +/// +/// This is the begining of the RESOURCE_TYPES::GROUP_ICON content struct pe_resource_icon_dir { uint16_t reserved; ///< Reserved uint16_t type; ///< Resource type (1 for icons) @@ -385,7 +385,7 @@ struct pe_resource_icon_dir { }; -//! Structure that follows pe_resource_icon_dir in a resource entry +/// Structure that follows pe_resource_icon_dir in a resource entry struct pe_resource_icon_group { uint8_t width; ///< Width, in pixels, of the image uint8_t height; ///< Height, in pixels, of the image @@ -397,7 +397,7 @@ struct pe_resource_icon_group { uint16_t ID; ///< The associated ID }; -//! Structure that follows pe_resource_icon_dir in a icon **file** +/// Structure that follows pe_resource_icon_dir in a icon **file** struct pe_icon_header { uint8_t width; ///< Width, in pixels, of the image uint8_t height; ///< Height, in pixels, of the image @@ -409,7 +409,7 @@ struct pe_icon_header { uint32_t offset; ///< Offset to the pixels }; -//! Extended dialog box template +/// Extended dialog box template struct pe_dialog_template_ext { uint16_t version; uint16_t signature; @@ -431,7 +431,7 @@ struct pe_dialog_template_ext { // char16_t typeface[stringLen]; }; -//! Dialog box template +/// Dialog box template struct pe_dialog_template { uint32_t style; uint32_t ext_style; @@ -443,7 +443,7 @@ struct pe_dialog_template { }; -//! Extended dialog box template item +/// Extended dialog box template item struct pe_dialog_item_template_ext { uint32_t help_id; uint32_t ext_style; @@ -459,7 +459,7 @@ struct pe_dialog_item_template_ext { }; -//! Dialog box template item +/// Dialog box template item struct pe_dialog_item_template { uint32_t style; uint32_t ext_style; diff --git a/src/VDEX/Structures.hpp b/src/VDEX/Structures.hpp index 2d661630ea..e8b99019b8 100644 --- a/src/VDEX/Structures.hpp +++ b/src/VDEX/Structures.hpp @@ -20,7 +20,7 @@ #include "LIEF/types.hpp" namespace LIEF { -//! @brief Namespace related to the LIEF's VDEX module +/// Namespace related to the LIEF's VDEX module namespace VDEX { namespace details { using vdex_version_t = uint32_t;