libintrovirt v0.57.4
IntroVirt introspection library
Loading...
Searching...
No Matches
FunctionCall.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
18#include <introvirt/core/fwd.hh>
20#include <introvirt/util/json/json.hh>
21
22#include <functional>
23#include <iostream>
24#include <memory>
25#include <string>
26#include <unordered_map>
27
28namespace introvirt {
29
34 public:
40 virtual guest_ptr<void> return_address() const = 0;
41
47 virtual void return_address(const guest_ptr<void>& value) = 0;
48
55 bool hook_return() const;
56
62 void hook_return(bool val);
63
71 virtual bool is_return_event(Event& event) const = 0;
72
80 virtual void handle_return(Event& event) = 0;
81
88 virtual bool returned() const = 0;
89
95 virtual const std::string& library_name() const = 0;
96
102 virtual const std::string& function_name() const = 0;
103
109 virtual void write(std::ostream& os = std::cout) const = 0;
110
116 virtual Json::Value json() const = 0;
117
127 void data(const std::string& key, const std::shared_ptr<void>& value);
128
132 void data(const std::string& key, std::shared_ptr<void>&& value);
133
142 std::shared_ptr<void> data(const std::string& key);
143
149 std::shared_ptr<const void> data(const std::string& key) const;
150
151 virtual ~FunctionCall() = default;
152
153 private:
154 std::unordered_map<std::string, std::shared_ptr<void>> data_;
155 bool hook_return_ = false;
156};
157
158} // namespace introvirt
Interface class for hypervisor events.
Definition Event.hh:43
Base class for function calls.
Definition FunctionCall.hh:33
std::shared_ptr< const void > data(const std::string &key) const
Retrieve arbitrary data stored with the FunctionCall.
void data(const std::string &key, const std::shared_ptr< void > &value)
Store arbitrary data with the FunctionCall.
virtual ~FunctionCall()=default
virtual void handle_return(Event &event)=0
Handle the return event.
virtual void return_address(const guest_ptr< void > &value)=0
Set the return address for this function call.
virtual guest_ptr< void > return_address() const =0
Get the return address for this function call.
virtual const std::string & library_name() const =0
Get the name of the library this call is for.
bool hook_return() const
Check if the user is requesting that the return be intercepted.
virtual const std::string & function_name() const =0
Get the function name.
void hook_return(bool val)
Configure if the return should be intercepted.
void data(const std::string &key, std::shared_ptr< void > &&value)
Store arbitrary data with the FunctionCall.
virtual bool is_return_event(Event &event) const =0
Check if the given event is a return event for this function call.
virtual void write(std::ostream &os=std::cout) const =0
Write out a textual representation of the function for display.
virtual Json::Value json() const =0
Get the function as Json.
std::shared_ptr< void > data(const std::string &key)
Retrieve arbitrary data stored with the FunctionCall.
virtual bool returned() const =0
Check if the call has returned.
Definition guest_ptr.hh:88
Type-safe guest virtual address pointer and guest_ptr template.
Core IntroVirt classes.
Definition Cr0.hh:20