ReactOS  0.4.14-dev-50-g13bb5e2
device.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for device.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI IKsDevice_fnQueryInterface (IN IKsDevice *iface, REFIID refiid, PVOID *Output)
 
ULONG NTAPI IKsDevice_fnAddRef (IN IKsDevice *iface)
 
ULONG NTAPI IKsDevice_fnRelease (IN IKsDevice *iface)
 
PKSDEVICE NTAPI IKsDevice_fnGetStruct (IN IKsDevice *iface)
 
NTSTATUS NTAPI IKsDevice_fnInitializeObjectBag (IN IKsDevice *iface, IN PKSIOBJECT_BAG Bag, IN PRKMUTEX Mutex)
 
NTSTATUS NTAPI IKsDevice_fnAcquireDevice (IN IKsDevice *iface)
 
NTSTATUS NTAPI IKsDevice_fnReleaseDevice (IN IKsDevice *iface)
 
NTSTATUS NTAPI IKsDevice_fnGetAdapterObject (IN IKsDevice *iface, IN PADAPTER_OBJECT *Object, IN PULONG MaxMappingsByteCount, IN PULONG MappingTableStride)
 
NTSTATUS NTAPI IKsDevice_fnAddPowerEntry (IN IKsDevice *iface, IN struct KSPOWER_ENTRY *Entry, IN IKsPowerNotify *Notify)
 
NTSTATUS NTAPI IKsDevice_fnRemovePowerEntry (IN IKsDevice *iface, IN struct KSPOWER_ENTRY *Entry)
 
NTSTATUS NTAPI IKsDevice_fnPinStateChange (IN IKsDevice *iface, IN KSPIN Pin, IN PIRP Irp, IN KSSTATE OldState, IN KSSTATE NewState)
 
NTSTATUS NTAPI IKsDevice_fnArbitrateAdapterChannel (IN IKsDevice *iface, IN ULONG NumberOfMapRegisters, IN PDRIVER_CONTROL ExecutionRoutine, IN PVOID Context)
 
NTSTATUS NTAPI IKsDevice_fnCheckIoCapability (IN IKsDevice *iface, IN ULONG Unknown)
 
VOID NTAPI IKsDevice_PnpPostStart (IN PDEVICE_OBJECT DeviceObject, IN PVOID Context)
 
NTSTATUS NTAPI IKsDevice_PnpStartDevice (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IKsDevice_Pnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IKsDevice_Power (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IKsDevice_Create (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
KSDDKAPI NTSTATUS NTAPI KsInitializeDevice (IN PDEVICE_OBJECT FunctionalDeviceObject, IN PDEVICE_OBJECT PhysicalDeviceObject, IN PDEVICE_OBJECT NextDeviceObject, IN const KSDEVICE_DESCRIPTOR *Descriptor OPTIONAL)
 
KSDDKAPI NTSTATUS NTAPI KsReferenceSoftwareBusObject (IN KSDEVICE_HEADER Header)
 
KSDDKAPI NTSTATUS NTAPI KsReferenceBusObject (IN KSDEVICE_HEADER Header)
 
KSDDKAPI VOID NTAPI KsDereferenceBusObject (IN KSDEVICE_HEADER Header)
 
KSDDKAPI VOID NTAPI KsDereferenceSoftwareBusObject (IN KSDEVICE_HEADER Header)
 

Variables

static IKsDeviceVtbl vt_IKsDevice
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file device.c.

Function Documentation

◆ IKsDevice_Create()

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

Definition at line 591 of file device.c.

594 {
595  PCREATE_ITEM_ENTRY CreateItemEntry;
596  PIO_STACK_LOCATION IoStack;
597  PDEVICE_EXTENSION DeviceExtension;
598  PKSIDEVICE_HEADER DeviceHeader;
599  PKSIOBJECT_HEADER ObjectHeader;
601 
602  DPRINT("IKsDevice_Create\n");
603  /* get current stack location */
605  /* get device extension */
606  DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
607  /* get device header */
608  DeviceHeader = DeviceExtension->DeviceHeader;
609 
610  if (IoStack->FileObject->FileName.Buffer == NULL)
611  {
612  // ReactOS PnPMgr still sucks
613  ASSERT(IoStack->FileObject->FileName.Length == 0);
614  Irp->IoStatus.Status = STATUS_SUCCESS;
616  DPRINT1("ReactOS PnP hack\n");
617  return STATUS_SUCCESS;
618  }
619 
620  /* acquire list lock */
621  IKsDevice_fnAcquireDevice((IKsDevice*)&DeviceHeader->BasicHeader.OuterUnknown);
622 
623  /* sanity check */
624  ASSERT(IoStack->FileObject);
625 
626  /* check if the request is relative */
627  if (IoStack->FileObject->RelatedFileObject != NULL)
628  {
629  /* request is to instantiate a pin / node / clock / allocator */
630  ObjectHeader = (PKSIOBJECT_HEADER)IoStack->FileObject->RelatedFileObject->FsContext2;
631 
632  /* sanity check */
633  ASSERT(ObjectHeader);
634 
635  /* find a matching a create item */
636  Status = FindMatchingCreateItem(&ObjectHeader->ItemList,
637  &IoStack->FileObject->FileName,
638  &CreateItemEntry);
639  }
640  else
641  {
642  /* request to create a filter */
643  Status = FindMatchingCreateItem(&DeviceHeader->ItemList,
644  &IoStack->FileObject->FileName,
645  &CreateItemEntry);
646  }
647 
648  if (NT_SUCCESS(Status))
649  {
650  /* set object create item */
651  KSCREATE_ITEM_IRP_STORAGE(Irp) = CreateItemEntry->CreateItem;
652 
653  /* call create function */
654  Status = CreateItemEntry->CreateItem->Create(DeviceObject, Irp);
655 
656  if (NT_SUCCESS(Status))
657  {
658  /* increment create item reference count */
659  InterlockedIncrement(&CreateItemEntry->ReferenceCount);
660  }
661  }
662 
663  /* release list lock */
664  IKsDevice_fnReleaseDevice((IKsDevice*)&DeviceHeader->BasicHeader.OuterUnknown);
665 
666  /* done */
667  return Status;
668 
669 
670 }
_In_ PIRP Irp
Definition: csq.h:116
struct KSIOBJECT_HEADER * PKSIOBJECT_HEADER
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IKsDevice_fnReleaseDevice(IN IKsDevice *iface)
Definition: device.c:119
PUNKNOWN OuterUnknown
Definition: kstypes.h:62
Definition: kstypes.h:45
PKSOBJECT_CREATE_ITEM CreateItem
Definition: kstypes.h:48
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
NTSTATUS NTAPI IKsDevice_fnAcquireDevice(IN IKsDevice *iface)
Definition: device.c:109
void DPRINT(...)
Definition: polytest.cpp:61
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
KSBASIC_HEADER BasicHeader
Definition: kstypes.h:87
LIST_ENTRY ItemList
Definition: kstypes.h:26
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
#define InterlockedIncrement
Definition: armddk.h:53
LONG ReferenceCount
Definition: kstypes.h:50
NTSTATUS FindMatchingCreateItem(PLIST_ENTRY ListHead, PUNICODE_STRING String, OUT PCREATE_ITEM_ENTRY *OutCreateItem)
Definition: irp.c:1750
#define DPRINT1
Definition: precomp.h:8
LIST_ENTRY ItemList
Definition: kstypes.h:94
#define IO_NO_INCREMENT
Definition: iotypes.h:566
return STATUS_SUCCESS
Definition: btrfs.c:2966
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION

Referenced by KsDispatchIrp(), and KsInitializeDriver().

◆ IKsDevice_fnAcquireDevice()

NTSTATUS NTAPI IKsDevice_fnAcquireDevice ( IN IKsDevice *  iface)

Definition at line 109 of file device.c.

111 {
112  PKSIDEVICE_HEADER This = (PKSIDEVICE_HEADER)CONTAINING_RECORD(iface, KSIDEVICE_HEADER, BasicHeader.OuterUnknown);
113 
114  return KeWaitForSingleObject(&This->DeviceMutex, Executive, KernelMode, FALSE, NULL);
115 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
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
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by IKsDevice_Create().

◆ IKsDevice_fnAddPowerEntry()

NTSTATUS NTAPI IKsDevice_fnAddPowerEntry ( IN IKsDevice *  iface,
IN struct KSPOWER_ENTRY *  Entry,
IN IKsPowerNotify *  Notify 
)

Definition at line 147 of file device.c.

151 {
152  //PKSIDEVICE_HEADER This = (PKSIDEVICE_HEADER)CONTAINING_RECORD(iface, KSIDEVICE_HEADER, BasicHeader.OuterUnknown);
153 
155  return STATUS_NOT_IMPLEMENTED;
156 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNIMPLEMENTED
Definition: debug.h:114

◆ IKsDevice_fnAddRef()

ULONG NTAPI IKsDevice_fnAddRef ( IN IKsDevice *  iface)

Definition at line 49 of file device.c.

51 {
52  PKSIDEVICE_HEADER This = (PKSIDEVICE_HEADER)CONTAINING_RECORD(iface, KSIDEVICE_HEADER, BasicHeader.OuterUnknown);
53 
54  return InterlockedIncrement(&This->ref);
55 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define InterlockedIncrement
Definition: armddk.h:53

◆ IKsDevice_fnArbitrateAdapterChannel()

NTSTATUS NTAPI IKsDevice_fnArbitrateAdapterChannel ( IN IKsDevice *  iface,
IN ULONG  NumberOfMapRegisters,
IN PDRIVER_CONTROL  ExecutionRoutine,
IN PVOID  Context 
)

Definition at line 189 of file device.c.

194 {
195  PKSIDEVICE_HEADER This = (PKSIDEVICE_HEADER)CONTAINING_RECORD(iface, KSIDEVICE_HEADER, BasicHeader.OuterUnknown);
197 
198  DPRINT("IKsDevice_fnArbitrateAdapterChannel NumberOfMapRegisters %lu ExecutionRoutine %p Context %p Irql %lu\n", NumberOfMapRegisters, ExecutionRoutine, Context, KeGetCurrentIrql());
199 
200  /* sanity check */
202  ASSERT(This->AdapterObject);
203 
204  /* allocate adapter channel */
205  Status = IoAllocateAdapterChannel(This->AdapterObject, This->KsDevice.FunctionalDeviceObject, NumberOfMapRegisters, ExecutionRoutine, Context);
206 
207  /* done */
208  return Status;
209 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
_Out_ PULONG NumberOfMapRegisters
Definition: halfuncs.h:209
LONG NTSTATUS
Definition: precomp.h:26
void DPRINT(...)
Definition: polytest.cpp:61
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
NTSTATUS NTAPI IoAllocateAdapterChannel(IN PADAPTER_OBJECT AdapterObject, IN PDEVICE_OBJECT DeviceObject, IN ULONG NumberOfMapRegisters, IN PDRIVER_CONTROL ExecutionRoutine, IN PVOID Context)
Definition: adapter.c:30
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
_In_ PDEVICE_OBJECT _In_ ULONG _In_ PDRIVER_CONTROL ExecutionRoutine
Definition: iofuncs.h:1393

◆ IKsDevice_fnCheckIoCapability()

NTSTATUS NTAPI IKsDevice_fnCheckIoCapability ( IN IKsDevice *  iface,
IN ULONG  Unknown 
)

Definition at line 213 of file device.c.

216 {
217  //PKSIDEVICE_HEADER This = (PKSIDEVICE_HEADER)CONTAINING_RECORD(iface, KSIDEVICE_HEADER, BasicHeader.OuterUnknown);
218 
220  return STATUS_NOT_IMPLEMENTED;
221 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNIMPLEMENTED
Definition: debug.h:114

◆ IKsDevice_fnGetAdapterObject()

NTSTATUS NTAPI IKsDevice_fnGetAdapterObject ( IN IKsDevice *  iface,
IN PADAPTER_OBJECT Object,
IN PULONG  MaxMappingsByteCount,
IN PULONG  MappingTableStride 
)

Definition at line 129 of file device.c.

134 {
135  PKSIDEVICE_HEADER This = (PKSIDEVICE_HEADER)CONTAINING_RECORD(iface, KSIDEVICE_HEADER, BasicHeader.OuterUnknown);
136 
137  *Object = This->AdapterObject;
138  *MaxMappingsByteCount = This->MaxMappingsByteCount;
139  *MappingTableStride = This->MappingTableStride;
140 
141  return STATUS_SUCCESS;
142 
143 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static IUnknown Object
Definition: main.c:512
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ IKsDevice_fnGetStruct()

PKSDEVICE NTAPI IKsDevice_fnGetStruct ( IN IKsDevice *  iface)

Definition at line 73 of file device.c.

75 {
76  PKSIDEVICE_HEADER This = (PKSIDEVICE_HEADER)CONTAINING_RECORD(iface, KSIDEVICE_HEADER, BasicHeader.OuterUnknown);
77 
78  return &This->KsDevice;
79 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

◆ IKsDevice_fnInitializeObjectBag()

NTSTATUS NTAPI IKsDevice_fnInitializeObjectBag ( IN IKsDevice *  iface,
IN PKSIOBJECT_BAG  Bag,
IN PRKMUTEX  Mutex 
)

Definition at line 83 of file device.c.

87 {
88  PKSIDEVICE_HEADER This = (PKSIDEVICE_HEADER)CONTAINING_RECORD(iface, KSIDEVICE_HEADER, BasicHeader.OuterUnknown);
89 
90  if (!Mutex)
91  {
92  /* use device mutex */
93  Mutex = &This->BagMutex;
94  }
95 
96  /* initialize object bag */
97  Bag->BagMutex = Mutex;
98  Bag->DeviceHeader = (PKSIDEVICE_HEADER)This;
99  InitializeListHead(&Bag->ObjectList);
100 
101  /* insert bag into device list */
102  InsertTailList(&This->ObjectBags, &Bag->Entry);
103 
104  return STATUS_SUCCESS;
105 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
#define InsertTailList(ListHead, Entry)
Definition: Mutex.h:15
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
static PFAST_MUTEX Mutex
Definition: timer.c:22
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ IKsDevice_fnPinStateChange()

NTSTATUS NTAPI IKsDevice_fnPinStateChange ( IN IKsDevice *  iface,
IN KSPIN  Pin,
IN PIRP  Irp,
IN KSSTATE  OldState,
IN KSSTATE  NewState 
)

Definition at line 173 of file device.c.

179 {
180  //PKSIDEVICE_HEADER This = (PKSIDEVICE_HEADER)CONTAINING_RECORD(iface, KSIDEVICE_HEADER, BasicHeader.OuterUnknown);
181 
183  return STATUS_NOT_IMPLEMENTED;
184 
185 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNIMPLEMENTED
Definition: debug.h:114

◆ IKsDevice_fnQueryInterface()

NTSTATUS NTAPI IKsDevice_fnQueryInterface ( IN IKsDevice *  iface,
REFIID  refiid,
PVOID Output 
)

Definition at line 16 of file device.c.

20 {
22  PKSIDEVICE_HEADER This = (PKSIDEVICE_HEADER)CONTAINING_RECORD(iface, KSIDEVICE_HEADER, BasicHeader.OuterUnknown);
23 
24  if (IsEqualGUIDAligned(refiid, &IID_IUnknown))
25  {
26  *Output = &This->BasicHeader.OuterUnknown;
28  return STATUS_SUCCESS;
29  }
30 
31  if (This->BasicHeader.ClientAggregate)
32  {
33  /* using client aggregate */
34  Status = This->BasicHeader.ClientAggregate->lpVtbl->QueryInterface(This->BasicHeader.ClientAggregate, refiid, Output);
35 
36  if (NT_SUCCESS(Status))
37  {
38  /* client aggregate supports interface */
39  return Status;
40  }
41  }
42 
43  DPRINT("IKsDevice_fnQueryInterface no interface\n");
44  return STATUS_NOT_SUPPORTED;
45 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
LONG NTSTATUS
Definition: precomp.h:26
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
long __cdecl _InterlockedIncrement(_Interlocked_operand_ long volatile *_Addend)
void DPRINT(...)
Definition: polytest.cpp:61
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
const GUID IID_IUnknown
Definition: arc.h:85
Status
Definition: gdiplustypes.h:24
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ IKsDevice_fnRelease()

ULONG NTAPI IKsDevice_fnRelease ( IN IKsDevice *  iface)

Definition at line 59 of file device.c.

61 {
62  PKSIDEVICE_HEADER This = (PKSIDEVICE_HEADER)CONTAINING_RECORD(iface, KSIDEVICE_HEADER, BasicHeader.OuterUnknown);
63 
65 
66  return This->ref;
67 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define InterlockedDecrement
Definition: armddk.h:52

◆ IKsDevice_fnReleaseDevice()

NTSTATUS NTAPI IKsDevice_fnReleaseDevice ( IN IKsDevice *  iface)

Definition at line 119 of file device.c.

121 {
122  PKSIDEVICE_HEADER This = (PKSIDEVICE_HEADER)CONTAINING_RECORD(iface, KSIDEVICE_HEADER, BasicHeader.OuterUnknown);
123 
124  return KeReleaseMutex(&This->DeviceMutex, FALSE);
125 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
Definition: mutex.c:189
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by IKsDevice_Create().

◆ IKsDevice_fnRemovePowerEntry()

NTSTATUS NTAPI IKsDevice_fnRemovePowerEntry ( IN IKsDevice *  iface,
IN struct KSPOWER_ENTRY *  Entry 
)

Definition at line 160 of file device.c.

163 {
164  //PKSIDEVICE_HEADER This = (PKSIDEVICE_HEADER)CONTAINING_RECORD(iface, KSIDEVICE_HEADER, BasicHeader.OuterUnknown);
165 
167  return STATUS_NOT_IMPLEMENTED;
168 
169 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNIMPLEMENTED
Definition: debug.h:114

◆ IKsDevice_Pnp()

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

Definition at line 406 of file device.c.

409 {
410  PIO_STACK_LOCATION IoStack;
411  PDEVICE_EXTENSION DeviceExtension;
412  PKSIDEVICE_HEADER DeviceHeader;
413  PKSDEVICE_DISPATCH Dispatch = NULL;
415 
416  /* get current stack location */
418 
419  /* get device extension */
420  DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
421  /* get device header */
422  DeviceHeader = DeviceExtension->DeviceHeader;
423 
424  /* do we have a device descriptor */
425  if (DeviceHeader->KsDevice.Descriptor && DeviceHeader->KsDevice.Descriptor->Dispatch)
426  {
427  /* does the device want pnp notifications */
428  Dispatch = (PKSDEVICE_DISPATCH)DeviceHeader->KsDevice.Descriptor->Dispatch;
429  }
430 
431  switch (IoStack->MinorFunction)
432  {
433  case IRP_MN_START_DEVICE:
434  {
436  }
437 
439  {
441  /* check for pnp notification support */
442  if (Dispatch)
443  {
444  /* check for query stop support */
445  if (Dispatch->QueryStop)
446  {
447  /* call driver's query stop */
448  Status = Dispatch->QueryStop(&DeviceHeader->KsDevice, Irp);
450  }
451  }
452 
453  if (!NT_SUCCESS(Status))
454  {
455  DPRINT1("Driver: query stop failed %x\n", Status);
456  Irp->IoStatus.Status = Status;
458  return Status;
459  }
460 
461  /* pass the irp down the driver stack */
463 
464  DPRINT("Next Device: Status %x\n", Status);
465 
466  Irp->IoStatus.Status = Status;
468  return Status;
469  }
470 
472  {
473  /* Clean up */
474  if (Dispatch)
475  {
476  /* check for remove support */
477  if (Dispatch->Remove)
478  {
479  /* call driver's stop routine */
480  Dispatch->Remove(&DeviceHeader->KsDevice, Irp);
481  }
482  }
483 
484  /* pass the irp down the driver stack */
486 
487  DPRINT("Next Device: Status %x\n", Status);
488 
489  /* FIXME delete device resources */
490 
491 
492  Irp->IoStatus.Status = Status;
494  return Status;
495  }
497  {
499  /* check for pnp notification support */
500  if (Dispatch)
501  {
502  /* check for query interface support */
503  if (Dispatch->QueryInterface)
504  {
505  /* call driver's query interface */
506  Status = Dispatch->QueryInterface(&DeviceHeader->KsDevice, Irp);
508  }
509  }
510 
511  if (NT_SUCCESS(Status))
512  {
513  /* driver supports a private interface */
514  DPRINT1("IRP_MN_QUERY_INTERFACE Device supports interface\n");
515  Irp->IoStatus.Status = Status;
517  return Status;
518  }
519 
520  /* pass the irp down the driver stack */
522 
523  DPRINT1("IRP_MN_QUERY_INTERFACE Next Device: Status %x\n", Status);
524  Irp->IoStatus.Status = Status;
526  return Status;
527  }
529  {
530  /* pass the irp down the driver stack */
532 
533  DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS Next Device: Status %x\n", Status);
534 
535  //Irp->IoStatus.Status = Status;
537  return Status;
538  }
540  {
541  /* pass the irp down the driver stack */
542  //Status = KspForwardIrpSynchronous(DeviceObject, Irp);
543  Status = Irp->IoStatus.Status;
544  DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS Next Device: Status %x\n", Status);
545 
546  //Irp->IoStatus.Status = Status;
548  return Status;
549  }
551  {
552  /* pass the irp down the driver stack */
554 
555  DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS Next Device: Status %x\n", Status);
556 
557  Irp->IoStatus.Status = Status;
559  return Status;
560  }
561  default:
562  DPRINT1("unhandled function %u\n", IoStack->MinorFunction);
563  /* pass the irp down the driver stack */
565 
566  Irp->IoStatus.Status = Status;
568  return Status;
569  }
570 }
#define IRP_MN_REMOVE_DEVICE
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IKsDevice_PnpStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: device.c:276
KSDEVICE KsDevice
Definition: kstypes.h:88
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define IRP_MN_QUERY_STOP_DEVICE
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_INTERFACE
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH * Dispatch
Definition: wsk.h:182
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define DPRINT1
Definition: precomp.h:8
#define IO_NO_INCREMENT
Definition: iotypes.h:566
NTSTATUS KspForwardIrpSynchronous(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: misc.c:65
return STATUS_SUCCESS
Definition: btrfs.c:2966
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION

Referenced by KsDispatchIrp(), and KsInitializeDriver().

◆ IKsDevice_PnpPostStart()

VOID NTAPI IKsDevice_PnpPostStart ( IN PDEVICE_OBJECT  DeviceObject,
IN PVOID  Context 
)

Definition at line 243 of file device.c.

246 {
249 
250  /* call driver pnp post routine */
251  Status = Ctx->DeviceHeader->KsDevice.Descriptor->Dispatch->PostStart(&Ctx->DeviceHeader->KsDevice);
252 
253  if (!NT_SUCCESS(Status))
254  {
255  /* set state to disabled */
257  }
258  else
259  {
260  /* set state to enabled */
263  }
264 
265  /* free work item */
266  IoFreeWorkItem(Ctx->WorkItem);
267 
268  /* free work context */
269  FreeItem(Ctx);
270 
271  DPRINT("IKsDevice_PnpPostStart: PostStart Routine returned %x\n", Status);
272 }
PIO_WORKITEM WorkItem
Definition: kstypes.h:131
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
Definition: iowork.c:64
KSDEVICE KsDevice
Definition: kstypes.h:88
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS KspSetFilterFactoriesState(IN PKSIDEVICE_HEADER DeviceHeader, IN BOOLEAN NewState)
PKSIDEVICE_HEADER DeviceHeader
Definition: kstypes.h:130
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
KSTARGET_STATE TargetState
Definition: kstypes.h:100
Status
Definition: gdiplustypes.h:24
struct PNP_POSTSTART_CONTEXT * PPNP_POSTSTART_CONTEXT

Referenced by IKsDevice_PnpStartDevice().

◆ IKsDevice_PnpStartDevice()

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

Definition at line 276 of file device.c.

279 {
280  PIO_STACK_LOCATION IoStack;
281  PDEVICE_EXTENSION DeviceExtension;
282  PKSIDEVICE_HEADER DeviceHeader;
285  PCM_RESOURCE_LIST TranslatedResourceList;
286  PCM_RESOURCE_LIST UntranslatedResourceList;
287 
288  /* get current stack location */
290  /* get device extension */
291  DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
292  /* get device header */
293  DeviceHeader = DeviceExtension->DeviceHeader;
294 
295  DPRINT("IKsDevice_PnpStartDevice DeviceHeader %p\n", DeviceHeader);
296 
297  /* first forward irp to lower device object */
299 
300  /* check for success */
301  if (!NT_SUCCESS(Status))
302  {
303  DPRINT1("NextDevice object failed to start with %x\n", Status);
304  Irp->IoStatus.Status = Status;
306  return Status;
307  }
308 
309  TranslatedResourceList = IoStack->Parameters.StartDevice.AllocatedResourcesTranslated;
310  UntranslatedResourceList = IoStack->Parameters.StartDevice.AllocatedResources;
311 
312  ASSERT(DeviceHeader->KsDevice.Descriptor);
313 
314  /* do we have a device descriptor */
315  if (DeviceHeader->KsDevice.Descriptor)
316  {
317  /* does the device want pnp notifications */
318  if (DeviceHeader->KsDevice.Descriptor->Dispatch)
319  {
320  /* does the driver care about IRP_MN_START_DEVICE */
321  if (DeviceHeader->KsDevice.Descriptor->Dispatch->Start)
322  {
323  /* call driver start device routine */
324  Status = DeviceHeader->KsDevice.Descriptor->Dispatch->Start(&DeviceHeader->KsDevice, Irp,
325  TranslatedResourceList,
326  UntranslatedResourceList);
327 
328 
329  DPRINT("IKsDevice_PnpStartDevice Start %p, Context %p\n", DeviceHeader->KsDevice.Descriptor->Dispatch->Start, DeviceHeader->KsDevice.Context);
331 
332  if (!NT_SUCCESS(Status))
333  {
334  DPRINT1("Driver: failed to start %x\n", Status);
335  Irp->IoStatus.Status = Status;
337  return Status;
338  }
339 
340  /* set state to run */
341  DeviceHeader->KsDevice.Started = TRUE;
342 
343  }
344 
345  /* does the driver need post start routine */
346  if (DeviceHeader->KsDevice.Descriptor->Dispatch->PostStart)
347  {
348  /* allocate pnp post workitem context */
350  if (!Ctx)
351  {
352  /* no memory */
354  }
355  else
356  {
357  /* allocate a work item */
359 
360  if (!Ctx->WorkItem)
361  {
362  /* no memory */
363  FreeItem(Ctx);
364  Ctx = NULL;
366  }
367  else
368  {
369  /* store device header for post-start pnp processing */
370  Ctx->DeviceHeader = DeviceHeader;
371  }
372  }
373  }
374  else
375  {
376  /* set state to enabled, IRP_MJ_CREATE request may now succeed */
377  DeviceHeader->TargetState = KSTARGET_STATE_ENABLED;
378  Status = KspSetFilterFactoriesState(DeviceHeader, TRUE);
379  }
380  }
381  else
382  {
383  /* set state to run */
384  DeviceHeader->KsDevice.Started = TRUE;
385  }
386  }
387 
388  /* store result */
389  Irp->IoStatus.Status = Status;
390  /* complete request */
392 
393  if (Ctx)
394  {
395  /* queue a work item for driver post start routine */
397  }
398 
399  /* return result */
400  DPRINT("IKsDevice_PnpStartDevice Status %x PostStartRoutine %p\n", Status, Ctx);
401  return Status;
402 }
PIO_WORKITEM WorkItem
Definition: kstypes.h:131
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
Definition: iowork.c:75
KSDEVICE KsDevice
Definition: kstypes.h:88
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS KspSetFilterFactoriesState(IN PKSIDEVICE_HEADER DeviceHeader, IN BOOLEAN NewState)
PKSIDEVICE_HEADER DeviceHeader
Definition: kstypes.h:130
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID NTAPI IKsDevice_PnpPostStart(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context)
Definition: device.c:243
KSTARGET_STATE TargetState
Definition: kstypes.h:100
Status
Definition: gdiplustypes.h:24
VOID NTAPI IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, IN WORK_QUEUE_TYPE QueueType, IN PVOID Context)
Definition: iowork.c:40
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
struct PNP_POSTSTART_CONTEXT * PPNP_POSTSTART_CONTEXT
#define DPRINT1
Definition: precomp.h:8
#define IO_NO_INCREMENT
Definition: iotypes.h:566
NTSTATUS KspForwardIrpSynchronous(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: misc.c:65
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION

Referenced by IKsDevice_Pnp().

◆ IKsDevice_Power()

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

Definition at line 574 of file device.c.

577 {
579 
580  /* TODO */
581 
582  Irp->IoStatus.Status = STATUS_SUCCESS;
583  Irp->IoStatus.Information = 0;
585 
586  return STATUS_SUCCESS;
587 }
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define UNIMPLEMENTED
Definition: debug.h:114
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by KsDispatchIrp(), and KsInitializeDriver().

◆ KsDereferenceBusObject()

KSDDKAPI VOID NTAPI KsDereferenceBusObject ( IN KSDEVICE_HEADER  Header)

Definition at line 854 of file device.c.

856 {
857  IKsDevice * Device;
859 
860  /* get device interface */
861  Device = (IKsDevice*)DeviceHeader->BasicHeader.OuterUnknown;
862 
863  if (Device)
864  {
865  /* release device interface */
866  Device->lpVtbl->Release(Device);
867  }
868 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
PUNKNOWN OuterUnknown
Definition: kstypes.h:62
Definition: Header.h:8
if(!(yy_init))
Definition: macro.lex.yy.c:714
nsrefcnt Release()
KSBASIC_HEADER BasicHeader
Definition: kstypes.h:87

Referenced by KopDispatchClose().

◆ KsDereferenceSoftwareBusObject()

KSDDKAPI VOID NTAPI KsDereferenceSoftwareBusObject ( IN KSDEVICE_HEADER  Header)

Definition at line 876 of file device.c.

878 {
879  IKsDevice * Device;
881 
882  DPRINT("KsDereferenceSoftwareBusObject DeviceHeader %p\n", Header);
883 
884  /* get device interface */
885  Device = (IKsDevice*)DeviceHeader->BasicHeader.OuterUnknown;
886 
887  if (Device)
888  {
889  /* release device interface */
890  Device->lpVtbl->Release(Device);
891  }
892 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
PUNKNOWN OuterUnknown
Definition: kstypes.h:62
Definition: Header.h:8
void DPRINT(...)
Definition: polytest.cpp:61
if(!(yy_init))
Definition: macro.lex.yy.c:714
nsrefcnt Release()
KSBASIC_HEADER BasicHeader
Definition: kstypes.h:87

Referenced by DispatchCreateKMix(), and WdmAudClose().

◆ KsInitializeDevice()

KSDDKAPI NTSTATUS NTAPI KsInitializeDevice ( IN PDEVICE_OBJECT  FunctionalDeviceObject,
IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN PDEVICE_OBJECT  NextDeviceObject,
IN const KSDEVICE_DESCRIPTOR *Descriptor  OPTIONAL 
)

Definition at line 678 of file device.c.

683 {
684  PDEVICE_EXTENSION DeviceExtension;
686  ULONG Index;
687  PKSIOBJECT_BAG Bag;
689 
690  DPRINT1("KsInitializeDevice Descriptor %p\n", Descriptor);
691 
692  /* get device extension */
694 
695  /* first allocate device header */
696  Status = KsAllocateDeviceHeader((KSDEVICE_HEADER*)&DeviceExtension->DeviceHeader, 0, NULL);
697 
698  /* point to allocated header */
699  Header = DeviceExtension->DeviceHeader;
700 
701  DPRINT1("DeviceHeader %p\n", DeviceExtension->DeviceHeader);
702 
703  if (Descriptor && Descriptor->Dispatch)
704  {
705  DPRINT("Descriptor Add %p\n", Descriptor->Dispatch->Add);
706  DPRINT("Descriptor Start %p\n", Descriptor->Dispatch->Start);
707  DPRINT("Descriptor PostStart %p\n", Descriptor->Dispatch->PostStart);
708  DPRINT("Descriptor QueryStop %p\n", Descriptor->Dispatch->QueryStop);
709  DPRINT("Descriptor CancelStop %p\n", Descriptor->Dispatch->CancelStop);
710  DPRINT("Descriptor Stop %p\n", Descriptor->Dispatch->Stop);
711  DPRINT("Descriptor QueryRemove %p\n", Descriptor->Dispatch->QueryRemove);
712  DPRINT("Descriptor CancelRemove %p\n", Descriptor->Dispatch->CancelRemove);
713  DPRINT("Descriptor Remove %p\n", Descriptor->Dispatch->Remove);
714  DPRINT("Descriptor QueryCapabilities %p\n", Descriptor->Dispatch->QueryCapabilities);
715  DPRINT("Descriptor SurpriseRemoval %p\n", Descriptor->Dispatch->SurpriseRemoval);
716  DPRINT("Descriptor QueryPower %p\n", Descriptor->Dispatch->QueryPower);
717  DPRINT("Descriptor SetPower %p\n", Descriptor->Dispatch->SetPower);
718  DPRINT("Descriptor QueryInterface %p\n", Descriptor->Dispatch->QueryInterface);
719  }
720 
721  /* check for success */
722  if (!NT_SUCCESS(Status))
723  {
724  DPRINT1("KsInitializeDevice Failed to allocate device header with %x\n", Status);
725  return Status;
726  }
727 
728  /* initialize IKsDevice interface */
729  Header->BasicHeader.OuterUnknown = (PUNKNOWN)&vt_IKsDevice;
730  Header->ref = 1;
731 
732  /* allocate object bag */
733  Header->KsDevice.Bag = AllocateItem(NonPagedPool, sizeof(KSIOBJECT_BAG));
734  if (!Header->KsDevice.Bag)
735  {
736  /* no memory */
737  KsFreeDeviceHeader((KSDEVICE_HEADER*)&DeviceExtension->DeviceHeader);
739  }
740 
741  /* initialize object bag */
742  KeInitializeMutex(&Header->BagMutex, 0);
743  KeInitializeMutex(&Header->DeviceMutex, 0);
744 
745  Bag = (PKSIOBJECT_BAG)Header->KsDevice.Bag;
746  Bag->BagMutex = &Header->BagMutex;
747  InitializeListHead(&Header->ObjectBags);
749  Bag->DeviceHeader = (PVOID)Header;
750 
751  /* insert bag into device list */
752  InsertTailList(&Header->ObjectBags, &Bag->Entry);
753 
754  /* initialize device header */
755  Header->KsDevice.FunctionalDeviceObject = FunctionalDeviceObject;
756  Header->KsDevice.PhysicalDeviceObject = PhysicalDeviceObject;
757  Header->KsDevice.NextDeviceObject = NextDeviceObject;
758  Header->KsDevice.Descriptor = Descriptor;
759  Header->KsDevice.SystemPowerState = PowerSystemWorking;
760  Header->KsDevice.DevicePowerState = PowerDeviceD0;
761  Header->KsDevice.Started = FALSE;
762  Header->KsDevice.Context = NULL;
764 
765 
766 
767  if (Descriptor)
768  {
769  /* create a filter factory for each filter descriptor */
770  DPRINT("KsInitializeDevice FilterDescriptorCount %lu\n", Descriptor->FilterDescriptorsCount);
771  for(Index = 0; Index < Descriptor->FilterDescriptorsCount; Index++)
772  {
774 
775  DPRINT("KsInitializeDevice Index %lu KspCreateFilterFactory Status %lx\n", Index, Status);
776  /* check for success */
777  if (!NT_SUCCESS(Status))
778  {
779  DPRINT1("KspCreateFilterFactory failed with %x\n", Status);
780  /* FIXME memory leak */
781  return Status;
782  }
783  }
784 
785  /* does the driver care about the add device */
786  if (Descriptor->Dispatch && Descriptor->Dispatch->Add)
787  {
788  Status = Descriptor->Dispatch->Add(&Header->KsDevice);
789  DPRINT("Driver: AddHandler Status %x\n", Status);
790  }
791 
792  Header->KsDevice.Descriptor = Descriptor;
793  }
794 
795 
796  return Status;
797 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
KSDDKAPI NTSTATUS NTAPI KsAllocateDeviceHeader(OUT KSDEVICE_HEADER *OutHeader, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList OPTIONAL)
Definition: api.c:522
KSDDKAPI VOID NTAPI KsSetDevicePnpAndBaseObject(IN KSDEVICE_HEADER Header, IN PDEVICE_OBJECT PnpDeviceObject, IN PDEVICE_OBJECT BaseDevice)
Definition: api.c:257
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
static IKsDeviceVtbl vt_IKsDevice
Definition: device.c:223
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1114
#define InsertTailList(ListHead, Entry)
struct KSIOBJECT_BAG * PKSIOBJECT_BAG
PRKMUTEX BagMutex
Definition: ksiface.h:17
Definition: Header.h:8
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
void * PVOID
Definition: retypes.h:9
NTSTATUS NTAPI KspCreateFilterFactory(IN PDEVICE_OBJECT DeviceObject, IN const KSFILTER_DESCRIPTOR *Descriptor, IN PWSTR RefString OPTIONAL, IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL, IN ULONG CreateItemFlags, IN PFNKSFILTERFACTORYPOWER SleepCallback OPTIONAL, IN PFNKSFILTERFACTORYPOWER WakeCallback OPTIONAL, OUT PKSFILTERFACTORY *FilterFactory OPTIONAL)
LIST_ENTRY ObjectList
Definition: ksiface.h:16
PVOID DeviceHeader
Definition: ksiface.h:18
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT * NextDeviceObject
Definition: ndis.h:4640
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
KSDDKAPI VOID NTAPI KsFreeDeviceHeader(IN KSDEVICE_HEADER DevHeader)
Definition: api.c:590
Status
Definition: gdiplustypes.h:24
LIST_ENTRY Entry
Definition: ksiface.h:15
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT * FunctionalDeviceObject
Definition: ndis.h:4640
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

Referenced by KsCreateDevice().

◆ KsReferenceBusObject()

KSDDKAPI NTSTATUS NTAPI KsReferenceBusObject ( IN KSDEVICE_HEADER  Header)

Definition at line 829 of file device.c.

831 {
832  IKsDevice * Device;
834 
835  /* get device interface */
836  Device = (IKsDevice*)DeviceHeader->BasicHeader.OuterUnknown;
837 
838  if (Device)
839  {
840  /* reference device interface */
841  Device->lpVtbl->AddRef(Device);
842  }
843 
844  return STATUS_SUCCESS;
845 
846 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
PUNKNOWN OuterUnknown
Definition: kstypes.h:62
Definition: Header.h:8
if(!(yy_init))
Definition: macro.lex.yy.c:714
KSBASIC_HEADER BasicHeader
Definition: kstypes.h:87
return STATUS_SUCCESS
Definition: btrfs.c:2966
nsrefcnt AddRef()

◆ KsReferenceSoftwareBusObject()

KSDDKAPI NTSTATUS NTAPI KsReferenceSoftwareBusObject ( IN KSDEVICE_HEADER  Header)

Definition at line 805 of file device.c.

807 {
808  IKsDevice * Device;
810 
811  /* get device interface */
812  Device = (IKsDevice*)DeviceHeader->BasicHeader.OuterUnknown;
813 
814  if (Device)
815  {
816  /* reference device interface */
817  Device->lpVtbl->AddRef(Device);
818  }
819 
820  return STATUS_SUCCESS;
821 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
PUNKNOWN OuterUnknown
Definition: kstypes.h:62
Definition: Header.h:8
if(!(yy_init))
Definition: macro.lex.yy.c:714
KSBASIC_HEADER BasicHeader
Definition: kstypes.h:87
return STATUS_SUCCESS
Definition: btrfs.c:2966
nsrefcnt AddRef()

Referenced by DispatchCreateKMix(), PcCreateItemDispatch(), PcCreatePinDispatch(), and WdmAudCreate().

Variable Documentation

◆ vt_IKsDevice

IKsDeviceVtbl vt_IKsDevice
static
Initial value:
=
{
}
NTSTATUS NTAPI IKsDevice_fnQueryInterface(IN IKsDevice *iface, REFIID refiid, PVOID *Output)
Definition: device.c:16
NTSTATUS NTAPI IKsDevice_fnInitializeObjectBag(IN IKsDevice *iface, IN PKSIOBJECT_BAG Bag, IN PRKMUTEX Mutex)
Definition: device.c:83
PKSDEVICE NTAPI IKsDevice_fnGetStruct(IN IKsDevice *iface)
Definition: device.c:73
ULONG NTAPI IKsDevice_fnRelease(IN IKsDevice *iface)
Definition: device.c:59
NTSTATUS NTAPI IKsDevice_fnReleaseDevice(IN IKsDevice *iface)
Definition: device.c:119
NTSTATUS NTAPI IKsDevice_fnCheckIoCapability(IN IKsDevice *iface, IN ULONG Unknown)
Definition: device.c:213
NTSTATUS NTAPI IKsDevice_fnAcquireDevice(IN IKsDevice *iface)
Definition: device.c:109
NTSTATUS NTAPI IKsDevice_fnPinStateChange(IN IKsDevice *iface, IN KSPIN Pin, IN PIRP Irp, IN KSSTATE OldState, IN KSSTATE NewState)
Definition: device.c:173
ULONG NTAPI IKsDevice_fnAddRef(IN IKsDevice *iface)
Definition: device.c:49
NTSTATUS NTAPI IKsDevice_fnArbitrateAdapterChannel(IN IKsDevice *iface, IN ULONG NumberOfMapRegisters, IN PDRIVER_CONTROL ExecutionRoutine, IN PVOID Context)
Definition: device.c:189
NTSTATUS NTAPI IKsDevice_fnGetAdapterObject(IN IKsDevice *iface, IN PADAPTER_OBJECT *Object, IN PULONG MaxMappingsByteCount, IN PULONG MappingTableStride)
Definition: device.c:129
NTSTATUS NTAPI IKsDevice_fnRemovePowerEntry(IN IKsDevice *iface, IN struct KSPOWER_ENTRY *Entry)
Definition: device.c:160
NTSTATUS NTAPI IKsDevice_fnAddPowerEntry(IN IKsDevice *iface, IN struct KSPOWER_ENTRY *Entry, IN IKsPowerNotify *Notify)
Definition: device.c:147

Definition at line 223 of file device.c.

Referenced by KsInitializeDevice().