Shadow Stack  0.2
 All Classes Namespaces Files Functions Variables Typedefs Macros
ss_mode.hpp
Go to the documentation of this file.
1 
2 #ifndef __SS_MODE_HPP__
3 #define __SS_MODE_HPP__
4 
5 
7 #define INTERNAL_MODE_FLAG "int"
8 
10 #define PROT_INTERNAL_MODE_FLAG "prot_int"
11 
13 #define EXTERNAL_MODE_FLAG "ext"
14 
15 
17 struct SSMode final {
18 
21  SSMode( const char *const m );
22 
24  SSMode() = delete;
25 
26 
28  const char *const str;
29 
31  const bool is_internal;
32 
35 
37  const bool is_external;
38 
40  const bool is_valid_mode;
41 };
42 
43 
44 /*********************************************************/
45 /* */
46 /* Static assertions */
47 /* */
48 /*********************************************************/
49 
50 
53 static constexpr bool str_equal( const char *const s1, const char *const s2 ) {
54  return ( s1[0] != s2[0] ) ? false :
55  ( s1[0] == 0 ) ? true : str_equal( s1 + 1, s2 + 1 );
56 }
57 
58 
61  "internal mode flag cannot equal external mode flag" );
63  "internal mode flag cannot equal protected internal mode flag" );
65  "protected iternal mode flag cannot equal external mode flag" );
66 
67 
68 #endif
const bool is_valid_mode
True if any mode is valid.
Definition: ss_mode.hpp:40
const bool is_external
True if mode = external.
Definition: ss_mode.hpp:37
#define INTERNAL_MODE_FLAG
The flag that must be passed to invoke internal mode.
Definition: ss_mode.hpp:7
const bool is_internal
True if mode = internal.
Definition: ss_mode.hpp:31
const bool is_protected_internal
True if mode = protected internal.
Definition: ss_mode.hpp:34
const char *const str
The mode.
Definition: ss_mode.hpp:28
#define PROT_INTERNAL_MODE_FLAG
The flag that must be passed to invoke protected internal mode.
Definition: ss_mode.hpp:10
static constexpr bool str_equal(const char *const s1, const char *const s2)
A compile time strcmp Recursively checks if the first characters of the strings match.
Definition: ss_mode.hpp:53
A tiny struct that represents a shadow stack mode.
Definition: ss_mode.hpp:17
#define EXTERNAL_MODE_FLAG
The flag that must be passed to invoke external mode.
Definition: ss_mode.hpp:13
SSMode()=delete
Disable the default constructor.