libintrovirt v0.57.4
IntroVirt introspection library
Loading...
Searching...
No Matches
ACCESS_MASK.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/util/json/json.hh>
19
20#include <cstdint>
21#include <ostream>
22#include <string>
23
24namespace introvirt {
25namespace windows {
26namespace nt {
27
86
110 public:
123
131 virtual AccessMaskType type() const { return UnknownAccessMaskType; }
132
138 Json::Value json() const {
139 Json::Value result;
140 // TODO: Add in the actual flags (depends on type)
141 result["value"] = value_;
142 return result;
143 }
144
148 operator Json::Value() const { return json(); }
149
155 inline uint32_t value() const { return value_; }
156
160 inline operator uint32_t() const { return value_; }
161
167 inline void value(uint32_t mask) { value_ = mask; }
168
176 inline bool has(AccessMaskFlag flag) const { return (value() & flag) == flag; }
177
183 inline void set(AccessMaskFlag flag) { value(value() | flag); }
184
190 inline void clear(AccessMaskFlag flag) { value(value() & ~flag); }
191
192 // Constructors and assignment operators
193 ACCESS_MASK() = default;
194 ACCESS_MASK(uint32_t mask) : value_(mask) {}
195
196 ACCESS_MASK(const ACCESS_MASK&) = default;
198
199 virtual ~ACCESS_MASK() = default;
200
201 private:
202 uint32_t value_ = 0;
203};
204
205const std::string& to_string(AccessMaskFlag);
206std::ostream& operator<<(std::ostream&, AccessMaskFlag);
207
209std::ostream& operator<<(std::ostream&, ACCESS_MASK);
210
211} // namespace nt
212} // namespace windows
213} // namespace introvirt
Generic ACCESS_MASK type.
Definition ACCESS_MASK.hh:109
uint32_t value() const
Get the raw value.
Definition ACCESS_MASK.hh:155
AccessMaskType
Definition ACCESS_MASK.hh:111
@ DirectoryAccessMask
Definition ACCESS_MASK.hh:112
@ UnknownAccessMaskType
Definition ACCESS_MASK.hh:121
@ FileAccessMask
Definition ACCESS_MASK.hh:114
@ TokenAccessMask
Definition ACCESS_MASK.hh:120
@ ProcessAccessMask
Definition ACCESS_MASK.hh:117
@ SectionAccessMask
Definition ACCESS_MASK.hh:118
@ KeyAccessMask
Definition ACCESS_MASK.hh:115
@ EventAccessMask
Definition ACCESS_MASK.hh:113
@ MutantAccessMask
Definition ACCESS_MASK.hh:116
@ ThreadAccessMask
Definition ACCESS_MASK.hh:119
void value(uint32_t mask)
Set the raw value.
Definition ACCESS_MASK.hh:167
virtual AccessMaskType type() const
Get the type of access mask.
Definition ACCESS_MASK.hh:131
ACCESS_MASK(const ACCESS_MASK &)=default
ACCESS_MASK & operator=(const ACCESS_MASK &)=default
void clear(AccessMaskFlag flag)
Clear the given flag.
Definition ACCESS_MASK.hh:190
Json::Value json() const
Get a JSON representation of the mask.
Definition ACCESS_MASK.hh:138
ACCESS_MASK(uint32_t mask)
Definition ACCESS_MASK.hh:194
void set(AccessMaskFlag flag)
Set the state of the given flag to enabled.
Definition ACCESS_MASK.hh:183
bool has(AccessMaskFlag flag) const
Check if the given flag is enabled.
Definition ACCESS_MASK.hh:176
AccessMaskFlag
Common flags for ACCESS_MASK.
Definition ACCESS_MASK.hh:35
@ WRITE_DAC
Write access to the DACL.
Definition ACCESS_MASK.hh:44
@ GENERIC_READ
Generic read access.
Definition ACCESS_MASK.hh:79
@ ACCESS_SYSTEM_SECURITY
used to indicate access to a system access control list (SACL)
Definition ACCESS_MASK.hh:70
@ WRITE_OWNER
The right to change the owner in the object's security descriptor.
Definition ACCESS_MASK.hh:47
@ STANDARD_RIGHTS_READ
Currently defined to equal READ_CONTROL.
Definition ACCESS_MASK.hh:58
@ STANDARD_RIGHTS_REQUIRED
Combines DELETE, READ_CONTROL, WRITE_DAC, and WRITE_OWNER access.
Definition ACCESS_MASK.hh:67
@ STANDARD_RIGHTS_WRITE
Currently defined to equal READ_CONTROL.
Definition ACCESS_MASK.hh:61
@ MAXIMUM_ALLOWED
Definition ACCESS_MASK.hh:84
@ GENERIC_WRITE
Generic write access.
Definition ACCESS_MASK.hh:77
@ STANDARD_RIGHTS_ALL
Combines DELETE, READ_CONTROL, WRITE_DAC, WRITE_OWNER, and SYNCHRONIZE access.
Definition ACCESS_MASK.hh:55
@ STANDARD_RIGHTS_EXECUTE
Currently defined to equal READ_CONTROL.
Definition ACCESS_MASK.hh:64
@ SYNCHRONIZE
Definition ACCESS_MASK.hh:52
@ READ_CONTROL
Definition ACCESS_MASK.hh:41
@ GENERIC_EXECUTE
Generic execute access.
Definition ACCESS_MASK.hh:75
@ DELETE
Delete access.
Definition ACCESS_MASK.hh:37
@ GENERIC_ALL
Generic all access.
Definition ACCESS_MASK.hh:73
std::ostream & operator<<(std::ostream &, APPHELPCACHESERVICECLASS val)
const std::string & to_string(APPHELPCACHESERVICECLASS val)
Core IntroVirt classes.
Definition Cr0.hh:20