1
2
3
4
5 package windows
6
7 import (
8 "syscall"
9 "unsafe"
10 )
11
12
13 const (
14 TCP_KEEPIDLE = 0x03
15 TCP_KEEPCNT = 0x10
16 TCP_KEEPINTVL = 0x11
17 )
18
19 const (
20 FILE_READ_DATA = 0x00000001
21 FILE_READ_ATTRIBUTES = 0x00000080
22 FILE_READ_EA = 0x00000008
23 FILE_WRITE_DATA = 0x00000002
24 FILE_WRITE_ATTRIBUTES = 0x00000100
25 FILE_WRITE_EA = 0x00000010
26 FILE_APPEND_DATA = 0x00000004
27 FILE_EXECUTE = 0x00000020
28
29 FILE_GENERIC_READ = STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE
30 FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE
31 FILE_GENERIC_EXECUTE = STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE
32
33 FILE_LIST_DIRECTORY = 0x00000001
34 FILE_TRAVERSE = 0x00000020
35
36 FILE_SHARE_READ = 0x00000001
37 FILE_SHARE_WRITE = 0x00000002
38 FILE_SHARE_DELETE = 0x00000004
39 FILE_ATTRIBUTE_READONLY = 0x00000001
40 FILE_ATTRIBUTE_HIDDEN = 0x00000002
41 FILE_ATTRIBUTE_SYSTEM = 0x00000004
42 FILE_ATTRIBUTE_DIRECTORY = 0x00000010
43 FILE_ATTRIBUTE_ARCHIVE = 0x00000020
44 FILE_ATTRIBUTE_DEVICE = 0x00000040
45 FILE_ATTRIBUTE_NORMAL = 0x00000080
46 FILE_ATTRIBUTE_TEMPORARY = 0x00000100
47 FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200
48 FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400
49 FILE_ATTRIBUTE_COMPRESSED = 0x00000800
50 FILE_ATTRIBUTE_OFFLINE = 0x00001000
51 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000
52 FILE_ATTRIBUTE_ENCRYPTED = 0x00004000
53 FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x00008000
54 FILE_ATTRIBUTE_VIRTUAL = 0x00010000
55 FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x00020000
56 FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x00040000
57 FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000
58
59 INVALID_FILE_ATTRIBUTES = 0xffffffff
60 )
61
62
63 type ACCESS_MASK uint32
64
65
66 const (
67 DELETE = 0x00010000
68 READ_CONTROL = 0x00020000
69 WRITE_DAC = 0x00040000
70 WRITE_OWNER = 0x00080000
71 SYNCHRONIZE = 0x00100000
72 STANDARD_RIGHTS_REQUIRED = 0x000F0000
73 STANDARD_RIGHTS_READ = READ_CONTROL
74 STANDARD_RIGHTS_WRITE = READ_CONTROL
75 STANDARD_RIGHTS_EXECUTE = READ_CONTROL
76 STANDARD_RIGHTS_ALL = 0x001F0000
77 SPECIFIC_RIGHTS_ALL = 0x0000FFFF
78 ACCESS_SYSTEM_SECURITY = 0x01000000
79 MAXIMUM_ALLOWED = 0x02000000
80 GENERIC_READ = 0x80000000
81 GENERIC_WRITE = 0x40000000
82 GENERIC_EXECUTE = 0x20000000
83 GENERIC_ALL = 0x10000000
84 )
85
86
87 type ACL struct {
88 AclRevision byte
89 Sbz1 byte
90 AclSize uint16
91 AceCount uint16
92 Sbz2 uint16
93 }
94
95
96 type IO_STATUS_BLOCK struct {
97 Status NTStatus
98 Information uintptr
99 }
100
101
102 type OBJECT_ATTRIBUTES struct {
103 Length uint32
104 RootDirectory syscall.Handle
105 ObjectName *NTUnicodeString
106 Attributes uint32
107 SecurityDescriptor *SECURITY_DESCRIPTOR
108 SecurityQoS *SECURITY_QUALITY_OF_SERVICE
109 }
110
111
112 func (o *OBJECT_ATTRIBUTES) init(root syscall.Handle, name string) error {
113 if name == "." {
114 name = ""
115 }
116 objectName, err := NewNTUnicodeString(name)
117 if err != nil {
118 return err
119 }
120 o.ObjectName = objectName
121 if root != syscall.InvalidHandle {
122 o.RootDirectory = root
123 }
124 o.Length = uint32(unsafe.Sizeof(*o))
125 return nil
126 }
127
128
129 const (
130 OBJ_INHERIT = 0x00000002
131 OBJ_PERMANENT = 0x00000010
132 OBJ_EXCLUSIVE = 0x00000020
133 OBJ_CASE_INSENSITIVE = 0x00000040
134 OBJ_OPENIF = 0x00000080
135 OBJ_OPENLINK = 0x00000100
136 OBJ_KERNEL_HANDLE = 0x00000200
137 OBJ_FORCE_ACCESS_CHECK = 0x00000400
138 OBJ_IGNORE_IMPERSONATED_DEVICEMAP = 0x00000800
139 OBJ_DONT_REPARSE = 0x00001000
140 OBJ_VALID_ATTRIBUTES = 0x00001FF2
141 )
142
143
144 type SECURITY_DESCRIPTOR struct {
145 revision byte
146 sbz1 byte
147 control SECURITY_DESCRIPTOR_CONTROL
148 owner *syscall.SID
149 group *syscall.SID
150 sacl *ACL
151 dacl *ACL
152 }
153
154
155 type SECURITY_DESCRIPTOR_CONTROL uint16
156
157
158 type SECURITY_QUALITY_OF_SERVICE struct {
159 Length uint32
160 ImpersonationLevel uint32
161 ContextTrackingMode byte
162 EffectiveOnly byte
163 }
164
165 const (
166
167 FILE_SUPERSEDE = 0x00000000
168 FILE_OPEN = 0x00000001
169 FILE_CREATE = 0x00000002
170 FILE_OPEN_IF = 0x00000003
171 FILE_OVERWRITE = 0x00000004
172 FILE_OVERWRITE_IF = 0x00000005
173 FILE_MAXIMUM_DISPOSITION = 0x00000005
174
175
176 FILE_DIRECTORY_FILE = 0x00000001
177 FILE_WRITE_THROUGH = 0x00000002
178 FILE_SEQUENTIAL_ONLY = 0x00000004
179 FILE_NO_INTERMEDIATE_BUFFERING = 0x00000008
180 FILE_SYNCHRONOUS_IO_ALERT = 0x00000010
181 FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020
182 FILE_NON_DIRECTORY_FILE = 0x00000040
183 FILE_CREATE_TREE_CONNECTION = 0x00000080
184 FILE_COMPLETE_IF_OPLOCKED = 0x00000100
185 FILE_NO_EA_KNOWLEDGE = 0x00000200
186 FILE_OPEN_REMOTE_INSTANCE = 0x00000400
187 FILE_RANDOM_ACCESS = 0x00000800
188 FILE_DELETE_ON_CLOSE = 0x00001000
189 FILE_OPEN_BY_FILE_ID = 0x00002000
190 FILE_OPEN_FOR_BACKUP_INTENT = 0x00004000
191 FILE_NO_COMPRESSION = 0x00008000
192 FILE_OPEN_REQUIRING_OPLOCK = 0x00010000
193 FILE_DISALLOW_EXCLUSIVE = 0x00020000
194 FILE_RESERVE_OPFILTER = 0x00100000
195 FILE_OPEN_REPARSE_POINT = 0x00200000
196 FILE_OPEN_NO_RECALL = 0x00400000
197 FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000
198 )
199
View as plain text