xref: /reactos/modules/rosapps/drivers/vfd/vfddrv.h (revision ba3f0743)
1 /*
2 	vfddrv.h
3 
4 	Virtual Floppy Drive for Windows NT platform
5 	Kernel mode driver: local header
6 
7 	Copyright(C) 2003-2005 Ken Kato
8 */
9 
10 #ifndef _VFDDRV_H_
11 #define _VFDDRV_H_
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #pragma message("Compiled as C++ for testing purpose.")
16 #endif	// __cplusplus
17 
18 #include "vfdtypes.h"
19 #include "vfdio.h"
20 #include "vfdver.h"
21 
22 //
23 //	Tag used for ExAllocatePoolWithTag
24 //
25 #define VFD_POOL_TAG			'DFVx'
26 
27 //
28 //	PnP driver specific stuff
29 //
30 #ifdef	VFD_PNP
31 
32 #if	(VER_PRODUCTBUILD < 2195)
33 #error Cannot build a PnP version with the Windows NT DDK
34 #endif	//	(VER_PRODUCTBUILD < 2195)
35 
36 //
37 //	device state enumeration
38 //
39 typedef enum  _DEVICE_STATE
40 {
41 	VFD_STOPPED,				// Dvice stopped
42 	VFD_WORKING,				// Started and working
43 	VFD_PENDINGSTOP,			// Stop pending
44 	VFD_PENDINGREMOVE,			// Remove pending
45 	VFD_SURPRISEREMOVED,		// Surprise removed
46 	VFD_REMOVED,				// Removed
47 	VFD_MAX_STATE				// Unknown state -Some error
48 }
49 DEVICE_STATE, *PDEVICE_STATE;
50 
51 //
52 //	use the address of the DriverEntry functions as the
53 //	driver extension identifier
54 //
55 #define VFD_DRIVER_EXTENSION_ID	((PVOID)DriverEntry)
56 
57 #endif	// VFD_PNP
58 
59 //
60 //	driver extension for the VFD driver
61 //
62 typedef struct _VFD_DRIVER_EXTENSION
63 {
64 	UNICODE_STRING				RegistryPath;
65 	ULONG						NumberOfDevices;
66 }
67 VFD_DRIVER_EXTENSION, *PVFD_DRIVER_EXTENSION;
68 
69 //
70 //	device extension for Virtual FD device
71 //
72 typedef struct _DEVICE_EXTENSION
73 {
74 	//	back pointer to the device object
75 	PDEVICE_OBJECT				DeviceObject;
76 
77 	//	device information
78 	UNICODE_STRING				DeviceName;		// \Device\Floppy<n>
79 	ULONG						DeviceNumber;	// \??\VirtualFD<n>
80 	CHAR						DriveLetter;	// \DosDevices\<x>:
81 
82 	//	Security context to access files on network drive
83 	PSECURITY_CLIENT_CONTEXT	SecurityContext;
84 
85 	//	IRP queue list
86 	LIST_ENTRY					ListHead;
87 	KSPIN_LOCK					ListLock;
88 
89 	//	device thread
90 	KEVENT						RequestEvent;
91 	PVOID						ThreadPointer;
92 	BOOLEAN						TerminateThread;
93 
94 	//	drive information
95 	ULONG						MediaChangeCount;
96 
97 	//	media information
98 	VFD_MEDIA					MediaType;
99 	VFD_FLAGS					MediaFlags;
100 	VFD_FILETYPE				FileType;
101 	ULONG						ImageSize;
102 	ANSI_STRING					FileName;
103 
104 	const DISK_GEOMETRY			*Geometry;
105 	ULONG						Sectors;
106 
107 	HANDLE						FileHandle;
108 	PUCHAR						FileBuffer;
109 
110 #ifdef VFD_PNP
111 	DEVICE_STATE				DeviceState;		// Current device state
112 	IO_REMOVE_LOCK				RemoveLock;			// avoid abnormal removal
113 	PDEVICE_OBJECT				PhysicalDevice;
114 	PDEVICE_OBJECT				TargetDevice;
115 	UNICODE_STRING				InterfaceName;
116 #else	// VFD_PNP
117 	PVFD_DRIVER_EXTENSION		DriverExtension;
118 #endif	// VFD_PNP
119 }
120 DEVICE_EXTENSION, *PDEVICE_EXTENSION;
121 
122 //
123 //	Stanard driver routines
124 //
125 NTSTATUS
126 NTAPI
127 DriverEntry(
128 	IN	PDRIVER_OBJECT			DriverObject,
129 	IN	PUNICODE_STRING			RegistryPath);
130 
131 VOID
132 NTAPI
133 VfdUnloadDriver(
134 	IN	PDRIVER_OBJECT			DriverObject);
135 
136 NTSTATUS
137 NTAPI
138 VfdCreateClose(
139 	IN	PDEVICE_OBJECT			DeviceObject,
140 	IN	PIRP					Irp);
141 
142 NTSTATUS
143 NTAPI
144 VfdReadWrite(
145 	IN	PDEVICE_OBJECT			DeviceObject,
146 	IN	PIRP					Irp);
147 
148 NTSTATUS
149 NTAPI
150 VfdDeviceControl(
151 	IN	PDEVICE_OBJECT			DeviceObject,
152 	IN	PIRP					Irp);
153 
154 #ifdef VFD_PNP
155 
156 NTSTATUS
157 NTAPI
158 VfdPlugAndPlay(
159 	IN	PDEVICE_OBJECT			DeviceObject,
160 	IN	PIRP					Irp);
161 
162 NTSTATUS
163 NTAPI
164 VfdPowerControl(
165 	IN	PDEVICE_OBJECT			DeviceObject,
166 	IN	PIRP					Irp);
167 
168 NTSTATUS
169 NTAPI
170 VfdSystemControl(
171 	IN	PDEVICE_OBJECT			DeviceObject,
172 	IN	PIRP					Irp);
173 
174 NTSTATUS
175 NTAPI
176 VfdAddDevice(
177 	IN		PDRIVER_OBJECT		DriverObject,
178 	IN OUT	PDEVICE_OBJECT		PhysicalDevice);
179 
180 #endif	// VFD_PNP
181 
182 //
183 //	Prototypes for private routines
184 //
185 
186 //
187 //	vfddrv.c
188 //
189 extern ULONG OsMajorVersion;
190 extern ULONG OsMinorVersion;
191 extern ULONG OsBuildNumber;
192 
193 VOID
194 NTAPI
195 VfdDeviceThread(
196 	IN	PVOID					ThreadContext);
197 
198 PWSTR
199 VfdCopyUnicode(
200 	OUT	PUNICODE_STRING			dst,
201 	IN	PUNICODE_STRING			src);
202 
203 VOID
204 VfdFreeUnicode(
205 	IN OUT	PUNICODE_STRING		str);
206 
207 //
208 //	vfddev.c
209 //
210 NTSTATUS
211 VfdCreateDevice(
212 	IN	PDRIVER_OBJECT			DriverObject,
213 	OUT	PVOID					Parameter);
214 
215 VOID
216 VfdDeleteDevice(
217 	IN	PDEVICE_OBJECT			DeviceObject);
218 
219 //
220 //	vfdioctl.c
221 //
222 VOID
223 VfdIoCtlThread(
224 	IN	PDEVICE_EXTENSION		DeviceExtension,
225 	IN	PIRP					Irp,
226 	IN	ULONG					ControlCode);
227 
228 //
229 //	vfdimg.c
230 //
231 NTSTATUS
232 VfdOpenCheck(
233 	IN	PDEVICE_EXTENSION		DeviceExtension,
234 	IN	PVFD_IMAGE_INFO			ImageInfo,
235 	IN	ULONG					InputLength);
236 
237 NTSTATUS
238 VfdOpenImage(
239 	IN	PDEVICE_EXTENSION		DeviceExtension,
240 	IN	PVFD_IMAGE_INFO			ImageInfo);
241 
242 VOID
243 VfdCloseImage(
244 	IN	PDEVICE_EXTENSION		DeviceExtension);
245 
246 NTSTATUS
247 VfdQueryImage(
248 	IN	PDEVICE_EXTENSION		DeviceExtension,
249 	OUT	PVFD_IMAGE_INFO			ImageInfo,
250 	IN	ULONG					BufferLength,
251 	OUT	PULONG					ReturnLength);
252 
253 //
254 //	vfdrdwr.c
255 //
256 VOID
257 VfdReadData(
258 	IN		PDEVICE_EXTENSION	DeviceExtension,
259 	IN OUT	PIRP				Irp,
260 	IN		ULONG				Length,
261 	IN		PLARGE_INTEGER		Offset);
262 
263 VOID
264 VfdWriteData(
265 	IN		PDEVICE_EXTENSION	DeviceExtension,
266 	IN OUT	PIRP				Irp,
267 	IN		ULONG				Length,
268 	IN		PLARGE_INTEGER		Offset);
269 
270 //
271 //	vfdlink.c
272 //
273 NTSTATUS
274 VfdSetLink(
275 	IN	PDEVICE_EXTENSION		DeviceExtension,
276 	IN	CHAR					DriveLetter);
277 
278 NTSTATUS
279 VfdStoreLink(
280 	IN	PDEVICE_EXTENSION		DeviceExtension);
281 
282 NTSTATUS
283 VfdLoadLink(
284 	IN	PDEVICE_EXTENSION		DeviceExtension,
285 	IN	PWSTR					RegistryPath);
286 
287 //
288 //	vfdfmt.c
289 //
290 extern const DISK_GEOMETRY geom_tbl[VFD_MEDIA_MAX];
291 
292 NTSTATUS
293 VfdFormatCheck(
294 	IN	PDEVICE_EXTENSION		DeviceExtension,
295 	IN	PFORMAT_PARAMETERS		FormatParams,
296 	IN	ULONG					InputLength,
297 	IN	ULONG					ControlCode);
298 
299 NTSTATUS
300 VfdFormatTrack(
301 	IN	PDEVICE_EXTENSION		DeviceExtension,
302 	IN	PFORMAT_PARAMETERS		FormatParams);
303 
304 //
305 //	vfdmnt.c
306 //
307 #ifdef VFD_MOUNT_MANAGER
308 /*
309 NTSTATUS
310 VfdRegisterMountManager(
311 	IN	PDEVICE_EXTENSION		DeviceExtension);
312 */
313 
314 NTSTATUS
315 VfdMountMgrNotifyVolume(
316 	IN	PDEVICE_EXTENSION		DeviceExtension);
317 
318 NTSTATUS
319 VfdMountMgrMountPoint(
320 	IN	PDEVICE_EXTENSION		DeviceExtension,
321 	IN	CHAR					DriveLetter);
322 
323 NTSTATUS
324 VfdMountDevUniqueId(
325 	IN	PDEVICE_EXTENSION		DeviceExtension,
326 	OUT	PMOUNTDEV_UNIQUE_ID		UniqueId,
327 	IN	ULONG					OutputLength,
328 	OUT	PIO_STATUS_BLOCK		IoStatus);
329 
330 NTSTATUS
331 VfdMountDevDeviceName(
332 	IN	PDEVICE_EXTENSION		DeviceExtension,
333 	OUT	PMOUNTDEV_NAME			DeviceName,
334 	IN	ULONG					OutputLength,
335 	OUT	PIO_STATUS_BLOCK		IoStatus);
336 
337 NTSTATUS
338 VfdMountDevSuggestedLink(
339 	IN	PDEVICE_EXTENSION		DeviceExtension,
340 	OUT	PMOUNTDEV_SUGGESTED_LINK_NAME	LinkName,
341 	IN	ULONG					OutputLength,
342 	OUT	PIO_STATUS_BLOCK		IoStatus);
343 
344 NTSTATUS
345 VfdMountDevLinkModified(
346 	IN	PDEVICE_EXTENSION		DeviceExtension,
347 	IN	PMOUNTDEV_NAME			LinkName,
348 	IN	ULONG					InputLength,
349 	IN	ULONG					ControlCode);
350 
351 #endif	//	VFD_MOUNT_MANAGER
352 
353 #ifdef __cplusplus
354 }
355 #endif	// __cplusplus
356 
357 #endif	// _VFDDRV_H_
358