LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
injector.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_RUNTIME_WIN_INJECTOR_H
16#define LIEF_RUNTIME_WIN_INJECTOR_H
17
18#include "LIEF/errors.hpp"
19#include "LIEF/visibility.h"
20
21#include <unordered_map>
22#include <ostream>
23#include <string>
24
25
26namespace LIEF::runtime::windows {
27
31 std::string target_path;
32
34 std::string args;
35
37 std::string library;
38
41 std::unordered_map<std::string, std::string> env;
42
45 bool validate() const;
46
47 operator bool() const {
48 return validate();
49 }
50
51 std::string to_string() const;
52
53 friend LIEF_API std::ostream& operator<<(std::ostream& os,
54 const injection_context_t& ctx) {
55 os << ctx.to_string();
56 return os;
57 }
58};
59
66
67}
68
69
70#endif
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:118
Definition windows/Host.hpp:23
ok_error_t inject_spawn(const injection_context_t &ctx)
Spawn the target described by the given injection context and inject the associated library before th...
Describes how to spawn a new process and inject a library into it.
Definition injector.hpp:29
friend std::ostream & operator<<(std::ostream &os, const injection_context_t &ctx)
Definition injector.hpp:53
std::string args
Command-line arguments passed to the spawned process.
Definition injector.hpp:34
bool validate() const
Check whether the context is consistent (required paths filled-in and readable).
std::string library
Absolute path to the library (DLL) that should be injected.
Definition injector.hpp:37
std::unordered_map< std::string, std::string > env
Environment variables to set in the spawned process. If left empty, the current process environment i...
Definition injector.hpp:41
std::string target_path
Absolute path to the target executable to spawn.
Definition injector.hpp:31
#define LIEF_API
Definition visibility.h:44