| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | namespace WixToolset.Data |
| 4 | { |
| 5 | using WixToolset.Data.Symbols; |
| 6 | |
| 7 | public static partial class SymbolDefinitions |
| 8 | { |
| 9 | public static readonly IntermediateSymbolDefinition LockPermissions = new IntermediateSymbolDefinition( |
| 10 | SymbolDefinitionType.LockPermissions, |
| 11 | new[] |
| 12 | { |
| 13 | new IntermediateFieldDefinition(nameof(LockPermissionsSymbolFields.LockObject), IntermediateFieldType.String), |
| 14 | new IntermediateFieldDefinition(nameof(LockPermissionsSymbolFields.Table), IntermediateFieldType.String), |
| 15 | new IntermediateFieldDefinition(nameof(LockPermissionsSymbolFields.Domain), IntermediateFieldType.String), |
| 16 | new IntermediateFieldDefinition(nameof(LockPermissionsSymbolFields.User), IntermediateFieldType.String), |
| 17 | new IntermediateFieldDefinition(nameof(LockPermissionsSymbolFields.Permission), IntermediateFieldType.Number), |
| 18 | }, |
| 19 | typeof(LockPermissionsSymbol)); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | namespace WixToolset.Data.Symbols |
| 24 | { |
| 25 | public enum LockPermissionsSymbolFields |
| 26 | { |
| 27 | LockObject, |
| 28 | Table, |
| 29 | Domain, |
| 30 | User, |
| 31 | Permission, |
| 32 | } |
| 33 | |
| 34 | /// <summary> |
| 35 | ///------------------------------------------------------------------------------------------------- |
| 36 | /// Layout of an Access Mask (from https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc783530(v=ws.10)) |
| 37 | /// |
| 38 | /// ------------------------------------------------------------------------------------------------- |
| 39 | /// |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|09|08|07|06|05|04|03|02|01|00| |
| 40 | /// ------------------------------------------------------------------------------------------------- |
| 41 | /// |GR|GW|GE|GA| Reserved |AS|StandardAccessRights| Object-Specific Access Rights | |
| 42 | /// |
| 43 | /// Key |
| 44 | /// GR = Generic Read |
| 45 | /// GW = Generic Write |
| 46 | /// GE = Generic Execute |
| 47 | /// GA = Generic All |
| 48 | /// AS = Right to access SACL |
| 49 | /// </summary> |
| 50 | public static class LockPermissionConstants |
| 51 | { |
| 52 | /// <summary> |
| 53 | /// Generic Access Rights (per WinNT.h) |
| 54 | /// --------------------- |
| 55 | /// GENERIC_ALL (0x10000000L) |
| 56 | /// GENERIC_EXECUTE (0x20000000L) |
| 57 | /// GENERIC_WRITE (0x40000000L) |
| 58 | /// GENERIC_READ (0x80000000L) |
| 59 | /// </summary> |
| 60 | public static readonly string[] GenericPermissions = { "GenericAll", "GenericExecute", "GenericWrite", "GenericRead" }; |
| 61 | |
| 62 | /// <summary> |
| 63 | /// Standard Access Rights (per WinNT.h) |
| 64 | /// ---------------------- |
| 65 | /// DELETE (0x00010000L) |
| 66 | /// READ_CONTROL (0x00020000L) |
| 67 | /// WRITE_DAC (0x00040000L) |
| 68 | /// WRITE_OWNER (0x00080000L) |
| 69 | /// SYNCHRONIZE (0x00100000L) |
| 70 | /// </summary> |
| 71 | public static readonly string[] StandardPermissions = { "Delete", "ReadPermission", "ChangePermission", "TakeOwnership", "Synchronize" }; |
| 72 | |
| 73 | /// <summary> |
| 74 | /// Object-Specific Access Rights |
| 75 | /// ============================= |
| 76 | /// Directory Access Rights (per WinNT.h) |
| 77 | /// ----------------------- |
| 78 | /// FILE_LIST_DIRECTORY ( 0x0001 ) |
| 79 | /// FILE_ADD_FILE ( 0x0002 ) |
| 80 | /// FILE_ADD_SUBDIRECTORY ( 0x0004 ) |
| 81 | /// FILE_READ_EA ( 0x0008 ) |
| 82 | /// FILE_WRITE_EA ( 0x0010 ) |
| 83 | /// FILE_TRAVERSE ( 0x0020 ) |
| 84 | /// FILE_DELETE_CHILD ( 0x0040 ) |
| 85 | /// FILE_READ_ATTRIBUTES ( 0x0080 ) |
| 86 | /// FILE_WRITE_ATTRIBUTES ( 0x0100 ) |
| 87 | /// </summary> |
| 88 | public static readonly string[] FolderPermissions = { "Read", "CreateFile", "CreateChild", "ReadExtendedAttributes", "WriteExtendedAttributes", "Traverse", "DeleteChild", "ReadAttributes", "WriteAttributes" }; |
| 89 | |
| 90 | /// <summary> |
| 91 | /// Registry Access Rights |
| 92 | /// ---------------------- |
| 93 | /// </summary> |
| 94 | public static readonly string[] RegistryPermissions = { "Read", "Write", "CreateSubkeys", "EnumerateSubkeys", "Notify", "CreateLink" }; |
| 95 | |
| 96 | /// <summary> |
| 97 | /// File Access Rights (per WinNT.h) |
| 98 | /// ------------------ |
| 99 | /// FILE_READ_DATA ( 0x0001 ) |
| 100 | /// FILE_WRITE_DATA ( 0x0002 ) |
| 101 | /// FILE_APPEND_DATA ( 0x0004 ) |
| 102 | /// FILE_READ_EA ( 0x0008 ) |
| 103 | /// FILE_WRITE_EA ( 0x0010 ) |
| 104 | /// FILE_EXECUTE ( 0x0020 ) |
| 105 | /// via mask FILE_ALL_ACCESS ( 0x0040 ) |
| 106 | /// FILE_READ_ATTRIBUTES ( 0x0080 ) |
| 107 | /// FILE_WRITE_ATTRIBUTES ( 0x0100 ) |
| 108 | /// |
| 109 | /// STANDARD_RIGHTS_REQUIRED (0x000F0000L) |
| 110 | /// FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF) |
| 111 | /// </summary> |
| 112 | public static readonly string[] FilePermissions = { "Read", "Write", "Append", "ReadExtendedAttributes", "WriteExtendedAttributes", "Execute", "FileAllRights", "ReadAttributes", "WriteAttributes" }; |
| 113 | } |
| 114 | |
| 115 | public class LockPermissionsSymbol : IntermediateSymbol |
| 116 | { |
| 117 | public LockPermissionsSymbol() : base(SymbolDefinitions.LockPermissions, null, null) |
| 118 | { |
| 119 | } |
| 120 | |
| 121 | public LockPermissionsSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SymbolDefinitions.LockPermissions, sourceLineNumber, id) |
| 122 | { |
| 123 | } |
| 124 | |
| 125 | public IntermediateField this[LockPermissionsSymbolFields index] => this.Fields[(int)index]; |
| 126 | |
| 127 | public string LockObject |
| 128 | { |
| 129 | get => (string)this.Fields[(int)LockPermissionsSymbolFields.LockObject]; |
| 130 | set => this.Set((int)LockPermissionsSymbolFields.LockObject, value); |
| 131 | } |
| 132 | |
| 133 | public string Table |
| 134 | { |
| 135 | get => (string)this.Fields[(int)LockPermissionsSymbolFields.Table]; |
| 136 | set => this.Set((int)LockPermissionsSymbolFields.Table, value); |
| 137 | } |
| 138 | |
| 139 | public string Domain |
| 140 | { |
| 141 | get => (string)this.Fields[(int)LockPermissionsSymbolFields.Domain]; |
| 142 | set => this.Set((int)LockPermissionsSymbolFields.Domain, value); |
| 143 | } |
| 144 | |
| 145 | public string User |
| 146 | { |
| 147 | get => (string)this.Fields[(int)LockPermissionsSymbolFields.User]; |
| 148 | set => this.Set((int)LockPermissionsSymbolFields.User, value); |
| 149 | } |
| 150 | |
| 151 | public int? Permission |
| 152 | { |
| 153 | get => (int?)this.Fields[(int)LockPermissionsSymbolFields.Permission]; |
| 154 | set => this.Set((int)LockPermissionsSymbolFields.Permission, value); |
| 155 | } |
| 156 | } |
| 157 | } |