LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
COFF/utils.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_COFF_UTILS_H
16#define LIEF_COFF_UTILS_H
18#include "LIEF/COFF/Header.hpp"
19#include "LIEF/visibility.h"
20
21#include <string_view>
22
23
24namespace LIEF::COFF {
25
29
31LIEF_API inline bool is_coff(BinaryStream& stream) {
32 return get_kind(stream) != Header::KIND::UNKNOWN;
33}
34
36LIEF_API bool is_coff(std::string_view file);
37
39LIEF_API inline bool is_coff(const uint8_t* buffer, size_t size) {
40 LIEF::SpanStream strm(buffer, size);
41 return is_coff(strm);
42}
43
45LIEF_API inline bool is_coff(const std::vector<uint8_t>& buffer) {
46 return is_coff(buffer.data(), buffer.size());
47}
48
50LIEF_API inline bool is_bigobj(BinaryStream& stream) {
51 return get_kind(stream) == Header::KIND::BIGOBJ;
52}
53
56LIEF_API inline bool is_regular(BinaryStream& stream) {
57 return get_kind(stream) == Header::KIND::REGULAR;
58}
59
60}
61
62#endif
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:34
KIND
Definition COFF/Header.hpp:34
@ UNKNOWN
Definition COFF/Header.hpp:35
@ REGULAR
Definition COFF/Header.hpp:36
@ BIGOBJ
Definition COFF/Header.hpp:37
Definition SpanStream.hpp:31
Definition AuxiliarySymbol.hpp:29
Header::KIND get_kind(BinaryStream &stream)
This function determines if the given stream wraps a COFF binary and if so, whether it's a regular or...
bool is_coff(BinaryStream &stream)
Check if the given stream wraps a COFF file.
Definition COFF/utils.hpp:31
bool is_bigobj(BinaryStream &stream)
Check if the COFF file wrapped by the given stream is a bigobj.
Definition COFF/utils.hpp:50
bool is_regular(BinaryStream &stream)
Check if the COFF file wrapped by the given stream is regular (i.e. not a bigobj).
Definition COFF/utils.hpp:56
#define LIEF_API
Definition visibility.h:44