forked from BenjaminKim/dokanx
-
Notifications
You must be signed in to change notification settings - Fork 2
/
public.h
311 lines (234 loc) · 7.01 KB
/
public.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
/*
Dokan : user-mode file system library for Windows
Copyright (C) 2008 Hiroki Asakawa [email protected]
http://dokan-dev.net/en
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _PUBLIC_H_
#define _PUBLIC_H_
//#include "devioctl.h"
#define DOKAN_DRIVER_VERSION 0x0000190
#define EVENT_CONTEXT_MAX_SIZE (1024*32)
#define IOCTL_TEST \
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SET_DEBUG_MODE \
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_EVENT_WAIT \
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_EVENT_INFO \
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x803, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_EVENT_RELEASE \
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x804, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_EVENT_START \
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x805, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_EVENT_WRITE \
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x806, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_KEEPALIVE \
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x809, METHOD_NEITHER, FILE_ANY_ACCESS)
#define IOCTL_SERVICE_WAIT \
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x80A, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_RESET_TIMEOUT \
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x80B, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_GET_ACCESS_TOKEN \
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x80C, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define DRIVER_FUNC_INSTALL 0x01
#define DRIVER_FUNC_REMOVE 0x02
#define DOKAN_MOUNTED 1
#define DOKAN_USED 2
#define DOKAN_START_FAILED 3
#define DOKAN_DEVICE_MAX 10
#define DOKAN_SECTOR_SIZE 512
#define DOKAN_ALLOCATION_UNIT_SIZE 512
// used in CCB->Flags and FCB->Flags
#define DOKAN_FILE_DIRECTORY 1
#define DOKAN_FILE_DELETED 2
#define DOKAN_FILE_OPENED 4
#define DOKAN_DIR_MATCH_ALL 8
#define DOKAN_DELETE_ON_CLOSE 16
#define DOKAN_PAGING_IO 32
#define DOKAN_SYNCHRONOUS_IO 64
#define DOKAN_WRITE_TO_END_OF_FILE 128
#define DOKAN_NOCACHE 256
// used in DOKAN_START->DeviceType
#define DOKAN_DISK_FILE_SYSTEM 0
#define DOKAN_NETWORK_FILE_SYSTEM 1
typedef struct _CREATE_CONTEXT {
ULONG FileAttributes;
ULONG CreateOptions;
ULONG DesiredAccess;
ULONG ShareAccess;
ULONG FileNameLength;
WCHAR FileName[1];
} CREATE_CONTEXT, *PCREATE_CONTEXT;
typedef struct _CLEANUP_CONTEXT {
ULONG FileNameLength;
WCHAR FileName[1];
} CLEANUP_CONTEXT, *PCLEANUP_CONTEXT;
typedef struct _CLOSE_CONTEXT {
ULONG FileNameLength;
WCHAR FileName[1];
} CLOSE_CONTEXT, *PCLOSE_CONTEXT;
typedef struct _DIRECTORY_CONTEXT {
ULONG FileInformationClass;
ULONG FileIndex;
ULONG BufferLength;
ULONG DirectoryNameLength;
ULONG SearchPatternLength;
ULONG SearchPatternOffset;
WCHAR DirectoryName[1];
WCHAR SearchPatternBase[1];
} DIRECTORY_CONTEXT, *PDIRECTORY_CONTEXT;
typedef struct _READ_CONTEXT {
LARGE_INTEGER ByteOffset;
ULONG BufferLength;
ULONG FileNameLength;
WCHAR FileName[1];
} READ_CONTEXT, *PREAD_CONTEXT;
typedef struct _WRITE_CONTEXT {
LARGE_INTEGER ByteOffset;
ULONG BufferLength;
ULONG BufferOffset;
ULONG RequestLength;
ULONG FileNameLength;
WCHAR FileName[2];
// "2" means to keep last null of contents to write
} WRITE_CONTEXT, *PWRITE_CONTEXT;
typedef struct _FILEINFO_CONTEXT {
ULONG FileInformationClass;
ULONG BufferLength;
ULONG FileNameLength;
WCHAR FileName[1];
} FILEINFO_CONTEXT, *PFILEINFO_CONTEXT;
typedef struct _SETFILE_CONTEXT {
ULONG FileInformationClass;
ULONG BufferLength;
ULONG BufferOffset;
ULONG FileNameLength;
WCHAR FileName[1];
} SETFILE_CONTEXT, *PSETFILE_CONTEXT;
typedef struct _VOLUME_CONTEXT {
ULONG FsInformationClass;
ULONG BufferLength;
} VOLUME_CONTEXT, *PVOLUME_CONTEXT;
typedef struct _LOCK_CONTEXT {
LARGE_INTEGER ByteOffset;
LARGE_INTEGER Length;
ULONG Key;
ULONG FileNameLength;
WCHAR FileName[1];
} LOCK_CONTEXT, *PLOCK_CONTEXT;
typedef struct _FLUSH_CONTEXT {
ULONG FileNameLength;
WCHAR FileName[1];
} FLUSH_CONTEXT, *PFLUSH_CONTEXT;
typedef struct _UNMOUNT_CONTEXT {
WCHAR DeviceName[64];
} UNMOUNT_CONTEXT, *PUNMOUNT_CONTEXT;
typedef struct _SECURITY_CONTEXT {
SECURITY_INFORMATION SecurityInformation;
ULONG BufferLength;
ULONG FileNameLength;
WCHAR FileName[1];
} SECURITY_CONTEXT, *PSECURITY_CONTEXT;
typedef struct _SET_SECURITY_CONTEXT {
SECURITY_INFORMATION SecurityInformation;
ULONG BufferLength;
ULONG BufferOffset;
ULONG FileNameLength;
WCHAR FileName[1];
} SET_SECURITY_CONTEXT, *PSET_SECURITY_CONTEXT;
typedef struct _EVENT_CONTEXT {
ULONG Length;
ULONG MountId;
ULONG SerialNumber;
ULONG ProcessId;
UCHAR MajorFunction;
UCHAR MinorFunction;
ULONG Flags;
ULONG FileFlags;
ULONG64 Context;
union {
DIRECTORY_CONTEXT Directory;
READ_CONTEXT Read;
WRITE_CONTEXT Write;
FILEINFO_CONTEXT File;
CREATE_CONTEXT Create;
CLOSE_CONTEXT Close;
SETFILE_CONTEXT SetFile;
CLEANUP_CONTEXT Cleanup;
LOCK_CONTEXT Lock;
VOLUME_CONTEXT Volume;
FLUSH_CONTEXT Flush;
UNMOUNT_CONTEXT Unmount;
SECURITY_CONTEXT Security;
SET_SECURITY_CONTEXT SetSecurity;
};
} EVENT_CONTEXT, *PEVENT_CONTEXT;
#define WRITE_MAX_SIZE (EVENT_CONTEXT_MAX_SIZE-sizeof(EVENT_CONTEXT)-256*sizeof(WCHAR))
typedef struct _EVENT_INFORMATION {
ULONG SerialNumber;
LONG Status;
ULONG Flags;
union {
struct {
ULONG Index;
} Directory;
struct {
ULONG Flags;
ULONG Information;
} Create;
struct {
LARGE_INTEGER CurrentByteOffset;
} Read;
struct {
LARGE_INTEGER CurrentByteOffset;
} Write;
struct {
UCHAR DeleteOnClose;
} Delete;
struct {
ULONG Timeout;
} ResetTimeout;
struct {
HANDLE Handle;
} AccessToken;
};
ULONG64 Context;
ULONG BufferLength;
UCHAR Buffer[8];
} EVENT_INFORMATION, *PEVENT_INFORMATION;
#define DOKAN_EVENT_ALTERNATIVE_STREAM_ON 1
#define DOKAN_EVENT_KEEP_ALIVE_ON 2
#define DOKAN_EVENT_REMOVABLE 4
typedef struct _EVENT_DRIVER_INFO {
ULONG DriverVersion;
ULONG Status;
ULONG DeviceNumber;
ULONG MountId;
WCHAR DeviceName[64];
} EVENT_DRIVER_INFO, *PEVENT_DRIVER_INFO;
typedef struct _EVENT_START {
ULONG UserVersion;
ULONG DeviceType;
ULONG Flags;
WCHAR DriveLetter;
} EVENT_START, *PEVENT_START;
typedef struct _DOKAN_RENAME_INFORMATION {
BOOLEAN ReplaceIfExists;
ULONG FileNameLength;
WCHAR FileName[1];
} DOKAN_RENAME_INFORMATION, *PDOKAN_RENAME_INFORMATION;
typedef struct _DOKAN_LINK_INFORMATION {
BOOLEAN ReplaceIfExists;
ULONG FileNameLength;
WCHAR FileName[1];
} DOKAN_LINK_INFORMATION, *PDOKAN_LINK_INFORMATION;
#endif // _PUBLIC_H_