LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
PE/utils.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 Quarkslab
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef LIEF_PE_UTILS_H
17#define LIEF_PE_UTILS_H
18#include <vector>
19#include <string>
20
21#include "LIEF/PE/enums.hpp"
22#include "LIEF/visibility.h"
23#include "LIEF/errors.hpp"
24
25namespace LIEF {
26class BinaryStream;
27
28namespace PE {
29class Binary;
30class Import;
31enum class IMPHASH_MODE {
34 DEFAULT = 0,
38};
39
40//Check if the given stream wraps a PE binary
41LIEF_API bool is_pe(BinaryStream& stream);
42LIEF_API bool is_pe(const std::string& file);
45LIEF_API bool is_pe(const std::vector<uint8_t>& raw);
48LIEF_API result<PE_TYPE> get_type(const std::string& file);
51LIEF_API result<PE_TYPE> get_type(const std::vector<uint8_t>& raw);
54
55// In this case we assume that stream contains a valid PE stream
57LIEF_API std::string get_imphash(const Binary& binary, IMPHASH_MODE mode = IMPHASH_MODE::DEFAULT);
72LIEF_API result<Import> resolve_ordinals(const Import& import, bool strict=false, bool use_std=false);
85
86LIEF_API ALGORITHMS algo_from_oid(const std::string& oid);
87}
88}
89#endif
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
Class which represents a PE binary This is the main interface to manage and modify a PE executable.
Definition PE/Binary.hpp:52
Class that represents a PE import.
Definition Import.hpp:39
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
ALGORITHMS
Cryptography algorithms.
Definition PE/enums.hpp:686
ALGORITHMS algo_from_oid(const std::string &oid)
result< PE_TYPE > get_type_from_stream(BinaryStream &stream)
std::string get_imphash(const Binary &binary, IMPHASH_MODE mode=IMPHASH_MODE::DEFAULT)
Compute the hash of imported functions.
result< PE_TYPE > get_type(const std::string &file)
if the input file is a PE one, return PE32 or PE32+
result< Import > resolve_ordinals(const Import &import, bool strict=false, bool use_std=false)
Take a PE::Import as entry and try to resolve imports by ordinal.
bool is_pe(BinaryStream &stream)
IMPHASH_MODE
Enum to define the behavior of LIEF::PE::get_imphash.
Definition PE/utils.hpp:33
@ VT
Definition PE/utils.hpp:37
@ DEFAULT
Definition PE/utils.hpp:34
@ LIEF
Definition PE/utils.hpp:35
@ PEFILE
Definition PE/utils.hpp:36
LIEF namespace.
Definition Abstract/Binary.hpp:36
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:75
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42