ReactOS  0.4.15-dev-2704-gd5265b0
ioctl.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BOOLEAN RequestDispatchProcessDirectly (_In_ WDFDEVICE Device, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters)
 
BOOLEAN RequestDispatchToSequentialQueue (_In_ WDFDEVICE Device, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters)
 
BOOLEAN RequestDispatchSyncWithSequentialQueue (_In_ WDFDEVICE Device, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters)
 
BOOLEAN RequestDispatchSpecialIoctls (_In_ WDFDEVICE Device, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters)
 
BOOLEAN RequestDispatchUnknownRequests (_In_ WDFDEVICE Device, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters)
 
NTSTATUS RequestHandleGetInquiryData (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestHandleGetMediaTypeEx (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _Out_ size_t *DataLength)
 
NTSTATUS RequestHandleMountQueryUniqueId (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestHandleMountQueryDeviceName (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestHandleMountQuerySuggestedLinkName (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestHandleGetDeviceNumber (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestHandleGetHotPlugInfo (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestHandleSetHotPlugInfo (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
 _IRQL_requires_max_ (APC_LEVEL) NTSTATUS RequestHandleEventNotification(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension
 
NTSTATUS RequestHandleQueryPropertyRetrieveCachedData (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
 _IRQL_requires_max_ (PASSIVE_LEVEL) NTSTATUS RequestHandleGetDriveGeometry(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension
 
NTSTATUS RequestHandleUnknownIoctl (_In_ WDFDEVICE Device, _In_ WDFREQUEST Request)
 
NTSTATUS RequestHandleQueryPropertyDeviceUniqueId (_In_ WDFDEVICE Device, _In_ WDFREQUEST Request)
 
NTSTATUS RequestHandleQueryPropertyWriteCache (_In_ WDFDEVICE Device, _In_ WDFREQUEST Request)
 
NTSTATUS RequestHandleReadWrite (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters)
 
NTSTATUS RequestValidateRawRead (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateReadTocEx (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateReadToc (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateGetLastSession (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateReadQChannel (_In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateDvdReadStructure (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateDvdStartSession (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateDvdSendKey (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateDvdReadKey (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateGetConfiguration (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateSetSpeed (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateAacsReadMediaKeyBlock (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateAacsStartSession (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateAacsSendCertificate (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateAacsGetCertificate (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateAacsGetChallengeKey (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateAacsSendChallengeKey (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateAacsReadVolumeId (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateAacsReadSerialNumber (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateAacsReadMediaId (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateAacsBindingNonce (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateExclusiveAccess (_In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateEnableStreaming (_In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateSendOpcInformation (_In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateGetPerformance (_In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
BOOLEAN RequestIsRealtimeStreaming (_In_ WDFREQUEST Request, _In_ BOOLEAN IsReadRequest)
 
NTSTATUS RequestValidateReadWrite (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters)
 
NTSTATUS RequestValidatePersistentReserve (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateDvdEndSession (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestValidateAacsEndSession (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 

Variables

_In_opt_ WDFREQUEST Request
 
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
 
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS _Out_ size_tDataLength
 

Function Documentation

◆ _IRQL_requires_max_() [1/2]

_IRQL_requires_max_ ( APC_LEVEL  )

Definition at line 197 of file cddata.c.

254 {
255  THREAD_CONTEXT ThreadContext = {0};
256  PIRP_CONTEXT IrpContext = NULL;
257  BOOLEAN Wait;
258 
259 #ifdef CD_SANITY
260  PVOID PreviousTopLevel;
261 #endif
262 
264 
265 #if DBG
266 
267  KIRQL SaveIrql = KeGetCurrentIrql();
268 
269 #endif
270 
272 
274 
276 
277 #ifdef CD_SANITY
278  PreviousTopLevel = IoGetTopLevelIrp();
279 #endif
280 
281  //
282  // Loop until this request has been completed or posted.
283  //
284 
285  do {
286 
287  //
288  // Use a try-except to handle the exception cases.
289  //
290 
291  _SEH2_TRY {
292 
293  //
294  // If the IrpContext is NULL then this is the first pass through
295  // this loop.
296  //
297 
298  if (IrpContext == NULL) {
299 
300  //
301  // Decide if this request is waitable an allocate the IrpContext.
302  // If the file object in the stack location is NULL then this
303  // is a mount which is always waitable. Otherwise we look at
304  // the file object flags.
305  //
306 
308 
309  Wait = TRUE;
310 
311  } else {
312 
313  Wait = CanFsdWait( Irp );
314  }
315 
316  IrpContext = CdCreateIrpContext( Irp, Wait );
317 
318  //
319  // Update the thread context information.
320  //
321 
322  CdSetThreadContext( IrpContext, &ThreadContext );
323 
324 #ifdef CD_SANITY
325  NT_ASSERT( !CdTestTopLevel ||
326  SafeNodeType( IrpContext->TopLevel ) == CDFS_NTC_IRP_CONTEXT );
327 #endif
328 
329  //
330  // Otherwise cleanup the IrpContext for the retry.
331  //
332 
333  } else {
334 
335  //
336  // Set the MORE_PROCESSING flag to make sure the IrpContext
337  // isn't inadvertently deleted here. Then cleanup the
338  // IrpContext to perform the retry.
339  //
340 
341  SetFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_MORE_PROCESSING );
342  CdCleanupIrpContext( IrpContext, FALSE );
343  }
344 
345  //
346  // Case on the major irp code.
347  //
348 
349  switch (IrpContext->MajorFunction) {
350 
351  case IRP_MJ_CREATE :
352 
353  Status = CdCommonCreate( IrpContext, Irp );
354  break;
355 
356  case IRP_MJ_CLOSE :
357 
358  Status = CdCommonClose( IrpContext, Irp );
359  break;
360 
361  case IRP_MJ_READ :
362 
363  //
364  // If this is an Mdl complete request, don't go through
365  // common read.
366  //
367 
368  if (FlagOn( IrpContext->MinorFunction, IRP_MN_COMPLETE )) {
369 
370  Status = CdCompleteMdl( IrpContext, Irp );
371 
372  } else {
373 
374  Status = CdCommonRead( IrpContext, Irp );
375  }
376 
377  break;
378 
379  case IRP_MJ_WRITE :
380 
381  Status = CdCommonWrite( IrpContext, Irp );
382  break;
383 
385 
386  Status = CdCommonQueryInfo( IrpContext, Irp );
387  break;
388 
390 
391  Status = CdCommonSetInfo( IrpContext, Irp );
392  break;
393 
395 
396  Status = CdCommonQueryVolInfo( IrpContext, Irp );
397  break;
398 
400 
401  Status = CdCommonDirControl( IrpContext, Irp );
402  break;
403 
405 
406  Status = CdCommonFsControl( IrpContext, Irp );
407  break;
408 
409  case IRP_MJ_DEVICE_CONTROL :
410 
411  Status = CdCommonDevControl( IrpContext, Irp );
412  break;
413 
414  case IRP_MJ_LOCK_CONTROL :
415 
416  Status = CdCommonLockControl( IrpContext, Irp );
417  break;
418 
419  case IRP_MJ_CLEANUP :
420 
421  Status = CdCommonCleanup( IrpContext, Irp );
422  break;
423 
424  case IRP_MJ_PNP :
425 
426  Status = CdCommonPnp( IrpContext, Irp );
427  break;
428 
429  case IRP_MJ_SHUTDOWN :
430 
431  Status = CdCommonShutdown( IrpContext, Irp );
432  break;
433 
434  default :
435 
437  CdCompleteRequest( IrpContext, Irp, Status );
438  }
439 
441 
442  Status = CdProcessException( IrpContext, Irp, _SEH2_GetExceptionCode() );
443  } _SEH2_END;
444 
445  } while (Status == STATUS_CANT_WAIT);
446 
447 #ifdef CD_SANITY
448  NT_ASSERT( !CdTestTopLevel ||
449  (PreviousTopLevel == IoGetTopLevelIrp()) );
450 #endif
451 
453 
454  NT_ASSERT( SaveIrql == KeGetCurrentIrql( ));
455 
456  return Status;
457 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
VOID CdSetThreadContext(_Inout_ PIRP_CONTEXT IrpContext, _In_ PTHREAD_CONTEXT ThreadContext)
Definition: cddata.c:981
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define IRP_MJ_SHUTDOWN
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define IRP_CONTEXT_FLAG_MORE_PROCESSING
Definition: cdstruc.h:1214
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
#define SafeNodeType(Ptr)
Definition: nodetype.h:54
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_SEH2_TRY
Definition: create.c:4226
#define IRP_MN_COMPLETE
Definition: iotypes.h:4420
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
VOID CdCompleteRequest(_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
Definition: cddata.c:914
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:164
unsigned char BOOLEAN
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
Status
Definition: gdiplustypes.h:24
#define IRP_MJ_FILE_SYSTEM_CONTROL
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
#define CanFsdWait(I)
Definition: cdprocs.h:2001
NTSTATUS CdCompleteMdl(_In_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: cachesup.c:411
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
NTSTATUS CdCommonDevControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: devctrl.c:46
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4400
LONG CdExceptionFilter(_Inout_ PIRP_CONTEXT IrpContext, _In_ PEXCEPTION_POINTERS ExceptionPointer)
Definition: cddata.c:525
#define ASSERT_OPTIONAL_IRP(I)
Definition: cddata.h:251
#define NULL
Definition: types.h:112
VOID CdCleanupIrpContext(_In_ PIRP_CONTEXT IrpContext, _In_ BOOLEAN Post)
Definition: strucsup.c:1733
NTSTATUS CdCommonLockControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: lockctrl.c:35
#define CDFS_NTC_IRP_CONTEXT
Definition: nodetype.h:34
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_CLEANUP
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
_Ret_valid_ PIRP_CONTEXT CdCreateIrpContext(_In_ PIRP Irp, _In_ BOOLEAN Wait)
Definition: strucsup.c:1573
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define STATUS_CANT_WAIT
Definition: ntstatus.h:452
#define NT_ASSERT
Definition: rtlfuncs.h:3312

◆ _IRQL_requires_max_() [2/2]

_IRQL_requires_max_ ( PASSIVE_LEVEL  )

Definition at line 64 of file Messaging.c.

75 {
76  PFLT_SERVER_PORT_OBJECT PortObject;
78 
79  /* The caller must allow at least one connection */
80  if (MaxConnections == 0)
81  {
83  }
84 
85  /* The request must be for a kernel handle */
86  if (!(ObjectAttributes->Attributes & OBJ_KERNEL_HANDLE))
87  {
89  }
90 
91  /*
92  * Get rundown protection on the target to stop the owner
93  * from unloading whilst this port object is open. It gets
94  * removed in the FltpServerPortClose callback
95  */
97  if (!NT_SUCCESS(Status))
98  {
99  return Status;
100  }
101 
102  /* Create the server port object for this filter */
106  KernelMode,
107  NULL,
108  sizeof(FLT_SERVER_PORT_OBJECT),
109  0,
110  0,
111  (PVOID *)&PortObject);
112  if (NT_SUCCESS(Status))
113  {
114  /* Zero out the struct */
115  RtlZeroMemory(PortObject, sizeof(FLT_SERVER_PORT_OBJECT));
116 
117  /* Increment the ref count on the target filter */
119 
120  /* Setup the filter port object */
121  PortObject->Filter = Filter;
122  PortObject->ConnectNotify = ConnectNotifyCallback;
124  PortObject->MessageNotify = MessageNotifyCallback;
125  PortObject->Cookie = ServerPortCookie;
126  PortObject->MaxConnections = MaxConnections;
127 
128  /* Insert the object */
129  Status = ObInsertObject(PortObject,
130  NULL,
132  0,
133  NULL,
135  if (NT_SUCCESS(Status))
136  {
137  /* Lock the connection list */
139 
140  /* Add the new port object to the connection list and increment the count */
143 
144  /* Unlock the connection list*/
146  }
147  }
148 
149  if (!NT_SUCCESS(Status))
150  {
151  /* Allow the filter to be cleaned up */
153  }
154 
155  return Status;
156 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _Outptr_ PFLT_PORT * ServerPort
Definition: fltkernel.h:1873
PFLT_CONNECT_NOTIFY ConnectNotify
Definition: fltmgrint.h:191
VOID FLTAPI FltObjectDereference(_Inout_ PVOID Object)
Definition: Object.c:53
LONG NTSTATUS
Definition: precomp.h:26
#define InsertTailList(ListHead, Entry)
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
ULONG FltpObjectPointerReference(_In_ PFLT_OBJECT Object)
Definition: Object.c:322
LIST_ENTRY mList
Definition: fltmgrint.h:56
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
#define FILE_READ_DATA
Definition: nt_native.h:628
NTSTATUS NTAPI ObCreateObject(IN KPROCESSOR_MODE ProbeMode OPTIONAL, IN POBJECT_TYPE Type, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext OPTIONAL, IN ULONG ObjectSize, IN ULONG PagedPoolCharge OPTIONAL, IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object)
Definition: oblife.c:952
Status
Definition: gdiplustypes.h:24
POBJECT_TYPE ServerPortObjectType
Definition: Messaging.c:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback
Definition: fltkernel.h:1873
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:454
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback
Definition: fltkernel.h:1873
NTSTATUS NTAPI ObInsertObject(IN PVOID Object, IN PACCESS_STATE AccessState OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG ObjectPointerBias, OUT PVOID *NewObject OPTIONAL, OUT PHANDLE Handle)
Definition: obhandle.c:2931
#define STANDARD_RIGHTS_ALL
Definition: nt_native.h:69
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
NTSTATUS FLTAPI FltObjectReference(_Inout_ PVOID Object)
Definition: Object.c:41
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID ServerPortCookie
Definition: fltkernel.h:1873
#define NULL
Definition: types.h:112
FAST_MUTEX mLock
Definition: fltmgrint.h:55
PFLT_MESSAGE_NOTIFY MessageNotify
Definition: fltmgrint.h:193
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY _In_opt_ PFLT_MESSAGE_NOTIFY _In_ LONG MaxConnections
Definition: fltkernel.h:1873
PFLT_DISCONNECT_NOTIFY DisconnectNotify
Definition: fltmgrint.h:192
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY _In_opt_ PFLT_MESSAGE_NOTIFY MessageNotifyCallback
Definition: fltkernel.h:1873
FLT_MUTEX_LIST_HEAD ConnectionList
Definition: fltmgrint.h:121

◆ RequestDispatchProcessDirectly()

BOOLEAN RequestDispatchProcessDirectly ( _In_ WDFDEVICE  Device,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters 
)

Definition at line 1694 of file cdrom.c.

1717 {
1720  size_t dataLength = 0;
1721 
1722  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(Device);
1723  ULONG ioctlCode = RequestParameters.Parameters.DeviceIoControl.IoControlCode;
1724 
1725  switch (ioctlCode)
1726  {
1727 
1729  {
1731 
1732  processed = TRUE;
1733  break; // complete the irp
1734  }
1735 
1737  {
1738  status = RequestHandleGetMediaTypeEx(deviceExtension, Request, &dataLength);
1739 
1740  processed = TRUE;
1741  break; // complete the irp
1742  }
1743 
1745  {
1747 
1748  processed = TRUE;
1749  break; // complete the irp
1750  }
1751 
1753  {
1755 
1756  processed = TRUE;
1757  break; // complete the irp
1758  }
1759 
1761  {
1763 
1764  processed = TRUE;
1765  break; // complete the irp
1766  }
1767 
1769  {
1771 
1772  processed = TRUE;
1773  break; // complete the irp
1774  }
1775 
1777  {
1779 
1780  processed = TRUE;
1781  break; // complete the irp
1782  }
1783 
1785  {
1787 
1788  processed = TRUE;
1789  break; // complete the irp
1790  }
1791 
1793  {
1794  status = RequestHandleEventNotification(deviceExtension, Request, &RequestParameters, &dataLength);
1795 
1796  processed = TRUE;
1797  break; // complete the irp
1798  }
1799 
1800 #if (NTDDI_VERSION >= NTDDI_WIN8)
1801  case IOCTL_VOLUME_ONLINE:
1802  {
1803  //
1804  // Mount manager and volume manager will
1805  // follow this online with a post online
1806  // but other callers may not. In those
1807  // cases, we process this request right
1808  // away. We approximate that these other
1809  // callers are from user mode
1810  //
1811 
1812  if (WdfRequestGetRequestorMode(Request) == KernelMode)
1813  {
1814  processed = TRUE;
1815  }
1816  break;
1817  }
1818 #endif
1819 
1820  default:
1821  {
1822  processed = FALSE;
1823  break;
1824  }
1825 
1826  } //end of switch (ioctlCode)
1827 
1828  if (processed)
1829  {
1830  UCHAR currentStackLocationFlags = 0;
1831  currentStackLocationFlags = RequestGetCurrentStackLocationFlags(Request);
1832 
1833  if ((status == STATUS_VERIFY_REQUIRED) &&
1834  (currentStackLocationFlags & SL_OVERRIDE_VERIFY_VOLUME))
1835  {
1836  // If the status is verified required and this request
1837  // should bypass verify required then retry the request.
1839  UNREFERENCED_PARAMETER(status); // disables prefast warning; defensive coding...
1840 
1842  }
1843  else
1844  {
1845  // Complete the request after processing it.
1846  RequestCompletion(deviceExtension, Request, status, dataLength);
1847  }
1848  }
1849 
1850  return processed;
1851 }
FORCEINLINE UCHAR RequestGetCurrentStackLocationFlags(_In_ WDFREQUEST Request)
Definition: cdrom.h:1554
#define IOCTL_STORAGE_SET_HOTPLUG_INFO
Definition: ntddstor.h:157
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_STORAGE_GET_HOTPLUG_INFO
Definition: imports.h:238
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
NTSTATUS RequestHandleMountQueryDeviceName(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:4015
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
#define IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
Definition: imports.h:93
VOID RequestCompletion(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ NTSTATUS Status, _In_ ULONG_PTR Information)
Definition: common.c:3439
#define IOCTL_MOUNTDEV_QUERY_UNIQUE_ID
Definition: imports.h:80
NTSTATUS RequestHandleGetMediaTypeEx(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _Out_ size_t *DataLength)
Definition: ioctl.c:336
#define FALSE
Definition: types.h:117
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
NTSTATUS RequestHandleMountQueryUniqueId(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:3939
BOOLEAN RequestDispatchProcessDirectly(_In_ WDFDEVICE Device, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters)
Definition: cdrom.c:1694
unsigned char BOOLEAN
#define IOCTL_VOLUME_ONLINE
Definition: ntddvol.h:62
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1823
#define IOCTL_STORAGE_GET_DEVICE_NUMBER
Definition: ntddstor.h:143
#define IOCTL_STORAGE_GET_MEDIA_TYPES_EX
Definition: cdrw_usr.h:190
ULONG dataLength
Definition: scsi.h:3751
unsigned char UCHAR
Definition: xmlstorage.h:181
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
NTSTATUS RequestHandleSetHotPlugInfo(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:5392
#define IOCTL_STORAGE_EVENT_NOTIFICATION
Definition: ntddstor.h:226
#define IOCTL_CDROM_GET_INQUIRY_DATA
Definition: ntddcdrm.h:91
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
#define IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME
Definition: imports.h:99
NTSTATUS RequestHandleGetDeviceNumber(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:5280
static int processed(const type_t *type)
Definition: typegen.c:2254
NTSTATUS RequestHandleGetInquiryData(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:270
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS RequestHandleGetHotPlugInfo(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:5337
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS RequestHandleMountQuerySuggestedLinkName(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:4088
Definition: ps.c:97

Referenced by DeviceEvtIoInCallerContext(), and RequestDispatchProcessDirectly().

◆ RequestDispatchSpecialIoctls()

BOOLEAN RequestDispatchSpecialIoctls ( _In_ WDFDEVICE  Device,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters 
)

Definition at line 2849 of file cdrom.c.

2872 {
2875  size_t dataLength = 0;
2876  BOOLEAN requestCompleted = FALSE;
2877 
2878  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(Device);
2879  PCDROM_DATA cdData = &(deviceExtension->DeviceAdditionalData);
2880  ULONG ioctlCode = RequestParameters.Parameters.DeviceIoControl.IoControlCode;
2881 
2882  switch (ioctlCode)
2883  {
2888  {
2889  // SPTI is considered special case as we need to set the MinorFunction before pass to low level.
2890 
2891 #if defined (_WIN64)
2892  if (WdfRequestIsFrom32BitProcess(Request))
2893  {
2894  if ((ioctlCode == IOCTL_SCSI_PASS_THROUGH) || (ioctlCode == IOCTL_SCSI_PASS_THROUGH_DIRECT))
2895  {
2896  if (RequestParameters.Parameters.DeviceIoControl.InputBufferLength < sizeof(SCSI_PASS_THROUGH32))
2897  {
2899  }
2900  }
2901  else
2902  {
2903  if (RequestParameters.Parameters.DeviceIoControl.InputBufferLength < sizeof(SCSI_PASS_THROUGH32_EX))
2904  {
2906  }
2907  }
2908  }
2909  else
2910 #endif
2911  {
2912  if ((ioctlCode == IOCTL_SCSI_PASS_THROUGH) || (ioctlCode == IOCTL_SCSI_PASS_THROUGH_DIRECT))
2913  {
2914  if (RequestParameters.Parameters.DeviceIoControl.InputBufferLength < sizeof(SCSI_PASS_THROUGH))
2915  {
2917  }
2918  }
2919  else
2920  {
2921  if (RequestParameters.Parameters.DeviceIoControl.InputBufferLength < sizeof(SCSI_PASS_THROUGH_EX))
2922  {
2924  }
2925  }
2926  }
2927 
2928  if (!NT_SUCCESS(status))
2929  {
2930  // validation failed.
2931  RequestCompletion(deviceExtension, Request, status, dataLength);
2932  }
2933  else
2934  {
2935  // keep the request in serialized manner and stay in user's context.
2936  status = RequestSetContextFields(Request, RequestHandleScsiPassThrough);
2937 
2938  if (NT_SUCCESS(status))
2939  {
2941  }
2942  else
2943  {
2944  RequestCompletion(deviceExtension, Request, status, 0);
2945  }
2946  }
2947 
2948  requestCompleted = TRUE;
2949  processed = TRUE;
2950  break;
2951  }
2952 
2954  {
2955  if (RequestParameters.Parameters.DeviceIoControl.InputBufferLength < sizeof(STORAGE_PROPERTY_QUERY))
2956  {
2958  }
2959  else
2960  {
2961  PSTORAGE_PROPERTY_QUERY inputBuffer = NULL;
2962 
2963  status = WdfRequestRetrieveInputBuffer(Request,
2964  RequestParameters.Parameters.DeviceIoControl.InputBufferLength,
2965  &inputBuffer,
2966  NULL);
2967 
2968  if (NT_SUCCESS(status))
2969  {
2970  if (!EXCLUSIVE_MODE(cdData) || // not locked
2971  EXCLUSIVE_OWNER(cdData, WdfRequestGetFileObject(Request)) || // request is from lock owner
2972  (inputBuffer->QueryType == PropertyExistsQuery)) // request not access device
2973  {
2974  if (inputBuffer->PropertyId == StorageDeviceUniqueIdProperty)
2975  {
2976  // previously handled in classpnp
2977  // keep the request in serialized manner and stay in user's context.
2979 
2980  if (NT_SUCCESS(status))
2981  {
2983  // remeber that the request has been completed.
2984  requestCompleted = TRUE;
2985  }
2986  }
2987  else if (inputBuffer->PropertyId == StorageDeviceWriteCacheProperty)
2988  {
2989  // previously handled in classpnp
2990  // keep the request in serialized manner and stay in user's context.
2992 
2993  if (NT_SUCCESS(status))
2994  {
2996  // remeber that the request has been completed.
2997  requestCompleted = TRUE;
2998  }
2999  }
3000  else
3001  {
3002  // Pass to port driver for handling
3004 
3005  // remeber that the request has been completed.
3006  requestCompleted = TRUE;
3007  }
3008  }
3009  else
3010  {
3011  // If cached data exists, return cached data. Otherwise, fail the request.
3012  if ((inputBuffer->QueryType == PropertyStandardQuery) &&
3013  ((inputBuffer->PropertyId == StorageDeviceProperty) || (inputBuffer->PropertyId == StorageAdapterProperty)) )
3014  {
3016  }
3017  else
3018  {
3020  }
3021  }
3022  }
3023  }
3024 
3025  processed = TRUE;
3026  break;
3027  }
3028 
3029  // this IOCTL is a fake one, used for MCN process sync-ed with serial queue.
3031  {
3032  PIRP irp = WdfRequestWdmGetIrp(Request);
3033 
3034  if ((deviceExtension->MediaChangeDetectionInfo != NULL) &&
3035  (irp == deviceExtension->MediaChangeDetectionInfo->MediaChangeSyncIrp) &&
3036  (WdfRequestGetRequestorMode(Request) == KernelMode) &&
3040  {
3041  // This is the requset we use to sync Media Change Detection with sequential queue.
3042  status = WdfDeviceEnqueueRequest(Device, Request);
3043 
3044  if (!NT_SUCCESS(status))
3045  {
3046  RequestCompletion(deviceExtension, Request, status, dataLength);
3047  }
3048 
3049  requestCompleted = TRUE;
3050  processed = TRUE;
3051  }
3052  else
3053  {
3054  // process as an unknown request.
3055  processed = FALSE;
3056  }
3057  break;
3058  }
3059 
3060  default:
3061  {
3062  processed = FALSE;
3063  break;
3064  }
3065  } //end of switch (ioctlCode)
3066 
3067  if (processed && !requestCompleted)
3068  {
3069  UCHAR currentStackLocationFlags = 0;
3070  currentStackLocationFlags = RequestGetCurrentStackLocationFlags(Request);
3071 
3072  if ((status == STATUS_VERIFY_REQUIRED) &&
3073  (currentStackLocationFlags & SL_OVERRIDE_VERIFY_VOLUME))
3074  {
3075  // If the status is verified required and this request
3076  // should bypass verify required then retry the request.
3078  UNREFERENCED_PARAMETER(status); // disables prefast warning; defensive coding...
3079 
3081  }
3082  else
3083  {
3084  RequestCompletion(deviceExtension, Request, status, dataLength);
3085  }
3086  }
3087 
3088  return processed;
3089 }
BOOLEAN RequestDispatchSpecialIoctls(_In_ WDFDEVICE Device, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters)
Definition: cdrom.c:2849
FORCEINLINE UCHAR RequestGetCurrentStackLocationFlags(_In_ WDFREQUEST Request)
Definition: cdrom.h:1554
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define IOCTL_SCSI_PASS_THROUGH_DIRECT_EX
Definition: ntddscsi.h:38
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
CDROM_DATA DeviceAdditionalData
Definition: cdrom.h:598
LONG NTSTATUS
Definition: precomp.h:26
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
NTSTATUS RequestSetContextFields(_In_ WDFREQUEST Request, _In_ PSYNC_HANDLER Handler)
Definition: common.c:2748
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
#define IOCTL_SCSI_PASS_THROUGH_EX
Definition: ntddscsi.h:37
VOID RequestCompletion(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ NTSTATUS Status, _In_ ULONG_PTR Information)
Definition: common.c:3439
#define FALSE
Definition: types.h:117
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
NTSTATUS RequestSynchronizeProcessWithSerialQueue(_In_ WDFDEVICE Device, _In_ WDFREQUEST Request)
Definition: cdrom.c:3893
unsigned char BOOLEAN
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1823
BOOLEAN RequestDispatchUnknownRequests(_In_ WDFDEVICE Device, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters)
Definition: cdrom.c:3093
VOID RequestSetupMcnSyncIrp(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension)
Definition: autorun.c:2749
#define IOCTL_STORAGE_QUERY_PROPERTY
Definition: ntddstor.h:178
NTSTATUS RequestHandleQueryPropertyDeviceUniqueId(_In_ WDFDEVICE Device, _In_ WDFREQUEST Request)
Definition: ioctl.c:2799
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG dataLength
Definition: scsi.h:3751
#define EXCLUSIVE_MODE(_CdData)
Definition: cdrom.h:788
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
NTSTATUS RequestHandleQueryPropertyRetrieveCachedData(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:2628
unsigned char UCHAR
Definition: xmlstorage.h:181
#define EXCLUSIVE_OWNER(_CdData, _FileObject)
Definition: cdrom.h:789
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define IOCTL_SCSI_PASS_THROUGH
Definition: scsi_port.h:47
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
STORAGE_QUERY_TYPE QueryType
Definition: ntddstor.h:553
#define IOCTL_SCSI_PASS_THROUGH_DIRECT
Definition: scsi_port.h:51
#define NULL
Definition: types.h:112
#define IOCTL_MCN_SYNC_FAKE_IOCTL
Definition: cdrom.h:181
STORAGE_PROPERTY_ID PropertyId
Definition: ntddstor.h:552
struct _WDF_REQUEST_PARAMETERS::@3670::@3675 Others
static int processed(const type_t *type)
Definition: typegen.c:2254
unsigned int ULONG
Definition: retypes.h:1
PMEDIA_CHANGE_DETECTION_INFO MediaChangeDetectionInfo
Definition: cdrom.h:563
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS RequestHandleQueryPropertyWriteCache(_In_ WDFDEVICE Device, _In_ WDFREQUEST Request)
Definition: ioctl.c:2974
FxIrp * irp
Definition: ps.c:97

Referenced by DeviceEvtIoInCallerContext(), and RequestDispatchSpecialIoctls().

◆ RequestDispatchSyncWithSequentialQueue()

BOOLEAN RequestDispatchSyncWithSequentialQueue ( _In_ WDFDEVICE  Device,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters 
)

Definition at line 2717 of file cdrom.c.

2740 {
2743  size_t dataLength = 0;
2744 
2745  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(Device);
2746  ULONG ioctlCode = RequestParameters.Parameters.DeviceIoControl.IoControlCode;
2747 
2748  switch (ioctlCode)
2749  {
2750 
2752  {
2753  //1. Validate
2755 
2756  //2. keep the request in serialized manner and stay in user's context.
2757  if (NT_SUCCESS(status))
2758  {
2759  PCDROM_EXCLUSIVE_ACCESS exclusiveAccess = NULL;
2760 
2761  status = WdfRequestRetrieveInputBuffer(Request,
2762  RequestParameters.Parameters.DeviceIoControl.InputBufferLength,
2763  &exclusiveAccess,
2764  NULL);
2765 
2766  if (NT_SUCCESS(status))
2767  {
2768  // do not need to check "status" as it passed validation and cannot fail in WdfRequestRetrieveInputBuffer()
2769  switch (exclusiveAccess->RequestType)
2770  {
2771 
2773  {
2774  status = RequestSetContextFields(Request, RequestHandleExclusiveAccessQueryLockState);
2775  break;
2776  }
2777 
2779  {
2780  status = RequestSetContextFields(Request, RequestHandleExclusiveAccessLockDevice);
2781  break;
2782  }
2783 
2785  {
2786  status = RequestSetContextFields(Request, RequestHandleExclusiveAccessUnlockDevice);
2787  break;
2788  }
2789  default:
2790  {
2791  // already valicated in RequestValidateExclusiveAccess()
2792  NT_ASSERT(FALSE);
2793  break;
2794  }
2795  }
2796  }
2797 
2798  if (NT_SUCCESS(status))
2799  {
2800  // now, put the special synchronization information into the context
2802 
2803  // "status" is used for debugging in above statement, reset to success to avoid further work in this function.
2805  }
2806  }
2807 
2808  processed = TRUE;
2809  break; // complete the irp
2810  }
2811 
2812  default:
2813  {
2814  processed = FALSE;
2815  break;
2816  }
2817  } //end of switch (ioctlCode)
2818 
2819  // Following process is only valid if the request is not really processed. (failed in validation)
2820  if (processed && !NT_SUCCESS(status))
2821  {
2822  UCHAR currentStackLocationFlags = 0;
2823  currentStackLocationFlags = RequestGetCurrentStackLocationFlags(Request);
2824 
2825  if ((status == STATUS_VERIFY_REQUIRED) &&
2826  (currentStackLocationFlags & SL_OVERRIDE_VERIFY_VOLUME))
2827  {
2828  //
2829  // If the status is verified required and this request
2830  // should bypass verify required then retry the request.
2831  //
2833  UNREFERENCED_PARAMETER(status); // disables prefast warning; defensive coding...
2834 
2836  }
2837  else
2838  {
2839  // Validation failed / forward failed, complete the request.
2840  RequestCompletion(deviceExtension, Request, status, dataLength);
2841  }
2842  }
2843 
2844  return processed;
2845 }
FORCEINLINE UCHAR RequestGetCurrentStackLocationFlags(_In_ WDFREQUEST Request)
Definition: cdrom.h:1554
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
NTSTATUS RequestSetContextFields(_In_ WDFREQUEST Request, _In_ PSYNC_HANDLER Handler)
Definition: common.c:2748
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
VOID RequestCompletion(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ NTSTATUS Status, _In_ ULONG_PTR Information)
Definition: common.c:3439
#define FALSE
Definition: types.h:117
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
BOOLEAN RequestDispatchSyncWithSequentialQueue(_In_ WDFDEVICE Device, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters)
Definition: cdrom.c:2717
NTSTATUS RequestSynchronizeProcessWithSerialQueue(_In_ WDFDEVICE Device, _In_ WDFREQUEST Request)
Definition: cdrom.c:3893
unsigned char BOOLEAN
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1823
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG dataLength
Definition: scsi.h:3751
unsigned char UCHAR
Definition: xmlstorage.h:181
#define IOCTL_CDROM_EXCLUSIVE_ACCESS
Definition: ntddcdrm.h:85
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
EXCLUSIVE_ACCESS_REQUEST_TYPE RequestType
Definition: ntddcdrm.h:419
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
#define NULL
Definition: types.h:112
NTSTATUS RequestValidateExclusiveAccess(_In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:2240
static int processed(const type_t *type)
Definition: typegen.c:2254
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

Referenced by DeviceEvtIoInCallerContext(), and RequestDispatchSyncWithSequentialQueue().

◆ RequestDispatchToSequentialQueue()

BOOLEAN RequestDispatchToSequentialQueue ( _In_ WDFDEVICE  Device,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters 
)

Definition at line 1855 of file cdrom.c.

1878 {
1881  size_t dataLength = 0;
1882  BOOLEAN inZeroPowerState = FALSE;
1883 
1884  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(Device);
1885  ULONG ioctlCode = RequestParameters.Parameters.DeviceIoControl.IoControlCode;
1886  PZERO_POWER_ODD_INFO zpoddInfo = deviceExtension->ZeroPowerODDInfo;
1887 
1888  if ((zpoddInfo != NULL) &&
1889  (zpoddInfo->InZeroPowerState != FALSE))
1890  {
1891  inZeroPowerState = TRUE;
1892  }
1893 
1894  switch (ioctlCode)
1895  {
1896 
1897  case IOCTL_CDROM_RAW_READ:
1898  {
1900 
1901  processed = TRUE;
1902  break;
1903  }
1904 
1907  {
1908  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
1909  "RequestDispatchToSequentialQueue: Get drive geometryEx\n"));
1910  if ( RequestParameters.Parameters.DeviceIoControl.OutputBufferLength <
1912  {
1915  }
1916  else if (inZeroPowerState != FALSE)
1917  {
1919  }
1920  else
1921  {
1923  }
1924 
1925  processed = TRUE;
1926  break;
1927  }
1928 
1931  {
1932  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
1933  "RequestDispatchToSequentialQueue: Get drive geometry\n"));
1934  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength <
1935  sizeof(DISK_GEOMETRY))
1936  {
1938  dataLength = sizeof(DISK_GEOMETRY);
1939  }
1940  else if (inZeroPowerState != FALSE)
1941  {
1943  }
1944  else
1945  {
1947  }
1948 
1949  processed = TRUE;
1950  break;
1951  }
1952 
1954  {
1956 
1957  if (inZeroPowerState != FALSE)
1958  {
1960  }
1961 
1962  processed = TRUE;
1963  break;
1964  }
1965 
1966  case IOCTL_CDROM_READ_TOC:
1967  {
1969 
1970  if (inZeroPowerState != FALSE)
1971  {
1973  }
1974 
1975  processed = TRUE;
1976  break;
1977  }
1978 
1980  {
1982 
1983  processed = TRUE;
1984  break;
1985  }
1986 
1988  {
1989  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
1990  "RequestDispatchToSequentialQueue: Play audio MSF\n"));
1991 
1992  if (RequestParameters.Parameters.DeviceIoControl.InputBufferLength <
1993  sizeof(CDROM_PLAY_AUDIO_MSF))
1994  {
1996  }
1997  else
1998  {
2000  }
2001 
2002  processed = TRUE;
2003  break;
2004  }
2005 
2007  {
2008  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2009  "RequestDispatchToSequentialQueue: Seek audio MSF\n"));
2010 
2011  if (RequestParameters.Parameters.DeviceIoControl.InputBufferLength <
2012  sizeof(CDROM_SEEK_AUDIO_MSF))
2013  {
2015  }
2016  else
2017  {
2019  }
2020 
2021  processed = TRUE;
2022  break;
2023  }
2024 
2026  {
2027  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2028  "RequestDispatchToSequentialQueue: Pause audio\n"));
2029 
2031  processed = TRUE;
2032  break;
2033  }
2034 
2036  {
2037  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2038  "RequestDispatchToSequentialQueue: Resume audio\n"));
2039 
2041  processed = TRUE;
2042  break;
2043  }
2044 
2046  {
2048 
2049  processed = TRUE;
2050  break;
2051  }
2052 
2054  {
2055  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2056  "RequestDispatchToSequentialQueue: Get volume control\n"));
2057 
2058  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength <
2059  sizeof(VOLUME_CONTROL))
2060  {
2062  dataLength = sizeof(VOLUME_CONTROL);
2063  }
2064  else
2065  {
2067  }
2068 
2069  processed = TRUE;
2070  break;
2071  }
2072 
2074  {
2075  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2076  "RequestDispatchToSequentialQueue: Set volume control\n"));
2077 
2078  if (RequestParameters.Parameters.DeviceIoControl.InputBufferLength <
2079  sizeof(VOLUME_CONTROL))
2080  {
2082  }
2083  else
2084  {
2086  }
2087 
2088  processed = TRUE;
2089  break;
2090  }
2091 
2093  {
2094  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2095  "RequestDispatchToSequentialQueue: Stop audio\n"));
2096 
2098  processed = TRUE;
2099  break;
2100  }
2101 
2104  {
2105  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2106  "RequestDispatchToSequentialQueue: [%p] Check Verify\n", Request));
2107 
2108  // Following check will let the condition "OutputBufferLength == 0" pass.
2109  // Since it's legacy behavior in classpnp, we need to keep it.
2110  if ((RequestParameters.Parameters.DeviceIoControl.OutputBufferLength > 0) &&
2111  (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength < sizeof(ULONG)))
2112  {
2114  dataLength = sizeof(ULONG);
2115  }
2116  else if (inZeroPowerState != FALSE)
2117  {
2119  }
2120  else
2121  {
2123  }
2124 
2125  processed = TRUE;
2126  break;
2127  }
2128 
2129  case IOCTL_DVD_GET_REGION:
2130  {
2131  // validation will be done when process it.
2133  processed = TRUE;
2134  break;
2135  }
2136 
2138  {
2139  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2140  "RequestDispatchToSequentialQueue: [%p] IOCTL_DVD_READ_STRUCTURE\n", Request));
2141 
2143 
2144  processed = TRUE;
2145  break;
2146  }
2147 
2148  case IOCTL_DVD_READ_KEY:
2149  {
2150  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2151  "RequestDispatchToSequentialQueue: [%p] IOCTL_DVD_READ_KEY\n", Request));
2152 
2154 
2155  processed = TRUE;
2156  break;
2157  }
2158 
2160  {
2161  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2162  "RequestDispatchToSequentialQueue: [%p] IOCTL_DVD_START_SESSION\n", Request));
2163 
2165 
2166  processed = TRUE;
2167  break;
2168  }
2169 
2170  case IOCTL_DVD_SEND_KEY:
2171  case IOCTL_DVD_SEND_KEY2:
2172  {
2173  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2174  "RequestDispatchToSequentialQueue: [%p] IOCTL_DVD_SEND_KEY\n", Request));
2175 
2177 
2178  processed = TRUE;
2179  break;
2180  }
2181 
2183  {
2184  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2185  "RequestDispatchToSequentialQueue: [%p] SetReadAhead\n", Request));
2186 
2187  if (RequestParameters.Parameters.DeviceIoControl.InputBufferLength <
2188  sizeof(STORAGE_SET_READ_AHEAD))
2189  {
2191  }
2192  else
2193  {
2195  }
2196 
2197  processed = TRUE;
2198  break;
2199  }
2200 
2202  {
2204 
2205  processed = TRUE;
2206  break;
2207  }
2208 
2210  {
2211  ULONG requiredSize = 0;
2212 
2213  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2214  "RequestDispatchToSequentialQueue: Get drive layout\n"));
2215 
2216  requiredSize = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION, PartitionEntry[1]);
2217 
2218  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength <
2219  requiredSize)
2220  {
2222  dataLength = requiredSize;
2223  }
2224  else
2225  {
2227  }
2228 
2229  processed = TRUE;
2230  break;
2231  }
2232 
2234  {
2235  ULONG requiredSize = 0;
2236 
2237  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2238  "RequestDispatchToSequentialQueue: Get drive layoutEx\n"));
2239 
2240  requiredSize = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EX, PartitionEntry[1]);
2241 
2242  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength <
2243  requiredSize)
2244  {
2246  dataLength = requiredSize;
2247  }
2248  else
2249  {
2251  }
2252 
2253  processed = TRUE;
2254  break;
2255  }
2256 
2258  {
2259  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2260  "RequestDispatchToSequentialQueue: Get Partition Info\n"));
2261 
2262  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength <
2263  sizeof(PARTITION_INFORMATION))
2264  {
2267  }
2268  else
2269  {
2271  }
2272 
2273  processed = TRUE;
2274  break;
2275  }
2276 
2278  {
2279  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2280  "RequestDispatchToSequentialQueue: Get Partition InfoEx\n"));
2281 
2282  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength <
2283  sizeof(PARTITION_INFORMATION_EX))
2284  {
2287  }
2288  else
2289  {
2291  }
2292 
2293  processed = TRUE;
2294  break;
2295  }
2296 
2297  case IOCTL_DISK_VERIFY:
2298  {
2299  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2300  "RequestDispatchToSequentialQueue: IOCTL_DISK_VERIFY to device %p through request %p\n",
2301  Device,
2302  Request));
2303 
2304  if (RequestParameters.Parameters.DeviceIoControl.InputBufferLength <
2305  sizeof(VERIFY_INFORMATION))
2306  {
2308  }
2309  else
2310  {
2312  }
2313 
2314  processed = TRUE;
2315  break;
2316  }
2317 
2319  {
2320  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2321  "RequestDispatchToSequentialQueue: Disk Get Length InfoEx\n"));
2322 
2323  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength <
2324  sizeof(GET_LENGTH_INFORMATION))
2325  {
2328  }
2329  else if (inZeroPowerState != FALSE)
2330  {
2332  }
2333  else
2334  {
2336  }
2337 
2338  processed = TRUE;
2339  break;
2340  }
2341 
2343  {
2344  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2345  "RequestDispatchToSequentialQueue: [%p] IOCTL_CDROM_GET_CONFIGURATION\n", Request));
2346 
2348 
2349  processed = TRUE;
2350  break;
2351  }
2352 
2353  case IOCTL_CDROM_SET_SPEED:
2354  {
2355  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2356  "RequestDispatchToSequentialQueue: [%p] IOCTL_CDROM_SET_SPEED\n", Request));
2357 
2359 
2360  processed = TRUE;
2361  break;
2362  }
2363 
2364  case IOCTL_DVD_END_SESSION:
2365  {
2366  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2367  "RequestDispatchToSequentialQueue: [%p] IOCTL_DVD_END_SESSION\n", Request));
2368 
2370 
2371  processed = TRUE;
2372  break;
2373  }
2374 
2376  {
2377  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2378  "RequestDispatchToSequentialQueue: [%p] IOCTL_AACS_END_SESSION\n", Request));
2379 
2381 
2382  processed = TRUE;
2383  break;
2384  }
2385 
2387  {
2388  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
2389  "AACS: Querying full MKB with bufferSize of %x bytes\n",
2390  (int)RequestParameters.Parameters.DeviceIoControl.OutputBufferLength
2391  ));
2392 
2394 
2395  processed = TRUE;
2396  break;
2397  }
2398 
2400  {
2401  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
2402  "AACS: Requesting AGID\n"
2403  ));
2404 
2406 
2407  processed = TRUE;
2408  break;
2409  }
2410 
2412  {
2413  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
2414  "AACS: Sending host certificate to drive\n"
2415  ));
2416 
2418 
2419  processed = TRUE;
2420  break;
2421  }
2422 
2424  {
2425  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
2426  "AACS: Querying drive certificate\n"
2427  ));
2428 
2430 
2431  processed = TRUE;
2432  break;
2433  }
2434 
2436  {
2437  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
2438  "AACS: Querying drive challenge key\n"
2439  ));
2440 
2442 
2443  processed = TRUE;
2444  break;
2445  }
2446 
2448  {
2449  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
2450  "AACS: Sending drive challenge key\n"
2451  ));
2452 
2454 
2455  processed = TRUE;
2456  break;
2457  }
2458 
2460  {
2461  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
2462  "AACS: Reading volume ID\n"
2463  ));
2464 
2466 
2467  processed = TRUE;
2468  break;
2469  }
2470 
2472  {
2473  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
2474  "AACS: Reading Serial Number\n"
2475  ));
2476 
2478 
2479  processed = TRUE;
2480  break;
2481  }
2482 
2484  {
2485  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
2486  "AACS: Reading media ID\n"
2487  ));
2488 
2490 
2491  processed = TRUE;
2492  break;
2493  }
2494 
2497  {
2498  if (ioctlCode == IOCTL_AACS_GENERATE_BINDING_NONCE)
2499  {
2500  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
2501  "AACS: Generating new binding nonce\n"
2502  ));
2503  }
2504  else
2505  {
2506  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
2507  "AACS: Reading existing binding nonce\n"
2508  ));
2509  }
2510 
2512 
2513  processed = TRUE;
2514  break;
2515  }
2516 
2518  {
2519  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2520  "RequestDispatchToSequentialQueue: [%p] IOCTL_CDROM_ENABLE_STREAMING\n", Request));
2521 
2523 
2524  processed = TRUE;
2525  break;
2526  }
2527 
2529  {
2530  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2531  "RequestDispatchToSequentialQueue: [%p] IOCTL_CDROM_SEND_OPC_INFORMATION\n", Request));
2532 
2534 
2535  processed = TRUE;
2536  break;
2537  }
2538 
2540  {
2541  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
2542  "RequestDispatchToSequentialQueue: [%p] IOCTL_CDROM_GET_PERFORMANCE\n", Request));
2543 
2545 
2546  processed = TRUE;
2547  break;
2548  }
2549 
2552  {
2553  if(RequestParameters.Parameters.DeviceIoControl.InputBufferLength <
2554  sizeof(PREVENT_MEDIA_REMOVAL))
2555  {
2557  }
2558  else
2559  {
2561  }
2562 
2563  processed = TRUE;
2564  break; // complete the irp
2565  }
2566 
2568  {
2569  if(RequestParameters.Parameters.DeviceIoControl.InputBufferLength <
2570  sizeof(PREVENT_MEDIA_REMOVAL))
2571  {
2573  }
2574  else
2575  {
2577  }
2578 
2579  processed = TRUE;
2580  break; // complete the irp
2581  }
2582 
2583  case IOCTL_STORAGE_RESERVE:
2584  case IOCTL_STORAGE_RELEASE:
2585  {
2586  // there is no validate check currently.
2588  processed = TRUE;
2589  break;
2590  }
2591 
2594  {
2596 
2597  processed = TRUE;
2598  break;
2599  }
2600 
2604  {
2606 
2607  processed = TRUE;
2608  break; // complete the irp
2609  }
2610 
2612  {
2613  // process it.
2615 
2617 
2618  processed = TRUE;
2619  break; // complete the irp
2620  }
2621 
2623  {
2624  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength < sizeof(STORAGE_READ_CAPACITY))
2625  {
2628  }
2629  else if (inZeroPowerState != FALSE)
2630  {
2632  }
2633  else
2634  {
2636  }
2637 
2638  processed = TRUE;
2639  break; // complete the irp
2640  }
2641 
2643  {
2644  // for disk.sys only in original classpnp
2646 
2647  processed = TRUE;
2648  break; // complete the irp
2649  }
2650 
2651 #if (NTDDI_VERSION >= NTDDI_WIN8)
2653  {
2654  // this request doesn't access device at all, so seemingly it can be processed
2655  // directly; however, in case volume online is not received, we will need to
2656  // park these requests in a queue, and the only way a request can be queued is
2657  // if the request came out of another queue.
2659 
2660  processed = TRUE;
2661  break;
2662  }
2663 
2664  case IOCTL_VOLUME_ONLINE:
2666  {
2668 
2669  processed = TRUE;
2670  break;
2671  }
2672 #endif
2673 
2674  default:
2675  {
2676  processed = FALSE;
2677  break;
2678  }
2679  } //end of switch (ioctlCode)
2680 
2681  if (processed)
2682  {
2683  UCHAR currentStackLocationFlags = 0;
2684  currentStackLocationFlags = RequestGetCurrentStackLocationFlags(Request);
2685 
2686  if ((status == STATUS_VERIFY_REQUIRED) &&
2687  (currentStackLocationFlags & SL_OVERRIDE_VERIFY_VOLUME))
2688  {
2689  // If the status is verified required and this request
2690  // should bypass verify required then retry the request.
2692  UNREFERENCED_PARAMETER(status); // disables prefast warning; defensive coding...
2693 
2695  }
2696  else
2697  {
2698  if (NT_SUCCESS(status))
2699  {
2700  // Forward the request to serialized queue.
2701  status = WdfDeviceEnqueueRequest(Device, Request);
2702  }
2703 
2704  if (!NT_SUCCESS(status))
2705  {
2706  // Validation failed / forward failed, complete the request.
2707  RequestCompletion(deviceExtension, Request, status, dataLength);
2708  }
2709  }
2710  }
2711 
2712  return processed;
2713 }
NTSTATUS RequestValidateAacsReadSerialNumber(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:2024
#define IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
Definition: ntddk_ex.h:208
#define IOCTL_STORAGE_MCN_CONTROL
Definition: ntddstor.h:128
#define IOCTL_STORAGE_SET_READ_AHEAD
Definition: cdrw_usr.h:186
return STATUS_NOT_SUPPORTED
#define STATUS_NO_MEDIA_IN_DEVICE
Definition: udferr_usr.h:141
NTSTATUS RequestValidateAacsGetCertificate(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:1757
FORCEINLINE UCHAR RequestGetCurrentStackLocationFlags(_In_ WDFREQUEST Request)
Definition: cdrom.h:1554
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define IOCTL_STORAGE_MEDIA_REMOVAL
Definition: ntddstor.h:104
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
NTSTATUS RequestValidateReadToc(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:984
#define IOCTL_AACS_GET_CERTIFICATE
Definition: ntddcdvd.h:73
#define IOCTL_CDROM_GET_CONFIGURATION
Definition: ntddcdrm.h:82
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_STORAGE_PERSISTENT_RESERVE_OUT
Definition: ntddstor.h:172
NTSTATUS RequestValidateDvdReadKey(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:3286
#define IOCTL_AACS_START_SESSION
Definition: ntddcdvd.h:64
#define IOCTL_CDROM_GET_LAST_SESSION
Definition: ntddcdrm.h:64
BOOLEAN RequestDispatchToSequentialQueue(_In_ WDFDEVICE Device, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters)
Definition: cdrom.c:1855
#define IOCTL_DISK_IS_WRITABLE
Definition: cdrw_usr.h:172
#define IOCTL_STORAGE_CHECK_PRIORITY_HINT_SUPPORT
Definition: ntddstor.h:196
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
BOOLEAN InZeroPowerState
Definition: cdromp.h:272
#define IOCTL_AACS_GENERATE_BINDING_NONCE
Definition: ntddcdvd.h:94
NTSTATUS RequestValidateGetLastSession(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:1029
PDEVICE_OBJECT LowerPdo
Definition: cdrom.h:496
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
struct _PARTITION_INFORMATION PARTITION_INFORMATION
#define IOCTL_AACS_READ_MEDIA_ID
Definition: ntddcdvd.h:88
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define IOCTL_CDROM_GET_DRIVE_GEOMETRY_EX
Definition: ntddcdrm.h:76
#define IOCTL_CDROM_RAW_READ
Definition: ntddcdrm.h:67
#define IOCTL_CDROM_SET_VOLUME
Definition: ntddcdrm.h:55
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
#define IOCTL_STORAGE_FIND_NEW_DEVICES
Definition: ntddstor.h:122
VOID RequestCompletion(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ NTSTATUS Status, _In_ ULONG_PTR Information)
Definition: common.c:3439
struct _PARTITION_INFORMATION_EX PARTITION_INFORMATION_EX
#define FALSE
Definition: types.h:117
#define IOCTL_DISK_VERIFY
Definition: cdrw_usr.h:170
NTSTATUS RequestValidateReadQChannel(_In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:1072
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
NTSTATUS RequestValidateAacsSendCertificate(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:1697
#define IOCTL_CDROM_STOP_AUDIO
Definition: ntddcdrm.h:40
NTSTATUS RequestValidateAacsGetChallengeKey(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:1826
#define IOCTL_STORAGE_EJECTION_CONTROL
Definition: ntddstor.h:125
struct _GET_LENGTH_INFORMATION GET_LENGTH_INFORMATION
NTSTATUS RequestValidateDvdStartSession(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:1225
NTSTATUS RequestValidatePersistentReserve(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:6715
#define IOCTL_STORAGE_RELEASE
Definition: ntddstor.h:119
#define IOCTL_STORAGE_EJECT_MEDIA
Definition: ntddstor.h:107
NTSTATUS RequestValidateAacsReadVolumeId(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:1955
#define IOCTL_CDROM_SEEK_AUDIO_MSF
Definition: ntddcdrm.h:37
STORAGE_READ_CAPACITY
Definition: ntddstor.h:861
unsigned char BOOLEAN
#define IOCTL_VOLUME_ONLINE
Definition: ntddvol.h:62
#define IOCTL_CDROM_PLAY_AUDIO_MSF
Definition: ntddcdrm.h:52
#define IOCTL_DVD_END_SESSION
Definition: cdrw_usr.h:162
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1823
NTSTATUS RequestValidateEnableStreaming(_In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:3515
NTSTATUS RequestValidateGetConfiguration(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:1364
#define IOCTL_CDROM_ENABLE_STREAMING
Definition: ntddcdrm.h:94
NTSTATUS RequestValidateDvdSendKey(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:1274
NTSTATUS RequestValidateAacsStartSession(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:1651
#define IOCTL_STORAGE_RESERVE
Definition: ntddstor.h:116
#define IOCTL_DISK_GET_LENGTH_INFO
Definition: imports.h:192
#define IOCTL_AACS_GET_CHALLENGE_KEY
Definition: ntddcdvd.h:76
#define IOCTL_STORAGE_CHECK_VERIFY
Definition: ntddstor.h:98
NTSTATUS RequestValidateAacsSendChallengeKey(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:1895
#define IOCTL_VOLUME_POST_ONLINE
Definition: volume.c:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IOCTL_STORAGE_PERSISTENT_RESERVE_IN
Definition: ntddstor.h:169
#define IOCTL_CDROM_GET_DRIVE_GEOMETRY
Definition: ntddcdrm.h:73
PZERO_POWER_ODD_INFO ZeroPowerODDInfo
Definition: cdrom.h:566
#define IOCTL_CDROM_GET_VOLUME
Definition: ntddcdrm.h:49
NTSTATUS RequestValidateSendOpcInformation(_In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:3576
ULONG dataLength
Definition: scsi.h:3751
#define IOCTL_DVD_SEND_KEY
Definition: cdrw_usr.h:161
#define IOCTL_STORAGE_LOAD_MEDIA2
Definition: ntddk_ex.h:210
#define IOCTL_DISK_ARE_VOLUMES_READY
Definition: ntdddisk.h:46
unsigned char UCHAR
Definition: xmlstorage.h:181
#define IOCTL_DISK_GET_PARTITION_INFO
Definition: ntdddisk.h:106
#define IOCTL_AACS_READ_SERIAL_NUMBER
Definition: ntddcdvd.h:85
#define IOCTL_STORAGE_CHECK_VERIFY2
Definition: ntddk_ex.h:212
#define IOCTL_DVD_READ_KEY
Definition: cdrw_usr.h:160
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define IOCTL_CDROM_PAUSE_AUDIO
Definition: ntddcdrm.h:43
#define IOCTL_DVD_GET_REGION
Definition: cdrw_usr.h:164
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
#define IOCTL_AACS_END_SESSION
Definition: ntddcdvd.h:67
NTSTATUS RequestValidateGetPerformance(_In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:3634
#define IOCTL_DISK_GET_DRIVE_LAYOUT
Definition: ntdddisk.h:91
#define IOCTL_CDROM_RESUME_AUDIO
Definition: ntddcdrm.h:46
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
NTSTATUS RequestValidateSetSpeed(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:1501
struct _DISK_GEOMETRY DISK_GEOMETRY
#define IOCTL_AACS_SEND_CERTIFICATE
Definition: ntddcdvd.h:70
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:2343
#define IOCTL_AACS_READ_MEDIA_KEY_BLOCK
Definition: ntddcdvd.h:61
#define IOCTL_DISK_GET_DRIVE_LAYOUT_EX
Definition: ntddk_ex.h:207
NTSTATUS RequestValidateAacsReadMediaKeyBlock(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:1584
#define IOCTL_CDROM_READ_TOC_EX
Definition: ntddcdrm.h:79
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define IOCTL_STORAGE_LOAD_MEDIA
Definition: ntddstor.h:110
#define NULL
Definition: types.h:112
NTSTATUS RequestValidateAacsBindingNonce(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:2162
NTSTATUS RequestValidateAacsEndSession(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:3462
#define IOCTL_DVD_SEND_KEY2
Definition: cdrw_usr.h:165
#define IOCTL_CDROM_GET_PERFORMANCE
Definition: ntddcdrm.h:100
#define IOCTL_AACS_READ_BINDING_NONCE
Definition: ntddcdvd.h:91
#define IOCTL_AACS_READ_VOLUME_ID
Definition: ntddcdvd.h:82
#define IOCTL_CDROM_SEND_OPC_INFORMATION
Definition: ntddcdrm.h:97
static int processed(const type_t *type)
Definition: typegen.c:2254
NTSTATUS RequestValidateDvdEndSession(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:3408
NTSTATUS RequestValidateReadTocEx(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:887
unsigned int ULONG
Definition: retypes.h:1
#define IOCTL_CDROM_READ_TOC
Definition: ntddcdrm.h:34
#define IOCTL_AACS_SEND_CHALLENGE_KEY
Definition: ntddcdvd.h:79
#define STATUS_SUCCESS
Definition: shellext.h:65
#define IOCTL_DVD_START_SESSION
Definition: cdrw_usr.h:159
#define IOCTL_CDROM_SET_SPEED
Definition: ntddcdrm.h:88
#define IOCTL_CDROM_READ_Q_CHANNEL
Definition: ntddcdrm.h:58
NTSTATUS RequestValidateDvdReadStructure(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:1151
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
Definition: cdrw_usr.h:169
NTSTATUS RequestValidateRawRead(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:650
struct _VOLUME_CONTROL VOLUME_CONTROL
#define IOCTL_DISK_GET_PARTITION_INFO_EX
Definition: ntddk_ex.h:206
#define IOCTL_STORAGE_READ_CAPACITY
Definition: ntddstor.h:175
NTSTATUS RequestValidateAacsReadMediaId(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: ioctl.c:2093
#define IOCTL_DVD_READ_STRUCTURE
Definition: cdrw_usr.h:157
Definition: ps.c:97

Referenced by DeviceEvtIoInCallerContext(), and RequestDispatchToSequentialQueue().

◆ RequestDispatchUnknownRequests()

BOOLEAN RequestDispatchUnknownRequests ( _In_ WDFDEVICE  Device,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters 
)

Definition at line 3093 of file cdrom.c.

3118 {
3120  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(Device);
3121 
3123 
3124  if ((KeGetCurrentIrql() != PASSIVE_LEVEL) ||
3125  (baseCode == FILE_DEVICE_ACPI))
3126  {
3127  // 1. When IRQL is higher than PASSIVE_LEVEL,
3128  // 2. ataport sends IOCTL_ACPI_ASYNC_EVAL_METHOD before queue starts,
3129  // send request directly to lower driver.
3131  }
3132  else
3133  {
3134  // keep the request in serialized manner and stay in user's context.
3136 
3137  if (NT_SUCCESS(status))
3138  {
3140  }
3141  else
3142  {
3143  RequestCompletion(deviceExtension, Request, status, 0);
3144  }
3145  }
3146 
3147  UNREFERENCED_PARAMETER(status); //defensive coding, avoid PREFAST warning.
3148 
3149  // All unknown IOCTLs are processed in this function.
3150  return TRUE; //processed
3151 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS RequestHandleUnknownIoctl(_In_ WDFDEVICE Device, _In_ WDFREQUEST Request)
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
NTSTATUS RequestSetContextFields(_In_ WDFREQUEST Request, _In_ PSYNC_HANDLER Handler)
Definition: common.c:2748
VOID RequestCompletion(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ NTSTATUS Status, _In_ ULONG_PTR Information)
Definition: common.c:3439
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
NTSTATUS RequestSynchronizeProcessWithSerialQueue(_In_ WDFDEVICE Device, _In_ WDFREQUEST Request)
Definition: cdrom.c:3893
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
#define DEVICE_TYPE_FROM_CTL_CODE(c)
Definition: winioctl.h:205
#define FILE_DEVICE_ACPI
Definition: winioctl.h:156
unsigned int ULONG
Definition: retypes.h:1
Definition: ps.c:97

Referenced by DeviceEvtIoInCallerContext(), and RequestDispatchSpecialIoctls().

◆ RequestHandleGetDeviceNumber()

NTSTATUS RequestHandleGetDeviceNumber ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters,
_Out_ size_t DataLength 
)

Definition at line 5280 of file ioctl.c.

5304 {
5306 
5307  *DataLength = 0;
5308 
5309  if(RequestParameters.Parameters.DeviceIoControl.OutputBufferLength >=
5310  sizeof(STORAGE_DEVICE_NUMBER))
5311  {
5312  PSTORAGE_DEVICE_NUMBER deviceNumber = NULL;
5313  status = WdfRequestRetrieveOutputBuffer(Request,
5314  RequestParameters.Parameters.DeviceIoControl.OutputBufferLength,
5315  &deviceNumber,
5316  NULL);
5317  if (NT_SUCCESS(status))
5318  {
5319  deviceNumber->DeviceType = DeviceExtension->DeviceObject->DeviceType;
5320  deviceNumber->DeviceNumber = DeviceExtension->DeviceNumber;
5321  deviceNumber->PartitionNumber = (ULONG)-1; // legacy reason, return (-1) for this IOCTL.
5322 
5324  *DataLength = sizeof(STORAGE_DEVICE_NUMBER);
5325  }
5326  }
5327  else
5328  {
5330  *DataLength = sizeof(STORAGE_DEVICE_NUMBER);
5331  }
5332 
5333  return status;
5334 }
DEVICE_TYPE DeviceType
Definition: ntddstor.h:324
LONG NTSTATUS
Definition: precomp.h:26
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _STORAGE_DEVICE_NUMBER STORAGE_DEVICE_NUMBER
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by RequestDispatchProcessDirectly().

◆ RequestHandleGetHotPlugInfo()

NTSTATUS RequestHandleGetHotPlugInfo ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters,
_Out_ size_t DataLength 
)

Definition at line 5337 of file ioctl.c.

5361 {
5363 
5364  *DataLength = 0;
5365 
5366  if(RequestParameters.Parameters.DeviceIoControl.OutputBufferLength >=
5367  sizeof(STORAGE_HOTPLUG_INFO))
5368  {
5370  status = WdfRequestRetrieveOutputBuffer(Request,
5371  RequestParameters.Parameters.DeviceIoControl.OutputBufferLength,
5372  &info,
5373  NULL);
5374  if (NT_SUCCESS(status))
5375  {
5376  *info = DeviceExtension->PrivateFdoData->HotplugInfo;
5377 
5379  *DataLength = sizeof(STORAGE_HOTPLUG_INFO);
5380  }
5381  }
5382  else
5383  {
5385  *DataLength = sizeof(STORAGE_HOTPLUG_INFO);
5386  }
5387 
5388  return status;
5389 }
LONG NTSTATUS
Definition: precomp.h:26
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
struct _STORAGE_HOTPLUG_INFO STORAGE_HOTPLUG_INFO
Definition: ps.c:97

Referenced by RequestDispatchProcessDirectly().

◆ RequestHandleGetInquiryData()

NTSTATUS RequestHandleGetInquiryData ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters,
_Out_ size_t DataLength 
)

Definition at line 270 of file ioctl.c.

293 {
295  PCDROM_DATA cdData = &(DeviceExtension->DeviceAdditionalData);
296 
297  *DataLength = 0;
298 
299  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength == 0)
300  {
302  }
303  else
304  {
305  PVOID outputBuffer = NULL;
306 
308  RequestParameters.Parameters.DeviceIoControl.OutputBufferLength);
309 
310  status = WdfRequestRetrieveOutputBuffer(Request,
311  RequestParameters.Parameters.DeviceIoControl.OutputBufferLength,
312  &outputBuffer,
313  NULL);
314 
315  if (NT_SUCCESS(status) &&
316  (outputBuffer != NULL))
317  {
318  // Always copy as much data as possible
319  RtlCopyMemory(outputBuffer,
320  cdData->CachedInquiryData,
321  *DataLength);
322  }
323 
324  // and finally decide between two possible status values
326  {
328  }
329  }
330 
331  return status;
332 }
LONG NTSTATUS
Definition: precomp.h:26
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG CachedInquiryDataByteCount
Definition: cdrom.h:392
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by RequestDispatchProcessDirectly().

◆ RequestHandleGetMediaTypeEx()

NTSTATUS RequestHandleGetMediaTypeEx ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_Out_ size_t DataLength 
)

Definition at line 336 of file ioctl.c.

358 {
360  PCDROM_DATA cdData = &(DeviceExtension->DeviceAdditionalData);
361 
362  PGET_MEDIA_TYPES mediaTypes = NULL;
363  PDEVICE_MEDIA_INFO mediaInfo = NULL; //&mediaTypes->MediaInfo[0];
364  ULONG sizeNeeded = 0;
365  PZERO_POWER_ODD_INFO zpoddInfo = DeviceExtension->ZeroPowerODDInfo;
366 
367  *DataLength = 0;
368 
369  // Must run below dispatch level.
371  {
372  NT_ASSERT(FALSE);
373  return STATUS_INVALID_LEVEL;
374  }
375 
376  sizeNeeded = sizeof(GET_MEDIA_TYPES);
377 
378  // IsMmc is static...
379  if (cdData->Mmc.IsMmc)
380  {
381  sizeNeeded += sizeof(DEVICE_MEDIA_INFO) * 1; // return two media types
382  }
383 
384  status = WdfRequestRetrieveOutputBuffer(Request,
385  sizeNeeded,
386  (PVOID*)&mediaTypes,
387  NULL);
388 
389  if (NT_SUCCESS(status) &&
390  (mediaTypes != NULL))
391  {
392  mediaInfo = &mediaTypes->MediaInfo[0];
393 
394  RtlZeroMemory(mediaTypes, sizeNeeded);
395 
396  // ISSUE-2000/5/11-henrygab - need to update GET_MEDIA_TYPES_EX
397 
398  mediaTypes->DeviceType = cdData->DriveDeviceType;
399 
400  mediaTypes->MediaInfoCount = 1;
401  mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaType = CD_ROM;
402  mediaInfo->DeviceSpecific.RemovableDiskInfo.NumberMediaSides = 1;
403  mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaCharacteristics = MEDIA_READ_ONLY;
404  mediaInfo->DeviceSpecific.RemovableDiskInfo.Cylinders.QuadPart = DeviceExtension->DiskGeometry.Cylinders.QuadPart;
405  mediaInfo->DeviceSpecific.RemovableDiskInfo.TracksPerCylinder = DeviceExtension->DiskGeometry.TracksPerCylinder;
406  mediaInfo->DeviceSpecific.RemovableDiskInfo.SectorsPerTrack = DeviceExtension->DiskGeometry.SectorsPerTrack;
407  mediaInfo->DeviceSpecific.RemovableDiskInfo.BytesPerSector = DeviceExtension->DiskGeometry.BytesPerSector;
408 
409  if (cdData->Mmc.IsMmc)
410  {
411  // also report a removable disk
412  mediaTypes->MediaInfoCount += 1;
413 
414  mediaInfo++;
415  mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaType = RemovableMedia;
416  mediaInfo->DeviceSpecific.RemovableDiskInfo.NumberMediaSides = 1;
417  mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaCharacteristics = MEDIA_READ_WRITE;
418  mediaInfo->DeviceSpecific.RemovableDiskInfo.Cylinders.QuadPart = DeviceExtension->DiskGeometry.Cylinders.QuadPart;
419  mediaInfo->DeviceSpecific.RemovableDiskInfo.TracksPerCylinder = DeviceExtension->DiskGeometry.TracksPerCylinder;
420  mediaInfo->DeviceSpecific.RemovableDiskInfo.SectorsPerTrack = DeviceExtension->DiskGeometry.SectorsPerTrack;
421  mediaInfo->DeviceSpecific.RemovableDiskInfo.BytesPerSector = DeviceExtension->DiskGeometry.BytesPerSector;
422  mediaInfo--;
423 
424  }
425 
426  // Status will either be success, if media is present, or no media.
427  // It would be optimal to base from density code and medium type, but not all devices
428  // have values for these fields.
429 
430  // Send a TUR to determine if media is present, only if the device is not in ZPODD mode.
431  if ((!EXCLUSIVE_MODE(cdData) ||
432  EXCLUSIVE_OWNER(cdData, WdfRequestGetFileObject(Request))) &&
433  ((zpoddInfo == NULL) ||
434  (zpoddInfo->InZeroPowerState == FALSE)))
435  {
436  SCSI_REQUEST_BLOCK srb;
437  PCDB cdb = (PCDB)srb.Cdb;
438 
439  RtlZeroMemory(&srb,sizeof(SCSI_REQUEST_BLOCK));
440 
441  srb.CdbLength = 6;
442  cdb->CDB6GENERIC.OperationCode = SCSIOP_TEST_UNIT_READY;
443 
445 
446  status = DeviceSendSrbSynchronously(DeviceExtension->Device,
447  &srb,
448  NULL,
449  0,
450  FALSE,
451  Request);
452 
453  if (NT_SUCCESS(status))
454  {
455  // set the disk's media as current if we can write to it.
456  if (cdData->Mmc.IsMmc && cdData->Mmc.WriteAllowed)
457  {
458  mediaInfo++;
459  SET_FLAG(mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaCharacteristics,
461  mediaInfo--;
462  }
463  else
464  {
465  SET_FLAG(mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaCharacteristics,
467  }
468  }
469  else
470  {
471  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
472  "RequestHandleGetMediaTypeEx: GET_MEDIA_TYPES status of TUR - %lx\n", status));
473  }
474  }
475 
476  // per legacy cdrom behavior, always return success
478  }
479 
480  *DataLength = sizeNeeded;
481 
482  return status;
483 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
UCHAR Cdb[16]
Definition: srb.h:271
BOOLEAN WriteAllowed
Definition: cdrom.h:250
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
#define SCSIOP_TEST_UNIT_READY
Definition: cdrw_hw.h:866
union _DEVICE_MEDIA_INFO::@3120 DeviceSpecific
UCHAR CdbLength
Definition: srb.h:250
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
BOOLEAN InZeroPowerState
Definition: cdromp.h:272
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
ULONG TimeOutValue
Definition: srb.h:254
struct _DEVICE_MEDIA_INFO::@3120::@3122 RemovableDiskInfo
#define FALSE
Definition: types.h:117
union _CDB * PCDB
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
struct _GET_MEDIA_TYPES GET_MEDIA_TYPES
#define STATUS_INVALID_LEVEL
Definition: ntstatus.h:564
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define EXCLUSIVE_MODE(_CdData)
Definition: cdrom.h:788
#define MEDIA_READ_WRITE
Definition: minitape.h:34
#define EXCLUSIVE_OWNER(_CdData, _FileObject)
Definition: cdrom.h:789
ULONG DeviceType
Definition: ntddstor.h:494
DEVICE_TYPE DriveDeviceType
Definition: cdrom.h:388
ULONG MediaInfoCount
Definition: ntddstor.h:495
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define MEDIA_CURRENTLY_MOUNTED
Definition: minitape.h:36
struct _CDB::_CDB6GENERIC CDB6GENERIC
#define NULL
Definition: types.h:112
#define MEDIA_READ_ONLY
Definition: minitape.h:33
CDROM_MMC_EXTENSION Mmc
Definition: cdrom.h:341
struct _DEVICE_MEDIA_INFO DEVICE_MEDIA_INFO
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
#define CDROM_TEST_UNIT_READY_TIMEOUT
Definition: cdrom.h:128
#define SET_FLAG(Flags, Bit)
Definition: cdrom.h:1493
DEVICE_MEDIA_INFO MediaInfo[1]
Definition: ntddstor.h:496
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

Referenced by RequestDispatchProcessDirectly().

◆ RequestHandleMountQueryDeviceName()

NTSTATUS RequestHandleMountQueryDeviceName ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters,
_Out_ size_t DataLength 
)

Definition at line 4015 of file ioctl.c.

4039 {
4042 
4043  *DataLength = 0;
4044 
4045  NT_ASSERT(DeviceExtension->DeviceName.Buffer);
4046 
4047  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength < sizeof(MOUNTDEV_NAME))
4048  {
4050  *DataLength = sizeof(MOUNTDEV_NAME);
4051  }
4052 
4053  if (NT_SUCCESS(status))
4054  {
4055  status = WdfRequestRetrieveOutputBuffer(Request,
4056  RequestParameters.Parameters.DeviceIoControl.OutputBufferLength,
4057  &name,
4058  NULL);
4059  }
4060 
4061  if (NT_SUCCESS(status))
4062  {
4064  name->NameLength = DeviceExtension->DeviceName.Length;
4065 
4066  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength <
4067  (sizeof(USHORT) + DeviceExtension->DeviceName.Length))
4068  {
4070  *DataLength = sizeof(MOUNTDEV_NAME);
4071  }
4072  }
4073 
4074  if (NT_SUCCESS(status))
4075  {
4076  RtlCopyMemory(name->Name,
4077  DeviceExtension->DeviceName.Buffer,
4078  name->NameLength);
4079 
4081  *DataLength = sizeof(USHORT) + name->NameLength;
4082  }
4083 
4084  return status;
4085 }
LONG NTSTATUS
Definition: precomp.h:26
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
struct _MOUNTDEV_NAME MOUNTDEV_NAME
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned short USHORT
Definition: pedump.c:61
#define NULL
Definition: types.h:112
Definition: name.c:38
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

Referenced by RequestDispatchProcessDirectly().

◆ RequestHandleMountQuerySuggestedLinkName()

NTSTATUS RequestHandleMountQuerySuggestedLinkName ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters,
_Out_ size_t DataLength 
)

Definition at line 4088 of file ioctl.c.

4112 {
4114 
4115  PMOUNTDEV_SUGGESTED_LINK_NAME suggestedName = NULL;
4116 
4117  WCHAR driveLetterNameBuffer[10] = {0};
4118  RTL_QUERY_REGISTRY_TABLE queryTable[2] = {0};
4119  PWSTR valueName = NULL;
4120  UNICODE_STRING driveLetterName = {0};
4121 
4122  *DataLength = 0;
4123 
4124  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength <
4126  {
4129  }
4130 
4131  if (NT_SUCCESS(status))
4132  {
4133  valueName = ExAllocatePoolWithTag(PagedPool,
4134  DeviceExtension->DeviceName.Length + sizeof(WCHAR),
4136  if (valueName == NULL)
4137  {
4139  }
4140  }
4141 
4142  if (NT_SUCCESS(status))
4143  {
4144  RtlCopyMemory(valueName,
4145  DeviceExtension->DeviceName.Buffer,
4146  DeviceExtension->DeviceName.Length);
4147  valueName[DeviceExtension->DeviceName.Length/sizeof(WCHAR)] = 0;
4148 
4149  driveLetterName.Buffer = driveLetterNameBuffer;
4150  driveLetterName.MaximumLength = sizeof(driveLetterNameBuffer);
4151  driveLetterName.Length = 0;
4152 
4154  queryTable[0].Name = valueName;
4155  queryTable[0].EntryContext = &driveLetterName;
4157 
4159  L"\\Registry\\Machine\\System\\DISK", // why hard coded?
4160  queryTable, NULL, NULL);
4161  }
4162 
4163  if (NT_SUCCESS(status))
4164  {
4165  if ((driveLetterName.Length == 4) &&
4166  (driveLetterName.Buffer[0] == '%') &&
4167  (driveLetterName.Buffer[1] == ':'))
4168  {
4169  driveLetterName.Buffer[0] = 0xFF;
4170  }
4171  else if ((driveLetterName.Length != 4) ||
4172  (driveLetterName.Buffer[0] < FirstDriveLetter) ||
4173  (driveLetterName.Buffer[0] > LastDriveLetter) ||
4174  (driveLetterName.Buffer[1] != ':'))
4175  {
4177  }
4178  }
4179 
4180  if (NT_SUCCESS(status))
4181  {
4182  status = WdfRequestRetrieveOutputBuffer(Request,
4183  RequestParameters.Parameters.DeviceIoControl.OutputBufferLength,
4184  &suggestedName,
4185  NULL);
4186  }
4187 
4188  if (NT_SUCCESS(status))
4189  {
4190  RtlZeroMemory(suggestedName, RequestParameters.Parameters.DeviceIoControl.OutputBufferLength);
4191  suggestedName->UseOnlyIfThereAreNoOtherLinks = TRUE;
4192  suggestedName->NameLength = 28;
4193 
4195 
4196  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength < *DataLength)
4197  {
4200  }
4201  }
4202 
4203  if (NT_SUCCESS(status))
4204  {
4206  L"\\Registry\\Machine\\System\\DISK",
4207  valueName);
4208 
4209  RtlCopyMemory(suggestedName->Name, L"\\DosDevices\\", 24);
4210  suggestedName->Name[12] = driveLetterName.Buffer[0];
4211  suggestedName->Name[13] = ':';
4212  }
4213 
4214  FREE_POOL(valueName);
4215 
4216  return status;
4217 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
LONG NTSTATUS
Definition: precomp.h:26
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
#define RTL_QUERY_REGISTRY_TYPECHECK
#define STATUS_NOT_FOUND
Definition: shellext.h:72
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CDROM_TAG_STRINGS
Definition: cdrom.h:743
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static const WCHAR L[]
Definition: oid.c:1250
NTSYSAPI NTSTATUS WINAPI RtlDeleteRegistryValue(ULONG, PCWSTR, PCWSTR)
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
#define LastDriveLetter
Definition: ioctl.c:41
struct _MOUNTDEV_SUGGESTED_LINK_NAME MOUNTDEV_SUGGESTED_LINK_NAME
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define RTL_QUERY_REGISTRY_TYPECHECK_SHIFT
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NULL
Definition: types.h:112
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define FirstDriveLetter
Definition: ioctl.c:40
#define STATUS_SUCCESS
Definition: shellext.h:65
#define REG_NONE
Definition: nt_native.h:1492
#define RTL_QUERY_REGISTRY_REQUIRED
Definition: nt_native.h:132
static SERVICE_STATUS status
Definition: service.c:31
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144
#define REG_SZ
Definition: layer.c:22
Definition: ps.c:97

Referenced by RequestDispatchProcessDirectly().

◆ RequestHandleMountQueryUniqueId()

NTSTATUS RequestHandleMountQueryUniqueId ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters,
_Out_ size_t DataLength 
)

Definition at line 3939 of file ioctl.c.

3963 {
3965  PMOUNTDEV_UNIQUE_ID uniqueId = NULL;
3966 
3967  *DataLength = 0;
3968 
3969  if (!DeviceExtension->MountedDeviceInterfaceName.Buffer)
3970  {
3972  }
3973  else if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength < sizeof(MOUNTDEV_UNIQUE_ID))
3974  {
3975  *DataLength = sizeof(MOUNTDEV_UNIQUE_ID);
3977  }
3978 
3979  if (NT_SUCCESS(status))
3980  {
3981  status = WdfRequestRetrieveOutputBuffer(Request,
3982  RequestParameters.Parameters.DeviceIoControl.OutputBufferLength,
3983  &uniqueId,
3984  NULL);
3985  }
3986 
3987  if (NT_SUCCESS(status))
3988  {
3989  RtlZeroMemory(uniqueId, RequestParameters.Parameters.DeviceIoControl.OutputBufferLength);
3990 
3991  uniqueId->UniqueIdLength = DeviceExtension->MountedDeviceInterfaceName.Length;
3992 
3993  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength <
3994  (sizeof(USHORT) + DeviceExtension->MountedDeviceInterfaceName.Length))
3995  {
3996  *DataLength = sizeof(MOUNTDEV_UNIQUE_ID);
3998  }
3999  }
4000 
4001  if (NT_SUCCESS(status))
4002  {
4003  RtlCopyMemory(uniqueId->UniqueId,
4004  DeviceExtension->MountedDeviceInterfaceName.Buffer,
4005  uniqueId->UniqueIdLength);
4006 
4007  *DataLength = sizeof(USHORT) + uniqueId->UniqueIdLength;
4009  }
4010 
4011  return status;
4012 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
USHORT UniqueIdLength
Definition: imports.h:138
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
struct _MOUNTDEV_UNIQUE_ID MOUNTDEV_UNIQUE_ID
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned short USHORT
Definition: pedump.c:61
#define NULL
Definition: types.h:112
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
UCHAR UniqueId[1]
Definition: imports.h:139
Definition: ps.c:97

Referenced by RequestDispatchProcessDirectly().

◆ RequestHandleQueryPropertyDeviceUniqueId()

NTSTATUS RequestHandleQueryPropertyDeviceUniqueId ( _In_ WDFDEVICE  Device,
_In_ WDFREQUEST  Request 
)

Definition at line 2799 of file ioctl.c.

2821 {
2823  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(Device);
2824  PSTORAGE_PROPERTY_QUERY inputBuffer = NULL;
2825  PSTORAGE_DESCRIPTOR_HEADER descHeader = NULL;
2826  size_t outLength = 0;
2827  WDF_REQUEST_PARAMETERS requestParameters;
2828 
2829  // Get the Request parameters
2830  WDF_REQUEST_PARAMETERS_INIT(&requestParameters);
2831  WdfRequestGetParameters(Request, &requestParameters);
2832 
2833  status = WdfRequestRetrieveInputBuffer(Request,
2834  requestParameters.Parameters.DeviceIoControl.InputBufferLength,
2835  &inputBuffer,
2836  NULL);
2837 
2838  if (NT_SUCCESS(status))
2839  {
2840  BOOLEAN overflow = FALSE;
2841  BOOLEAN infoFound = FALSE;
2842 
2843  // Must run at less then dispatch.
2845  {
2846  NT_ASSERT(FALSE);
2847  outLength = 0;
2849  }
2850  else if (inputBuffer->QueryType == PropertyExistsQuery)
2851  {
2852  outLength = 0;
2854  }
2855  else if (inputBuffer->QueryType != PropertyStandardQuery)
2856  {
2857  outLength = 0;
2859  }
2860  else
2861  {
2862  // Check AdditionalParameters validity.
2863  if (inputBuffer->AdditionalParameters[0] == DUID_INCLUDE_SOFTWARE_IDS)
2864  {
2865  // Do nothing
2866  }
2867  else if (inputBuffer->AdditionalParameters[0] == DUID_HARDWARE_IDS_ONLY)
2868  {
2869  // Do nothing
2870  }
2871  else
2872  {
2873  outLength = 0;
2875  }
2876 
2877  if (NT_SUCCESS(status) &&
2878  (outLength < sizeof(STORAGE_DESCRIPTOR_HEADER)))
2879  {
2880  outLength = 0;
2882  }
2883  }
2884 
2885  // From this point forward the status depends on the overflow
2886  // and infoFound flags.
2887  if (NT_SUCCESS(status))
2888  {
2889  outLength = requestParameters.Parameters.DeviceIoControl.OutputBufferLength;
2890  status = WdfRequestRetrieveOutputBuffer(Request,
2891  requestParameters.Parameters.DeviceIoControl.OutputBufferLength,
2892  &descHeader,
2893  NULL);
2894  }
2895 
2896  if (NT_SUCCESS(status))
2897  {
2898  RtlZeroMemory(descHeader, outLength);
2899 
2900  descHeader->Version = DUID_VERSION_1;
2901  descHeader->Size = sizeof(STORAGE_DEVICE_UNIQUE_IDENTIFIER);
2902 
2903  // Try to build device unique id from StorageDeviceIdProperty.
2904  status = RequestDuidGetDeviceIdProperty(deviceExtension,
2905  Request,
2906  requestParameters,
2907  &outLength);
2908 
2910  {
2911  overflow = TRUE;
2912  }
2913 
2914  if (NT_SUCCESS(status))
2915  {
2916  infoFound = TRUE;
2917  }
2918 
2919  // Try to build device unique id from StorageDeviceProperty.
2920  status = RequestDuidGetDeviceProperty(deviceExtension,
2921  Request,
2922  requestParameters,
2923  &outLength);
2924 
2926  {
2927  overflow = TRUE;
2928  }
2929 
2930  if (NT_SUCCESS(status))
2931  {
2932  infoFound = TRUE;
2933  }
2934 
2935  // Return overflow, success, or a generic error.
2936  if (overflow)
2937  {
2938  // If output buffer is STORAGE_DESCRIPTOR_HEADER, then return
2939  // success to the user. Otherwise, send an error so the user
2940  // knows a larger buffer is required.
2941  if (outLength == sizeof(STORAGE_DESCRIPTOR_HEADER))
2942  {
2944  }
2945  else
2946  {
2947  outLength = (ULONG)WdfRequestGetInformation(Request);
2949  }
2950 
2951  }
2952  else if (infoFound)
2953  {
2955 
2956  // Exercise the compare routine. This should always succeed.
2958  (PSTORAGE_DEVICE_UNIQUE_IDENTIFIER)descHeader));
2959 
2960  }
2961  else
2962  {
2964  }
2965  }
2966  }
2967 
2968  RequestCompletion(deviceExtension, Request, status, outLength);
2969 
2970  return status;
2971 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
return STATUS_NOT_SUPPORTED
* PSTORAGE_DESCRIPTOR_HEADER
Definition: ntddstor.h:560
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
FORCEINLINE DUID_MATCH_STATUS CompareStorageDuids(_In_ PSTORAGE_DEVICE_UNIQUE_IDENTIFIER Duid1, _In_ PSTORAGE_DEVICE_UNIQUE_IDENTIFIER Duid2)
Definition: storduid.h:56
#define DUID_HARDWARE_IDS_ONLY
Definition: storduid.h:22
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
NTSTATUS RequestDuidGetDeviceIdProperty(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: common.c:2797
VOID RequestCompletion(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ NTSTATUS Status, _In_ ULONG_PTR Information)
Definition: common.c:3439
#define FALSE
Definition: types.h:117
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
#define DUID_VERSION_1
Definition: storduid.h:20
unsigned char BOOLEAN
struct _STORAGE_DEVICE_UNIQUE_IDENTIFIER STORAGE_DEVICE_UNIQUE_IDENTIFIER
#define STATUS_NOT_FOUND
Definition: shellext.h:72
#define STATUS_INVALID_LEVEL
Definition: ntstatus.h:564
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
STORAGE_DESCRIPTOR_HEADER
Definition: ntddstor.h:560
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
STORAGE_QUERY_TYPE QueryType
Definition: ntddstor.h:553
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define NULL
Definition: types.h:112
FORCEINLINE VOID WDF_REQUEST_PARAMETERS_INIT(_Out_ PWDF_REQUEST_PARAMETERS Parameters)
Definition: wdfrequest.h:211
UCHAR AdditionalParameters[1]
Definition: ntddstor.h:554
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
NTSTATUS RequestDuidGetDeviceProperty(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
Definition: common.c:2888
#define DUID_INCLUDE_SOFTWARE_IDS
Definition: storduid.h:23
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

Referenced by RequestDispatchSpecialIoctls().

◆ RequestHandleQueryPropertyRetrieveCachedData()

NTSTATUS RequestHandleQueryPropertyRetrieveCachedData ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters,
_Out_ size_t DataLength 
)

Definition at line 2628 of file ioctl.c.

2652 {
2654  PSTORAGE_PROPERTY_QUERY inputBuffer = NULL;
2655 
2656  *DataLength = 0;
2657 
2658  status = WdfRequestRetrieveInputBuffer(Request,
2659  RequestParameters.Parameters.DeviceIoControl.InputBufferLength,
2660  &inputBuffer,
2661  NULL);
2662 
2663  if (NT_SUCCESS(status))
2664  {
2665  if (inputBuffer->PropertyId == StorageDeviceProperty)
2666  {
2667  // check output buffer length
2668  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength == 0)
2669  {
2670  // According to MSDN, an output buffer of size 0 can be used to determine if a property exists
2671  // so this must be a success case with no data transferred
2672  *DataLength = 0;
2674  }
2675  else if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength < sizeof(STORAGE_DESCRIPTOR_HEADER))
2676  {
2677  // Buffer too small
2678  *DataLength = DeviceExtension->DeviceDescriptor->Size;
2680  }
2681  else
2682  {
2683  PSTORAGE_DEVICE_DESCRIPTOR outputDescriptor = NULL;
2684  CHAR* localDescriptorBuffer = (CHAR*)DeviceExtension->DeviceDescriptor;
2685 
2686  status = WdfRequestRetrieveOutputBuffer(Request,
2687  RequestParameters.Parameters.DeviceIoControl.OutputBufferLength,
2688  &outputDescriptor,
2689  NULL);
2690 
2691  if (NT_SUCCESS(status))
2692  {
2693  // transfer as much data out as the buffer will allow
2695  DeviceExtension->DeviceDescriptor->Size);
2696 
2697  RtlCopyMemory(outputDescriptor,
2698  DeviceExtension->DeviceDescriptor,
2699  *DataLength);
2700 
2701  // walk through and update offset variables to reflect data that didn't make it into the output buffer
2702  if ((*DataLength >= RTL_SIZEOF_THROUGH_FIELD(STORAGE_DEVICE_DESCRIPTOR, VendorIdOffset)) &&
2703  (DeviceExtension->DeviceDescriptor->VendorIdOffset != 0) &&
2704  (DeviceExtension->DeviceDescriptor->VendorIdOffset != 0xFFFFFFFF))
2705  {
2706  // set VendorIdOffset appropriately
2707  if (*DataLength <
2708  (DeviceExtension->DeviceDescriptor->VendorIdOffset + strlen(localDescriptorBuffer + DeviceExtension->DeviceDescriptor->VendorIdOffset)))
2709  {
2710  outputDescriptor->VendorIdOffset = 0;
2711  }
2712  }
2713 
2714  if ((*DataLength >= RTL_SIZEOF_THROUGH_FIELD(STORAGE_DEVICE_DESCRIPTOR, ProductIdOffset)) &&
2715  (DeviceExtension->DeviceDescriptor->ProductIdOffset != 0) &&
2716  (DeviceExtension->DeviceDescriptor->ProductIdOffset != 0xFFFFFFFF))
2717  {
2718  // set ProductIdOffset appropriately
2719  if (*DataLength <
2720  (DeviceExtension->DeviceDescriptor->ProductIdOffset + strlen(localDescriptorBuffer + DeviceExtension->DeviceDescriptor->ProductIdOffset)))
2721  {
2722  outputDescriptor->ProductIdOffset = 0;
2723  }
2724  }
2725 
2726  if ((*DataLength >= RTL_SIZEOF_THROUGH_FIELD(STORAGE_DEVICE_DESCRIPTOR, ProductRevisionOffset)) &&
2727  (DeviceExtension->DeviceDescriptor->ProductRevisionOffset != 0) &&
2728  (DeviceExtension->DeviceDescriptor->ProductRevisionOffset != 0xFFFFFFFF))
2729  {
2730  // set ProductRevisionOffset appropriately
2731  if (*DataLength <
2732  (DeviceExtension->DeviceDescriptor->ProductRevisionOffset + strlen(localDescriptorBuffer + DeviceExtension->DeviceDescriptor->ProductRevisionOffset)))
2733  {
2734  outputDescriptor->ProductRevisionOffset = 0;
2735  }
2736  }
2737 
2738  if ((*DataLength >= RTL_SIZEOF_THROUGH_FIELD(STORAGE_DEVICE_DESCRIPTOR, SerialNumberOffset)) &&
2739  (DeviceExtension->DeviceDescriptor->SerialNumberOffset != 0) &&
2740  (DeviceExtension->DeviceDescriptor->SerialNumberOffset != 0xFFFFFFFF))
2741  {
2742  // set SerialNumberOffset appropriately
2743  if (*DataLength <
2744  (DeviceExtension->DeviceDescriptor->SerialNumberOffset + strlen(localDescriptorBuffer + DeviceExtension->DeviceDescriptor->SerialNumberOffset)))
2745  {
2746  // NOTE: setting this to 0 since that is what most port drivers do
2747  // [this could cause issues with SCSI port devices whose clients expect -1 in this field]
2748  outputDescriptor->SerialNumberOffset = 0;
2749  }
2750  }
2752  }
2753  }
2754  } //end of StorageDeviceProperty
2755  else if (inputBuffer->PropertyId == StorageAdapterProperty)
2756  {
2757  if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength == 0)
2758  {
2759  // According to MSDN, an output buffer of size 0 can be used to determine if a property exists
2760  // so this must be a success case with no data transferred
2761  *DataLength = 0;
2763  }
2764  else if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength < sizeof(STORAGE_DESCRIPTOR_HEADER))
2765  {
2766  // Buffer too small
2767  *DataLength = DeviceExtension->AdapterDescriptor->Size;
2769  }
2770  else
2771  {
2772  PSTORAGE_ADAPTER_DESCRIPTOR outputDescriptor = NULL;
2773 
2774  status = WdfRequestRetrieveOutputBuffer(Request,
2775  RequestParameters.Parameters.DeviceIoControl.OutputBufferLength,
2776  &outputDescriptor,
2777  NULL);
2778  if (NT_SUCCESS(status))
2779  {
2780  // copy as much data out as the buffer will allow
2782  DeviceExtension->AdapterDescriptor->Size);
2783 
2784  RtlCopyMemory(outputDescriptor,
2785  DeviceExtension->AdapterDescriptor,
2786  *DataLength);
2787 
2788  // set status
2790  }
2791  }
2792  }
2793  }
2794 
2795  return status;
2796 }
* PSTORAGE_ADAPTER_DESCRIPTOR
Definition: ntddstor.h:599
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
* PSTORAGE_DEVICE_DESCRIPTOR
Definition: ntddstor.h:576
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
STORAGE_DEVICE_DESCRIPTOR
Definition: ntddstor.h:576
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
Definition: ntbasedef.h:672
STORAGE_DESCRIPTOR_HEADER
Definition: ntddstor.h:560
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
STORAGE_PROPERTY_ID PropertyId
Definition: ntddstor.h:552
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by RequestDispatchSpecialIoctls().

◆ RequestHandleQueryPropertyWriteCache()

NTSTATUS RequestHandleQueryPropertyWriteCache ( _In_ WDFDEVICE  Device,
_In_ WDFREQUEST  Request 
)

Definition at line 2974 of file ioctl.c.

2994 {
2996  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(Device);
2998  PSTORAGE_WRITE_CACHE_PROPERTY writeCache = NULL;
2999  PMODE_PARAMETER_HEADER modeData = NULL;
3000  PMODE_CACHING_PAGE pageData = NULL;
3001  size_t length = 0;
3002  ULONG information = 0;
3003  PSCSI_REQUEST_BLOCK srb = NULL;
3004  WDF_REQUEST_PARAMETERS requestParameters;
3005 
3006  // Get the Request parameters
3007  WDF_REQUEST_PARAMETERS_INIT(&requestParameters);
3008  WdfRequestGetParameters(Request, &requestParameters);
3009 
3010  status = WdfRequestRetrieveInputBuffer(Request,
3011  requestParameters.Parameters.DeviceIoControl.InputBufferLength,
3012  &query,
3013  NULL);
3014 
3015  if (NT_SUCCESS(status))
3016  {
3017 
3018  // Must run at less then dispatch.
3020  {
3021  NT_ASSERT(FALSE);
3023  }
3024  else if (query->QueryType == PropertyExistsQuery)
3025  {
3026  information = 0;
3028  }
3029  else if (query->QueryType != PropertyStandardQuery)
3030  {
3032  }
3033  }
3034 
3035  if (NT_SUCCESS(status))
3036  {
3037  length = requestParameters.Parameters.DeviceIoControl.OutputBufferLength;
3038 
3039  if (length < sizeof(STORAGE_DESCRIPTOR_HEADER))
3040  {
3042  }
3043  }
3044 
3045  if (NT_SUCCESS(status))
3046  {
3047  status = WdfRequestRetrieveOutputBuffer(Request,
3048  requestParameters.Parameters.DeviceIoControl.OutputBufferLength,
3049  &writeCache,
3050  NULL);
3051  }
3052 
3053  if (NT_SUCCESS(status))
3054  {
3055  RtlZeroMemory(writeCache, length);
3056 
3057  // Set version and required size.
3058  writeCache->Version = sizeof(STORAGE_WRITE_CACHE_PROPERTY);
3059  writeCache->Size = sizeof(STORAGE_WRITE_CACHE_PROPERTY);
3060 
3061  if (length < sizeof(STORAGE_WRITE_CACHE_PROPERTY))
3062  {
3063  // caller only wants header information, bail out.
3066 
3067  RequestCompletion(deviceExtension, Request, status, information);
3068  return status;
3069  }
3070  }
3071 
3072  if (NT_SUCCESS(status))
3073  {
3074  srb = ExAllocatePoolWithTag(NonPagedPoolNx,
3075  sizeof(SCSI_REQUEST_BLOCK) +
3076  (sizeof(ULONG_PTR) * 2),
3077  CDROM_TAG_SRB);
3078 
3079  if (srb == NULL)
3080  {
3082  }
3083  }
3084 
3085  if (NT_SUCCESS(status))
3086  {
3087  RtlZeroMemory(srb, sizeof(SCSI_REQUEST_BLOCK));
3088 
3089  // Set known values
3090  writeCache->NVCacheEnabled = FALSE;
3091  writeCache->UserDefinedPowerProtection = TEST_FLAG(deviceExtension->DeviceFlags, DEV_POWER_PROTECTED);
3092 
3093  // Check for flush cache support by sending a sync cache command
3094  // to the device.
3095 
3096  // Set timeout value and mark the request as not being a tagged request.
3098  srb->TimeOutValue = TimeOutValueGetCapValue(deviceExtension->TimeOutValue, 4);
3099  srb->QueueTag = SP_UNTAGGED;
3101  srb->SrbFlags = deviceExtension->SrbFlags;
3102 
3104  srb->CdbLength = 10;
3105 
3106  srb->Cdb[0] = SCSIOP_SYNCHRONIZE_CACHE;
3107 
3108  status = DeviceSendSrbSynchronously(Device,
3109  srb,
3110  NULL,
3111  0,
3112  TRUE, //flush drive cache
3113  Request);
3114 
3115  if (NT_SUCCESS(status))
3116  {
3117  writeCache->FlushCacheSupported = TRUE;
3118  }
3119  else
3120  {
3121  // Device does not support sync cache
3122  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
3123  "RequestHandleQueryPropertyWriteCache: Synchronize cache failed with status 0x%X\n", status));
3124  writeCache->FlushCacheSupported = FALSE;
3125 
3126  // Reset the status if there was any failure
3128  }
3129 
3130  modeData = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned,
3133 
3134  if (modeData == NULL)
3135  {
3136  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
3137  "RequestHandleQueryPropertyWriteCache: Unable to allocate mode data buffer\n"));
3139  }
3140  }
3141 
3142  if (NT_SUCCESS(status))
3143  {
3145 
3146  length = DeviceRetrieveModeSenseUsingScratch(deviceExtension,
3147  (PCHAR)modeData,
3151 
3152  if (length < sizeof(MODE_PARAMETER_HEADER))
3153  {
3154  // Retry the request in case of a check condition.
3155  length = DeviceRetrieveModeSenseUsingScratch(deviceExtension,
3156  (PCHAR)modeData,
3160 
3161  if (length < sizeof(MODE_PARAMETER_HEADER))
3162  {
3163  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL, "RequestHandleQueryPropertyWriteCache: Mode Sense failed\n"));
3165  }
3166  }
3167  }
3168 
3169  if (NT_SUCCESS(status))
3170  {
3171  // If the length is greater than length indicated by the mode data reset
3172  // the data to the mode data.
3173  if (length > (ULONG) (modeData->ModeDataLength + 1))
3174  {
3175  length = modeData->ModeDataLength + 1;
3176  }
3177 
3178  // Look for caching page in the returned mode page data.
3179  pageData = ModeSenseFindSpecificPage((PCHAR)modeData,
3180  length,
3182  TRUE);
3183 
3184  // Check if valid caching page exists.
3185  if (pageData == NULL)
3186  {
3187  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL, "RequestHandleQueryPropertyWriteCache: Unable to find caching mode page.\n"));
3188 
3189  // Set write cache value as unknown.
3190  writeCache->WriteCacheEnabled = WriteCacheEnableUnknown;
3191  writeCache->WriteCacheType = WriteCacheTypeUnknown;
3192  }
3193  else
3194  {
3195  writeCache->WriteCacheEnabled = pageData->WriteCacheEnable
3198 
3199  writeCache->WriteCacheType = pageData->WriteCacheEnable
3202  }
3203 
3204  // Check write through support.
3206  {
3207  writeCache->WriteThroughSupported = WriteThroughSupported;
3208  }
3209  else
3210  {
3211  writeCache->WriteThroughSupported = WriteThroughNotSupported;
3212  }
3213 
3214  // Get the changeable caching mode page and check write cache is changeable.
3216 
3217  length = DeviceRetrieveModeSenseUsingScratch(deviceExtension,
3218  (PCHAR) modeData,
3222 
3223  if (length < sizeof(MODE_PARAMETER_HEADER))
3224  {
3225  // Retry the request in case of a check condition.
3226  length = DeviceRetrieveModeSenseUsingScratch(deviceExtension,
3227  (PCHAR) modeData,
3231 
3232  if (length < sizeof(MODE_PARAMETER_HEADER))
3233  {
3234  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL, "RequestHandleQueryPropertyWriteCache: Mode Sense failed\n"));
3235 
3236  // If the device fails to return changeable pages, then
3237  // set the write cache changeable value to unknown.
3238  writeCache->WriteCacheChangeable = WriteCacheChangeUnknown;
3240  }
3241  }
3242  }
3243 
3244  if (NT_SUCCESS(status))
3245  {
3246  // If the length is greater than length indicated by the mode data reset
3247  // the data to the mode data.
3248  if (length > (ULONG) (modeData->ModeDataLength + 1))
3249  {
3250  length = modeData->ModeDataLength + 1;
3251  }
3252 
3253  // Look for caching page in the returned mode page data.
3254  pageData = ModeSenseFindSpecificPage((PCHAR)modeData,
3255  length,
3257  TRUE);
3258  // Check if valid caching page exists.
3259  if (pageData == NULL)
3260  {
3261  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL, "RequestHandleQueryPropertyWriteCache: Unable to find caching mode page.\n"));
3262 
3263  // Set write cache changeable value to unknown.
3264  writeCache->WriteCacheChangeable = WriteCacheChangeUnknown;
3265  }
3266  else
3267  {
3268  writeCache->WriteCacheChangeable = pageData->WriteCacheEnable
3271  }
3272 
3274 
3275  }
3276 
3277  FREE_POOL(srb);
3278  FREE_POOL(modeData);
3279 
3280  RequestCompletion(deviceExtension, Request, status, information);
3281 
3282  return status;
3283 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
signed char * PCHAR
Definition: retypes.h:7
return STATUS_NOT_SUPPORTED
#define SCSIOP_SYNCHRONIZE_CACHE
Definition: cdrw_hw.h:918
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
ULONG SrbFlags
Definition: srb.h:252
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
* PSTORAGE_WRITE_CACHE_PROPERTY
Definition: ntddstor.h:898
UCHAR WriteCacheEnable
Definition: cdrw_hw.h:2779
UCHAR Cdb[16]
Definition: srb.h:271
#define MODE_PAGE_CACHING
Definition: cdrw_hw.h:846
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
UCHAR CdbLength
Definition: srb.h:250
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
UCHAR QueueAction
Definition: srb.h:249
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
ULONG TimeOutValue
Definition: srb.h:254
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define SP_UNTAGGED
Definition: srb.h:225
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
VOID RequestCompletion(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ NTSTATUS Status, _In_ ULONG_PTR Information)
Definition: common.c:3439
#define FALSE
Definition: types.h:117
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
UCHAR DeviceSpecificParameter
Definition: cdrw_hw.h:2507
UCHAR QueueTag
Definition: srb.h:248
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
#define STATUS_INVALID_LEVEL
Definition: ntstatus.h:564
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MODE_DSP_FUA_SUPPORTED
Definition: cdrw_hw.h:2522
UCHAR Function
Definition: srb.h:242
USHORT Length
Definition: srb.h:241
STORAGE_WRITE_CACHE_PROPERTY
Definition: ntddstor.h:898
#define MODE_SENSE_CHANGEABLE_VALUES
Definition: cdrw_hw.h:860
FORCEINLINE ULONG TimeOutValueGetCapValue(_In_ ULONG TimeOutValue, _In_ ULONG Times)
Definition: cdrom.h:1569
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
STORAGE_DESCRIPTOR_HEADER
Definition: ntddstor.h:560
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define CDROM_TAG_MODE_DATA
Definition: cdrom.h:737
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define DEV_POWER_PROTECTED
Definition: cdrom.h:143
#define CDROM_TAG_SRB
Definition: cdrom.h:742
#define SRB_SIMPLE_TAG_REQUEST
Definition: srb.h:415
#define SCSI_REQUEST_BLOCK_SIZE
Definition: srb.h:274
#define MODE_PAGE_DATA_SIZE
Definition: cdromp.h:376
#define NULL
Definition: types.h:112
FORCEINLINE VOID WDF_REQUEST_PARAMETERS_INIT(_Out_ PWDF_REQUEST_PARAMETERS Parameters)
Definition: wdfrequest.h:211
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
static PDB_INFORMATION information
Definition: db.cpp:178
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
#define MODE_SENSE_CURRENT_VALUES
Definition: cdrw_hw.h:859
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

Referenced by RequestDispatchSpecialIoctls().

◆ RequestHandleReadWrite()

NTSTATUS RequestHandleReadWrite ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters 
)

Definition at line 6353 of file ioctl.c.

6375 {
6377  PCDROM_DATA cdData = &(DeviceExtension->DeviceAdditionalData);
6378 
6379  size_t transferByteCount = 0;
6380  PIRP irp = NULL;
6381  PIO_STACK_LOCATION currentStack = NULL;
6382 
6384 
6385 
6386  irp = WdfRequestWdmGetIrp(Request);
6387  currentStack = IoGetCurrentIrpStackLocation(irp);
6388  dataBuffer = MmGetMdlVirtualAddress(irp->MdlAddress);
6389 
6390  if (NT_SUCCESS(status))
6391  {
6393  {
6394  transferByteCount = RequestParameters.Parameters.Read.Length;
6395  }
6396  else
6397  {
6398  transferByteCount = RequestParameters.Parameters.Write.Length;
6399  }
6400 
6401  if (transferByteCount == 0)
6402  {
6403  // Several parts of the code turn 0 into 0xffffffff,
6404  // so don't process a zero-length request any further.
6406  RequestCompletion(DeviceExtension, Request, status, 0);
6407  return status;
6408  }
6409 
6410  // Add partition byte offset to make starting byte relative to
6411  // beginning of disk.
6412  currentStack->Parameters.Read.ByteOffset.QuadPart += (DeviceExtension->StartingOffset.QuadPart);
6413 
6414  //not very necessary as the starting offset for CD/DVD device is always 0.
6416  {
6417  RequestParameters.Parameters.Read.DeviceOffset = currentStack->Parameters.Read.ByteOffset.QuadPart;
6418  }
6419  else
6420  {
6421  RequestParameters.Parameters.Write.DeviceOffset = currentStack->Parameters.Write.ByteOffset.QuadPart;
6422  }
6423  }
6424 
6425  if (NT_SUCCESS(status))
6426  {
6427  ULONG entireXferLen = currentStack->Parameters.Read.Length;
6428  ULONG maxLength = 0;
6429  ULONG packetsCount = 0;
6430 
6431  PCDROM_SCRATCH_READ_WRITE_CONTEXT readWriteContext;
6432  PCDROM_REQUEST_CONTEXT requestContext;
6433  PCDROM_REQUEST_CONTEXT originalRequestContext;
6434 
6435  // get the count of packets we need to send.
6436  if ((((ULONG_PTR)dataBuffer) & (PAGE_SIZE-1)) == 0)
6437  {
6439  }
6440  else
6441  {
6443  }
6444 
6445  packetsCount = entireXferLen / maxLength;
6446 
6447  if (entireXferLen % maxLength != 0)
6448  {
6449  packetsCount++;
6450  }
6451 
6452  originalRequestContext = RequestGetContext(Request);
6453 
6454 
6455  ScratchBuffer_BeginUse(DeviceExtension);
6456 
6457  readWriteContext = &DeviceExtension->ScratchContext.ScratchReadWriteContext;
6458  requestContext = RequestGetContext(DeviceExtension->ScratchContext.ScratchRequest);
6459 
6460  readWriteContext->PacketsCount = packetsCount;
6461  readWriteContext->EntireXferLen = entireXferLen;
6462  readWriteContext->MaxLength = maxLength;
6463  readWriteContext->StartingOffset = currentStack->Parameters.Read.ByteOffset;
6464  readWriteContext->DataBuffer = dataBuffer;
6465  readWriteContext->TransferedBytes = 0;
6466  readWriteContext->IsRead = (RequestParameters.Type == WdfRequestTypeRead);
6467 
6468  requestContext->OriginalRequest = Request;
6469  requestContext->DeviceExtension = DeviceExtension;
6470 
6471  //
6472  // Setup the READ/WRITE fields in the original request which is what
6473  // we use to properly synchronize cancellation logic between the
6474  // cancel callback and the timer routine.
6475  //
6476 
6477  originalRequestContext->ReadWriteIsCompleted = FALSE;
6478  originalRequestContext->ReadWriteRetryInitialized = FALSE;
6479  originalRequestContext->DeviceExtension = DeviceExtension;
6480 
6481  status = ScratchBuffer_PerformNextReadWrite(DeviceExtension, TRUE);
6482 
6483  // We do not call ScratchBuffer_EndUse here, because we're not releasing the scratch SRB.
6484  // It will be released in the completion routine.
6485  }
6486 
6487  return status;
6488 }
LARGE_INTEGER StartingOffset
Definition: cdrom.h:285
#define MmGetMdlVirtualAddress(_Mdl)
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
WDF_REQUEST_TYPE Type
Definition: wdfrequest.h:142
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
NTSTATUS ScratchBuffer_PerformNextReadWrite(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ BOOLEAN FirstTry)
Definition: scratch.c:429
PVOID dataBuffer
struct _WDF_REQUEST_PARAMETERS::@3670::@3673 Write
uint32_t ULONG_PTR
Definition: typedefs.h:65
VOID RequestCompletion(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ NTSTATUS Status, _In_ ULONG_PTR Information)
Definition: common.c:3439
#define ScratchBuffer_BeginUse(context)
Definition: scratch.h:87
BOOLEAN ReadWriteIsCompleted
Definition: cdrom.h:665
#define FALSE
Definition: types.h:117
struct _WDF_REQUEST_PARAMETERS::@3670::@3672 Read
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
BOOLEAN ReadWriteRetryInitialized
Definition: cdrom.h:666
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG MaxPageAlignedTransferBytes
Definition: cdrom.h:360
#define PAGE_SIZE
Definition: env_spec_w32.h:49
PCDROM_DEVICE_EXTENSION DeviceExtension
Definition: cdrom.h:631
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define NULL
Definition: types.h:112
GLsizei maxLength
Definition: glext.h:6877
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
static SERVICE_STATUS status
Definition: service.c:31
FxIrp * irp
ULONG MaxUnalignedTransferBytes
Definition: cdrom.h:361
WDFREQUEST OriginalRequest
Definition: cdrom.h:633
Definition: ps.c:97

Referenced by ReadWriteWorkItemRoutine(), and SequentialQueueEvtIoReadWrite().

◆ RequestHandleSetHotPlugInfo()

NTSTATUS RequestHandleSetHotPlugInfo ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters,
_Out_ size_t DataLength 
)

Definition at line 5392 of file ioctl.c.

5416 {
5419 
5420  *DataLength = 0;
5421 
5422  if (RequestParameters.Parameters.DeviceIoControl.InputBufferLength <
5423  sizeof(STORAGE_HOTPLUG_INFO))
5424  {
5425  // Indicate unsuccessful status and no data transferred.
5427  }
5428 
5429  if (NT_SUCCESS(status))
5430  {
5431  status = WdfRequestRetrieveInputBuffer(Request,
5432  RequestParameters.Parameters.DeviceIoControl.InputBufferLength,
5433  &info,
5434  NULL);
5435  }
5436 
5437  if (NT_SUCCESS(status))
5438  {
5439  if (info->Size != DeviceExtension->PrivateFdoData->HotplugInfo.Size)
5440  {
5442  }
5443 
5444  if (info->MediaRemovable != DeviceExtension->PrivateFdoData->HotplugInfo.MediaRemovable)
5445  {
5447  }
5448 
5449  if (info->MediaHotplug != DeviceExtension->PrivateFdoData->HotplugInfo.MediaHotplug)
5450  {
5452  }
5453 
5454  if (info->WriteCacheEnableOverride != DeviceExtension->PrivateFdoData->HotplugInfo.WriteCacheEnableOverride)
5455  {
5457  }
5458  }
5459 
5460  if (NT_SUCCESS(status))
5461  {
5462  DeviceExtension->PrivateFdoData->HotplugInfo.DeviceHotplug = info->DeviceHotplug;
5463 
5464  // Store the user-defined override in the registry
5465  DeviceSetParameter(DeviceExtension,
5469  }
5470 
5471  return status;
5472 }
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
LONG NTSTATUS
Definition: precomp.h:26
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:477
#define CLASSP_REG_SUBKEY_NAME
Definition: cdromp.h:120
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Parameters
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
#define STATUS_INVALID_PARAMETER_5
Definition: ntstatus.h:479
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
#define NULL
Definition: types.h:112
#define CLASSP_REG_REMOVAL_POLICY_VALUE_NAME
Definition: cdromp.h:126
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by RequestDispatchProcessDirectly().

◆ RequestHandleUnknownIoctl()

NTSTATUS RequestHandleUnknownIoctl ( _In_ WDFDEVICE  Device,
_In_ WDFREQUEST  Request 
)

◆ RequestIsRealtimeStreaming()

BOOLEAN RequestIsRealtimeStreaming ( _In_ WDFREQUEST  Request,
_In_ BOOLEAN  IsReadRequest 
)

Definition at line 6050 of file ioctl.c.

6072 {
6073  BOOLEAN useStreaming = FALSE;
6074 
6075  if (!useStreaming) {
6076  //
6077  // Check if we're required to use Streaming via I/O Stack Location flags
6078  //
6079  UCHAR currentStackLocationFlags = 0;
6080  currentStackLocationFlags = RequestGetCurrentStackLocationFlags(Request);
6081 
6082  useStreaming = TEST_FLAG(currentStackLocationFlags, SL_REALTIME_STREAM);
6083  }
6084 
6085  if (!useStreaming) {
6086  //
6087  // Check if we were previously requested to enforce Streaming for
6088  // the file handle through which this request was sent.
6089  //
6090 
6091  WDFFILEOBJECT fileObject;
6092  PFILE_OBJECT_CONTEXT fileObjectContext;
6093 
6094  fileObject = WdfRequestGetFileObject(Request);
6095 
6096  if (fileObject != NULL) {
6097  fileObjectContext = FileObjectGetContext(fileObject);
6098  NT_ASSERT(fileObjectContext != NULL);
6099 
6100  if (IsReadRequest && fileObjectContext->EnforceStreamingRead)
6101  {
6102  useStreaming = TRUE;
6103  }
6104 
6105  if (!IsReadRequest && fileObjectContext->EnforceStreamingWrite)
6106  {
6107  useStreaming = TRUE;
6108  }
6109  }
6110  }
6111 
6112  return useStreaming;
6113 }
FORCEINLINE UCHAR RequestGetCurrentStackLocationFlags(_In_ WDFREQUEST Request)
Definition: cdrom.h:1554
#define TRUE
Definition: types.h:120
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define SL_REALTIME_STREAM
Definition: iotypes.h:1827
BOOLEAN EnforceStreamingRead
Definition: cdromp.h:368
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
unsigned char UCHAR
Definition: xmlstorage.h:181
#define NULL
Definition: types.h:112
BOOLEAN EnforceStreamingWrite
Definition: cdromp.h:369
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by RequestValidateReadWrite(), and ScratchBuffer_SetupReadWriteSrb().

◆ RequestValidateAacsBindingNonce()

NTSTATUS RequestValidateAacsBindingNonce ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters,
_Out_ size_t DataLength 
)

Definition at line 2162 of file ioctl.c.

2187 {
2189  PCDROM_DATA cdData = &(DeviceExtension->DeviceAdditionalData);
2190  PAACS_READ_BINDING_NONCE inputBuffer = NULL;
2191 
2192  *DataLength = 0;
2193 
2194  if (!cdData->Mmc.IsAACS)
2195  {
2197  }
2198  else if (RequestParameters.Parameters.DeviceIoControl.InputBufferLength != sizeof(AACS_READ_BINDING_NONCE))
2199  {
2201  }
2202  else if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength < sizeof(AACS_BINDING_NONCE))
2203  {
2204  *DataLength = sizeof(AACS_BINDING_NONCE);
2206  }
2207  else if (RequestParameters.Parameters.DeviceIoControl.OutputBufferLength > sizeof(AACS_BINDING_NONCE))
2208  {
2210  }
2211 
2212  if (NT_SUCCESS(status))
2213  {
2214  status = WdfRequestRetrieveInputBuffer(Request,
2215  RequestParameters.Parameters.DeviceIoControl.InputBufferLength,
2216  &inputBuffer,
2217  NULL);
2218  }
2219 
2220  if (NT_SUCCESS(status))
2221  {
2222  if (inputBuffer->SessionId > MAX_COPY_PROTECT_AGID)
2223  {
2225  }
2226  else if (inputBuffer->NumberOfSectors > 255)
2227  {
2229  }
2230  else if (inputBuffer->StartLba > MAXULONG)
2231  {
2233  }
2234  }
2235 
2236  return status;
2237 }
#define MAX_COPY_PROTECT_AGID
Definition: cdrom.h:712
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
DVD_SESSION_ID SessionId
Definition: ntddcdvd.h:322
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
struct _WDF_REQUEST_PARAMETERS::@3670::@3674 DeviceIoControl
union _WDF_REQUEST_PARAMETERS::@3670 Paramete