ReactOS  0.4.15-dev-1367-g07cc0b5
stream.h File Reference
#include <strmini.h>
#include <debug.h>
Include dependency graph for stream.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  STREAM_CLASS_DRIVER_EXTENSION
 
struct  MEMORY_RESOURCE_LIST
 
struct  STREAM_DEVICE_EXTENSION
 
struct  HW_STREAM_REQUEST_BLOCK_EXT
 

Macros

#define YDEBUG
 
#define STREAMDEBUG_LEVEL   DebugLevelMaximum
 

Typedefs

typedef BOOLEAN(NTAPISYNCHRONIZE_FUNC) (IN PKINTERRUPT Interrupt, IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, IN PVOID SynchronizeContext)
 
typedef struct STREAM_CLASS_DRIVER_EXTENSIONPSTREAM_CLASS_DRIVER_EXTENSION
 
typedef struct MEMORY_RESOURCE_LISTPMEMORY_RESOURCE_LIST
 
typedef struct STREAM_DEVICE_EXTENSIONPSTREAM_DEVICE_EXTENSION
 
typedef struct HW_STREAM_REQUEST_BLOCK_EXTPHW_STREAM_REQUEST_BLOCK_EXT
 

Functions

NTSTATUS NTAPI StreamClassCreateFilter (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI StreamClassPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI StreamClassPower (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI StreamClassSystemControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI StreamClassCleanup (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI StreamClassFlushBuffers (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI StreamClassDeviceControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI StreamClassAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
 
NTSTATUS NTAPI ForwardIrpSynchronous (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
BOOLEAN NTAPI StreamClassSynchronize (IN PKINTERRUPT Interrupt, IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, IN PVOID SynchronizeContext)
 
BOOLEAN NTAPI StreamClassInterruptRoutine (IN PKINTERRUPT Interrupt, IN PVOID ServiceContext)
 
VOID NTAPI StreamClassInterruptDpc (IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 
VOID CompleteIrp (IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
 

Macro Definition Documentation

◆ STREAMDEBUG_LEVEL

#define STREAMDEBUG_LEVEL   DebugLevelMaximum

Definition at line 7 of file stream.h.

◆ YDEBUG

#define YDEBUG

Definition at line 4 of file stream.h.

Typedef Documentation

◆ PHW_STREAM_REQUEST_BLOCK_EXT

◆ PMEMORY_RESOURCE_LIST

◆ PSTREAM_CLASS_DRIVER_EXTENSION

◆ PSTREAM_DEVICE_EXTENSION

◆ SYNCHRONIZE_FUNC

Definition at line 9 of file stream.h.

Function Documentation

◆ CompleteIrp()

VOID CompleteIrp ( IN PIRP  Irp,
IN NTSTATUS  Status,
IN ULONG_PTR  Information 
)

Definition at line 12 of file pnp.c.

16 {
17  Irp->IoStatus.Status = Status;
18  Irp->IoStatus.Information = Information;
20 }
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1044
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
#define IO_NO_INCREMENT
Definition: iotypes.h:581

Referenced by AfdEventReceiveDatagramHandler(), FxPkgIo::DispatchStep1(), FxPkgIo::DispatchStep2(), Ext2LockControl(), StreamClassStartDevice(), UDFCommonDeviceControl(), UDFMountVolume(), and VfatDispatchRequest().

◆ ForwardIrpSynchronous()

NTSTATUS NTAPI ForwardIrpSynchronous ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 29 of file helper.c.

32 {
33  KEVENT Event;
34  PSTREAM_DEVICE_EXTENSION DeviceExt;
36 
38 
39  /* initialize the notification event */
41 
43 
45 
46  /* now call the driver */
48  /* did the request complete yet */
49  if (Status == STATUS_PENDING)
50  {
51  /* not yet, lets wait a bit */
53  Status = Irp->IoStatus.Status;
54  }
55  return Status;
56 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2864
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:450
Status
Definition: gdiplustypes.h:24
#define STATUS_PENDING
Definition: ntstatus.h:82
struct STREAM_DEVICE_EXTENSION * PSTREAM_DEVICE_EXTENSION
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
Definition: wdfrequest.h:893
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
PDEVICE_OBJECT LowerDeviceObject
Definition: stream.h:27

Referenced by StreamClassStartDevice().

◆ StreamClassAddDevice()

NTSTATUS NTAPI StreamClassAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  PhysicalDeviceObject 
)

Definition at line 13 of file driver.c.

16 {
17  PSTREAM_CLASS_DRIVER_EXTENSION DriverObjectExtension;
19  PSTREAM_DEVICE_EXTENSION DeviceExtension;
20  PKSOBJECT_CREATE_ITEM ItemList;
22 
23  /* Fetch driver object extension */
25  if (!DriverObjectExtension)
26  {
27  /* Failed to get driver extension */
29  }
30  /* Allocate Create Item */
31  ItemList = ExAllocatePool(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM));
32  if (!ItemList)
33  {
34  /* Failed to allocated Create Item */
36  }
37 
38  /* Create the FDO */
40  if (!NT_SUCCESS(Status))
41  {
42  /* Failed to create the FDO */
43  ExFreePool(ItemList);
44  return Status;
45  }
46 
47  /* Attach to device stack */
49  if (!LowerDeviceObject)
50  {
51  /* Failed to attach */
53  ExFreePool(ItemList);
54  return STATUS_UNSUCCESSFUL;
55  }
56 
57  /* Zero Create item */
58  RtlZeroMemory(ItemList, sizeof(KSOBJECT_CREATE_ITEM));
59  /* Setup object class */
60  RtlInitUnicodeString(&ItemList->ObjectClass, L"GLOBAL");
61  /* Setup CreateDispatch routine */
62  ItemList->Create = StreamClassCreateFilter;
63 
64  /* Get device extension */
66  /* Zero device extension */
67  RtlZeroMemory(DeviceExtension, sizeof(STREAM_DEVICE_EXTENSION));
68  /* Initialize Ks streaming */
69  Status = KsAllocateDeviceHeader(&DeviceExtension->Header, 1, ItemList);
70  if (!NT_SUCCESS(Status))
71  {
72  /* Cleanup resources */
75  ExFreePool(ItemList);
76  return Status;
77  }
78 
79  /* Store lower device object */
80  DeviceExtension->LowerDeviceObject = LowerDeviceObject;
81 
82  /* Store physical device object */
83  DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
84  /* Store driver object extension */
85  DeviceExtension->DriverExtension = DriverObjectExtension;
86  /* Initialize memory list */
87  InitializeListHead(&DeviceExtension->MemoryResourceList);
88  /* Setup device extension */
89  DeviceExtension->DeviceExtension = (PVOID) (DeviceExtension + 1);
90  /* Init interrupt dpc */
91  KeInitializeDpc(&DeviceExtension->InterruptDpc, StreamClassInterruptDpc, (PVOID)DeviceExtension);
92 
93  /* Set device transfer method */
95  /* Clear init flag */
97 
98  return Status;
99 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define DO_POWER_PAGABLE
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:428
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS NTAPI StreamClassCreateFilter(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filter.c:261
VOID NTAPI StreamClassInterruptDpc(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: pnp.c:74
KSDDKAPI NTSTATUS NTAPI KsAllocateDeviceHeader(OUT KSDEVICE_HEADER *OutHeader, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList OPTIONAL)
Definition: api.c:522
HW_INITIALIZATION_DATA Data
Definition: stream.h:13
LONG NTSTATUS
Definition: precomp.h:26
ULONG DeviceExtensionSize
Definition: srb.h:566
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
KSDEVICE_HEADER Header
Definition: stream.h:26
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
void * PVOID
Definition: retypes.h:9
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PDEVICE_OBJECT PhysicalDeviceObject
Definition: stream.h:28
struct STREAM_DEVICE_EXTENSION * PSTREAM_DEVICE_EXTENSION
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static const WCHAR L[]
Definition: oid.c:1250
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
_In_z_ PCCHAR _In_ PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:982
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1872
NTSTATUS NTAPI StreamClassAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: driver.c:13
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define FILE_DEVICE_KS
Definition: winioctl.h:152
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
PSTREAM_CLASS_DRIVER_EXTENSION DriverExtension
Definition: stream.h:44
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
PDEVICE_OBJECT LowerDeviceObject
Definition: stream.h:27
LIST_ENTRY MemoryResourceList
Definition: stream.h:40
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by StreamClassAddDevice(), StreamClassRegisterAdapter(), and StreamClassStartDevice().

◆ StreamClassCleanup()

NTSTATUS NTAPI StreamClassCleanup ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 39 of file control.c.

42 {
43  Irp->IoStatus.Information = 0;
44  Irp->IoStatus.Status = STATUS_SUCCESS;
46  return STATUS_SUCCESS;
47 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by StreamClassRegisterAdapter().

◆ StreamClassCreateFilter()

NTSTATUS NTAPI StreamClassCreateFilter ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 261 of file filter.c.

264 {
266  DPRINT1("StreamClassCreateFilter Called\n");
267 
268  /* Init filter */
270 
271  Irp->IoStatus.Status = Status;
272  Irp->IoStatus.Information = 0;
274  return Status;
275 }
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS InitializeFilterWithKs(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: filter.c:150
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8
#define IO_NO_INCREMENT
Definition: iotypes.h:581

Referenced by StreamClassAddDevice().

◆ StreamClassDeviceControl()

NTSTATUS NTAPI StreamClassDeviceControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 63 of file control.c.

66 {
67  Irp->IoStatus.Information = 0;
68  Irp->IoStatus.Status = STATUS_SUCCESS;
70  return STATUS_SUCCESS;
71 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by StreamClassRegisterAdapter().

◆ StreamClassFlushBuffers()

NTSTATUS NTAPI StreamClassFlushBuffers ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 51 of file control.c.

54 {
55  Irp->IoStatus.Information = 0;
56  Irp->IoStatus.Status = STATUS_SUCCESS;
58  return STATUS_SUCCESS;
59 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by StreamClassRegisterAdapter().

◆ StreamClassInterruptDpc()

VOID NTAPI StreamClassInterruptDpc ( IN PKDPC  Dpc,
IN PVOID  DeferredContext,
IN PVOID  SystemArgument1,
IN PVOID  SystemArgument2 
)

Definition at line 74 of file pnp.c.

79 {
80  //TODO
81  //read/write data
82 }

Referenced by StreamClassAddDevice().

◆ StreamClassInterruptRoutine()

BOOLEAN NTAPI StreamClassInterruptRoutine ( IN PKINTERRUPT  Interrupt,
IN PVOID  ServiceContext 
)

Definition at line 87 of file pnp.c.

90 {
91  BOOLEAN Ret = FALSE;
93 
94  /* Does the driver implement HwInterrupt routine */
95  if (DeviceExtension->DriverExtension->Data.HwInterrupt)
96  {
97  /* Check if the interrupt was coming from this device */
98  Ret = DeviceExtension->DriverExtension->Data.HwInterrupt(DeviceExtension->DeviceExtension);
99  if (Ret)
100  {
101  /* Interrupt has from this device, schedule a Dpc for us */
102  KeInsertQueueDpc(&DeviceExtension->InterruptDpc, NULL, NULL);
103  }
104  }
105  /* Return result */
106  return Ret;
107 }
HW_INITIALIZATION_DATA Data
Definition: stream.h:13
BOOLEAN NTAPI KeInsertQueueDpc(IN PKDPC Dpc, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: dpc.c:724
#define FALSE
Definition: types.h:117
PHW_INTERRUPT HwInterrupt
Definition: srb.h:561
unsigned char BOOLEAN
struct STREAM_DEVICE_EXTENSION * PSTREAM_DEVICE_EXTENSION
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID ServiceContext
Definition: iofuncs.h:798
#define NULL
Definition: types.h:112
PSTREAM_CLASS_DRIVER_EXTENSION DriverExtension
Definition: stream.h:44

Referenced by StreamClassStartDevice().

◆ StreamClassPnp()

NTSTATUS NTAPI StreamClassPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 448 of file pnp.c.

451 {
452  PIO_STACK_LOCATION IoStack;
453 
454  /* Get current irp stack location */
456 
457  switch (IoStack->MinorFunction)
458  {
459  case IRP_MN_START_DEVICE:
460  {
462  }
463  }
464 
466  return STATUS_NOT_SUPPORTED;
467 }
return STATUS_NOT_SUPPORTED
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
NTSTATUS NTAPI StreamClassStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pnp.c:113
#define IRP_MN_START_DEVICE
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define IO_NO_INCREMENT
Definition: iotypes.h:581

Referenced by StreamClassRegisterAdapter().

◆ StreamClassPower()

NTSTATUS NTAPI StreamClassPower ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 15 of file control.c.

18 {
19  Irp->IoStatus.Information = 0;
20  Irp->IoStatus.Status = STATUS_SUCCESS;
22  return STATUS_SUCCESS;
23 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by StreamClassRegisterAdapter().

◆ StreamClassSynchronize()

BOOLEAN NTAPI StreamClassSynchronize ( IN PKINTERRUPT  Interrupt,
IN PKSYNCHRONIZE_ROUTINE  SynchronizeRoutine,
IN PVOID  SynchronizeContext 
)

Definition at line 61 of file pnp.c.

65 {
66  /* This function is used when the driver either implements synchronization on its own
67  * or if there is no interrupt assigned
68  */
70 }
_In_ PKSYNCHRONIZE_ROUTINE SynchronizeRoutine
Definition: kefuncs.h:536
_In_ PKSYNCHRONIZE_ROUTINE _In_opt_ __drv_aliasesMem PVOID SynchronizeContext
Definition: kefuncs.h:536

Referenced by StreamClassStartDevice().

◆ StreamClassSystemControl()

NTSTATUS NTAPI StreamClassSystemControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 27 of file control.c.

30 {
31  Irp->IoStatus.Information = 0;
32  Irp->IoStatus.Status = STATUS_SUCCESS;
34  return STATUS_SUCCESS;
35 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by StreamClassRegisterAdapter().