-
Notifications
You must be signed in to change notification settings - Fork 206
/
binexport.h
46 lines (37 loc) · 1.94 KB
/
binexport.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2011-2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This file provide a set of commonly used utility functions to work with
// BinExport2 protos.
#ifndef BINEXPORT_H_
#define BINEXPORT_H_
#include <vector>
#include "third_party/zynamics/binexport/binexport2.pb.h"
#include "third_party/zynamics/binexport/util/types.h"
// This namespace collects functions that work directly with BinExport2 protocol
// buffers, similar to a class with just static methods.
namespace security::binexport {
// Returns the address for an instruction. Takes care of instructions without an
// address (that are part of a continuous run of instructions, for example).
// Aborts the process with a fatal error, if no address can be found for the
// instruction. Note that this should note happen with well-formed BinExport2
// protos. If the specified index is out of bounds, the behavior is undefined.
Address GetInstructionAddress(const BinExport2& proto, int index);
// Like above, but returns the addresses for all instructions in a BinExport2
// proto. This function is more efficient than calling GetInstructionAddress()
// repeatedly in a loop. The trade-off is that the returned vector will store
// all addresses, unlike the BinExport2 proto itself which only stores the
// beginning of continuous instruction runs.
std::vector<Address> GetAllInstructionAddresses(const BinExport2& proto);
} // namespace security::binexport
#endif // BINEXPORT_H_