xref: /reactos/modules/rosapps/drivers/vfd/vfddrv.h (revision 6b1ca758)
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 #ifndef __REACTOS__
252 	OUT	PULONG					ReturnLength);
253 #else
254 	OUT	PSIZE_T					ReturnLength);
255 #endif
256 
257 //
258 //	vfdrdwr.c
259 //
260 VOID
261 VfdReadData(
262 	IN		PDEVICE_EXTENSION	DeviceExtension,
263 	IN OUT	PIRP				Irp,
264 	IN		ULONG				Length,
265 	IN		PLARGE_INTEGER		Offset);
266 
267 VOID
268 VfdWriteData(
269 	IN		PDEVICE_EXTENSION	DeviceExtension,
270 	IN OUT	PIRP				Irp,
271 	IN		ULONG				Length,
272 	IN		PLARGE_INTEGER		Offset);
273 
274 //
275 //	vfdlink.c
276 //
277 NTSTATUS
278 VfdSetLink(
279 	IN	PDEVICE_EXTENSION		DeviceExtension,
280 	IN	CHAR					DriveLetter);
281 
282 NTSTATUS
283 VfdStoreLink(
284 	IN	PDEVICE_EXTENSION		DeviceExtension);
285 
286 NTSTATUS
287 VfdLoadLink(
288 	IN	PDEVICE_EXTENSION		DeviceExtension,
289 	IN	PWSTR					RegistryPath);
290 
291 //
292 //	vfdfmt.c
293 //
294 extern const DISK_GEOMETRY geom_tbl[VFD_MEDIA_MAX];
295 
296 NTSTATUS
297 VfdFormatCheck(
298 	IN	PDEVICE_EXTENSION		DeviceExtension,
299 	IN	PFORMAT_PARAMETERS		FormatParams,
300 	IN	ULONG					InputLength,
301 	IN	ULONG					ControlCode);
302 
303 NTSTATUS
304 VfdFormatTrack(
305 	IN	PDEVICE_EXTENSION		DeviceExtension,
306 	IN	PFORMAT_PARAMETERS		FormatParams);
307 
308 //
309 //	vfdmnt.c
310 //
311 #ifdef VFD_MOUNT_MANAGER
312 /*
313 NTSTATUS
314 VfdRegisterMountManager(
315 	IN	PDEVICE_EXTENSION		DeviceExtension);
316 */
317 
318 NTSTATUS
319 VfdMountMgrNotifyVolume(
320 	IN	PDEVICE_EXTENSION		DeviceExtension);
321 
322 NTSTATUS
323 VfdMountMgrMountPoint(
324 	IN	PDEVICE_EXTENSION		DeviceExtension,
325 	IN	CHAR					DriveLetter);
326 
327 NTSTATUS
328 VfdMountDevUniqueId(
329 	IN	PDEVICE_EXTENSION		DeviceExtension,
330 	OUT	PMOUNTDEV_UNIQUE_ID		UniqueId,
331 	IN	ULONG					OutputLength,
332 	OUT	PIO_STATUS_BLOCK		IoStatus);
333 
334 NTSTATUS
335 VfdMountDevDeviceName(
336 	IN	PDEVICE_EXTENSION		DeviceExtension,
337 	OUT	PMOUNTDEV_NAME			DeviceName,
338 	IN	ULONG					OutputLength,
339 	OUT	PIO_STATUS_BLOCK		IoStatus);
340 
341 NTSTATUS
342 VfdMountDevSuggestedLink(
343 	IN	PDEVICE_EXTENSION		DeviceExtension,
344 	OUT	PMOUNTDEV_SUGGESTED_LINK_NAME	LinkName,
345 	IN	ULONG					OutputLength,
346 	OUT	PIO_STATUS_BLOCK		IoStatus);
347 
348 NTSTATUS
349 VfdMountDevLinkModified(
350 	IN	PDEVICE_EXTENSION		DeviceExtension,
351 	IN	PMOUNTDEV_NAME			LinkName,
352 	IN	ULONG					InputLength,
353 	IN	ULONG					ControlCode);
354 
355 #endif	//	VFD_MOUNT_MANAGER
356 
357 #ifdef __cplusplus
358 }
359 #endif	// __cplusplus
360 
361 #endif	// _VFDDRV_H_
362