Arion 1.0.2-alpha
A high-performance C++ framework for emulating executable binaries.
 
Loading...
Searching...
No Matches
context_manager.hpp
Go to the documentation of this file.
1#ifndef ARION_CONTEXT_MANAGER_HPP
2#define ARION_CONTEXT_MANAGER_HPP
3
8#include <memory>
9#include <string>
10#include <vector>
11
12namespace arion
13{
14
15class Arion;
16
18const char CONTEXT_FILE_MAGIC[] = "ARIONCTX";
20const float CONTEXT_FILE_VERSION = 1.0;
21
24{
28 std::vector<std::unique_ptr<ARION_THREAD>> thread_list;
30 std::vector<std::unique_ptr<ARION_FUTEX>> futex_list;
32 std::vector<std::unique_ptr<ARION_MAPPING>> mapping_list;
34 std::vector<std::unique_ptr<ARION_FILE>> file_list;
36 std::vector<std::unique_ptr<ARION_SOCKET>> socket_list;
37 /*
38 * Builder for ARION_CONTEXT instances.
39 */
41 /*
42 * Builder for ARION_CONTEXT instances.
43 * @param[in] running_tid TID of the currently running thread.
44 * @param[in] thread_list List of all threads in the Arion context.
45 * @param[in] futex_list List of all futexes in the Arion context.
46 * @param[in] mapping_list List of all mappings in the Arion context.
47 * @param[in] file_list List of all open files in the Arion context.
48 * @param[in] socket_list List of all open socket connections in the Arion context.
49 */
50 ARION_CONTEXT(pid_t running_tid, std::vector<std::unique_ptr<ARION_THREAD>> thread_list,
51 std::vector<std::unique_ptr<ARION_FUTEX>> futex_list,
52 std::vector<std::unique_ptr<ARION_MAPPING>> mapping_list,
53 std::vector<std::unique_ptr<ARION_FILE>> file_list,
54 std::vector<std::unique_ptr<ARION_SOCKET>> socket_list)
55 : running_tid(running_tid), thread_list(std::move(thread_list)), futex_list(std::move(futex_list)),
56 mapping_list(std::move(mapping_list)), file_list(std::move(file_list)),
57 socket_list(std::move(socket_list)) {};
58};
59
63{
64 private:
66 std::weak_ptr<Arion> arion;
67
68 public:
74 static std::unique_ptr<ContextManager> initialize(std::weak_ptr<Arion> arion);
79 ContextManager(std::weak_ptr<Arion> arion) : arion(arion) {};
84 std::shared_ptr<ARION_CONTEXT> ARION_EXPORT save();
92 void ARION_EXPORT restore(std::shared_ptr<ARION_CONTEXT> ctx, bool restore_mappings = true,
93 bool restore_data = true);
100 void ARION_EXPORT restore(std::shared_ptr<ARION_CONTEXT> ctx, std::vector<std::shared_ptr<ARION_MEM_EDIT>> edits);
105 void ARION_EXPORT save_to_file(std::string file_path);
109 void ARION_EXPORT restore_from_file(std::string file_path);
110};
111
112}; // namespace arion
113
114#endif // ARION_CONTEXT_MANAGER_HPP
Definition context_manager.hpp:63
std::weak_ptr< Arion > arion
The Arion instance which context is being managed.
Definition context_manager.hpp:66
void restore_from_file(std::string file_path)
void restore(std::shared_ptr< ARION_CONTEXT > ctx, std::vector< std::shared_ptr< ARION_MEM_EDIT > > edits)
void save_to_file(std::string file_path)
std::shared_ptr< ARION_CONTEXT > save()
void restore(std::shared_ptr< ARION_CONTEXT > ctx, bool restore_mappings=true, bool restore_data=true)
static std::unique_ptr< ContextManager > initialize(std::weak_ptr< Arion > arion)
ContextManager(std::weak_ptr< Arion > arion)
Definition context_manager.hpp:79
#define ARION_EXPORT
Defines which symbols should be exported from the library.
Definition global_defs.hpp:13
Definition arch_x86-64.hpp:11
const char CONTEXT_FILE_MAGIC[]
Magic string for headers of Arion context files.
Definition context_manager.hpp:18
const float CONTEXT_FILE_VERSION
Version number of Arion context file format.
Definition context_manager.hpp:20
Stores the whole context of an Arion instance that can be saved and restored to resume emulation from...
Definition context_manager.hpp:24
pid_t running_tid
TID of the currently running thread.
Definition context_manager.hpp:26
std::vector< std::unique_ptr< ARION_THREAD > > thread_list
List of all threads in the Arion context.
Definition context_manager.hpp:28
std::vector< std::unique_ptr< ARION_SOCKET > > socket_list
List of all open socket connections in the Arion context.
Definition context_manager.hpp:36
ARION_CONTEXT()
Definition context_manager.hpp:40
std::vector< std::unique_ptr< ARION_FUTEX > > futex_list
List of all futexes in the Arion context.
Definition context_manager.hpp:30
ARION_CONTEXT(pid_t running_tid, std::vector< std::unique_ptr< ARION_THREAD > > thread_list, std::vector< std::unique_ptr< ARION_FUTEX > > futex_list, std::vector< std::unique_ptr< ARION_MAPPING > > mapping_list, std::vector< std::unique_ptr< ARION_FILE > > file_list, std::vector< std::unique_ptr< ARION_SOCKET > > socket_list)
Definition context_manager.hpp:50
std::vector< std::unique_ptr< ARION_MAPPING > > mapping_list
List of all mappings in the Arion context.
Definition context_manager.hpp:32
std::vector< std::unique_ptr< ARION_FILE > > file_list
List of all open files in the Arion context.
Definition context_manager.hpp:34