ReactOS  0.4.12-dev-919-gfc3b8d5
vfdio.h
Go to the documentation of this file.
1 /*
2  vfdio.h
3 
4  Virtual Floppy Drive for Windows
5  Kernel mode driver / user mode program interface header
6 
7  Copyright (C) 2003-2005 Ken Kato
8 */
9 
10 #ifndef _VFDIO_H_
11 #define _VFDIO_H_
12 
13 #ifndef __T
14 #ifdef _NTDDK_
15 #define __T(x) L ## x
16 #else
17 #define __T(x) x
18 #endif
19 #endif
20 
21 #ifndef _T
22 #define _T(x) __T(x)
23 #endif
24 
25 //
26 // Device/driver setting registry value names
27 //
28 #define VFD_REG_DEVICE_NUMBER _T("NumberOfDisks")
29 #define VFD_REG_TRACE_FLAGS _T("TraceFlags")
30 #define VFD_REG_DRIVE_LETTER _T("DriveLetter")
31 
32 //
33 // Device object interface base name
34 //
35 #define VFD_DEVICE_BASENAME _T("VirtualFD")
36 
37 //
38 // sector size constants and macros
39 //
40 #define VFD_BYTES_PER_SECTOR 512
41 #define VFD_SECTOR_ALIGN_MASK (VFD_BYTES_PER_SECTOR - 1)
42 #define VFD_BYTE_SHIFT_COUNT 9
43 
44 #define VFD_BYTE_TO_SECTOR(b) ((b) >> VFD_BYTE_SHIFT_COUNT)
45 #define VFD_SECTOR_TO_BYTE(s) ((s) << VFD_BYTE_SHIFT_COUNT)
46 #define VFD_SECTOR_ALIGNED(b) (((b) & VFD_SECTOR_ALIGN_MASK) == 0)
47 
48 //
49 // Fill character for formatting media
50 //
51 #define VFD_FORMAT_FILL_DATA (UCHAR)0xf6
52 
53 //
54 // Image information structure
55 // Used for IOCTL_VFD_OPEN_IMAGE and IOCTL_VFD_QUERY_IMAGE
56 //
57 #pragma pack (push,2)
58 #ifdef _MSC_VER
59 #pragma warning (push)
60 #pragma warning (disable: 4200) // Zero sized struct member warning
61 #endif
62 
63 typedef struct _VFD_IMAGE_INFO {
64  VFD_DISKTYPE DiskType; // VFD_DISKTYPE_xxx value in vfdtypes.h
65  VFD_MEDIA MediaType; // VFD_MEDIA_xxx value in vfdtypes.h
66  VFD_FLAGS MediaFlags; // VFD_FLAG_xxx value in vfdtypes.h
67  VFD_FILETYPE FileType; // VFD_FILETYE_xxx value in vfdtypes.h
68  ULONG ImageSize; // actual image size in bytes
69  USHORT NameLength; // length in bytes of the file name
70  CHAR FileName[0]; // variable length file name string
72 
73 #ifdef _MSC_VER
74 #pragma warning (pop)
75 #endif
76 #pragma pack (pop)
77 
78 //
79 // Device IO control codes
80 //
81 
82 /*
83  IOCTL_VFD_OPEN_IMAGE
84 
85  Open an existing floppy image file or create an empty RAM disk
86 
87  Input:
88  buffer containing a VFD_IMAGE_INFO structure followed by
89  an image file name
90 
91  InputLength:
92  sizeof(VFD_IMAGE_INFO) plus length of the image file name
93 
94  Output:
95  Not used with this operation; set to NULL.
96 
97  Output Length:
98  Not used with this operation; set to zero.
99 
100  Return:
101  STATUS_INVALID_PARAMETER input buffer size < sizeof(VFD_IMAGE_INFO)
102  or any other parameter errors
103  STATUS_DEVICE_BUSY an image is already opened
104  STATUS_ACCESS_DENIED file access error. returned also when the
105  file is compressed / encrypted
106 */
107 #define IOCTL_VFD_OPEN_IMAGE CTL_CODE( \
108  IOCTL_DISK_BASE, \
109  0x800, \
110  METHOD_BUFFERED, \
111  FILE_READ_ACCESS | FILE_WRITE_ACCESS)
112 
113 /*
114  IOCTL_VFD_CLOSE_IMAGE
115 
116  Close the current virtual floppy image
117 
118  Input:
119  Not used with this operation; set to NULL.
120 
121  Input Length:
122  Not used with this operation; set to zero.
123 
124  Output:
125  Not used with this operation; set to NULL.
126 
127  Output Length:
128  Not used with this operation; set to zero.
129 
130  Return:
131  STATUS_NO_MEDIA_IN_DEVICE image is not opened
132 */
133 #define IOCTL_VFD_CLOSE_IMAGE CTL_CODE( \
134  IOCTL_DISK_BASE, \
135  0x801, \
136  METHOD_NEITHER, \
137  FILE_READ_ACCESS | FILE_WRITE_ACCESS)
138 
139 /*
140  IOCTL_VFD_QUERY_IMAGE
141 
142  Get the current image information
143 
144  Input:
145  Not used with this operation; set to NULL.
146 
147  Input Length:
148  Not used with this operation; set to zero.
149 
150  Output:
151  Buffer to receive a VFD_IMAGE_INFO data structure
152 
153  Output Length:
154  must be long enough to hold a VFD_IMAGE_INFO with the image file name
155 
156  Return:
157  STATUS_BUFFER_TOO_SMALL buffer length < sizeof(VFD_IMAGE_INFO)
158  STATUS_BUFFER_OVERFLOW buffer cannot hold the image file name.
159  NameLength member contains the file name
160  length (number of bytes). See this value
161  to decide necessary buffer length.
162 */
163 #define IOCTL_VFD_QUERY_IMAGE CTL_CODE( \
164  IOCTL_DISK_BASE, \
165  0x802, \
166  METHOD_BUFFERED, \
167  FILE_READ_ACCESS)
168 
169 /*
170  IOCTL_VFD_SET_LINK
171 
172  Create or delete a persistent drive letter
173  On Windows NT, this command simply creates a symbolic link.
174  On Windows 2000/XP, the driver calls the Mount Manager to manipulate
175  a drive letter.
176 
177  Input:
178  buffer containing a drive letter 'A' - 'Z' to create a drive letter,
179  or 0 to delete the current drive letter.
180 
181  Input Length:
182  sizeof(CHAR) or larger
183 
184  Output:
185  Not used with this operation; set to NULL.
186 
187  Output Length:
188  Not used with this operation; set to zero.
189 
190  Return:
191  STATUS_INVALID_PARAMETER input length == 0 or
192  any other parameter errors
193 */
194 #define IOCTL_VFD_SET_LINK CTL_CODE( \
195  IOCTL_DISK_BASE, \
196  0x803, \
197  METHOD_BUFFERED, \
198  FILE_READ_ACCESS | FILE_WRITE_ACCESS)
199 
200 /*
201  IOCTL_VFD_QUERY_LINK
202 
203  Get the current persistent drive letter
204 
205  Input:
206  Not used with this operation; set to NULL.
207 
208  Input Length:
209  Not used with this operation; set to zero.
210 
211  Output:
212  buffer to receive the current drive letter.
213  0 is returned if there is none.
214 
215  Output Length:
216  sizeof(CHAR) or larger
217 
218  Return:
219  STATUS_BUFFER_TOO_SMALL buffer length < sizeof(CHAR)
220 */
221 #define IOCTL_VFD_QUERY_LINK CTL_CODE( \
222  IOCTL_DISK_BASE, \
223  0x804, \
224  METHOD_BUFFERED, \
225  FILE_READ_ACCESS)
226 
227 /*
228  IOCTL_VFD_SET_PROTECT
229 
230  Enable the virtual media write protection
231 
232  Input:
233  Not used with this operation; set to NULL.
234 
235  Input Length:
236  Not used with this operation; set to zero.
237 
238  Output:
239  Not used with this operation; set to NULL.
240 
241  Output Length:
242  Not used with this operation; set to zero.
243 
244  Return:
245  STATUS_NO_MEDIA_IN_DEVICE image is not opened
246 */
247 #define IOCTL_VFD_SET_PROTECT CTL_CODE( \
248  IOCTL_DISK_BASE, \
249  0x805, \
250  METHOD_NEITHER, \
251  FILE_READ_ACCESS | FILE_WRITE_ACCESS)
252 
253 /*
254  IOCTL_VFD_CLEAR_PROTECT
255 
256  Disable the virtual media write protection
257 
258  Input:
259  Not used with this operation; set to NULL.
260 
261  Input Length:
262  Not used with this operation; set to zero.
263 
264  Output:
265  Not used with this operation; set to NULL.
266 
267  Output Length:
268  Not used with this operation; set to zero.
269 
270  Return:
271  STATUS_NO_MEDIA_IN_DEVICE image is not opened
272 */
273 #define IOCTL_VFD_CLEAR_PROTECT CTL_CODE( \
274  IOCTL_DISK_BASE, \
275  0x806, \
276  METHOD_NEITHER, \
277  FILE_READ_ACCESS | FILE_WRITE_ACCESS)
278 
279 /*
280  IOCTL_VFD_RESET_MODIFY
281 
282  Reset the data modify flag
283 
284  Input:
285  Not used with this operation; set to NULL.
286 
287  Input Length:
288  Not used with this operation; set to zero.
289 
290  Output:
291  Not used with this operation; set to NULL.
292 
293  Output Length:
294  Not used with this operation; set to zero.
295 
296  Return:
297  STATUS_NO_MEDIA_IN_DEVICE image is not opened
298 */
299 #define IOCTL_VFD_RESET_MODIFY CTL_CODE( \
300  IOCTL_DISK_BASE, \
301  0x807, \
302  METHOD_NEITHER, \
303  FILE_READ_ACCESS | FILE_WRITE_ACCESS)
304 
305 /*
306  IOCTL_VFD_QUERY_NUMBER
307 
308  Get the current device's VFD device number (<n> in "\??\VirtualFD<n>")
309 
310  Input:
311  Not used with this operation; set to NULL.
312 
313  Input Length:
314  Not used with this operation; set to zero.
315 
316  Output:
317  buffer to receive the VFD device number
318 
319  Output Length:
320  sizeof(ULONG) or larger
321 
322  Return:
323  STATUS_BUFFER_TOO_SMALL buffer length < sizeof(ULONG)
324 */
325 #define IOCTL_VFD_QUERY_NUMBER CTL_CODE( \
326  IOCTL_DISK_BASE, \
327  0x80d, \
328  METHOD_BUFFERED, \
329  FILE_READ_ACCESS)
330 
331 /*
332  IOCTL_VFD_QUERY_NAME
333 
334  Get the current device's name (\Device\Floppy<n>)
335  The name is returned in a counted UNICODE string (not NULL terminated)
336 
337  Input:
338  Not used with this operation; set to NULL.
339 
340  Input Length:
341  Not used with this operation; set to zero.
342 
343  Output:
344  buffer to receive the length (USHORT value, number of bytes) followed
345  by the UNICODE device name.
346 
347  Output Length:
348  enough to receive the length and the name
349 
350  Return:
351  STATUS_BUFFER_TOO_SMALL buffer length < sizeof(USHORT)
352  STATUS_BUFFER_OVERFLOW buffer cannot hold the device name.
353  The first sizeof(USHORT) bytes of the
354  buffer contains the device name length.
355  See this value to decide the necessary
356  buffer length.
357 */
358 #define IOCTL_VFD_QUERY_NAME CTL_CODE( \
359  IOCTL_DISK_BASE, \
360  0x80e, \
361  METHOD_BUFFERED, \
362  FILE_READ_ACCESS)
363 
364 /*
365  IOCTL_VFD_QUERY_VERSION
366 
367  Get the running VFD driver version
368 
369  Input:
370  Not used with this operation; set to NULL.
371 
372  Input Length:
373  Not used with this operation; set to zero.
374 
375  Output:
376  buffer to receive the VFD version (ULONG value)
377  High word: major version
378  Low word: minor version
379  MSB: debug version flag (1:debug 0:release)
380 
381  Output Length:
382  sizeof(ULONG) or larger
383 
384  Return:
385  STATUS_BUFFER_TOO_SMALL buffer length < sizeof(ULONG)
386 */
387 #define IOCTL_VFD_QUERY_VERSION CTL_CODE( \
388  IOCTL_DISK_BASE, \
389  0x80f, \
390  METHOD_BUFFERED, \
391  FILE_READ_ACCESS)
392 
393 #endif // _VFDIO_H_
VFD_DISKTYPE DiskType
Definition: vfdio.h:64
UCHAR VFD_DISKTYPE
Definition: vfdtypes.h:60
VFD_FLAGS MediaFlags
Definition: vfdio.h:66
char CHAR
Definition: xmlstorage.h:175
VFD_FILETYPE FileType
Definition: vfdio.h:67
struct _VFD_IMAGE_INFO VFD_IMAGE_INFO
ULONG ImageSize
Definition: vfdio.h:68
UCHAR VFD_FLAGS
Definition: vfdtypes.h:63
VFD_MEDIA MediaType
Definition: vfdio.h:65
struct _VFD_IMAGE_INFO * PVFD_IMAGE_INFO
UCHAR VFD_FILETYPE
Definition: vfdtypes.h:62
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
USHORT NameLength
Definition: vfdio.h:69
UCHAR VFD_MEDIA
Definition: vfdtypes.h:61