libintrovirt v0.57.4
IntroVirt introspection library
Loading...
Searching...
No Matches
Flags.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 <cstdint>
19
20namespace introvirt {
21namespace x86 {
22
26class Flags {
27 public:
34 bool carry() const;
35
42 bool parity() const;
43
50 bool adjust() const;
51
58 bool zero() const;
59
66 bool sign() const;
67
74 bool trap() const;
75
82 bool interrupt() const;
83
89 void interrupt(bool val);
90
97 bool direction() const;
98
105 bool overflow() const;
106
112 int8_t iopl() const;
113
120 bool nested_task() const;
121
128 bool resume() const;
129
136 bool virtual_8086() const;
137
144 bool alignment_check() const;
145
152 bool virtual_interrupt() const;
153
161
168 bool cpuid() const;
169
175 uint64_t value() const;
176
182 void value(uint64_t value);
183
187 explicit Flags();
188
194 explicit Flags(uint64_t flags);
195
204 explicit Flags(uint64_t& flags, bool* modified);
205
206 Flags(const Flags& src) = delete;
207 Flags& operator=(const Flags&) = delete;
208
209 Flags& operator=(Flags&&) noexcept = default;
210
211 private:
212 inline void set_modified() {
213 if (modified_ != nullptr)
214 *modified_ = true;
215 }
216
217 uint64_t value_ = 0; // Used only for the default constructorm
218 uint64_t* flags_;
219 bool* modified_ = nullptr;
220};
221
222} // namespace x86
223} // namespace introvirt
Handler for the x86 EFLAGS/RFLAGS register.
Definition Flags.hh:26
Flags(uint64_t flags)
Construct a new Flags instances.
uint64_t value() const
Get the raw flags value.
bool resume() const
Get the RF (Resume flag) bit.
bool virtual_interrupt_pending() const
Get the VIP (Virtual-interrupt pending flag) bit.
bool adjust() const
Get the AF (Adjust flag) bit.
bool overflow() const
Get the OF (Overflow flag) bit.
bool sign() const
Get the SF (Sign flag) bit.
int8_t iopl() const
Get the IOPL (I/O privilege level) bits.
Flags & operator=(const Flags &)=delete
Flags & operator=(Flags &&) noexcept=default
bool cpuid() const
Get the ID (CPUID) bit.
Flags()
Construct a new Flags instance (default)
void interrupt(bool val)
Set the IF (interrupt flag) flag.
bool direction() const
Get the DF (Direction flag) bit.
bool zero() const
Get the ZF (Zero flag) bit.
bool interrupt() const
Get the IF (interrupt flag) bit.
bool trap() const
Get the TF (Trap flag) bit.
bool virtual_interrupt() const
Get the VIF (Virtual-interrupt flag) bit.
bool carry() const
Get the CF (Carry flag) bit.
void value(uint64_t value)
Set the raw flags value.
Flags(const Flags &src)=delete
bool alignment_check() const
Get the AC (Aligment-check) bit.
bool virtual_8086() const
Get the VM (Virtual 8086 mode) bit.
Flags(uint64_t &flags, bool *modified)
Construct a new Flags instances using a reference variable.
bool nested_task() const
Get the NT (Nested-task flag) bit.
bool parity() const
Get the PF (Parity flag) bit.
Core IntroVirt classes.
Definition Cr0.hh:20