ReactOS  0.4.13-dev-464-g6b95727
propertyhandler.cpp File Reference
#include "private.hpp"
#include <debug.h>
Include dependency graph for propertyhandler.cpp:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS HandlePropertyInstances (IN PIO_STATUS_BLOCK IoStatus, IN PKSIDENTIFIER Request, IN OUT PVOID Data, IN PSUBDEVICE_DESCRIPTOR Descriptor, IN BOOL Global, IN ISubdevice *SubDevice)
 
NTSTATUS HandleNecessaryPropertyInstances (IN PIO_STATUS_BLOCK IoStatus, IN PKSIDENTIFIER Request, IN OUT PVOID Data, IN PSUBDEVICE_DESCRIPTOR Descriptor, IN ISubdevice *SubDevice)
 
NTSTATUS HandleDataIntersection (IN PIO_STATUS_BLOCK IoStatus, IN PKSIDENTIFIER Request, IN OUT PVOID Data, IN ULONG DataLength, IN PSUBDEVICE_DESCRIPTOR Descriptor, IN ISubdevice *SubDevice)
 
NTSTATUS HandlePhysicalConnection (IN PIO_STATUS_BLOCK IoStatus, IN PKSIDENTIFIER Request, IN ULONG RequestLength, IN OUT PVOID Data, IN ULONG DataLength, IN PSUBDEVICE_DESCRIPTOR Descriptor)
 
NTSTATUS NTAPI PinPropertyHandler (IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
 
NTSTATUS NTAPI TopologyPropertyHandler (IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file propertyhandler.cpp.

Function Documentation

◆ HandleDataIntersection()

NTSTATUS HandleDataIntersection ( IN PIO_STATUS_BLOCK  IoStatus,
IN PKSIDENTIFIER  Request,
IN OUT PVOID  Data,
IN ULONG  DataLength,
IN PSUBDEVICE_DESCRIPTOR  Descriptor,
IN ISubdevice *  SubDevice 
)

Definition at line 112 of file propertyhandler.cpp.

119 {
120  KSP_PIN * Pin = (KSP_PIN*)Request;
121  PKSMULTIPLE_ITEM MultipleItem;
122  PKSDATARANGE DataRange;
124  ULONG Index, Length;
125 
126  // Access parameters
127  MultipleItem = (PKSMULTIPLE_ITEM)(Pin + 1);
128  DataRange = (PKSDATARANGE)(MultipleItem + 1);
129 
130  for(Index = 0; Index < MultipleItem->Count; Index++)
131  {
132  // Call miniport's proprietary handler
133  PC_ASSERT(Descriptor->Factory.KsPinDescriptor[Pin->PinId].DataRangesCount);
134  PC_ASSERT(Descriptor->Factory.KsPinDescriptor[Pin->PinId].DataRanges[0]);
135  Status = SubDevice->DataRangeIntersection(Pin->PinId, DataRange, (PKSDATARANGE)Descriptor->Factory.KsPinDescriptor[Pin->PinId].DataRanges[0],
136  DataLength, Data, &Length);
137 
138  if (Status == STATUS_SUCCESS)
139  {
140  IoStatus->Information = Length;
141  break;
142  }
143  DataRange = (PKSDATARANGE)((PUCHAR)DataRange + DataRange->FormatSize);
144  }
145 
146  IoStatus->Status = Status;
147  return Status;
148 }
ULONG Count
Definition: ks.h:2010
#define PC_ASSERT(exp)
Definition: usbehci.h:17
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
Definition: ks.h:672
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
struct KSMULTIPLE_ITEM * PKSMULTIPLE_ITEM
Status
Definition: gdiplustypes.h:24
union KSDATAFORMAT * PKSDATARANGE
#define STATUS_NO_MATCH
Definition: ntstatus.h:737
unsigned int ULONG
Definition: retypes.h:1
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG DataLength
Definition: hidpi.h:333
return STATUS_SUCCESS
Definition: btrfs.c:2777
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

Referenced by PinPropertyHandler().

◆ HandleNecessaryPropertyInstances()

NTSTATUS HandleNecessaryPropertyInstances ( IN PIO_STATUS_BLOCK  IoStatus,
IN PKSIDENTIFIER  Request,
IN OUT PVOID  Data,
IN PSUBDEVICE_DESCRIPTOR  Descriptor,
IN ISubdevice *  SubDevice 
)

Definition at line 72 of file propertyhandler.cpp.

78 {
79  PULONG Result;
80  KSP_PIN * Pin = (KSP_PIN*)Request;
81  ULONG FilterNecessary, FilterCurrent, FilterPossible, GlobalCurrent, GlobalPossible;
83 
84  if (Pin->PinId >= Descriptor->Factory.PinDescriptorCount)
85  {
86  IoStatus->Information = 0;
89  }
90 
91  Result = (PULONG)Data;
92 
93 
94  // check if the miniport supports the IPinCount interface
95  Status = SubDevice->PinCount(Pin->PinId, &FilterNecessary, &FilterCurrent, &FilterPossible, &GlobalCurrent, &GlobalPossible);
96 
97  if (NT_SUCCESS(Status))
98  {
99  *Result = FilterNecessary;
100  }
101  else
102  {
103  *Result = Descriptor->Factory.Instances[Pin->PinId].MinFilterInstanceCount;
104  }
105 
106  IoStatus->Information = sizeof(ULONG);
107  IoStatus->Status = STATUS_SUCCESS;
108  return STATUS_SUCCESS;
109 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
Definition: ks.h:672
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2777
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

Referenced by PinPropertyHandler().

◆ HandlePhysicalConnection()

NTSTATUS HandlePhysicalConnection ( IN PIO_STATUS_BLOCK  IoStatus,
IN PKSIDENTIFIER  Request,
IN ULONG  RequestLength,
IN OUT PVOID  Data,
IN ULONG  DataLength,
IN PSUBDEVICE_DESCRIPTOR  Descriptor 
)

Definition at line 151 of file propertyhandler.cpp.

158 {
159  PKSP_PIN Pin;
161  //PKSPIN_PHYSICALCONNECTION Connection;
163 
164  // get pin
165  Pin = (PKSP_PIN)Request;
166 
167  if (RequestLength < sizeof(KSP_PIN))
168  {
169  // input buffer must be at least sizeof KSP_PIN
170  DPRINT("input length too small\n");
172  }
173 
174  if (IsListEmpty(&Descriptor->PhysicalConnectionList))
175  {
176  DPRINT("no connection\n");
177  return STATUS_NOT_FOUND;
178  }
179 
180  // get first item
181  Entry = Descriptor->PhysicalConnectionList.Flink;
182 
183  do
184  {
186 
187  if (ConEntry->FromPin == Pin->PinId)
188  {
189  //Connection = (PKSPIN_PHYSICALCONNECTION)Data;
190  DPRINT("FoundEntry %S Size %u\n", ConEntry->Connection.SymbolicLinkName, ConEntry->Connection.Size);
191  IoStatus->Information = ConEntry->Connection.Size;
192 
193  if (!DataLength)
194  {
195  IoStatus->Information = ConEntry->Connection.Size;
196  return STATUS_MORE_ENTRIES;
197  }
198 
199  if (DataLength < ConEntry->Connection.Size)
200  {
202  }
203 
204  RtlMoveMemory(Data, &ConEntry->Connection, ConEntry->Connection.Size);
205  return STATUS_SUCCESS;
206  }
207 
208  // move to next item
209  Entry = Entry->Flink;
210  }while(Entry != &Descriptor->PhysicalConnectionList);
211 
212  IoStatus->Information = 0;
213  return STATUS_NOT_FOUND;
214 }
struct _Entry Entry
Definition: kefuncs.h:640
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
WCHAR SymbolicLinkName[1]
Definition: ks.h:688
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
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
KSPIN_PHYSICALCONNECTION Connection
Definition: interfaces.hpp:183
#define STATUS_NOT_FOUND
Definition: shellext.h:67
Definition: ks.h:672
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
struct PHYSICAL_CONNECTION_ENTRY * PPHYSICAL_CONNECTION_ENTRY
ULONG FromPin
Definition: interfaces.hpp:182
Definition: typedefs.h:117
#define STATUS_MORE_ENTRIES
Definition: udferr_usr.h:124
Definition: interfaces.hpp:179
struct KSP_PIN * PKSP_PIN
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG DataLength
Definition: hidpi.h:333
return STATUS_SUCCESS
Definition: btrfs.c:2777
base of all file and directory entries
Definition: entries.h:82
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

Referenced by PinPropertyHandler().

◆ HandlePropertyInstances()

NTSTATUS HandlePropertyInstances ( IN PIO_STATUS_BLOCK  IoStatus,
IN PKSIDENTIFIER  Request,
IN OUT PVOID  Data,
IN PSUBDEVICE_DESCRIPTOR  Descriptor,
IN BOOL  Global,
IN ISubdevice *  SubDevice 
)

Definition at line 18 of file propertyhandler.cpp.

25 {
26  KSPIN_CINSTANCES * Instances;
27  KSP_PIN * Pin = (KSP_PIN*)Request;
28  ULONG FilterNecessary, FilterCurrent, FilterPossible, GlobalCurrent, GlobalPossible;
30 
31  if (Pin->PinId >= Descriptor->Factory.PinDescriptorCount)
32  {
33  IoStatus->Information = 0;
36  }
37 
38  Instances = (KSPIN_CINSTANCES*)Data;
39 
40  // check if the miniport supports the IPinCount interface
41  Status = SubDevice->PinCount(Pin->PinId, &FilterNecessary, &FilterCurrent, &FilterPossible, &GlobalCurrent, &GlobalPossible);
42 
43  if (NT_SUCCESS(Status))
44  {
45  if (Global)
46  {
47  Instances->PossibleCount = GlobalPossible;
48  Instances->CurrentCount = GlobalCurrent;
49  }
50  else
51  {
52  Instances->PossibleCount = FilterPossible;
53  Instances->CurrentCount = FilterCurrent;
54  }
55  }
56  else
57  {
58  if (Global)
59  Instances->PossibleCount = Descriptor->Factory.Instances[Pin->PinId].MaxGlobalInstanceCount;
60  else
61  Instances->PossibleCount = Descriptor->Factory.Instances[Pin->PinId].MaxFilterInstanceCount;
62 
63  Instances->CurrentCount = Descriptor->Factory.Instances[Pin->PinId].CurrentPinInstanceCount;
64  }
65 
66  IoStatus->Information = sizeof(KSPIN_CINSTANCES);
67  IoStatus->Status = STATUS_SUCCESS;
68  return STATUS_SUCCESS;
69 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
UNICODE_STRING Global
Definition: symlink.c:37
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
Definition: ks.h:672
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG PossibleCount
Definition: ks.h:681
Status
Definition: gdiplustypes.h:24
ULONG CurrentCount
Definition: ks.h:682
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2777
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

Referenced by PinPropertyHandler().

◆ PinPropertyHandler()

NTSTATUS NTAPI PinPropertyHandler ( IN PIRP  Irp,
IN PKSIDENTIFIER  Request,
IN OUT PVOID  Data 
)

Definition at line 218 of file propertyhandler.cpp.

222 {
223  PIO_STACK_LOCATION IoStack;
224  //PKSOBJECT_CREATE_ITEM CreateItem;
226  IIrpTarget * IrpTarget;
227  IPort *Port;
228  ISubdevice *SubDevice;
229  PDISPATCH_CONTEXT DispatchContext;
230 
232 
233  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
235 
236  // get current irp stack
238 
239  // get dispatch context
240  DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
241 
242  // Get the IrpTarget
243  IrpTarget = DispatchContext->Target;
244  PC_ASSERT(IrpTarget);
245 
246  // Get the parent
247  Status = IrpTarget->QueryInterface(IID_IPort, (PVOID*)&Port);
248  if (!NT_SUCCESS(Status))
249  {
250  DPRINT("Failed to obtain IPort interface from filter\n");
251  Irp->IoStatus.Information = 0;
252  Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
253  return STATUS_UNSUCCESSFUL;
254  }
255 
256  // Get private ISubdevice interface
257  Status = Port->QueryInterface(IID_ISubdevice, (PVOID*)&SubDevice);
258  if (!NT_SUCCESS(Status))
259  {
260  DPRINT("Failed to obtain ISubdevice interface from port driver\n");
261  DbgBreakPoint();
262  while(TRUE);
263  }
264 
265  // get current stack location
267 
268  switch(Request->Id)
269  {
277  case KSPROPERTY_PIN_NAME:
279  Status = KsPinPropertyHandler(Irp, Request, Data, Descriptor->Factory.PinDescriptorCount, Descriptor->Factory.KsPinDescriptor);
280  break;
282  Status = HandlePropertyInstances(&Irp->IoStatus, Request, Data, Descriptor, TRUE, SubDevice);
283  break;
285  Status = HandlePropertyInstances(&Irp->IoStatus, Request, Data, Descriptor, FALSE, SubDevice);
286  break;
289  break;
290 
292  Status = HandleDataIntersection(&Irp->IoStatus, Request, Data, IoStack->Parameters.DeviceIoControl.OutputBufferLength, Descriptor, SubDevice);
293  break;
295  Status = HandlePhysicalConnection(&Irp->IoStatus, Request, IoStack->Parameters.DeviceIoControl.InputBufferLength, Data, IoStack->Parameters.DeviceIoControl.OutputBufferLength, Descriptor);
296  break;
300  break;
301  default:
304  }
305 
306  // Release reference
307  Port->Release();
308 
309  // Release subdevice reference
310  SubDevice->Release();
311 
312  return Status;
313 }
CPPORT Port[4]
Definition: headless.c:34
#define TRUE
Definition: types.h:120
#define PC_ASSERT(exp)
Definition: usbehci.h:17
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
void DbgBreakPoint()
Definition: mach.c:558
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
IIrpTarget * Target
Definition: private.hpp:431
void DPRINT(...)
Definition: polytest.cpp:61
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
NTSTATUS HandleNecessaryPropertyInstances(IN PIO_STATUS_BLOCK IoStatus, IN PKSIDENTIFIER Request, IN OUT PVOID Data, IN PSUBDEVICE_DESCRIPTOR Descriptor, IN ISubdevice *SubDevice)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
nsrefcnt Release()
KSDDKAPI NTSTATUS NTAPI KsPinPropertyHandler(IN PIRP Irp, IN PKSPROPERTY Property, IN OUT PVOID Data, IN ULONG DescriptorsCount, IN const KSPIN_DESCRIPTOR *Descriptor)
Definition: connectivity.c:666
NTSTATUS HandlePropertyInstances(IN PIO_STATUS_BLOCK IoStatus, IN PKSIDENTIFIER Request, IN OUT PVOID Data, IN PSUBDEVICE_DESCRIPTOR Descriptor, IN BOOL Global, IN ISubdevice *SubDevice)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS HandlePhysicalConnection(IN PIO_STATUS_BLOCK IoStatus, IN PKSIDENTIFIER Request, IN ULONG RequestLength, IN OUT PVOID Data, IN ULONG DataLength, IN PSUBDEVICE_DESCRIPTOR Descriptor)
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
#define UNIMPLEMENTED
Definition: debug.h:114
NTSTATUS HandleDataIntersection(IN PIO_STATUS_BLOCK IoStatus, IN PKSIDENTIFIER Request, IN OUT PVOID Data, IN ULONG DataLength, IN PSUBDEVICE_DESCRIPTOR Descriptor, IN ISubdevice *SubDevice)
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

◆ TopologyPropertyHandler()

NTSTATUS NTAPI TopologyPropertyHandler ( IN PIRP  Irp,
IN PKSIDENTIFIER  Request,
IN OUT PVOID  Data 
)

Definition at line 317 of file propertyhandler.cpp.

321 {
323 
324  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
325 
326  return KsTopologyPropertyHandler(Irp, Request, Data, Descriptor->Topology);
327 }
_In_ PIRP Irp
Definition: csq.h:116
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
KSDDKAPI NTSTATUS NTAPI KsTopologyPropertyHandler(IN PIRP Irp, IN PKSPROPERTY Property, IN OUT PVOID Data, IN const KSTOPOLOGY *Topology)
Definition: topology.c:144
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966