-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccess.h
More file actions
60 lines (51 loc) · 1.41 KB
/
Access.h
File metadata and controls
60 lines (51 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#include <type_traits>
#include <Windows.h>
namespace libreg
{
enum class Access : DWORD
{
AllAccess = KEY_ALL_ACCESS,
CreateSubKey = KEY_CREATE_SUB_KEY,
EnumerateSubKey = KEY_ENUMERATE_SUB_KEYS,
Read = KEY_READ,
QueryValue = KEY_QUERY_VALUE,
SetValue = KEY_SET_VALUE,
Write = KEY_WRITE,
};
enum class Wow64Access : DWORD
{
Key32Bits = KEY_WOW64_32KEY,
Key64Bits = KEY_WOW64_64KEY
};
template <typename TLeft, typename TRight>
struct IsAccessFlag
{
static const bool value = false;
};
template <>
struct IsAccessFlag<Access, Access>
{
static const bool value = true;
};
template <>
struct IsAccessFlag<Wow64Access, Access>
{
static const bool value = true;
};
template <>
struct IsAccessFlag<Access, Wow64Access>
{
static const bool value = true;
};
template <typename TLeft, typename TRight>
std::enable_if_t<IsAccessFlag<TLeft, TRight>::value, Access> operator| (TLeft left, TRight right)
{
return static_cast<Access>(static_cast<DWORD>(left) | static_cast<DWORD>(right));
}
template <typename TLeft, typename TRight>
std::enable_if_t<IsAccessFlag<TLeft, TRight>::value, bool> operator& (TLeft left, TRight right)
{
return static_cast<DWORD>(left) & static_cast<DWORD>(right);
}
}