libintrovirt v0.57.4
IntroVirt introspection library
Loading...
Searching...
No Matches
Domain.hh
Go to the documentation of this file.
1/*
2 * Copyright 2021 Assured Information Security, Inc.
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#pragma once
17
24#include <introvirt/core/fwd.hh>
28
29#include <cstdint>
30#include <functional>
31#include <memory>
32#include <string>
33#include <vector>
34
35namespace introvirt {
36
44class Domain {
45 public:
53 virtual std::shared_ptr<Breakpoint> create_breakpoint(const guest_ptr<void>& address,
54 std::function<void(Event&)> callback) = 0;
55
67 virtual std::unique_ptr<Watchpoint> create_watchpoint(const guest_ptr<void>& address,
68 uint64_t length, bool read, bool write,
69 bool execute,
70 std::function<void(Event&)> callback) = 0;
71
79 virtual std::unique_ptr<SingleStep> single_step(Vcpu& vcpu,
80 std::function<void(Event&)> callback) = 0;
81
90 virtual bool detect_guest() = 0;
91
97 virtual Guest* guest() = 0;
98
102 virtual const Guest* guest() const = 0;
103
109 virtual std::string name() const = 0;
110
120 virtual uint32_t id() const = 0;
121
129 virtual Vcpu& vcpu(uint32_t index) = 0;
130
134 virtual const Vcpu& vcpu(uint32_t index) const = 0;
135
141 virtual uint32_t vcpu_count() const = 0;
142
148 virtual const x86::PageDirectory& page_directory() const = 0;
149
157 virtual void poll(EventCallback& callback) = 0;
158
162 virtual void interrupt() = 0;
163
167 virtual void pause() = 0;
168
172 virtual void resume() = 0;
173
179 virtual TaskFilter& task_filter() = 0;
180
191
195 virtual const SystemCallFilter& system_call_filter() const = 0;
196
202 virtual const Hypervisor& hypervisor() const = 0;
203
214 virtual std::shared_ptr<GuestMemoryMapping> map_pfns(const uint64_t* pfns,
215 size_t count) const = 0;
216
233 virtual void intercept_system_calls(bool enabled) = 0;
234
243 virtual void intercept_cr_writes(int cr, bool enabled) = 0;
244
250 virtual void suspend_event(Event& event) = 0;
251
257 virtual void suspend_event_step(Event& event) = 0;
258
266
270 virtual ~Domain() = default;
271};
272
273} // namespace introvirt
A class representing a single Domain.
Definition Domain.hh:44
virtual void suspend_event_step(Event &event)=0
Mark an event as suspended for single step.
virtual const Vcpu & vcpu(uint32_t index) const =0
Get a vcpu by index.
virtual std::string name() const =0
Get the name of the Domain, if it exists.
virtual void intercept_cr_writes(int cr, bool enabled)=0
Toggle control register write interception on all VCPUs.
virtual bool detect_guest()=0
Attempt guest OS detection.
virtual void intercept_system_calls(bool enabled)=0
Toggle system call interception for all VCPUs.
virtual uint32_t vcpu_count() const =0
Get the number of vcpus in the Domain.
virtual std::shared_ptr< Breakpoint > create_breakpoint(const guest_ptr< void > &address, std::function< void(Event &)> callback)=0
Create an execution breakpoint.
virtual void poll(EventCallback &callback)=0
Poll for events and deliver them to the callback.
virtual Vcpu & vcpu(uint32_t index)=0
Get a vcpu by index.
virtual Guest * guest()=0
Get the guest detected by detect_guest()
virtual SystemCallFilter & system_call_filter()=0
Get the system call filter for this Domain.
virtual ~Domain()=default
Destroy the instance.
virtual const Hypervisor & hypervisor() const =0
Gets the hypervisor that the Domain is running on.
static Domain & thread_local_domain()
Get the domain for the current thread.
virtual void interrupt()=0
Interrupt a poll() call.
virtual std::unique_ptr< SingleStep > single_step(Vcpu &vcpu, std::function< void(Event &)> callback)=0
Start single stepping a VCPU.
virtual TaskFilter & task_filter()=0
Get the task filter for this domain.
virtual uint32_t id() const =0
Get the id of the Domain.
virtual std::shared_ptr< GuestMemoryMapping > map_pfns(const uint64_t *pfns, size_t count) const =0
Map a list of pfns into our address space.
virtual void suspend_event(Event &event)=0
Mark an event as suspended.
virtual void pause()=0
Pause the entire Domain.
virtual std::unique_ptr< Watchpoint > create_watchpoint(const guest_ptr< void > &address, uint64_t length, bool read, bool write, bool execute, std::function< void(Event &)> callback)=0
Create a watchpoint on guest memory (e.g. break on read/write)
virtual const SystemCallFilter & system_call_filter() const =0
Get the system call filter for this Domain.
virtual const x86::PageDirectory & page_directory() const =0
Get the page directory for address translation.
virtual const Guest * guest() const =0
Get the guest detected by detect_guest()
virtual void resume()=0
Resume the Domain.
Interface for an event poller callback.
Definition EventCallback.hh:29
Interface class for hypervisor events.
Definition Event.hh:43
Base interface for a Guest.
Definition Guest.hh:35
Abstract class for managing a hypervisor.
Definition Hypervisor.hh:48
Base class for system call filtering.
Definition SystemCallFilter.hh:35
Filter to remove events based on task.
Definition TaskFilter.hh:34
A class representing a single virtual processor.
Definition Vcpu.hh:33
Definition guest_ptr.hh:88
Type-safe guest virtual address pointer and guest_ptr template.
Core IntroVirt classes.
Definition Cr0.hh:20